Week 8 - Simulation of a backward facing step in OpenFOAM
Aim :- Simulation of a backward facing step in OpenFOAM
Objective :-
- To simulate an incompressible-laminar-viscous flow through the backward facing step geometry and perform a transient simulation. The solver can be chosen based on the described physics of the flow. To explain the entire simulation procedure. To provide explanations to every change you make inside the reference case files obtained from OpenFOAM tutorials.
- To 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 (including the step wall).
Incompressible Flow :-
The flow in which there is no change in the density is called the Incompressible flow.
Laminar flow :-
A Laminar flow is one where the fluid motion is regular is no mixing. It can be visualised 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 little or no mixing.
At low velocities, the fluid tends to flow without lateral mixing and adjacent layers slide past one another. There are no cross-currents perpendicular to the direction of flow nor eddies or swirls of fluids mathematically. Reynolds number is the ratio of inertial force to the viscous force.
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.
Mesh specification :-
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the longer y direction = 20
Boundary Conditions :-
The domain specifications are provided in the following figure

Desired output :-
To measure the velocity profile at 0.085 m from the inlet of the geometry for both case studies and compare by using plot over line tool.
To explain why Grading/Growth factor is essential for meshing.
Procedure :-
To open the run folder in OpenFOAM in which we are going to run our simulations.
To open the tutorial by using the command- cd $FOAM_TUTORIALS"/incompressible/
To copy the cavity folder to the run folder so that the official file of OpenFOAM remain untouched.
To find out blockMesh script file to create domain space and provide mesh specification. In this case there are 21 vertices and 5 blocks. While creating the blocks we 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.

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
);
Grading Factor (GF) :-
The grading factor enables the mesh to be graded or refined in specified directions.
The simple description specifies uniform expansion in the local x1,x2 and x3 direction respectively, In first case we not going to provide any GF for our problem
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)
);
"hex" denotes the type of mesh and "(0 1 2 3 11 12 13 14), (3 2 4 5 14 13 15 16), (2 7 6 4 13 18 17 15), (1 8 7 2 12 19 18 13), (10 9 8 1 21 20 19 12)" denotes the facing of the geometry.
"(50 5 1), (50 5 1), (150 5 1), (150 5 1), (150 20 1)" denotes the number of cells along x,y and z direction.
Given Mesh specifications :-
Number of cells along x-axis is 200
Number of cells along y-axis is 20
To assign the boundary conditions. All the faces in OpenFOAM refers to patches and giving them the type that is inlet and outlet will be the faces(type patch), for front and back type will be empty faces, for top and bottom which are wall type and setting up these will constitute a particular boundary, then save these changes in the blockMesh dict. 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 zero gradient and at the outlet velocity type will be zero gradient and pressure will be type fixed value that value will be uniform O, 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. Then save all the properties changed and enter the command blockMesh in the terminal and enter the command paraFoam to acquire the results.
Code :-
BlockMesh dict :-
For the grading size 1 :
/*--------------------------------*- 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) (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 grading size 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.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) (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
(
);
// ************************************************************************* //
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 20;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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 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 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 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 properties :-
/*--------------------------------*- 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;
// ************************************************************************* //
Results :-
Results are acquired after solving using the icofoam solver.

Grading Factor of 1 :
Mesh :

Velocity Field :
This filed is acquired by using the paraFoam command.

Pressure field :

Velocity profiles before and after time steps :
The plots are acquired by using the plot over line tool.

This graph predicts that the maximum velocity profile has decreased because of the change in area.
Grading Factor of 0.2 :
Mesh :

The cells are finer near the wall.
Velocity Field :

Pressure Field :

Velocity Field before the step :

Velocity profile after the step :

Velocity profile before and after the step :

Results :
If the mesh is not fine it gives average results because of capturing less elements at each node, To capture accurate results its required for finer mesh to capture flow properties of fluid. By comparing both the plots G.F-0.2 gives better reults than simple grading 1
Velocity magnitude profiles gives similar results for both cases in general at 0.085m there is an decrease in velocity but with a mesh grading factor finer results are obtained with accurate results at step height and boundary walls.
A graded mesh determines the element density in each region of the model based on the complexity of the geometry.More complex geometry with more angles and cuts will have a higher density of elements to better capture the topographical features. The mesh density grades away from the complex regions.