OpenFOAM Cluster install with GCC and OpenMPI

OpenFOAM (Open Field Operationa and Manipulation) is a computational fluid dynamics toolbox which simulates "anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics, electromagnetics and the pricing of financial options." All this and free and open source as well.

Note that this installation instructions are substantially different to the version 1.5 install instructions.

Download the source code and third-party essentials and put them somewhere sensible (e.g., /usr/local/src/OPENFOAM). Extract the tar files (tar xvf OpenFOAM-2.1.1.tgz, ThirdParty-2.1.0.tgz).

Edit /usr/local/openfoam/$ver/OpenFOAM-$ver/etc/bashrc and set the following:


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

Load the requisite modules. module load openmpi-gcc/1.4.4 cmake/2.8.7 gcc/4.6.2

The export and source some files and settings... then install.


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

It'll take quite a while.

Create module files the usual way, i.e., cd /usr/local/Modules/openfoam/.base, ln -s .base 1.5, module load openfoam).


#%Module1.0#####################################################################
##
## $name modulefile
##
set ver [lrange [split [ module-info name ] / ] 1 1 ]
set name [lrange [split [ module-info name ] / ] 0 0 ]
set loading [module-info mode load]
set desc [join [read [ open "/usr/local/Modules/modulefiles/$name/.desc" ] ] ]
proc ModulesHelp { } {
puts stderr "\tThis module sets the environment for $name v$ver"
}
module-whatis "$desc (v$ver)"
if { $loading && ![ is-loaded gcc/4.6.2 ] } {
module load gcc/4.6.2
}
if { $loading && ![ is-loaded openmpi-gcc ] } {
module load openmpi-gcc
}
setenv FOAM_INST_DIR /usr/local/$name/$ver
setenv foamDotFile /usr/local/$name/$ver/OpenFOAM-$ver/etc/bashrc
puts stderr "\tYou now need to source the \$foamDotFile. Either type '. \$foamDotFile' in your terminal, or add 'source \$foamDotFile' to your script."

Thanks to Matt Wallis for his contribution to this updated version