Challenge

Week 8 - BlockMesh Drill down challenge

Problem Definition:

1. To create a geometry given below by providing respective boundary names and conditions

2. Mesh

Along x- axis 200
Along y-axis 10

3. Observe the variation of velocity magnitude profile with change in grading factors 0.2, 0.5, 0.8. Measure the velocity profile at x = 0.085 m and represent using a line plot.

4. Contour plots of velocity and pressure.

Procedure:

a. Vertices of the geometry:

point Coordinates Point Coordinates
0 (0 0 0) 11 (0 0 1)
1 (80 0 0) 12 (80 0 1)
2 (80 5 0) 13 (80 5 1)
3 (0 5 0) 14 (0 5 1)
4 (80 10 0) 15 (80 10 1)
5 (0 10 0) 16 (0 10 1)
6 (200 10 0) 17 (200 10 1)
7 (200 5 0) 18 (200 5 1)
8 (200 0 0) 19 (200 0 1)
9 (200 -5 0) 20 (200 -5 1)
10 (80 -5 0) 21 (80 -5 1)

The above tabular column contains coordinates for all the points starting from 0 to 21. Convert into meters by multiplying with 0.001.

b. Blocks:

The entire geometry is divided into 5 blocks each containing 8 vertices.

Block number Vertices
1 0, 1, 2, 3, 11, 12, 13, 14
2 3, 2, 4, 5, 14, 13, 15, 16
3 2, 7, 6, 4, 13, 18, 17, 15
4 1, 8, 7, 2, 12, 19, 18, 13
5 10, 9, 8, 1, 21, 20, 19, 12

c. Meshing:

For the length of 80 mm '80' grid points are taken and for the length of 120 mm '120' grid points are taken along xaxis for all the blocks

Along y axis for each block ten grid points are taken.

Along z axis only one grid is taken because the problem being solved is 2D.

d. Mesh grading:

Mesh grading depends on grading factor(f) = `("end grid size")/("start grid size")`

if mesh grid size is less than 1 then end grid is smaller compared to starting grid, by using this concept fine mesh can be obtained at the walls.

e. boundary names:

Boundary name Faces
inlet (14 3 0 11)
(16 5 3 14)
outlet (9 8 19 20)
(8 7 18 19)
(7 6 17 18)
Noslipwall (15 4 5 16)
(17 6 4 15)
(12 1 10 21)
(0 1 12 11)
(10 9 20 21)
frontAndBack (2 1 0 3)
(4 2 3 5)
(8 9 10 1)
(7 8 1 2)
(6 7 2 4)
(12 13 14 11)
(13 15 16 14)
(20 19 12 21)
(19 18 13 12)
(18 17 15 13)

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 0.001;

