Project

BlockMesh Drill down challenge

Objectives:

  • To Generate the BlockMesh file for the given Geometry using OpenFOAM and use the icoFoam solver to simulate the flow through a backward-facing step.
  • To create multiple meshes and will be comparing the results obtained from each mesh.
  • To show the velocity magnitude profile change as a function of mesh grading factor. Use factors, 0.2, 0.5, 0.8
  • To Measure the velocity profile at 0.085 m from the inlet of the geometry
  • To Plot a line plot
  • To Compare velocity magnitude contours near the step region for the above mentioned grading factors.

Given Data:

Mesh specification

  1. Number of cells along the x direction (longer dimension) = 200
  2. Number of cells along the y direction = 10
  3. Use a graded mesh. Grading factor near all walls should be 0.2

Geometry and Boundary condition specification

Follow the specifications that are provided in the following figure.

Theory:

A Backward-facing step is to be generated using openFoam which is solved by using icoFoam solver which is a transient solver for incompressible, laminar flow of Newtonian fluids.

Assumptions:

  1. end time = 0.01
  2. time step, deltaT = 1e-5
  3. inlet velocity =2 m/s

Procedure:

  • To create the above geometry, First create a copy of cavity case from tutorials/incompressible/icoFoam/cavity to run directory.
  • After copying the case, edit the blockMeshDict file located in the system folder and make the necessary changes in the file to generate the required geometry.

BlockMeshDict file for Geometry with grading as 0.2

