-
-
Notifications
You must be signed in to change notification settings - Fork 32
OpenFOAM(R) dev & Homebrew
This guide is a slightly modified version of OpenFOAM(R) git version & Homebrew.
<commit>
is time-dependent variable, substitute current value taken from
patch file name.
The whole procedure is not so different:
$ brew install open-mpi
$ brew install boost
$ brew install cgal
$ brew install metis
$ brew tap mrklein/foam
$ brew install mrklein/foam/scotch
$ brew install mrklein/foam/parmgridgen
$ cd
$ hdiutil create -size 8.3g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle
$ mkdir -p OpenFOAM
$ mkdir -p .OpenFOAM
$ hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle
$ cd OpenFOAM
$ git clone https://github.com/OpenFOAM/OpenFOAM-dev.git
$ cd OpenFOAM-dev
$ git checkout -b local-install <commit>
$ curl -L https://raw.githubusercontent.com/mrklein/openfoam-os-x/master/OpenFOAM-dev-<commit>.patch > OpenFOAM-dev-<commit>.patch
$ git apply OpenFOAM-dev-<commit>.patch
$ echo 'WM_COMPILER=Clang' > "$HOME/.OpenFOAM/prefs.sh"
$ echo 'WM_COMPILE_OPTION=Opt' >> "$HOME/.OpenFOAM/prefs.sh"
$ echo 'WM_MPLIB=SYSTEMOPENMPI' >> "$HOME/.OpenFOAM/prefs.sh"
$ echo 'WM_LABEL_SIZE=32' >> "$HOME/.OpenFOAM/prefs.sh"
$ source etc/bashrc WM_NCOMPPROCS=$(sysctl -n hw.ncpu)
$ [ "$(ulimit -n)" -lt "4096" ] && ulimit -n 4096
$ ./Allwmake > log.Allwmake 2>&1
First you install dependencies, then create disk image with case-sensitive file
system, then mount the image into $HOME/OpenFOAM
, then check out sources,
download patch, apply it, create a file with options, set up environment
variables, and finally build OpenFOAM(R).
Below each step is described in more details.
In general there is no obligatory software to be installed, build process will just skip parts that do not have dependencies installed. Yet this statement is rather theoretical, since I did not try to build OpenFOAM without OpenMPI or Scotch.
$ brew install open-mpi
$ brew install boost
$ brew install cgal
$ brew install metis
$ brew tap mrklein/foam
$ brew install mrklein/foam/scotch
$ brew install mrklein/foam/parmgridgen
Homebrew is constantly evolving, so certain installation flags could be removed, check them with brew info <package>
command.
$ hdiutil create -size 8.3g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle
$ cd $HOME
$ mkdir -p OpenFOAM
$ mkdir -p .OpenFOAM
$ hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle
The first command creates disk image with the size 8.3g and name OpenFOAM.sparsebundle
. -fs HFSX -volname OpenFOAM -fsargs -s
part of the command creates cases-sensitive HFS+ file system on the image. Second command creates mount point for disk image, third - folder for preferences, and forth command mounts created disk image into $HOME/OpenFOAM.
$ cd OpenFOAM
$ git clone [email protected]:OpenFOAM/OpenFOAM-dev.git
$ cd OpenFOAM-dev
$ git checkout -b local-install <commit>
Since OpenFOAM(R) source layout is case-sensitive, they should be cloned onto
newly created disk image. So first you go to folder where you mounted disk
image and then issue git clone
command. The last command checks out source
tree state for which patch was created.
$ curl -L https://raw.githubusercontent.com/mrklein/openfoam-os-x/master/OpenFOAM-dev-<commit>.patch > OpenFOAM-dev-<commit>.patch
$ git apply OpenFOAM-dev-<commit>.patch
This part is self-explanatory.
$ echo 'WM_COMPILER=Clang' > "$HOME/.OpenFOAM/prefs.sh"
$ echo 'WM_COMPILE_OPTION=Opt' >> "$HOME/.OpenFOAM/prefs.sh"
$ echo 'WM_MPLIB=SYSTEMOPENMPI' >> "$HOME/.OpenFOAM/prefs.sh"
$ echo 'WM_LABEL_SIZE=32' >> "$HOME/.OpenFOAM/prefs.sh"
Earlier versions of the guide suggested editing of etc/bashrc file, yet this time I have decided, it is easier to create preferences file and leave bashrc file intact. Though this way has nuance: you have only one set of preferences for all OpenFOAM(R) versions.
$ source etc/bashrc WM_NCOMPPROCS=$(sysctl -n hw.ncpu)
$ [ "$(ulimit -n)" -lt "4096" ] && ulimit -n 4096
$ ./Allwmake > log.Allwmake 2>&1
This part is also obvious: you set up environment variables and start
compilation process. WM_NCOMPPROCS=$(sysctl -n hw.ncpu)
is optional but it
greatly reduces time necessary for compilation, especially on systems with SSD.
This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM(R) and OpenCFD(R) trade marks.
OPENFOAM(R) is a registered trade mark of OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com.