Challenge

Simulation of a backward facing step in OpenFOAM

OBJECTIVE

  1. Transient simulation of an incompressible-laminar-viscous flow through the backward facing step geometry
  2. Simulate the flow without using any grading factor and also using a grading factor of 0.2
  3. Compare the velocity profile at 0.085 m from the inlet of the geometry for both case studies
  4. Explain why Grading/Growth factor is essential for meshing.

GEOMETRY

The backward facing step geometry with specifications is given. This geometry is to be simulated 2 dimensionally. recreating the geometry as blocks, we get to see the following arrangement with all the vertices given.

SELECTING THE SOLVER AND TUTORIAL

Assuming the fluid to be Newtonian and neglecting the frictional losses, for a incompressible-laminar flow icoFoam solver can be used.

In OpenFOAM we first create the run folder to execute our problem. The tutorial we select is incompressible icoFoam and copy the cavity folder into the run folder so that the files can be coded in order to suit the objectives of the problem.

CASE 1: SIMULATION OF FLOW WITHOUT ANY GRADING FACTOR

As per the geometry and the blocks we edit the blockMeshDict file so that it has all the vertices from 0-21, 5 blocks without grading factor and specifying the type of each boundary. The mesh specifications need to be

  1. Number of cells along the x direction (longer dimension) = 200
  2. Number of cells along the longer y direction = 20.

In this case, we specify the inlet and outlet as patches, front and back faces as empty and the rest including the backward facing step as walls. On executing the blockMesh command, a polymesh is created which can be viewed in the Paraview.

The initial conditions for the problem must be given. This is done by editing the velocity and pressure files in the 0 directory to our choice such that they respect the objectives. Finally, the controlDict file needs to be edited such that Courant number<1. For the solution not to go unstable, lets take Courant number=0.15 and calculate the deltaT value.

We know `Co=(dt.U)/(dx)` and here `Co=0.15` and `U=0.3text(m/s)`

`dx=(text(Domain length in x axis))/(text(Number of cells in x direction))=0.2/200=0.001m`

`dt=(Co*dx)/U=(0.15*0.001)/0.3=0.0005`

  • blockMeshDict code
/*--------------------------------*- 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)   //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) (80 5 1) simpleGrading (1 1 1)
    hex (3 2 4 5 14 13 15 16) (80 5 1) simpleGrading (1 1 1)
    hex (2 7 6 4 13 18 17 15) (120 5 1) simpleGrading (1 1 1)
    hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (1 1 1)
    hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (1 1 1)    
);

edges
(
);

boundary
(
    inletWalls
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    outletWalls
    {
        type patch;
        faces
        (
            (20 9 8 19)
            (19 8 7 18)
            (18 7 6 17)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (11 12 13 14)
            (14 13 15 16)
            (13 18 17 15)
            (12 19 18 13)
            (21 20 19 12)

            (0 3 2 1)
            (3 5 4 2)
            (2 4 6 7)
            (1 2  7 8)
            (10 1 8 9)
        );
    }
    noslipWalls
    {
        type wall;
        faces
        (
             (16 15 4 5)
             (15 17 6 4)
             (11 0 1 12)
             (21 10 9 20)
             (10 21 12 1)
      );
    }
);

mergePatchPairs
(
);

// ************************************************************************* //
  • controlDict code
/*--------------------------------*- 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         5;

deltaT          0.0005;

writeControl    timeStep;

writeInterval   200;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


// ************************************************************************* //
  • Velocity U code
/*--------------------------------*- 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
{
    inletWalls
    {
        type            fixedValue;
        value           uniform (0.3 0 0);
    }

    outletWalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
    
    noslipWalls
    {
        type            noSlip;
    }
}

// ************************************************************************* //
  • Pressure p code
/*--------------------------------*- 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
{
    inletWalls
    {
        type            zeroGradient;
    }

    outletWalls
    {
        type           fixedValue;
        value         uniform 0;
    }

    frontAndBack
    {
        type            empty;
    }
    
    noslipWalls
    {
        type            zeroGradient;
    }
}

// ************************************************************************* //
  • Transport properties
/*--------------------------------*- 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    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


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

POST- PROCESSING RESULTS

  • Pressure Contour

  • Velocity Contour

CASE 2: SIMULATION OF FLOW WITH GRADING FACTOR=0.2

This simulation is similar the previous one but has a change in the grading factors for the blocks and that needs to be edited. All other files (controlDict, initial velocity and pressure conditions and transport properties) are same as the previous simulation

  • blockMeshDict code
/*--------------------------------*- 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)   //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) (80 5 1) simpleGrading (0.2 5 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 (5 0.2 1)
    hex (1 8 7 2 12 19 18 13) (120 5 1) simpleGrading (5 5 1)
    hex (10 9 8 1 21 20 19 12) (120 10 1) simpleGrading (5 5 1)    
);

edges
(
);

boundary
(
    inletWalls
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    outletWalls
    {
        type patch;
        faces
        (
            (20 9 8 19)
            (19 8 7 18)
            (18 7 6 17)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (11 12 13 14)
            (14 13 15 16)
            (13 18 17 15)
            (12 19 18 13)
            (21 20 19 12)

            (0 3 2 1)
            (3 5 4 2)
            (2 4 6 7)
            (1 2  7 8)
            (10 1 8 9)
        );
    }
    noslipWalls
    {
        type wall;
        faces
        (
             (16 15 4 5)
             (15 17 6 4)
             (11 0 1 12)
             (21 10 9 20)
             (10 21 12 1)
      );
    }
);

mergePatchPairs
(
);

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

POST- PROCESSING RESULTS

  • Velocity Contour

  • Pressure Contour

COMPARISON OF VELOCITY PROFILES AT x=0.085m

We see more accurate solution when grading factor is 0.2 than that in 1 as the mesh is finer. As mesh gets coarser, the solution might start drift away from the original value. Hence grading factor is essential while meshing so as to get accurate solutions.

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.