vertices
(
    (0 0 0)
    (80 0 0)
    (80 5 0)
    (0 5 0)
    (80 10 0)
    (0 10 0)
    (200 10 0)
    (200 5 0)
    (200 0 0)
    (200 -5 0)
    (80 -5 0)
    (0 0 1)
    (80 0 1)
    (80 5 1)
    (0 5 1)
    (80 10 1)
    (0 10 1)
    (200 10 1)
    (200 5 1)
    (200 0 1)
    (200 -5 1)
    (80 -5 1)
);

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.2 5 1)
    hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.2 0.2 1)
    hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (5 0.2 1)
    hex (1 8 7 2 12 19 18 13) (120 10 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)
            (16 5 3 14) 
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18) 
        );
    }
    Noslipwall
    {
        type wall;
        faces
        (
            (15 4 5 16)
            (17 6 4 15)
            (12 1 10 21)
            (0 1 12 11)
            (10 9 20 21)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (2 1 0 3)
            (4 2 3 5)           
            (8 9 10 1)
            (7 8 1 2)
            (6 7 2 4)
            (12 13 14 11)
            (13 15 16 14)
            (20 19 12 21)
            (19 18 13 12)
            (18 17 15 13)  
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //

In the blockMeshDict file all the information regarding mesh and geometry is present, here grading factors can be changed and also number of grid points can be changed as per requirement.

ControlDict 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;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.3;

deltaT          0.0002;

writeControl    timeStep;

writeInterval   200;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //

In controlDict file start time, end time, time step(deltaT) and others can be changed for a given problem to maintain the courant number < 1.

Courant number plays very important role while running icoFoam for maintaining accuracy and stability courant number must be less then 1

Courant number `C_0 = (deltat|U|)/(deltax)`

Therefore courant number depends on time step, velocity, grid size and by varying these one can maintain courant number less than 1.

initial conditions are not varied to observe changes by varing grading factor and comparing with results of no mesh grading.

f. Initial and boundary conditions for velocity and pressure

For velocity:-

/*--------------------------------*- 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;
    }
    Noslipwall
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

// ************************************************************************* //

For Kinematic Pressure:-

/*--------------------------------*- 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;
    }
    Noslipwall
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

// ************************************************************************* //

Results:

I. For simple grading (1 1 1)

Variable Value set to
Thermal diffusivity 0.001
time step(deltaT) 3e-4
t start 0
t end 0.3
U_initial 1 m/s

Here the maximum value of CFL for last time step is found to be 0.544112

1. Mesh obtained:

In the above mesh no mesh grading is done.

2. Plot over line showing variation of velocity magnitude wrt width at x = 0.085 m for no mesh grading.

Here the variation of velocity profile is calculated from bottom to top. ie . point 1 at the bottom (0.085, -0.01, 0) and point 2 is at the top (0.085, 0.01, 0)

3. Contour plots of velocity and pressure for no mesh grading.

Here as expected velocity at the centre is maximum and decrease to zero at the walls because of no slip condition.

Here pressure at the inlet is high and as the fluid flows though the pipe pressure gradually decreases and finally reaches to atmospheric pressure (zero gauge pressure) at the outlet.

II. For grading factor f = 0.2

Here grading factor is introduced to create a finer mesh at the walls and code in the blockMeshDict file is varied respctively.

Variable Value set to
Thermal diffusivity 0.001
time step(deltaT) 2e-4
t start 0
t end 0.3
U_initial 1 m/s

Here maximum CFL for the final time step is found to be 0.755528.

1. Mesh:

Here it can be clearly seen to be refined at the walls, so one can observe changes in results due to mesh grading.

2. Plot over line showing variation of velocity magnitude wrt width at x = 0.085 m for grading factor = 0.2.

Here one can observe the variation of results compared to no mesh grading (I.2) here clear results are obtained between 0.005 to 0.008 but when no mesh grading is done there was increase in peak value and graph started to parabolically increase after width = 0.008, because of lack of mesh refinement.

3. Contour plots of velocity magnitude and Kinematic pressure for mesh grading factor = 0.2

Vector plot:

From the vector plot it can be seen that there is changes in the direction of velocity at the backward facing step. so, in the graph one can observe small velocity magnitude at the bottom.

III. For mesh grading factor = 0.5

Variable Value set to
Thermal diffusivity 0.001
time step(deltaT) 2e-4
t start 0
t end 0.3
U_initial 1 m/s

Here the maximum value of CFL for the last time step is found to be 0.4645

1. Mesh

One can observe that by increasing the mesh grading factor from 0.2 to 0.5 there is decrease in mesh refinement at the walls.

2. Plot over line showing variation of velocity magnitude wrt width at x = 0.085 m for grading factor = 0.5:

3. Contour plots of velocity and kinematic pressure for mesh grading factor = 0.5:

IV. For mesh grading factor = 0.8

Variable Value set to
Thermal diffusivity 0.001
time step(deltaT) 2e-4
t start 0
t end 0.3
U_initial 1 m/s

Here the maximum value of CFL for the last time step is found to be 0.388754

1. Mesh:

2. Plot over line on Variation of velocity magnitude wrt width for mesh grading factor = 0.8

3. contour plot of velocity magnitude and kinematic pressure for mesh grading factor = 0.8

Conclusion:

From the above result we can conclude that for mesh grading factor = 0.2 one can obtain good results as there is sudden decrease in velocity near the walls and tending to zero at the walls due to no slip condition. so, by mesh refinement at the walls correct plots can be obtained and results will be realistic.

when the plot over line graphs are compared it can be seen that with increase in mesh grading from 0.2 to 1 it is difficult to capture the values at the bottom wall because of lack of refinement.

Also by varying mesh grading factor from 0.2 to 1 slight changes in contour plots can be observed especially in velocity contour plot at the walls.

Mesh grading factor of 0.2 is recommended for this case is recommended but needed to be carefully chosen to get realistic results because by using mesh grading factor end grid size is reduced and also start grid size is increased.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.