Howto install OpenFOAM v16 Mac
This page describes how to install OpenFOAM 1.6 and 1.7 on Mac OS X - the procedure is almost the same for both cases. It assumes that you are already familiar with compiling OpenFOAM and gives only a rough overview on the process.
This procedure was test on OpenFOAM 1.7.x, and Snow Leopard (OS X 10.6).
1 Walk-through for Compiling OpenFOAM
What to do:
- Make sure that ~/OpenFOAM is on a case-sensitive file-system (either a disk image or a separate partition). Create such a file system with the Disk Utility application, at least 4Gb for a single install, but more if you want to run the tutorial on this partition (mine is 20Gb).
- Get the git version of OpenFOAM from http://repo.or.cz/r/OpenFOAM-1.7.x.git with
git clone http://repo.or.cz/r/OpenFOAM-1.7.x.git/The latest git version is preferable to releases. It is supposed to be stable/tested, and will have bug fixed that releases might not have.
- Thirdparty-1.7 are only available as releases, download the latest tarball, and unzip to your filesystem. When using the 1.7.x git version, ThirdParty-1.7 must be renamed ThirdParty-1.7.x (or etc/bashrc must be modified).
- Apply the patches to both OpenFOAM (File:OpenFOAM-1.7-Mac.patch.gz) and Thirdparty (File:ThirdParty-1.7-Mac.patch.gz). Typically as
cd OpenFOAM-1.7.x; patch -p1 < ../patchfile. There are usually spurious errors in this process due to (a) files that have been diff'ed inadvertently, e.g. the git config files .gitignore, and (b) changes that have since been added to the repository. Skip these errors, and if you are concerned take a look in the patchfile to see what it's trying to do - it's human-readable, and not too long.
- Adapt the hard-coded compiler (gcc-mp-4.5 and g+-mp-4.5) in etc/bashrc and wmake/rules/darwinIntel64/* to fit your system. You'll need to modify c, c++ and general. Minimum gcc version is 4.3, Apple-supplied gcc with Snow Leopard is 4.2. Hence you'll need to install a compiler. Macports is good for this - install it from binary, it will install to /opt/local/ to keep separate from the Apple-supplied stuff. Then do:
sudo port install gcc45You will get /opt/local/bin/gcc-mp-4.5, this distinctive naming is very useful for keeping clear which compiler you are using.
- Source etc/bashrc. This can give problems due to the Apple sed command not having all expected functionality. This can be solved by removing a section from foamCleanPath, namely the while loop commented # strip out wildcards via sed. Alternatively install the GNU version gsed using Macports, and symlink sed to gsed.
- At one point during the compile gmake is required. Two options are: (a) create a symlink named gmake to make in /usr/bin, or (b) install gmake using Macports:
sudo port install gmake
- Compile OpenFOAM according to the README, see also Howto_install_OpenFOAM-1.6.x_(git_repository_version).
- Things are unlikely to work perfectly first time - do not loose hope! To deal with compilation errors, record the output of the compilation to a file, for searching later (e.g. bash):
./Allwmake 2>&1 | tee compile.logIdentify the location (directory/module) where the *first* error occurs, navigate to that directory, and look at the local Allwmake script. Using this it is possible to compile just the problematic module, without starting at the top-level every time.
- Extend and update this Wiki-page so that those trying after you have it easier.
2 Walk-through for Compiling ParaView
Two options: (a) compile from source, or (b) use precompiled Mac binaries. Option (b) takes 2 minutes, and is much preferable as most recent versions of Paraview include an OpenFOAM importer as standard. To use this stand-alone Paraview, just create an empty .foam file in the case directory you want to visualize with e.g. touch cavity.foam. Open this file from Paraview and the case data will be available.
The advantages of compiling from source, is more complete importing facilities (citation required?).
- Compile ParaView using the makeParaView-script (see the README)
3 Remarks on the patches
- The patches compiled a complete OF 1.6 (with paraview) on an Intel Mac with Mac OS X 10.5 in 32 bit (***update: 64 bit works as well with minor modifications in the patches for architecture darwinIntel64)
- libhoard does not compile under 64 bit
- In 64 bit everything except paraview gets compiled (there seems to be a general problem with Paraview and 64 bits on the Mac) / QT needs to be built with Cocoa framework for 64 bit and the ParaView source code needs to be patched, not fully supported for now ...
- the used compiler was thegcc-4.3 from the MacPorts-project
- MacPorts packages "gsed" and "gawk" sould be installed where "gsed" is needed by the ThirdParty patch and "gawk" should be used instead of awk in $WM_PROJECT_DIR/bin/foamLog
- PowerPC SHOULD work, but is untested
- to enable parallel computations copy the libPstream from $FOAM_LIBBIN/openmpi-1.3.3 to $FOAM_LIBBIN/dummy
- your milage may vary
- the patch to the OF-directory has been tested on a Linux-system and doesn't break the compilation there. The ThirdParty-patch has not been tested and might break things (***update: works, slightly modified for darwinIntel64)
- in Paraview Python has been automatically enabled
- it has been reported for previous versions of OF on MacOSX that the give compiler-switches give not the optimal performance (OF runs slower than is to be expected). This issue has not been addressed in the patch yet
- the stackTrace-facility currently assumes the existence of the gaddr2line-utility found in the binutils-package in MacPorts. Nevertheless it currently does not work because gaddr2line doesn't seem to recognize the format of the binaries
4 Further information
Further information on compiling OF on the Mac can be found here on the board or on this Wiki.
Discussion about these packages is in this thread on the MessageBoard.
The actual patch files:
- Patch for OpenFOAM 1.6: File:OpenFOAM-1.6-Mac.patch.v1.gz
- Patch for ThirdParty 1.6: File:ThirdParty-1.6.-Mac.patch.v1.gz
5.1 'Development'-version of the patch
Can be found (and downloaded via Subversion) at this address: https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.6/other/patchMacOSX
It might or might not work.