Study of icoFOAM solver to simulate the flow through a backward-facing step
Objective:
Study of icoFOAM solver to simulate the flow through a backward-facing step. You shall create different meshes and compare the results obtained from them.
Specification
- The number of cells along the direction of flow = 200
- The number of cells along the y-direction for each block = 10
- Inlet Velocity is 1 m/sec.
Boundary condition specification
Follow the specifications that are provided in the following figure.
Desired output
- Run the first simulation without grading factor.
- Run the second simulation with the mesh grading factors of 0.2, 0.5 & 0.8. Compare the effect of grading factor with necessary contours & plots.
- Measure the velocity profile at 0.085 m from the inlet of the geometry with a line plot.
- Compare velocity magnitude contours near the step region for the above-mentioned grading factors.
Solution:
1) here, first of all, we have to open a new terminal by \'alt\'+\'ctr\'+\'T\' inside Linux ubuntu virtual machine and run OpenFOAM -an open-source CFD package.
2)Then we have to create a new folder \'RUN\' using Linux command and then copy the desired \'icoFoam\' solver tutorial \'cavity\' from the tutorials folder to that created folder. It is the place, where we are supposed to run CFD simulation.
3) After that, we have to go to the \'system\' folder inside that tutorial and edit the \'blockMeshDict\' file to make desired changes in geometry and also we have to edit the \'controlDict\' file to give perfect time step based on CFL number. in this case, deltaT=1e-5 for the first two grading factors and 1e-6 for later 0.2.
4) we have to give initial-boundary conditions by editing the \'0\' folder and then create a mesh by \'BlockMesh\' command and then solve it by using \'icoFoam\' command in terminal.
5) then visualize the results in ParaView by running the \'paraFoam\' command.
6) here is the blockMeshDict file as following to create desired backward-facing step geometry as it allows the flow to undergo a change at step.
/*--------------------------------*- 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) //point 0
(8 0 0)
(8 0.5 0)
(0 0.5 0)
(0 1 0)
(8 1 0)
(20 1 0)
(20 0.5 0)
(20 0 0) //point 8
(20 -1 0)
(8 -1 0)
(8 0 0.05)
(0 0 0.05)
(0 0.5 0.05)
(8 0.5 0.05)
(8 1 0.05)
(0 1 0.05) //point 16
(20 1 0.05)
(20 0.5 0.05)
(20 0 0.05)
(20 -1 0.05)
(8 -1 0.05)
);
blocks
(
hex (0 1 2 3 12 11 14 13) (200 10 1) simpleGrading (0.2 1.2 1)
hex (3 2 5 4 13 14 15 16) (200 10 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 5 14 18 17 15) (200 10 1) simpleGrading (1.2 0.2 1)
hex (1 8 7 2 11 19 18 14) (200 10 1) simpleGrading (1.2 1.2 1)
hex (10 9 8 1 21 20 19 11) (200 10 1) simpleGrading (1.2 1.2 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(12 0 3 13)
(13 3 4 16)
);
}
outlet
{
type patch;
faces
(
(17 18 7 6)
(18 19 8 7)
(19 20 9 8)
);
}
front
{
type empty;
faces
(
(12 11 14 13)
(13 14 15 16)
(14 18 17 15)
(11 19 18 14)
(21 20 19 11)
);
}
back
{
type empty;
faces
(
(0 1 2 3)
(3 2 5 4)
(2 7 6 5)
(1 8 7 2)
(10 9 8 1)
);
}
topandbottom
{
type wall;
faces
(
(12 11 1 0)
(1 10 21 11)
(21 20 9 10)
(4 5 15 16)
(5 6 17 15)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
7)Then also we have to make changes to \'controlDict\' file as deltaT=1e-5
here is ControlDict file as follows
/*--------------------------------*- 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.5;
deltaT 10e-6;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Here we have to make changes P and U file inside \'0\' folder as follows
for Pressure p, BC
/*--------------------------------*- 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;
}
front
{
type empty;
}
back
{
type empty;
}
topandbottom
{
type zeroGradient;
}
}
// ************************************************************************* //
for velocity U, BC
/*--------------------------------*- 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.5 0 0);
}
outlet
{
type zeroGradient;
}
front
{
type empty;
}
back
{
type empty;
}
topandbottom
{
type noSlip;
}
}
// ************************************************************************* //
8)here results for simulation with grading factor =size of end cell/size of start cell,
here we can access flow contour by showing flow fields and taking a snap of it as well to capture velocity profile we have to use \'plot over line\' command and then select that point as (0.085,0,0) with U as property to be recorded.
i) For no grading
flow contour
velocity profile at 0.085
ii) For grading 0.2
flow contour
velocity profile at 0.085
iii)For grading 0.5
flow contour
velocity profile at 0.085
iv) For grading 0.8
flow contour
velocity profile at 0.085
Conclusion:
1) from grading, we can say that with grading factor 1 to 0.2 we can refine mesh at the required spot to get fine-tuned results at that point.
2) Here it is observed that 0.2 gives a better result than 0.5 and 0.8 grading factor as the mesh is more refined at step.
3) here velocity shows rough transition for 1 and 0.8 as compare to 0.5 and 0.2.
4)contours are well defined for 0.2 than that of rest grading factor.