Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Simulation of a backward facing step in OpenFOAM

Aim:-

  • Simulate an incompressible-laminar-viscous flow through the backward facing step geometry.
  • To perform transient simulation; choose solver based on the described physics of the flow in problem statement.
  • To simulate the flow without using any grading factor(ie; GF = 1)
  • To simulate the flow with a grading factor of 0.2.

Incompressible flow: The flow in which there is no change in the density is called the incompressible flow.

Laminar flow:- A laminar flow is one where the fluid motion is regular and there is no mixing. It can be visualized by the pathlines that do not intersecteach other. In fluid dynamics laminar flow is characterized by fluid particles following smooth paths in layers, with each layer moving smoothly past the adjacent layers with little or no mixing. At low velocities, the fluid tends to flow without lateral mixing, and adjacent layers slide past one another(nor eddies or swirls of fluid). In laminar flow, the motion of the particles close to a solid surface moving in straight lines parallel to that surface. Laminar flow is a flow regime which characterized by high momentum diffusion and low momentum convection.

Problem Statement

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

Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1).

Case 2 - Simulate the flow with grading factor of 0.2. The cells should be finer near the walls (includig the step wall).

Mesh specification

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

Boundary condition specification

The domain specifications are provided in the following figure.

Procedure:-

  • To start the simulation process by typing 'ctrl+alt+t' to open a new terminal.
  • Using the available tutorials present in openFOAM typing the command 'tut' and to identify what kind of tutorial present in it(directory) typing the command 'ls'(list).
  • Here we need to solve Incompressible flow simulation for the above case problem, so select the 'Incompressible' from directory by typing command 'cd incompressible/' and agin type 'ls' to explore it.
  • Here we can see the plethora of solver folders. For this case of problem, we need solver for laminar viscous flow, so choose the sover 'icoFoam'.
  • IcoFoam is a solver in openFoam, it canbe used as a transient solver for incompressible,laminar flow of newtonian fluid.
  • So select 'icoFoam' folder by typing the command 'cd icoFoam' and typing 'ls' to explore this folder in terminal.
  • Here we can see two options 'cavity' and 'elbow'. Both are the part of icoFoam solver, to create required domain use cavity section
  • In cavity folder, we have to define our fluid domain and generate blockMesh. so copy the cavity folder, using the command 'cp -r cavity' and paste it in openFoam run folder by typing 'cp -r cavity $FOAM_RUN/cavity_test' and the type 'cd $FOAM_RUN'. Then type 'ls'.
  • To provide specification for our blockMesh in system folder open 'cavity_test' folder, by typing 'cd cavity_test'.
  • Here we can see that there are four script files, we want to open the "blockMeshDict" to creae the domain.By typing the command 'cd system' and 'ls' .
  • Then type 'notepad.exe blockMeshDict' and edit it and similarly done the same for controlDict.
  • After editing of blockMeshDict file save it and close it.
  • Then open the 'controlDict'file to provide time lmits, ie; start time and end time and also to represent deltat,after making the changes in controlDict file save it and close it.
  • Then we have to define our initial value for pressure and velocity,inorder to do that go back in cavity_copy diectory using 'cd ..' command and select folder named '0', which stand for initial values.
  • After setting the initial boundary condition for pressure and velocity at each faces also update the name of the boundary same as we changed inlet outlet name in blockMeshDict script file.
  • Then proceed to deploy mesh using command 'blockMesh' and then to chech the mesh if there is any error using the command 'checkMesh'
  • After checkMesh we get confirmation and using to view results type command 'paraviewWindows' and explore through it.

CODE:-

BLOCKMESHDICT

