Sie sind auf Seite 1von 22

Getting started with OpenFOAM applications: solvers and utilities

Eric Paterson
egp@vt.edu

Kevin T. Crofton Department of Aerospace and Ocean Engineering


Virginia Polytechnic Institute and State University

ESOP Workshop
5-8 June 2017
Outline

1 Introduction

2 Standard Solvers

3 Finding and Running Tutorials

4 Standard Utilities

5 Case Structure

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 2 / 22
Applications in OpenFOAM

OpenFOAM is first and foremost a C++ library, used primarily to create


executables, known as applications. The applications fall into two categories:
solvers – designed to solve a specific continuum mechanics problem
utilities – designed to perform tasks that involve data manipulation
OpenFOAM is distributed with a large number of applications, covering some
different aspects of what can be done with OpenFOAM. Don’t view these
applications as a limit of what you can do, instead view them as examples of what
you can do.
Any advanced user will develop new applications for his/ her special needs. The
basic way to do this is to find and copy an application that almost does what is
needed, and then to modify it by copy/ paste from other applications that has
some features that are needed.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 3 / 22
Finding applications (source code) in OpenFOAM

The source code for the applications is arranged in a structure that is useful for
finding the application you need
Use the pre-defined alias "app" to go to the source code applications directory
(alias app = ’cd $FOAM_APP’)
There you will find:

Allwmake is used to compile all the applications


solvers contains the source code of the solvers
test contains source code for testing specific features of OpenFOAM
utilities contains the source code of the utilities
Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 4 / 22
Finding applications (source code) in OpenFOAM

In $FOAM_APP/solvers (alias sol = ’cd $FOAM_SOLVERS’) you find the


source code for the solvers:

Note the descriptive nature of the directory names, which is described by the type
of physical phenomena solved.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 5 / 22
Finding applications (source code) in OpenFOAM

Let’s have a look at the incompressible solvers ($FOAM_SOLVERS/incompressible) :

Inside each solver directory you find a *.C file with the same name as the directory. This is the
main file, where you will find the top-level source code and a short description of the solver.
Most solvers have self-explanatory names (at least once you are familiar with OpenFOAMese):
icoFoam – Transient solver for incompressible, laminar flow of Newtonian fluids
simpleFoam – Steady-state solver for incompressible flows with turbulence
modelling.
pisoFoam – Transient solver for incompressible, turbulent flow, using the PISO
algorithm.
If all else fails, read the commented description in the source file
Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 6 / 22
Some standard OpenFOAM solvers

Basic solvers
laplacianFoam: Laplace equation solver for a scalar quantity.
potentialFoam: Potential flow solver which solves for the velocity potential, to calculate the
flux-field, from which the velocity field is obtained by reconstructing the flux. The potential flow
solution is typically employed to generate initial fields for full Navier-Stokes codes.
scalarTransportFoam: Solves a transport equation for a passive scalar.
Incompressible flow
icoFoam: Transient solver for incompressible, laminar flow of Newtonian fluids
nonNewtonianIcoFoam: Transient solver for incompressible, laminar flow of non-Newtonian
fluids..
pimpleFoam: Large time-step transient solver for incompressible, turbulent flow, using the
PIMPLE (merged PISO-SIMPLE) algorithm.
pisoFoam: Transient solver for incompressible, turbulent flow, using the PISO algorithm.
simpleFoam: Steady-state solver for incompressible flows with turbulence modelling.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 7 / 22
Some standard OpenFOAM solvers

Compressible flow
rhoCentralFoam: Density-based compressible flow solver based on central-upwind schemes of
Kurganov and Tadmor.
rhoPimpleFoam: Transient solver for turbulent flow of compressible fluids for HVAC and similar
applications.
rhoSimpleFoam: Steady-state solver for turbulent flow of compressible fluids.
sonicFoam: Transient solver for trans-sonic/supersonic, turbulent flow of a compressible gas.
Heat transfer
buoyantBoussinesqPimpleFoam: Transient solver for buoyant, turbulent flow of incompressible
fluids.
buoyantPimpleFoam: Transient solver for buoyant, turbulent flow of compressible fluids for
ventilation and heat-transfer.
chtMultiRegionFoam: Transient solver for buoyant, turbulent fluid flow and solid heat
conduction with conjugate heat transfer between solid and fluid regions.
thermoFoam: Solver for energy transport and thermodynamics on a frozen flow field.
Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 8 / 22
Some standard OpenFOAM solvers

