Week 8 - Simulation of a backward facing step in OpenFOAM
Objective: To simulate an incompressible-laminar-viscous flow through the backward-facing step geometry using transient condition
Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)
Case 2 - Simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step wall).
You can use the following mesh parameters but you can feel free to modify these values.
Mesh specification
-
Number of cells along the x-direction (longer dimension) = 200
-
Number of cells along the longer y-direction = 20;
Boundary condition specification
The domain specifications are provided in the following figure.
Geometry Creation:
Let us consider creating the geometry using 5 blocks as shown in the figure below,
Vertices for each block by referring following sketch:

STEPS FOLLOWED IN OpenFOAM:
-
Open the terminal window by pressing ctrl+alt+T or right-clicking on Terminal to begin the simulation.
-
Now we'll simulate our problem in OpenFOAM and solve it with the help of the tutorial file that comes with OpenFOAM. To see what kind of file is present within the tutorial directory, type 'tut' to open it and then 'ls' to see what kind of file is present.
-
For this problem, we need to solve incompressible flow simulation, so type 'cd' to go to an incompressible directory and then 'ls' to look through the files in the incompressible folder.
-
We see different types of solvers in the incompressible folder; for this problem, we need a solver for laminar viscous flow, so we choose 'icoFoam'. (icoFoam is an OpenFOAM solver for incompressible, laminar flow of Newtonian fluids that is used as a transient solver). As a result, pick this folder by typing 'cd icoFoam' and then exploring it with the 'ls' command.
-
We have two options here: cavity and elbow, both of which are included in the icoFoam solver. For our required domain, we use the cavity folder. However, we will not make any modifications to the tutorial section because OpenFOAM does not enable us to alter their official tutorials.
-
Next, we'll use the 'cp-r cavity' command to copy the cavity folder and paste it into the OpenFOAM run folder by typing 'cp-r cavity $FOAM RUN/cavity test'. We can now make changes to the cavity test folder without affecting the official OpenFOAM file. Open the cavity test folder, where we can include the block mesh specification in a device folder.
-
There are four script file system directories, and we can build a domain and provide block mesh specifications by opening blockMeshdict. So, type gedit blockMeshdict to open this file. Make the required changes to the blockMeshdict script file now. Next, we search for lines in this file that contain the hex term. In the X, Y, and Z directions, these lines define the faces of the blocks as well as the number of cells. There are 21 vertices and 5 blocks in this scene. Also, define the inlet, outlet, and wall faces. This file should be saved.
-
The next move is to go to the controlDict folder and set the simulation time there. Then we must describe initial velocity and pressure values. Return to the cavity test folder and pick the 'O' folder, which stands for initial values. We set an initial boundary condition for pressure and velocity at each face, as well as updating the name of the boundary, just as we did in blockMeshdict with the inlet-outlet name.
-
Now that we've established our problem statement, we can use the 'blockmesh' command to deploy mesh, and then use the 'checkmesh' command to see if there are any errors. We are now able to run our simulation after deploying mesh.
-
'icoFoam' was the simulation that we picked. As a result, simply type 'icoFoam' to begin the simulation. Let's use the 'paraFoam' command to display the results in ParaView.
Case 1- Simulate the flow without using any grading factor (i.e., GF = 1)
BlockMesh file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
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) (120 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
fixedWalls
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
(10 21 12 1)
(11 0 1 12)
(21 10 9 20)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Controldict File
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.2;
deltaT 0.00001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Velocity initial settings
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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 0 0);
}
outlet
{
type zeroGradient;
}
fixedWalls
{
type noSlip;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Pressure initial settings
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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;
}
fixedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
RESULTS:
1 Without Grading Factor
1.1 Mesh Grid
1.2 Pressure Distribution

1.3 Velocity Distribution

1.4 Velocity at a distance of 0.085m from the inlet

Case 2 - Simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step wall).
Why Grading/Growth factor is essential for meshing?
-
The grading factor is the ratio of the size of the end cell to the size of starting cell.
-
This helps in getting more detailing at some positions as per the grading factor.
-
The grading factor helps us to increase the cell number at the start or end of the block. The change can be seen clearly with the proper grading factor.
For this case, the procedure is the same as above only change is in the Blockmesh file.
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
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 (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 wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
fixedWalls
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
(10 21 12 1)
(11 0 1 12)
(21 10 9 20)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
2.1 Mesh Grid:

2.2 Pressure Distribution

2.3 Velocity Distribution

2.4 Velocity Plot at a distance of 0.085m from inlet:
