Week 8 - Simulation of a backward facing step in OpenFOAM
Introduction:
Open FOAM stands for Open source Field Operation And Manipulation used for developing numerical solvers and finding solutions for continuum mechanics problems including computational fluid dynamics. This work focusses on the transient simulation of an incompressible laminar viscous flow through the backwards-facing step geometry.

IcoFoam:
IcoFoam solves the incompressible laminar Navier stokes equations using the PISO algorithm
Objective:
- To simulate the flow using any grading factor ie. (GF=1)
- To simulate the flow using a grading factor of 0.2
Procedures:
- Open the terminal by clicking clt+alt+T in the Linux operating system.
- Type $FOAM_TUTORIALS or TUT in the terminal window.
- ls represents a list folder.
- pwd represents the present working directory.
- Type cd incompressible/icoFoam/cavity to enter into cavity folder.
- Copy the cavity directory by using cp and paste the directory in the RUN
- Enter into the RUN window by typing cd $FOAM_RUN.
- In the RUN window type cd cavity/cavity/system to enter into the system folder.
- Gedit command is used to open text files.
- Gedit blockmeshdict is used to open blockmesh file.
- Gedit controldict is used to open the control file.
- Cd .. is used to go to the previous folder.
- The constants related to fluid flow like diffusivity can be changed under the constant folder.
- The initial condition related to fluid flow can be changed under the 0 folder.
Geometry:
Block mesh dict file is used for creating geometry, generating mesh and defining boundary condition. The following procedures needed to be followed in creating geometry in Blockmesh.
The whole part is created by using a combination of 5 blocks.
- At first, vertices should be defined for each block ie. 1,2.
- After creating blocks meshing is done by using hex(a,b,c,..) (x,y,z) simpleGrading(p,q,r)
- Hex represents a hexahedral mesh.
- a,b,c represents vertices of the block.
- x,y,z represents meshing in x,y and z-direction.
- Simple grading alters the size of each element.

- The boundary condition is specified in the blockmesh dict file.


Blockmesh dict
/*--------------------------------*- 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]
(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.1)//[11]
(0.08 0 0.1)//[12]
(0.08 0.005 0.1)//[13]
(0 0.005 0.1)//[14]
(0.08 0.01 0.1)//[15]
(0 0.01 0.1)//[16]
(0.2 0.01 0.1)//[17]
(0.2 0.005 0.1)//[18]
(0.2 0 0.1)//[19]
(0.2 -0.01 0.1)//[20]
(0.08 -0.01 0.1)//[21]
);
blocks
(
hex (0 1 2 3 11 12 13 14) (100 10 1) simpleGrading (0.2 1 1)
hex (3 2 4 5 14 13 15 16) (100 10 1) simpleGrading (0.2 1 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (2 1 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (2 1 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (2 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)
);
}
Bottomwall
{
type wall;
faces
(
(11 0 1 12)
(21 10 9 20)
(10 21 12 1)
);
}
Topwall
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
);
}
frontAndBack
{
type empty;
faces
(
(14 13 15 16)
(11 12 13 14)
(21 20 19 12) //Front side
(12 19 18 13)
(13 18 17 15)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)//Back side
(1 2 7 8)
(10 1 8 9)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Controldict
Time steps can be controlled in the controldict file. In this simulation start and end time is provided as 0 and 0.5. deltaT is assumed to be 0.00001.
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;
// ************************************************************************* //
Initial condition
The initial condition for velocity and pressure can be provided in the p and U file located in the 0 folder.
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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
Bottomwall
{
type zeroGradient;
}
Topwall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
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
{
inlet
{
type fixedValue;
value uniform (1 0 0);
}
outlet
{
type zeroGradient;
}
Bottomwall
{
type noSlip;
}
Topwall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Transport properties:
In this simulation, the constant affecting the fluid flow is the diffusivity and the value is chosen to be 0.01.
Transport properties
/*--------------------------------*- 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.01;
// ************************************************************************* //
Results and discussion:
GF=1



GF=0.2



Conclusion:
From the above graph and plots, it can be concluded that change in simple grading value doesn't affect the solution.