Simulation of a backward facing step in OpenFOAM
OBJECTIVE:
In this challenge, you are going to simulate an incompressible-laminar-viscous flow through the backward facing step geometry. You should perform a transient simulation. The solver can be chosen based on the described physics of the flow. You need to explain the entire simulation procedure (how you set up the case). You should also provide explanations to every change you make inside the reference case files obtained from OpenFOAM tutorials. You can choose the inlet velocity shuch that the flow is laminar.
After that, you will 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 (includig 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.
To create the geometry as shown in the figure, we need edit the blockMeshDict file that is available in the system folder of the case setup.
Geometry Creation:
Let us consider creating the geometry using 5 blocks as shown in the figure below,
THEORY:
Backward Facing Step (BFS) is widely known for its application in the studies on turbulence in internal flows. The flow separation is caused due to the sudden changes in the geometry. This creates a zone of re-circulation and a point of flow reattachment.
- Here we are going to simulate an incompressible laminar and viscous flow over a channel using the backward-facing step.
- The simulation is done in the openFoam.
- The solver is used icoFoam solver which is already avaiolable in the tutorilas folder of openFoam.
- Later on there are few commands to be followed for simulating the process in the terminal.
- In the end the post processing is done in the paraview which is also obtained through the terminal using paraFoam command.
COMMAND LINE:

- In the above Command line the cavity folder is run in the run folder which was already copied from solvers to the run folder.
- After in the tun folder of cavity we need to edit some text files to run the simulation smoothly.
- The text files which are to be edited are as follows below:
- blockMeshdDict
- ControlDict
- Pressure
- velocity
- There are two more text files which are not be disturbed anything
- Fvschemes
- Fvsolution
After making the changes inthe text files the editted text looks like as below
These tecxt files are available in this comand
BLOCKMESHDICT:
/*--------------------------------*- 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 1;
vertices
(
(0 0 0)
(0.08 0 0)
(0.08 0.005 0)
(0 0.005 0)
(0.08 0.01 0)
(0 0.01 0)
(0.2 0.01 0)
(0.2 0.005 0)
(0.2 0 0)
(0.2 -0.01 0)
(0.08 -0.01 0)
(0 0 0.01)
(0.08 0 0.01)
(0.08 0.005 0.01)
(0 0.005 0.01)
(0.08 0.01 0.01)
(0 0.01 0.01)
(0.2 0.01 0.01)
(0.2 0.005 0.01)
(0.2 0 0.01)
(0.2 -0.01 0.01)
(0.08 -0.01 0.01)
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (120 20 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(11 14 3 0)
(14 16 5 3)
);
}
outlet
{
type patch;
faces
(
(19 20 9 8)
(18 19 8 7)
(17 18 7 6)
);
}
frontAndBack
{
type empty;
faces
(
(16 14 13 15)
(14 11 12 13)
(15 13 18 17)
(13 12 19 18)
(12 21 20 19)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
top_bottom_step
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
(11 0 1 12)
(21 10 9 20)
(21 12 1 10)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
CONTROLDICT:
/*--------------------------------*- 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 1.2;
deltaT 0.00005;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
FVSCHEMES:
/*--------------------------------*- 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 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;
}
// ************************************************************************* //
FVSOLUTIONS:
/*--------------------------------*- 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 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;
}
// ************************************************************************* //
There are no changes done in the fvschemes and fvsolutions to run the simulations without any errrors.
There are two more text files which is available in the 0 folder, they are pressure and velocity text files.
P
/*--------------------------------*- 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;
}
frontAndBack
{
type empty;
}
top_bottom_step
{
type zeroGradient;
}
}
// ************************************************************************* //
U:
/*--------------------------------*- 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.5 0 0);
}
outlet
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
top_bottom_step
{
type noSlip;
}
}
// ************************************************************************* //
- And the last text file is TRANSPORT PROPERTIES which is available in the constant folder.
TRANSPORT PROPERTIES:
/*--------------------------------*- 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 1.48e-5;
// ************************************************************************* //
Then the block mesh command is run in the command line to start the inititial simulation,It is to check the wether the mesh ran perfectly or not.
/*---------------------------------------------------------------------------*
========= |
/ F ield | OpenFOAM: The Open Source CFD Toolbox
/ O peration | Website: https://openfoam.org
/ A nd | Version: 8
/ M anipulation |
*---------------------------------------------------------------------------*/
Build : 8-1c9b5879390b
Exec : blockMesh
Date : Sep 02 2021
Time : 18:37:42
Host : "yasirhaneef"
PID : 3143
I/O : uncollated
Case : /home/yasir-haneef/OpenFOAM/yasir-haneef-8/run/cavity/cavity
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Deleting polyMesh directory
"/home/yasir-haneef/OpenFOAM/yasir-haneef-8/run/cavity/cavity/constant/polyMesh"
Creating block mesh from
"system/blockMeshDict"
Creating block edges
No non-planar block faces defined
Creating topology blocks
Creating topology patches
Creating block mesh topology
Check topology
Basic statistics
Number of internal faces : 5
Number of boundary faces : 20
Number of defined boundary faces : 20
Number of undefined boundary faces : 0
Checking patch -> block consistency
Creating block offsets
Creating merge list .
Creating polyMesh from blockMesh
Creating patches
Creating cells
Creating points with scale 1
Block 0 cell size :
i : 0.001 .. 0.001
j : 0.0005 .. 0.0005
k : 0.01
Block 1 cell size :
i : 0.001 .. 0.001
j : 0.0005 .. 0.0005
k : 0.01
Block 2 cell size :
i : 0.001 .. 0.001
j : 0.0005 .. 0.0005
k : 0.01
Block 3 cell size :
i : 0.001 .. 0.001
j : 0.0005 .. 0.0005
k : 0.01
Block 4 cell size :
i : 0.001 .. 0.001
j : 0.0005
k : 0.01
Writing polyMesh
----------------
Mesh Information
----------------
boundingBox: (0 -0.01 0) (0.2 0.01 0.01)
nPoints: 13282
nCells: 6400
nFaces: 25840
nInternalFaces: 12560
----------------
Patches
----------------
patch 0 (start: 12560 size: 20) name: inlet
patch 1 (start: 12580 size: 40) name: outlet
patch 2 (start: 12620 size: 12800) name: frontAndBack
patch 3 (start: 25420 size: 420) name: top_bottom_step
End
yasir-haneef@yasirhaneef:~/OpenFOAM/yasir-haneef-8/run/cavity/cavity$
- There fore the blockmesh ran perfectly and is succesfull.
- Now it is ready for the postprocessing before that to run the post processing the solver is used ,Here the solver used is icoFOAM this is entered in the terminal and the simulation ran smoothly
Time = 1.2
Courant Number mean: 0.0541743 max: 0.129963
smoothSolver: Solving for Ux, Initial residual = 2.44283e-06, Final residual = 2.44283e-06, No Iterations 0
smoothSolver: Solving for Uy, Initial residual = 8.10596e-06, Final residual = 8.10596e-06, No Iterations 0
DICPCG: Solving for p, Initial residual = 1.43408e-05, Final residual = 9.73554e-07, No Iterations 22
time step continuity errors : sum local = 9.16399e-12, global = 2.14019e-12, cumulative = -1.82727e-08
DICPCG: Solving for p, Initial residual = 1.28805e-05, Final residual = 9.7311e-07, No Iterations 20
time step continuity errors : sum local = 9.15978e-12, global = 2.2568e-12, cumulative = -1.82705e-08
ExecutionTime = 553.46 s ClockTime = 627 s
yasir-haneef@yasirhaneef:~/OpenFOAM/yasir-haneef-8/run/cavity/cavity$ ls
0 0.035 0.07 0.105 0.14 0.175 0.21 0.245 0.28 0.315 0.35 0.385 0.42 0.455 0.49 0.525 0.56 0.595 0.63 0.665 0.7 0.735 0.77 0.805 0.84 0.875 0.91 0.945 0.98 1.015 1.05 1.085 1.12 1.155 1.19 system
0.005 0.04 0.075 0.11 0.145 0.18 0.215 0.25 0.285 0.32 0.355 0.39 0.425 0.46 0.495 0.53 0.565 0.6 0.635 0.67 0.705 0.74 0.775 0.81 0.845 0.88 0.915 0.95 0.985 1.02 1.055 1.09 1.125 1.16 1.195
0.01 0.045 0.08 0.115 0.15 0.185 0.22 0.255 0.29 0.325 0.36 0.395 0.43 0.465 0.5 0.535 0.57 0.605 0.64 0.675 0.71 0.745 0.78 0.815 0.85 0.885 0.92 0.955 0.99 1.025 1.06 1.095 1.13 1.165 1.2
0.015 0.05 0.085 0.12 0.155 0.19 0.225 0.26 0.295 0.33 0.365 0.4 0.435 0.47 0.505 0.54 0.575 0.61 0.645 0.68 0.715 0.75 0.785 0.82 0.855 0.89 0.925 0.96 0.995 1.03 1.065 1.1 1.135 1.17 cavity.OpenFOAM
0.02 0.055 0.09 0.125 0.16 0.195 0.23 0.265 0.3 0.335 0.37 0.405 0.44 0.475 0.51 0.545 0.58 0.615 0.65 0.685 0.72 0.755 0.79 0.825 0.86 0.895 0.93 0.965 1 1.035 1.07 1.105 1.14 1.175 constant
0.025 0.06 0.095 0.13 0.165 0.2 0.235 0.27 0.305 0.34 0.375 0.41 0.445 0.48 0.515 0.55 0.585 0.62 0.655 0.69 0.725 0.76 0.795 0.83 0.865 0.9 0.935 0.97 1.005 1.04 1.075 1.11 1.145 1.18 log.blockMesh
0.03 0.065 0.1 0.135 0.17 0.205 0.24 0.275 0.31 0.345 0.38 0.415 0.45 0.485 0.52 0.555 0.59 0.625 0.66 0.695 0.73 0.765 0.8 0.835 0.87 0.905 0.94 0.975 1.01 1.045 1.08 1.115 1.15 1.185 log.icoFoam
The simulation has run perfectly through succefully.
The post processing is done using the paraview
MESH:



Plot between the pressure and velocity


Simulatimg the flow with grading factor of 0.2.
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12) (120 20 1) simpleGrading (5 5 1)





Why Grading/Growth factor is essential for meshing?
To sum up, the blockMeshDict dictionary generates a single block with:
• X/Y/Z dimensions: 1.0/1.0/1.0
• As the cell spacing in all directions is defined as 0.05, it will use the following number of cells in the X, Y, and Z directions: 20 x 20 x 20 cells.
• One single hex block with straight lines.
• Six patches of base type wall, namely, left, right, top, bottom, front, and back.
• The information regarding the patch base type and patch name is saved in the file boundary. Feel free to modify this file to fit your needs.
• Remember to use the utility check mesh to check the quality of the mesh and look for topological errors.
• Topological errors must be repaired.
conclusion: There is a slight difference between the meshes and the plot from the output. As we can see the slope is not different from one another.