Simulation of a backward facing step in OpenFOAM
Objective- To use the icoFOAM solver and simulate the flow through a backward facing step.To create multiple meshes and compare the results obtained from each mesh.
Mesh specification
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the y direction = 10
Boundary condition specification
The specifications that are provided in the following figure.
blockMeshDict file
The geometry and mesh is created in the blockMeshDict file.The code for this is below.
/*--------------------------------*- 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.001;
vertices
(
(0 0 0)
(80 0 0)
(80 5 0)
(0 5 0)
(0 0 1)
(80 0 1)
(80 5 1)
(0 5 1)
(200 0 0)
(200 5 0)
(200 0 1)
(200 5 1)
(80 -10 0)
(200 -10 0)
(80 -10 1)
(200 -10 1)
(200 10 0)
(80 10 0)
(200 10 1)
(80 10 1)
(0 10 0)
(0 10 1)
);
blocks
(
hex (0 1 2 3 4 5 6 7)
(80 5 1)
simpleGrading (1 5 1)
hex (1 8 9 2 5 10 11 6)
(120 5 1)
simpleGrading (5 5 1)
hex (12 13 8 1 14 15 10 5)
(120 10 1)
simpleGrading (5 5 1)
hex (2 9 16 17 6 11 18 19)
(120 5 1)
simpleGrading (5 0.2 1)
hex (3 2 17 20 7 6 19 21)
(80 5 1)
simpleGrading (1 0.2 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 4 7 3)
(3 7 21 20)
);
}
outlet
{
type patch;
faces
(
(13 8 10 15)
(8 9 11 10)
(9 16 18 11)
);
}
noSlipWall
{
type wall;
faces
(
(17 20 21 19)
(16 17 19 18)
(0 1 5 4)
(1 12 14 5)
(12 13 15 14)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(3 20 17 2)
(2 17 16 9)
(1 2 9 8)
(12 1 8 13)
(4 5 6 7)
(7 6 19 21)
(6 11 18 19)
(5 10 11 6)
(14 15 10 5)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
controlDict file
In this file time step and time of simulation is provided.The time-step was taken as 1e-4 which gives a courant number below 1.
The simulation was run for 0.1 seconds.
/*--------------------------------*- 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.1;
deltaT 0.0001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
fvShemes
The discretization scheme is provided here.
/*--------------------------------*- 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;
}
// ************************************************************************* //
fvSolution
The iterative solver is included here.
/*--------------------------------*- 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;
}
// ************************************************************************* //
Initial and Boundary conditions:
Initial and boundary conditions are given in p and U file located in the 0 folder.
The initial condition is indicated by the name Internal Field and is set to 0,which means pressure and velocity is 0 at the start.
Boundary condition is given in the boundary field
Intlet velocity is given as 1 m/s and pressure is extrapolated from inner nodes
Oultet velocity is extrapolated from inner nodes and pressure is set to 0
No-slip boundary condition at top and bottom walls.
p 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;
}
noSlipWall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
U 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;
}
noSlipWall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Output:
Mesh for different Grading Factor:
For Grading Factor 0.2
For Grading Factor 0.5
For Grading Factor 0.8
Velocity contour
For Grading Factor 0.2
For Grading Factor 0.5
For Grading Factor 0.8
Velocity magnitude at 0.085m from inlet
For Grading Factor 0.2
For Grading Factor 0.5
For Grading Factor 0.8
Conclusion:
- From the above graphs it can be seen that as we increased the grading factors the velocity profile got smoother.
- This implies that low grading factor gives more accurate result as the grid is finer.
- By using grading factor we can make the grid coarse or fine according to the need of problem at specific areas.