Header


 

In this quick guide, we will show you how to install OpenFOAM 2.2.0 on Mac OS X 10.8.3, as known as Mountain Lion.

This post is only a repetition of awesome work by B. Gschaider, and the original link can be found here.

 

A. Prerequisite

First, we need to make sure we have all the required files before installing OpenFOAM.

1. Xcode | https://developer.apple.com/xcode/

  • Download the latest version of Xcode and Command Line Tools. You’re going to need an Apple ID, and probably need to register as a developer. We’re using Xcode 4.6.1, and Command Line Tools  (OS X Mountain Lion) for Xcode – March 2013

2. MacPorts | http://www.macports.org/

  • Download Macports for Mountain Lion, and installation should be very straightforward (.pkg file)

 

B. Compilers and Libraries

Gcc4.6, OpenMPI, flex, bison, boost, cgal, ccache
(there was a mistake when I recorded the video. It’s ccache, not cache)

Now you’re ready to use MacPorts to install compilers and libraries using MacPorts. Simply launch Terminal and enter following commands.

sudo port selfupdate
Check if we’re on the same page.
gcc --version
If it returns default GCC 4.2.1, you’ve installed Xcode correctly. Recent updates in OpenFOAM require GCC 4.5 or higher. We’ll use MacPorts to install GCC 4.6
sudo port install gcc46
Select Gcc 4.6 as default compiler by typing the following.
sudo port select gcc mp-gcc46

Check to see if you’re doing it correct so far.

>> gcc –version
gcc (MacPorts gcc46 4.6.3_9) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Now install OpenMPI by typing
sudo port install openmpi

These two will take a while, so sit back, and try not to scare your computer. You can also install multiple tools using a single command. Try this line to install the remainder.
sudo port install flex bison boost cgal ccache

 

 C. OpenFOAM

Option 1 : Download precompiled sparseimage file.

1. Unzip, and double-click the .sparseimage file to mount
2. Create symbolic link on your home directory.
cd ~
ln -s /Volumes/OpenFOAM-v2.2 OpenFOAM

3. Edit your .profile to source ~/OpenFOAM/OpenFOAM-2.2.0/etc/bashrc when you start up Terminal
vi ~/.profile
Add this line…
source OpenFOAM/OpenFOAM-2.2.0/etc/bashrc
4. Clean and recompile OpenFOAM
cd ~/OpenFOAM/OpenFOAM-2.2.0
wcleanAll
./Allwmake

 

Option 2 : If it doesn’t work out of the box for some reason, carefully follow this instruction.

 

This post is not approved or endorsed by ESI Group.

# Update on April 2013
New post about OpenFOAM 2.2 on Mac OS X Snow Lion

http://www.optimulation.com/2013/03/31/installing-openfoam-2-2-0-on-mac-os-x-mountain-lion-10-8-3/

# Now back to the original post…

As of today, the latest OpenFOAM available is OpenFOAM-2.0.1. I am going to walk through installing it on my Macbook Pro (2.4 Ghz Intel Core 2 Duo). Installing open-source code can be a hassle since hardware/specification varies a lot. But it’s a price to pay, but you can google whenever you encounter a problem. You may find this forum (cfd-online) very useful. I listed

1. Update your OS X to the most recent version. I paid $29.99 for the new OS X Lion (10.7.1) from App Store. (~6 hrs)

2. Go to App Store, and download and install Xcode 4.1 . It’s free, but you have to register as a developer. (~3 hrs)

3. Install Macports for Lion. Simply follow the link and click on Lion to download dmg file. (< 5min)

4. Now you’re ready to install gcc 4.5.3. Open Terminal or X11, and type as followed

>> sudo port install gcc45

It will take a while. (~3 hrs?)

5. Mac OS X 10.7 does NOT come with OpenMPI, so you need to install it. On Terminal, type

>> sudo port install openmpi +gcc45

6. Now we’re ready to install OpenFOAM. Here’s the link for OpenFOAM disk image file for Mac. Download ‘README’ and ‘Mac-OF-2.0.x.sparseimage.zip’.

7. Extract Mac-OF-2.0.x.sparseimage.zip, and mount the image by double clicking.

8. Now, follow the instruction on ‘README’… I’m just going to narrate it here as well. Open Terminal and type..

>> cd ~

>> ln -sf /Volumes/Mac-OF-2.0.x OpenFOAM

>> cd OpenFOAM

>> ln -sf ~/Documents/OF-User ‘whoami’-2.0.x

>> cd ~

>> vi .profile

and add this line

. ~/OpenFOAM/OpenFOAM-2.0.x/etc/bashrc

Quit and restart Terminal…

9. Change the OpenMPI setting…

>>vi ~/OpenFOAM/site/2.0.x/prefs.sh

and replace OPENMPI to SYSTEMOPENMPI

export WM_MPLIB=SYSTEMOPENMPI

10. It’s a good idea to recompile it from the beginning.

>> cd ~/OpenFOAM/OpenFOAM-2.0.x

>>wcleanAll

…. this will clear everything up

>>./Allwmake

…. this will take a while…

 

After few hours of wait, OpenFOAM is finally ready to use. Test drive it by doing one of the tutorials.