From Consultancy.EdVoncken.NET

Jump to: navigation, search


About OpenFOAM

OpenFOAM is an Open Source application for Computational Fluid Dynamics (CFD).

This document describes the installation on RHEL 5.6, 64-bit (more accurately, Red Hat HPC Solution).


RHEL 5 ships with GCC version 4.1.x, so we need to install a newer version of the Gnu Compiler Collection with C++:

 yum install gcc44 gcc44-c++

Install assorted tools and development libraries needed for building OpenFOAM:

 yum install bison doxygen flex graphviz tix.x86_64
 yum install binutils-devel glibc-devel libXt-devel ncurses-devel qt-devel zlib-devel
 yum install openmpi openmpi-devel openmpi-libs

Download the OpenFOAM and ThirdParty source code packages into /tmp Unpack them into a directory, for example /usr/local/OpenFOAM.

 mkdir /usr/local/OpenFOAM
 cd /usr/local/OpenFOAM
 tar zxf /tmp/OpenFOAM-1.7.1.gtgz
 tar zxf /tmp/ThirdParty-1.7.1.gtgz

Configure Open MPI

You may have several MPI stacks installed. We will build OpenFOAM against Open MPI as installed on the system. Start the MPI selector, and set Open MPI to be the System and User default (in my case, I selected "3us"):


Obtain lots of information about Open MPI on your system:


Note: OpenFOAM also contains a version of Open MPI. We will not be using the OpenFOAM-supplied version.

Configure OpenFOAM

Edit /usr/local/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc, around line 45:


And around line 157, change the value of WM_CC and WM_CXX to gcc44 and g++44, respectively. This tells OpenFOAM to use the gcc44 compiler instead of the standard gcc compiler.

Source this bashrc file from your profile, or make it available for all users by creating a symlink:

 ln -s /usr/local/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc /etc/profile.d/

Edit two files, c and c++ in /usr/local/OpenFOAM/OpenFOAM-1.7.1/wmake/rules/linux64Gcc/, to change any occurrences of "gcc" and "g++" into "gcc44" and "g++44".

Run the system check:


This should yield something like:

 Checking basic system...
 Shell:           /bin/bash
 Host:            installer.redhathpc.local
 OS:              Linux version 2.6.18-238.1.1.el5
 User:            root
 System check: PASS
 Continue OpenFOAM installation.

Build OpenFOAM

Distribute the build across available processor cores:


Start the build:


Create a system user that will own the OpenFOAM files:

 useradd -r openfoam
 cd /usr/local && chown -R openfoam.openfoam OpenFOAM

File permissions should be changed to allow "other" users to access the OpenFOAM configuration and tools:

 cd /usr/local/OpenFOAM
 find . -type d -exec chmod 755 {} \;
 find . -type f -perm -g=rx -exec chmod o+rx {} \;
 find . -type f -perm -g=r -exec chmod o+r {} \;

Install Paraview

You can build Paraview yourself, or download the binary. For building, you need qmake (part of qt4-devel) and cmake (obtain from EPEL repository). On RHEL5.6, the most recent version of Qt4 is 4.2.x. Paraview needs at least version 4.3 to build correctly. Therefore I decided to download a binary from

Integration with an HPC cluster

To achieve the best results, OpenFOAM can be run on an HPC cluster (for example Red Hat HPC Solution).

Wrapper scripts

OpenFOAM commands can be intercepted and sent to the compute cluster by use of wrapper scripts. OpenFOAM contains a large set of solvers that can be run as a batch-job on the cluster. To find the solvers, look in the ${FOAM_SOLVERS} directory:

 find . -mindepth 2 -maxdepth 2 |cut -d/ -f3 |grep Foam

This excludes two find-results: dsmc and molecularDynamics. The corresponding solvers are dsmcFoam and mdFoam.

Another list of solvers can be found online: OpenFOAM standard solvers.

Related links

Building OpenFOAM

Extensions and utilities

Using OpenFOAM