Week 8 - Simulation of a backward facing step in OpenFOAM
Simulation of a backward facing step in OpenFOAM
AIM
To simulate a transient incompressible-laminar-viscous flow through the backward facing step geometry.
To compare the mesh from different meshes created using different grading factor.
CASE STUDIES
Simulate the flow without using grading factor;GF = 1.
Simulate the flow with grading factor of 0.2.
Mesh specification
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the longer y direction = 20.
DOMAIN

CODE EXPLANATION
First, call the tutorials, incompressible, icoFoam, cavity using the cd and ls command (cd = call directory ls = list).
Then copy the cavity directory from the tutorials to FOAM_RUN to work on it.
Call the FOAM_RUN, and then the system to change the blockMeshDict, controlDict, boundary, P, U the gedit command.
To check the simulation icofoam and PARA-FOAM is used.
CASE: 1
blockMeshDict
Verctices and grading factor are defined here
/*--------------------------------*- 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 0.01)//vertex 11
(8 0 0.01)//vertex 12
(8 0.5 0.01)//vertex 13
(0 0.5 0.01)//vertex 14
(8 1 0.01)//vertex 15
(0 1 0.01)//vertex 16
(20 1 0.01)//vertex 17
(20 0.5 0.01)//vertex 18
(20 0 0.01)//vertex 19
(20 -1 0.01)//vertex 20
(8 -1 0.01)//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
(
(16 15 4 5)
(15 17 6 4)
(10 9 20 21)
(10 21 12 1)
(0 1 12 11)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
controlDict
The start and end time is provided here
/*--------------------------------*- 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 10;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
boundary
/*--------------------------------*- 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 polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
4
(
inlet
{
type patch;
nFaces 10;
startFace 9770;
}
outlet
{
type patch;
nFaces 30;
startFace 9780;
}
walls
{
type wall;
inGroups List 1(wall);
nFaces 420;
startFace 9810;
}
defaultFaces
{
type empty;
inGroups List 1(empty);
nFaces 10000;
startFace 10230;
}
)
// ************************************************************************* //
pressure
/*--------------------------------*- 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
/*--------------------------------*- 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;
}
}
// ************************************************************************* //


The velocity profile at 0.085 m from the inlet of the geometry
CASE :2
blockMeshDict (for GF = 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 0.01)//vertex 11
(8 0 0.01)//vertex 12
(8 0.5 0.01)//vertex 13
(0 0.5 0.01)//vertex 14
(8 1 0.01)//vertex 15
(0 1 0.01)//vertex 16
(20 1 0.01)//vertex 17
(20 0.5 0.01)//vertex 18
(20 0 0.01)//vertex 19
(20 -1 0.01)//vertex 20
(8 -1 0.01)//vertex 21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (50 5 1) simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16) (50 5 1) simpleGrading (0.2 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 5 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
(
(16 15 4 5)
(15 17 6 4)
(10 9 20 21)
(10 21 12 1)
(0 1 12 11)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //


The velocity profile at 0.085 m from the inlet of the geometry
Reason why Grading/Growth factor is essential for meshing
Grading factor helps us to refine or focus on the particular phase where the vectors act instead of focusing on the whole domain.
CONCLUSION
Thus the simulation of a transient incompressible-laminar-viscous flow through the backward facing step geometry for the given domain is done.
Also, the mesh using 2 different grading factors is done and comparing them, we can see that there isn't much difference