Installation/Mac OS/OpenFOAM 1.7.x
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.
Contents
1 Prepare your Mac OS X Environment
- Obtain the necessary software through MacPorts.
- libtool
- Obtain the latest version of XCode.
- This may be available on your Max OS X Install CD/DVD.
- Available online at http://developer.apple.com/technologies/xcode.html.
- Note: You will need to sign in with your Apple ID and password to access the download.
- Obtain the latest version of XQuartz from http://xquartz.macosforge.org/.
- Obtain the latest version of Qt from http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x.
- Note: You do not need the full SDK. The "QT libraries" download is sufficient, and will include qmake.
- Obtain the latest version of CMake from http://www.cmake.org/cmake/resources/software.html
2 OpenFOAM 1.7.x Compilation Instructions
- Create the ubiquitous case-sensitive file system. There are two ways of doing this:
- 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.
- Purchase an external hard drive and format it with Disk Utility.
- Repartition your Mac's hard drive with Disk Utility to create a new partition.
- Obtain OpenFOAM 1.7.x source code from http://www.openfoam.com/download/source.php.
- Obtain OpenFOAM 1.7.x Mac OS X patches from http://www.cfd-online.com/Forums/openfoam-installation/77570-patches-openfoam-1-7-macos-x.html.
- Note: This will require you to register on the CFD Online forums.
- Direct download links:
- OpenFOAM-1.7-Mac.patch.gz (8.2 KB)
- ThirdParty-1.7-Mac.patch.gz (2.1 KB)
- 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
- 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
- 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
-
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
- Source the "etc/bashrc" script.
source etc/bashrc
- Execute Allwmake to compile the core OpenFOAM programs.
./Allwmake
3 ThirdParty 1.7.x Compilation Instructions
- Execute Allwmake to compile the ThirdParty programs.
./Allclean ./Allwmake
- Edit makeParaView within ThirdParty-1.7.0/ and update the following variables:
Variable New Value withMPI true MPI_MAX_PROCS 2 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
- Create the symbolic link libmpi.so 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 libmpi.so 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 libmpi.so cd -
- 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". IF (APPLE AND NOT VTK_USE_RPATH) FILE(WRITE ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh "#!/bin/sh\n" ) FILE(APPEND ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh "export DYLD_LIBRARY_PATH=${ParaView_BINARY_DIR}/bin\n" ) FILE(APPEND ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh "cd ${ParaView_BINARY_DIR}/bin\n" ) FILE(APPEND ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh "./vtkHashSource ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx vtkSocketCommunicatorHash ${VTK_BINARY_DIR}/Parallel/vtkSocketCommunicatorHash.h\n") ADD_CUSTOM_COMMAND( OUTPUT ${VTK_BINARY_DIR}/Parallel/vtkSocketCommunicatorHash.h DEPENDS ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx vtkHashSource COMMAND /bin/chmod ugo+rx ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh COMMAND ${ParaView_BINARY_DIR}/bin/vtkHashSource.sh ) ELSE () ADD_CUSTOM_COMMAND( OUTPUT ${VTK_BINARY_DIR}/Parallel/vtkSocketCommunicatorHash.h DEPENDS ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx vtkHashSource COMMAND vtkHashSource ${VTK_SOURCE_DIR}/Parallel/vtkSocketCommunicator.cxx vtkSocketCommunicatorHash vtkSocketCommunicatorHash.h ) ENDIF ()
- Execute makeParaView to compile the ParaView program.
./makeParaView
<<TODO: Finish compilation instructions.>>