Week 8 - Simulation of a backward facing step in OpenFOAM
BlockMesh Drill down Challenge:
Objective : To simulate an incompressible-laminar-viscous flow through the backward facing step geometry.
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).
Desired output
- Measure the velocity profile at 0.085 m from the inlet of the geometry for both case studies and compare. You can use the plot over line tool for this.
- Explain why Grading/Growth factor is essential for meshing.
Block

Setting up the case Files Steps :
- Copy the base case file from /opt/openfoam8/tutorials/incompressible/icoFoam/cavity/cavity to the run directory
- The cavity tutorial case is used since it matches our flow problem incompressible laminar viscous flow
- The blockMeshdict file is edited according to our geometry and no of grids in x axis = 200 and y axis = 20 respectively .
- The boundary conditions are changed in the 0 folder.
- Pressure - the upperwall, lowerwall, inlet are specified as zeroGradient i.e Neumann boundary
- Outlet specified type -fixedValue - uniform 0
- frontAndBack type empty - since in z direction no computation takes place
- The boundary conditions for U
- upperWall, lowerWall,outlet - zeroGradient
- inlet - fixedValue velocity in x direction - 1m/s
- frontAndback - empty
- we calculate the courant number for the problem according to the CFL condition here a `Delta T` = 0.00001 is used
- After setting up the case files we run the simulation
- BlockMesh - creates the mesh
- icoFoam - solves the equations
- paraFoam - Post -processing
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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Note: this file is a Copy of $FOAM_TUTORIALS/resources/blockMesh/pitzDaily
convertToMeters 0.01;
vertices
(
(-8 0 -0.5)
(-8 1 -0.5)
(0 -1 -0.5)
(0 0 -0.5)
(0 1 -0.5)
(12 -1 -0.5)
(12 0 -0.5)
(12 1 -0.5)
(12 0.5 -0.5)
(0 0.5 -0.5)
(-8 0.5 -0.5)
(-8 0 0.5)
(-8 1 0.5)
(0 -1 0.5)
(0 0 0.5)
(0 1 0.5)
(12 -1 0.5)
(12 0 0.5)
(12 1 0.5)
(12 0.5 0.5)
(0 0.5 0.5)
(-8 0.5 0.5)
);
blocks
(
hex (0 3 9 10 11 14 20 21)
(200 20 1)
simpleGrading (1 1 1)
hex (10 9 4 1 21 20 15 12)
(200 20 1)
simpleGrading ( 1 1 1)
hex (9 8 7 4 20 19 18 15)
(200 20 1)
simpleGrading ( 1 1 1)
hex (3 6 8 9 14 17 19 20)
(200 20 1)
simpleGrading (1 1 1)
hex (2 5 6 3 13 16 17 14)
(200 20 1)
simpleGrading ( 1 1 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 21 10)
(10 21 12 1 )
);
}
outlet
{
type patch;
faces
(
(7 18 19 8)
(8 19 17 6)
(6 17 16 5)
);
}
upperWall
{
type wall;
faces
(
(1 12 15 4)
(4 15 18 7)
);
}
lowerWall
{
type wall;
faces
(
(11 0 3 14)
(14 3 2 13)
(13 2 5 16)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 9 10)
(10 9 4 1)
(9 8 7 4)
(3 6 8 9)
(2 5 6 3)
(11 21 20 14)
(21 12 15 20)
(20 15 18 19)
(14 20 19 17)
(13 14 17 16)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Boundary conditions Velocity
/*--------------------------------*- 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
{
upperWall
{
type noSlip;
}
lowerWall
{
type noSlip;
}
inlet
{
type fixedValue;
value uniform (1 0 0);
}
outlet
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Boundary conditions pressure
/*--------------------------------*- 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
{
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
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 0.5;
deltaT 0.00001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Grading Factor = 1
Mesh

Pressure:

Velocity:

Pressure profile at x = 0.085 m

Velocity profile at x = 0.085 m

Grading Factor = 0.2
block with grading factor
blocks
(
hex (0 3 9 10 11 14 20 21)
(200 20 1)
simpleGrading (0.2 4 1)
hex (10 9 4 1 21 20 15 12)
(200 20 1)
simpleGrading ( 0.2 0.2 1)
hex (9 8 7 4 20 19 18 15)
(200 20 1)
simpleGrading ( 4 0.2 1)
hex (3 6 8 9 14 17 19 20)
(200 20 1)
simpleGrading (4 4 1)
hex (2 5 6 3 13 16 17 14)
(200 20 1)
simpleGrading ( 4 4 1)
);

Pressure

Velocity

Pressure profile at 0.085 m

Velocity profile at 0.085 m

Results and Disccusions
From the plots ablove it is observed there are slight variation in the velocity profile values at 0.085m from the inlet for the non-graded mesh and graded mesh as shown above.
The grading factor is used to obtain the accurate flow variable values in our region of interest and this region region of interest depends upon the problem we are solving and the type of geometry .