Challenge

Week 8 - BlockMesh Drill down challenge

Aim: Simulating a 2-D pipe flow on a backward facing step

Objectives:

  • Creating a geometry (backward facing step), defining its mesh using blockMesh object in OpenFOAM for the given specifications.
  • Using the icoFoam solver (in OpenFOAM) for the geometry to obtain the solution.
  • Determining the velocity profile and effect of mesh grading factor on the velocity profile; thus plotting the results.

Theory:

OpenFOAM (acronym for Open Source Field Operation and Manipulation) is a C++ toolbox for the development of customised numerical solvers, and pre/postprocessing utilities for the solution of continuum mechanics problems, most prominently the CFD problems.

icoFoam solves the incompressible laminar Navier-stokes equations using the PISO algorithm. The code is inherently transient, requiring an initial condition (such as zero velocity) and boundary conditions.

The problem statement for this challenge; we have a backward facing step, over which we'll be solving the incompressible laminar Navier-stokes equation using the icoFoam solver. The steps involved in simulation are:

  1. Creating geometry and mesh using nodes and blocks.
  2. Setting the solver parameters.
  3. Initial conditions.
  4. Solving and post-processing the results.

The set-up:

The geometry defined for this problem is as shown:

For creation of required geometry, we divide it into five blocks. As we are interested in 2-D analysis, we choose a very small thickness for the domain. Thus, the blocks are set using the nodal coordinates as shown above. The names of different walls are defined. The leftmost boundary forms the inlet, rightmost boundary forms the outlet. The front and back walls are set as empty to make it behave like a 2-D domain. The boundaries are defined using node numbers in cyclic arrangement such that the normal to each of the faces points outwards of the domain. These definitions are defined in the blockMeshDict file.

Now that we have defined the we need to set up a solver that would be implemented for our test case. The details for the solver and analysis is stored in controlDict file.
Although the boundary conditions were set in the blockMeshDict file, we still need to specify the initial conditions. For this, we create a folder 0 (which indicates `t=0`). The solver would read the initial conditions form this file(s).

Code:

The codes are in C++ (files for OpenFOAM)

blockMeshDict:

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

convertToMeters 0.01;

vertices
(
    (0 0 0) //vertices 0
    (8 0 0) //vertices 1
    (8 0.5 0) //vertices 2
    (0 0.5 0) //vertices 3
    (0 1 0) //vertices 4
    (8 1 0) //vertices 5
    (20 1 0) //vertices 6
    (20 0.5 0) //vertices 7
    (20 0 0) //vertices 8
    (20 -1 0) //vertices 9
    (8 -1 0) //vertices 10

    (8 0 0.1) //vertices 11
    (0 0 0.1) //vertices 12
    (0 0.5 0.1) //vertices 13
    (8 0.5 0.1) //vertices 14
    (8 1 0.1) //vertices 15
    (0 1 0.1) //1vertices 16
    (20 1 0.1) //vertices 17
    (20 0.5 0.1) //vertices 18
    (20 0 0.1) //vertices 19
    (20 -1 0.1) //vertices 20
    (8 -1 0.1) //vertices 21
);

blocks
(

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

edges
(
);

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

mergePatchPairs
(
);

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

controlDict:

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.05;

deltaT          1e-05;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Initial Conditions:

Velocity-Object: U

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  5                                     |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     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 (3 0 0);
    }

    outlet
    {
        type            zeroGradient;
    }

    front
    {
        type            empty;
    }

    Back
    {
        type            empty;
    }

    topandbottom
    {
        type            noSlip;
    }

}


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

Pressure-Object: p

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

}

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

Outputs:

For mesh grading factor - 0.2

Mesh

Velocity Contour

Pressure Contour

For mesh grading factor - 0.5

Mesh

Velocity contour

Pressure contour

For mesh grading factor - 0.8

Mesh

Velocity contour

Pressure contour

Result/Conclusion:

  • From the above graphs and images, it is evident that mesh grading factor has almost negligible effect on pressure and velocity contour but we can observe that when the mesh grading factor is 0.2, the velocity at walls approaches zero more accurately, but in this case, velocity of interiors is quite discretized. Mesh grading factor of 0.8 shows exactly opposite results.
  • For no-slip boundary condition, we must have observed a parabolic profile, but the profile is shifted to the right. This happens due to sudden change of cross sectional area, thus wakes are formed which alter the profile.
  • A special care should be taken while choosing the time step in the controlDict object. If Courant number exceeds unity, then the solution will get unstable and can make the program crash or stop unexpectedly (which can be an annoying experience). Thus, a time step, that can keep the Courant number less than unity is required to obtain the results.

References:

  • Introduction to CFD using MATLAB and OpenFOAM - course provided by Skill Lync
  • BluCFD - FS Dynamics
  • OpenFOAM.org - OpenFOAM Foundation
  • Supporting Material: OpenFOAM documentation - OpenFOAM Foundation
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.