Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Objective : to simulate an incompressible-laminar-viscous flow through the backward facing step geometry and to perform transient simulation

There are two cases.

i) No grading factor (i.e GF = 1)

ii) Grading Factor GF=0.2

The flow is Incompressible-laminar-viscous flow.

The Incompressible flow is the one in which there volume strain rate is zero. Volume strain rate is given by

ie. divergence of veloctiy vector is zero.

So, in the case of incompressible flow, volume strain rate becomes zero. (no change in density is special case of incompressible fluid flow).

In the laminar flow, fluid particles move in smooth paths in layers. Viscous force dominates inertial force.

The distinction between laminar flow and turbulent flow can be shown by using Reynolds Number.

The internal flow in this case is laminar till Re=2000. After that it enters transition region and if Re>4000, it becomes turbulent.

Internal Flow:

In the internal flow, as shown above, the velocity profile keeps on changing until the flow is fully developed. When it becomes fully developed, its profile becomes parabolic in nature as shown above. Such flows are governed by pressure gradient across the tube/pipe and it is used to overcome the shear resistance offered by viscocity and by performing this analysis , we get the parabolic profile of velocity in the fully developed region.

Procedure:

1. We create Run folder in which we run the simulation.

2. This is done so that whatever changes we do in the tutorial problems of OpenFOam, do not affect the original files in tutorials.

3. We copy the cavity tutorial in the run folder and start making changes in its files one by one.

4. First the changes are done in the blockMeshDict file. Here blocks are defined by using right hand rule and then mesh size is also defined. Grading is also defined to make the mesh size fine or coarse wherever needed. Surface types are defined in terms of patch, wall etc depending on whether the surface is inlet or a simple wall

5. After this, controlDict file is opened in which parameters like simulation time (end time), timestep can be changed as per the simulation requirements.

6. In the Constant directory, in the transport directory file, fluid properties which are constant throughout simulation are mentioned (like Viscocity).

7. similarly, in the zero folder, where the initialization is done and initial velocity of pressure and velocity are given and then the respective solver is run (here icoFoam) and results are obtained and they can be seen by opening paraFoam.

Code :

Without Applying Grade Factor:

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

convertToMeters 0.001;

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

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

mergePatchPairs
(
);

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

Meshing of the body under consideration

Velocity profile for Grading Factor =1

Velocity profile at x=0.085 by using plot over line command

Pressure distribution for the backward facing step for GF=1

for a simulation with Grading Factor GF =0.2

blockMeshDict code for GF=0.2

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

convertToMeters 0.001;

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

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

mergePatchPairs
(
);

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

velocity profile for GF=0.2

pressure profile for GF=0.2

velocity profile at x=0.085

codes of files common for the configurations:

Pressure ( zero (0) directory):

/--------------------------------- C++ -----------------------------------\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  9
     \\/     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 code ( zero directory):

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

    frontAndBack
    {
        type            empty;
    }
    
    noslipwall
    {
       type             noSlip;
    }
}

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

code for transport properties:

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

nu              [0 2 -1 0 0 0 0] 0.01;


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

code for controlDict:

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.0001;

writeControl    timeStep;

writeInterval   100;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Conclusion:

1. the parabolic nature of velocity profile can be clearly seen

2. By changine the GF and thus making grid finer, we can clearly see the higher accuracy in the velocity value ( can be chacked from x=0.085 graphs for both cases)

3. overall other results are mostly same

4. computational time increases when grid size becomes finer.

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.