Effect of mesh grading and variation of flow velocity in a backward facing step using OpenFoam
Objective
The objective of this project is to compare the variation in solution by changing the grading pattern mesh size. OpenFOAM software is used in this project for simulating the CFD models. ParaView post-processing software is used to view and post-process the obtained results.
Steps:
1) Creating a backward-facing step geometry with different grading patterns of the mesh using grading function in the blockMeshDict file.
2)Providing initial and boundary conditions in blockMeshDict and 0 folder (initial conditions folder).
3)selecting a suitable solver (icoFoam in our case) and using it to solve the simulation.
4) Viewing the solution obtained in ParaView and post-processing it for comparison.
The geometry used for the backward-facing step:
controlDict file for all the three different grading patterns (i.e. 0.2, 0.5, 0.8)
The solution runtime is of 3 seconds
deltaT (size of time step) is set to 1e-5 so that the courant number does not exceed above 0.5.
If the courant number exceeds above 0.5 we might get unstable or blown out results.
witeInterval is set to 1000 ( that means after every 100 time steps the solver would give out the values of assigned variables like pressure and velocity in this case)
runTime is set to modifiable such that the solver will stop once the solution converges or will change the runTime such that the courant number always stays below 0.5.
/*--------------------------------*- 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 3;
deltaT 1e-5;
writeControl timeStep;
writeInterval 1000;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Pressure file for all the three different grading patterns (i.e. 0.2, 0.5, 0.8)
Pressure for this simulation is set to 1e5 (`~~`1 atm) for all the cases.
/*--------------------------------*- 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 1e5;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 1e5;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
U (velocity) file for all the three different grading patterns (i.e. 0.2, 0.5, 0.8)
Inlet velocity is set to 1.5 m/s for all the cases.
/*--------------------------------*- 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.5 0 0);
}
outlet
{
type zeroGradient;
}
upperWall
{
type noSlip;
value uniform (0 0 0);
}
lowerWall
{
type noSlip;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
blockMeshDict file for creating a geometry
The grading scheme is carried in all three simulations while defining the blocks in this file. The below script shows uniform mesh throughout the geometry.
/*--------------------------------*- 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.01 1)
(0.08 0.01 1)
(0.08 0.015 1)
(0 0.015 1)
(0.08 0.02 1)
(0 0.02 1)
(0.2 0.02 1)
(0.2 0.015 1)
(0.2 0.01 1)
(0.2 0 1)
(0.08 0 1)
(0 0.01 1.02)
(0.08 0.01 1.02)
(0.08 0.015 1.02)
(0 0.015 1.02)
(0.08 0.02 1.02)
(0 0.02 1.02)
(0.2 0.02 1.02)
(0.2 0.015 1.02)
(0.2 0.01 1.02)
(0.2 0 1.02)
(0.08 0 1.02)
);
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
(
(7 6 17 18)
(8 7 18 19)
(9 8 19 20)
);
}
upperWall
{
type wall;
faces
(
(5 16 15 4)
(4 15 17 6)
(21 12 1 10)
);
}
lowerWall
{
type wall;
faces
(
(0 1 12 11)
(21 10 9 20)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 5 4 2)
(7 2 4 6)
(8 1 2 7)
(9 10 1 8)
(11 12 13 14)
(13 15 16 14)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
View 1:
In this view, the inlet, top, and side views of the geometry can be viewed.
View 2:
In this view outlet, top and side views of the geometry can be viewed.
For 0.2 :
blockMeshDict
The below part of the scrip is changed from the blockMeshDict file to provide a grading scheme of 0.2 to the mesh near the walls.
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 0.2 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (5 0.2 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 5 1)
);
Meshing with grading scheme of 0.2
The above image shows the variation of velocity along with the geometry for 0.2 grading pattern
The velocity profile is plotted along the vertical length of the geometry and 0.085 meters away from the inlet.
Here,
horizontal axis = length in the vertical direction (m)
vertical axis = velocity (m/s)
For 0.5 :
blockMeshDict
The below part of the scrip is changed from the blockMeshDict file to provide a grading scheme of 0.5 to the mesh near the walls.
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 0.5 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (2 0.5 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 2 1)
);
Meshing with grading scheme of 0.5
The above image shows the variation of velocity along with the geometry for 0.5 grading pattern
The velocity profile is plotted along the vertical length of the geometry and 0.085 meters away from the inlet.
Here,
horizontal axis = length in the vertical direction (m)
vertical axis = velocity (m/s)
For 0.8 :
blockMeshDict
The below part of the scrip is changed from the blockMeshDict file to provide a grading scheme of 0.2 to the mesh near the walls.blockMeshDict
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 0.8 1)
hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (1.25 0.8 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 1.25 1)
Meshing with grading scheme of 0.8
The above image shows the variation of velocity along with the geometry for 0.8 grading pattern
The velocity profile is plotted along the vertical length of the geometry and 0.085 meters away from the inlet.
Here,
horizontal axis = length in the vertical direction (m)
vertical axis = velocity (m/s)
Conclusion :
It can be observed from the above three line graphs that as the mesh becomes finer the solution obtained is much more realistic and accurate variation can be observed from the line plot. as we from 0.2 to 0.8 the mesh near the walls (point of interest in the geometry) goes on becoming coarse and hence a smooth curve is obtained in the line plot of 0.8 grading scheme while the line plot of 0.2 grading scheme shows a proper variation at the point of interest (0.085m away from the inlet.
Hence while selecting a grading scheme and the method of grading as well as the position of grading should be properly decided since a finer mesh is required where the change in value or variation is higher as compared to positions where the variation in values is less or not a point of interest.