We design our OpenFOAM Training so that users can learn effective CFD, giving them the confidence to carry out CFD analysis, repeatedly, to a defined standard in a timely manner.  We provide 4 courses — Essential CFD, Applied CFD, Programming CFD and Cloud CFD — that teach reliable procedures to configure, run and maintain CFD simulations.  While creating and improving these courses, we have contributed tools to OpenFOAM for more productive CFD, so that users waste less time on routine tasks.

Template Cases (v4, commit 1cb715)

Template cases provide a convenient way to set up and start a new simulation, including a strategy to simplify meshing with snappyHexMesh.  The templates are located in the $FOAM_ETC/templates directory and are designed to create prototype simulations that run quickly with simple flow physics.  These prototype simulations provide reliable starting solutions from which users can build more complex simulations in small, manageable steps.  The following example creates a new case named case1 using a template case for simulations that include inflow and outflow:

cp -r $FOAM_ETC/templates/inflowOutflow case1

foamCloneCase (v4, commit 966c15)

foamCloneCase is a convenient tool to copy an established case directory, to start a new, modified simulation; e.g. to create case2 from case1:

foamCloneCase case1 case2

foamCleanCase (v9, commit fac831)

foamCleanCase is a simple script to clean a case directory, resetting it to its initial state. The mesh, time directories, postProcessing directory and other results files are all deleted. It is run from within a case directory simply by:

foamListTimes -rm (v4, commit 227f3a)

foamListTimes lists the time directories in the user’s case directory, omitting the 0 (zero) directory by default.  The -rm option deletes the listed time directories, so a user can restart an existing case by deleting previous results by running:

foamListTimes -rm

Post-Processing CLI, including postProcess (v4, commits 30e2f9, cacf16)

In OpenFOAM v4 we created unified set of tools to simplify post-processing, improve functionality and maintainability, supported by new documentation, see OpenFOAM User Guide, Sec. 6.2.  Post-processing code was all moved into function objects, which were packaged into individual configuration files within the $FOAM_ETC/caseDicts/postProcessing directory.  Packaged function objects can be listed as follows:

postProcess -list

Any function object, e.g. singleGraph, can be configured locally by copying it to the case system directory and editing it.  It can be included within a running simulation by using the #includeFunc directive within the controlDict file, e.g.:

    #includeFunc singleGraph

The function object can be run after the simulation using the postProcess utility, e.g.

postProcess -func singleGraph

or in some cases, running a solver with the -postProcess option, e.g.

simpleFoam -postProcess -func singleGraph

foamMonitor (v2.4, commit a95250)

foamMonitor provides a real-time view of time-value data written by packaged function objects, see OpenFOAM User Guide, Sec. 6.3.  For example, the following command monitors output from the residuals function object:

foamMonitor -l postProcessing/residuals/0/residuals.dat

foamGet (v6, commit 097e15)

foamGet copies sample case files, e.g. packaged function objects and utility dictionaries, into a case directory, see OpenFOAM User Guide, Sec. 4.6.3.  For example, the following command copies the singleGraph packaged function object into a case system directory (replacing the find and cp commands used in the video above):

foamGet singleGraph

Bash (TAB) Completion (v5, commit 90f39e)

In OpenFOAM v5, we introduced Bash completion, enabling users of OpenFOAM to to complete terminal commands and their arguments easily using the TAB key.  For example, type the following in a terminal window:

s i m p l e F TAB - l TAB TAB TAB Sc TAB -l TAB V TAB

This will produce the command in the following (-list.*) section.

-list.* Options (v5, commit a4e755)

The -list.* options list available models for a given solver, see OpenFOAM User Guide, Sec. 5.2.3.  For example, the following command lists the available boundary conditions when using simpleFoam:

simpleFoam -listScalarBCs -listVectorBCs

foamInfo (v6, commit 930f02)

foamInfo provides information and examples relating to a subject that the user provides, see OpenFOAM User Guide, Sec. 4.6.4 . The subject can relate to: models, including boundary conditions and packaged function objects; applications; and, scripts. For example, the following command prints information about the simpleFoam solver, flowRateInletVelocity boundary condition, surfaces function object and kEpsilon turbulence model:

foamInfo simpleFoam
foamInfo flowRateInletVelocity
foamInfo surfaces
foamInfo kEpsilon

In OpenFOAM-v9, foamInfo lists other models in the same family when printing information about a model.

foamDictionary (v4, commit 615edf)

The foamDictionary utility offers several options for writing, editing and adding keyword entries in case files, see OpenFOAM User Guide, Sec. 4.6.2.  In particular, it can modify case files within batch scripts, e.g. the following command changes the end time to 500 in the controlDict file:

foamDictionary -entry endTime -set 500 system/controlDict

In OpenFOAM-v9, foamDictionary can substitute values using keyword=value syntax, e.g. the following is equivalent to the command above:

foamDictionary -set "endTime=500" system/controlDict

Reading .orig Files (v6, commit df6e2d)

Some simulations require initialisation of non-uniform fields, e.g. the phase fraction of a liquid alpha.liquid for a liquid-gas interface.  For convenience, the user typically initialises a uniform field in an equivalent field file with the “.orig” extension, e.g. alpha.water.orig.  That file is then read by a utility such as setFields which calculates the non-uniform field and writes it to file.  Prior to OpenFOAM v6, the “.orig” file had to be copied without the extension, prior to running the utility.  From v6, the “.orig” file is read automatically and written to a new file without the extension.

foamCreateVideo (v2.4, commit 29394d)

The foamCreateVideo script creates a video file from a sequence of PNG images, typically exported for animation from ParaView.  In the simplest example, the user needs only to provide the frame rate using the -fps option, e.g.:

foamCreateVideo -fps 4

foamSequenceVTKFiles (v2.4, commit 457288)

To create an animation from a series of VTK files in ParaView, each file must include an integer in its name to indicate its position in the series, e.g. image.0020.vtk.   The foamSequenceVTKFiles script searches the postProcessing directory for VTK files and creates a soft link to each file in a sequencedVTK directory, with naming that ParaView recognises as a series.  Any series can then simply be opened from the sequencedVTK directory within ParaView.

foamNewFunctionObject (v4, commit 59f7f1)

The foamNewFunctionObject script generates starter code for programming a new function object in OpenFOAM.  For example, the following command creates code for a new function object named energy:

foamNewFunctionObject energy

foamNewBC (v4, commit 6b67e3)

The foamNewBC script generates starter code for programming a new boundary condition in OpenFOAM.  For example, the following command creates starter code for a boundary condition named rampVelocity, see video below:

foamNewBC -fixedValue -vector rampVelocity

Productive CFD with OpenFOAM
Tagged on: