Week 8 - Simulation of a backward facing step in OpenFOAM
AIM:
To simulate an incompressible-laminar-viscous flow through the backward-facing step geometry.
CASES TO PERFORM:
Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)
Case 2 - Simulate the flow with a grading factor of 0.2. The cells should be finer near the wall (including the step wall).
Introduction:
The backward-facing step geometry is a classic example that offers insight into the phenomena of separating and attaching flows otherwise commonly observed in aerodynamic applications like flow over airfoil and diffusers to name a few. This challenge aims to perform two-dimensional transient numerical simulations of an incompressible-laminar-viscous flow through the backward-facing step geometry wherein the grading factor defining all the hex blocks for the given computational domain remains unchanged i.e., GF=1 while in another setup, the grading factor change to 0.2 such that cells are finer near the walls, including at the step wall.
Method:
The typical approach adopted to performing numerical simulation in open FOAM involves the following steps:
- Identifying the tutorial in the ‘FOAM_TUTORIALS’ folder that contains the appropriate governing equations relevant to the physics of the flow for the given problem. A typical file structure of an open FOAM tutorial consists of the below-mentioned directories and files:
- A ‘system’ directory with the ‘contradict; ‘fvSchemes’ and ‘fvSolution’ files are used for specifying the numerical schemes and solution procedure along with control on the simulation run properties. Additionally, for the numerical problem, a file by the name ‘blockMeshDict’ mentions the creation of different blocks representing the geometry as well as its mesh properties.
- A ‘constant’ directory that contains a ‘polyMesh’ directory outlining the various aspects of the mesh such as ‘boundary’,’ points’,’ faces’, etc., and a file that defines the physical properties in this case, ‘transportProperties’
- A time directory usually called the ‘O’ directory that consists of files representing the different fields or fluid flow properties with values as required at the start of the simulation run or at time t = O.
- Copying the now identified tutorial folder from the ‘FOAM’_TUTORIALS’ folder to the ‘FOAM_RUN’ folder, specifically created to allow simulation run of Open FOAM numerical simulation cases, with either the same name or preferably a name relevant to the geometry to be discretized.
- Replacing the geometry and boundary list of the pre-existing tutorial with the geometry and boundary list of the given problem and defining mesh parameters with regards to the flow physics, in this case by updating the ‘blockMeshDict’ file (Section 2.1 Modelling).
- Updating the fields’ files present inside the ‘O’ directory viz., ‘U’and ‘P’ with the boundary list as specified in the ‘blockMeshDict’ file and appropriate values at the relevant boundary to ensure the given numerical problem has the right boundary conditions and that the solution would be correctly initialized (Section 2.2 Boundary Conditions).
- Updating the ‘controlDict’ file, in this case, the ‘deltaT’ and ‘endTime’parameters with values that take into consideration domain-specific attributes such as length of the domain in the direction of flow, fluid flow velocity, and avoiding violation of Courant-Friedrichs-Lewy Condition or the CFL number by limiting its mean and maximum value during the simulation run below 1(Section 2.4 Determination of transient parameters).
The above steps were executed using Linux commands in an Ubuntu 20.04.2.0 LTS (Long Term Support) operating system as shown below:
- By the ‘Ctrl + Alt + T’ command, the terminal is opened in ubuntu.
- Now, a new directory $FOAM_RUN is created in which the simulation will be performed.
- Copy cavity Example from FOAM_TUTORIALS that contain in the icoFoam solver example.
- Now rename the cavity tutorial to backward_facing_step_sg_1.
- Change directory to backward_facing_step_sg_1 for simulating the results for simple grading – 1.
- Now, the next step will be changing the geometry and boundary conditions according to our need by editing the blockMeshDict file which is present in the system folder.
- Now updating the boundary list and boundary condition by editing the U and p file which is present in zero (0)
- Now next updating the ‘delteT’ and ‘endtime’ parameter with appropriate values in ‘controlDict’
- Creating the block base geometry and generating a mesh for the computational domain.
- Running the ‘icoFoam’ solver to solve for the incompressible laminar Navier – Stokes’s equation.
- The next final step is the post-processing and visualizing of the results.
- Similarly, a copy of the backward_facing_step_sg_1 is created as 2 which is having a grading factor of 0.2 such that the walls are finer near the wall (including the step wall).
Modeling:
- The problem was solved by constructing the set of five three–dimensional hexahedral blocks (number of mesh element in Z- the direction was set to 1 implying 2D flow) that together resembled the backward-facing step geometry with each block defined using 8 vertices in a dictionary type file called ‘blockMeshDict’.
- Alignment of the hexahedral blocks was positioned in such a manner that the inlet section of the geometry up to the step was split mid-way along the local, y-axis direction creating two hex blocks each of length 0.08 meters in the direction of flow that also continued from the step to the outlet adding three more hex blocks of length 0.12 meter each in the direction of flow.
- Vertices were assigned, as seen below representing the 8 corners for each block.
- The line starting the creation of hex block in the ‘blockMeshDict’ file followed the arrangement of vertices according to the right-hand system such that the normal (direction in which the right-hand thumb points) was oriented outward for the respective hex block face.
- A similar procedure is followed for the creation of all the hex blocks.
- The longer side along the direction of flow (X-Direction) is considered as 0.2 meters in length and the direction along the Y – Direction is taken as 0.01.
- After the creation of the block, the boundary condition is assigned.
- As specified in the question the boundary condition ‘INLET’, ‘OUTLET’, ‘UPPER WALL’, ‘LOWER WALL’, ‘FRONT AND BACK’ is assigned to the respective faces of the blocks.

