Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Objective:

To simulate an incompressible-laminar-viscous flow through the backward facing step geometry.

To perform a transient simulation. The solver can be chosen based on the described physics of the flow.

To explain the entire simulation procedure (how you set up the case).

Procedure:

  • To choose the solve
  • To Set up the case (blockmesh and the various boundary conditions)
  • To run the simulation
  • To postprocess the result in Paraview

Since the flow is incompressible and laminar . Also the flow is of low reynolds number, the solver chosen is icoFoam.

Using the PISO algorithm , the incompressible laminar flow is solved.

The general approach to set up the case is to create a copy of the files of the icoFoam solver and create a different folder .

The Run folder inside FOAM_RUN contains all the copied folders. 

To create the geometry, the blockMeshDict file needs to be edited. The general idea of blockMesh is we define the geometry by set of blocks.

The origin of the geometry is nominated as 0 (0 0 0). The file is written in a C++ language.

The geometry can be simplified to create the co ordinates. It can be considered as two sets of five blocks, Joined together as front and back starting from index 0. To create the first block:

hex(0 1 2 3 11 12 1 3 14)(1 1 1) simplegrading(1 1 1)

In the above command, hex detremines the mesh. Here hexahedral mesh is done. It should be noted that the indexing of the block is done in cyclic order (whatever may be) If not followed, the solution will cxrash.

The (1 1 1) denotes the no of grids in x ,y and z direction. Since this is a 2D analysis, it is immamterial to provide meshing in the z direction , or to increase the grid points in the z direction.

The simple grading refers to mesh stretching. That is to stretch the mesh in a particular direction. This is nessecary to achieve good computational efficiency.

The formula to calculate grading factor is : f = size of end cell/(size of first cell). So if the grading factor is 0.1,  the end cell will be one tenth of the first cell.

To check the blockmeshDict to see if the blocks are genberated in a proper way or not, blockMesh command is used. To check the mesh, checkMesh is used. After that icoFoam solver is used to perform the simulation.

The blockMeshDict for the grading factor 0.2 is pasted along below.

Boundary conditions:

The boundary condition in openFoam is given to faces . Here it is called patch. The boundary faces are : 1) Inlet 2) No slip boundaries 3) Outlet.

The inlet and outlet are type: patch. This is a dictionary. The no slip boundaries are type walls.

 The blockMeshDict file is pasted below

/*--------------------------------*- 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.1;

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 1)  //11
    (8 0 1)  //12
    (8 0.5 1)//13
    (0 0.5 1)//14
    (8 1 1)  //15
    (0 1 1) //16
    (20 1 1) //17
    (20 0.5 1) //18
    (20 0 1) //19
    (20 -1 1) //20
    (8 -1 1)  //21
    
);

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

mergePatchPairs
(
);

// ************************************************************************* //
/*--------------------------------*- 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      fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

ddtSchemes
{
    default         Euler;
}

gradSchemes
{
    default         Gauss linear;
    grad(p)         Gauss linear;
}

divSchemes
{
    default         none;
    div(phi,U)      Gauss linear;
}

laplacianSchemes
{
    default         Gauss linear orthogonal;
}

interpolationSchemes
{
    default         linear;
}

snGradSchemes
{
    default         orthogonal;
}


// ************************************************************************* //
  • Results:

Mesh generation:

The grid generation can be visualized as, near the edges , a grading factor of 0.2 is applied. this means that near the edge, the size of  gris is 0.2 times the size of the cell at the beginning.

  • Velocity contour:

The plot over line shows a parabolic profile . The location of the plot over line is y=0.85 meters.

  • Pressure contour:

For grading factor 1 ,

The blockmeshDict file is :

The simplegrading(1 1 1) denotes a grading factor of 1.

/*--------------------------------*- 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.1;

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 1)  //11
    (8 0 1)  //12
    (8 0.5 1)//13
    (0 0.5 1)//14
    (8 1 1)  //15
    (0 1 1) //16
    (20 1 1) //17
    (20 0.5 1) //18
    (20 0 1) //19
    (20 -1 1) //20
    (8 -1 1)  //21
    
);

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

mergePatchPairs
(
);

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

 Results for grading factor 1:

  • Mesh generation:

The grids are uniform, since the grading factor is 1.

  • Velocity contour along a slice with normal along z direction:

The velovcity profile obtained is parabolic. The plot over line is created at an location of y =0.85 meters.

  • Pressure contour along a slice with normal along z direction:

Conclusion:

  • The study of flow over a backward facing step is studied.
  • Two different grading factors is studied, 0.2 and 1.
  • Velocity contours and pressure contours are obtained. Velocity profile is studied at a lociation by using the plot over line feature of Paraview.
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.