Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

Aim:

  • To simulate an incompressible –laminar-viscous flow through the backwards –facing step geometry and perform a transient solution.
  • Case_1 – To simulate the flow without using any grading factor (i.e.,GF=1)
  • Case_2- to simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step walls).

Incompressible laminar –viscous -flow

Incompressible flow

The flow in which there is no change in density is called the incompressible flow.

Mathematically. an incompressible flow can be expressed as

Laminar flow:

A laminar flow is one where the fluid motion is regular and there is no mixing. It can be visualized by the path lines that do not intersect each other.

In fluid dynamics, laminar flow is characterized by fluid particles following smooth paths in layer, with each layer moving smoothly past the adjacent layers with little or no mixing

At low velocities, the fluid tends to flow without lateral mixing, and adjacent layers slide past one another like playing cards. There are no cross-currents perpendicular to the direction of flow, nor eddies or swirl of fluids.

In laminar flow, the motion of the particles of the fluid is very orderly with particles close to a solid surface moving in straight lines parallel to that surface. Laminar flow is a flow regime characterized by high momentum diffusion and low momentum convection.

Reynolds number is the parameter to differentiate a flow as laminar or turbulent.

Whenever the Reynolds number is less than about 2000, flow in a pipe is laminar, whereas at values greater than 2000 flow is usually turbulent .

Mathematically , Reynolds number is the ratio of internal force to the viscous force.

Where,

  • is the density of the fluid (kg/m³)
  • is the flow speed (m/s)
  • is the characteristics linear dimension (m)
  • is the dynamic viscosity of the fluid (Pa.s or N.s/m²or kg/m-s)
  • is the kinematic viscosity of the fluid (m²/s)

Viscosity flow:

A type of fluid flow in which there is a continuous steady state motion of particles, the motion at a fixed point always remain constant. Also called stream line flow, laminar flow, steady flow.

The fluid flow in form of layer. The layer which sticks with the walls has zero velocity which is called no slip condition and it develops the frictional effect of the wall. Frictional effects are also present between two layers of fluid and slower tries to slow down the faster layer which can be measured by viscosity.

Effects of viscosity are maximum near the boundary so laminar sub layer exists near the boundary that is shown in the below figure.

Mesh Grading

Mesh Grading is the factor that is

Grading Factor

Procedure:

  • First, we are creating a run folder in OPEN FOAM in which we will running our simulations.
  • And then need to copy the cavity folder to the run folder so that we can make the changes nin the blockMeshDict, ControlDict,and pressure and velocity files torun our required simulations we copying the folder because we are not supposed to make any changes in the original folder in the Open FOAM.

  • Then will make the required changes in the blockmeshDict file that is naming the vertices for and then creating the blocks in this case there are 21vertices and then 5 blocks while creating blocks we also need to specify the specify the number of mesh points needed along the x, y and z -direction and also the simple grading should be along the boundaries.

  • Then we need to assign the boundary conditions here, we need to define all the faces in Open FOAM refers to patches and giving them type that is the inlet and outlet will be the faces (type patch) ,for front and back type will be empty faces , for top and bottom which are the boundary conditions in this case type will be wall type and setting up these will constitute a particular boundary , then will save these changes in the blockMeshDict.

  • Then in the velocity and pressure files,we have to give the values of the velocity at the inlet type will be fixed value here we should assign some values as initial velocity and pressure will be zerogradient and the outlet velocity type will be zerogradient and pressure will be type fixed values that values will be uniform 0. then the front and back velocity type empty and pressure as well as type empty at the no slip boundaries that is top and bottom velocity will be type no slip and pressure type empty .And in the transport properties we can change the nu value in order to obtain the lower courant number.

  • And in the ContorlDict file the simulation time and the time step need to be assigned n the way that the courant number should be less 0.5

  • And then creating the blockmesh and then run the simulation usingthe respective solver after the completion of simulation open the paraview in the paraFoam and plot the velocity profile for the given value.

CODE:

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

// Note: this file is a Copy of $FOAM_TUTORIALS/resources/blockMesh/pitzDaily

convertToMeters 0.001;

