Week 8 - BlockMesh Drill down challenge
Mesh specification
- Number of cells along the x direction (longer dimension) = 200
- Number of cells along the y direction = 10
- Use a graded mesh. Grading factor near all walls should be 0.
First the geometry has to be created. So the apprapriate solver is choosed and geotmetry is created in the blockMeshDict c program file found in its system file. I selected icoFoam-cavity in tutorial.so the icofoam folder is copied to run folder in the openfoam directory. then the blockMeshDict file in system file is editedto required Geometry.
Program for geometry:
/*--------------------------------*- 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.1;
vertices
(
(0 0 0) //0
(0.8 0 0)//1
(0.8 0.1 0)//2
(0 0.1 0)//3
(2 0.1 0)//4
(2 0 0)//5
(2 -0.1 0)//6
(0.8 -0.1 0)//7
(0 0 0.01)//8
(0.8 0 0.01)//9
(0.8 0.1 0.01)//10
(0 0.1 0.01)//11
(2 0.1 0.01)//12
(2 0 0.01)//13
(2 -0.1 0.01) //14
(0.8 -0.1 0.01)//15
);
blocks
(
hex (0 1 2 3 8 9 10 11) (80 10 1) simpleGrading (0.2 0.2 1)
hex (1 5 4 2 9 13 12 10) (120 10 1) simpleGrading (0.2 0.2 1)
hex (7 6 5 1 15 14 13 9) (120 10 1) simpleGrading (0.2 0.2 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 8 11 3)
);
}
outlet
{
type patch;
faces
(
(6 5 13 14)
(5 4 12 13)
);
}
topWalls
{
type wall;
faces
(
(11 10 2 3)
(10 12 4 2)
);
}
botWalls
{
type wall;
faces
(
(0 1 9 8)
(7 6 14 15)
);
}
sideWalls
{
type wall;
faces
(
(1 7 9 15)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(1 2 4 5)
(7 1 5 6)
(8 9 10 11)
(9 13 12 10)
(15 14 13 9)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
In the above geometry program, mesh grading factor is 0.2. For different mesh grading factor the value in block - hex - simple grading is changed. once the Geometry is done, the initial and boundary condition for velocity and pressure is implied by editing the c program in u and p files in constant. The inlet velocity is assumed to be 1m/s.
program for timestep:
/*--------------------------------*- 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 0.0001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
edited velocity program:
/*--------------------------------*- 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;
}
topWalls
{
type noSlip;
}
botWalls
{
type noSlip;
}
sideWalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
edited pressure program:
/*--------------------------------*- 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;
}
topWalls
{
type zeroGradient;
}
botWalls
{
type zeroGradient;
}
sideWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Result:
for mesh Grading factor 0.2:
velocity:
pressure:
velocity graph:
for mesh Grading factor 0.5:
velocity:
pressure:
velocity graph:
for mesh Grading factor 0.8:
velocity:
pressure:
velocity graph:
Thus, the velocity profile at 0.085m is 0.8 m/s. the result from different mesh grading are same. the only difference is the execution time and finess of result. The execution time for mesh grading 0.2,0.5 and 0.8 are 21.64, 20.41 and 19.74 seconds respectively. so the finner the mesh the better the result accuracy and time taken.