Backward facing step simulation using openfoam
Objective: Study of icoFOAM solver to simulate the flow through a backward-facing step
- Run the first simulation without grading factor.
- Run the second simulation with the mesh grading factors of 0.2, 0.5 & 0.8. Compare the effect of grading factor with necessary contours & plots.
- Measure the velocity profile at 0.085 m from the inlet of the geometry with a line plot.
- Compare velocity magnitude contours near the step region for the above-mentioned grading factors.
Geometry is created using blockmesh with 5 blocks as shown in figure.
The vertices are as shown in the figure below.
Create the blocks by editing the blockMeshDict file in the system folder. After that run the blockMesh command for generate mesh.
Mesh details:
- The number of cells along the direction of flow = 200
- The number of cells along the y-direction for each block = 10
Case 1(without grading factor)
blockMeshDict
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0) //1
(0.08 0 0) //2
(0.08 0.005 0) //3
(0 0.005 0) //4
(0.08 0.01 0) //5
(0 0.01 0) //6
(0.2 0.01 0) //7
(0.2 0.005 0) //8
(0.2 0 0) //9
(0.2 -0.01 0) //10
(0.08 -0.01 0) //11
(0 0 0.01) //12
(0.08 0 0.01) //13
(0.08 0.005 0.01) //14
(0 0.005 0.01) //15
(0.08 0.01 0.01) //16
(0 0.01 0.01) //17
(0.2 0.01 0.01) //18
(0.2 0.005 0.01) //19
(0.2 0 0.01) //20
(0.2 -0.01 0.01) //21
(0.08 -0.01 0.01) //22
);
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (200 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)
);
}
Noslipwalls
{
type wall;
faces
(
(5 16 15 4)
(4 15 17 6)
(0 1 12 11)
(10 9 20 21)
(10 21 12 1)
);
}
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)
(1 2 7 8)
(2 4 6 7)
(10 1 8 9)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
After meshing apply boundary conditions and initial conditions. It can be given by editing the p and U files in \'0\' folder.
Velocity boundary conditions
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ 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;
}
Noslipwalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Pressure boundary conditions
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ 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;
}
Noslipwalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
ControlDict
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 7
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location \"system\";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime .5;
deltaT 0.00001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
After this run the icoFoam solver.
Mesh
Case 2(grading factor=0.2)
The only change in this case is in the blockmesh. Grading factor of 0.2 is added to the blocks.
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (0.2 1 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (5 1 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (5 .2 1)
);
Mesh
Case 3(Grading factor=0.5)
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.5 2 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (0.5 1 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (2 1 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (2 2 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (2 .5 1)
);
Mesh
Case 4(Grading factor=0.8)
blocks
(
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.8 1.25 1)
hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (0.8 1 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (1.25 1 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1.25 1.25 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1.25 .8 1)
);
Mesh
Result:
Case 1
Velocity plot
Pressure plot
Velocity profile
Velocity profile at 0.085m from inlet is plotted using plot over line.
Case 2
Velocity plot
Pressure plot
Velocity profile
Case 3
Velocity plot
Pressure plot
Velocity profile
Case 4
Velocity plot
Pressure plot
Velocity profile
From the above plots, the change in velocity profile with mesh refinement is negligible. But there is a small change in maximum velocity. It is given in the table. As the grading factor decreases it gives a smooth mesh and thus better plots.