Week 8 - Simulation of a backward facing step in OpenFOAM
Question:
In this challenge, you are going to simulate an incompressible-laminar-viscous flow through the backward facing step geometry. You should perform a transient simulation. The solver can be chosen based on the described physics of the flow. You need to explain the entire simulation procedure (how you set up the case). You should also provide explanations to every change you make inside the reference case files obtained from Open FOAM tutorials. You can choose the inlet velocity such that the flow is laminar.
After that, you will perform 2 case studies as described below and compare the results.
Objective:
Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)
Case 2 - Simulate the flow with grading factor of 0.2. The cells should be finer near the walls (including the step wall).
You can use the following mesh parameters but you can feel free to modify these values
Measure the velocity profile at 0.085 m from the inlet of the geometry for both case studies and compare. You can use the plot over line tool for this.
Explain why Grading/Growth factor is essential for meshing.
Solution:
As every CFD problem or project is solved in 3 general steps pre-processing, solving and post-processing. Where as in pre-processing we prepare the geometry and then perform mesh on it same thing we are going to do here. We first create the geometry which is given in question which we can see below;
Fig 1. Geometry and Boundary Conditions
Now if we see the above figure we can observe that above geometry can be made by assembling 3 rectangular blocks or 5 rectangular blocks. Now how we can create these blocks as we are going to solve this using the open Foam so lets see step by step how we can setup this.
<!-- [if !supportLists]-->1. <!--[endif]-->First of all we open the OPENFOAM in which we first observes the multiple directories like application, bin, tutorial etc who have sub directories.
<!-- [if !supportLists]-->2. <!--[endif]-->Where in tutorial there are mostly used simulations are given for example multiphase, compressible fluid, incompressible fluid, multi regions etc.
<!-- [if !supportLists]-->3. <!--[endif]-->So based on type of simulation we want to solve we have to choose the tutorial and copy it to run directory (run directory is directory where we solve the solution) we copy it to run directory because if we solve it in tutorial folder then the tutorial files and our simulation file messed up which is not good scenario.
<!-- [if !supportLists]-->4. <!--[endif]-->So we use command $FOAMRUN which creates run directory and using copy(cp -r pitzDaily/ $FOAM_RUN/ pitzDaily_two) command we copy the tutorial which matches our application and paste it in run directory.
<!-- [if !supportLists]-->5. <!--[endif]-->Now how we select the tutorial, so if we see the question ask us for incompressible laminar flow so if we see in tutorial there is incompressible fluid directory in which there is pitzDaily name directory which we are going to use here so we copy that folder which we mention above in step 4.
<!-- [if !supportLists]-->6. <!--[endif]-->After copying the tutorial to run directory its time to check the geometry and the prepare the geometry as asked in question, so to create that geometry we have one block Mesh name file in system directory of tutorial we copied, this block Mesh file is very important to create the mesh and geometry. These blocks are created using vertices number which we can see below(we can open this block mesh file using gedit command);
Fig 2. Block Mesh vertices
In above fig we start the geometry from point 0 where length at x, y, and z is 0, 0, 0 respectively and then the direction where we want point one, we give length at that direction axis (x, y, z) like in or case we give (0.08 0 0) which means 0.08 at x axis and 0 at y and z axis similarly we define all the vertices.
<!-- [if !supportLists]-->7. <!--[endif]-->As we created the vertices now, we create the blocks using hex command here using 8 vertices one block is created and then we define the number of cells we want along x direction and y direction in block which is mentioned in question. And next to that we mention the grading factor according to both cases & Likewise we got total of 5 blocks.
<!-- [if !supportLists]-->8. <!--[endif]-->Next using same vertices, we define the boundary conditions like inlet, outlet, walls etc. for ex. In our case face of two blocks are inlets so we name (11 14 3 0) and (14 16 5 3) here one thing to notice is the direction of vertices we mentioned is anticlockwise which follows right hand thumb rule which states that anti clockwise directs flow toward right hand side. And similarly, we define the outlet and wall properties.
Fig 3. Boundary Conditions
<!-- [if !supportLists]-->9. <!--[endif]-->Now using gedit command we open the controldict file in which we mention the starting and ending time of simulation and size of time step we want here. In our case we goanna run it for 12 seconds so instead of 0.3 we give ending time as 1.2 so that we can get converged solution. We can see the blockmesh file below;
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 11
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0.08 0 0)
(0.08 0.005 0)
(0 0.005 0)
(0.08 0.01 0)
(0 0.01 0)
(0.2 0.01 0)
(0.2 0.005 0)
(0.2 0 0)
(0.2 -0.01 0)
(0.08 -0.01 0)
(0 0 0.01)
(0.08 0 0.01)
(0.08 0.005 0.01)
(0 0.005 0.01)
(0.08 0.01 0.01)
(0 0.01 0.01)
(0.2 0.01 0.01)
(0.2 0.005 0.01)
(0.2 0 0.01)
(0.2 -0.01 0.01)
(0.08 -0.01 0.01)
);
blocks
(
hex (0 1 2 3 11 12 13 14)(80 10 1)simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16)(80 10 1)simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15)(120 10 1)simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13)(120 10 1)simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12)(120 20 1)simpleGrading (5 5 1)
);
boundary
(
inlet
{
type patch;
faces
(
(11 14 3 0)
(14 16 5 3)
);
}
outlet
{
type patch;
faces
(
(19 20 9 8)
(18 19 8 7)
(17 18 7 6)
);
}
upperWall
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
);
}
lowerWall
{
type wall;
faces
(
(11 0 1 12)
(21 10 9 20)
(21 12 1 10)
);
}
frontAndBack
{
type empty;
faces
(
(16 14 13 15)
(14 11 12 13)
(15 13 18 17)
(13 12 19 18)
(12 21 20 19)
(0 3 2 1)
(3 5 4 2)
(2 4 6 7)
(1 2 7 8)
(10 1 8 9)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
<!-- [if !supportLists]-->10. <!--[endif]-->And now at last step we run the simulation using foamRun solver.
Results:
Case 1: Grading Factor 1
Fig 4. After post processing simulation
Fig 5. Changing of parameters along the length of domain
Fig 6. Velocity at 0.085m length
Above results are for grading factor 1.
Fig 7. Grading Factor 1
Case 2: Grading Factor 0.2
Fig 8. Simulation flow post processing
Fig 9. Change in parameters along the length
Fig 10. Velocity at 0.085m length
Fig 11. Grading factor 0.2
Now let’s see what is grading factor or growth factor?
Grading factor is factor which decides the density of mesh and we all know more the denser mesh higher the accuracy we achieve but, too much of denser mesh consumes extra computational power so the growth factor starts from one value and build the element with growth of given factor as it plays transition low between high mesh density and low mesh density, we can see the difference between 0.2 growth factor mesh and 1 growth factor mesh.
Fig 12. 0.2 growth Factor
Fig 13. 1 growth factor
we can clearly se the difference between both of the mesh as in 0.2 grading factor mesh element size looks like increasing where as if we see fig 13. The mesh looks continuous and probably with same size from up to down.