Fig: Backward Facing Step geometry (Geometry specified in the Question)


Fig: The Five Hexahedral blocks representing the domain

Fig: Meshing of the domain for simple grading (S.G = 1)

Fig: Meshing of the domain for simple grading (S.G = 0.2)
The following table describes the boundary condition of the setup:
|
Patch Name |
Inlet |
Outlet |
Upper Wall |
Lower Wall |
Front and Back |
|
Patch Type (In blockMeshDict) |
Patch |
Patch |
Wall |
Wall |
Empty |
|
Type (U) |
Fixed Value |
Zero gradient |
No-slip |
No-slip |
Empty |
|
Value (U) |
Uniform (1 0 0) |
-- |
-- |
-- |
-- |
|
Type (P) |
Zero gradient |
Fixed Value |
Zero gradient |
Zero gradient |
Empty |
|
Value (P) |
-- |
Uniform (0) |
-- |
-- |
-- |
icoFoam Model:
The icoFoam solver uses the PISO pressure–velocity coupling algorithm to solve the incompressible laminar Navier – Stokes equations. The Navier – Stokes equations define the fluid flow properties such as velocity, pressure, density, temperature, viscosity, energy, etc., within a given physical domain.
Continuity equation:

Momentum Equation:

Where u is the velocity (in m/s)
p is kinematic pressure (in m2/s2)
Determination of transient parameters:
The setup of simulation run time and time – step for any given computational domain in OpenFOAM is described in the ‘controlDict’ file. Typically, the start of any simulation begins at t = 0, in which case OpenFOAM is required to read the field values of the ‘0’ directory, and therefore ‘startsFrom’ keyword is set to ‘startTime’ which is in turn set to 0 referring to the ‘0’ directory. The ‘endTime’ depends on the domain length and the flow velocity, in the direction of flow, such that the fluid medium passes through it at least 10 times to acquire steady-state conditions, in the case of laminar flow as a mark of a general rule and also as a recommendation in the OpenFOAM v8 User Guide.
Therefore, ‘endTime’ can be evaluated as shown below:

L is the length of the computation domain = 0.2m
U is the fluid flow velocity = 1m/s
After determining the ‘endTime’ and Timestep size, ‘deltaT’ was decided based on CFL number which is expressed below:

`∆t`is time – step size,
`∆x`represents the smallest cell size.
For Grading factor 1 (i.e., GF = 1)

For Grading factor 1 (i.e., GF = 0.2)

The following table represents the smallest element size () and time step size () values for meshes without using any grading factor (GF = 1) and with using grading factor (GF = 0.2)
|
Mesh |
||
|
Grading Factor (GF = 1) |
0.01 |
0.0005 |
|
Grading Factor (GF = 0.2) |
0.0002 |
0.0001 |
The below table represents the coordinates of the point for viewing the velocity profile:
| Line | x | y | z |
| Point 1 | 0.085 | -0.01 | 0 |
| Point 2 | 0.085 | 0.01 | 0 |
Results:
Velocity profiles for different meshes (with and without grading) Fig.4 below shows the velocity profiles computed for different meshes i.e., without any grading factor (GF=1) and using a grading factor of 0.2 for refinement of cells near the walls (including at the step wall). It can be seen that by decreasing the cell size near the walls and step wall regions, the shape of the profile tends toward a narrower curved peak region as compared to the grid that has an even distribution of cells across the entire domain. This can be attributed to the fact that the gradients of velocity along the direction of flow and especially in the vicinity of the walls and steps wall zones vary more drastically and is better captured with smaller element size, in this case with a grading factor of 0.2. The differences seem to be less noticeable while viewing the field plots i.e., for velocity (U) and pressure (p) between the two previously mentioned meshes as the development of the flow fields are almost similar and therefore only single plots (Fig.5) of the computational domain were included for visualization for the case of without any grading factor (GF=1).
For Simple Grading (GF = 1):

