Project

Simulation of flow through backward facing step using icoFoam solver

Aim: To perform a simulation of flow in bacward facing step using openFoam software.

Objective:

1) To generate mesh using BlockMeshdict file for three grading factors.

Case 1, grading factor = 0.2

Case 2, grading factor = 0.5

Case 3, grading factor = 0.8

2) To solve the case using icoFoam solver.

3) To plot the velocity and pressure variation near backward facing step.

Geometry:

Calculating Minimum cell size (dx), Time step (dt) and end time of simulation (t):

Minimum cell size

Time step value

End time for simulation

The minimum cell size for non-uniform mesh is determined and time step value for max CFL number is calculated and the end time for simulation is calculated.

Initial condition:

Velocity initial condition

/*--------------------------------*- 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.5 0 0);
    }

    Outlet
    {
        type            zeroGradient;
    }

    Front
    {
        type            empty;
    }
    
    Back
    {
        type            empty;
    }
    
    Noslip
    {
        type            noSlip;
    }    
}

Pressure initial condition

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

    Front
    {
        type            empty;
    }
    Back
    {
        type            empty;
    }
    Noslip
    {
        type            zeroGradient;
    }
}

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

The initial condition of flow velocity and pressure is provided in the 0 zero directory in openfoam. For inlet boundary, velocity of 0.5 m/s is specified as the initial condition, this type of boundary condition is dirichlet boundary condition. For outlet boundary, kinematic pressure of zero gradient is specified as boundary condition, this type of boundary is known as neumann boundary condition.

Simulation time parameters:

Control dict 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         0.4;

deltaT          6e-4;

writeControl    timeStep;

writeInterval   100;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

The controldict file contains the simulation parameters such as time step value, simulation start time, end time and interval for writing output.

Fluid property

/*--------------------------------*- 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] 1.86e-5;


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

The transport properties file contains the fluid viscosity which defines the reynold's number. In this case, air is taken as fluid whose viscosity is 1.86e-5 m^2/s at 300K.

Mesh generation:

Case 1

BlockMeshDict file for grading factor 0.2

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

vertices
(
    (0 0 0)
    (100 0 0)
    (100 5 0)
    (0 5 0)
    (100 10 0)
    (0 10 0)
    (200 10 0)
    (200 5 0)
    (200 0 0)
    (200 -5 0)
    (100 -5 0)

    (0 0 1)
    (100 0 1)
    (100 5 1)
    (0 5 1)
    (100 10 1)
    (0 10 1)
    (200 10 1)
    (200 5 1)
    (200 0 1)
    (200 -5 1)
    (100 -5 1)
);

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

edges
(
);

boundary
(
    Inlet
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    Outlet
    {
        type patch;
        faces
        (
            (7 6 17 18)
            (8 7 18 19)
            (9 8 19 20)
        );
    }
    Front
    {
        type empty;
        faces
        (
            (12 13 14 11)
            (13 15 16 14)
            (18 17 15 13)
            (19 18 13 12)
            (20 19 12 21)
        );
    }
    Back
    {
        type empty;
        faces
        (
            (3 5 4 2)
            (0 3 2 1)
            (2 4 6 7)
            (1 2 7 8)
            (10 1 8 9)
        );
    }
    Noslip
    {
        type wall;
        faces
        (
            (15 4 5 16)
            (17 6 4 15)
            (21 12 1 10)
            (11 0 1 12)
            (21 10 9 20)
        );
    }
);

mergePatchPairs
(
);

Mesh for grading factor 0.2 :

Case 2

Blockmeshdict file for grading factor 0.5

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

vertices
(
    (0 0 0)
    (100 0 0)
    (100 5 0)
    (0 5 0)
    (100 10 0)
    (0 10 0)
    (200 10 0)
    (200 5 0)
    (200 0 0)
    (200 -5 0)
    (100 -5 0)

    (0 0 1)
    (100 0 1)
    (100 5 1)
    (0 5 1)
    (100 10 1)
    (0 10 1)
    (200 10 1)
    (200 5 1)
    (200 0 1)
    (200 -5 1)
    (100 -5 1)
);

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

edges
(
);

boundary
(
    Inlet
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    Outlet
    {
        type patch;
        faces
        (
            (7 6 17 18)
            (8 7 18 19)
            (9 8 19 20)
        );
    }
    Front
    {
        type empty;
        faces
        (
            (12 13 14 11)
            (13 15 16 14)
            (18 17 15 13)
            (19 18 13 12)
            (20 19 12 21)
        );
    }
    Back
    {
        type empty;
        faces
        (
            (3 5 4 2)
            (0 3 2 1)
            (2 4 6 7)
            (1 2 7 8)
            (10 1 8 9)
        );
    }
    Noslip
    {
        type wall;
        faces
        (
            (15 4 5 16)
            (17 6 4 15)
            (21 12 1 10)
            (11 0 1 12)
            (21 10 9 20)
        );
    }
);

mergePatchPairs
(
);

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

Mesh for grading factor 0.5 :

Case 3

Blockmeshdict file for grading factor 0.8

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

vertices
(
    (0 0 0)
    (100 0 0)
    (100 5 0)
    (0 5 0)
    (100 10 0)
    (0 10 0)
    (200 10 0)
    (200 5 0)
    (200 0 0)
    (200 -5 0)
    (100 -5 0)

    (0 0 1)
    (100 0 1)
    (100 5 1)
    (0 5 1)
    (100 10 1)
    (0 10 1)
    (200 10 1)
    (200 5 1)
    (200 0 1)
    (200 -5 1)
    (100 -5 1)
);

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

edges
(
);

boundary
(
    Inlet
    {
        type patch;
        faces
        (
            (0 11 14 3)
            (3 14 16 5)
        );
    }
    Outlet
    {
        type patch;
        faces
        (
            (7 6 17 18)
            (8 7 18 19)
            (9 8 19 20)
        );
    }
    Front
    {
        type empty;
        faces
        (
            (12 13 14 11)
            (13 15 16 14)
            (18 17 15 13)
            (19 18 13 12)
            (20 19 12 21)
        );
    }
    Back
    {
        type empty;
        faces
        (
            (3 5 4 2)
            (0 3 2 1)
            (2 4 6 7)
            (1 2 7 8)
            (10 1 8 9)
        );
    }
    Noslip
    {
        type wall;
        faces
        (
            (15 4 5 16)
            (17 6 4 15)
            (21 12 1 10)
            (11 0 1 12)
            (21 10 9 20)
        );
    }
);

mergePatchPairs
(
);

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

Mesh for grading factor 0.8 :

The blockmeshdict file contains the details of geometry, boundaries, number of cells and mesh grading factor.

Results:

Velocity plot for Case 1

Velocity plot for Case 2

Velocity plot for Case 3

Pressure plot for Case 1

Pressure plot for Case 2

Pressure plot for Case 3

Velocity contour

Pressure contour

Velocity streamline contour

Flow separation and vortex formation

The contours obtained in the case 1 provides more detail compared to other two cases, hence the velocity contour from case 1 is selected for observing the flow separation, point of separation, point of reattchment and vortex formation.

From the above figure, it can be observed that the stream of fluid starts to dettach itself near the step and this point is known as the point of flow separation. And at a certain length after the backward facing step, the stream of fluid flow stop recirculating and joins the rest of the flow, this point is known as point of reattachment. A region of low pressure is created just after the backward facing step where recirculating and backward flow occurs, this region is called as separated flow region. In the separated flow region, formation of circulating fluid structures takes place and these structures are known as vortices.

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.