Simulation of flow over a backward facing step geometry block using Openfoam and Paraview
Aim: To study the effect of fluid flow over a backward facing step geometry block in OpenFOAM and Paraview.
Objectives:
- Show the variation of velocity magnitude profile as a function of mesh grading factor. Use grading factors 0.2, 0.5, 0.8.
- Measure the velocity profile at 0.085m from the inlet of the geometry.
- Compare velocity magnitude contours near the step region for the above-mentioned grading factors.
Geometry of the problem:
Follow the specifications that are provided in the following figure.
The view of this stepped block geometry in 3D structure is given below
Problem specification:
Initial conditions
Mesh specification
No of cells in x direction = 200
No of cells in y direction = 10
Mesh grading factor
Vertices of geometry
Blocks
Boundary wall specification
Algorithm behind simulation:
- Define the geometry to create blocks and vertices according to the design.
- Open virtual box and in new terminal open tutorial folder inside openfoam application section.
- Copy the cavity tutorial from the icoFoam solver and paste it on the openfoam run folder with a different name.
- To create polymesh file, open the blockMeshDict file and edit the C++ code accordingly to the given problem.
- Inside the blockMeshDict file specify the no of vertices, no of cells in x, y, z direction and grading factor along the axises.
- Specify the top moving wall, bottom fixed wall, front and back wall and step sided wall wrt vertex position.
- Inside the controldict file, initialize the start and end time, diffusivity and delta T and no of time steps.
- Now define the slip boundary conditions for velocity and pressure separately for different wall positions.
- After defining the boundary conditions, run the incompressible solver (icoFoam).
- After the iteration gets converged, post process the solution in paraview.
- After viewing the mesh grading across the boundary wall, post simulate the velocity variation along the inlet and outlet wall.
- Using plot over line command from the filter section, plot the variation of velocity profile at different mesh grading.
Physics behind simulation:
- For a given value of dt, the courant no stability criteria is computed at every iteration steps. The maximum and mean value of courant no determines the convergence of solution.
- The velocity from the inlet to outlet wall is captured for different grading sizes. The flow behavior is studied near the stepped wall.
Workflow diagram
Program code for blockMeshDict file
mesh grading factor 1
/*--------------------------------*- C++ -*----------------------------------*
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation | CodeDeveloper: SOUDIP HAZRA
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0) //vertex[0]
(80 0 0) //vertex[1]
(80 5 0) //vertex[2]
(0 5 0) //vertex[3]
(80 10 0) //vertex[4]
(0 10 0) //vertex[5]
(200 10 0) //vertex[6]
(200 5 0) //vertex[7]
(200 0 0) //vertex[8]
(200 -10 0) //vertex[9]
(80 -10 0) //vertex[10]
(0 0 1) //vertex[11]
(80 0 1) //vertex[12]
(80 5 1) //vertex[13]
(0 5 1) //vertex[14]
(80 10 1) //vertex[15]
(0 10 1) //vertex[16]
(200 10 1) //vertex[17]
(200 5 1) //vertex[18]
(200 0 1) //vertex[19]
(200 -10 1)//vertex[20]
(80 -10 1) //vertex[21]
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (1 1 1) //block1
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (1 1 1) //block2
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1 1 1) //block3
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (1 1 1) //block4
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1 1 1)//block5
);
edges
(
);
boundary
(
topMovingWalls
{
type wall;
faces
(
(15 4 5 16)
(6 4 15 17)
);
}
bottomFixedWalls
{
type wall;
faces
(
(0 1 12 11)
(21 10 9 20)
);
}
stepSidedWalls
{
type wall;
faces
(
(12 1 10 21)
);
}
inletWalls
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outletWalls
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBackWall
{
type empty;
faces
(
(2 1 0 3)
(4 2 3 5)
(8 9 10 1)
(7 8 1 2)
(6 7 2 4)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
mesh grading factor 0.2
/*--------------------------------*- C++ -*----------------------------------*
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation | CodeDeveloper: SOUDIP HAZRA
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0) //vertex[0]
(80 0 0) //vertex[1]
(80 5 0) //vertex[2]
(0 5 0) //vertex[3]
(80 10 0) //vertex[4]
(0 10 0) //vertex[5]
(200 10 0) //vertex[6]
(200 5 0) //vertex[7]
(200 0 0) //vertex[8]
(200 -10 0) //vertex[9]
(80 -10 0) //vertex[10]
(0 0 1) //vertex[11]
(80 0 1) //vertex[12]
(80 5 1) //vertex[13]
(0 5 1) //vertex[14]
(80 10 1) //vertex[15]
(0 10 1) //vertex[16]
(200 10 1) //vertex[17]
(200 5 1) //vertex[18]
(200 0 1) //vertex[19]
(200 -10 1)//vertex[20]
(80 -10 1) //vertex[21]
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.2 5 1) //block1
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.2 0.2 1) //block2
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (5 0.2 1) //block3
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (5 5 1) //block4
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (5 5 1)//block5
);
edges
(
);
boundary
(
topMovingWalls
{
type wall;
faces
(
(15 4 5 16)
(6 4 15 17)
);
}
bottomFixedWalls
{
type wall;
faces
(
(0 1 12 11)
(21 10 9 20)
);
}
stepSidedWalls
{
type wall;
faces
(
(12 1 10 21)
);
}
inletWalls
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outletWalls
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBackWall
{
type empty;
faces
(
(2 1 0 3)
(4 2 3 5)
(8 9 10 1)
(7 8 1 2)
(6 7 2 4)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
mesh grading factor 0.5
/*--------------------------------*- C++ -*----------------------------------*
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation | CodeDeveloper: SOUDIP HAZRA
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0) //vertex[0]
(80 0 0) //vertex[1]
(80 5 0) //vertex[2]
(0 5 0) //vertex[3]
(80 10 0) //vertex[4]
(0 10 0) //vertex[5]
(200 10 0) //vertex[6]
(200 5 0) //vertex[7]
(200 0 0) //vertex[8]
(200 -10 0) //vertex[9]
(80 -10 0) //vertex[10]
(0 0 1) //vertex[11]
(80 0 1) //vertex[12]
(80 5 1) //vertex[13]
(0 5 1) //vertex[14]
(80 10 1) //vertex[15]
(0 10 1) //vertex[16]
(200 10 1) //vertex[17]
(200 5 1) //vertex[18]
(200 0 1) //vertex[19]
(200 -10 1)//vertex[20]
(80 -10 1) //vertex[21]
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.5 2 1) //block1
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.5 0.5 1) //block2
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (2 0.5 1) //block3
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (2 2 1) //block4
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (2 2 1)//block5
);
edges
(
);
boundary
(
topMovingWalls
{
type wall;
faces
(
(15 4 5 16)
(6 4 15 17)
);
}
bottomFixedWalls
{
type wall;
faces
(
(0 1 12 11)
(21 10 9 20)
);
}
stepSidedWalls
{
type wall;
faces
(
(12 1 10 21)
);
}
inletWalls
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outletWalls
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBackWall
{
type empty;
faces
(
(2 1 0 3)
(4 2 3 5)
(8 9 10 1)
(7 8 1 2)
(6 7 2 4)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
mesh grading factor 0.8
/*--------------------------------*- C++ -*----------------------------------*
========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 7
\/ M anipulation | CodeDeveloper: SOUDIP HAZRA
*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0) //vertex[0]
(80 0 0) //vertex[1]
(80 5 0) //vertex[2]
(0 5 0) //vertex[3]
(80 10 0) //vertex[4]
(0 10 0) //vertex[5]
(200 10 0) //vertex[6]
(200 5 0) //vertex[7]
(200 0 0) //vertex[8]
(200 -10 0) //vertex[9]
(80 -10 0) //vertex[10]
(0 0 1) //vertex[11]
(80 0 1) //vertex[12]
(80 5 1) //vertex[13]
(0 5 1) //vertex[14]
(80 10 1) //vertex[15]
(0 10 1) //vertex[16]
(200 10 1) //vertex[17]
(200 5 1) //vertex[18]
(200 0 1) //vertex[19]
(200 -10 1)//vertex[20]
(80 -10 1) //vertex[21]
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.8 1.25 1) //block1
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.8 0.8 1) //block2
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1.25 0.8 1) //block3
hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (1.25 1.25 1) //block4
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1.25 1.25 1)//block5
);
edges
(
);
boundary
(
topMovingWalls
{
type wall;
faces
(
(15 4 5 16)
(6 4 15 17)
);
}
bottomFixedWalls
{
type wall;
faces
(
(0 1 12 11)
(21 10 9 20)
);
}
stepSidedWalls
{
type wall;
faces
(
(12 1 10 21)
);
}
inletWalls
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
outletWalls
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
frontAndBackWall
{
type empty;
faces
(
(2 1 0 3)
(4 2 3 5)
(8 9 10 1)
(7 8 1 2)
(6 7 2 4)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Program code for 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.3;
deltaT 2e-4;
writeControl timeStep;
writeInterval 100;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Program code for transportProperties 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 "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
nu [0 2 -1 0 0 0 0] 0.01;
// ************************************************************************* //
Program code for fvschemes 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 fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linear;
}
laplacianSchemes
{
default Gauss linear orthogonal;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default orthogonal;
}
// ************************************************************************* //
Program code for fvsolutions 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 fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.05;
}
pFinal
{
$p;
relTol 0;
}
U
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-05;
relTol 0;
}
}
PISO
{
nCorrectors 2;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
}
// ************************************************************************* //
Program code for velocity boundary condition 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
{
inletWalls
{
type fixedValue;
value uniform (1.5 0 0);
}
outletWalls
{
type zeroGradient;
}
topMovingWalls
{
type noSlip;
}
bottomFixedWalls
{
type noSlip;
}
stepSidedWalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Program code for pressure boundary condition 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
{
inletWalls
{
type zeroGradient;
}
outletWalls
{
type fixedValue;
value uniform 0;
}
topMovingWalls
{
type zeroGradient;
}
bottomFixedWalls
{
type zeroGradient;
}
stepSidedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Results and analysis
for without mesh
velocity flow simulation
velocity variation plot at x=0.085
The maximum velocity attained is close to 2m/s. The meshing is more in x direction than that of y direction. The maximum velocity is found at the centre of the domain.
for mesh grading factor 0.2
velocity flow simulation
velocity variation plot at x=0.085
The maximum velocity attained is close to 1.7m/s. The meshing is finer in x direction and at the stepped wall side. The maximum velocity is also found at the centre of the domain.
for mesh grading factor 0.5
velocity flow simulation
velocity variation plot at x=0.085
The maximum velocity attained is close to 1.9m/s. The meshing is more in x direction than that of y direction.
for mesh grading factor 0.8
velocity flow simulation
velocity variation plot at x=0.085
The maximum velocity attained is close to 1.9m/s. The meshing is more in x direction and less near the stepped region.
The courant no gives the stability index with respect to mesh grading factor, it is found that mesh grading 0.2 is best as it gives lower courant no as compared to other grading factors.
Conclusion
- The value of mesh grading plays an important role in predicting better velocity flow inside the geometrical domain.
- The courant no also helps in converging towards a stable solution for a given period of iterations.
- The peak velocity is observed to be more smoother in meshed grading factor than without mesh grading factor.
- The velocity range is almost similar for any grading factor, with its high intensity at the stepped wall region.
- Mesh grading factor 0.2 is considered to be best for the given geometrical problem, for lower values of courant no.