Week 8 - Simulation of a backward facing step in OpenFOAM
SIMULATION OF BACKWARD FACING STEP USING OPENFOAM
AIM: To write program that simulates the flow over backward facing step.
OBJECTIVES:
- To simulate flow without using any grading factor ie., GF=1
- To simulate flow with grading factor of 0.2. The cells should be finer near the walls
- To measure the velocity profile at 0.085 from the inlet of geometry and compare.
- To explain why grading factor is essential for meshing.
GIVEN DETAILS:
Mesh Specification:
- Number of cells along x-direction =200
- Number of cells along with longer y-direction =20
Boundary Condition Specification:

Geometry Creation:
Lets create geometry using 5 blocks

Vertices for each block are given as shown below

PROCEDURE:
- In order to start the simulation open terminal window either by pressing ctrl+alt+T or by right clicking on desktop.
- Now in order to simulate the given problem using open foam we are using open foam tutorials folder. For this we have to type "tut" to open tutorial directory and then type “ls” to know the types of files inside the directory.
- We have to solve incompressible flow problem, so select the incompressible directory using “cd” command and then type “ls” to explore the files inside that.
- In the incompressible folder we see different types of solvers hence for this problem we need a solver for laminar viscous flow therefore here we choose icoFoam(icoFoam is a solver in OpenFoam which is used as a transient solver for incompressible laminar flow of Newtonian fluids). Therefore selecting this folder by typing cd icoFoam and then using the “ls” command for exploring the folder.
- Here we have two options cavity and elbow they both are part of the icoFoam solver. Here we use a cavity folder for our required domain. But we are not going to make any changes here in the tutorials action because open foam does not allow us to make changes in their official tutorials.
- So we are going to copy the cavity folder using cp –r cavity command and paste it into the open foam run folder by typing cp –r cavity $FOAM_RUN . Now we can make changes to this cavity folder which will never affect the open foam official file. Open cavity folder here we can provide the specification for our block mesh in system folder.
- There are four script file system folders and by opening blockMeshDict we can create domain and provide the specifications for block mesh. Open this file by typing it blockMeshDict. Make required changes in blockMeshDict script file. After making the changes accordingly save and close this file.
- Now navigate to the controlDict folder and specify simulation time. Now in order to specify the initial values of velocity and pressure and initial boundary conditions navigate to the “0” folder.
- After making the changes in p and U scripts, now we can proceed to deploy mesh using blockMesh command after deploying the mesh then we can run our simulation using icoFoam and then the simulation will start. After completion of this simulation we can view the results using paraFoam command.
- After completing this whole process for grading factor of 1, copy the cavity folder and paste it in the run folder with another name and make the changes accordingly with gf =0.2 and run the program again .
CASE-1 :SIMULATION OF FLOW WITHOUT GRADING FACTOR (GF=1)
BlockMesh 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 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 1)//vertex 11
(8 0 1)//vertex 12
(8 0.5 1)//vertex 13
(0 0.5 1)//vertex 14
(8 1 1)//vertex 15
(0 1 1)//vertex 16
(20 1 1)//vertex 17
(20 0.5 1)//vertex 18
(20 0 1)//vertex 19
(20 -1 1)//vertex 20
(8 -1 1)//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 5 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
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
);
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 20;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
walls
{
type zeroGradient;
}
}
// ************************************************************************* //
Velcoity 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
{
inlet
{
type fixedValue;
value uniform (0.02 0 0);
}
outlet
{
type zeroGradient;
}
walls
{
type noSlip;
}
}
// ************************************************************************* //
OUTPUTS :
BlockMesh Output:

Velcoity Distribution along the domain :

Pressure Distribution along the domain:

Velocity Plot at distance x=0.085 from inlet:

CASE-1 :SIMULATION OF FLOW WITH GRADING FACTOR OF GF=0.2
BlockMesh 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 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 1)//vertex 11
(8 0 1)//vertex 12
(8 0.5 1)//vertex 13
(0 0.5 1)//vertex 14
(8 1 1)//vertex 15
(0 1 1)//vertex 16
(20 1 1)//vertex 17
(20 0.5 1)//vertex 18
(20 0 1)//vertex 19
(20 -1 1)//vertex 20
(8 -1 1)//vertex 21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (50 5 1) simpleGrading (1 5 1)
hex (3 2 4 5 14 13 15 16) (50 5 1) simpleGrading (1 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 10 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
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
);
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 20;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
walls
{
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
{
inlet
{
type fixedValue;
value uniform (0.02 0 0);
}
outlet
{
type zeroGradient;
}
walls
{
type noSlip;
}
}
// ************************************************************************* //
OUTPUTS:
BlockMesh Output:

Pressure Ditsribution along domain:

Velocity distribution along domain :

Velocity plot at x=0.078 and x=0.085 from the inlet:

Imporatance of Grading Factor :
1. Grading factor is ratio of size of end cell to the starting cell.
2. If we need finer mesh at starting cell the grading factor should be greater than 1 and if we need coarser mesh at first cell the grading factor should be less than zero.
3. So grading factor is used to create different meshes based upon requirement.
CONCLUSIONS :
1. As the mesh beacomes finer we can obtain at accuarte results but not always depending upon the problem statement the meshing should be changed with help of grading factor.
2. From the above graphs of vecloity profile at x=0.085 we can observe that the overall slope remained same whereas as grading factor increased the graphs beacomes smoother at the walls.
3. From the above graph we can also say that wthe perks in between when the mesh is finer gives us the most accuarte value at that point . This how process effects the pressure also but reversly as velocity increases the pressure decreases and viceversa.