Command line interface *user@openfoam:~$...*

Basic usage

OpenFOAM comprises many applications, primarily designed to be driven by the command line. Whilst sometimes unfamiliar to new users, this interface provides the most flexible means by which to control the phases of case set-up, execution and evaluation of results, and lends itself to automation and batch-processing.

Applications are typically invoked using commands of the form:

<application> [OPTIONS] <arguments>

More detailed usage information is available using the help option; for example, when applied to the blockMesh application as:

blockMesh -help

the following text is presented:

Usage: blockMesh [OPTIONS]
  -blockTopology    write block edges and centres as .obj files
  -case <dir>       specify alternate case directory, default is the cwd
  -dict <file>      specify alternative dictionary for the blockMesh description
                    do not execute functionObjects
  -region <name>    specify alternative mesh region
  -sets             write cellZones as cellSets too (for processing purposes)
  -srcDoc           display source code in browser
  -doc              display application documentation in browser
  -help             print the usage

Block description

  For a given block, the correspondence between the ordering of
  vertex labels and face labels is shown below.
  For vertex numbering in the sequence 0 to 7 (block, centre):
    faces 0 (f0) and 1 are left and right, respectively;
    faces 2 and 3 are bottom and top;
    and faces 4 and 5 are front the back:

           4 ---- 5
      f3   |\     |\   f5
      |    | 7 ---- 6   \
      |    0 |--- 1 |    \
      |     \|     \|    f4
      f2     3 ---- 2

            f0 ----- f1

Using: OpenFOAM-plus (see
Build: plus-3d414cf4be8a


Useful commands

Moving around the source code and cases is easily performed using standard linux commands, e.g.

  • ls: list directory contents
  • cd: change directory

In addition, several aliases are available which provide short cuts to many OpenFOAM directories. These include:

  • foam: change to the main OpenFOAM project directory
  • src: change to the top-level source directory
  • sol: change to the top-level solver directory
  • util: change to the top-level utilties directory
  • tut: change to the top-level tutorial directory

Tab completion

Command line tab completion of OpenFOAM applications presents users with selections that are tailored for the current action. For example, issuing

checkMesh <TAB> <TAB>

returns the list of available options for the checkMesh utility:

-allGeometry        -help               -noZero             -writeAllFields
-allTopology        -latestTime         -parallel           -writeFields
-case               -meshQuality        -region             -writeSets
-constant           -newTimes           -roots
-decomposeParDict   -noFunctionObjects  -srcDoc
-doc                -noTopology         -time

Many options require additional user input, shown by the -option <value> type entries when requesting help via the -help option as shown in the previous blockMesh example.

If using the -time option, the completion will limit the options to the list of availabe times, e.g. after running the $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity tutorial:

checkMesh -time <TAB> <TAB>


0    0.1  0.2  0.3  0.4  0.5

Multi-region cases are notoriously complex to set-up and process. The -region option will limit the available options to the list of regions, e.g. applied to the $FOAM_TUTORIALS/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger tutorial

checkMesh -region <TAB> <TAB>


air     porous

Copyright ©  OpenCFD Ltd. 2017, 2018
Creative Commons License