How to Run OpenFOAM


"OpenFOAM (Open Source Field Operation and Manipulation) is a C++ toolbox for the development of customized numerical solvers, and pre-/post-processing utilities for the solution of continuum mechanics problems, including computational fluid dynamics (CFD)."

Version 2.1.1 of OpenFOAM has been installed under "/share/apps/OpenFOAM/" on Lewis.

The executables/utilities are under "/share/apps/OpenFOAM/bin/". To check all the OpenFOAM programs,type

ls /share/apps/OpenFOAM/bin/
There is also an OpenFOAM Tutorial suite in the "/share/apps/OpenFOAM/tutorials/" directory, which includes a number of test examples. Users may copy those files to their own directory and learn how to run the OpenFOAM programs on specific applications.

1. Set the Environment Variable

Users will have to run the following command before using the OpenFOAM program/tools.
source /share/apps/OpenFOAM/etc/bashrc
or add the above command to your "~/.bashrc" file once for all.

2. Run the OpenFOAM serial Jobs

Assuming users have processed/prepared all the necessary input files for OpenFOAM (see "/share/apps/OpenFOAM/tutorials/" for examples), the command to submit an OpenFOAM job on lewis via LSF may look like this
bsub < jobfile
where "jobfile" is a LSF job script file that may look like this.
# Set job parameters
#BSUB -J jobname
#BSUB -oo jobname.o%J
#BSUB -eo jobname.e%J

# Start OpenFOAM job
fireFoam > log.fireFoam 2>&1
where "jobname" is an arbitrary name users want to set, "fireFoam" is one of the OpenFOAM programs, and "log.fireFoam" will incldue the running log informaiton.

3. Run the OpenFOAM MPI Jobs

For a paralell MPI job, the job script file might look like this
# Set job parameters
#BSUB -a openmpi
#BSUB -J jobname
#BSUB -oo jobname.o%J
#BSUB -eo jobname.e%J

# Set number of CPUs
#BSUB -n 4

# Start OpenFOAM job
mpirun.lsf fireFoam -parallel > log.fireFoam 2>&1
where "#BSUB -a openmpi" is required for an MPI job and should not be changed by users. Here, 4 cpus are used for the job, and users may set more or fewer cpus in their jobs according to the size of studied systems. NOTE: the number of cpus must be consistent with the specified number of cpus when you process the input files.
For more information about the usage of OpenFOAM, see the OpenFOAM Online Documentation.

For general information about how to submit jobs via LSF, please go to Submitting Jobs via LSF on Lewis.