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]
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
  -noFunctionObjects
                    Do not execute function objects
  -region <name>    Specify alternative mesh region
  -sets             Write cellZones as cellSets too (for processing purposes)
  -time <time>      specify a time to write mesh to
  -doc              Display documentation in browser
  -doc-source       Display source code in browser
  -help             Display short help 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-plus (1812) (see www.OpenFOAM.com)

Navigation

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>

returns

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>

returns

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:

Copyright ©  OpenCFD Ltd. 2017-2019
Creative Commons License