Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Content

Sr no Topic
1 Theory
1.1 Problem Statement
2 Case setup
Code
2.1 Initial Conditions
2.2 Time Setup
Case 1(ungraded)
3 blockMesh
3.1 Result
3.2 Plot over line
Case2(Graded)
4 blockMesh
4.1 Result
4.2 Plot over line
5 Why Grading factoe is necessary?
6 Conclusion

Simulation of Backward facing step in OpenFoam.

1) Theory:

  • the layers of fluid do not intersect and flow intheir own plane parallel to eachother.
  • Reynold's Number: Defined as `(rho u L)/mu`, helps inpredicting the flow weather Laminar or Terbulent. A lower Reynolds number signifies a Laminar flow. It can be concluded that Laminar flow has higher Viscosity.

1.1) Problem Statement: To understand how a Laminar flow will behave when passed over a Backwards facing step.

As the diagram shows the specification of steps, the conditions under which the simulations will take place will be given via user inputs in the program files of OpenFoam.

The inputs include Simulation time, time steps, initial conditions, boundary conditions and the geometry of the Backwards step.

The simulation is done using 2 methods.

1) Simple grading (factor (1 1 1))

2) Simple grading (factor (0.2 0.2 1))

The constant conditions that exist for both the methods is given by:(Changes made in the original files)

Table 1
Initial conditions
Velocity Pressure

Inlet: uniform(1 0 0)

Outlet: zeroGradient

noSlip: noSlip

Inlet: zeroGradient

Outlet: uniform 0

noSlip: zeroGradient

Time
Simulation time Time steps
0.2 0.00001
Geometry
x y z
150 20 1

Note: Solver used is in this case is icoFoam as it requairs inputs as Velocity and Pressure field.

------------------------------------------------------------------

2) Case setup:

In the given problem we will be seeing the difference how the change in grading factor changes/ affects the result. So, the conditions like initial, boundary, time steps will remain the same.

Initial Conditions (updated with given initial conditions from table 1)
Velocity
/*--------------------------------*- 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 (1 0 0);
    }
    
    outlet
    {
        type            zeroGradient;
        
    }

    noslipwalls
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

    noslipwalls
    {
        type            zeroGradient;
    }

    frontAndBack
    {
        type            empty;
    }
}

// ************************************************************************* //
ControlDict (time) (from table 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;
    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;


// ************************************************************************* //
------------------------------------------------------------------

3) Case 1) Ungraded:

blockMesh (considering the given geometry)
/*--------------------------------*- 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 1;

vertices
(
    (0 0 0)
    (0.08 0 0)
    (0.08 0.005 0)
    (0 0.005 0)
    (0.08 0.01 0)
    (0 0.01 0)
    (0.20 0.01 0)
    (0.20 0.005 0)
    (0.20 0 0)
    (0.20 -0.01 0)
    (0.08 -0.01 0)

    (0 0 0.001)
    (0.08 0 0.001)
    (0.08 0.005 0.001)
    (0 0.005 0.001)
    (0.08 0.01 0.001)
    (0 0.01 0.001)
    (0.20 0.01 0.001)
    (0.20 0.005 0.001)
    (0.20 0 0.001)
    (0.20 -0.01 0.001)
    (0.08 -0.01 0.001)
);

blocks
(
    hex (0 1 2 3 11 12 13 14)
    (150 20 1)
    simpleGrading (1 1 1)

    hex (3 2 4 5 14 13 15 16)
    (150 20 1)
    simpleGrading (1 1 1)

    hex (2 7 6 4 13 18 17 15)
    (150 20 1)
    simpleGrading (1 1 1)
    
    hex (1 8 7 2 12 19 18 13)
    (150 20 1)
    simpleGrading (1 1 1)

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

mergePatchPairs
(
);

// ************************************************************************* //
Mesh Preview
------------------------------------------------------------------

3.1) Result: The following pictures show the result of the conditions applied from above.

Velocity Pressure

3.2) Plot over line result:

Plot
------------------------------------------------------------------

4) Case 2) Graded:

blockMesh (considering the given geometry)
/*--------------------------------*- 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 1;

vertices
(
    (0 0 0)
    (0.08 0 0)
    (0.08 0.005 0)
    (0 0.005 0)
    (0.08 0.01 0)
    (0 0.01 0)
    (0.20 0.01 0)
    (0.20 0.005 0)
    (0.20 0 0)
    (0.20 -0.01 0)
    (0.08 -0.01 0)

    (0 0 0.001)
    (0.08 0 0.001)
    (0.08 0.005 0.001)
    (0 0.005 0.001)
    (0.08 0.01 0.001)
    (0 0.01 0.001)
    (0.20 0.01 0.001)
    (0.20 0.005 0.001)
    (0.20 0 0.001)
    (0.20 -0.01 0.001)
    (0.08 -0.01 0.001)
);

blocks
(
    hex (0 1 2 3 11 12 13 14)
    (150 20 1)
    simpleGrading (0.2 0.2 1)

    hex (3 2 4 5 14 13 15 16)
    (150 20 1)
    simpleGrading (0.2 0.2 1)

    hex (2 7 6 4 13 18 17 15)
    (150 20 1)
    simpleGrading (0.2 0.2 1)
    
    hex (1 8 7 2 12 19 18 13)
    (150 20 1)
    simpleGrading (0.2 0.2 1)

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

mergePatchPairs
(
);

// ************************************************************************* //
Preview of Mesh
------------------------------------------------------------------

4.1) Result:

Velocity Pressure

4.2) Plot over line result:

Plot
------------------------------------------------------------------

5) Why Gradinf Factor is necessary?

Grading factor is a method in OpenFoam with which we can adjust the distribution of the mesh throught a block. This is necessary because as we know Finite volume method averages the values obtained throught the cell it is better to have as much as cell in a small area to get better result. Grading factor helps in this, when we requair a good resolution in a perticular part without adding more cells and decreasing the space step so that the CFL criteria is not voilated.

Grading gives better Resolution over the area where the results analysis is crucial.

In our case it is important to understanf the effects of flow near the step, So increasing the grading factor towars the steps helps us getting more accurate result near that reagion. Even if it means to compramising the qualiti of resolution at other areas.

6) Conclusion:

As we finish the simulation we can see the effects of grading on the solution, as the plot over line shows clearly there is a slight variations (Near the top in case2) (graded)) in the places where the mesh elemets are bigger. With this we can conclude the affects of solution(resolution) is proportional to the grading factor in a backwards facing step, using OpenFoam.

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.