vertices
(
    (-20.6 0 -0.5)
    (-20.6 25.4 -0.5)
    (0 -25.4 -0.5)
    (0 0 -0.5)
    (0 25.4 -0.5)
    (206 -25.4 -0.5)
    (206 0 -0.5)
    (206 25.4 -0.5)
    (290 -16.6 -0.5)
    (290 0 -0.5)
    (290 16.6 -0.5)

    (-20.6 0 0.5)
    (-20.6 25.4 0.5)
    (0 -25.4 0.5)
    (0 0 0.5)
    (0 25.4 0.5)
    (206 -25.4 0.5)
    (206 0 0.5)
    (206 25.4 0.5)
    (290 -16.6 0.5)
    (290 0 0.5)
    (290 16.6 0.5)
);

negY
(
    (2 4 1)
    (1 3 0.3)
);

posY
(
    (1 4 2)
    (2 3 4)
    (2 4 0.25)
);

posYR
(
    (2 1 1)
    (1 1 0.25)
);


blocks
(
    hex (0 3 4 1 11 14 15 12)
    (18 30 1)
    simpleGrading (0.5 $posY 1)

    hex (2 5 6 3 13 16 17 14)
    (180 27 1)
    edgeGrading (4 4 4 4 $negY 1 1 $negY 1 1 1 1)

    hex (3 6 7 4 14 17 18 15)
    (180 30 1)
    edgeGrading (4 4 4 4 $posY $posYR $posYR $posY 1 1 1 1)

    hex (5 8 9 6 16 19 20 17)
    (25 27 1)
    simpleGrading (2.5 1 1)

    hex (6 9 10 7 17 20 21 18)
    (25 30 1)
    simpleGrading (2.5 $posYR 1)
);

edges
(
);

boundary
(
    inlet
    {
        type patch;
        faces
        (
            (0 1 12 11)
        );
    }
    outlet
    {
        type patch;
        faces
        (
            (8 9 20 19)
            (9 10 21 20)
        );
    }
    upperWall
    {
        type wall;
        faces
        (
            (1 4 15 12)
            (4 7 18 15)
            (7 10 21 18)
        );
    }
    lowerWall
    {
        type wall;
        faces
        (
            (0 3 14 11)
            (3 2 13 14)
            (2 5 16 13)
            (5 8 19 16)
        );
    }
    frontAndBack
    {
        type empty;
        faces
        (
            (0 3 4 1)
            (2 5 6 3)
            (3 6 7 4)
            (5 8 9 6)
            (6 9 10 7)
            (11 14 15 12)
            (13 16 17 14)
            (14 17 18 15)
            (16 19 20 17)
            (17 20 21 18)
        );
    }
);
mergepatchpairs	
(
);
// ************************************************************************* //

BLOCK MESH WITH GRADING FACTOR 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.01;

vertices
(
    (0 0 0)
    (8 0 0)
    (8 0.5 0)
    (0 0.5 0)
    (8 1 0)
    (0 1 0)
    (20 1 0)
    (20 0.5 0)
    (20 0 0)
    (20 -1 0)
    (8 -1 0)
    (0 0 0.6)
    (8 0 0.6)
    (8 0.5 0.6)
    (0 0.5 0.6)
    (8 1 0.6)
    (0 1 0.6)
    (20 1 0.6)
    (20 0.5 0.6)
    (20 0 0.6)
    (20 -1 0.6)
    (8 -1 0.6)
    
);

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

CONTROL DICT :

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

deltaT          1e-3;

writeControl    runTime;

writeInterval  0.5;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Pressure Code:

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

    noslipWall
    {
        type            zeroGradient;
    }

    frontANDBack
    {
        type            empty;
    }
}

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

Velocity Code:

/*--------------------------------*- 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 (0.066 0 0);
    }
    outlet
    {
         type           zeroGradient;
    }
    noslipWall
    {
        type            noSlip;
    }

    frontANDBack
    {
        type            empty;
    }
}

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

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] 1e-6;


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

Block Mesh without Grading Factor:

Velocity Without grading Factor:

Pressure Without Grading Factor:

Block Mesh With Grading Factor 0.2:

Pressure with Grading Factor:

Velocity with Grading Factor:

The pot ofbthe velocity is 0.085 without applying Grading Factor.

The pot ofbthe velocity is 0.085 with applying Grading Factor 0.02 are as follows:

Conclusion:

By changing the simple grading factor from the value 0.2 to 1 the mesh becomes finer and solution becomes accurate.

Overall the change in the size of simple grading factor (mesh size) the result remains the same as approximately.

The execution time lower for lower Meshing grading factor

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.