2 dimensional flow simulation over a Backward Facing Step (BFS) in a pipe for different meshing strategies using BlockMesh tool in OpenFOAM
1. Project Aim : 2 dimensional flow simulation over a Backward Facing Step (BFS) in a pipe for different meshing strategies using BlockMesh tool in OpenFOAM
2. Problem Description :
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the y direction = 10
- Use a graded mesh. Grading factor near all walls should be 0.2
3. Boundary condition specification :
Follow the specifications that are provided in the following figure.
4. Project objectives :
- How does the velocity magnitude profile change as a function of mesh grading factor. Use factors, 0.2, 0.5,0.8.
- To measure the velocity profile at 0.085 m from the inlet of the geometry.
- Plot must be a line plot.
- To compare velocity magnitude contours near the step region for the above mentioned grading factors
5. Solver :
Solver used for simulating the flow is icoFoam which is a transient solver for incompressible, laminar flow of Newtonian fluids.
6. Governing Equations :
Continuity equation : `Deltau = 0`
Momentum equation : `(delu)/(delt)+Delta(u u)=-1/rhoDeltabarp+Deltan.u[2S]`
pressure :`p=1/rhobarp`
7. Procedure :
7.1. Step 1. Splitting the geometry in multiple blocks
The given geometry is first divided in 5 blocks and each vertex is indexed by a number as shown in the figure
The isometric view of the geometry along with the indexing for all the vertices is as shown. After that the hexahedral (six-faced) blocks are defined in which the sequence of the vertices is important. The sequence is decided by the 'right hand thumb rule' in which thumb points towards the direction of the normal when the fingers are curls as per the vertices sequence.
Boundary description involves 4 boundaries named Inlet, Outlet, frontAndBack and noSlipWalls as indicated in blockMeshDict file. Looking at the geometry the necessary changes are made in the BlockMeshDict codes which would be shown below.
The blockMeshDict file for without grading case is as shown:
/*--------------------------------*- 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) // Vertex no. 0
(0.08 0 0) // Vertex no. 1
(0.08 0.005 0) // Vertex no. 2
(0 0.005 0) // Vertex no. 3
(0.08 0.01 0) // Vertex no. 4
(0 0.01 0) // Vertex no. 5
(0.2 0.01 0) // Vertex no. 6
(0.2 0.005 0) // Vertex no. 7
(0.2 0 0) // Vertex no. 8
(0.2 -0.01 0) // Vertex no. 9
(0.08 -0.01 0) // Vertex no. 10
(0 0 0.001) // Vertex no. 11
(0.08 0 0.001) // Vertex no. 12
(0.08 0.005 0.001) // Vertex no. 13
(0 0.005 0.001) // Vertex no. 14
(0.08 0.01 0.001) // Vertex no. 15
(0 0.01 0.001) // Vertex no. 16
(0.2 0.01 0.001) // Vertex no. 17
(0.2 0.005 0.001) // Vertex no. 18
(0.2 0 0.001) // Vertex no. 19
(0.2 -0.01 0.001) // Vertex no. 20
(0.08 -0.01 0.001) // Vertex no. 21
);
blocks
( // Vertex no. no. Cells cell stretching
hex (0 1 2 3 11 12 13 14) (100 10 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (100 10 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (100 10 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (100 10 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (100 10 1) simpleGrading (1 1 1)
);
edges
(
);
boundary // Keyword
(
Inlet // Patch0 Name
{
type patch; // Patch0 type
faces
(
(0 11 14 3) // Block face 0 in this patch
(3 14 16 5) // Block face 1 in this patch
);
}
Outlet
{
type patch; // patch1 Name
faces // patch1 type
(
(20 9 8 19) // Block face 0 in this patch
(19 8 7 18) // Block face 1 in this patch
(18 7 6 17) // Block face 2 in this patch
);
}
frontAndBack // patch2 Name
{
type empty; // patch2 type
faces
(
(0 3 2 1) // Block face 0 in this patch
(3 5 4 2) // Block face 1 in this patch
(10 1 8 9) // Block face 2 in this patch
(1 2 7 8) // Block face 3 in this patch
(2 4 6 7) // Block face 4 in this patch
(11 12 13 14)// Block face 5 in this patch
(14 13 15 16)// Block face 6 in this patch
(21 20 19 12)// Block face 7 in this patch
(12 19 18 13)// Block face 8 in this patch
(13 18 17 15)// Block face 9 in this patch
);
}
noSlipWalls // patch3 Name
{
type wall; // patch3 type
faces
(
(16 15 4 5) // Block face 0 in this patch
(15 17 6 4) // Block face 1 in this patch
(10 21 12 1) // Block face 2 in this patch
(0 1 12 11) // Block face 3 in this patch
(10 9 20 21) // Block face 4 in this patch
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
7.2. Step 2. Viewing the Mesh and Geometry in Paraview
After defining the geometry in the BlockMeshDict, the blockmesh command is run in the terminal and the geometry and mesh can be seen in Paraview.
For this case, the number of cells in each block are 200 along x-direction and 10 along y-direction for each block. The grading factors are given to have a finer grid near the wall surface where the flow parameters are expected to change abruptly.
Fig1. Geomtery and Mesh without grading factor
Fig2. Geomtery and Mesh without grading factor = 0.8
Fig3. Geomtery and Mesh without grading factor = 0.5
Fig4. Geomtery and Mesh without grading factor = 0.2
7.3. Step 3. Setting up the controlDict file
Parameters like the end time (1s) and time step (0.0001) can be changed in this file as shown in the figure. The solution results are saved after every 1000 time steps.
/*--------------------------------*- 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 1;
deltaT 0.0001;
writeControl timeStep;
writeInterval 1000;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
7.4. Step 4 : Setting up the Initial Conditions:
Initial conditions are the starting conditions from which the solver starts to calculate for the further time steps. These initial conditions are provided through out the domain as well as on the boundaries. The '0' folder is the one which stores the initial conditions for the variables that matters for the simulation. For this simulation for all the meshes the initial conditions are kept constant as shown.
Initial Pressure 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 ;
}
frontAndBack
{
type empty;
}
noSlipWalls
{
type zeroGradient;
}
// ************************************************************************* //
Initial Velocity 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;
}
frontAndBack
{
type empty;
}
noSlipWalls
{
type noSlip;
}
}
// ************************************************************************* //
8. Results and Discussions :
8.1. Pressure and Velocity Contours
icoFOAM solver was used to run the simulation and the results obtained for all the cases are as shown:
8.1.1 Case 1 : Without Grading factor
In this case there was no mesh grading provided to the mesh. It means the uniform mesh is used throughout the domain.
Fig5. Pressure Contour (without grading factor):
Fig6. Velocity Contour (without grading factor):
8.1.2 Case 2: Grading factor = 0.8
In this case there was mesh grading of 0.8 was provided to the mesh, so that a finer mesh can be obtained near the walls and near the step region. But the number of cells along X and Y directions are kept same throughout.
Fig7. Pressure Contour (with grading factor = 0.8):
Fig8. Velocity Contour (with grading factor = 0.8):
8.1.3 Case 3: Grading factor = 0.5
In this case there was mesh grading of 0.5 was provided to the mesh, so that a finer mesh (as compared to previous case) can be obtained near the walls and near the step region. But the number of cells along X and Y directions are kept same throughout.
Fig9. Pressure Contour (with grading factor = 0.5):
Fig10. Velocity Contour (with grading factor = 0.5):
8.1.4 Case 4: Grading factor = 0.2
In this case there was mesh grading of 0.2 was provided to the mesh, so that a finer mesh (the finest grid in all the cases) can be obtained near the walls and near the step region. But the number of cells along X and Y directions are kept same throughout.
Fig11. Pressure Contour (with grading factor = 0.2):
Fig12. Velocity Contour (with grading factor = 0.2):
8.2. Line Plots along a line parallel to Y axis :
To capture the effect of grading near the top and bottom walls, a line plot is obtained at the specified position.
Fig13. Velocity profile for different grading factors
As shown in velocity plot there is not much difference in the velocity magnitudes in all the cases. But on a magnified scale near the boundary (i.e. 0m and 0.02m) there are some variations for velocity values for all the meshes which can be captured by magnified axis along X and Y or can be seen from the datas from which the plot is generated.
8.3. Line Plots along X axis :
To capture the effect of grading near the step region, a line plot is obtained at the X axis. The plot is shown below.
Fig14. Velocity Fluctuations near step region for different profiles
As seen from the plot the velocity fluctuates near the step region for all the meshes. But on a magnified scale, it can be seen that the finer the grid, the smaller are the fluctuations.
Fig15. Magnified view of Velocity fluctuations near step region for different meshes.
Thus the grading factor of 0.2 gives better results near the step region.
9. Conclusion:
For this particular case, to get even more accurate results, a 0.2 grading factor with more number of cells (to avoid the abrupt change in cell size over a short distance) can be recommended.