Week 8 - Simulation of a backward facing step in OpenFOAM
Simulation of a backward facing step in OpenFOAM
- Objective :
To simulate an incompressible laminar viscous flow through the backward facing step geometry and perform a transient simulation.
CASE 1: To simulate the flow without using any grading factor (i.e, GF = 1).
CASE 2: To simulate the flow with a grading factor of 0.2. The cell should be finer near the walls (including the step wall).
Incompressible-Laminar-Viscous Flow :
Incompressible Flow :
- The flow in which there is no change in the density is called the incompressible flow.
- Mathematically, an incompressible flow can be expressed as

Laminar Flow :
- A laminar flow is one where the fluid motion is regular and there is no mixing. It can be visualized by the path line that do not intersect each other.
- In fluid dynamics, laminar flow is characterized by fluid particles following smooth path in ayers with each layer moving smoothly past the adjacent layer moving smoothly past the adjacent layers with little or no mixing.
- At low velocities the fluid tends to flow without lateral mixing and adjacent layers slide past one another like playing cards. There are no cross currents perpendicular to the direction of flow, nor eddies or swirls of fluids.
- In laminar flow the motion of the particles of the fluid is very orderly with the particles close to the solid surface moving in straight line parallel to the surface. Laminar flow is a flow regime characterized by high momentum diffusion and low momentum convection.

Reynolds Number :
It is the parameter is differntiate a flow as laminar or turbulent.
Whenever the Reynolds number is less than about 2000 flow in a pipe is generally laminar , whereas at values greater than 2000, flow is usually turbulent.
Mathematically, Reynolds number is the ratio of inertial force to the viscous force.
Where,
- `rho` is the density of the fluid(kg/`m^2`).
- u is the flow speed (m/sec).
- L is a characterstic linear dimension (m).
- `mu` is the dynamic viscosity of the fluid (Pa.s or N.s/`m^2` or kg/m.s).
- v is kinematic viscosity of the fluid (`m^2`/sec).
Viscous Flow :
A type of fluid in which there is a continous steady motion of the particles .The motion at a fixed point always remain constant. Also the streamline flow; laminar flow ; steady flow.
The fluid flow is form of a layer. The layer which sticks with the wall has zero velocity which is called no-slip condition abd it develops the frictional effects at the wall. Frictional effects are also present between two layers of fluid and slower layer tries to slow down the faster layer which can be measured by using viscosity. Effects of viscosity are maximum near the boundary so laminar sublayer exist near the boundary this shown.

Mesh Grading :
Mesh grading is a factor that is :
Grading Factor = Size of the last cell / Size of the first cell .
Procedure :-
- First, we are creating the run folder in OpenFoam in which we will be running our simulations.

- And then need to copy the cavity folder to the run folder so that we can make the changes in the blockMeshDict, controlDict, pressure (p), and velocity (U) files as to run our required simulation we are copying the folder because we are not supposed to make any changes in the original folder in the OpenFoam.
- Then will make the changes in the blockMeshDict file that is naming the vertices for and then creating the blocks in this case there are 21 vertices and 5 blocks while creating blocks we also need to specify the numbers of mesh points needed along the x, y, and z-direction and also the simple grading should be done along the boundaries.


