Example Two
Example Two
Built in Mesh
This offering is not approved or endorsed by ESI® Group, ESI-OpenCFD® or the OpenFOAM®
Foundation, the producer of the OpenFOAM® software and owner of the OpenFOAM® trademark.
OpenFOAM® Basic Training
Tutorial Two
ISBN 978-3-903337-02-2
Publisher: chemical-engineering.at
Available from: www.fluiddynamics.at
OpenFOAM® Basic Training
Tutorial Two
Background
1. What is mesh?
The partial differential equations that describe fluid flow and heat transfer are
the conservation equations of mass, energy and momentum. However, we are
usually unable to solve them analytically, except in very simple cases. This is
when discretization comes in. The flow region is broken up into smaller sub-
regions, with the equations solved in each sub-region. One of the methods used
to solve the equations is the finite volume method, which we will cover in detail
below. The sub-regions are later on referred to as grid cells, with a collection of
grid cells forming a mesh.
= ∫ ∫ 𝒏 ∙ (𝛤∇𝜑) 𝑑𝐴𝑑𝑡 + ∫ ∫ 𝑆𝜑 𝑑𝑉 𝑑𝑡
∆𝑡 𝐴 ∆𝑡 𝐶𝑉
OpenFOAM® Basic Training
Tutorial Two
4. rhoPimpleFoam solver
rhoPimpleFoam is a transient solver. It solves trans-sonic/supersonic, turbulent
flow of a compressible gas/fluid.
OpenFOAM® Basic Training
Tutorial Two
rhoPimpleFoam – forwardStep
Tutorial outline
Using rhoPimpleFoam solver, simulate 10 s of flow over a forward step.
Objectives
• Understand blockMesh
• Define vertices via coordinates as well as surfaces and volumes via
vertices.
Data processing
Import your simulation into ParaView, and examine the mesh and the results in
detail.
OpenFOAM® Basic Training
Tutorial Two
1. Pre-processing
$FOAM_TUTORIALS/compressible/rhoPimpleFoam/laminar/forwar
dStep
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * *//
OpenFOAM® Basic Training
Tutorial Two
In the thermoType, the models for calculating thermo physical properties of gas
are set:
- type: Specifies the underlying thermos-physical model.
- mixture: Is the model which is used for the mixture, whether it is a pure
mixture, a homogeneous mixture, a reacting mixture or ….
- transport: Defines the used transport model. In this example a
constant value is used.
- thermo: It defines the method for calculating heat capacities, e.g. in this
example constant heat capacities are used.
- equationOfState: Shows the relation which is used for the
compressibility of gases. Here ideal gas model is applied by selecting
perfectGas.
- energy: This key word lets the solver decide which type of energy
equation it should solve, enthalpy or internal energy.
After defining the models for different thermos-physical properties of gas, the
constants and coefficients of each model are defined in the sub-dictionary
mixture. E.g. molWeight shows the molecular weight of gas, Cp stands for
heat capacity, Hf is the heat of fusion, mu is the dynamic viscosity and Pr shows
the Prandtl number.
By opening the momentumProperties the appropriate turbulent mode can be
set (in this case it is laminar):
simulationType laminar;
>nano blockMeshDict
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * *//
convertToMeters 1;
vertices
(
(0 0 -0.05)
(0.6 0 -0.05)
(0 0.2 -0.05)
(0.6 0.2 -0.05)
(3 0.2 -0.05)
(0 1 -0.05)
(0.6 1 -0.05)
(3 1 -0.05)
(0 0 0.05)
(0.6 0 0.05)
(0 0.2 0.05)
(0.6 0.2 0.05)
(3 0.2 0.05)
(0 1 0.05)
(0.6 1 0.05)
(3 1 0.05)
OpenFOAM® Basic Training
Tutorial Two
);
blocks
(
hex (0 1 3 2 8 9 11 10) (25 10 1) simpleGrading (1 1 1)
hex (2 3 6 5 10 11 14 13) (25 40 1) simpleGrading (1 1 1)
hex (3 4 7 6 11 12 15 14) (100 40 1) simpleGrading (1 1 1)
);
defaultPatch
{
type empty;
}
boundary
(
inlet
{
type patch;
faces
(
(0 8 10 2)
(2 10 13 5)
);
}
outlet
{
type patch;
faces
(
(4 7 15 12)
);
}
bottom
{
type symmetryPlane;
faces
(
(0 1 9 8)
);
}
top
{
type symmetryPlane;
faces
(
(5 13 14 6)
(6 14 15 7)
);
}
obstacle
{
type patch;
faces
(
(1 3 11 9)
(3 4 12 11)
);
}
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * *//
Tutorial Two
shows that the dimensions are in millimeter, and by multiplying them by 0.001
they are converted into meters.
In the vertices part, the coordinates of the geometry vertices are defined, the
vertices are stored and numbered from zero, e.g. vertex (0 0 -0.05) is
numbered zero, and vertex (0.6 1 -0.05) points to number 6.
In the block part, blocks are defined. The array of numbers in front each block
shows the block building vertices, e.g. the first block is made of vertices (0 1
3 2 8 9 11 10).
After each block, the mesh is defined in every direction. e.g. (25 10 1) shows
that this block is divided into:
- 25 parts in x direction
- 10 parts in y direction
- 1 part in z direction
As it was explained before, even for 2D simulations the mesh and geometry
should be 3D, but with one cell in the direction, which is not going to be solved,
e.g. here number of cells in z direction is one and it’s because of that it’s a 2D
simulation in x-y plane.
The last part, simpleGrading(1 1 1) shows the size function.
In the boundary part, each boundary is defined by the vertices it is made of,
and its type and name are defined.
Note: For creating a face, the vertices should be chosen clockwise when
looking at the face from inside of the geometry.
2. Running simulation
Before running the simulation, the mesh has to be created. In the previous step,
the mesh and the geometry data were set. For creating it, the following
command should be executed from the case main directory (e.g. forwardStep):
>blockMesh
After that, the mesh is created in the constant/polyMesh folder. For running the
simulation, type the solver name form case directory and execute it:
>rhoPimpleFoam
3. Post-processing
The mesh is presented in the following way in ParaView, and you can easily
see the three blocks, which were created.
OpenFOAM® Basic Training
Tutorial Two
Note: When a cut is created by default in ParaView, the program shows the
mesh on that plane as a triangular mesh even if it is a hex mesh. In fact,
ParaView changes the mesh to a triangular mesh for visualization, where every
square is represented by two triangles. For avoiding this when creating a cut in
ParaView in the Slice properties window, uncheck “Triangulate the Slice”.
The simulation results are as follows:
0.5 s
1s
10 s
Tutorial Two