Skip navigation.
Home

Installing OpenFOAM : A Detailed Guide

Installation of OpenFOAM (and Paraview) can be carried out through several different methods, depending on the user's desires and the Linux distribution and package manager that is being used. Essentially there are three main methods; either installating with the Advanced Packaging Tool (apt) common on Debian, Ubuntu, Mint, etc., with various front-end implementations (e.g., aptitude, Synaptic, Ubuntu Software Center), the Red Hat Package Manager (rpm), common on SuSE, RHEL, Fedora, CentOS, Mageia, etc., with its front-ends (e.g., yum, up2date, urmpi), and compiling from source. As is ever the case, the latter provides the best opportunity optimisation, performance enhancements, and compatibility, but is a significantly more difficult path. The good people at the OpenFOAM Foundation have provided packages for Ubuntu (using apt), SuSe (using RPM), Fedora (also with RPM), source packagaes, all of which have been tested. For those who live on the cutting edge of development versions, there is also a Git Repository.

Starting with the apt manager for Ubuntu and similar distributions (e.g., Debian, Mint), the first step to installation is to include OpenFOAM into apt's list of packages.


VERS=$(lsb_release -cs)
echo "deb http://www.openfoam.org/download/ubuntu $VERS main" | sudo tee -a /etc/apt/sources.list.d/openfoam.list

These commands starts with establishing the VERS variable, by running the command lsb_release -cs. The second line invokes superuser commands (sudo) and, through the tee and pipe, it sends the output to standard output so the user can check that it has done what they expect it to. Note the use in the double-quotes in the echo statement to ensure that the $VERS variable is actually exported correctly.

The next step is to install OpenFOAM and then Paraview, after updating the source lists. The numbers refer to version numbers, so in these examples OpenFOAM2.11 and ParaView3.12.0. In all the two programs make up some 450 megabytes of space.


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install openfoam211
sudo apt-get install paraviewopenfoam3120

If all goes well, the results will look something similar to the following:


