Week 8 - Simulation of a backward facing step in OpenFOAM
AIM- To simulate a backward facing step in OpenFOAM using grading factor 1 and 0.2 and measure the velocity profile at 0.085m from the inlet.
THEORY-
#The geometry provided can be distributed into five blocks as follows,

#3 Dimensional representation of the step,

PROCEDURE-
1.Open the terminal and simulate the in OpenFOAM using the tutorial file.
2.The tutorials directory is opened by typing 'tut', then list of files within the directory is extracted by entering ls.
3.Since the the simulation is performed for incompressible flow, cd command is used to open the respective directory followed by ls to list the files within the directory.
4.Then solver icoFOAM and cavity folder are selected and a copy of cavity into FOAM_RUN folder is made by the name 'cavity_challenge'.
5.The blockMeshDict file within the system directory is opened to define the specifications of the problem and the file is then saved.
6.The controlDict script file is opened and the simulation time is specified.
7.Later, the blockMesh command is entered to launch the mesh and solver name 'icfoam' is entered to start the simulation.
8.The variations and results of the simulation are viewed in paraview using paraFoam command.
CASE 1- GRADING FACTOR 1
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;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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 10 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 walls;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
- The vertices are defined by making changes to the exiting blockMeshDict file.
- Allocation of cells in both x and y direction is also defined.
- Grading factor used is also defined which is 1 as in this case.
ControlDict-
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ 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;
// ************************************************************************* //
INITIAL SETUP-
FOR 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 (0.02 0 0);
}
outlet
{
type zeroGradient;
}
walls
{
type noSlip;
}
}
// ************************************************************************* //
FOR 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;
}
walls
{
type zeroGradient;
}
}
// ************************************************************************* //
RESULTS-
BLOCK MESH

Since the grading factor is one the mesh size is even throughout the geometry.
VELOCITY

PRESSURE

VELOCITY PROFILE

Velocity profile at x=0.085m
PRESSURE PROFILE

Pressure profile at x=0.085.
CASE 2- GRADING FACTOR 0.2
BlockMeshDict
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ 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 10 1) simpleGrading (5 5 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 walls;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
ControlDict
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ 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;
// ************************************************************************* //
Block Mesh (Graded to 0.02)

As the grading factor is reduced the size of the mesh doesn't remain even throughout the geometry,the mesh mesh at specified areas become finer instead.
Velocity Simulation

Pressure simulation

Velocity Profile

Pressure Profile

CONCLUSION-
1.Higher grading factor results in larger mesh where as a lower grading factor leads to a finer mesh.
2.As the mesh becomes finer, the results get to differ slightly from the results of mesh with higer grade, the precision in results increases with decrease in grading factor.