Challenge

Week 8 - Simulation of a backward facing step in OpenFOAM

AIM:

To simulate an incompressible-laminar-viscous flow through the backward-facing step geometry. And to simulate with different mesh properties,

Case 1 - Simulate the flow without using any grading factor (i.e., GF = 1)

Case 2 - Simulate the flow with a grading factor of 0.2. The cells should be finer near the walls (including the step wall).

INTRODUCTION:

Incompressible flow:

The flow which does not has a change in density is called Incompressible flow.

Laminar flow:

Laminar flow is also called streamline flow. The flow which has velocity, pressure, and other properties will be the same at each point.

Mesh grading:

Mesh grading is a factor that is,

Grading factor = Size of last cell / Size of the first cell

STEPS TO RUN OpenFOAM:

  • Selecting the suitable solver and tutorial from the inbuilt tutorials.
  • Changing the mesh properties according to the problem.
  • Setting the case,
  • Assigning Boundary conditions.
  • Assigning Initial conditions.
  • Post-processing the results.

Procedure:

  • In this project, we are going to use icoFoam solver.
  • OpenFoam has icoFoam tutorials so we can use the tutorials and make changes according to the project.
  • Before running the simulation we need to create a run folder.
  • In the run folder, we need to copy the cavity folder and make changes in blockMeshDict, controlDict, pressure, and velocity files.
  • 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 21 vertices and 5 blocks while creating blocks we also need to specify the number of mesh points needed along the x, y, and z-direction and also the simple grading should be done along the boundaries.
  • then, we need to assign the boundary conditions here, we need to define all the faces in OpenFOAM 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 value of the velocity at the inlet type will be fixed value here we should assign some value as initial velocity and pressure will be zero gradients and at the outlet velocity type will be zero gradients and pressure will be type fixed value that value will be uniform 0, then at 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 nonslip and pressure type empty. And in the transport properties, we can change the nu value to obtain the lower courant number.
  • and then creating the block mesh and then run the simulation using the respective solver after the completion of the simulation open the paraview in the para form and plot the velocity profile for the given value.

OpenFoam Code:

Case 1:

blockMeshDict,

Simple grading factor = 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;
    object      blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

convertToMeters 0.1;

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

mergePatchPairs
(
);

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

Case 2:

blockMeshDict,

Simple grading factor = 0.2

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

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

mergePatchPairs
(
);

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

controlDict code:

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

deltaT          1e-3;

writeControl    timeStep;

writeInterval   20;

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:  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;
    }

    frontAndBack
    {
        type            empty;
    }
    
    noslipwall
    {
        
        type            zeroGradient;
        
    }
}

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

Velocity code:

/*--------------------------------*- 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 (0.066 0 0);
    }

    outlet
    {
        type            zeroGradient;
     }

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

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

Transport Properties Code:

/*--------------------------------*- 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    "constant";
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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



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

Results:

Case 1 Grading factor:

Mesh Generation:

Velocity Contour:

Pressure Contour:

Velocity plot:

Case 2 Grading Factor 0.2:

Mesh Generation:

Velocity Contour:

Pressure Contour:

Velocity plot:

Conclusion:

  • While changing the simple grading factor from 1 to 0.2 the mesh becomes finer and the results are very accurate.
  • The time execution for lower mesh grading factor is very high.
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.