Project

BlockMesh Drill down challenge in OpenFoam

Aim:

To simulate the flow through a backward facing step using the icoFOAM solver.Create multiple meshes and compare the results obtained from each mesh.

Objective:

  • How does the velocity magnitude profile change as a function of mesh grading factor. Use factors, 0.2, 0.5,0.8
  • Measure the velocity profile at 0.085 m from the inlet of the geometry
  • Plot must be a line plot
  • Compare velocity magnitude contours near the step region for the above mentioned grading factors.

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.2

Problem Statement:

Geometry:

Back side:

Front side:

inlet & outlet:

Theory:

Grading Factor:

  • It is ratio of size of end cell to size of starting cell.
  • Specifies the maximum ratio of adjacent mesh edges for transitioning between coarse and fine regions. For example, a setting of 1.5 limits an elements edge length to 1.5 times the edge length of the adjacent element
  • Grading factor values range from 1 to 10. A value of 1 produces the most uniform mesh transition. A value of 10 produces the least uniform mesh transition.
  • Increasing the value can reduce the number of elements and local mesh quality. Decreasing the value can drastically increase the number of elements

Boundary Condition:

Inlet:

At inlet, we have assumed velocity of flow is 1 m/s and preasure is 0 Pa.

Outlet:

Velocity: zeroGradient

(i.e no change in velocity at initial and final point but it may marry at all the point between initial and final point)

Code:

controlDict

select the value of delta T to keep the courant number value less than 1 and also start and end time of simulation

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

deltaT          5e-05;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Preassure:

