Installation/Mac OS/OpenFOAM-1.6-ext
This page guides you through an installation of on your Mac.
Bernhard Grieser
Zurich, 2013-10-26
Contents
- 1 Tested Setup
- 2 Installation
- 2.1 Xcode
- 2.2 MacPorts
- 2.2.1 Installation time
- 2.2.2 Install MacPorts
- 2.2.3 Update the Portfiles
- 2.2.4 Install a gnu c++ compiler
- 2.2.5 Install python
- 2.2.6 (Mac OS X Mavericks only)
- 2.2.7 Install MacPorts applications
- 2.2.8 Select your python version
- 2.2.9 Select your gcc version
- 2.2.10 Set a symbolic link for mpirun and mpicc
- 2.2.11 Optional: Show installed ports
- 2.3 Paraview
- 2.4 OpenFOAM
- 2.4.1 Installation time
- 2.4.2 Create a sparse disk image
- 2.4.3 Pull the newest OpenFOAM-1.6-ext release
- 2.4.4 Load OpenFOAM environment variables
- 2.4.5 Rules for wmake
- 2.4.6 Download patches to support newer Mac OS X architectures
- 2.4.7 Edit the bashrc
- 2.4.8 Disable Paraview compilation
- 2.4.9 Compile the Third-Party applications
- 2.4.10 Edit the bashrc
- 2.4.11 Compile the OpenFOAM libraries and applications
- 2.4.12 Edit your ~/.bashrc
- 2.4.13 New terminal
1 Tested Setup
Mac
iMac 21.5" Late 2013 :: 3.1 GHz Intel Core i7 :: Mac OS X Mountain Lion 10.8.5 (12F2015) :: darwin12.5.0
Xcode
Version 5.0 (5A1413)
MacPorts
Version 2.2.0
OpenFOAM
Version 1.6-ext
(pulled on 10/24/2013 via git://git.code.sf.net/p/openfoam-extend/OpenFOAM-1.6-ext)
Paraview
Version 4.0.1 64-bit
Hint for Linux newcomers:
This tutorial uses the vim editor. Check out the man page for editing/saving/closing files with vim by typing
man vim
2 Installation
2.1 Xcode
2.1.1 Installation time
The Xcode download may take long (several GBs), depending on your internet connection.
2.1.2 Install Xcode
Install it via Apple Store https://developer.apple.com/xcode/
2.1.3 Install Xcode command line tools
- by GUI
xcode -> Preferences -> Downloads
- by terminal
xcode-select --install
2.2 MacPorts
2.2.1 Installation time
This may take several hours.
2.2.2 Install MacPorts
Install MacPorts from source as described on the website
http://www.macports.org/install.php#source
2.2.3 Update the Portfiles
sudo port -v selfupdate
Upgrade any existing but outdated ports
sudo port upgrade outdated
2.2.4 Install a gnu c++ compiler
My choice was gcc46
sudo port install gcc45 sudo port install gcc46
2.2.5 Install python
My choice was python26
sudo port install python25 sudo port install python26 sudo port install python27
2.2.6 (Mac OS X Mavericks only)
Prepare the installation of perl5.8
vim /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/lang/perl5.8/Portfile
Add platform support for darwin 13 (= Mac OS X Mavericks) through a new entry:
platform darwin 13 { # bypass stupid check that assumes fprintf must be in libc.dylib patchfiles-append patch-hints_darwin.sh-usenm.diff }
2.2.7 Install MacPorts applications
sudo port install cmake
sudo port install gmake
sudo port install wget
sudo port install boost
sudo port install cgal
sudo port install ccache
sudo port install openmpi
sudo port install flex
sudo port install bison
sudo port install perl5.8
sudo port install rpm
sudo port install gcc_select
sudo port install python_select
sudo port install libgcc
2.2.8 Select your python version
My choice was python26
port select --list python sudo port select --set python python25 sudo port select --set python python26 sudo port select --set python python27
2.2.9 Select your gcc version
My choice was gcc46
port select --list gcc sudo port select --set gcc mp-gcc45 sudo port select --set gcc mp-gcc46
2.2.10 Set a symbolic link for mpirun and mpicc
sudo ln -s /opt/local/bin/openmpirun /usr/bin/mpirun sudo ln -s /opt/local/bin/openmpicc /usr/bin/mpicc
2.2.11 Optional: Show installed ports
Show all installed ports incl. version number and category
port list installed
2.3 Paraview
2.3.1 Installation time
Less than 10min
2.3.2 Install ParaView
Download ParaView-x.x.x-Darwin-64bit.dmg from the website (e.g. with version number x.x.x = 4.0.1):
http://www.paraview.org/paraview/resources/software.php
2.3.3 Easy access
Make paraview easily accessible from the terminal
sudo ln -s /Applications/paraview.app/Contents/MacOS/paraview /usr/bin/paraview
2.4 OpenFOAM
2.4.1 Installation time
ca. 1h10min
2.4.2 Create a sparse disk image
Use Apple's 'Disk Utility' (in /Applications/Utilities) to create a case-sensitive sparse disk image (~/OpenFOAM.sparseimage) with the following settings
- Save As: OpenFOAM
- Name: OpenFOAM
- Size: Custom (>10GB)
- Format: Mac OS Extended (Case-sensitive,Journaled)
- Encryption: none
- Partitions: Hard disk
- Image Format: sparse disk image
2.4.3 Pull the newest OpenFOAM-1.6-ext release
git clone git://git.code.sf.net/p/openfoam-extend/OpenFOAM-1.6-ext ~/OpenFOAM/OpenFOAM-1.6-ext
2.4.4 Load OpenFOAM environment variables
Execute the bashrc to get the environment variables
. ~/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc
2.4.5 Rules for wmake
This depends on your architecture. Here: darwinIntel64Gcc
ln -s $WM_DIR/rules/darwinIntel64 $WM_DIR/rules/darwinIntel64Gcc
Open the general rules for wmake with
vim $WM_DIR/rules/darwinIntel64Gcc/general
and add the -P option in the first line
CPP = cpp $(GFLAGS) -P
2.4.6 Download patches to support newer Mac OS X architectures
Note: Mac OS X Mavericks users need to edit those files and replace all entries for darwin12.5.0 with their own darwin13.x.x
wget -O $WM_THIRD_PARTY_DIR/rpmBuild/SOURCES/libccmio-2.6.1.patch_0 http://www.ifd.mavt.ethz.ch/people/grieserb/files/libccmio-2.6.1.patch_0 wget -O $WM_THIRD_PARTY_DIR/rpmBuild/SPECS/libccmio-2.6.1.spec http://www.ifd.mavt.ethz.ch/people/grieserb/files/libccmio-2.6.1.spec
2.4.7 Edit the bashrc
Get the maximum number of parallel cores and use your system’s openmpi for compiling Third-Party libraries.
Open the bashrc with
vim $WM_PROJECT_DIR/etc/bashrc
and change the following content at the appropriate location
#: ${WM_NCOMPPROCS:=8}; export WM_NCOMPPROCS export WM_NCOMPPROCS=`sysctl -n hw.ncpu`
and further down also the following
#: ${WM_MPLIB:=OPENMPI}; export WM_MPLIB export WM_MPLIB='SYSTEMOPENMPI'
2.4.8 Disable Paraview compilation
Open
vim $WM_THIRD_PARTY_DIR/AllMake
and comment the following line:
#./AllMake.stage4
2.4.9 Compile the Third-Party applications
$WM_THIRD_PARTY_DIR/AllMake 2>&1 | tee $WM_THIRD_PARTY_DIR/make1.log
And compile them again to check for potential errors
$WM_THIRD_PARTY_DIR/AllMake 2>&1 | tee $WM_THIRD_PARTY_DIR/make2.log
2.4.10 Edit the bashrc
Now edit the $WM_PROJECT_DIR/etc/bashrc again and set $WM_MPLIB back to OPENMPI
#: ${WM_MPLIB:=OPENMPI}; export WM_MPLIB #export WM_MPLIB='SYSTEMOPENMPI' export WM_MPLIB='OPENMPI'
2.4.11 Compile the OpenFOAM libraries and applications
$WM_PROJECT_DIR/Allwmake 2>&1 | tee $WM_PROJECT_DIR/make1.log
And compile them again to check for potential errors
$WM_PROJECT_DIR/Allwmake 2>&1 | tee $WM_PROJECT_DIR/make2.log
2.4.12 Edit your ~/.bashrc
Open or create your personal ~/.bashrc with
vim ~/.bashrc
and add the following entry
alias OF1.6-ext='hdiutil attach ~/OpenFOAM.sparseimage > /dev/null; . ~/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc'
2.4.13 New terminal
From now on, when you open a new terminal, load the OpenFOAM environment by simply typing the command
OF1.6-ext