Simulating flow over backward facing step using openfoam
Objective:
1. To solve two-dimensional flow over backward step using icoFoam solver, which is transient incompressible, laminar flow of newtonian fluids in openfoam.
2. To analyse velocity profile change as a function of mesh grading factor(0.2, 0.5,0.8 and 1)
Flow Domain:
The computational flow domain is a two dimensional backward facing step where the fluid enters from inlet and exits via outlet.No slip boundary condition is employed at the walls.
Mesh creation procedure:
1. First, openfoam/tutorials/incompressible/icoFoam/cavity file is copied to the run folder($FOAM_RUN).
2. The Mesh(along with geometry) and specified boundaries is contained in a dictionary file \'blockMeshDict\' in system folder. Therfore blockMeshDict file is to be edited to suit our case using gedit command.
3. By Default, OPENFOAM creates three dimensional mesh, To suit our case the three dimensional geometry is converted to 2D geometry by providing front and back sides as an empty boundary.
4. Therefore, first we need to create three dimensional geometry by specifing the vertices and create faces from specified vertices.The three dimensional backward facing step is is created in form of five blocks and then merged together as shown in figure below.
5. While creating the blocks from the vertices, the order of vertices would define the local coordinate system of the block.i.e for the 1st block, if the vertices are specified in 0 1 2 3 11 12 13 14 order then the x,y and z axis of local coordinate system is along positive x,y and z axis.
6. After specifing the blocks in the order as stated above, mesh is refined in certain areas of domain(wall and step region) using mesh grading factor. Mesh grading factor is the ratio of the width of end cell along one edge of a block to the width of start cell along the edge.for if mesh grading factor is 0.2 then end cell:start cell= 1:5. Mesh refining is done using \'simpleGrading\' command which specifies the mesh grading factor along the three local coordinate axis. For ex. simpleGrading ( 0.2 1 1) implies mesh is refined in x axis by grading factor 0.2.
7. Mesh can be generated by using the blockMesh command in the transcript window.
8. For solution calculation, the name of the solver used \'icoFoam\' command is given in the transcript window.And to open the post processor of openfoam(paraview), paraFoam command is given in the transcript.
BOUNDARY CONDITIONS:
1. Faces were assigned with following boundary types,
Inlet --> patch
Outlet --> patch
Top and bottom --> wall
front and back --> empty (to convert to 2D)
2. While assigning the faces to these boundary types, right hand thumb rule should be followed where thumb pointing towards the normal directtion of the face(outwards). For ex, while assinging faces to inlet, vertices should be assigned in anti-clockwise direction(i.e. 0 11 16 5).
3. At Inlet- velocity of the fluid flow is specified 1m/s.( along x direction)
4. At Outlet- gauge pressure( or atmospheric pressure) is set to 0 at outlet.
5. At wall- No slip condition is specified where the fluid which is in contact with the wall is stationary( velocity is zero).
Initial Conditions:
1. In our case, Pressure is actually the ratio of pressure[pa] and density[kg/m^3] , the dimensions are specified `frac{m^2}{s^2}`. We need to specify the units of our primitive variables with appropriate units,This is done using dimensions command in initial conditions.In order to specify the units in dimensions, the following algorithmn must be followed,
2. Therefore for pressure[m^2/s^2], dimensions [ 0 2 -2 0 0 0 0]. And velocity[m/s] , dimensions [ 0 1 -1 0 0 0 0].
3. For both pressure and velocity, initial flow field is set to 0, where pressure is given uniform 0 and velocity is given uniform(0 0 0), since pressure is scalar quantity and velocity is vector quantity.
Transport Properties:
1. Since, The flow is assumed laminar, kinematic viscosity[m^2/s] is given a value of 0.01.In openfoam kinematic viscosity is denoted by \'nu\'. This information is stored in transportProperties file located in constant folder.
/*--------------------------------*- 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 \"constant\";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.01;
// ************************************************************************* //
Time Step calculation:
1. total time of simulation: 0.05 sec
2. time step: time step is given a value of 1e-05, in order to maintain courant number less than 1(according to CFL condition).
3. This information is stored in controlDict file in system folder.
blockMeshDict file for grading factor 1:
/*--------------------------------*- 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 0.01;
vertices
(
(0 0 0)// 0
(8 0 0)//1
(8 0.5 0)//2
(0 0.5 0)//3
(8 1 0)//4
(0 1 0)//5
(20 1 0)//6
(20 0.5 0)//7
(20 0 0)//8
(20 -1 0)//9
(8 -1 0)//10
(0 0 0.1)//11
(8 0 0.1)//12
(8 0.5 0.1)//13
(0 0.5 0.1)//14
(8 1 0.1)//15
(0 1 0.1)//16
(20 1 0.1)//17
(20 0.5 0.1)//18
(20 0 0.1)//19
(20 -1 0.1)//20
(8 -1 0.1)//21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (1 1 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1 1 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 12) (120 5 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
Inlet
{
type patch;
faces
(
(0 11 14 3)
(14 16 5 3)
);
}
Outlet
{
type patch;
faces
(
(19 20 9 8)
(18 19 8 7)
(17 18 7 6)
);
}
frontAndBack
{
type empty;
faces
(
(2 1 0 3)
(4 2 3 5)
(6 7 2 4)
(7 8 1 2)
(8 9 10 1)
(11 12 13 14)
(14 13 15 16)
(13 18 17 15)
(12 19 18 13)
(21 20 19 12)
);
}
topandbottom
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(1 12 11 0)
(9 20 21 10)
(12 1 10 21)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
For grading Factor of 0.2:
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.2 1 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (0.2 0.2 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (5 1 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (5 0.2 1)
hex (10 9 8 1 21 20 19 12) (120 5 1) simpleGrading (5 5 1)
);
For grading Factor of 0.5:
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.5 1 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (0.5 0.5 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (2 1 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (2 0.5 1)
hex (10 9 8 1 21 20 19 12) (120 5 1) simpleGrading (2 2 1)
);
For grading Factor of 0.8:
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.8 1 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (0.8 0.8 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1.25 1 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1.25 0.8 1)
hex (10 9 8 1 21 20 19 12) (120 5 1) simpleGrading (1.25 1.25 1)
);
controlDict file:
/*--------------------------------*- 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 0.05;
deltaT 1e-04;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
pressure file:
/*--------------------------------*- 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;
}
topandbottom
{
type zeroGradient;
}
}
// ************************************************************************* //
velocity file:
/*--------------------------------*- 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;
}
topandbottom
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
1.For grading factor 1:
1.1 Mesh Generated
1.2 Velocity contour :
1.3 Velocity profile at cross section 0.085 m from Inlet
2. for grading factor 0.2:
2.1 Mesh Generated :
2.2 Velocity contour :
2.3 Velocity profile at cross section 0.085 m from Inlet
3.for grading factor 0.5:
3.1 Mesh Generated:
3.2 Velocity contour :
3.3 Velocity profile at cross section 0.085 m from Inlet
4. for grading factor 0.8:
4.1 Mesh Generated
4.2 Velocity contour :
4.3 Velocity profile at cross section 0.085 m from Inlet
Conclusion:
1. By observing the velocity contours,before the backing facing step, we can observe there at a cross section velocity magnitude is maximum at its centre and velocity is minimum near the wall.This behaviour is due to the no slip condition.
2. After the flow passes through the backward facing step( at cross section of 0.085m from inlet), we can observe that the maximum velocity magnitude is shifted towards the right of the cross section.i.e just after the backward facing step velocity is maximum at 0.04m from centre of the cross section. This change in velocity profile is observed due to the expansion in area of flow(backward facing step).
3. As the flow passes throught the backward facing step, There is increase in flow area which leads to decrease in overall velocity of fluid flow.
4. By observing the mesh generated by different grading factor, grading factor of 0.2 has the most refined mesh near the backward facing step region.And refined mesh would lead to better flow properties calculation in those regions thereby better plots.Though there is not much difference in velocity profiles in these different grading factors.
5. Therefore using mesh grading factors we can refine the mesh in the regions where the flow properties are to be measured accurately.