Installing and running OpenFoam

The HPC Network of Experts is a collaboration of highly technical and knowledgeable individuals that create a support network for consultations, questions, and answers for high-performance computing end-users, software vendors and systems builders. Each of the HPC Advisory Council members participate in the Network of Experts to utilize their vast experience to contribute into the Network knowledge base. Issues raised to the Network of Experts, which are of interest to general HPC end-users should be submitted here.

Installing and running OpenFoam

Postby shainer on Wed Dec 15, 2010 12:13 am

Download OpenFOAM and Third-Party source pack at:

Pre-setup requirements
% . $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc

Make sure that you use GNU compilers 4.4 version and not the version that comes with RHEL or CentOS by default.

Many of the steps below are outlined in the Download page:

Create a directory
% mkdir $HOME/OpenFOAM
% cd ~/OpenFOAM
% tar xvfz tar xvfz OpenFOAM-1.7.1.gtgz
% tar xvfz ThirdParty-1.7.1.gtgz

Package Dependencies
Depending how you install your OS, you may need this package:
Otherwise you might run into this at compile time:
/usr/bin/ld: cannot find –liberty
Makefile changes for GNU compilers

Make sure you have GCC 4.4 installed. For RHEL, you can install gcc44-4.4.0-6.el5 and gcc44-c++-4.4.0-6.el5 using yum. Then make changes to these files.
% cd $HOME/OpenFOAM/OpenFOAM-1.7.1/wmake/rules/linux64Gcc
% vim c
cc = gcc44 -m64
% vim c++
CC = g++44 -m64

Makefile changes for Intel compilers
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/

Makefile changes for Platform MPI
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
% vim mplibHPMPI

Makefile changes for compilers and Open MPI
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
% vim mplibOPENMPI

Makefile changes for compilers and Intel MPI
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
: ${WM_MPLIB:=IMPI}; export WM_MPLIB
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/
export MPI_HOME=/application/intel/impi/intel64
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib

Makefile changes for MVAPICH2
Make sure that MVAPICH2 has the name MPI included otherwise OpenFOAM will not be able to detect it.
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/bashrc
% vim $HOME/OpenFOAM/OpenFOAM-1.7.1/etc/
export MPI_HOME=/application/mvapich2-1.5-gnu
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib

Build the sources
% Allwmake

Verifying the installation
$ cd /home/pak/OpenFOAM/OpenFOAM-1.7.1/bin
$ ./foamInstallationTest

Running OpenFOAM
Copy over the tutorial and run the first example
Create a project directory within the $HOME/OpenFOAM directory named <USER>-1.7.1 (e.g. chris-1.7.1 for user chris and OpenFOAM version 1.7.1) and create a directory named run within it, e.g. by typing:
Copy the tutorial examples directory in the OpenFOAM distribution to the run directory. If the OpenFOAM environment variables are set correctly, then the following command will be correct:
% mkdir -p $FOAM_RUN

Run the first example case of incompressible laminar flow in a cavity:
% cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavity
% blockMesh
% icoFoam
% paraFoam

Running OpenFOAM in Parallel
Create a new case called “damBreakFine”
% cd $FOAM_RUN/tutorials/multiphase/interFoam/laminar
% mkdir damBreakFine
% cp -r damBreak/0 damBreakFine
% cp -r damBreak/system damBreakFine
% cp -r damBreak/constant damBreakFine

Increase the mesh density and mesh grading in file:
constant/polyMesh/blockMeshDict /blockMeshDict
hex (0 1 2 3 4 5 6 7) (1000 1000 1) simpleGrading (1 1 1)

Change the deltaT for the steps
In system/controlDict, adjust deltaT to 0.0005 to give 1000 steps.
Also change the writeInterval to control the rate data get written.
endTime 0.5;
deltaT 0.0005;
writeInterval 20000;

Specify the number of Subdomains for a parallel run
Add “system/decomposeParDict” file for case of interest, then modify the “numberOfSubdomains” and the method of Coeffs to the to the number of processes you plan to run:
n ( 4 6 7 );
delta 0.001;
% decomposePar -force
8.6 use Open MPI to launch the parallel job
% mpirun -np 168 –hostfile ~/hostfile.14 interFoam -parallel
Posts: 13
Joined: Thu Jun 11, 2009 8:31 pm

Return to Network of Experts

Who is online

Users browsing this forum: No registered users and 1 guest