Getting Started

From Sapienza Rocket Team
Revision as of 22:42, 11 April 2025 by Argonon (talk | contribs)

First Step in OpenFoam

Once you have installed OpenFOAM, hopefully without losing your mind, you can start its environment by typing in the terminal

openfoamXXXX

where XXXX is the version selected during the download.

From now on, the journey begins.

Your First Case:

To run your first simulation, it is essential to understand how the software operates. Each simulation is organized into several sub-folders:

  • "Simulation_1"
    • "0"
    • "constant"
    • "system"

The 0 directory contains specifications for the boundary fields, including patch type and initial values.

The constant directory houses the geometry, mesh and files that define constant values, such as fluid or turbulence properties.

The system directory hold all the instruction needed, including the Solver, numeric schemes, number of iterations, multi-processing options, and more.

This is a brief overview of how a general case is structured in OpenFOAM. Below an illustration of how the directory should look. To clarify the upcoming paragraphs, we will use a tutorial located in the OpenFOAM sub-directory. You can access it by typing the following commands in your terminal :

cd $FOAM_TUTORIALS
cd incompressible/simpleFoam/motorBike/

0 directory

The 0 directory contain the following files :

  • "0.orig"
    • U
    • p
    • nut
    • k
    • omega

There is also another directory "include", but for now ignore it. The image on the right show how the file is structured.

In particular the image is referred to the U file, but all of them have the same structure. The file is like a key-value dictionary where the first key encountered is dimension, following internalField and boundaryField (we skipped the "#include" for now) . The dimension, as we can imagine, define the physical dimensional unit of the field. The array [ ... ] has 7 slots that represent 7 different units in this order:

OpenFOAM Dimensional Field Units
No. Property SI unit USCS unit
1 Mass kilogram (kg) pound-mass (lbm)
2 Length metre (m) foot (ft)
3 Time second (s) second (s)
4 Temperature Kelvin (K) degree Rankine (R)
5 Quantity mole (mol) mole (mol)
6 Current ampere (A) ampere (A)
7 Luminous intensity candela (cd) candela (cd)

The number given to the array represent the order of the dimension, for example ms is [0 1 -1 0 0 0 0].

Internal field key represent the value of the field at the beginning.

The boundary field key contains all the boundary conditions defined in the mesh. Each of them need a type and the relative options. Here is linked the standard boundary conditions list for OpenFOAM.

Constant Directory

The constant directory contain the following files :

  • "constant"
    • transportProperties
    • turbulenceProperties
    • ObjectFile - "polyMesh"

The last element in the list simply represent a 3D object or an already meshed object for OpenFOAM, underling that we need a specific mesh file/files for this software.

The other two file, transportProperties and turbulenceProperties , contains respectively the fluid physic properties, such dynamic viscosity or in general transport constant, and the turbulence model. On the left are showed images for both files.

In this example the turbulenceProperties file is set with a RAS (Reynolds Averaged Simulation) and the model selected is kOmegaSST. Values of k and omega are setted in the 0 directory, in the same name files.

System direcotry

the system directory can contain a lot of files, in particular it is possible to create your own script made in C++ with OpenFOAM library to achive a complete customization. By the way the main files are :

  • "system"
    • controlDict
    • fvSchemes
    • fvSolution
    • decomposePar

All other files are needed to create the mesh or obtain information about the solution, but explore those files is not the purpose of this page.

The controlDict is the core of the simulation. It contains the name of the method, in this case simpleFoam is the SIMPLE method, and other stuff like iteration number, start and end time of the simulation,