lev@isocracy:~$ sudo apt-get install paraviewopenfoam3120
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libscotch-dev libibverbs-dev libptscotch-dev libscotch-5.1 binutils-dev libreadline-dev mpi-default-dev libptscotch-5.1 libreadline6-dev
libopenmpi-dev
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
paraviewopenfoam3120
0 upgraded, 1 newly installed, 0 to remove and 326 not upgraded.
Need to get 44.5 MB of archives.
After this operation, 154 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
paraviewopenfoam3120
Install these packages without verification [y/N]? Y
Get:1 http://www.openfoam.org/download/ubuntu/ precise/main paraviewopenfoam3120 i386 0-1 [44.5 MB]
Fetched 44.5 MB in 7s (6,177 kB/s)
Selecting previously unselected package paraviewopenfoam3120.
(Reading database ... 536171 files and directories currently installed.)
Unpacking paraviewopenfoam3120 (from .../paraviewopenfoam3120_0-1_i386.deb) ...
Setting up paraviewopenfoam3120 (0-1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

lev@isocracy:~$ sudo apt-get install openfoam211
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
openfoam211
0 upgraded, 1 newly installed, 0 to remove and 326 not upgraded.
Need to get 87.0 MB of archives.
After this operation, 303 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
openfoam211
Install these packages without verification [y/N]? Y
Get:1 http://www.openfoam.org/download/ubuntu/ precise/main openfoam211 i386 0-1 [87.0 MB]
Fetched 87.0 MB in 12s (6,989 kB/s)
Selecting previously unselected package openfoam211.
(Reading database ... 540352 files and directories currently installed.)
Unpacking openfoam211 (from .../openfoam211_0-1_i386.deb) ...
Setting up openfoam211 (0-1) ...

** To use OpenFOAM please add
**
** . /opt/openfoam211/etc/bashrc
**
** To your ~/.bashrc

This is a generic requirement, which will be returned to at the end of the example installations.

For Fedora and other related distributions (RHEL, CentOS) and using the yum package manager, the OpenFOAM Foundation have provided RPM packs for scotch/pscotch, OpenFOAM, and Paraview. It is necessary however to install the development tools, openmpi, and qt-development tools, & etc., proir to this.


sudo yum groupinstall 'Development Tools'
sudo yum install openmpi openmpi-devel qt-devel qt-webkit-devel zlib-devel

Scotch, OpenFOAM and Paraview can be installed by the standard rpm commands. Where appropriate, replace the version number of Fedora. Select one of the two according to whether the system is 32-bit or 64-bit (determine with uname -a).

For 32-bit machines


sudo rpm -i http://www.openfoam.org/download/fedora/16/i386/OpenFOAM-scotch-5.1.12-1...
sudo rpm -i http://www.openfoam.org/download/fedora/16/i386/OpenFOAM-ParaView-3.12.0...
sudo rpm -i http://www.openfoam.org/download/fedora/16/i386/OpenFOAM-2.1.1-1.i686.rpm

For 64 bit machines


sudo rpm -i http://www.openfoam.org/download/fedora/16/x86_64/OpenFOAM-scotch-5.1.12...
sudo rpm -i http://www.openfoam.org/download/fedora/16/x86_64/OpenFOAM-ParaView-3.12...
sudo rpm -i http://www.openfoam.org/download/fedora/16/x86_64/OpenFOAM-2.1.1-1.x86_6...

OpenFOAM-2.1.1 and Paraview-3.12.0 will be installed in the /opt directory.


lev@linux-d7m6:~/Desktop> ls /opt
OpenFOAM-2.1.1 OpenFOAM-ParaView-3.12.0 OpenFOAM-scotch-5.1.12

With SuSE RPM is available for installing OpenFOAM and Paraview; the installation must include all the the C/C++ development tools Development Tools in YaST (except where there is incompatibilities, in which case select the newest version). Also, ensure that the libqt4 library is installed.


sudo zypper install -t pattern devel_C_C++
sudo zypper install cmake libqt4-devel gnuplot
sudo zypper in libqt4 libQtWebKit4

Install openmpi by typing the following on the command line:

sudo zypper in openmpi

It is possible that the system does not identify the version of openmpi to run. If so, the user can first list the version of openmpi available, by typing:


lev@linux-d7m6:~/Desktop> mpi-selector --list
openmpi-1.4.3

If there is some confusion this can be set explicitly, e.g.,

lev@linux-d7m6:~/Desktop> mpi-selector --set openmpi-1.4.3

Although for this to effect, the user must cycle their login.

Assuming all this is done, the user needs to install Scotech, Paraview and OpenFOAM either for 32 or 64 bit (determine from uname -a)

32-bit


lev@linux-d7m6:~/Desktop>sudo rpm -i http://www.openfoam.org/download/suse/11.4/i586/OpenFOAM-scotch-5.1.12-1...
lev@linux-d7m6:~/Desktop>sudo rpm -i http://www.openfoam.org/download/suse/12.1/i586/OpenFOAM-ParaView-3.12.0...
lev@linux-d7m6:~/Desktop>sudo rpm -i http://www.openfoam.org/download/suse/12.1/i586/OpenFOAM-2.1.1-1.i586.rpm

64-bit


lev@linux-d7m6:~/Desktop>sudo rpm -i http://www.openfoam.org/download/suse/11.4/x86_64/OpenFOAM-scotch-5.1.12...
lev@linux-d7m6:~/Desktop>sudo rpm -i http://www.openfoam.org/download/suse/12.1/x86_64/OpenFOAM-ParaView-3.12...
lev@linux-d7m6:~/Desktop>sudo rpm -i http://www.openfoam.org/download/suse/12.1/x86_64/OpenFOAM-2.1.1-1.x86_6...

OpenFOAM-2.1.1 and Paraview-3.12.0 will be installed in the /opt directory.


lev@linux-d7m6:~/Desktop> ls /opt
OpenFOAM-2.1.1 OpenFOAM-ParaView-3.12.0 OpenFOAM-scotch-5.1.12

Installations from source are recommended if the user wants to maximise performance, will be making modifications to the code, or will have an alternative distribution or architecture. The user will need to install the appropriate build tools and libraries (e.g., cmake, openmpi, gcc), as follows:

For Ubuntu, Debian, Mint, & etc:

sudo apt-get install build-essential flex bison cmake zlib1g-dev qt4-dev-tools libqt4-dev gnuplot libreadline-dev libncurses-dev libxt-dev
sudo apt-get install libscotch-dev libopenmpi-dev

For SuSE:

zypper install -t pattern devel_C_C++
zypper install cmake libqt4-devel gnuplot

For Fedora, CentOS, RHEL, etc:

sudo yum groupinstall 'Development Tools'
sudo yum install openmpi openmpi-devel qt-devel qt-webkit-devel zlib-devel

If one has the time, inclination, or need (e.g., because of architecture, desire for performance), all these packages can be installed from source as well, however that is beyond the scope of this discussion.

After the necessary dependencies are installed, and OpenFOAM installation directory must be selected: $HOME/openfoam/$ver is a good option if the user does not have root access; /usr/local/openfoam/$ver if they do. Note that with OpenFOAM the installation and build directories are the same. So even if the system administrators have the fine habit of differentiating between the two (for example by using /usr/local/src/$software/$ver as the build directory and /usr/local/$software/$ver as the installation directory), the only files that should be kept in the build directory are the tarballs. The tarballs themselves need to be extracted - and built - in the installation directory.

Change to the appropriate directory and download;


wget http://downloads.sourceforge.net/foam/OpenFOAM-2.1.1.tgz
wget http://downloads.sourceforge.net/foam/ThirdParty-2.1.1.tgz
tar xvf OpenFOAM-2.1.1.tgz
tar xvf http://downloads.sourceforge.net/foam/ThirdParty-2.1.1.tgz

Edit /usr/local/openfoam/$ver/OpenFOAM-$ver/etc/bashrc with the now preferred text editor and set the following:


foamInstall=/usr/local/openfoam/$ver/$WM_PROJECT
Set WM_MPLIB=SYSTEMOPENMPI

Export the installation directory, source the files and settings, and then install.

For a bash based shell:

export FOAM_INST_DIR=/usr/local/openfoam/$ver
foamDotFile=$FOAM_INST_DIR/OpenFOAM-2.1.1/etc/bashrc
cd /usr/local/openfoam/2.1.1/OpenFOAM-2.1.1/
[ -f $foamDotFile ] && . $foamDotFile
./Allwmake

For a csh, tsch based shell:

export FOAM_INST_DIR /usr/local/openfoam/$ver
source $HOME/OpenFOAM/OpenFOAM-2.1.x/etc/cshrc
cd /usr/local/openfoam/2.1.1/OpenFOAM-2.1.1/
if ( -f $foamDotFile ) source $foamDotFile
./Allwmake

Be aware that this will take "a while". Make yourself a coffee. Long black for me, thanks.

For those who really want to live on the cutting-edge of OpenFOAM development there is also a Git version. Git is a distributed version control and source code mnagement system. It can be installed by the usual methods on relevant distributions e.g.,

sudo apt-get install git-core (for apt-based distributions, such as Ubuntu, Debian, Mint, etc)
zypper install git-core (for SuSE)
yum install git (for Fedora, CentOS, RHEL, etc)

Once Git is installed, a directory should be selected to download and install. This follows the same conventions are expressed previously; $HOME/OpenFOAM for non-root single-users, /usr/local/openfoam, /opt/OpenFOAM, & etc if it is being installed as a root or multi-user system. To download and unpack simple change to the appropriate directory and run the git clone command.

git clone git://github.com/OpenFOAM/OpenFOAM-2.1.x.git

The repository can be updates at any time by changing to the appropriate directory and running the git pull command.


cd $OpenFOAM-2.1.x
git pull

Finally, in all cases add a source to .bashrc (or .tcshrc) in each user's home directory. e.g., nano ~/.bashrc and add

source $OpenFOAM/etc/bashrc[cshrc]

The briefest test for OpenFOAM should also be carried out;

icoFoam -help

A "Usage" message should appear. If so, the installation is complete.