Getting Started: Difference between revisions

From Sapienza Rocket Team
Argonon (talk | contribs)
No edit summary
Argonon (talk | contribs)
No edit summary
Line 23: Line 23:
cd incompressible/simpleFoam/motorBike/</syntaxhighlight>
cd incompressible/simpleFoam/motorBike/</syntaxhighlight>


== 0 directory ==
=== 0 directory ===
[[File:U_file_photo.png|thumb|410x410px]]
[[File:U_file_photo.png|thumb|410x410px]]
The 0 directory contain the following files :  
The 0 directory contain the following files :  
Line 86: Line 86:
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 [https://www.openfoam.com/documentation/user-guide/a-reference/a.4-standard-boundary-conditions standard boundary conditions] list for OpenFOAM.
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 [https://www.openfoam.com/documentation/user-guide/a-reference/a.4-standard-boundary-conditions standard boundary conditions] list for OpenFOAM.


== Constant Directory ==
=== Constant Directory ===
[[File:Turbulentproperties image.png|thumb|300x300px]]The constant directory contain the following files :  
[[File:Turbulentproperties image.png|thumb|300x300px]]The constant directory contain the following files :  


Line 100: Line 100:
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.  
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 directory ==
=== System directory ===
[[File:ControlDict image.png|thumb|257x257px]]
[[File:ControlDict image.png|thumb|257x257px]]
The system directory can contain many files. In particular, you can create your own script in C++ using the OpenFOAM library to achieve complete customization. The main files of interest are: [[File:DecomposePar image.png|thumb|244x244px]]
The system directory can contain many files. In particular, you can create your own script in C++ using the OpenFOAM library to achieve complete customization. The main files of interest are: [[File:DecomposePar image.png|thumb|244x244px]]

Revision as of 19:06, 14 April 2025

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 directory

The system directory can contain many files. In particular, you can create your own script in C++ using the OpenFOAM library to achieve complete customization. The main files of interest are:

While there are additional files needed to create the mesh or collect information about the solution, exploring these files is not the focus of this page.

The controlDict is the core of the simulation. It specifies the simulation method ,here simpleFoam is the SIMPLE method, along with other important details such as the iteration number, start and end times of the simulation, and more. The function key allow the user to add existing function, like forceCoeffs , to evaluate aerodynamics coefficients in a specific reference system.

fvSchemes and fvSolution contains the divergence schemes for all the fields, gradients, flux, etc., as well as the solvers for each field, complete with various controls on residuals, tolerances, and other parameters. We will not delve deeply into these two files, as they are quite complex and not the focus of this section.

Lastly, the decomposePar, allow the user to decompose the case in different part using various methods. In this example the hierarchical method is employed, specifying how many pieces the case should be split into. This decomposition aims to parallelize the process across CPU cores, thereby speeding up the solution.