OpenFOAM Tutorial


The OpenFOAM (Open Field Operation and Manipulation) CFD Toolbox can simulate anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to solid dynamics, electromagnetics and the pricing of financial options. OpenFOAM is produced by OpenCFD Ltd and is freely available and open source, licensed under the GNU General Public Licence.

Please read Logging in and transferring files tutorial before continuing here.

Job Submission
Serious compute loads must be launched via PBS on the cluster. You will need X-forwarding turned on for when you use Paraview to visualise the files.

Copy the job files to your working directory using the following commands:

ssh -X
cp -r /common/examples/openfoam/ .
cd openfoam

The files copied to your working directory are shown below:

0 constant openfoam_par system

openfoam_par is the pbs script; please modify to use your username. You can optionally reconstruct the parallel jobs with the final line of the PBS script, which is commented out by default.

#PBS -N parallel_openfoam
#PBS -l nodes=4
#PBS -l walltime=6:15:0
module load openfoam/1.5
#Mesh the geometry, you can replace $PBS_O_WORKDIR to your OPENFOAM location
blockMesh -case $PBS_O_WORKDIR
#Decompose the mesh for parallel run
decomposePar -case $PBS_O_WORKDIR
#Run the solver
#simpleFoam $TMPDIR $OpenFOAM_case
mpirun -np 4 simpleFoam -case $PBS_O_WORKDIR -parallel
#Reconstruct the parallel results
reconstructPar -case $PBS_O_WORKDIR

To launch the script use qsub openfoam_par

cd openfoam

Check with module list command if openfoam appear in the list if not load with;

module load openfoam/1.5
module load paraview

OpenFOAM files need to be converted to VTK to be viewed with paraviw. Simply enter foamToVTK in the directory with your openFOAM files. This will create a separate directory VTK; change to this directory and enter paraview. A graphic window for paraview will appear on the desktop. Go to File->Open and select the parallel_openfoam.vtk file and select 'apply'.

Top of Page