Project

Simulate the flow through a backward-facing step BlockMesh Drill down challenge using icoFoam solver

OBJECTIVE

To simulate the flow through a backward-facing step using OpenFOAM ( icoFoam solver) and compare the velocity magnitude contours for the mesh grading factor of 0,0.2,0.5,0.8.

Given Geometry with Boundry Condition:

We are using the icoFoam solver to generate a backward-facing step which is a transient solver for incompressible, laminar flow of Newtonian fluids. We are taking some specifications to solve this problem.

1) The number of cells along the direction of flow = 200

2) The number of cells along the y-direction for each block = 10

3) For grade the mesh used grading factor 0.2, 0.5, 0.8

4) Inlet Velocity is 1 m/sec.

first of all edit the BlockMeshDict file, which is present in the system folder of icoFoam solver to generate the geometry and assign the vertices. There is also defines the mesh grid. The first mesh was generated without the grading factor.

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

convertToMeters 0.1;

vertices
(
    (0 0 0) //v0
    (0.8 0 0) //v1
    (0.8 0.05 0) //v2
    (0 0.05 0) //v3
    (0 0.1 0) //v4
    (0.8 0.1 0) //v5
    (2.0 0.1 0) //v6
    (2.0 0.05 0) //v7
    (2.0 0 0) //v8
    (2.0 -0.1 0) //v9
    (0.8 -0.1 0) //v10
    (0.8 0 0.005) //v11
    (0 0 0.005) //v12
    (0 0.05 0.005) //v13
    (0.8 0.05 0.005) //v14
    (0.8 0.1 0.005) //v15
    (0 0.1 0.005) //v16
    (2.0 0.1 0.005) //v17
    (2.0 0.05 0.005) //v18
    (2.0 0 0.005) //v19
    (2.0 -0.1 0.005) //v20
    (0.8 -0.1 0.005) //v21

);

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

);

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (12 0 3 13)
            (13 3 4 16)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (17 18 7 6)
            (18 19 8 7)
            (19 20 9 8)
        );
    }
    front
    {
        type empty;
        faces
        (
            (12 11 14 13)
            (13 14 15 16)
            (14 18 17 15)
            (11 19 18 14)
            (21 20 19 11)            
        );
    }

    Back
    {
        type empty;
        faces
        (
            (0 1 2 3)
            (3 2 5 4)
            (2 7 6 5)
            (1 8 7 2)
            (10 9 8 1)

        );
    }
    topandbottom
    {
        type wall;
        faces
        (
            (12 11 1 0)
            (1 10 21 11)
            (21 20 9 10)
            (4 5 15 16)
            (5 6 17 15)            
        );
    }
);

mergePatchPairs
(
);

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

Flow conditions

When a fluid is flowing through a closed channel such as a pipe or between two flat plates, either of two types of flow may occur depending on the velocity and viscosity of the fluid: laminar flow or turbulent flow. Laminar flow occurs at lower velocities so that inlet velocity is set to 1 m/s. Since icoFoam is a transient solver so we care about the time step otherwise our solution became unstable, we set time for 0.01 second and time step 1e-5 for the simulation.

so edit the velocity, pressure file present in icoFoam solver and define the time and time step in the controlDict.

Initial Condition for Pressure

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  7
     \\\\/     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;
    }

    topandbottom
    {
        type            zeroGradient;
    }


}

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

Initial Condition for Velocity

/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  7
     \\\\/     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;
    }
/*--------------------------------*- C++ -*----------------------------------*\\
  =========                 |
  \\\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\\\    /   O peration     | Website:  https://openfoam.org
    \\\\  /    A nd           | Version:  7
     \\\\/     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;
    }

    front
    {
        type            empty;
    }
   
    back
    {
        type            empty;
    }

    topandbottom
    {
        type            noSlip;
    }

}

// ************************************************************************* //
    topandbottom
    {
        type            zeroGradient;
    }


}

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

We run the solver for creating the mesh for different four gradings. The first blockMesh file is for the zero grading shown above and others with 0.8, 0.5, 0.2 grading respectively.

Meshing

For 0 grading

For 0.8 grading

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

For 0.5 grading

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

For 0.2 grading

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

Velocity plot and Velocity Magnitude line plot

Velocity contour data is extracted at location 0.085 from the Inlet.

For zero grading

for 0.8 grading

for 0.5 grading

for 0.2 grading

Discussions

As we define the inlet speed was 1 m/s but when we see in the velocity contour at 0.085 from the inlet, It is more than 1 m/s. This is due to the boundary layer. Walls offer resistance to the flow, due to this phenomenon velocity near the walls decreases. To compensate that the velocity near the central region increases to maintain a constant mass flow rate.

Conclusions

Velocity contour obtained from different mesh grading factors looks similar with a negligible variation and as it has identified that the lower mesh size (finer mesh) increased the accuracy of the result.

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.