Challenge

Flow over a backwards facing step using openFoam

Objective: To simulate flow of a fluid over a backwards facing step.

A fluid of given viscosity is considered for flow over a backwards facing step with definite initial and boundary conditions.

We use the icoFoam solver available in openFoam for this simulation, for 10 seconds with a time step calculated keeping in check the value of the Courant number.

Problem: The geometry of the step is shown below with the boudnary conditions and dimensions. The flow simulated will be a 2-D flow, as the flow properties do not change in the z-direction.

The kinematic viscosity of the fluid is set to be 1e^-6.

The number of cells in the x-direction - 200
The number of cells in the y-direction - 10

The grading factor of the cells will be changed to different values to check for consistency and accuracy of solution.

Grading factor = (Size of last cell) / (Size of first cell). Grading factor is used to manipulate mesh quality.

The geomtry of the block is divided into different blocks.

blockmeshDict File:

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

convertToMeters 0.01;

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

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

mergePatchPairs
(
);

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

controlDict File

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         10;

deltaT          0.01;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Velocity initial conditons

/*--------------------------------*- C++ -*----------------------------------*
  =========                 |
  \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \    /   O peration     | Website:  https://openfoam.org
    \  /    A nd           | Version:  8
     \/     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.02 0 0);
    }

    outlet 
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
    Noslipwalls
    {
        type            noSlip;
    }    
}

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

Pressure initial conditions

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

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

Grading factor of 0.2

The blockMeshdict file has to be edited to account for this grading factor. The changes in the blockMeshdict file are-

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

The simulation is run from t=0 to t=10 seconds and the distributions of velocity and pressure at t=10 are shown.

Mesh:

Pressure distribution:

Velocity distribution:

Velocity distribution along the vertical direction at 0.085m from inlet:

Grading factor of 0.5:

The changes in the blockMeshdict file are-

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

Mesh:

Pressure distribution:

Velocity distribution:

Velocity distribution along the vertical direction at 0.085m from inlet:

Grading factor of 0.8:

The changes in the blockMeshdict file are-

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

Mesh:

Pressure distribution:

Velocity distribution:

Velocity distribution along the vertical direction at 0.085m from inlet:

Conclusion:

Having a finer mesh gives a more accurate output of results, however, with negligible differences.

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.