Week 8 - Simulation of a backward facing step in OpenFOAM
Simulation of Backward Facing Step in openFOAM
Objective:-
- To simulate an incompressible-laminar-viscous flow through the backwards - facing step geometry and perform a transient simulation.
- Case 1 - To simulate the flow without using any grading factor (i,e., GF = 1)
- Case 2 - To simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step wall).
Incompressible-laminar-viscous flow:-
Incompressible flow:-
- The flow in which there is no change in the density is called the incompressible flow.
- Mathematically, an incompressible flow can be expressed as `nabla.u=0">nabla.u = 0Re =(rho.v.L)/(mu)`
Laminar flow:-
- A laminar flow is one where the fluid motion is regular and there is no mixing. It can be visuvalized by the pathlines 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 adjecent layers with little or no mixing.
- At low velocities, the fluid tends to flow without lateral mixing, and adjacent layers slide past one another like playing cards. There are no cross-currents perpendicular to the directtion of flow, nor eddies or swirls off fluids.
- In laminar flow, the motion of the particles of the fluid is very orderly with particles close to solid surface moving in straight lines parallel to that surface. Laminar flow is a flow regime characterized by high momemtum diffusion and low momentum convection.

- Reynolds number is the parameter to differentiate a flow as lamiinar or turbulent.
- Whenever the Reynolds number is less than about 2000, flow in pipe is generally laminar, where as, at values greayer than 2000 flow is usually turbulent.
- Mathematically, Reynolds number is the ratio of internal force to the viscous force.
where,
- `rho` is the density of the fluid (kg/m^3)
- u is the flow speed(m/s)
- L is a characteristic linear dimension (m)
- `mu`is dynamic viscosity of the fluid (Pa.s or N.s/m^2 or kg/(m.s))
- V is the kinematic viscosity of the fluid (m^2/s)
Viscous flow:-
- A type of fluid flow in which there is a contionous stedy motion of the the particles, the motion at a fixed point always remains constant. Also called streme line flow. laminar flow, steady 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 sublayer exits near the boundary that is shown in the below figure.

- Mesh grading.
- Mesh grading is a factor that is,
- Grading factor = `(size of the cell)/(Size of the first cell`
PROCEDURE:-
- First, we are creating the run folder in openFOAM in which we will be running our simulations.
- And then 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 simulations, we are copying the folder because we are not supposed to make any changes in the origional folders in the openFOAM.
- Then will make the required changes in the blockMeshDict file that is naming the vertices for and then creating the blocks, 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 x,y, and z - direction and also the simple grading should be done along the boundaries.
- Then, we need to assign the boundary conditions here, we need to define all the the faces in openFOAM refers to patches and giving them type that is the inlet and outlet will be the faces(type patch), for front and back type velocity will be no slip and pressure type empty and pressure as well as transport proberties we can change the nu value in order to obtain the lower courant number.
- And in the ControlDict file the simulation time and the time step need be assigned in the way that the courant number shuld be less than 0.5.
- The creating the block mesh and then run the simulation using the respective solver after the completion of simulation open the paraview in the paraFoam and plot the velocity profile for given value.
CODE:-
For Without applying Grading Factor (GF = 1)
BLOCKMESHDICT:-
*--------------------------------*- 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.01;
vertices
(
(0 0 0) //vertex0
(8 0 0) //vertex1
(8 0.5 0) //vertex2
(0 0.5 0) //vertex3
(8 1 0) //vertex4
(0 1 0) //vertex5
(20 1 0) //vertex6
(20 0.5 0) //vertex7
(20 0 0) //vertex8
(20 -1 0) //vertex9
(8 -1 0) //vertex10
(0 0 1) //vertex11
(8 0 1) //vertex12
(8 0.5 1) //vertex13
(0 0.5 1) //vertex14
(8 1 1) //vertex15
(0 1 1) //vertex16
(20 1 1) //vertex17
(20 0.5 1) //vertex18
(20 0 1) //vertex19
(20 -1 1) //vertex20
(8 -1 1) //vertex21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (50 5 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (50 5 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (150 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (150 5 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (150 20 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
walls
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
For With the applied Grading factor 0.2 (GF = 0.2)
BLOCKMESHDICT:-
/*--------------------------------*- 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.01;
vertices
(
(0 0 0) //vertex0
(8 0 0) //vertex1
(8 0.5 0) //vertex2
(0 0.5 0) //vertex3
(8 1 0) //vertex4
(0 1 0) //vertex5
(20 1 0) //vertex6
(20 0.5 0) //vertex7
(20 0 0) //vertex8
(20 -1 0) //vertex9
(8 -1 0) //vertex10
(0 0 1) //vertex11
(8 0 1) //vertex12
(8 0.5 1) //vertex13
(0 0.5 1) //vertex14
(8 1 1) //vertex15
(0 1 1) //vertex16
(20 1 1) //vertex17
(20 0.5 1) //vertex18
(20 0 1) //vertex19
(20 -1 1) //vertex20
(8 -1 1) //vertex21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (50 5 1) simpleGrading (1 5 1)
hex (3 2 4 5 14 13 15 16) (50 5 1) simpleGrading (1 0.2 1)
hex (2 7 6 4 13 18 17 15) (150 5 1) simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13) (150 5 1) simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12) (150 20 1) simpleGrading (5 10 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
walls
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
PRESSURE (GF = 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 volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
walls
{
type zeroGradient;
}
}
// ************************************************************************* //
VELOCITY (GF = 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 volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
inlet
{
type fixedValue;
value uniform (0.02 0 0);
}
outlet
{
type zeroGradient;
}
walls
{
type noSlip;
}
}
// ************************************************************************* //
TRANSPORT IP PROBERTIES
/*--------------------------------*- 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 1e-5;
// ************************************************************************* //
ControlDict
/*--------------------------------*- 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 20;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
OUTPUTS:-
Without assigning any grading factor the block mesh is shown below:-

For the given grading factor 0.2 the results are as follows:-

Velocity Flow Diagram without grading factor:-

Pressure Flow Diagram without grading factor:-

Velocity Flow Diagram with grading factor (GF = 0.2):-

Pressure Flow Diagram with grading factor (GF = 0.2)

Comparasion plots with velocity (0.078 & 0.085)
CONCLUSION:-
By changing the simple grading factor from the value of 0.2 to 1 the mesh becomes finer and the solution becomes very accurate. Overall the change in the size of simple grading factor (mesh size ) the results remains the same as approxmately. The execution time is lower meshing grading factor.