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 and exit
  -case <dir>       Specify case directory to use (instead of the cwd)
  -dict <file>      Alternative dictionary for the blockMesh description
  -noClean          Do not remove any existing polyMesh/ directory or files
  -region <name>    Specify alternative mesh region
  -sets             Write cellZones as cellSets too (for processing purposes)
  -time <time>      Specify a time to write mesh to (default: constant)
  -doc              Display documentation in browser
  -help             Display short help and exit
  -help-compat      Display compatibility options and exit
  -help-full        Display full help and exit

Block mesh generator.
  The ordering of vertex and face labels within a block as shown below.
  For the local vertex numbering in the sequence 0 to 7:
    Faces 0, 1 (x-direction) are left, right.
    Faces 2, 3 (y-direction) are front, back.
    Faces 4, 5 (z-direction) are bottom, top.
                        7 ---- 6
                 f5     |\     |\     f3
                 |      | 4 ---- 5     \
                 |      3 |--- 2 |      \
                 |       \|     \|      f2
                 f4       0 ---- 1
    Y  Z
     \ |                f0 ------ f1
       O--- X

Using: OpenFOAM-v1906 (1906) (see
Build: v1906
Arch:  LSB;label=32;scalar=64


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 utilities 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		-latestTime		-roots			-help
-allTopology		-meshQuality		-time			-help-man
-case			-noFunctionObjects	-writeAllFields		-help-notes
-constant		-noTopology		-writeFields		-help-full
-decomposeParDict	-noZero			-writeSets
-fileHandler		-parallel		-doc
-hostRoots		-region			-doc-source

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 tutorial:

Invoking the following:

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 tutorial:

Invoking the following:

checkMesh -region <TAB> <TAB>


air     porous

Command line help

Manual pages provide a straightforward interface to access the options available to all OpenFOAM applications. See the full list of options here:

Would you like to suggest an improvement to this page? Create an issue

Copyright © 2017 OpenCFD Ltd.

Licensed under the Creative Commons License BY-NC-ND Creative Commons License