Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Aim:

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).

Description:

Incompressible flow : In fluid dynamics, incompressible flow refers to a flow in which the density remains constant in any fluid parcel, i.e. any infinitesimal volume of fluid moving in the flow.

Laminar flow : Fluid (gas or liquid) flow in which the fluid travels smoothly or in regular paths .In laminar flow, sometimes called streamline flow, the velocity, pressure, and other flow properties at each point in the fluid remain constant. Laminar flow over a horizontal surface may be thought of as consisting of thin layers, or laminae, all parallel to each other. The fluid in contact with the horizontal surface is stationary, but all the other layers slide over each other.

Reynolds number is used to differentiate the flow between laminar and turblent.For flow in a pipe of diameter D, experimental observations show that laminar flow occurs when ReD < 2300 and turbulent flow occurs when ReD > 2900.

Viscous Flow : The fluid flow in which frictional effects become signification, are treated as viscous flow. When two fluid layers move relatively to each other, frictional force develops between them which is quantified by the fluid property 'viscosity'. Boundary layer flows are the example of viscous flow.

The flow which contains all these effects is called incompressible -laminar -viscous flow.

Simulation Procedure:

  • Open openFoam tutorials and find the the solver to solve incompressible-laminar-viscous flow problem.
  • Next step is to copy required file in solver and paste it in OpenFOAM run folder so that the official file of OpenFoam remain same as constant.
  • Find out blockmeshDict script file edit the vertices and blocks in the script file based on the given geometry.
  • Find ‘controlDict’ file to edit start and end time for simulation.
  • In initial folder ‘0’ edit initial parameter for velocity and pressure according to faces of the given domain.
  • Use blockMesh command to generate mesh and checkMesh to verify it.
  • Enter icoFoam command to start the simulation.
  • Open simulation file in paraView and plot the velocity profile at point 0.085m from inlet.
  • Repeat above procedure for grading factor 0.2 to check the differences in results.

Given Geometry:

To create the above geometry, let us consider creating the geometry using 5 blocks as below figure,

Case 1 -Flow without using any grading factor

Vertices:

The following vertices should be change in blockMeshDict script file,

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

Blocks:

Same as the folllowing blocks should be change in blockMeshDict script file,

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (1 1 1)   //Block1
    hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (1 1 1)   //Block2
    hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (1 1 1)  //Block3
    hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (1 1 1)  //Block4
    hex (10 9 8 1 21 20 19 12) (120 20 1) simpleGrading (1 1 1) //Block5
);

Boundary Conditions:

The following boundary connditions are applied for the simulation, so these condition should change in blockMeshDict script file,

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

Script Files:

The following changed script files are used in this simulation to solve the flow without using any grading factor.

blockmeshDict file :

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

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

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

mergePatchPairs
(

);

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

controlDict file :

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.00001;

writeControl    timeStep;

writeInterval   2000;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

pressure :

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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;
    }
    frontAndBack
    {
        type            empty;
    }
    noSlipWall
    {
        type            zeroGradient;
    }

}

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

velocity :

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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;
    }
    noSlipWall
    {
        type            noSlip;
    }
    frontAndBack
    {
        type            empty;
    }
}

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

Simulation Results:

Meshgrid:

Velocity Distribution:

Pressure Distribution:

Velocity Plot:

Case 2 - Flow with grading factor of 0.2 ( cells near the walls )

Vertices:

The following vertices should be change in blockMeshDict script file,

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

Blocks:

Same as the folllowing blocks should be change in blockMeshDict script file,

blocks
(
    hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.2 5 1)   //Block1
    hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.2 0.2 1)   //Block2
    hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (5 0.2 1)  //Block3
    hex (1 8 7 2 12 19 18 13) (120 10 1) simpleGrading (5 5 1)  //Block4
    hex (10 9 8 1 21 20 19 12) (120 20 1) simpleGrading (5 5 1) //Block5
);

Boundary Conditions:

The following boundary connditions are applied for the simulation, so these condition should change in blockMeshDict script file,

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

Script Files:

The following changed script files are used in this simulation to solve the flow with grading factor of 0.2 ( cells near the walls )

blockmeshDict file :

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

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

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

mergePatchPairs
(

);

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

controlDict file :

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.00001;

writeControl    timeStep;

writeInterval   2000;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

pressure :

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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;
    }
    frontAndBack
    {
        type            empty;
    }
    noSlipWall
    {
        type            zeroGradient;
    }

}

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

velocity :

/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  10
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    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;
    }
    noSlipWall
    {
        type            noSlip;
    }
    frontAndBack
    {
        type            empty;
    }
}

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

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    movingWall
    {
        type            fixedValue;
        value           uniform (1 0 0);
    }

    fixedWalls
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

Simulation Results:

Meshgrid:

Velocity Distribution:

Pressure Distribution:

Velocity Plot:

Now finally we can conclude that by seeing the plots, when we use the grading factor and refined the mesh we can see that the flow is captured exactly than without grading factor.At a distance 0.01 along Y-axis from a distance 0.085m from the inlet we can see that the flow is captured exactly that there is a sharp rise in value of velocity which was not captured well before.So using the finer mesh will lead to accurate results but it costs a lot of computational effort.

Grading Factor:

The grading factor enables the mesh to be graded, or refined, in specified directions. The ratio is that of the width of the end cell δe">δealong one edge of a block to the width of the start cell δs">δs along the edge ,

Grading Factor = (size of end cell) / (size of starting cell)

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.