Challenge

Week 8 - BlockMesh Drill down challenge

OBJECTIVE:

To create a geometry and simulate a 2D flow through a Backward Facing step using multiple meshes refining mesh grading factors inside BlockMeshDict file of BlockMesh using OpenFOAM.

Problem Statement:

Mesh specification

  1. Number of cells along the x direction (longer dimension) = 200
  2. Number of cells along the y direction = 10
  3. Use a graded mesh. Grading factor near all walls should be 0.2

THEORY:

Computational Fluid Dynamics (CFD) is the branch of CAE that simulates fluid motion and heat transfer using numerical approaches. The software we use here to simulate the flow is OpenFoam.

OpenFOAM (Open-source Field Operation And Manipulation) is a C++ toolbox for the development of customized numerical solvers, and pre-/post-processing utilities for the solution of continum mechanics problems, most prominently including Computational Fluid Dynamics(CFD).

Boudary Layer- It is the locus of the point at which the velocity of the fluid becomes equal to 99% of the freestream velocity. It is the region in the flow field inside which a fulid flows with high relative velocity. It is the region beyond which there exist no relative motion. The thickness of the boundary layer is the function of direction of flow. As the fluid flow propogates the nature of the Boundary layer also changes as per the type of flow depending wheather it is laminar, transient and turbulent.

Boundary layer separation:

It is nothing but the detachment of boundary layer from a surface. The fluid exerts a constant pressure on the surface once it has separated instead of a continually increasing pressure if still attached. Separation of the boundary layers occurs whenever the flow tries to decelerate quickly, that is whenever the outer pressure gradient is negative, or the pressure gradient is positive, sometimes referred to as an adverse pressure gradient

Flow separation occurs when the velocity at the wall is zero or negative and an inflection point exists in the velocity profile and a positive or adverse pressure gradient occurs in the direction of flow.

In fluid Dynamics, the no-slip condition for viscous fluids assumes that at a solid boundary, the fluid will have zero velocity relative to the boundary.The fluid velocity at all fluid–solid boundaries is equal to that of the solid boundary.

Operating System and Interface

Operating System used here is Linux - Ubuntu. Hence OpenFoam is a Command Line Interface (CLI), it uses text-based user interface (UI) used to view and manage computer files.

Commands Used:

tut - tutorial

app - applications

sol - solver

cp - copy

rm - remove

ls - list

gedit - used to open text editors

./ - Run

cd - Change directory

cd .. - Change to previous directory

mkdir - Make Directory

$FOAM_RUN - navigates to OpenFoam run directory

paraFoam - opens paraview where the simulation is represented

EXPLANATION:

Steps to be done

  • Choosing a Solver
  • Creating Geometry
  • Editing BlockMeshDict file
    A) Boundary Conditions
    B) Intial Conditions
    1) Pressure
    2) Velocity
  • Editing ControlDict file
  • Comparision of various Grading schemes
    Velocity Profile & Line Plot
  • Conclusion

Detail Explanation:

  1. The 'tutorial' folder in OpenFoam folder is opened and the 'incompressible' directory is opened.
  2. Then the 'cavity' is selected and opened, inside of which there exists another 'cavity' folder.
  3. This 'cavity' folder is copied into 'run' folder and renamed as 'Drill_down'
  4. Later on we navigate into 'solver' folder, inside of which there exists an 'incompressible' directory (similar to that in 'tutuorials')
  5. There is a solver called 'icoFoam' inside the 'incompressible'. This is the solver we are supposed to use for this simulation.
  6. Now we go to the 'run' folder, and open the 'Drill_down' directory.
  7. There will be 'p' and 'U' inside 'Drill_down'. The 'p' directory stands for pressure and it needs to be edited in gedit as per our requirements. The 'U' directory stands for Velocity and it also needs to be edited in gedit as per our requirements.
  8. Next the System directory is selected from directory 'Drill_down', inside of which there exists 'blockMeshDict' , 'controlDict', 'fvSchemes', 'fvSolutions'.
  9. The 'fvSchemes' and 'fvSolutions' are methods and need not be edited
  10. The 'blockMeshDict' has to be edited according to our part design which we have prepared and structured earlier in paper.
  11. The 'controlDict' also has to be edited according to our part design which we have prepared and structured earlier in paper.
  12. Next, we type in 'blockMesh' command to initiate the mesh.
  13. Then the solver which we have reffered to earlier is typed in as 'icoFoam'. The result is obtained. To get a graphical view type in 'paraFoam'.
  14. Do this for the grading factors 0.2, 0.5, 0.8.
  15. Then we compare velocity magnitude contours near the step region for the mesh grading factor of 0.2, 0.5, 0.8.
  16. Measure the velocity profile at 0.085 m from the inlet of the geometry.

Solver:

Since we need a solver which solves a Incompressible Laminar Navier Stokes Equation (Continuity and Momentum), we choose icoFoam which is present as an inbuilt directory in OpenFoam software.

Inside icoFoam solver, cavity is selected for the project.

Creating Geometry

