massive-website-banner

Running an OpenFOAM Tutorial

A typical workflow for OpenFOAM is to take an existing tutorial program, run it and the adapt it to suit the research question. This page shows how to do this on MASSIVE.

The versions of OpenFOAM installed on MASSIVE can be found with the "module avail" command (see Modules). Using the "module show" command will show the directories that OpenFOAM is installed in.

module show openfoam/2.2.2
-------------------------------------------------------------------
/usr/local/Modules/modulefiles/openfoam/2.2.2:

conflict openfoam
module load baseline/gcc-4.7.0
module-whatis OpenFOAM is a free, open source CFD software package (v2.2.2)
prepend-path PATH /usr/local/openfoam/2.2.2/bin
setenv GCONV_PATH /usr/lib64/gconv/
setenv PBS_ROOT /usr/local/torque/latest
setenv FOAM_INST_DIR /usr/local/openfoam
setenv WM_PROJECT_VERSION 2.2.2
setenv WM_PROJECT OpenFOAM
setenv foamDotFile /usr/local/openfoam/OpenFOAM-2.2.2/etc/bashrc
-------------------------------------------------------------------

You can then find the tutorial directory based on the above information and copy the tutorial you wish to use to your project folder.e.g. From your project folder

cp -r /usr/local/openfoam/2.2.2/tutorials/incompressible/icoFoam .


The OpenFOAM tutorials come with an "Allclean" and "Allrun" helper script which will run the tutorials. Before they can run though you will need to set up the OpenFOAM environment using the following steps:


# start with a clean environment
module purge
# load the openfoam version you wish to use
module load openfoam/2.2.2
# import the openfoam commands into your environment (note "." means "source")
. $foamDotFile


Once this has been done, you can run the tutorial


./Allrun
Running blockMesh on /home/paulmc/icoFoam/cavity
Running icoFoam on /home/paulmc/icoFoam/cavity
Cloning cavityFine case from cavity
Running blockMesh on /home/paulmc/icoFoam/cavityFine
Running mapFields from cavity to cavityFine
Running icoFoam on /home/paulmc/icoFoam/cavityFine
Running blockMesh on /home/paulmc/icoFoam/cavityGrade
Running mapFields from cavityFine to cavityGrade
Running icoFoam on /home/paulmc/icoFoam/cavityGrade
Cloning cavityHighRe case from cavity
Setting cavityHighRe to generate a secondary vortex
Copying cavity/0* directory to cavityHighRe
Running blockMesh on /home/paulmc/icoFoam/cavityHighRe
Running icoFoam on /home/paulmc/icoFoam/cavityHighRe
Running blockMesh on /home/paulmc/icoFoam/cavityClipped
Running mapFields from cavity to cavityClipped
Running icoFoam on /home/paulmc/icoFoam/cavityClipped
fluentMeshToFoam: converting mesh elbow/elbow.msh
Running icoFoam on /home/paulmc/icoFoam/elbow
Running foamMeshToFluent on /home/paulmc/icoFoam/elbow
Running foamDataToFluent on /home/paulmc/icoFoam/elbow

The above demonstrates the process interactively, the same commands are used in a PBS batch file. You can easily create a PBS batch file by copying AllRun and adding the module commands at the top:

e.g. cp Allrun to PBS_Allrun

#!/bin/sh
# start with a clean environment
module purge
# load the openfoam version you wish to use
module load openfoam/2.2.2
# import the openfoam commands into your environment (note "." means "source")
. $foamDotFile
# the rest is already provided in the Allrun script

cd ${0%/*} || exit 1 # run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions...

Copyright © 2016 MASSIVE. All Rights Reserved.