Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

The appropriate solver for the given flow condition is icoFoam. From the tutorials folder of the OpenFoam, the cavity tutorial which uses icoFoam solver is copied to the run folder. The blockMeshDict file is edited as below according to the following configuration. 

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.12 0 0)
    (-0.08 0.01 0)
    (0 0.01 0)
    (0.12 0.01 0)
    (-0.08 0.015 0)
    (0 0.015 0)
    (0.12 0.015 0)
    (-0.08 0.02 0)
    (0 0.02 0)
    (0.12 0.02 0)
    (0 0 0.05)
    (0.12 0 0.05)
    (-0.08 0.01 0.05)
    (0 0.01 0.05)
    (0.12 0.01 0.05)
    (-0.08 0.015 0.05)
    (0 0.015 0.05)
    (0.12 0.015 0.05)
    (-0.08 0.02 0.05)
    (0 0.02 0.05)
    (0.12 0.02 0.05)
);

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

edges
(
);

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

mergePatchPairs
(
);
// ************************************************************************* //

The fluid through the channel is air and its properties are taken at `27^ 0 C` and 101325 Pa.

Next, the p file is edited as follows

/*--------------------------------*- 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 86143.46691;

boundaryField
{
    Inlet
    {
        type            zeroGradient;
        
    }

    Outlet
    {
        type            fixedValue;
        value           uniform 86143.46691;
    }

    fixedWalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

The U file is edited as follows

/*--------------------------------*- 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 (1.0 0 0);
    }

    Outlet
    {
        type            zeroGradient;
    }

    fixedWalls
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

The timestep is chosen such that the Courant number is less than one. The kinematic viscosity of air is updated in the transportProperties file.

The controlDict is edited as follows

/*--------------------------------*- 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         4;

deltaT          0.0005;

writeControl    runTime;

writeInterval   0.25;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

In the first case, grading is not applied. The velocity `(V_x)` at x=0.085 m for the first case is obtained as follows.

In the second case, grading is applied and the blockMeshDict is edited as follows

/*--------------------------------*- 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.12 0 0)
    (-0.08 0.01 0)
    (0 0.01 0)
    (0.12 0.01 0)
    (-0.08 0.015 0)
    (0 0.015 0)
    (0.12 0.015 0)
    (-0.08 0.02 0)
    (0 0.02 0)
    (0.12 0.02 0)
    (0 0 0.05)
    (0.12 0 0.05)
    (-0.08 0.01 0.05)
    (0 0.01 0.05)
    (0.12 0.01 0.05)
    (-0.08 0.015 0.05)
    (0 0.015 0.05)
    (0.12 0.015 0.05)
    (-0.08 0.02 0.05)
    (0 0.02 0.05)
    (0.12 0.02 0.05)
);

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

edges
(
);

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

mergePatchPairs
(
);
// ************************************************************************* //

The timestep is varied to 0.0001 for the second case. The velocity profile obtained in this case is as follows.

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.