Week 8 - Simulation of a backward facing step in OpenFOAM
1. Title – Simulation of Backward Facing Step in OpenFoam.
2. Objective –
- To create backward facing step using existing blockmesh dictionary with different grading factor.
- To setup the initial and boundary conditions for simulation and run with a suitable solver.
- Create pressure and velocity contours and profiles using paraview and analyze them.
3. Introduction –
Backward-Facing Step flow is one representative model for separation flows, which can be widely seen in aerodynamic flows engine flows, condensers, vehicles, heat transfer systems, and even the flow around buildings, etc. The flow separation after a simple stage will introduce separation bubble formation, evolution and re-attachment process, which is dependent on the backward facing step geometric design, the inlet and outlet conditions, turbulent intensity, as well as heat transfer conditions. In this study we are simulating flow over a backward facing step to see wake region of flow.
4. Theory –
Open source Field Operation and Manipulation (OpenFoam) is a free, open source CFD software and a c++ toolbox. It does not have GUI, for geometry creaton and case setup we have to write c++ script.
In this study we decided to go with existing script files provides by OpenFoam as tutorial. First step of the simulation creation, which is also defined by c++ script. We divided the back step geometry into 5 block and indexed as shown the image.
Actual Geometry -

Blocked Geometry -

Let consider the first block –

For it, we can define the vertices in script as following –
hex(0 1 2 3 11 12 13 14)(1 1 1)simpleGrading(1 1 1)
here hex(…) defines the vertices with index(for mesh), hex indicates type of mesh, which is hexahedral here.
(1 1 1) indicates number of cells along x,y and z axis
SimpleGrading (1 1 1) defines the grading factor in x,y and z direction
Similarly other vertices can be defined by closely following the geometry.
We have to define vertices also respective to distance from origin like –
(0 0 0) origin
(80 0 0) 80unit in x and 0units in y and z
(80 5 0) 80unit in x, 5unit in y and 0unit in z
Similarly other vertices can be defined in same manner.
For meshing we need to change values in second parenthesis, like in this study we want 200cells in x direction, 20cells in y direction, since simulation is 2D so number of cells in z direction is 1. So, we will write (200 20 1).
In boundary condition we need to define the inlet, outlet and wall patches so for inlet and outlet we can write
For inlet
(0 11 14 13)
(3 14 16 5)
For outlet
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
Similarly patches for front and back wall and top and bottom wall can be defined. For initial condition velocity and pressure will get zero value.
Boundary conditions –
Velocity (inlet) – 1.5m/s
Pressure (outlet) – 0pa
Outlet velocity and inlet pressure will be calculate using interpolation.
Simple Grading – it is a technique to stretch the mesh in one direction. In openFoam we can define this stretch by a factor called grading factor, which is defined in the blockMesh script.
Formula of grading factor = size of the end cell/size of the starting cell
If we take grading factor 0.1, means the size of end cells is going to be small. Simple grading technique is important in simulation. For example, in simulation of flow over backward step, every one focuses on the flow where area expands suddenly, to capture it properly we need a finer mesh. For it, there are option put finer mesh on whole object or fine the mesh on a particular area. Solver will take a lot of time to solve first case so we will me move with the second. Here comes simple grading into picture, it fines the mesh only where it is required, that’s why simple grading is important.
5. Procedure –
Flow over a backwards facing step is a classic CFD test problem which is used extensively for validation of simulation codes. The test problem essentially consists of studying how a fully developed flow profile reacts to a sudden expansion in a channel. The expansion will cause a break in the flow and a recirculation or separation zone will form. For this study we simulated two cases distinguished in grading factor only. For incompressible-laminar-viscous flow through the backward facing step we chose cavity_test model from OpenFoam tutorial and modified the geometry and the setting like initial condition, boundary condition and control parameter. The following procedure was followed to simulate flow over a backward facing step –
1. Started with copying the files of cavity test model in Foam run folder and run blockmesh executable file to generate blockmeshdict file for the same case.
2. We changed the blockmesh setting, velocity and pressure profiles and control parameters as following code.
blockMeshDict file -
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0)
(80 0 0)
(80 5 0)
(0 5 0)
(80 10 0)
(0 10 0)
(200 10 0)
(200 5 0)
(200 0 0)
(200 -10 0)
(80 -10 0)
(0 0 0.5)
(80 0 0.5)
(80 5 0.5)
(0 5 0.5)
(80 10 0.5)
(0 10 0.5)
(200 10 0.5)
(200 5 0.5)
(200 0 0.5)
(200 -10 0.5)
(80 -10 0.5)
);
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 patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type patch;
faces
(
(7 6 17 18)
(8 7 18 19)
(9 8 19 20)
);
}
front
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
back
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
topandbottom
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
(10 21 12 1)
(11 12 1 0)
(21 20 9 10)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
controlDict file -
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.1;
deltaT 1e-5;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
p file -
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
front
{
type empty;
}
back
{
type empty;
}
topandbottom
{
type zeroGradient;
}
}******************************************************************** //
U file -
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
front
{
type empty;
}
back
{
type empty;
}
topandbottom
{
type noSlip;
}
}
// ************************************************************************* //
fvScheme -
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
// ************************************************************************* //
fvSolution -
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //
3. After it, we executed icoFoam.exe file and solver begun the solving.
4. paraFoam command was used to open paraFoam for postprocessing.
Major codes used in terminal -
ls - list
cd - change directory
blockmesh.exe - blockmesh generation
icoFoam.exe - solver executable
paraFoam - to open paraview
6. Results –
Geometry -

Case 1
Mesh -

Pressure contour -

Velocity contour -

Velocity profile(at 0.085m from inlet) -

Case 2 (with grading factor 0.2)
Mesh -

Pressure contour -

Velocity contour -

Velocity profile(at 0.085m from inlet) -

Velocity comparison -
|
Case/Parameter |
Distance along Y axis(m) |
Velocity(m/s) |
|
Case1 |
-0.002 |
0.8227 |
|
Case2 |
-0.002 |
0.8080 |
|
Case1 |
0.004 |
1.3762 |
|
Case2 |
0.004 |
1.3732 |
|
Case1 |
0.009 |
0.6021 |
|
Case2 |
0.009 |
0.5885 |
negative sign is indicating point above y axis.
There were two cases one with no grading factor and second with grading factor of 0.2. for these cases pressure and velocity contours were created. Now if we see the velocity contour, we find that velocity is very low adjacent to vertical wall of backstep, this region is called as wake region or recirculation zone. Recirculation zone created by flow separation, which form due to sudden expansion in the geometry. Pressure is low in wake region and some time it might lead to a negative value. These things validate theory. Now if we talk about the velocity profile at 0.085m from inlet, velocity is low adjacent to wall boundaries and it has maximum value at the mid of channel along the y axis. Grading factor refines the mesh at a particular area, so we can go around the experimental results.