Week 8 - Simulation of a backward facing step in OpenFOAM
Aim:
In this challenge, you are going to simulate an incompressible-laminar-viscous flow through the backward facing step geometry. You should perform a transient simulation. The solver can be chosen based on the described physics of the flow. You need to explain the entire simulation procedure (how you set up the case). You should also provide explanations to every change you make inside the reference case files obtained from OpenFOAM tutorials. You can choose the inlet velocity shuch that the flow is laminar.
After that, you will perform 2 case studies as described below and compare the results.
Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)
Case 2 - Simulate the flow with grading factor of 0.2. The cells should be finer near the walls (includig the step wall).
You can use the following mesh parameters but you can feel free to modify these values.
Mesh specification
Number of cells along the x direction (longer dimension) = 200
Number of cells along the longer y direction = 20;
Boundary condition specification
The domain specifications are provided in the following figure.

Incompressible-laminar-viscous flow:
Incompressible flow:
The flow in which there is no change in the density is called the incompressible flow. In mathematically, an incompressible flow can be expressed as
Laminar flow:
A laminar flow is one where the fluid motion is regular and there is no mixing. It can be visualized by the path lines that do not intersect each other.
In fluid dynamics, laminar flow is characterized by fluid particles following smooth paths in layers, with each layer moving smoothly past the adjacent layers with or no mixing.
At low velocity, the fluid tends to flow without lateral mixing, and adjacent layers slide past one another like playing cards. There are no cross-current perpendicular to the direction of flow, nor eddies or swirls of fluids.
In laminar flow, the motion of the particles of the fluid is very orderly with particles close to a solid surface moving in straight lines parallel to that surfaces. Laminar flow is a flow regime characterized by high momentum diffusion and low momentum convection.

Reynolds number is the parameter to differentiate a flows as laminar or turbulent. Whenever the Reynolds number is less than about 2000, flow in pipe is generally laminar, whereas at values greater than 2000, flows is usually turbulent. Mathematically Reynolds number is the ratio of inertial force to the viscous force.
Where,
Ρ is the density of the fluid (Kg/m3)
U is the flow speed (m/s)
L is a characteristic linear dimension (m)
μ is the dynamic viscosity of the fluid (pa*s or N-s/m2 or Kg/(m-s))
v is the kinematic viscosity of the fluids (m2/s)
Viscous flow:
A type of fluid f low in which there is a continuous steady motion of the particles. The motion at a fixed point always remains constant. Also called streamline flow.
The fluid flow in form of a layer. The layer which sticks with the wall has zero velocity which is called no-slip condition and it develops the frictional effect at the wall.
Frictional effects are also present between two layers of fluid and slower layer tries to slow down the faster layer which can be measured by using viscosity.
Effects of viscosity are maximum near the boundary so laminar sub layer exists near the boundary that is shown in the below figure.


Grading Factor:
The expansion ratio enables the mesh to be graded or refined in specified direction. The ratio is that of the width of the end cell.
δe – Along one edge of a block to the width of the start cell.
Δs – Along the edge as shown in below figure

In simple format,
Expansion ratio= (size of end cell) / (size of starting cell)
The simple description specifies uniform expansion in the local x1, x2, and x3. Directions respectively with only 3 expansion ratio. For first case, we are not going to provide any grading for our problem.
Procedure:
- First, we are creating the run folder in OpenFoam in which we will be running our simulation.
- Then we need to copy the cavity folder to the run folder so that we can make the changes in the blockMeshDict, controlDict, and pressure and velocity files as to run our required simulation, we copying the folder because we are not supposed to make any changes in the original folders in the OpenFoam.
- Then will make the required change in the blockMeshDict file that is naming the vertices for and then creating the block, in this case, there are 21 vertices and 5 blocks while creating blocks we also need to specify the number of mesh points needed along the boundaries.
- Then, we need to assign the boundary conditions here, we need to define all the faces in OpenFoam refers to patches and giving them type that is the inlet and outlet will be the faces (type patch), for font and back type will be empty faces, for top and bottom which are the boundary conditions in this case type will be wall type and setting up these will constitute a particular boundary, then will save these changes in the blockMeshDict.
- Then, in the velocity and pressure files, we have to give the value of the velocity at the inlet type will be fixed value here, we should assign some value as initial velocity and pressure will be zerogradient and at the outlet velocity type will be zerogradient and pressure will be in this fixed value that value will will be uniform 0, then at front and back velocity type empty and pressure, as well as type empty at the no slip boundaries that is top and bottom velocity, will be type noslip and pressure type empty. And in the transport properties we can change the nu value in order to obtain the lower courant number.
- In the controlDict file the simulation time and time step need to be assigned in the way that the courant number should be less than 0.5.
- Then creating the block mesh and run the simulation using the respective solver after the completion of simulation open the paraFoam and plot the velocity profile for given value.


Block Mesh with out GF:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.1;
vertices
(
(0 0 0) //0
(8 0 0) //1
(8 0.5 0) //2
(0 0.5 0) //3
(8 1 0) //4
(0 1 0) //5
(20 1 0) //6
(20 0.5 0) //7
(20 0 0) //8
(20 -1 0) //9
(8 -1 0) //10
(0 0 0.1) //11
(8 0 0.1) //12
(8 0.5 0.1) //13
(0 0.5 0.1) //14
(8 1 0.1) //15
(0 1 0.1) //16
(20 1 0.1) //17
(20 0.5 0.1)//18
(20 0 0.1) //19
(20 -1 0.1) //20
(8 -1 0.1) //21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (200 20 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (200 20 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (200 20 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (200 20 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (200 20 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
fixedWalls
{
type wall;
faces
(
(5 16 15 4)
(0 1 12 11)
(4 15 17 6)
(10 9 20 21)
(10 21 12 1)
);
}
frontAndBack
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Control Dict:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.2;
deltaT 0.00001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Pressure:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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;
}
fixedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Velocity:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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;
}
fixedWalls
{
type noSlip;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Block Mesh with gradient factor 0.2:
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.1;
vertices
(
(0 0 0) //0
(8 0 0) //1
(8 0.5 0) //2
(0 0.5 0) //3
(8 1 0) //4
(0 1 0) //5
(20 1 0) //6
(20 0.5 0) //7
(20 0 0) //8
(20 -1 0) //9
(8 -1 0) //10
(0 0 0.1) //11
(8 0 0.1) //12
(8 0.5 0.1) //13
(0 0.5 0.1) //14
(8 1 0.1) //15
(0 1 0.1) //16
(20 1 0.1) //17
(20 0.5 0.1)//18
(20 0 0.1) //19
(20 -1 0.1) //20
(8 -1 0.1) //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 wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
fixedWalls
{
type wall;
faces
(
(5 16 15 4)
(0 1 12 11)
(4 15 17 6)
(10 9 20 21)
(10 21 12 1)
);
}
frontAndBack
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
PLOTTING:
VELOCITY WITH OUT GF

PRESSURE WITHOUT GF

PLOTS

VELOCITY WITH GF

PRESSURE WITH GF

PLOTS

Conclusion:
- By changing the simple grading factor from the value of 0.2 to 1 the mesh becomes finer and the solution becomes accurate.
- Overall the change in the size of simple grading factor the result remains the same as approximately.
- The execution time is lower meshing grading factor.