Week 8 - BlockMesh Drill down challenge
INTRODUCTION: The following simulation has been performed for three cases -grading factor 0.2,0.5&0.8.
EXPLANATION: The mesh in 2D looks somewhat like,
These are 5 blocks from which this is formed, a 3 D image would look roughly like,
Each of these block have 8 vertices , and all of them will be listed,
The vertices are listed as:
[0]=(0 0 0)
[1]=(0.08 0 0)
[2]=(0.08 0.005 0)
[3]=(0 0.005 0)
[4]=(0.08 0.01 0)
[5]=(0 0.01 0)
[6]=(0.2 0.01 0)
[7]=(0.2 0.005 0)
[8]=(0.2 0 0)
[9]=(0.2 -0.01 0)
[10]=(0.08 -0.01 0)
[11]=(0 0 0.1)
[12]=(0.08 0 0.1)
[13]=(0.08 0.005 0.1)
[14]=(0 0.005 0.1)
[15]=(0.08 0.01 0.1)
[16]=(0 0.01 0.1)
[17]=(0.2 0.01 0.1)
[18]=(0.2 0.005 0.1)
[19]=(0.2 0 0.1)
[20]=(0.2 -0.01 0.1)
[21]=(0.08 -0.01 0.1)
z-axis direction is considered as 0.1, only 1 cell is considered in that direction , because the mesh is solved as a 2D mesh.
METHOD:Step-1:Writing the blockMeshDict file,
Inlet& Outlet are of the type PATCH, Wall in the z-plane are taken as type EMPTY, all other walls are taken as FIXED WALLS. , the no. of cells along x are divided such that the 200 cells are there in the x -direction and 10 cells in the y direction in total. The grading factor is taken as 0.2 for this simulation.
At time =0, i.e at starting we taken the boundary condition of pressure inlet as ZERO GRADIENT at the inlet and at the fixed walls , and Pressure outlet as 0( i.e open to atmosphere) at the outlet patch, and for walls of type empty, pressure condition is also taken as type empty.
The velocity at inlet is taken as 1m/s( in the x -direction , or along the length), at outlet the condition id taken as zero gradient, at the walls condition of no slip is applied and for the walls of type Empty , the velocity condition is also taken as type empty.
Writing the grading factor correctly in the file is also very helpful in obtaining accurate results, the mesh near the walls can be made finer or coarser as per the change in the grading factor. Also, mesh consistency is of key importance to be maintained for the mesh.
Grading factor for all the blocks in the three directions is given as:
|
Block |
Grading factor 0.2 |
Grading factor 0.5 |
Grading factor 0.8 |
|
Block1 |
(1,5,1) |
(1,2,1) |
(1,1.25,1) |
|
Block2 |
(1,0.2,1) |
(1,0.5,1) |
(1,0.8,1) |
|
Block 3 |
(5,0.2,1) |
(2,0.5,1) |
(1.25,0.8,1) |
|
Block 4 |
(5,5,1) |
(2,2,1) |
(1.25,1.25,1) |
|
Block 5 |
(5,5,1) |
(2,2,1) |
(1.25,1.25,1) |
Explanation for grading factor :
The grading is not required in z-direction , one of the faces of block1& block 2 is the inlet and the other face is merged with other block, so grading for block 1&2 is not required in the x direction as there are no walls. For the other 2 faces of block1, lower face is the wall and and the upper face is merged with block2, the grading should be done such that the mesh at the lower wall side is finer, hence the grading required there is actually 1/0.2 instead of 0.2 to get the value of ratio of lower side of block1/upper face =0.2, hence 5 is the grading value there. Mesh consistency is required at block 1&4 for the horizontal lines( which are responsible for dy distance) and the consistency in block 3&4&5 is required for the vertical lines( which actually show the dx distance)
Step-2: After writing the blockMesh file and setting the boundary conditions in the cd 0 file for pressure and velocity, we run the blockMesh command .
Step-3: After successfully running the blockMesh command , we define the run time for simulation and the deltaT i.e the time step for the simulation in the controlDict file inside system folder.
Step-4: Now in the case file, run icoFoam command .After successfully running the icoFoam command, the paraFoam command should be run to view the results.
In the following table, I have displayed the details for grading factor of 0.2, 0.5& 0.8.
Note: The courant number(max) should be less than 1, the formula for courant no. is written as, C=dt*U/dx, where U is the modulus of velocity , dt is the time step and dx is the cells distance.
Now if the cells are graded then, the smallest cell distance is calculated using the formula of geometric series, this formula here is for grading factor less than 1.
g= 0.8…grading factor
n=5(no. of cells)
l=0.005 ( y direction length of a block here, take l along x to calculate dx)
r=g^(1/(n-1))……ratio between one cell and next
alpha= 1-(r^(-n)) + (r^(-1))
dy=(l*(r-1))/(alpha*r-1)…cell distance
This is also calculated for cell distance in the x direction, and whichever is smaller, dx or dy that is taken in the courant number formula to find dt for the worst condition.
By putting the value of dx calculated in the formula of courant number we can calculate delta T which gives a stable solution, assume a safe courant number while doing the calculation for dt. This dt we put in the controlDict file.
The table given below shows the calculated dx according to the assumed Courant number value and the calculated dt according to that. The results are approximately same as we get on simulation , ie the value of courant number max obtained on choosing a particular dt and the grading factor is nearly the same as calculated .
|
G(grading factor) |
0.8 |
0.5 |
0.2 |
|
dx(least) (calculated) |
0.000892 |
0.000686 |
0.000382 |
|
dt(calc.) |
0.0001 |
0.0001 |
0.0001 |
|
Co(assumed) |
0.177 |
0.2189 |
0.36 |
|
U(in m/s) |
1 |
1 |
1 |
|
Co(max)(obtained) |
0.177267 |
0.2189 |
0.360364 |
|
execution time after icoFoam |
1.5 |
1.48 |
1.52 |
|
Clocktime |
3 |
3 |
3 |
|
run time in paraFoam |
0.01 |
0.01 |
0.01 |
|
L(in m) |
0.005 |
0.005 |
0.005 |
For the simulation using grading factor 0.2,
1)BlockMeshDict 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0.08 0 0)
(0.08 0.005 0)
(0 0.005 0)
(0.08 0.01 0)
(0 0.01 0)
(0.2 0.01 0)
(0.2 0.005 0)
(0.2 0 0)
(0.2 -0.01 0)
(0.08 -0.01 0)
(0 0 0.1)
(0.08 0 0.1)
(0.08 0.005 0.1)
(0 0.005 0.1)
(0.08 0.01 0.1)
(0 0.01 0.1)
(0.2 0.01 0.1)
(0.2 0.005 0.1)
(0.2 0 0.1)
(0.2 -0.01 0.1)
(0.08 -0.01 0.1)
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (1 5 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 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
(
(14 3 0 11)
(5 3 14 16)
);
}
outlet
{
type patch;
faces
(
(6 17 18 7)
(7 18 19 8)
(8 19 20 9)
);
}
fixedwall
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(1 10 21 12)
);
}
frontAndBack
{
type empty;
faces
(
(13 14 11 12)
(15 16 14 13)
(17 15 13 18)
(18 13 12 19)
(19 12 21 20)
(2 1 0 3)
(4 2 3 5)
(6 7 2 4)
(7 8 1 2)
(8 9 10 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
2)Pressure file at time step 0:
/*--------------------------------*- 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;
}
fixedwall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
3) Velocity at time step 0:
/*--------------------------------*- 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;
}
fixedwall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
For the simulation using grading factor 0.5,
1)BlockMeshDict 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0.08 0 0)
(0.08 0.005 0)
(0 0.005 0)
(0.08 0.01 0)
(0 0.01 0)
(0.2 0.01 0)
(0.2 0.005 0)
(0.2 0 0)
(0.2 -0.01 0)
(0.08 -0.01 0)
(0 0 0.1)
(0.08 0 0.1)
(0.08 0.005 0.1)
(0 0.005 0.1)
(0.08 0.01 0.1)
(0 0.01 0.1)
(0.2 0.01 0.1)
(0.2 0.005 0.1)
(0.2 0 0.1)
(0.2 -0.01 0.1)
(0.08 -0.01 0.1)
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (1 2 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 0.5 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (2 0.5 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (2 2 1)
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (2 2 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(14 3 0 11)
(5 3 14 16)
);
}
outlet
{
type patch;
faces
(
(6 17 18 7)
(7 18 19 8)
(8 19 20 9)
);
}
fixedwall
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(1 10 21 12)
);
}
frontAndBack
{
type empty;
faces
(
(13 14 11 12)
(15 16 14 13)
(17 15 13 18)
(18 13 12 19)
(19 12 21 20)
(2 1 0 3)
(4 2 3 5)
(6 7 2 4)
(7 8 1 2)
(8 9 10 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
2) Pressure at time step 0:
/*--------------------------------*- 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;
}
fixedwall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
3) Velocity at timestep 0:
/*--------------------------------*- 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;
}
fixedwall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
For the simulation using grading factor 0.8,
1)BlockMesh Dict 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 dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(0 0 0)
(0.08 0 0)
(0.08 0.005 0)
(0 0.005 0)
(0.08 0.01 0)
(0 0.01 0)
(0.2 0.01 0)
(0.2 0.005 0)
(0.2 0 0)
(0.2 -0.01 0)
(0.08 -0.01 0)
(0 0 0.1)
(0.08 0 0.1)
(0.08 0.005 0.1)
(0 0.005 0.1)
(0.08 0.01 0.1)
(0 0.01 0.1)
(0.2 0.01 0.1)
(0.2 0.005 0.1)
(0.2 0 0.1)
(0.2 -0.01 0.1)
(0.08 -0.01 0.1)
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 5 1) simpleGrading (1 1.25 1)
hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 0.8 1)
hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1.25 0.8 1)
hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1.25 1.25 1)
hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1.25 1.25 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(14 3 0 11)
(5 3 14 16)
);
}
outlet
{
type patch;
faces
(
(6 17 18 7)
(7 18 19 8)
(8 19 20 9)
);
}
fixedwall
{
type wall;
faces
(
(4 5 16 15)
(6 4 15 17)
(0 1 12 11)
(10 9 20 21)
(1 10 21 12)
);
}
frontAndBack
{
type empty;
faces
(
(13 14 11 12)
(15 16 14 13)
(17 15 13 18)
(18 13 12 19)
(19 12 21 20)
(2 1 0 3)
(4 2 3 5)
(6 7 2 4)
(7 8 1 2)
(8 9 10 1)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
2)Pressure at time step 0:
/*--------------------------------*- 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;
}
fixedwall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
3) Velocity at time step 0:
/*--------------------------------*- 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;
}
fixedwall
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Note : The pressure and velocity file at time step 0 is same for all the three grading factors, just the change is in the blockMesh files.
Vakue of dt is entered in the controlDict file and then icoFoam is run.
PLOT OVER LINE
Plot over line command is used to plot the curve for velocity variation .
Here we draw a line at x=0.085m and parallel to y axis, ie from -0.01 to +0.01, the z plane can be chosen as anything as it does not matter. Also we see the variation along y axis. The graph for velocity magnitude variation with y axis is shown for all the grading factors.
OBSERVATION: 1. Velocity vs Length at grading factor 0.2 at x=0.085m
2. Velocity Vs Length at grading factor 0.5 at x=0.085m
3. Velocity vs Length at grading factor 0.8 at x=0.085m
On a closer view,the mesh looks like,
Also the values of velocity magnitude max at different grading factors is shown as,
The velocity is maximum at y value of 0.00406, (this is somewhere in the 4th block ie middle of 3rd, 4th &5th block)
0.2- 1.076028 m/s
0.5-1.037318m/s
0.8-1.018488m/s
These are the max velocity magnitude written , the excel sheets are exported from parafoam, in which all the velocity magnitude value are written along with arc length.
Velocity magnitude is square root of the sum of the squares of these velocity components, i.e
√(Vx^2+Vy^2+Vz^2)
For the three grading factors , a compilated excel file(attached below with the title 'FINAL_GRADING_SHEET') is created and through octave this data is then read and plotted , where we can easily compare all the three plots at once.
The code for octave is written below,
clear all
close all
clc
A=csvread('FINAL_GRADING_SHEET.csv')
y=A(:,1);
U_2=A(:,2);
U_5=A(:,3);
U_8=A(:,4);
plot(y,U_2,"color","red");
hold on
plot(y,U_5,"color","blue");
hold on
plot(y,U_8,"color","magenta");
legend("red-0.2,blue-0.5,magenta-0.8");
set(gca,"xlabel",text("string","length","fontsize",25));
set(gca,"ylabel",text("string","velocity","fontsize",25));
The plot for comparison of the three plots looks( near the step region, at 0.085m) like,
CONCLUSION: The velocity grows from the walls to the middle of the geometry, the walls resist the flow and so due to shear stress viscous forces are generated. At the walls the velocity is zero i.e the no slip condition. The velocity is maximum at the middle of geometry which is somewhere near the 4 th block if we see for the area near step region.i.e the velocity decreases on both sides of the peak value. This confirms that the plot obtained is correct . The mesh gets finer as the grading factor reduces i.e the 0.2 grading factor has the finest mesh , so the velocity is the most accurate for the simulation when grading factor is 0.2, out of all the three plots although there is not much difference in these three grading factors.