Week 8 - BlockMesh Drill down challenge
Block Mesh drill down challenge:
OpenFOAM contains mainly three folders where all the required data is present. They are:
0- It has initial values.
constant- It has all the parameters that are constant across the solution.
system - It has the details about the time, solvers and schemes.
Given geometry:
Fluid enters the stepped pipe at a velocity of 0.1 m/s. Transient analysis is performed on this pipe to study the variation of pressure and velocity with time.
This geometry is generated using OpenFoam. Five blocks are created and meshed as per the requirement. Geometry is divided into blocks as shown in the figure below.
Geometry and mesh are constant across the solution. They are created by coding in the file called blockMeshdict file. The code for this problem is below:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.1;
vertices
(
(0 0 0) //ver 0
(0.8 0 0) //1
(0.8 0.05 0) //2
(0 0.05 0) //3
(0.8 0.1 0) //4 2
(0 0.1 0) //5 3
(2 0.1 0) //6 4
(2 0.05 0) //7
(2 0 0) //8 5
(2 -0.1 0) //9 6
(0.8 -0.1 0) //10 7
(0 0 0.1) //11 8
(0.8 0 0.1) //12 9
(0.8 0.05 0.1) //13
(0 0.05 0.1) //14
(0.8 0.1 0.1) //15 10
(0 0.1 0.1) //16 11
(2 0.1 0.1) //17 12
(2 0.05 0.1) //18
(2 0 0.1) //19 13
(2 -0.1 0.1) //20 14
(0.8 -0.1 0.1) //21 15
);
blocks
(
hex (0 1 2 3 11 12 13 14) (100 10 1) simpleGrading (0.2 2 1)
hex (3 2 4 5 14 13 15 16) (100 10 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15) (100 10 1) simpleGrading (6 0.2 1)
hex (1 8 7 2 12 19 18 13) (100 10 1) simpleGrading (6 2 1)
hex (10 9 8 1 21 20 19 12) (100 10 1) simpleGrading (6 2 1)
);
edges
(
);
boundary
(
inlet
{
type patch;
faces
(
(0 11 14 3)
(3 14 16 5)
);
}
fixedWalls
{
type wall;
faces
(
(16 15 4 5)
(15 17 6 4)
(10 21 12 1)
(0 1 12 11)
(10 9 20 21)
);
}
frontAndBack
{
type empty;
faces
(
(1 0 3 2)
(2 3 5 4)
(7 2 4 6)
(8 1 2 7)
(9 10 1 8)
(12 11 14 13)
(13 14 16 15)
(18 13 15 17)
(19 12 13 18)
(20 21 12 19)
);
}
outlet
{
type patch;
faces
(
(18 7 6 17)
(19 8 7 18)
(20 9 8 19)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
Mesh 0.2 grading:
Boundary conditions:
Pressure:
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ 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;
//value uniform 0;
}
fixedWalls
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
outlet
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //
Velocity:Inlet velocity is 1 m/s. No slip condition is imposed on the fixed walls.
As I am using a older version of OpenFOAM, no slip condition has been represented using a keyword 'fixedValue',uniform (0 0 0). (There is no keyword 'noslip' in the older versions)
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ 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);
}
fixedWalls
{
type fixedValue;
value uniform (0 0 0);
}
frontAndBack
{
type empty;
}
outlet
{
type zeroGradient;
//value uniform (0 0 0);
}
}
// ************************************************************************* //
Solution time is represented in the controlDict file. Run time is given as 0.2s.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.2;
deltaT 0.0001;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
Output:
The velocity contour is as shown in the figure below:
Velocity of the fluid decreases as the diameter increases. When the fluid passes through the step, it diverges. This can be visualised using the streamlines.
Change in velocity in y direction with respect to distance is as follows:
Change in velocity in x-direction:
Execution time =18.91s
Clock time=19s.
Grading is changed for the values of 0.5 and 0.8
The values are similar but the execution time varies.
Grading 0.5:
Execution time:171.17s
Clock time:174s
Velocity contour:
Grading 0.8:
Execution time:172.68
Clock time:188s
Velocity contour: