Simulation of flow over a backward facing step
Aim:
To perform flow analysis through a given geometry on OpenFOAM, and draw conclusions.
- To find how the velocity magnitude profile change as a function of mesh grading factor, 0.2, 0.5, and 0.8
- Measure the velocity profile at 0.085 m from the inlet of the geometry
- Compare velocity magnitude contours near the step region for the above-mentioned grading factors.
Geometry:

Dividing the geometry into blocks:

The given geometry is divided into 5 blocks as shown above. Each block is further divided into 200 mesh elements in the x-direction and 10 mesh elements in the y-direction. Since we are not interested in the flow parameters in the z-direction, only one mesh element is defined.
boundary conditions:
inlet - [0 5 16 11]
outlet - [6 9 20 17]
velocity of flow of fluid at inlet = 1.5 m/s
Solution:
The above problem is first solved for a mesh grading factor of 0.2 and then it can be subsequently solved for mesh grading factor of 0.5 and 0.8. Similarly, the velocity profile for these mesh grading factors can be compared and analyzed.
a) Mesh grading factor = 0.2
BlockmeshDict code:
/*--------------------------------*- C++ -*----------------------------------*
========= |
/ F ield | OpenFOAM: The Open Source CFD Toolbox
/ O peration | Website: https://openfoam.org
/ A nd | Version: 7
/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
(0 0 0)//v0
(8 0 0)//v1
(8 0.5 0)//v2
(0 0.5 0)//v3
(8 1 0)//v4
(0 1 0)//v5
(20 1 0)//v6
(20 0.5 0)//v7
(20 0 0)//v8
(20 -1 0)//v9
(8 -1 0)//v10
(0 0 0.1)//v11
(8 0 0.1)//v12
(8 0.5 0.1)//v13
(0 0.5 0.1)//v14
(8 1 0.1)//v15
(0 1 0.1)//v16
(20 1 0.1)//v17
(20 0.5 0.1)//v18
(20 0 0.1)//v19
(20 -1 0.1)//v20
(8 -1 0.1)//v21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (5 5 1)
);
edges
(
);
boundary
(
topandbottom
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(12 11 0 1)
(20 21 10 9)
(1 10 21 12)
);
}
frontandback
{
type empty;
faces
(
(3 2 1 0)
(5 4 2 3)
(4 6 7 2)
(2 7 8 1)
(1 8 9 10)
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
inlet
{
type patch;
faces
(
(11 14 3 0)
(14 16 5 3)
);
}
outlet
{
type patch;
faces
(
(17 18 7 6)
(18 19 8 7)
(19 20 9 8)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
In blockMeshDict code, the following are defined
- Vortices
- Block in which the geometry is divided into
- Number of mesh elements in x, y, and z-directions
- Mesh-grading along x, y, and z-direction
- Boundary definition
ControlDict code:
/*--------------------------------*- C++ -*----------------------------------*
========= |
/ F ield | OpenFOAM: The Open Source CFD Toolbox
/ O peration | Website: https://openfoam.org
/ A nd | Version: 7
/ M anipulation |
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.05;
deltaT 1e-5a;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
In ControlDict code the following are defined
- Start and end time
- The magnitude of time-step. This value must be carefully selected in such a way the Courant number does not exceed 1, else the solution may not converge and may become unstable, hence solution cannot be obtained
Velocity code:
/*--------------------------------*- C++ -*----------------------------------*
========= |
/ F ield | OpenFOAM: The Open Source CFD Toolbox
/ O peration | Website: https://openfoam.org
/ A nd | Version: 7
/ 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.5 0 0);
}
outlet
{
type zeroGradient;
}
topandbottom
{
type noSlip;
}
frontandback
{
type empty;
}
}
// ************************************************************************* //
The velocity code contains the velocity boundary conditions. Here, the inlet velocity in the x-direction is given as 1.5 m/s, and inlet velocity in y and z-direction is given as 0 m/s.
Pressure code:
/*--------------------------------*- C++ -*----------------------------------*
========= |
/ F ield | OpenFOAM: The Open Source CFD Toolbox
/ O peration | Website: https://openfoam.org
/ A nd | Version: 7
/ 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;
}
topandbottom
{
type zeroGradient;
}
frontandback
{
type empty;
}
}
// ************************************************************************* //
The pressure code contains the pressure boundary conditions
Blocks divided into mesh elements:

Here, the given blocks are divided into 200, 10, and 1 mesh elements in x, y, and z-direction respectively. Mesh grading is defined as the ratio of the size of the first element to the ratio of the final element. Here mesh grading of 0.2 is provided, wherein the mesh element are densely packed near the walls and the diverging section so as to visualize the flow separation clearly.
Velocity contours:

Velocity profile at 0.085m from inlet:
This is the profile of the magnitude of velocity at a distance of 0.085m from the inlet. The start point is taken as the bottom wall and the endpoint is taken as the top wall. We get the highest velocity magnitude of 1.67269m/s at a distance of 0.01368m.
b) Mesh grading factor = 0.5
BlockmeshDict code:
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.5 2 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (0.5 0.5 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (2 0.5 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (2 2 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (2 2 1)
);
Here, the grading factor is changed and the rest of the blockMeshDict code remains the same. Similarly, the ControlDict, velocity, and pressure code remains the same unless we want to change any boundary conditions.
Geometry divided into the mesh:

Here, the given blocks are divided into 200, 10, and 1 mesh elements in x, y, and z-direction respectively. Mesh grading is defined as the ratio of the size of the first element to the ratio of the final element. Here mesh grading of 0.5 is provided, wherein the mesh element are densely packed near the walls and the diverging section so as to visualize the flow separation clearly.
Velocity contours:

Velocity profile at 0.085m from inlet:

This is the profile of the magnitude of velocity at a distance of 0.085m from the inlet. The start point is taken as the bottom wall and the endpoint is taken as the top wall. We get the highest velocity magnitude of 1.67853m/s at a distance of 0.0137m.
c) Mesh grading factor = 0.8
BlockmeshDict code:
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.8 1.25 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (0.8 0.8 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (1.25 0.8 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1.25 1.25 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1.25 1.25 1)
);
Here, the grading factor is changed and the rest of the blockMeshDict code remains the same. Similarly, the ControlDict, velocity, and pressure code remains the same unless we want to change any boundary conditions.
Geometry divided into the mesh:

Here, the given blocks are divided into 200, 10, and 1 mesh elements in x, y, and z-direction respectively. Mesh grading is defined as the ratio of the size of the first element to the ratio of the final element. Here mesh grading of 0.8 is provided, wherein the mesh element are densely packed near the walls and the diverging section so as to visualize the flow separation clearly.
Velocity contours:

Velocity profile at 0.085m from inlet:

This is the profile of the magnitude of velocity at a distance of 0.085m from the inlet. The start point is taken as the bottom wall and the endpoint is taken as the top wall. We get the highest velocity magnitude of 1.67224m/s at a distance of 0.0136m.
d) Mesh grading factor = 1
BlockMeshDict code:
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1 1 1)
);
Here, the grading factor is changed and the rest of the blockMeshDict code remains the same. Similarly, the ControlDict, velocity, and pressure code remains the same unless we want to change any boundary conditions. With mesh grading factor = 1.0, the mesh elements remain of the same size throughout. Hence, we can compare the results obtained from this mesh to the results obtained with mesh grading.
Geometry divided into the mesh:

Velocity contours:

Velocity profile:

This is the profile of the magnitude of velocity at a distance of 0.085m from the inlet. The start point is taken as the bottom wall and the endpoint is taken as the top wall. We get the highest velocity magnitude of 1.67235m/s at a distance of 0.01366m.
Results:
Hence, the given geometry was divided into the required number of blocks, and these blocks were divided into the required number of mesh elements, with different mesh grading factors to compare them with each other. The velocity magnitude results obtained at a distance of 0.085m from the inlet of the pipe for various mesh grading factors can be summarized in the table below:
| Mesh-grading factor | Highest velocity magnitude | The location from the bottom wall |
| 1.0 | 1.67235 | 0.01368 |
| 0.8 | 1.67224 | 0.0136 |
| 0.5 | 1.67853 | 0.0137 |
| 0.2 | 1.67269 | 0.01368 |
From the above table, we see that the results obtained are almost the same using different mesh grading factors. Some advantages of using a graded mesh are:
- If we compare the velocity contours obtained using different mesh grading factors, the boundary layer separation can be easily visualized from the solution obtained with the least mesh grading factor, ie, 0.2
- The velocity profile obtained at a distance of 0.085m from the inlet is much more accurate for a mesh grading factor of 0.2, and this accuracy decreases with its increase. The value of flow parameters changes more rapidly near the walls and near the throat than at the center of the pipe, so in order to capture this change, a greater number of grid points need to be present at these points. Since the mesh grid factor with 0.2 has the highest number of grid points at these locations, this solution can be said to be the most accurate in comparison to other results