Week 8 - Simulation of a backward facing step in OpenFOAM
Aim: Simulation of Backward facing step in OpenFOAM.
Given:
Geometrical Details and Boundary Conditions for Backward facing step:

Mesh specification
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the longer y direction = 20;
Solver requirements:
Transient solver for incompressible laminar viscous flow
Simulation has to be done for following two cases:
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).
Theory with Workflow:
Viscous laminar flow: The flow of viscous fluid which is characterised by the parallel flow of sublayers without mixing and each sublayer has the different velocity than the layer below and above (i.e. Existance of Velocity gradient).
Laminar External flow over a flat surface has the Reynolds number less than ` 5 xx 10^5` .
i.e. `"Re" < 5xx10^5` .
Here Inlet freestream velocity considered to be 0.5 m/s for the air at `25^@ C` such that the flow through the geometry lies into the laminar region.
There are number of solvers available with the tutorial cases in the OpenFOAM, The `"icoFoam"` solver is used for the transient state analysis of viscous laminar flows which fits for our requirements. Thus the tutorial case for icoFoam has been copied and modifications and settings are done accordingly to simulate the given cases as metioned above.
`"blockMesh"` : It is the utility native to openFOAM which generates mesh by creating the blocks of the geometry as mentioned in the directory called `"blockMeshDict"` . After running the `"blockMesh"` cammand the `"polyMesh"` directory is generated inside the `"constant"` folder.
Here we modified `"blockMeshDict"` according to our needs and code is attached herewith.
Intial and Boundary Conditions (`"0"- "directory"`): In OpenFOAM case setup the initial and boundary conditions has to be defined for all primitive variables inside the `"0"- "directory"`.
Here for this case the initial boundary conditions are defined for `"Dynamic Pressure(p)"` and `" Velocity(U)"` allover the domain of interest. The codes is attached below.
`"Transportproperties"` : The transport property of the flow which remains constant for the simulation are defined inside the transportporties.
Here for this simulation the value of `"Kinematic Viscosity" (nu)` is defined inside the transportproperties.
Reynolds Number based on the `"Kinematic Viscosity" (nu)` is given as follows:
`"Re" = (U*L)/nu` where `L - "Characteristic Length (Distance from leading edge)"` .
`"controlDict"`: It the directory which includes the settings for simulation.
Here we set the simulation start time as 0 sec and end time as 3 sec with the incremental time step as 0.001 sec. Which keep keeps the CFL number below 1 as the stability criteria suggests.
`"Paraview"` : It the data visualisation and post processing tool availble with the OpenFOAM.
Here the contour plots and velocity profile graphs are obtained from the `"Paraview"` .
`"simpleGrading"` : It is used to generate uniform and nonuniform mesh insides the blocks with given expansion ratios i.e ratio of final and initial cell lengths in specific directions.
Importance of simpleGrading (Expansion Ratios): It enables the mesh to be graded or refined in specified directions which indeed helps in mesh refinement in the area of interest.
For `case I` we used `"simpleGrading" (1 1 1)` and for `case II` `"simpleGrading"` is modified accordingly.
Cammands Used for simulation:
- `"blockMesh"` - To generate mesh
- `"icoFoam"` - To solve the required governing equations
- `"paraFoam"` - To visualise and post process the results
Case I -blockMeshDict Code:
/*--------------------------------*- 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 1;
vertices
(
(0 0 0) //0
(0.08 0 0) //1
(0.08 0.005 0) //2
(0 0.005 0) //3
(0.08 0.01 0) //4
(0 0.01 0) //5
(0.2 0.01 0) //6
(0.2 0.005 0) //7
(0.2 0 0) //8
(0.2 -0.01 0) //9
(0.08 -0.01 0) //10
(0 0 0.01) //11
(0.08 0 0.01) //12
(0.08 0.005 0.01) //13
(0 0.005 0.01) //14
(0.08 0.01 0.01) //15
(0 0.01 0.01) //16
(0.2 0.01 0.01) //17
(0.2 0.005 0.01) //18
(0.2 0 0.01) //19
(0.2 -0.01 0.01) //20
(0.08 -0.01 0.01) //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 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)
);
}
upperWall
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
);
}
lowerWall
{
type wall;
faces
(
(0 1 12 11)
(10 9 20 21)
(1 10 21 12)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(1 8 9 10)
(2 7 8 1)
(4 6 7 2)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
);
// ************************************************************************* //
Case II -blockMeshDict Code:
/*--------------------------------*- 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 1;
vertices
(
(0 0 0) //0
(0.08 0 0) //1
(0.08 0.005 0) //2
(0 0.005 0) //3
(0.08 0.01 0) //4
(0 0.01 0) //5
(0.2 0.01 0) //6
(0.2 0.005 0) //7
(0.2 0 0) //8
(0.2 -0.01 0) //9
(0.08 -0.01 0) //10
(0 0 0.01) //11
(0.08 0 0.01) //12
(0.08 0.005 0.01) //13
(0 0.005 0.01) //14
(0.08 0.01 0.01) //15
(0 0.01 0.01) //16
(0.2 0.01 0.01) //17
(0.2 0.005 0.01) //18
(0.2 0 0.01) //19
(0.2 -0.01 0.01) //20
(0.08 -0.01 0.01) //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 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)
);
}
upperWall
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
);
}
lowerWall
{
type wall;
faces
(
(0 1 12 11)
(10 9 20 21)
(1 10 21 12)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(1 8 9 10)
(2 7 8 1)
(4 6 7 2)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
);
// ************************************************************************* //
Initial and Boundary conditions code:
Dynamic Pressure (p) :
/*--------------------------------*- 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;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Velocity(U):
/*--------------------------------*- 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.5 0 0);
}
outlet
{
type zeroGradient;
}
upperWall
{
type noSlip;
}
lowerWall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Transportpropeties:
/*--------------------------------*- 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1e-05;
// ************************************************************************* //
controlDict:
/*--------------------------------*- 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 3;
deltaT 0.001;
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: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
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;
}
// ************************************************************************* //
Graphs:
1) Meshing for Case I (Top) and Case II (Bottom):

2) Final Pressure contours for Case I (Top) and Case II (Bottom):

3) Final Velocity contour for Case I (Top) and Case II (Bottom):

4) Velocity Profile at 0.085 m from the inlet for Case I:

5) Velocity Profile at 0.085 m from the inlet for Case II:

Observations and Conclusions:
1) From the figure 1 it is clear that in Case I the mesh is uniform through out the domain while in Case II the mesh is fine at the walls as well as around the step corner.
This is achieved by changing the simpleGrading parameters.
2) From the figure 2 the final pressure contours, it can be clearly seen that the dynamic pressure is less around the step at flow is expanding there due to sudden enlargement of cross section. While the dark blue spot is clearly visible at step corner in case II only which is due to the mesh refinement around the step corner.
3) From the figure 3 the final velocity contours, it can seen seen that the flow is purely laminar in nature. In Case II the velocity contour is more sharp near the domain walls and around the corner, this is also due to the mesh refinement at required zones using simpleGrading.
4) Figure 4 shows the graph of velocity profile across the cross section at x=0.085 m (i.e. 0.085 m away from the inlet) for uniform mesh (Case I). The velocity change around the step corner is smooth.
5) Similarly Figure 5 shows the graph of velocity profile across the cross section at x=0.085 m (i.e. 0.085 m away from the inlet) for refined mesh (Case II). The velocity change around the step corner is sharp. This is because of the mesh refinement around the step corner using simpleGrading. The Velocity profile is not smooth at the center of upper half as compared to velocity profile at figure 4 , this is due to the coarse mesh at that region in the Case II.
6) The CFL number through out the simulation of both cases observed to be below 1 which indiactes the stability of the solution.