/*--------------------------------*- C++ -*----------------------------------*\\
| =========                 |                                                 |
| \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\\\    /   O peration     | Version:  4.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;
    }
    outlet
    {
        type            fixedValue;
        value           uniform 0;

    }

    noSlipWalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }

}

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

Velocity:

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

    outlet
    {
        type            zeroGradient;
    }

    noSlipWalls
    {
        type            noSlip;
    }  

    frontAndBack
    {
        type            empty;
    }
}

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

Grading factor 1:

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

convertToMeters 0.01;

vertices
(
    (0 0 0)//0
    (8 0 0)//1
    (8 0.5 0)//2
    (0 0.5 0)//3
    (8 1 0)//4
    (0 1 0)//5
    (20 1 0)//6
    (20 0.5 0)//7
    (20 0 0)//8
    (20 -1 0)//9
    (8 -1 0)//10
   
    (0 0 0.1)//11
    (8 0 0.1)//12
    (8 0.5 0.1)//13
    (0 0.5 0.1)//14
    (8 1 0.1)//15
    (0 1 0.1)//16
    (20 1 0.1)//17
    (20 0.5 0.1)//18
    (20 0 0.1)//19
    (20 -1 0.1)//20
    (8 -1 0.1)//21
);

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

mergePatchPairs
(
);

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

Output:

Mesh:

Velocity:

Preasure:

Velocity Profile:

Grading Factor 0.2

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

convertToMeters 0.01;

vertices
(
    (0 0 0)//0
    (8 0 0)//1
    (8 0.5 0)//2
    (0 0.5 0)//3
    (8 1 0)//4
    (0 1 0)//5
    (20 1 0)//6
    (20 0.5 0)//7
    (20 0 0)//8
    (20 -1 0)//9
    (8 -1 0)//10
   
    (0 0 0.1)//11
    (8 0 0.1)//12
    (8 0.5 0.1)//13
    (0 0.5 0.1)//14
    (8 1 0.1)//15
    (0 1 0.1)//16
    (20 1 0.1)//17
    (20 0.5 0.1)//18
    (20 0 0.1)//19
    (20 -1 0.1)//20
    (8 -1 0.1)//21
);

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

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)
            (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)
  
        );
    }
    noSlipWalls
    {
        type wall;
        faces
        (
            (16 15 4 5)
            (15 17 6 4)
            (10 21 12 1)
            (11 0 1 12)
            (21 10 9 20)
        );
    }
);

mergePatchPairs
(
);

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

Output:

Velocity:

Preasure:

Velocity Profile:

Grading Factor 0.5

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

convertToMeters 0.01;

vertices
(
    (0 0 0)//0
    (8 0 0)//1
    (8 0.5 0)//2
    (0 0.5 0)//3
    (8 1 0)//4
    (0 1 0)//5
    (20 1 0)//6
    (20 0.5 0)//7
    (20 0 0)//8
    (20 -1 0)//9
    (8 -1 0)//10
   
    (0 0 0.1)//11
    (8 0 0.1)//12
    (8 0.5 0.1)//13
    (0 0.5 0.1)//14
    (8 1 0.1)//15
    (0 1 0.1)//16
    (20 1 0.1)//17
    (20 0.5 0.1)//18
    (20 0 0.1)//19
    (20 -1 0.1)//20
    (8 -1 0.1)//21
);

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

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)
            (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)
  
        );
    }
    noSlipWalls
    {
        type wall;
        faces
        (
            (16 15 4 5)
            (15 17 6 4)
            (10 21 12 1)
            (11 0 1 12)
            (21 10 9 20)
        );
    }
);

mergePatchPairs
(
);

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

Output:

Velocity:

Preasure:

Velocity Profile:

Grading Factor 0.8

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

convertToMeters 0.01;

vertices
(
    (0 0 0)//0
    (8 0 0)//1
    (8 0.5 0)//2
    (0 0.5 0)//3
    (8 1 0)//4
    (0 1 0)//5
    (20 1 0)//6
    (20 0.5 0)//7
    (20 0 0)//8
    (20 -1 0)//9
    (8 -1 0)//10
   
    (0 0 0.1)//11
    (8 0 0.1)//12
    (8 0.5 0.1)//13
    (0 0.5 0.1)//14
    (8 1 0.1)//15
    (0 1 0.1)//16
    (20 1 0.1)//17
    (20 0.5 0.1)//18
    (20 0 0.1)//19
    (20 -1 0.1)//20
    (8 -1 0.1)//21
);

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

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)
            (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)
  
        );
    }
    noSlipWalls
    {
        type wall;
        faces
        (
            (16 15 4 5)
            (15 17 6 4)
            (10 21 12 1)
            (11 0 1 12)
            (21 10 9 20)
        );
    }
);

mergePatchPairs
(
);

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

Output:

Velocity:

Preasure:

velocity Profile:

Procedure:

  • Open terminal prompt in ubuntu and type \'tut\' to open tutorials directory in openfoam.
  • In tutorials, go to the incompressible directory and then open icoFoam directory, copy the directory \'cavity\' using command \'cp -r cavity/ $FOAM_RUN\' , cavity directory will get copied to run directory.
  • Now type \'run\' to navigate into Foam run directory and open cavity directory using \'cd cavity\'. To know how many directories are there type \'ls\' it will list down all the sub directories in cavity.
  • Go to directory system in directory cavity and find \'blockMeshDict\' file.To open it type \'gedit blockMeshDict\'. Now edit the file according to required geometry.simillarly, open \'controlDict\' file and set the value of start and end time and delta T to keep the value of courant number less than 1.
  • Type \'cd ..\' to come into cavity directory and type \'cd 0\' to set the boundary condition for velocity and preasure.
  • Now go to cavity directory and type \'blockMesh\' to create mesh and later type \'checkMesh\' to check validity of mesh. type \'icoFoam\' to run the incompressible solver, it will calculate fluid properties at each mesh point.
  • Now to visualise the geometry type \'ParaFoam\' and click on \'apply\'.
  • To plot the cuve for velocity, go to \'filter\' tab and select \'data analysis\' and click on \'plot over line\'. and set the point of line wherever you want to plot the curve and hit apply.

Conclusion:

  • At the grading factor 0.2, fine mesh is produced and at 0.8 coarse mesh is produced.
  • velocity is maximum at the centre and zero at wall surface.(this is due to zero shear stress at centre.)
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.