The below SolidWorks figure represents the geometry to be created by using BlockMeshDict file (present in tutorial/systems) with the same specifications shown below

The BlockMeshDict file is modified to create geometry using Backward Facing Step. Hence it can only be done in blocks, we have considered it as 5 different blocks(1st pic) and the indexed the vertices(2nd pic) inas shown below.

1)Distribution of Blocks

2)Indexing the Vertices

BlockMeshDict file

/*--------------------------------*- 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)		//vertex no.0
    (0.08 0 0)		//vertex no.1
    (0.08 0.005 0)	//vertex no.2
    (0 0.005 0)	//vertex no.3
    (0.08 0.01 0)	//vertex no.4
    (0 0.01 0)		//vertex no.5
    (0.2 0.01 0)	//vertex no.6
    (0.2 0.005 0)	//vertex no.7
    (0.2 0 0)		//vertex no.8
    (0.2 -0.01 0)	//vertex no.9
    (0.08 -0.01 0)	//vertex no.10
    (0 0 0.001)	//vertex no.11
    (0.08 0 0.001)	//vertex no.12
    (0.08 0.005 0.001)	//vertex no.13
    (0 0.005 0.001)	//vertex no.14
    (0.08 0.01 0.001)	//vertex no.15
    (0 0.01 0.001)	//vertex no.16
    (0.2 0.01 0.001)	//vertex no.17
    (0.2 0.005 0.001)	//vertex no.18
    (0.2 0 0.001)	//vertex no.19
    (0.2 -0.01 0.001)	//vertex no.20
    (0.08 -0.01 0.001)	//vertex no.21
  
);

blocks
(
    //CODE SPLIT UP
    //Vertex no. hex()
    //no. of cells in (x y z)
    //streching of cells simpleGrading (x y z)
    
    hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (1 1 1)
    hex (3 2 4 5 14 13 15 16) (200 10 1) simpleGrading (1 1 1)
    hex (2 7 6 4 13 18 17 15) (200 10 1) simpleGrading (1 1 1)
    hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1 1 1)
    hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1 1 1)
);

edges
(
);

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

mergePatchPairs
(
);

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

A)Boundary Conditions

Here we have assigned the boundary conditions according to the vertices and mesh grading for the blocks by editing the BlockMeshDict file

The above file creates a Geometry which when viewed in parafiew is shown below.

B)Initial Condtions

Initial Conditions are assigned as per the Boundary Conditions. For this project there are two Initial Conditions. They are

  • Pressure
  • Velocity

1)Pressure Initial Condition

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

    front
    {
        type            empty;
    }

    Back
    {
        type            empty;
    }

    Top
    {
        type            zeroGradient;
    }
    
    Bottom
    {
        type            zeroGradient;
    }    
    
    Stepside
    {
        type            zeroGradient;
    }    
}
}

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

2)Velocity Initial Condition

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

    front
    {
        type            empty;
    }

    Back
    {
        type            empty;
    }

    Top
    {
        type            noSlip;
    }
    
    Bottom
    {
        type            noSlip;
    }    
    
    Stepside
    {
        type            noSlip;
    }    
    
}

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

ControlDict file

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

deltaT          0.0001;

writeControl    timeStep;

writeInterval   1000;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Data Taken:

Simulation Time : 0 to 1 second

dt : 0.001 second

Interval : Stored for every 1000 steps

COMPARISION OF VARIOUS GRADING SCHEMES

A)Velocity Profile

Grading Scheme 1(Default)

Grading Scheme 0.2

In order to increase the Grading scheme to 0.2 from default, we have to modify code in the BlockMeshDict file. The change of code in the particulate section is given below:

blocks
(
    //CODE SPLIT UP
    //Vertex no: hex ()    
    //no. of cells in (x y z)
    //streching of cells simpleGrading (x y z)        

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

);

Velocity Contour

Grading Scheme 0.5

Similary as represented in the previous Scheme, code is modified accordingly to change the Grad to 0.5.

blocks
(
    //CODE SPLIT UP
    //Vertex no: hex ()    
    //no. of cells in (x y z)
    //streching of cells simpleGrading (x y z)        

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

);

Velocity Contour

Grading Scheme 0.8

Similar Changes as stated in previous section have been modified to change the grade to 0.8

blocks
(
    //CODE SPLIT UP
    //Vertex no: hex ()    
    //no. of cells in (x y z)
    //streching of cells simpleGrading (x y z)        

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

);

Velocity Contour

CONCLUSIONS:

From the above Velocity Contours and Line plots, we can conclude that

  • When the fluid crosses the step region, the area increases.
  • There is not much difference in the velocity magnitudes in all the cases, however on a magnified scale we can see slight variations around the boundaries because of the presence of close grid spacing resulting in finer results.
  • But due to the accurate results at the edge, we could see the flow affected at the center of the region.
  • Grading Scheme 0.2 shows wider and cleaner curve as the velocity drops.
  • Overall all Grading Schemes gives same results, but due to the mesh grading factor we can say that Velocity Gradient at 0.2 shows more accurate finer results compared to other grading schemes.
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.