Week 8 - Simulation of a backward facing step in OpenFOAM
TITLE
Simulation of a backward facing step in OpenFOAM
OBJECTIVES
- Code in the required inputs in openFOAM and get the geometry right.
- check for errors in geometry
- apply BC's and run the simulation.
- Then change the grading factor to 0.2 and do the same.
The dimensions of the backward step is given below and we generate the geometry accordingly. Codes for which are given below.

ASSUMPSIONS
1. Fluid is Newtonian.
2. incompressible flow (laminar).
3. Small reynolds number.
4. No frictional losses.
STEPS
- Choosing a solver.
- Selecting a Tutorial. (incompressible, icofoam)
- Applying BC's and IC's.
- post processing the results.
- plotting.
CODE
The boundary conditions and initial conditions are given in the 0 file(zero file). Here the bc's are pressure and velocity.
Pressure 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 volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
Toppanel
{
type zeroGradient;
}
Bottompanel
{
type zeroGradient;
}
Front
{
type empty;
}
Back
{
type empty;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
extrapanel
{
type zeroGradient;
}
}
// ************************************************************************* //
Velocity 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 volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
Toppanel
{
type noSlip;
}
Bottompanel
{
type noSlip;
}
Front
{
type empty;
}
Back
{
type empty;
}
inlet
{
type fixedValue;
value uniform (1 0 0);
}
outlet
{
type zeroGradient;
}
extrapanel
{
type noSlip;
}
}
// ************************************************************************* //
BlockMeshDict 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 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.002)
(0.08 0 0.002)
(0.08 0.005 0.002)
(0 0.005 0.002)
(0.08 0.01 0.002)
(0 0.01 0.002)
(0.2 0.01 0.002)
(0.2 0.005 0.002)
(0.2 0 0.002)
(0.2 -0.01 0.002)
(0.08 -0.01 0.002)
);
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 (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (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
(
Toppanel
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
);
}
Bottompanel
{
type wall;
faces
(
(1 12 11 0)
(10 9 20 21)
);
}
Front
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(12 19 18 13)
(21 20 19 12)
);
}
Back
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(1 2 7 8)
(2 4 6 7)
);
}
extrapanel
{
type wall;
faces
(
(1 10 21 12)
);
}
inlet
{
type patch;
faces
(
(5 3 14 16)
(3 0 11 14)
);
}
outlet
{
type patch;
faces
(
(7 6 17 18)
(8 7 18 19)
(9 8 19 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.5;
deltaT 0.00001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Grading factor change in BlockMeshDict is below
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 (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (5 5 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (5 0.2 1)
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (5 5 1)
);
RESULTS
Below you can see the results from which i have obtained with the above codes.
In the beginning i havent taken into account the grading factor which was mentioned in the question.
since this question is not as complex as other difficult problems the data may not be different.
1.So, the below image shows you the variation of magnitude across the cross section of the backward facing step.

2. Variation of pressure through the backward step (last time step)

3. The grading factor was not given any different value. (1 1 1)

4. Magnitude (U) vs vertical axis taken at(x = 0.085, y=-0.01 to 0.01)

5. Pressure taken along the x-axis at(x=0 to 0.2,y = 0)

6. Variation of magnitude with Grading factor of 0.2

7.Variation of Pressure (with GF = 0.2)

8. Visual representation of the cell at GF = 0.2

9. Velocity and Pressure graph with the new GF = 0.2.


As you can see in both cases (of grading factor), the values in the graph appear to be almost the same. This is just because the problem isnt as complex. This is just just an easy example to illustrate the features of OpenFoam and how to use them.
In the case of velocity, The peaks attained are slightly off, if you notice closely we can see in the GF = 1 case the peak velocity is reached at 0.014m, while the problem with a grading factor of 0.2 attains peak velocity slightly faster somewhere in between 0.012 and 0.014.
The pressure variation, shows almost identical behaviour. And as the area increases at 0.08m from the start, you can see a pressure drop. This is due to the change in area, as pressure is defined as force per unit area, as area will increase pressure should decrease.
The pressure all the way till the end reaches a value of 0.
Grading factors are important because they give us more number of data points for the same geometry where some sections of the geometry requires more accuracy than other regions. Here the walls are of more importance(just this example). Grading factor helps us to get more information at those important regions.