- 1 Known Guides For Building OpenFOAM 2.3.x on Mac OS X
- 2 Introduction and Notes
1 Known Guides For Building OpenFOAM 2.3.x on Mac OS X
The known guides for building OpenFOAM on Mac OS X are as follows:
- Available on the forum: Installation notes: OpenFOAM 2.3.x (git repo) on OSX 10.9
- First ever instructions... er, patches for building OpenFOAM 2.3 on Mac OS X: Compile OF 2.3 on Mac OS X .... the patch
- Thread about project for compiling OpenFOAM 2.3.x on Mac OS X with Macports: OpenFOAM 2.3.x for Mac at GitHub
- Instructions on how to install OpenFOAM on Mac OS X with Homebrew: OpenFOAM git version & Homebrew
2 Introduction and Notes
- Anyone reading this is welcome to updating this section. You can take inspiration on the other existing pages that are referenced on the parent page: Installation/Mac OS
Here are notes on installing OpenFOAM 2.3.x on OSX 10.9 with macports for dependencies.
2.1 Install Dependencies
sudo port install gcc48 sudo port select --set gcc mp-gcc48 sudo port install openmpi-gcc48 sudo port select --set mpi openmpi-gcc48-fortran sudo port install boost +openmpi sudo port install cgal sudo port install ccache sudo port install flex sudo port install scotch -mpich +gcc48 +openmpi sudo port install metis +gcc48
And for completeness:
sudo port select --set llvm mp-llvm-3.5 sudo port select --set python python27 sudo port select --set db db48
Note, before installing and upon running "port select --summary", you should get something that looks like this:
$ port select --summary Name Selected Options ==== ======== ======= db db48 db48 none gcc mp-gcc48 mp-gcc48 none llvm mp-llvm-3.5 mp-llvm-3.5 none mpi openmpi-gcc48-fortran openmpi-gcc48-fortran none python python27 python25-apple python26-apple python27 python27-apple none
2.2 Create a volume and mount it
hdiutil create -size 8.3g -type SPARSEBUNDLE -fs HFSX -volname OpenFOAM -fsargs -s OpenFOAM.sparsebundle mkdir -p OpenFOAM hdiutil attach -mountpoint $HOME/OpenFOAM OpenFOAM.sparsebundle cd OpenFOAM git clone https://github.com/OpenFOAM/OpenFOAM-2.3.x cd OpenFOAM-2.3.x
2.3 Get the patch
Download the above and place it in the OpenFOAM-2.3.x directory.
2.4 Apply the patch
Given that the patch was originally developed for OpenFOAM 2.3.x after a couple of days of the repository having started, we need to change back to the older commit in the 2.3.x git history, by running the following commands:
git checkout 081e976023a9b6c9cd0405cfb48d2acd6999f6e1 git checkout -b macosx
Then we can safely apply the patch:
Now we can finish up the application of the patch by submitting the changed to the git tree, by running:
git add -u git add wmake/rules/darwinIntel64* bin/addr2line4Mac.py git commit -m "Applied patch"
2.5 Update the OpenFOAM-2.3.x/etc/bashrc
Append these lines to the /path/to/OpenFOAM-2.3.x/etc/bashrc (change the "/path/to" to whatever your fully qualified path would be):
echo "WM_CC=mpicc" >> /path/to/OpenFOAM-2.3.x/etc/bashrc echo "WM_CXX=mpicxx" >> /path/to/OpenFOAM-2.3.x/etc/bashrc
Note: using the mpi wrappers (mpicc, mpicxx) revolves errors locating mpi header files, i.e. "mpi.h" - no sideffects were observed in the logs.
2.6 Apply fixes manually
If trying to compile on OSX El Capitain or newer, try to apply the fix indicated here: Error installing openfoam on El Capitan - post #4 - has the instructions for fixing an issue in building with Flex.
source etc/bashrc && WM_NCOMPPROCS=$(sysctl -n hw.ncpu) ./Allwmake > log.Allwmake 2>&1
Note, you may notice this message:
"Proper OpenMPI not installed. Either do 'port install openmpi-mp' or 'port install openmpi-default'"
Ignore it. Using mpicc and mpicxx wrappers will take care of includes and linking.
It might also complain about the ulimit, ignore this as well. (If you are on 10.9 and you try to change this, you will get an error anyway). Do the following instead, if needed:
Add this line:
limit maxfiles 16384 32768
(create it if it does not exist, and restart to take effect)
2.8 Update your bash profile
Update your ~/.bash_profile to load the OpenFOAM bashrc file by adding:
if [ -f $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc ]; then . $HOME/OpenFOAM/OpenFOAM-2.3.x/etc/bashrc fi
to your ~/.bash_profile (assuming you have mounted the volume, this will load the openfoam bashrc file and setup your environment).
All steps were taken from bash history file after compilation and testing.