OFcheat Sheet
OFcheat Sheet
Jens Höpken
s
our
ceflux
Sourceflux, www.sourceflux.de
Introduction Aliases
OpenFOAM is a library written in C++, that can handle all sorts of numerical
run jump to $FOAM_RUN app jump to $FOAM_APPLICATIONS
problems. Foremost it is used to solve fluiddynamical problems. In addition
sol jump to $FOAM_SOLVERS util jump to $FOAM_UTILITIES
to the library, it provides a lot of tools (pre- and postprocessing, solvers, mesh
foam jump to $WM_PROJECT_DIR foamfv jump to
generation), that are build upon the library.
A finite volume method is employed to discretise the computational domain and foamsrc jump to $FOAM_SRC/finiteVolume
all generated meshes are handled as being arbitrarily unstructured. $FOAM_SRC/$WM_PROJECT tut jump to $FOAM_TUTORIALS
This cheat sheet is by no means all-embracing and solely touches the surface of Solvers
OpenFOAM.
• simpleFoam is a steady state solver for an incompressible flow. Turbulence
Terminology modelling can either be laminar, RAS or LES.
• pimpleFoam is a transient solver for an incompressible flow. Turbulence
• case Project folder on the disk, containing all relevant information modelling can either be laminar, RAS or LES.
• dictionary Any file in the case, that is read by OpenFOAM to define parameters • interFoam solves the Navier-Stokes equations for two incompressible, inmiscible
• timestep Any folder in the case, that has a numerical name (e.g. 0.3 or 122) phases. Turbulence modelling can either be laminar, RAS or LES.
• interDyMFoam is similar to interFoam, but employs a dynamic mesh.
Rules of Conduct
Running in Parallel
• Always read and analyse the warnings and errors that you get from OpenFOAM
• Always execute OpenFOAM commands from the case folder Before starting a parallel run, the computational domain needs to be decomposed.
• OpenFOAM does only what you tell it to do. Nothing more, nothing less. The parameters are defined in system/decomposeParDict. To start the decom-
position, execute decomposePar before starting the parallel run via:
Case Struture > mpirun -np <N> <SOLVER> -parallel
<case>/ Where <N> denotes the number of subdomains and <SOLVER> represents the solver
0/ ............................................... Boundary conditions to run in parallel.
U .........................................Velocity boundary condition After the simulation is finished, you have to glue the subdomains together. For this
p ........................................ Pressure boundary condition task, reconstructPar is the tool of choice.
constant/ ................................... Mesh, physical properties
polyMesh/ ....................................................Mesh Using functionObjects
system/ ...........................................Solution controlling
fvSchemes .....................................Discretisation schemes
fvSolution ...........................................Solver settings In OpenFOAM, functionObjects are code snippets that can be loaded into any
controlDict ................................. Run control parameters solver during run-time. This enables each solver to be coupled with some additional
(0.*|[1-9]*)/ ...................................... Timestep folders functionality, that is independent from the flow model. All functionObjects have to
Mesh Generation be included in system/controlDict like the following:
functions
• blockMesh Blockstuctured mesh generation, that allows cell gradings and {
curved edges. Complex geometries are not easy to mesh. Definition in <name>
constant/polyMesh/blockMeshDict [1, 2]. {
• snappyHexMesh Generates a mesh based on one or multiple STL geomteries type <type>;
and a blockMesh background mesh. The result is always 3D and is hexahedral functionObjectLibs ("<lib>");
dominant, though other cell shapes exist. Definition in outputControl timeStep;
system/snappyHexMeshDict [1, 2]. outputInterval 1;
// Specific parameters for the functionObject
Boundary Conditions }
}
The boundary conditions are defined in the 0/ directory and each field has it’s own
definition. All files in that folder contain two sections: Integrating forces
1 The internalField specifies the initial values for all cells. This can either be
uniform for all cells or defined explicitely for each cell. To integrate the forces over a list of patches, the functionObject forces can be used
2 Values on the boundaries need to be defined in boundaryField, by selecting an
and must be included as shown in the previous section. The specific parameters are:
appropriate boundary condition. patches ( "<patchNames>" ); // This may be done regexp
pName p; // Name of the pressure field
• fixedValue represents the Dirichlet boundary condition and defines the solution
UName U; // Name of the velocity field
of a property φ on the boundary:
rhoName rhoInf; // Indicates incompressible
φ=n log false; // Only write to file
• zeroGradient represents the Neumann boundary condition and defines the rhoInf 1; // Redundant for incompressible
derivative of the solution of a property φ on the boundary: CofR (0.72 0 0); // Ref. point for moment calc.
∂φ The output is written to postProcessing/forces/<startTime>/forces.dat
=0
∂x and contains the pressure and viscous forces, as well as the pressure and viscous
• symmetryPlane is fairly self-explanatory moments. The data is grouped by round brackets, that need to be removed to plot
• empty must be used to create 2D meshes. All boundaries with normal vectors them in gnuplot. There are multiple ways to do that, using sed is just one of
that are not inside the 2D plane have to be defined as empty. them:
In addition to the boundary conditions mentioned above, there ?> sed -e ’s/[(,)]/ /g’ \
are much more implemented in OpenFOAM, just have a look into postProcessing/forces/<startTime>/forces.dat > tmp
$FOAM_SRC/finiteVolume/fields/fvPatchFields.
References
Preprocessing
[1] url: http://www.openfoam.com/docs/user.
• checkMesh should always be used after the mesh generation to check the
[2] T. Marić, J. Höpken, and K. Mooney. The OpenFOAM Technology Primer.
integrity of the mesh. Study and analyse the output! First Edition. Sourceflux, 2014. url: www.sourceflux.de/book.
• setFields can be used to initialise the fields with non uniform values (e.g. the
volume fraction field). Disclaimer
• mapFields maps the volume fields from one mesh to another.
OpenFOAM© and OpenCFD© are registered trademarks of OpenCFD Limited, the producer OpenFOAM software. All
Postprocessing registered trademarks are property of their respective owners. This offering is not approved or endorsed by OpenCFD
Limited, the producer of the OpenFOAM software and owner of the OPENFOAM© and OpenCFD© trade marks.