Week 8 - Simulation of a backward facing step in OpenFOAM
Introduction :
Studying the flow behaviour through various structures is an important subject for a CFD engineer. When fluids flow through different geometries, they exhibit different velocity, pressure and flow properties. In this project, a Simulation of a flow-through backwards-facing step is done to study the flow of fluids through geometries that have sudden-changing shapes. The simulations are refined using multiple meshes and mesh grading factors inside the BlockMeshDict file of BlockMesh, which is also used to create the geometry to be solved 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`
`Re = frac(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 visualized 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 adjacent 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 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 surface. Laminar flow is a flow regime characterized by high momentum diffusion and low momentum convection.

Reynolds number is the parameter to differentiate a flow as laminar or turbulent.
Whenever the Reynolds number is less than about 2,000, flow in a pipe is generally laminar, whereas, at values greater than 2,000, flow is
usually turbulent.
Mathematically, the Reynolds number is the ratio of inertial force to the viscous force.
`Re = frac(rho.v.l)(mu)`
where,
p is the density of the fluid (kg/`m^3`)
u is the flow velocity (m/s)
L is a characteristic linear dimension (m)
`mu` is the dynamic viscosity of the fluid (Pa-s or N-s/`m^2` or kg/(m-s))
`nu` is the kinematic viscosity of the fluid (`m^2`/s)
Viscous flow :
A type of fluid flow in which there is a continuous steady motion of the particles; the motion at a fixed point always remains constant. Also called streamline 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 the no-slip condition and it develops the frictional effect at the wall. Frictional effects are also present between two layers of fluid and the 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 a laminar sublayer exists near the boundary that is shown in the below figure.

Steps to be done:
Step 1: Choosing a solver.
Step 2: Select a solver tutorial to create Geometry and Meshing.
Step 3: Setting up Case.
Step 4: Assigning Boundary conditions
Step 5: Assigning initial conditions.
Step 6:Post-processing the results.
Step 7: Plotting Results
1. Choosing a solver:
OpenFOAM software has been used for this project, hence choosing a solver as per our problem is the first essential step towards the study.
Assumptions for the problem:
i. The fluid is Newtonian
ii. The flow is incompressible & laminar
ill. Low Reynolds number.
iv. Zero frictional losses
The solver chosen considering the above assumptions is icoFOAM.
It solves the incompressible laminar Navier-stokes equations (continuity and momentum) using PISO/algorithm.
2. Selecting Solver tutorial:
The solver tutorial from the incompressible icoFoam called cavity is chosen for the task and its geometry and initial conditions are modified
as per the objective.
3. Creating Geometry:
A software file called BlockMeshDict in the tutorials system folder creates the Geometry and mesh, hence this is modified to create the
backwards-facing step. Since blockmeshdict file can create geometries only in block format, we created the blocks and indexed the vertices
as shown below.

/*--------------------------------*- 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) //vertex 0
(8 0 0) //vertex 1
(8 0.5 0) //vertex 2
(0 0.5 0) //vertex 3
(8 1 0) //vertex 4
(0 1 0) //vertex 5
(20 1 0) //vertex 6
(20 0.5 0) //vertex 7
(20 0 0) //vertex 8
(20 -1 0) //vertex 9
(8 -1 0) //vertex 10
(0 0 1) //vertex 11
(8 0 1) //vertex 12
(8 0.5 1) //vertex 13
(0 0.5 1) //vertex 14
(8 1 1 ) //vertex 15
(0 1 1) //vertex 16
(20 1 1) //vertex 17
(20 0.5 1) //vertex 18
(20 0 1) //vertex 19
(20 -1 1) //vertex 20
(8 -1 1) //vertex 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) (180 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (180 5 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (180 5 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
(
);
// ************************************************************************* //
4. Open Foam Geometry
Mesh Specification:
1. Number of cells along the x-direction (longer dimension) = 260.
2. Number of cells along with the y-direction = 15
3. Use a graded mesh. The grading factor near all walls should be 1,0.2
we shall perform analysis over different grading factors and compare results.

5. Setting up Case:
We now set up the case in blockMeshDict file by assigning Boundary & wall conditions, time step and end time in ControlDict file and initial
conditions in the Velocity and pressure file.
/*--------------------------------*- 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;
// ************************************************************************* //
5. Boundary conditions:
Once the geometry is created, we assign different boundary conditions for the flow to take place within the geometry.
These faces are assigned in the blockMeshDict file as:
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)
);
}
);

Initial Condition :
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;
}
walls
{
type zeroGradient;
}
}
// ************************************************************************* //
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 (0.02 0 0);
}
outlet
{
type zeroGradient;
}
walls
{
type noSlip;
}
}
// ************************************************************************* //
6.ParaFoam Results :
Case 1:
Grading factor 0.2
Mesh Grid


Initial Velocity :

Initial Pressure

Final Velocity Contour

Final pressure Contour

Graph:

Case 2
Grading factor 1
Mesh Grid

Initial Velocity

Initial Pressure

Final Velocity Contour :

Final pressure Contour

Graph:

CONCLUSION :
By changing the simple grading factor from the value of O.2 to 1 the mesh becomes finer and the solution becomes very accurate.
Overall the change in the size of the simple grading factor (mesh size) the results remains the same as approximately.
The execution time is lower for the lower meshing grading factor.