Flow Analysis through Backward Facing Step (BDS) block using BlockMesh tool in OpenFoam
OBJECTIVE:
To create a geometry and simulate a 2D flow through a Backward Facing step using multiple meshes refining mesh grading factors inside BlockMeshDict file of BlockMesh using OpenFOAM.
Problem Statement:
Mesh specification
- 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
THEORY:
Computational Fluid Dynamics (CFD) is the branch of CAE that simulates fluid motion and heat transfer using numerical approaches. The software we use here to simulate the flow is OpenFoam.
OpenFOAM (Open-source Field Operation And Manipulation) is a C++ toolbox for the development of customized numerical solvers, and pre-/post-processing utilities for the solution of continum mechanics problems, most prominently including Computational Fluid Dynamics(CFD).
Operating System and Interface
Operating System used here is Linux - Ubuntu. Hence OpenFoam is a Command Line Interface (CLI), it uses text-based user interface (UI) used to view and manage computer files.
Commands Used:
tut - tutorial
app - applications
sol - solver
cp - copy
rm - remove
ls - list
gedit - used to open text editors
./ - Run
cd - Change directory
cd .. - Change to previous directory
mkdir - Make Directory
$FOAM_RUN - navigates to OpenFoam run directory
paraFoam - opens paraview where the simulation is represented
EXPLANATION:
Steps to be done
- Choosing a Solver
- Creating Geometry
- Editing BlockMeshDict file
A) Boundary Conditions
B) Intial Conditions
1) Pressure
2) Velocity - Editing ControlDict file
- Comparision of various Grading schemes
Velocity Profile & Line Plot - Conclusion
Solver:
Since we need a solver which solves a Incompressible Laminar Navier Stokes Equation (Continuity and Momentum), we choose icoFoam which is present as an inbuilt directory in OpenFoam software.
Inside icoFoam solver, cavity is selected for the project.
Creating Geometry
The below SolidWorks figure represents the geometry to be created by using BlockMeshDict file (present in tutorial/systems) with the same specifications shown below
The BlockMeshDict file is modified to create geometry using Backward Facing Step. Hence it can only be done in blocks, we have considered it as 5 different blocks(1st pic) and the indexed the vertices(2nd pic) inas shown below.
1)Distribution of Blocks
2)Indexing the Vertices
BLOCKMESHDICT FILE
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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
(
//CODE SPLIT UP
//Vertex no: hex ()
//no. of cells in (x y z)
//streching of cells simpleGrading (x y z)
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
(
(20 9 8 19)
(19 8 7 18)
(18 7 6 17)
);
}
front
{
type empty;
faces
(
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
Back
{
type empty;
faces
(
(3 2 1 0)
(5 4 2 3)
(4 6 7 2)
(2 7 8 1)
(1 8 9 10)
);
}
Bottom
{
type wall;
faces
(
(0 1 12 11)
(10 9 20 21)
);
}
Top
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
);
}
Stepside
{
type wall;
faces
(
(1 10 21 12)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
A)Boundary Conditions
Here we have assigned the boundary conditions according to the vertices and mesh grading for the blocks by editing the BlockMeshDict file
The above file creates a Geometry which when viewed in parafiew is shown below.
B)Initial Condtions
Initial Conditions are assigned as per the Boundary Conditions. For this project there are two Initial Conditions. They are
- Pressure
- Velocity
1)Pressure Initial Condition
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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;
}
front
{
type empty;
}
Back
{
type empty;
}
Top
{
type zeroGradient;
}
Bottom
{
type zeroGradient;
}
Stepside
{
type zeroGradient;
}
}
}
// ************************************************************************* //
2)Velocity Initial Condition
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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;
}
front
{
type empty;
}
Back
{
type empty;
}
Top
{
type noSlip;
}
Bottom
{
type noSlip;
}
Stepside
{
type noSlip;
}
}
// ************************************************************************* //
ControlDict file
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ 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;
// ************************************************************************* //
Data Taken:
Simulation Time : 0 to 1 second
dt : 0.001 second
Interval : Stored for every 1000 steps
COMPARISION OF VARIOUS GRADING SCHEMES
A)Velocity Profile
Grading Scheme 1(Default)
Plot
Grading Scheme 0.2
In order to increase the Grading scheme to 0.2 from default, we have to modify code in the BlockMeshDict file. The change of code in the particulate section is given below:
blocks
(
//CODE SPLIT UP
//Vertex no: hex ()
//no. of cells in (x y z)
//streching of cells simpleGrading (x y z)
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.2 1.2 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 (1.2 0.2 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1.2 1.2 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1.2 1.2 1)
);
Velocity Contour
Plot
Grading Scheme 0.5
Similary as represented in the previous Scheme, code is modified accordingly to change the Grad to 0.5.
blocks
(
//CODE SPLIT UP
//Vertex no: hex ()
//no. of cells in (x y z)
//streching of cells simpleGrading (x y z)
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.5 1.5 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 (1.5 0.5 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1.5 1.5 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1.5 1.5 1)
);
Velocity Contour
Plot
Grading Scheme 0.8
Similar Changes as stated in previous section have been modified to change the grade to 0.8
blocks
(
//CODE SPLIT UP
//Vertex no: hex ()
//no. of cells in (x y z)
//streching of cells simpleGrading (x y z)
hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.8 1.8 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.8 0.8 1)
hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1.8 1.8 1)
hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1.8 1.8 1)
);
Velocity Contour
Plot
CONCLUSIONS:
From the above Velocity Contours and Line plots, we can conclude that
- When the fluid crosses the step region, the area increases.
- There is not much difference in the velocity magnitudes in all the cases, however on a magnified scale we can see slight variations around the boundaries because of the presence of close grid spacing resulting in finer results.
- But due to the accurate results at the edge, we could see the flow affected at the center of the region.
- Grading Scheme 0.2 shows wider and cleaner curve as the velocity drops.
- Overall all Grading Schemes gives same results, but due to the mesh grading factor we can say that Velocity Gradient at 0.2 shows more accurate finer results compared to other grading schemes.