How is an application programmed in OpenFOAM?

CFD Direct's Programming CFD course shows how to code applications in OpenFOAM

Programming CFD

Chapter 3 Applications and libraries

The examples in Chapter 2 show that OpenFOAM provides a range of software ‘tools’ that are run from a terminal command line. The tools include applications which are executable programs written in C++, the base programming language of OpenFOAM. Applications obtain most of the functionality from OpenFOAM’s vast store of pre-compiled libraries, also written in C++. Since OpenFOAM is open source software, users have the freedom to create their own applications and libraries. Applications are generally split into two categories:

  • solvers, e.g. foamRun, that perform CFD calculations involving fluid dynamics, energy, etc.;

  • utilities, e.g. blockMesh and foamPostProcess, that perform other tasks in CFD like meshing and post-processing.

Prior to version 11 of OpenFOAM, there were many solvers, since separate ones were written for various different types of flow, e.g. simpleFoam, pimpleFoam, etc. However, most flow solvers are now written as modules, e.g. incompressibleFluid, incompressibleVoF and e.g.solid which are loaded by the general foamRun (or foamMultiRun) solvers. Rather than existing as an application, each solver module is compiled into a library of its own.

In addition to applications, the tools in OpenFOAM also include shell scripts, e.g. paraFoam, foamInfo and foamGet. Many of the scripts help with the configuration of cases.

This chapter gives an overview of applications and libraries, including their creation, modification, compilation and execution.

OpenFOAM v12 User Guide - Chapter 3 Applications and libraries
OpenFOAM User Guide