Installation/Mac OS/OpenFOAM 1.7.x

From OpenFOAMWiki

This page describes how to compile OpenFOAM 1.7.x on Mac OS X. It was created from the official OpenFOAM installation instructions, the Howto install OpenFOAM v16 Mac OpenFOAMWiki topic, information shared on this thread of the OpenFOAM Installation forum of CFD Online, and my personal experience of installing it on my own laptop.

These compilation instructions have only been tested on the following system:

Macbook (version 5,2)
Intel Core 2 Duo
Mac OS X Snow Leopard (version 10.6.4)

These instructions may need to be tailored as required to fit your specific system if they deviate from the above.

Many thanks go to Bernhard Gschaider (a.k.a. gschaider) of CFD Online for maintaining the latest OpenFOAM Mac OS X patches.

1 Prepare your Mac OS X Environment

  1. Obtain the necessary software through MacPorts.
    • libtool
  2. Obtain the latest version of XCode.
  3. Obtain the latest version of XQuartz from
  4. Obtain the latest version of Qt from
    • Note: You do not need the full SDK. The "QT libraries" download is sufficient, and will include qmake.
  5. Obtain the latest version of CMake from

2 OpenFOAM 1.7.x Compilation Instructions

  1. Create the ubiquitous case-sensitive file system. There are two ways of doing this:
    1. Repartition your Mac's hard drive with Disk Utility to create a new partition.
      • Often this may be problematic when attempting to re-size a live hard drive partition, as Disk Utility may simply error out with a vague message of being unsuccessful. If this is consistently a problem, try using Disk Utility from a booted system disk; this is done by inserting your Mac OS X installation CD/DVD, then going to System Preferences->Startup Disk.
    2. Purchase an external hard drive and format it with Disk Utility.
  2. Obtain OpenFOAM 1.7.x source code from
  3. Obtain OpenFOAM 1.7.x Mac OS X patches from
  4. Decompress both OpenFOAM and ThirdParty archives into the case-sensitive file system.
cd ~/Downloads/
mv OpenFOAM-1.7.0.gtgz /Volumes/OpenFOAM/
mv ThirdParty-1.7.0.gtgz /Volumes/OpenFOAM/
cd /Volumes/OpenFOAM/
tar -zvxf OpenFOAM-1.7.0.gtgz
tar -zvxf ThirdParty-1.7.0.gtgz
  1. Apply the Mac OS X patches.
cd ~/Downloads/
mv OpenFOAM-1.7-Mac.patch.gz /Volumes/OpenFOAM/OpenFOAM-1.7.0/
mv ThirdParty-1.7-Mac.patch.gz /Volumes/OpenFOAM/ThirdParty-1.7.0/
cd /Volumes/OpenFOAM/OpenFOAM-1.7.0/
gunzip OpenFOAM-1.7-Mac.patch.gz
patch -p1 <OpenFOAM-1.7-Mac.patch
cd /Volumes/OpenFOAM/ThirdParty-1.7.0/
gunzip ThirdParty-1.7-Mac.patch.gz
patch -p1 <ThirdParty-1.7-Mac.patch
  1. Edit etc/bashrc within OpenFOAM-1.7.0/, and modify the foamInstall variable (line 45) to the appropriate location.
cd /Volumes/OpenFOAM/OpenFOAM-1.7.0/
vi etc/bashrc
  1. Create the directory structure lib/darwinIntel64DPOpt/ within OpenFOAM-1.7.0/.
    • Note: For some reason the etc/bashrc script has trouble creating this directory on its own.
mkdir lib
mkdir lib/darwinIntel64DPOpt
  1. Source the "etc/bashrc" script.
source etc/bashrc
  1. Execute Allwmake to compile the core OpenFOAM programs.

3 ThirdParty 1.7.x Compilation Instructions

  1. Execute Allwmake to compile the ThirdParty programs.
  1. Edit makeParaView within ThirdParty-1.7.0/ and update the following variables:
    Variable New Value
    withMPI true
    withPYTHON true
    PYTHON_LIBRARY "/usr/lib/libpython.dylib"
    withMESA true
    MESA_INCLUDE "/usr/X11/include/GL"
    MESA_LIBRARY "/usr/X11/lib/libOSMesa.dylib"
    withQT true
    QMAKE_PATH "/usr/bin/qmake"

    Note: I chose "2" for MPI_MAX_PROCS simply because I will only be running ParaView on my Macbook, which has a 2-core CPU; change this value as needed.

cd /Volumes/OpenFOAM/ThirdParty-1.7.0/
vi makeParaView
  1. Create the symbolic link to point to libmpi.dylib in ThirdParty-1.7.0/platforms/darwinIntel64/openmpi-1.4.1/lib/. This is required because CMake incorrectly attempts to search for while building libCosmos.dylib; if this link is not there, the build will fail.
cd /Volumes/OpenFOAM/1.7.0/ThirdParty-1.7.0/platforms/darwinIntel64/openmpi-1.4.1/lib
ln -s libmpi.dylib
cd -
  1. Modify paraview-3.8.0/VTK/Parallel/CMakeLists.txt and change the code beginning on line 236 to the following:[1]
    • It would be nice if a patch file could be written up for this.
# Generate "vtkSocketCommunicatorHash.h".
  FILE(WRITE ${ParaView_BINARY_DIR}/bin/ "#!/bin/sh\n" )
  FILE(APPEND ${ParaView_BINARY_DIR}/bin/ "export DYLD_LIBRARY_PATH=${ParaView_BINARY_DIR}/bin\n" )
  FILE(APPEND ${ParaView_BINARY_DIR}/bin/ "cd ${ParaView_BINARY_DIR}/bin\n" )
  FILE(APPEND ${ParaView_BINARY_DIR}/bin/ "./vtkHashSource ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx vtkSocketCommunicatorHash ${VTK_BINARY_DIR}/Parallel/vtkSocketCommunicatorHash.h\n")
    OUTPUT ${VTK_BINARY_DIR}/Parallel/vtkSocketCommunicatorHash.h
    DEPENDS ${ParaView_BINARY_DIR}/bin/ ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx
    COMMAND /bin/chmod ugo+rx ${ParaView_BINARY_DIR}/bin/
    COMMAND ${ParaView_BINARY_DIR}/bin/
    OUTPUT ${VTK_BINARY_DIR}/Parallel/vtkSocketCommunicatorHash.h
    DEPENDS ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx
    COMMAND vtkHashSource
      vtkSocketCommunicatorHash vtkSocketCommunicatorHash.h
  1. Execute makeParaView to compile the ParaView program.

<<TODO: Finish compilation instructions.>>

  1. Bug 0010685: ParaView build errors on OS X with VTK_USE_RPATH: OFF