/*--------------------------------*- 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.01;

vertices
(
    (0 0 0) // v0
    (8 0 0) // v1
    (8 0.5 0) // v2
    (0 0.5 0) // v3
    (8 1 0) // v4
    (0 1 0) // v5
    (20 1 0) // v6
    (20 0.5 0) // v7
    (20 0 0) // v8
    (20 -1 0) // v9
    (8 -1 0) // v10
    (0 0 0.1) // v11
    (8 0 0.1) // v12
    (8 0.5 0.1) // v13
    (0 0.5 0.1) // v14
    (8 1 0.1) // v15
    (0 1 0.1) // v16
    (20 1 0.1) // v17
    (20 0.5 0.1) // v18
    (20 0 0.1) // v19
    (20 -1 0.1) // v20
    (8 -1 0.1) // v21   
);

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

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (3 5 4 2)
            (10 1 8 9)
            (1 2 7 8)
            (2 4 6 7)
            (11 12 13 14)
            (14 13 15 16)
            (21 20 19 12)
            (12 19 18 13)
            (13 18 17 15)
        );
    }
    noslipwalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (4 15 17 6)
            (10 21 12 1)
            (0 1 12 11)
            (10 9 20 21)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
  • After Editing the blockMeshDict file, within the same system directory, there is another file controlDict. Edit this file by setting up the end time and time step, deltaT.

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.01;

deltaT          1e-5;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //
  • Now set the initial condition for pressure and velocity. For this go to \'\'0\'\' folder located in the cavity folder. In this folder there are two files one file is pressure file, \'p\' and other file is velocity, \'U\'.
  • Edit the pressure file, \'p\' and set the pressure for internal fields, boundary walls, inlet and outlet.

Pressure 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }   
    outlet
    {
        type            fixedValue;
        value           uniform 0;
    }
    frontAndBack
    {
        type            empty;
    }
    noslipwalls
    {
        type            zeroGradient;
    }
}

// ************************************************************************* //
  • Now, edit the velocity file, \'U\' and set the velocity at inlet, at outlet, for internal fields and at boundary walls.
/*--------------------------------*- 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 (2 0 0);
    } 
  
    outlet
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }

    noslipwalls
    {
        type            noSlip; 
    }
}

// ************************************************************************* //
  • Now the case is fully set up.
  • Now generate the mesh file. To do that type \'blockMesh\' in the command terminal and execute it.
  • After mesh generation run the \'icoFoam\' solver in the terminal.
  • After running the solver the data is to be post processed. For this the paraFoam command is used in the command terminal and execute it
  • In the post processing, the required data like simulation image, mesh and line plot are to be saved.
  • Repeat the above steps for remaining two grading factors 0.5 and 0.8. compare the velocity at x = 0.085 m for these three different grading factors.

Results:

1. For mesh grading factor of 0.2

Geometry of Block Mesh with Mesh:

velocity pattern along the length of the domain

Pressure pattern along the length of the domain

velocity profile at x = 0.085m from the inlet

2. For mesh grading factor of 0.5

BlockMeshDict file for Geometry with grading as 0.5

/*--------------------------------*- 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.01;

vertices
(
    (0 0 0) // v0
    (8 0 0) // v1
    (8 0.5 0) // v2
    (0 0.5 0) // v3
    (8 1 0) // v4
    (0 1 0) // v5
    (20 1 0) // v6
    (20 0.5 0) // v7
    (20 0 0) // v8
    (20 -1 0) // v9
    (8 -1 0) // v10
    (0 0 0.1) // v11
    (8 0 0.1) // v12
    (8 0.5 0.1) // v13
    (0 0.5 0.1) // v14
    (8 1 0.1) // v15
    (0 1 0.1) // v16
    (20 1 0.1) // v17
    (20 0.5 0.1) // v18
    (20 0 0.1) // v19
    (20 -1 0.1) // v20
    (8 -1 0.1) // v21   
);

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

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (3 5 4 2)
            (10 1 8 9)
            (1 2 7 8)
            (2 4 6 7)
            (11 12 13 14)
            (14 13 15 16)
            (21 20 19 12)
            (12 19 18 13)
            (13 18 17 15)
        );
    }
    noslipwalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (4 15 17 6)
            (10 21 12 1)
            (0 1 12 11)
            (10 9 20 21)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
  • The control Dict file, the initial conditions of pressure and velocity remains same but the BlockMeshDict is to be altered only at the blocks with a grading factor as 0.5 as shown above.

Geometry of Block Mesh with Mesh:

velocity pattern along the length of the domain

pressure pattern along the length of the domain

velocity profile at x = 0.085m from the inlet

3. For mesh grading factor of 0.8

BlockMeshDict file for Geometry with grading as 0.8

/*--------------------------------*- 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.01;

vertices
(
    (0 0 0) // v0
    (8 0 0) // v1
    (8 0.5 0) // v2
    (0 0.5 0) // v3
    (8 1 0) // v4
    (0 1 0) // v5
    (20 1 0) // v6
    (20 0.5 0) // v7
    (20 0 0) // v8
    (20 -1 0) // v9
    (8 -1 0) // v10
    (0 0 0.1) // v11
    (8 0 0.1) // v12
    (8 0.5 0.1) // v13
    (0 0.5 0.1) // v14
    (8 1 0.1) // v15
    (0 1 0.1) // v16
    (20 1 0.1) // v17
    (20 0.5 0.1) // v18
    (20 0 0.1) // v19
    (20 -1 0.1) // v20
    (8 -1 0.1) // v21   
);

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

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 2 1)
            (3 5 4 2)
            (10 1 8 9)
            (1 2 7 8)
            (2 4 6 7)
            (11 12 13 14)
            (14 13 15 16)
            (21 20 19 12)
            (12 19 18 13)
            (13 18 17 15)
        );
    }
    noslipwalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (4 15 17 6)
            (10 21 12 1)
            (0 1 12 11)
            (10 9 20 21)
        );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
  • In this case also the control Dict file, the initial conditions of pressure and velocity remains same but the BlockMeshDict is to be altered only at the blocks with a grading factor as 0.8 as shown above.

Geometry of Block Mesh with Mesh:

velocity pattern along the length of the domain

pressure pattern along the length of the domain

velocity profile at x = 0.085m from the inlet

Conclusion:

  • Fine Mesh with grading factor 0.8 results clear simulation at the walls as compared with other grading factors
  • The velocity profile looks similar for 0.2, 0.5 and 0.8 grading factors, there is no predominant variation in the velocity profiles, but finer mesh gives a small variation.
  • The velocity profile in each case at x = 0.085 m from inlet along the length of the domain in Y-axis(i.e., -0.01 to 0.01 m) shows maximum velocity as 2.2 m/s at 0.014 m.
  • The profile starts and ends with a velocity as 0 m/s, it is clear from the simulation that we have defined no slip condition and no slip walls.
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.