Skip to content

OpenFOAM setup (fluid)

Makis Chourdakis edited this page Nov 28, 2017 · 18 revisions

OpenFOAM reads several configuration files, which are included in a case directory. In our tutorial, for the Fluid participant, we see the following files:

  • 0/: State of the domain at time=0. In other words: the initial and boundary conditions.
    • T: Temperature field
    • U: Velocity
    • alphat: Turbulent thermal diffusivity
    • epsilon, k: Parameters of the k-epsilon turbulence model (disabled by default)
    • nut: Turbulent viscosity
    • p and p_rgh: Pressure
  • constant/: Model properties
    • g: Gravity
    • thermophysicalProperties: Properties of the thermophysical model (thermodynamics, transport, etc.)
    • turbulenceProperties: Properties of the turbulence model. By default it is set to laminar flow.
  • system/: Solver properties
    • blockMeshDict: Mesh properties. The mesh is produced with the command blockMesh.
    • controlDict: Time step length, end time, output settings etc
    • fvSchemes: Finite Volume Schemes - the numerical schemes
    • fvSolution: Finite Volume Solution - the numerical solvers' parameters
  • Fluid.foam: An empty file that serves as a reference to ParaView
  • precice-adapter-config.yml: Our adapter's configuration file

Let's see the most relevant files in more details.

Mesh generation

The mesh for this case is defined in the system/blockMeshDict file. This is one of the ways to define a mesh in OpenFOAM, which does not require a geometry file.

In this file, the section vertices( ... ) specifies geometry points in the form (x y z). In the blocks( ... ) sections, the vertices are used to create blocks:

blocks
(
    hex (12 0 3 13 15 4 7 14) (81 41 1) simpleGrading (.2 15 1)
    hex (0 1 2 3 4 5 6 7) (161 41 1) simpleGrading (5 15 1)
    hex (1 8 9 2 5 10 11 6) (51 41 1) simpleGrading (1 15 1)
);
  • Each line corresponds to a block.
  • The hex means hexahedral cells.
  • The first set of numbers defines the vertices used for the block and the numbers correspond to the order they were defined in the vertices. When defining blocks, the order of the nodes in each block needs to follow the "right-hand rule".
  • The second set of numbers is the cells per (x y z) direction. Here, we only use one cell in the z (depth) direction.
  • The rest of the line defines the cell grading or mesh stretching. Here, the method simpleGrading is used. The set of numbers define the ratio of the size of the last cell in each direction to the first one.

In this file we also define the boundaries of the geometry in the boundary( ... ) section. For example:

interface
{
    type wall;
    faces
    (
        (4 0 1 5)
    );
}

defines a wall boundary, named interface, that consists of one face. These numbers refer again to the geometry points and need to follow the "right-hand rule". We are going to use this boundary as the coupling interface.

In order to generate the mesh, we run blockMesh. This is done in the run scripts.