Multiphase flow
cavitatingFoam: Transient cavitation code based on the homogeneous equilibrium model from
which the compressibility of the liquid/vapour "mixture" is obtained.
compressibleInterFoam: Solver for 2 compressible, non-isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach
interFoam: Solver for 2 incompressible, isothermal immiscible fluids using a VOF (volume of
fluid) phase-fraction based interface capturing approach.
interPhaseChangeFoam : Solver for 2 incompressible, isothermal immiscible fluids with
phase-change (e.g. cavitation). Uses a VOF (volume of fluid) phase-fraction based interface
capturing approach.
Electromagnetics
electrostaticFoam: Solver for electrostatics.
magneticFoam: Solver for the magnetic field generated by permanent magnets.
mhdFoam: Solver for magnetohydrodynamics (MHD): incompressible, laminar flow of a
conducting fluid under the influence of a magnetic field.

. . . and many more


Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 9 / 22
Finding solver tutorials/example cases in OpenFOAM

Tutorials/example cases exist for most solvers.


Use the pre-defined alias tut to go to the tutorials directory, where there are
complete set–ups of cases for all the solvers.
Note that it is recommended to copy the tutorials to your
$WM_PROJECT_USER_DIR/run directory before running them or making any
modification to them, so that you always have a clean version of the tutorials
(more on environment variables later).

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 10 / 22
Finding solver tutorials/example cases in OpenFOAM

Let’s have a look at the tutorials directory (OpenFOAM v1612+):

The directory organizaton of the tutorials is much like that of the solvers, making
it much easier to find a desired example case.
Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 11 / 22
Utilities in OpenFOAM

In the utilities directory ($FOAM_APP/utilities) you find the source code for
the utilities.
Use the pre-defined alias util to go directly there.
The utilities are arrange according to:

Let’s look in mesh:

. . . and in mesh/generation:

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 12 / 22
Utilities in OpenFOAM

Inside each utility directory you find a *.C file with the same name as the directory.
This is the main file, where you will find the top–level source code and a short
description of the utility.
Some utilities require a dictionary for specifying input parameters. If one is
required, an example or "boilerplate" will be in the directory, too.
For snappyHexMesh :

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 13 / 22
Some standard OpenFOAM utilities

preProcessing [1]
applyBoundaryLayer: Apply a simplified boundary-layer model to the velocity and turbulence
fields based on the 1/7th power-law.
boxTurb: Makes a box of turbulence which conforms to a given energy spectrum and is
divergence free.
changeDictionary: Utility to change dictionary entries, e.g. can be used to change the patch type
in the field and polyMesh/boundary files.
createExternalCoupledPatchGeometry: Application to generate the patch geometry (points and
faces) for use with the externalCoupled functionObject.
createZeroDirectory: Creates a zero directory with fields appropriate for the chosen solver and
turbulence model. Operates on both single and multi-region cases.
dsmcInitialise: Initialize a case for dsmcFoam by reading the initialization dictionary
system/dsmcInitialise
engineSwirl: Generates a swirling flow for engine calulations.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 14 / 22
Some standard OpenFOAM utilities

preProcessing [2]
faceAgglomerate: Agglomerate boundary faces using the pairPatchAgglomeration algorithm.
foamUpgradeCyclics: Tool to upgrade mesh and fields for split cyclics.
mapFields: Maps volume fields from one mesh to another, reading and interpolating all fields
present in the time directory of both cases.
mapFieldsPar: Maps volume fields from one mesh to another, reading and interpolating all fields
present in the time directory of both cases.
mdInitialise: Initialises fields for a molecular dynamics (MD) simulation.
setFields: Set values on a selected set of cells/patchfaces through a dictionary.
viewFactorsGen: View factors are calculated based on a face agglomeration array.
wallFunctionTable: Generates a table suitable for use by tabulated wall functions

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 15 / 22
Some standard OpenFOAM utilities