/*--------------------------------*- 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   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) (200 20 1) simpleGrading (1 1 1)     //block1
    hex (3 2 4 5 14 13 15 16) (200 20 1) simpleGrading (1 1 1)     //block2
    hex (2 7 6 4 13 18 17 15) (200 20 1) simpleGrading (1 1 1)     //block3
    hex (1 8 7 2 12 19 18 13) (200 20 1) simpleGrading (1 1 1)     //block4
    hex (10 9 8 1 21 20 19 12) (200 20 1) simpleGrading (1 1 1)    //block5
);

edges
(
);

boundary
(
    inlet
    {
        type wall;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)    
        );
    }
    outlet
    {
        type wall;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    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)
        );
    }
    fixedwalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (0 1 12 11)
            (4 15 17 6)
            (10 9 20 21)
            (10 21 12 1)
        );
    }
 );

mergePatchPairs
(
);

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

CONTROLDICT

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

deltaT          0.00001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

PRESSURE 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value           uniform 0;
    }

    fixedwalls
    {
        type            zeroGradient;
    }
    frontAndBack
    {
        type             empty;
    }
}
// ************************************************************************* //

VELOCITY 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       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);
    }

    outlet
    {
        type            zeroGradient;
    }

    fixedwalls
    {
        type            noSlip;
        value           uniform (0 0 0);
    }
    frontAndBack
    {
        type             empty;
    }
}

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

OUTPUT:-

Without assigning any grading factor the blockMesh is shown below;

Velocity Distribution along the domain area is shown below;

Pressure Distribution along the domain area is shown below;

Velocity plot at a distance 0.085m from inlet is shown below;

While looking into the above mesh,it can identified that it is not uniform all over the surface, so adjusting the mesh and shown below.

After making the above changes the mesh is uniformly distributed which is shown below

CODE:-

BLOCKMESHDICT

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

edges
(
);

boundary
(
    inlet
    {
        type wall;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)    
        );
    }
    outlet
    {
        type wall;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    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)
        );
    }
    fixedwalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (0 1 12 11)
            (4 15 17 6)
            (10 9 20 21)
            (10 21 12 1)
        );
    }
 );

mergePatchPairs
(
);

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

CONTROLDICT

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

deltaT          0.00001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

PRESSURE 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value           uniform 0;
    }

    fixedwalls
    {
        type            zeroGradient;
    }
    frontAndBack
    {
        type             empty;
    }
}
// ************************************************************************* //

VELOCITY 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       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);
    }

    outlet
    {
        type            zeroGradient;
    }

    fixedwalls
    {
        type            noSlip;
        value           uniform (0 0 0);
    }
    frontAndBack
    {
        type             empty;
    }
}

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

OUTPUT:-

Without assigning any grading factor the blockMesh is shown below;

Velocity Distribution along the domain area is shown below;

Pressure Distribution along the domain area is shown below;

Velocity plot at a distance 0.085m from inlet is shown below;

With applying Grading factor-0.2

CODE:-

BLOCKMESHDICT

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

edges
(
);

boundary
(
    inlet
    {
        type wall;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)    
        );
    }
    outlet
    {
        type wall;
        faces
        (
            (9 8 19 20)
            (8 7 18 19)
            (7 6 17 18)
        );
    }
    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)
        );
    }
    fixedwalls
    {
        type wall;
        faces
        (
            (5 16 15 4)
            (0 1 12 11)
            (4 15 17 6)
            (10 9 20 21)
            (10 21 12 1)
        );
    }
 );

mergePatchPairs
(
);

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

CONTROLDICT

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

deltaT          0.00001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

PRESSURE 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       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    inlet
    {
        type            zeroGradient;
    }

    outlet
    {
        type            fixedValue;
        value           uniform 0;
    }

    fixedwalls
    {
        type            zeroGradient;
    }
    frontAndBack
    {
        type             empty;
    }
}
// ************************************************************************* //

VELOCITY 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       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);
    }

    outlet
    {
        type            zeroGradient;
    }

    fixedwalls
    {
        type            noSlip;
        value           uniform (0 0 0);
    }
    frontAndBack
    {
        type             empty;
    }
}

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

Output:-

With assigning grading factor-0.2 the blockMesh is shown below;

Velocity Distribution along the domain area is shown below;

Pressure Distribution along the domain area is shown below;

Velocity plot at a distance 0.085m from inlet is shown below;

  • Changing the grading factor from the value of 0.2 to 1 the mesh becomes finer and the solution becomes very accurate.
  • The execution time is lower for lower meshing grading factor.
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.