Week 8 - Simulation of a backward facing step in OpenFOAM
The given geometry is divided into 5 blocks with 21 vertex points. Simple grading is done.
Tutorial selected: incompressible - icoFoam - cavity
Case 1: Meshing without grading, i.e simple grading with grading factor 0.2 is used.
Step 1:Modify blockMeshDict file:
blockMeshDict file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 0.1;
vertices
(
(0 0 0) //V-0
(8 0 0) //V-1
(8 0.5 0) //V-2
(0 0.5 0) //V-3
(8 1 0) //V-4
(0 1 0) //V-5
(20 1 0) //V-6
(20 0.5 0) //V-7
(20 0 0) //V-8
(20 -1 0) //V-9
(8 -1 0) //V-10
(0 0 0.1) //V-11
(8 0 0.1) //V-12
(8 0.5 0.1) //V-13
(0 0.5 0.1) //V-14
(8 1 0.1) //V-15
(0 1 0.1) //V-16
(20 1 0.1) //V-17
(20 0.5 0.1)//V-18
(20 0 0.1) //V-19
(20 -1 0.1) //V-20
(8 -1 0.1) //V-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 (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 12 19 18 13) (120 5 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)
(3 2 4 5)
(10 1 8 9)
(1 2 7 8)
(2 4 6 7)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
noslipwall
{
type wall;
faces
(
(16 15 4 5)
(11 12 1 0)
(15 17 6 4)
(21 20 9 10)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Step 2: Modify U file:
U file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
frontAndBack
{
type empty;
}
noslipwall
{
type noSlip;
}
}
// ************************************************************************* //
Step 3: modify p file:
p file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
noslipwall
{
type zeroGradient;
}
}
// ************************************************************************* //
Step 4: modify controlDict
controlDict file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 3;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Step 5: run blockMesh
Step 6: run checkMesh
Step 7: run icoFoam
Once the simulation is done, post processing is done.
Step 8: Post processing is done in paraview;
Mesh file with simple grading:

Velocity profile:

Pressure profile:

Importance of grading in mesh:
Grading introduces variation between coarse and finer mesh gradients. Grading factor is used to define the purpose; it is a ratio of cell size percentage of last cell to the cell size percentage of the first cell.
A grading factor of 0.2 gives a mesh with 1st cell of the block 10 times to the last cell of the block, hence grading factor 0.2(1/10=0.2).
Simple grading mode is used; and is specified in the blockMeshDict file.
Case 2: With grading factor 0.2
Step 1:Modify blockMeshDict file:
blockMeshDict file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scale 0.1;
vertices
(
(0 0 0) //V-0
(8 0 0) //V-1
(8 0.5 0) //V-2
(0 0.5 0) //V-3
(8 1 0) //V-4
(0 1 0) //V-5
(20 1 0) //V-6
(20 0.5 0) //V-7
(20 0 0) //V-8
(20 -1 0) //V-9
(8 -1 0) //V-10
(0 0 0.1) //V-11
(8 0 0.1) //V-12
(8 0.5 0.1) //V-13
(0 0.5 0.1) //V-14
(8 1 0.1) //V-15
(0 1 0.1) //V-16
(20 1 0.1) //V-17
(20 0.5 0.1)//V-18
(20 0 0.1) //V-19
(20 -1 0.1) //V-20
(8 -1 0.1) //V-21
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (0.2 0.2 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (5 5 1)
hex (10 9 8 1 21 20 19 12) (120 10 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)
(3 2 4 5)
(10 1 8 9)
(1 2 7 8)
(2 4 6 7)
(11 12 13 14)
(14 13 15 16)
(21 20 19 12)
(12 19 18 13)
(13 18 17 15)
);
}
noslipwall
{
type wall;
faces
(
(16 15 4 5)
(11 12 1 0)
(15 17 6 4)
(21 20 9 10)
(10 21 12 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Step 2: Modify U file:
U file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
frontAndBack
{
type empty;
}
noslipwall
{
type noSlip;
}
}
// ************************************************************************* //
Step 3: modify p file:
p file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ 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;
}
noslipwall
{
type zeroGradient;
}
}
// ************************************************************************* //
Step 4: modify controlDict
controlDict file:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 3;
deltaT 1e-2;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Step 5: run blockMesh
Step 6: run checkMesh
Step 7: run icoFoam
Once the simulation is done, post processing is done.
Step 8: Post processing is done in paraview;
Mesh file with grading factor 0.2:

Velocity profile:

Pressure profile:

Comparison of velocity profiles:
using plot over line command, velocity profiles are plotted for various grading factors in mesh.
Velocity profile without grading:

velocity profile with grading factor 0.2:

Inference: as seen from the above graphs there is not much difference in the velocities by introducing a grading factor of 0.2 in mesh.