vendredi 21 février 2014

Building OpenFOAM 2.3.0 on OS X. Tk.2

NB! Updated version of the guide can be found in the post Building OpenFOAM on OS X. Update.

After I've made patches for OpenFOAM 2.3.0 to build it with clang I came upon post by Bernhard Gshaider where he decided to drop ThirdParty source packs as all necessary software can be installed with Macports. Since all software from ThirdParty package can be installed with Homebrew (except you don't need to install gcc with all the stuff Macports pull with it), I've made this patch.

Installation is more or less straight-forward:
  1. Download OpenFOAM-2.3.0.tgz source pack
  2. Download patch.
  3. Create disk image with CASE SENSITIVE file system. Guide with pictures is on OpenFOAM wiki. Usually guides suggest sparseimage format though sparsebundle format is more convenient for the systems with active backup software.
  4. Mount created image into $HOME/OpenFOAM (hdiutil attach -quiet -mountpoint $HOME/OpenFOAM <your disk image file>)
  5. Unpack source archive into $HOME/OpenFOAM. Assuming you've downloaded it in $HOME/Downloads you can do the following:
    $ cd $HOME/OpenFOAM
    $ tar xzf ~/Downloads/OpenFOAM-2.3.0.tgz
  6. Copy patch into $HOME/OpenFOAM/OpenFOAM-2.3.0 folder
    $ cd $HOME/OpenFOAM/OpenFOAM-2.3.0
    $ cp ~/Downloads/OpenFOAM-2.3.0-3.patch .
  7. Apply patch with git apply OpenFOAM-2.3.0-3.patch
  8. Install third party software. I assume you're using Homebrew as a package manager, so you need to do:
    $ brew install open-mpi gmp mpfr boost gcal
  9. Now you can initialize environment variables for OpenFOAM with $ source etc/bashrc
    (or you can first edit this file if you're installing OpenFOAM somewhere but $HOME/OpenFOAM/OpenFOAM-2.3.0)
  10. Now you are ready to execute ./Allwmake
And that's it.

13 commentaires:

  1. Hello Alexey, i always get this i dont know why? please help me

    nasirs-imac:OpenFOAM-2.3.0 nasiryakubu$ git apply OpenFOAM-2.3.0.patch
    OpenFOAM-2.3.0.patch:753: trailing whitespace.
    handle =
    OpenFOAM-2.3.0.patch:1311: trailing whitespace.

    OpenFOAM-2.3.0.patch:1340: trailing whitespace.

    OpenFOAM-2.3.0.patch:1579: trailing whitespace.
    c++DBUG =
    OpenFOAM-2.3.0.patch:1605: trailing whitespace.
    cDBUG =
    fatal: corrupt patch at line 1944

    kind regards

    RépondreSupprimer
    Réponses
    1. Hi,

      I can only guess cause I've tested just now the application of the patch with Apple's git and Homebrew's git and everything went fine. Maybe patch was corrupted during download? How did you download the patch?

      Supprimer
    2. Also it seems that you're asking question about Bernhard Gschaider's patch not mine (I've tried to compare your output and content of my patch) ;) As he suggest using 'patch -p1 < ...' command, I guess his patch can have trailing white spaces and something else that makes git unhappy.

      Supprimer
  2. I get the following error: ./Allwmake: line 4: wmakeCheckPwd: command not found
    Error: Current directory is not $WM_PROJECT_DIR
    The environment variables are inconsistent with the installation.
    Check the OpenFOAM entries in your dot-files and source them.
    export WM_PROJECT=OpenFOAM
    export WM_PROJECT_VERSION=2.3.0

    ################################################################################
    # USER EDITABLE PART: Changes made here may be lost with the next upgrade
    #
    # either set $FOAM_INST_DIR before sourcing this file or set
    # 'foamInstall' below to where OpenFOAM is installed
    #
    # Location of the OpenFOAM installation
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    foamInstall=$HOME/OpenFOAM/OpenFOAM-2.3.0
    # foamInstall=~$WM_PROJECT
    # foamInstall=/opt/$WM_PROJECT
    #foamInstall=/usr/local/OpenFOAM/OpenFOAM-2.3.0
    #
    # END OF (NORMAL) USER EDITABLE PART
    ################################################################################

    brew_help() {
    echo <<- EOM
    Applied patch assumes you are using Homebrew (http://brew.sh) as a
    package manager but it wasn't found. Please check you installation.
    EOM
    }

    # Checking if brew is available
    `which -s brew` || { brew_help; unset brew_help; return; }
    unset brew_help

    #
    # These are the defaults for this version which should generally be
    # overridden from the prefs.sh file or from command-line specification
    #
    #- note the location for later use (eg, in job scripts)
    : ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR

    #- Compiler location:
    # foamCompiler= system
    foamCompiler=system

    #- Compiler:
    # WM_COMPILER = Clang
    export WM_COMPILER=Clang
    unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH

    #- Architecture:
    # WM_ARCH_OPTION = 32 | 64
    export WM_ARCH_OPTION=64

    #- Precision:
    # WM_PRECISION_OPTION = DP | SP
    export WM_PRECISION_OPTION=DP

    #- Optimised, debug, profiling:
    # WM_COMPILE_OPTION = Opt | Debug | Prof
    export WM_COMPILE_OPTION=Opt

    rostand.mowa@yahoo.de

    RépondreSupprimer
    Réponses
    1. I guess you've forgotten to source etc/bashrc. Did you do
      $ cd $HOME/OpenFOAM/OpenFOAM-2.3.0
      $ source etc/bashrc
      ?

      Also I'm not quite sure in your bashrc itself, if you followed the instruction you should have this line

      foamInstall=$HOME/$WM_PROJECT

      in your bashrc, while you've got

      foamInstall=$HOME/OpenFOAM/OpenFOAM-2.3.0

      Supprimer
  3. I have this error :
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [/Users/paul/OpenFOAM/OpenFOAM-2.3.0/platforms/darwinIntel64ClangDPOpt/bin/solidEquilibriumDisplacementFoam] Error 1
    make[1]: *** [solidEquilibriumDisplacementFoam] Error 2
    make[1]: Target `application' not remade because of errors.
    make: *** [stressAnalysis] Error 2
    make: Target `application' not remade because of errors.

    Can you help me please

    RépondreSupprimer
    Réponses
    1. Hi,

      I'd like but you've provided not enough information ;) Can you send me whole output of Allwmake script?

      Also this guide is rather outdated (also patch has certain bugs), I'd suggest you following instructions at http://matveichev.blogspot.fr/2014/04/building-openfoam-on-os-x.html.

      Supprimer
  4. how to compile ThirPArty-2.3.x on mac 10.9?

    how to compute in parallel ?

    RépondreSupprimer
    Réponses
    1. As you install OpenMPI and other dependencies with Homebrew you don't need ThirdParty tarball.

      As usual. First you decompose your case, then run it with mpiexec -np or with foamJob -parallel .

      Supprimer
  5. when i enter "mpiexec -np 4 simpleFoam -parallel" i get:
    --------------------------------------------------------------------------
    Sorry! You were supposed to get help about:
    opal_init:startup:internal-failure
    But I couldn't open the help file:
    /Users/Mowa/OpenFOAM/ThirdParty-2.3.x/platforms/darwinIntel64Gcc/openmpi-1.6.5/share/openmpi/help-opal-runtime.txt: No such file or directory. Sorry!
    --------------------------------------------------------------------------

    RépondreSupprimer
    Réponses
    1. Well, there is a problem with OpenMPI installation. As the provided information is somewhat limited I can't say anything on the nature of this problem.

      Supprimer
  6. Before following the steps you mention above, what previous steps should I consider to do? I am a new OP user, wishing to install this on Mac

    RépondreSupprimer
  7. Well, first you can try reading updated post - http://matveichev.blogspot.fr/2014/04/building-openfoam-on-os-x.html, or even more recent guides - https://github.com/mrklein/openfoam-os-x/wiki. But basically step 0 is to install Homebrew (http://brew.sh) after this you'll have command-line tools, package manager and will be ready for the next steps.

    RépondreSupprimer