Installation/Mac OS/OpenFOAM-1.6-ext

From OpenFOAMWiki

This page guides you through an installation of OF Version 16ext.png on your Mac.

Bernhard Grieser
Zurich, 2013-10-26


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 OF Version 16ext.png

(pulled on 2013-10-24 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

The whole installation process will probably consume an afternoon, mostly due to MacPorts.



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 Modify perl (Mavericks only)

Open

vim /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/lang/perl5.8/Portfile

and 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 ports

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

Alternatively, you could also extend your PATH variable by opening

vim ~/.bashrc

and adding the following entry

export PATH=$PATH:/Applications/paraview.app/Contents/MacOS

In any of the two cases, you should now be able to open ParaView from the command line. Open a new terminal tab and type

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 Edit the bashrc

Get the maximum number of parallel cores.
Open the bashrc with

vim ~/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc

and change the following content at the appropriate location

#: ${WM_NCOMPPROCS:=8}; export WM_NCOMPPROCS
export WM_NCOMPPROCS=`sysctl -n hw.ncpu`

2.4.5 Load OpenFOAM environment variables

Execute the bashrc to get the environment variables

. ~/OpenFOAM/OpenFOAM-1.6-ext/etc/bashrc

2.4.6 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

(from http://www.cfd-online.com/Forums/openfoam-installation/70318-wmake-error-file-make-linux64gcc44dpopt-objectfiles-could-not-created.html)

2.4.7 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

Download Media:Libccmio-2.6.1.zip to a folder on your hard-drive. Within that folder, send the following terminal command:

unzip Libccmio-2.6.1.zip -d $WM_THIRD_PARTY_DIR/rpmBuild/

(from http://www.cfd-online.com/Forums/openfoam-news-announcements-other/82587-extend-project-1-6-ext-binary-release-mac-os-x-2.html)

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 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.11 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.12 New terminal

From now on, when you open a new terminal, load the OpenFOAM environment by simply typing the command

OF1.6-ext