postProcessing
noise: Utility to perform noise analysis of pressure data.
postProcessing: Execute the set of functionObjects specified in the selected dictionary (which
defaults to system/controlDict) or on the command-line for the selected set of times on the
selected set of fields.
postProcessing/dataConversion
foamDataToFluent: Translates OpenFOAM data to Fluent format.
foamToEnsight: Translates OpenFOAM data to EnSight format.
. . . plus a lot more

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 16 / 22
Some standard OpenFOAM utilities

parallelProcessing
decomposePar: Automatically decomposes a mesh and fields of a case for parallel execution of
OpenFOAM.
reconstructPar: Reconstructs fields of a case that is decomposed for parallel execution of
OpenFOAM.
reconstructParMesh: Reconstructs a mesh using geometric information only.
redistributePar: Redistributes existing decomposed mesh and fields according to the current
settings in the decomposeParDict file.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 17 / 22
Some standard OpenFOAM utilities

mesh/generation
blockMesh: A multi-block mesh generator.
extrude: Extrude mesh from existing patch (by default outwards facing normals; optional flips faces) or
from patch read from file.
extrude2DMesh: Takes 2D mesh (all faces 2 points only, no front and back faces) and creates a 3D
mesh by extruding with specified thickness.
foamyMesh: Conformal Voronoi automatic mesh generator
snappyHexMesh: Automatic split hex mesher. Refines and snaps to surface.
mesh/manipulation - numerous
checkMesh: Checks validity of a mesh.
mergeMeshes: Merges two meshes.
refineMesh: Utility to refine cells in multiple directions.
renumberMesh: Renumbers the cell list in order to reduce the bandwidth, reading and renumbering all
fields from all the time directories.
transformMesh: Transforms the mesh points in the polyMesh directory according to the translate, rotate
and scale options.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 18 / 22
Some standard OpenFOAM utilities

Miscellaneous utilities
foamDictionary: Interrogates and manipulates dictionaries.
foamFormatConvert: Converts all IOobjects associated with a case into the format specified in
the controlDict.
foamHelp: Top level wrapper utility around foam help utilities
foamList: Print the table of contents of selectable switches, classes etc. in the OpenFOAM
libraries
foamListTimes: List times using timeSelector.
patchSummary: Writes fields and boundary condition info for each patch at each requested time
instance.

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 19 / 22
Finding tutorials for the utilities in OpenFOAM

There are no specific tutorials for the utilities, but many of the solver tutorials also
show how to use the utilities. (We will have a look at some of them while we run
through the icoFoam cavity tutorial.)
The best way to find examples of how to use a specific utility:
Go to the utility source code and find the name of the dictionary required for that
utility. For example, for snappyHexMesh:

Search for instances of that dictionary in the OpenFOAM tutorials:


find $FOAM_TUTORIALS -name *Dict | grep snappyHexMeshDict
Of course, you could also search for all dictionaries in the OpenFOAM tutorials via:
find $FOAM_TUTORIALS -name *Dict | less
Finally, most utilities take arguments, including the -help argument

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 20 / 22
Running solver tutorial cases in OpenFOAM

In general, if you have questions on running a specific tutorial case see the
Allrun script (if it exists).
This will show which utilities must also be executed to successfully run a tutorial
case
For example, see $FOAM_TUTORIALS/interFoam/Allrun:

Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 21 / 22
The OpenFOAM case structure

Before we try running the icoFoam cavity tutorial, first a brief


introduction to the OpenFOAM case structure
Each OpenFOAM simulation is organized in its own case directory
There are 3 main subdirectories for each case:
system – contains dictionaries for setting parameters associated with the
solution procedure itself (time step size, discretezation schemes, solution
schemes, etc.)
constant – contains the case mesh in a subdirectory polyMesh and
files specifying physical properties for the application concerned,
e.g.transportProperties.
time directories – contain solution files for particular fields at each
time step
The relevant solver and any utilities are all executed in the top level of the
case directory
Eric Paterson (Virginia Tech AOE) Getting started with OpenFOAM applications 5-8 June 2017 22 / 22

Das könnte Ihnen auch gefallen