Challenge

Week 8 - BlockMesh Drill down challenge

1. Problem definition - In this problem we have to learn about the blockmesh and effect of mesh grading factor on velocity profile at a particular distance from the geometry and we will use a tutorial name called cavity and solve it using an icofoam solver

2. Procedure -

  • First we will copy the cavity tutorial from tutorial-incompressible-icoFoam-cavity to $FOAM_RUN with a different name and perform our simulation on this new file
  • Then we will edit the blockMeshDict file according to our geometry, number of cells, mesh grading factor and will specify our boundary for the geometry
  • Then we will specify the start time, end time and time steps in controlDict file inside system directory
  • Then we will specify the boundary condition for p and U inside the 0 directory
  • After doing all this we will run the blockMesh in command terminal
  • Then we will use icoFoam solver for running our simulation
  • Lastly we will use paraFoam to view our resuls and plots

3. Theory - In openFoam we have to convert our geometry into number of blocks and specify its vertices as the input. For our particular problem we will convert our geometry into 5 blocks

Mesh grading factor - It makes the mesh more dense or less dense at the wall depending on the value of the grading factor.

plot over line - we will calculate how our velocity or pressure is varying at particular point in the geometry with respect to time steps

Boundary layer - A layer inside which a relative motion between fluid particle exists and inside our boundary layer velocity gradient exist

Boundary layer seperation - As the fluid flows along the solid surface,the boundary layer thickness increases and at particular point ,the fluid in contact with the solid surface (no slip condition) looses contact with it and velocity gradient becomes negative and pressure gradient becomes positive so beacuse of this our fluid flows in reversed direction and we can see as eddys/vortices forming in our flow. If boundary layer sepeartion has occurred then there will be more drag friction and it will reduce the velocity of the flow

Mesh - For our particular problem we will make our mesh finer near the walls (top,bottom and sides) and also at the sudden change in area of the geometry in order to have a clear view of the results

4. Code -

  • For mesh grading of 0.2

blockMeshDict file -

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.0                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     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.001)
    (0.08 0 0.001)
    (0.08 0.005 0.001)
    (0 0.005 0.001)
    (0.08 0.01 0.001)
    (0 0.01 0.001)
    (0.2 0.01 0.001)
    (0.2 0.005 0.001)
    (0.2 0 0.001)
    (0.2 -0.01 0.001)
    (0.08 -0.01 0.001)
);

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

mergePatchPairs
(
);

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

controlDict file -

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.0                                   |
|   \\  /    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         1;

deltaT          0.0001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

boundary condition for pressure (p) -

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.0                                   |
|   \\  /    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;
    }

    outlet
    {
        type            fixedValue;
        value           uniform 0;
    }

    noslipwalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

boundary condition for velocity (U) -

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.0                                   |
|   \\  /    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);
    }

    outlet
    {
        type            zeroGradient;
    }

    noslipwalls
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

transport properties file -

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.0                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              [0 2 -1 0 0 0 0] 1e-4;


// ************************************************************************* //
  • For mesh grading 0.5

blockMeshDict file -

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.5 2 1)
    hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.5 0.5 1)
    hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (2 0.5 1)
    hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (2 2 1)
    hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (2 2 1)
);
  • For mesh grading 0.8

blockMeshDict file -

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.8 1.25 1)
    hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.8 0.8 1)
    hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1.25 0.8 1)
    hex (1 8 7 2 12 19 18 13) (120 10 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)
);

5. Results -

  • For mesh grading of 0.2 and velocity profile at 0.085m from inlet

  • For mesh grading of 0.5 and velocity profile at 0.085m from inlet

  • For mesh grading of 0.8 and velocity profile at 0.085m from inlet

6. Conclusion -

  • The velocity profile at 0.085m from inlet is almost same for all mesh grading i.e 0.2,0.5 and 0.8
  • for 0.2 grading, max velocity = 1.484 m/s
  • for 0.5 grading, max velocity =1.489 m/s
  • for 0.8 grading, max velocity = 1.490 m/s
  • As we can see when we use more finer mesh we will get more accurate results
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.