Week 8 - Simulation of a backward facing step in OpenFOAM
Problem Statement:-
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)
Now, we have to simulate our problem in OpenFOAM and we are going to solve our problem using tutorials present in OpenFOAM.
First, start terminal command space in Linux and input "tut" (tutorial), and list out the type of tutorial
Select the incompressible directory by typing ‘cd incompressible’ and list out the type of folders in incompressible folders.
And input the "cd icoFoam" command and list out the type of folders. icoFoam is the solver in OpenFOAM which solve incompressible-laminar-viscous flow

Select the cavity file and list out the type of folders in a cavity. Again, we can see the cavity file in a cavity folder and open the cavity file and list out the folders.
where we have to define our fluid domain and generate block mesh. There are tutorial files in the domain of OpenFOAM So, we are going to copy this cavity folder using the ‘cp -r cavity’ command and paste it into the OpenFOAM run folder by typing ‘cp -r cavity $FOAM_RUN/cavity_test’.
And then open the run folder by typing ‘cd $FOAM_RUN’. where we can see the cavity_test file.

Open the cavity_test folder. Here, we can provide specifications for our block mesh in a system folder.
First open, the blockMesh file and we change which is the flavor to our problem statement the following


vertices
(
(0 0 0)
(8 0 0)
(8 0.5 0)
(0 0.5 0)
(8 1 0)
(0 1 0)
(20 1 0)
(20 0.5 0)
(20 0 0)
(20 -1 0)
(8 -1 0)
(0 0 0.1)
(8 0 0.1)
(8 0.5 0.1)
(0 0.5 0.1)
(8 1 0.1)
(0 1 0.1)
(20 1 0.1)
(20 0.5 0.1)
(20 0 0.1)
(20 -1 0.1)
(8 -1 0.1)
)
ock for meshing
mesh format first letter, in block parenthesis, is ‘hex’ which defines the type of mesh which is hexahedral mesh.
we provide vertices numbers according to order which follows the right-hand thumb rule and the order of vertices follows the rotational order of our other finger.
blocks
(
hex (0 1 2 3 11 12 13 14) (200 20 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (200 20 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (200 20 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (200 20 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (200 20 1) simpleGrading (1 1 1)
);
Here (200,20,1) are number of cells in (x,y,z) direction
Also, we specify boundary conditions of the faces as the inlet, outlet, and walls and pass the vertices numbers.
boundary
(
inlet
{
type wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBack
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
fixedWalls
{
type wall;
faces
(
(5 16 15 4)
(0 1 12 11)
(4 15 17 6)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
After, editing of blockMeshDic file save it and close it.
Furthermore, we are going to edit ‘controlDict’ file to provide time limits - start time and end time. Also to represent delta. While the selection of delta CFL value should be less than 1.
Now we come out system file and open 0 file in cavity_test and open the pressure, and velocity file and we make changes to the boundary condition at each face.
openFOAM code the blockMesh
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
(0 0 0)
(8 0 0)
(8 0.5 0)
(0 0.5 0)
(8 1 0)
(0 1 0)
(20 1 0)
(20 0.5 0)
(20 0 0)
(20 -1 0)
(8 -1 0)
(0 0 0.1)
(8 0 0.1)
(8 0.5 0.1)
(0 0.5 0.1)
(8 1 0.1)
(0 1 0.1)
(20 1 0.1)
(20 0.5 0.1)
(20 0 0.1)
(20 -1 0.1)
(8 -1 0.1)
);
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 (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (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
(
inlet
{
type wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBack
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
fixedWalls
{
type wall;
faces
(
(5 16 15 4)
(0 1 12 11)
(4 15 17 6)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
openFOAM code for controlDict
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.2;
deltaT 0.00001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
openFOAM code for Pressure
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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;
}
fixedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
openFOAM code for Velocity
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ 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;
}
fixedWalls
{
type noSlip;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
At this point, our problem statement is set, we can now proceed to deploy mesh using ‘blockMesh’ command and then use ‘checkMesh’ command

RESULTS


GRAPHS

Case 2 - Simulate the flow with grading factor of 0.2. The cells should be finer near the walls
openFOAM code for blockMeshDict with grading factor of 0.2 at walls
/--------------------------------- C++ -----------------------------------\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\---------------------------------------------------------------------------/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
(0 0 0)
(8 0 0)
(8 0.5 0)
(0 0.5 0)
(8 1 0)
(0 1 0)
(20 1 0)
(20 0.5 0)
(20 0 0)
(20 -1 0)
(8 -1 0)
(0 0 0.1)
(8 0 0.1)
(8 0.5 0.1)
(0 0.5 0.1)
(8 1 0.1)
(0 1 0.1)
(20 1 0.1)
(20 0.5 0.1)
(20 0 0.1)
(20 -1 0.1)
(8 -1 0.1)
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) // block1
simpleGrading
(
(
(0.5 0.5 5) // 50% y-dir, 50% cells, expansion = 5
(0.5 0.5 0.2) // 50% y-dir, 50% cells, expansion = 0.2 (1/5)
)
(
(0.8 0.9 5) // 80% y-dir, 90% cells, expansion = 5
(0.2 0.1 1) // 20% y-dir, 10% cells, expansion = 1
)
1 // z-direction expansion ratio
)
hex (3 2 4 5 14 13 15 16) (80 10 1)
simpleGrading
(
(
(0.5 0.5 5)
(0.5 0.5 0.2)
)
(
(0.2 0.1 1)
(0.8 0.9 0.2)
)
1
)
hex (2 7 6 4 13 18 17 15) (120 10 1)
simpleGrading
(
(
(0.5 0.5 5)
(0.5 0.5 0.2)
)
(
(0.2 0.1 1)
(0.8 0.9 0.2)
)
1
)
hex (1 8 7 2 12 19 18 13) (120 10 1)
simpleGrading
(
(
(0.5 0.5 5)
(0.5 0.5 0.2)
)
(
(0.8 0.9 5)
(0.2 0.1 1)
)
1
)
hex (10 9 8 1 21 20 19 12) (120 10 1)
simpleGrading
(
(
(0.5 0.5 5)
(0.5 0.5 0.2)
)
(
(0.9 0.9 5)
(0.1 0.1 1)
)
1
)
);
edges
(
);
boundary
(
inlet
{
type wall;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outlet
{
type wall;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBack
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
fixedWalls
{
type wall;
faces
(
(5 16 15 4)
(0 1 12 11)
(4 15 17 6)
(10 9 20 21)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************* //
RESULTS




Conclusion
One may conclude after looking at the velocity profile results for grading factors 1 and 0.2. Conclusion: GF 0.2 has a better smooth curve and takes more time to compute than GF 1.