Blockmesh with different gradings
AIM:-
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.
EXPLANATION AND CODE:-
Blockmeshdict file changes:-
First of all we have to copy the \"case folder\" to the \"run\" folder in which \'blockmeshdict file\" is present (incompressible--> icoFoam --> cavity). Now we can open the blockmeshdict file and make necessary changes to the file as per our requirements. The code changes has been mentioned below.
BlockMeshDict file:-
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ M anipulation |
\\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.01;
vertices
(
(0 0 0) //point 0
(8 0 0) //point 1
(8 0.5 0) //point 2
(0 0.5 0) //point 3
(0 1 0) //point 4
(8 1 0) //point 5
(20 1 0) //point 6
(20 0.5 0) //point 7
(20 0 0) //point 8
(20 -1 0) //point 9
(8 -1 0) //point 10
(8 0 0.05) //point 11
(0 0 0.05) //point 12
(0 0.5 0.05) //point 13
(8 0.5 0.05) //point 14
(8 1 0.05) //point 15
(0 1 0.05) //point 16
(20 1 0.05) //point 17
(20 0.5 0.05) //point 18
(20 0 0.05) //point 19
(20 -1 0.05) //point 20
(8 -1 0.05) //point 21
);
blocks
(
hex (0 1 2 3 12 11 14 13) (80 5 1) simpleGrading (1 1 1)
hex (3 2 5 4 13 14 15 16) (80 5 1) simpleGrading (1 1 1)
hex (2 7 6 5 14 18 17 15) (120 5 1) simpleGrading (1 1 1)
hex (1 8 7 2 11 19 18 14) (120 5 1) simpleGrading (1 1 1)
hex (10 9 8 1 21 20 19 11) (120 5 1) simpleGrading (1 1 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
(
);
//****************************************************************************************************//
Pressure (p) boundary conditions:-
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ 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;
}
}
// ************************************************************************* //
Velocity(U) boundary conditions:-
/*--------------------------------*- C++ -*----------------------------------*\\
========= |
\\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\\\ / O peration | Website: https://openfoam.org
\\\\ / A nd | Version: 6
\\\\/ 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;
}
}
// ************************************************************************* //
Here I have taken end tme + 0.5 and deltaT = 1e-5, If you want to see mor changes in the solution you can change the values in the controlDict file below.
ControlDict:-
/*--------------------------------*- 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 1e-5;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Veocity contour plot with uniform or no grading shown beliow:-
Velocity plot:-
Now lets excute the file with different simple gradings
For SimpleGrading 0.8:-
hex (0 1 2 3 12 11 14 13) (80 5 1) simpleGrading (0.8 1.8 1)
hex (3 2 5 4 13 14 15 16) (80 5 1) simpleGrading (0.8 0.8 1)
hex (2 7 6 5 14 18 17 15) (120 5 1) simpleGrading (1.8 0.8 1)
hex (1 8 7 2 11 19 18 14) (120 5 1) simpleGrading (1.8 1.8 1)
hex (10 9 8 1 21 20 19 11) (120 5 1) simpleGrading (1.8 1.8 1)
line plot:-
For simpleGrading 0.5:-
hex (0 1 2 3 12 11 14 13) (80 5 1) simpleGrading (0.5 1.5 1)
hex (3 2 5 4 13 14 15 16) (80 5 1) simpleGrading (0.5 0.5 1)
hex (2 7 6 5 14 18 17 15) (120 5 1) simpleGrading (1.5 0.5 1)
hex (1 8 7 2 11 19 18 14) (120 5 1) simpleGrading (1.5 1.5 1)
hex (10 9 8 1 21 20 19 11) (120 5 1) simpleGrading (1.5 1.5 1)
line plot:-
For simpleGrading 0.2:-
hex (0 1 2 3 12 11 14 13) (80 5 1) simpleGrading (0.2 1.2 1)
hex (3 2 5 4 13 14 15 16) (80 5 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 5 14 18 17 15) (120 5 1) simpleGrading (1.2 0.2 1)
hex (1 8 7 2 11 19 18 14) (120 5 1) simpleGrading (1.2 1.2 1)
hex (10 9 8 1 21 20 19 11) (120 5 1) simpleGrading (1.2 1.2 1)
line plot:-
So from the line plots we can see clearly that there is no big difference in the plots even when we change the simpleGradings, but we can see that the mesh and solution is becoming finer as we reduce the simpleGrading from 1 to 0.2.
So now we can conclude that the accaracy of the results is depending on the simpleGrading mesh sizes. Uniform simple grading is not that accurate comparerd to the other simpleGradings