Fig: Velocity Profile

Fig: Pressure Profile

Fig: Velocity plot for GF = 1
For Simple Grading (GF = 0.2):

Fig: Velocity Profile

Fig: Pressure Profile

Fig: Velocity plot for GF = 0.2
Discussion:
The evaluation of velocity profiles for the two different meshes indicates the significance of grading/growth factor as the mesh without any grading factor (GF = 1) was not refined enough to capture the near-wall gradient of the flow properties, especially velocity, as compared to the mesh using a grading factor of 0.2 in the relevant blocks of the decomposed domain. This Implies that the computational model developed without any grading factor, for the given numerical problem, would be less reliable and less accurate in comparison to its experimental model as well as having more errors due to the presence of increased numerical diffusion than the computational model using appropriate grading factor that better captures the physics of the flow.
Conclusion:
- The simulation of an incompressible-laminar-viscous flow through the backward-facing step geometry has to be performed.
- The simulation for grading factor (GF = 1) and (GF = 0.2) is been performed, and the proper flow properties, especially velocity are obtained at grading factor 0.2.
Dictionary and Field Files:
1. BlockMeshDict file for Simple Grading (GF = 1)
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) //0
(0.08 0 0 ) //1
(0.08 0.005 0) //2
(0 0.005 0) //3
(0.08 0.01 0) //4
(0 0.01 0) //5
(0.2 0.01 0) //6
(0.2 0.005 0) //7
(0.2 0 0) //8
(0.2 -0.01 0) //9
(0.08 -0.01 0) //10
(0 0 0.0005) //11
(0.08 0 0.0005 ) //12
(0.08 0.005 0.0005) //13
(0 0.005 0.0005) //14
(0.08 0.01 0.0005) //15
(0 0.01 0.0005) //16
(0.2 0.01 0.0005) //17
(0.2 0.005 0.0005) //18
(0.2 0 0.0005) //19
(0.2 -0.01 0.0005) //20
(0.08 -0.01 0.0005) //21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type patch;
faces
(
(6 17 18 7)
(7 18 19 8)
(8 19 20 9)
);
}
upperWalls
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
);
}
lowerWalls
{
type wall;
faces
(
(10 9 20 21)
(1 10 21 12)
(0 1 12 11)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
(13 14 11 12)
(15 16 14 13)
(17 15 13 18)
(18 13 12 19)
(19 12 21 20)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
2. BlockMeshDict file for Simple Grading (GF = 0.2)
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) //0
(0.08 0 0 ) //1
(0.08 0.005 0) //2
(0 0.005 0) //3
(0.08 0.01 0) //4
(0 0.01 0) //5
(0.2 0.01 0) //6
(0.2 0.005 0) //7
(0.2 0 0) //8
(0.2 -0.01 0) //9
(0.08 -0.01 0) //10
(0 0 0.0005) //11
(0.08 0 0.0005 ) //12
(0.08 0.005 0.0005) //13
(0 0.005 0.0005) //14
(0.08 0.01 0.0005) //15
(0 0.01 0.0005) //16
(0.2 0.01 0.0005) //17
(0.2 0.005 0.0005) //18
(0.2 0 0.0005) //19
(0.2 -0.01 0.0005) //20
(0.08 -0.01 0.0005) //21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (5 5 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type patch;
faces
(
(6 17 18 7)
(7 18 19 8)
(8 19 20 9)
);
}
upperWalls
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
);
}
lowerWalls
{
type wall;
faces
(
(10 9 20 21)
(1 10 21 12)
(0 1 12 11)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
(13 14 11 12)
(15 16 14 13)
(17 15 13 18)
(18 13 12 19)
(19 12 21 20)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
3. ControlDict file for Simple Grading (GF = 1)
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 2;
deltaT 0.0005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
4. ControlDict file for Simple Grading (GF = 0.2)
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 2;
deltaT 0.0001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
5. Velocity (U) field file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (1 0 0);
}
outlet
{
type zeroGradient;
}
upperWalls
{
type noSlip;
}
lowerWalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
6. Pressure (P) field file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
upperWalls
{
type zeroGradient;
}
lowerWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
7. Transproperties field file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.01;
// ************************************************************************* //