- Then we need to assign the boundary conditions here, we need to define all the faces in OpenFoam refers to the patches and giving them type that is the inlet and outlet will be the faces,(type patch), for top and bottom which are the boundary conditions in this cases type will be wall type and setting up these will constitute a particular boundary, then will save these changes in the blockMeshDict.
- blockMeshDict File at gradient factor 1.
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class dictionary; object blockMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // convertToMeters 0.01; vertices ( (0 0 0) (8 0 0) (8 0.5 0) (0 0.5 0) (8 1 0) (0 1 0) (20 1 0) (20 0.5 0) (20 0 0) (20 -1 0) (8 -1 0) (0 0 0.6) (8 0 0.6) (8 0.5 0.6) (0 0.5 0.6) (8 1 0.6) (0 1 0.6) (20 1 0.6) (20 0.5 0.6) (20 0 0.6) (20 -1 0.6) (8 -1 0.6) ); blocks ( hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (1 1 1) hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (1 1 1) hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1 1 1) hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (1 1 1) hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1 1 1) ); edges ( ); boundary ( inlet { type patch; faces ( (0 11 14 3) (3 14 16 5) ); } outlet { type patch; faces ( (9 8 19 20) (8 7 18 19) (7 6 17 18) ); } frontAndBack { type empty; faces ( (0 3 2 1) (11 12 13 14) (3 5 4 2) (13 15 16 14) (2 4 6 7) (13 18 17 15) (1 2 7 8) (12 19 18 13) (10 1 8 9) (21 20 19 12) ); } noslipwalls { type wall; faces ( (4 5 16 15) (4 15 17 6) (0 1 12 11) (9 20 21 10) (1 10 21 12) ); } ); mergePatchPairs ( ); // ************************************************************************* // - blockMeshDict file at gradient factor 0.2
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class dictionary; object blockMeshDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // convertToMeters 0.01; vertices ( (0 0 0) (8 0 0) (8 0.5 0) (0 0.5 0) (8 1 0) (0 1 0) (20 1 0) (20 0.5 0) (20 0 0) (20 -1 0) (8 -1 0) (0 0 0.6) (8 0 0.6) (8 0.5 0.6) (0 0.5 0.6) (8 1 0.6) (0 1 0.6) (20 1 0.6) (20 0.5 0.6) (20 0 0.6) (20 -1 0.6) (8 -1 0.6) ); 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) ); edges ( ); boundary ( inlet { type patch; faces ( (0 11 14 3) (3 14 16 5) ); } outlet { type patch; faces ( (9 8 19 20) (8 7 18 19) (7 6 17 18) ); } frontAndBack { type empty; faces ( (0 3 2 1) (11 12 13 14) (3 5 4 2) (13 15 16 14) (2 4 6 7) (13 18 17 15) (1 2 7 8) (12 19 18 13) (10 1 8 9) (21 20 19 12) ); } noslipwalls { type wall; faces ( (4 5 16 15) (4 15 17 6) (0 1 12 11) (9 20 21 10) (1 10 21 12) ); } ); mergePatchPairs ( ); // ************************************************************************* // - controlDict file
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application icoFoam; startFrom startTime; startTime 0; stopAt endTime; endTime 200; deltaT 1e-2; writeControl timeStep; writeInterval 20; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; // ************************************************************************* // - velocity file(U)
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { 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 (0.066 0 0); } outlet { type zeroGradient; } frontAndBack { type empty; } noslipwalls { type noSlip; } } // ************************************************************************* // - pressure file (p)
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { 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; } noslipwalls { type zeroGradient; } } // ************************************************************************* // - tranportProperties file
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 9 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { format ascii; class dictionary; location "constant"; object transportProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // nu [0 2 -1 0 0 0 0] 1e-6; // ************************************************************************* // - Then in the velocity and pressure files we have to give the value of the velocity at the inlet type will be fixed values here we should assign same values as initial velocity and pressure will be zero Gradient and at the outlet the velocity type will be type will be zero Gradient and pressure will be type fixed value that value be uniform 0; then at frontAndBack velocity type empty and pressure as well as type empty at the no-slip boundaries that is top and bottom velocity, will be type no-slip and pressure type empty. And in the transport Properties we can change the (nu) value in order to obtain the lower courant number.
- And in the controlDict files the simulation time and the time step needed is assigned in the way that the courant number should be less than 0.5.
- And then creating the blockMesh and run the simulation using the respective solver after the completion of simulation open the paraview in the paraFoam and plot the velocity profile for the given value.
- OUTPUT :
Mesh without any grading factor

Mesh with grading factor 0.2

Velocity with no grading factor

Pressure with no grading factor

Velocity with grading factor 0.2

Pressure with grading factor 0.2

Plot of velocity at point 0.085 with no grading factor

Plot of velocity at point 0.085 with grading factor 0.2

- Conclusion :
- By changing the simpleGrading factors from the value of 0.2 to 1 the mesh becomes finer and the solution becomes very accurate.
- Overall the changes in the size of simpleGrading factor (mesh size) the results remain the same as approximately.
- The execution time is lower for lower meshing grading factor.