Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Simulation of a backward facing step in OpenFOAM

The project demonstrates importance of grading factor while meshing in CFD numerical simulation.

Geometry for analysis:-

In order to develop this geometry to be solved in openFoam, 3 blocks were made and meshed using blockMesh. The blocks created is described below:-

in order to apply variable grid spacing, growth factor in the blockMeshDict file has been applied.

The numerical analysis is done with the following changing grid spacing factor of 0.1, 0.2, 0.4, 0.8, 1.

The grid spacing is applied in such a way to increase the no. of grid points in the corner point.

Setting up the Simulation:-

In order to simulate the problem, tutorial file from incompressible flow is taken and modified. The modified files are, blockMeshDict, controlDict, transportProperties and initial condition values in folder named 0.

The boundary definitions used in the simulation is as follows:-

The blockMeshDict file:-

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

scale   1;

vertices
(
    (0 0 0) //0
    (0.01 0 0) //1
    (0.01 0.12 0) //2
    (0 0.12 0) //3
    (0.02 0 0) //4
    (0.02 0.12 0) //5
    (0.02 0.2 0) //6
    (0.01 0.2 0) //7
    (0 0 0.001) //8
    (0.01 0 0.001) //9
    (0.01 0.12 0.001) //10
    (0 0.12 0.001) //11
    (0.02 0 0.001) //12
    (0.02 0.12 0.001) //13
    (0.02 0.2 0.001) //14
    (0.01 0.2 0.001) //15
);

blocks
(
    hex (0 1 2 3 8 9 10 11) (20 200 1) simpleGrading (1 1 1)
    hex (1 4 5 2 9 12 13 10) (20 200 1) simpleGrading (1 1 1)
    hex (2 5 6 7 10 13 14 15) (20 200 1) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    Inlet
        {
            type patch;
            faces
            (
                (7 15 14 6)
            );
        }
    
    Outlet
        {
            type patch;
            faces
            (
                (1 4 12 9)
                (0 1 9 8)
            );
        }
    
    frontAndBack
        {
            type empty;
            faces
            (
                (2 5 6 7)
                (1 4 5 2)
                (0 1 2 3)
                (10 13 14 15)
                (9 12 13 10)
                (8 9 10 11)
            );
        }

    top
        {
            type wall;
            faces
            (
                (5 13 14 6)
                (4 12 13 5)
            );
        }

    bottom
        {
            type wall;
            faces
            (
                (0 8 11 3)
                (2 10 15 7)
            );
        }

    side
        {
            type wall;
            faces
            (
                (3 11 10 2)
            );
        }
);

mergePatchPairs
(
);

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

the controlDict file:-

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     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.00005;

writeControl    timeStep;

writeInterval   10;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

transportProperties for Kinematic Viscosity:-

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

nu             [0 2 -1 0 0 0 0] 1.48e-5;


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

pressure initial Condition:-

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     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;

    }

    top
    {
        type            zeroGradient;
    }

    bottom
    {
        type            zeroGradient;
    }

    side
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

Velocity Boundary Condition :-

Inlet has uniform velocity of 1 m/s in the negative y direction.

top, bottom and side boundary has no slip condition, their velocity is kept zero.

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     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 (0 -1 0);
    }

    Outlet
    {
        type            zeroGradient;

    }

    top
    {
        type            noSlip;
    }

    bottom
    {
        type            noSlip;
    }

    side
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

The Mesh in the cornor area for different grading factor along with its implementations are :-

for grading factor 1:-

blocks
(
    hex (0 1 2 3 8 9 10 11) (20 200 1) simpleGrading (1 1 1)
    hex (1 4 5 2 9 12 13 10) (20 200 1) simpleGrading (1 1 1)
    hex (2 5 6 7 10 13 14 15) (20 200 1) simpleGrading (1 1 1)
);

for grading factor 0.8:-

blocks
(
    hex (0 1 2 3 8 9 10 11) (20 200 1) simpleGrading (0.8 0.8 1)
    hex (1 4 5 2 9 12 13 10) (20 200 1) simpleGrading (1.25 0.8 1)
    hex (2 5 6 7 10 13 14 15) (20 200 1) simpleGrading (1.25 1.25 1)
);

for grading factor 0.4:-

blocks
(
    hex (0 1 2 3 8 9 10 11) (20 200 1) simpleGrading (0.4 0.4 1)
    hex (1 4 5 2 9 12 13 10) (20 200 1) simpleGrading (2.5 0.4 1)
    hex (2 5 6 7 10 13 14 15) (20 200 1) simpleGrading (2.5 2.5 1)
);

for grading factor 0.2:-

blocks
(
    hex (0 1 2 3 8 9 10 11) (20 200 1) simpleGrading (0.2 0.2 1)
    hex (1 4 5 2 9 12 13 10) (20 200 1) simpleGrading (5 0.2 1)
    hex (2 5 6 7 10 13 14 15) (20 200 1) simpleGrading (5 5 1)
);

for grading factor 0.1:-

blocks
(
    hex (0 1 2 3 8 9 10 11) (20 200 1) simpleGrading (0.1 0.1 1)
    hex (1 4 5 2 9 12 13 10) (20 200 1) simpleGrading (10 0.1 1)
    hex (2 5 6 7 10 13 14 15) (20 200 1) simpleGrading (10 10 1)
);

Results:-

From the plot is can be easily be seen that, there is very less variation in velocity magnitude with grading factor where the mesh is fine, at around 0.01m along the line of interest.
Whereas, the velocity magnitude varies at around the top surface around 0.014 and beyond.

The behaviour can easily be understood by the fact of grid independence. At around x = 0.1, the grid points are already so near to each other. While simulation, with varying grid factor, that region was always with refined grid points.

At the top surface around 0.014 (in line of interest) and beyond, the grid spacing changed and the grid was course, so there are variotions in the results.

It is worth noting that, for those parts of the geometry, where, more accuracy is needed, the grid points must be refined. Since, no. of grid points have a huge effect on simulation time, So grading factor can help a lot in controling grid spacing at desired places. While, the areas where more tolerace can be allowed, the grid can be coarse.

The coarse grid mesh requires less time for running the simulation as compared to finer grid. So grid factor can help in saving simulation resourse without comprimising with the quality of solution.

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.