Challenge

Week 8 - BlockMesh Drill down challenge

BlockMesh Challenge for various Mesh grading factor

Objectives:

1) To create the mesh using the specific tutorial from OpenFoam tutorial directory.

2) To make refiniment in the mesh by using refiniment factor as 0.2,0.5 and 0.5.

3) To run the simulation for each refined mesh and plot the graph of velocity magnitude vs Mesh grading factor.

4) Comparing velocity magnitude factor near the step.

Inputs for Meshing:

1) Meshing is considered as in the 2D domain.

2) Domain should be divided in 200 parts for X-axis.

3) Domain should be divided in 10 parts for Y-axis.

4) Use the grading factor as 0.2,0.5 and 0.8 near all the walls in geometry.

Selection of Tutorial.

The tutorial which is used for the above case is cavity from incompressible transient solver. Belowe command line show the way to navigate to it:

shubham@shubham-OP:~$ foam
shubham@shubham-OP:/opt/openfoam8$ tut
shubham@shubham-OP:/opt/openfoam8/tutorials$ ls
Allclean  Alltest  combustion    discreteMethods  electromagnetics  heatTransfer    IO          mesh        resources
Allrun    basic    compressible  DNS              financial         incompressible  lagrangian  multiphase  stressAnalysis
shubham@shubham-OP:/opt/openfoam8/tutorials$ cd incompressible
shubham@shubham-OP:/opt/openfoam8/tutorials/incompressible$ ls
adjointShapeOptimizationFoam  icoFoam              pimpleFoam  porousSimpleFoam  simpleFoam     SRFSimpleFoam
boundaryFoam                  nonNewtonianIcoFoam  pisoFoam    shallowWaterFoam  SRFPimpleFoam
shubham@shubham-OP:/opt/openfoam8/tutorials/incompressible$ cd icoFoam
shubham@shubham-OP:/opt/openfoam8/tutorials/incompressible/icoFoam$ ls
cavity  elbow
shubham@shubham-OP:/opt/openfoam8/tutorials/incompressible/icoFoam$ cp -r cavity/ $FOAM_RUN/ cavity_run1
cp: target 'cavity_run1' is not a directory
shubham@shubham-OP:/opt/openfoam8/tutorials/incompressible/icoFoam$ cp -r cavity/ $FOAM_RUN/cavity_run1
shubham@shubham-OP:/opt/openfoam8/tutorials/incompressible/icoFoam$ cd
shubham@shubham-OP:~$ cd $FOAM_RUN
shubham@shubham-OP:~/OpenFOAM/shubham-8/run$ ls
cavity_run1  cavity_test1  pitzDaily
shubham@shubham-OP:~/OpenFOAM/shubham-8/run$ cd cavity_run1
shubham@shubham-OP:~/OpenFOAM/shubham-8/run/cavity_run1$ ls
Allclean  Allrun  cavity  cavityClipped  cavityGrade
shubham@shubham-OP:~/OpenFOAM/shubham-8/run/cavity_run1$ cd cavity
shubham@shubham-OP:~/OpenFOAM/shubham-8/run/cavity_run1/cavity$ ls
0  constant  system
shubham@shubham-OP:~/OpenFOAM/shubham-8/run/cavity_run1/cavity$ cd system
shubham@shubham-OP:~/OpenFOAM/shubham-8/run/cavity_run1/cavity/system$ ls
blockMeshDict  controlDict  fvSchemes  fvSolution
shubham@shubham-OP:~/OpenFOAM/shubham-8/run/cavity_run1/cavity/system$ ll
total 24
drwxr-xr-x 2 shubham shubham 4096 Aug 11 22:43 ./
drwxr-xr-x 5 shubham shubham 4096 Aug 11 22:43 ../
-rw-r--r-- 1 shubham shubham 1307 Aug 11 22:43 blockMeshDict
-rw-r--r-- 1 shubham shubham 1045 Aug 11 22:43 controlDict
-rw-r--r-- 1 shubham shubham 1067 Aug 11 22:43 fvSchemes
-rw-r--r-- 1 shubham shubham 1171 Aug 11 22:43 fvSolution

1) First we will open the terminal which is best way to navigate to the specific location in Unix operating system.

2) Then enter the 'foam' command to navigate in the openFoam directory.

3) Use the 'tut' shortcut to enter in tutorials of openFoam software. Use 'ls' command to list out all the tutorials in the openfoam which are arranged as per the solver names mostly.

4) Use 'cd' command to enter in specific tutorial folder, in our case we are using incompressible tutorials.

5) In incompressible tutorial folder navigate to icoFoam solver tutorial exmaples and inside it list for cavity folder.

6) Copy cavity folder using command 'cp -r <folder name> / <Copy location folder name>/ <rename>'.

Note: Don't run the any case file in OpenFoam tutorials as it will create confusion to the user while navigating.

5) We have copied the cavity folder as 'cavity_run1' in the FOAM_RUN folder which has been created while installing the openfoam.

6) In the same directory of cavity_run1 navigate to the cavity folder and then to the system folder in which we will find blockMeshDict file.

7) While running the blockMesh command make sure you are in the right directory.

Note: Running the blockMesh command in the cavity_run1 directory it will provide the error message of controlDict. Because in the cavity_run1 folder there are subcases provided which are interdependent.

8) The icoFoam is the solver used for incompressible transient flow in which it uses implicit approach to solve continuity and momentum equation. The input required for solver are kinematic pressure and velocity.

Meshing:

For the meshing use 'gedit' command to open the blockMeshDict file from the system folder. The dimension of the domain is given below.

From the above figure we will create the geomtry by using points in three direction x, y and z keeping z direction as nominal as possible. The hexa mesh can be created in the geomtry by using hex command in the blockMeshDict file. The file is given as:

/*--------------------------------*- 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.01;

vertices
(
    (0 0 0)		//P0
    (8 0 0)		//P1
    (8 0.5 0)		//P2
    (0 0.5 0)		//P3	
    (0 1 0)		//P4
    (8 1 0)		//P5
    (20 1 0)		//P6
    (20 0.5 0)		//P7
    (20 0 0)		//P8
    (20 -1 0)		//P9
    (8 -1 0)		//P10
    (8 0 0.05)		//P11
    (0 0 0.05)		//P12
    (0 0.5 0.05)	//P13
    (8 0.5 0.05)	//P14
    (8 1 0.05)		//P15
    (0 1 0.05)		//P16
    (20 1 0.05)	//P17
    (20 0.5 0.05)	//p18
    (20 0 0.05)	//p19
    (20 -1 0.05)	//P20
    (8 -1 0.05)	//P21	
);

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

edges
(
);

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

mergePatchPairs
(
);

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

In above blockMeshDict txt file it is written for without any grid factor. In the bracket of simplegrading as we can see there in no grade applied in each of the direction.

After running only blockMesh command in the terminal we will get the output of Meshing in paraview as:

From the above figure we can say that according to the dimension given we have developed the mesh accordingly.

Boundary Condition:

After checking the mesh is okay and as per the requirement, boundary conditions has to be changed as per written in blockMeshDict file. The boundary condition files are present in the '0' folder of cavity tutorial. It is named as zero because it stored the initial conditions. The first initial condition is pressure which is given as:

/*--------------------------------*- 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;
    }
    topandbottom
    {
    	type		 zeroGradient;
    }
}

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

From the above file we can see that we have provided the outlet pressure as fixed value. Similarly velocity boundary condition is given as:

/*--------------------------------*- 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.5 0 0);
    }

    outlet
    {
        type            zeroGradient;
    }

    front
    {
        type            empty;
    }
    back
    {
    	type		 empty;
    }
    topandbottom
    {
    	type		 noSlip;
    }
}

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

In above file as we can see the velocity is applied only in x-direction which is of 1.5.

After assigning the proper boundary condition and creating the mesh we need to take care for the control of solution by providing the time and time step value for the simulation. This can be done by editing the controlDict file present in system folder.

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

deltaT          1e-05;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

The end solution time for the simulation is 0.05 seconds and the step size is taken as 1e-5 to get the convergence.

Results:

1) Mesh without grading factor.

In above image we can see the velocity contour in the domain. It has started from inlet and increased in the upto 2.2 m/sec and then shaded away after the step profile of geometry. To check the velocity magnitute around to the location specified in the problem which is 0.085 distance from the inlet, we need to create the line plot to get into details.

For the line plot select this icon in the paraview and select the start point and end point accordingly.

So as we can see in above plot, the velocity get increases somewhere above the step profile of domain and then gradually decreasing because of intertial effects.

2) Mesh with Grading factor as 0.2

For the mesh as grading factor as 0.2 the simpleGrading command for the blockMeshDict file can be written as:

    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)

The mesh can be view as:

The result for the velocity magnitude contour is:

The plot for the same can be given as:

3) Mesh with Grading factor as 0.5

For the mesh as grading factor as 0.5 the simpleGrading command for the blockMeshDict file can be written as:

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

The Mesh representation for above grading factor is:

The velocity magnitude contour for above grading factors is given as:

And the plot for the same can be viewed as:

4) Mesh with Grading factor as 0.8

For the mesh as grading factor as 0.5 the simpleGrading command for the blockMeshDict file can be written as:

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

The Mesh representation for above grading factor is:

The velocity magnitude contour for above grading factors is given as:

And the plot for the same can be viewed as:

Conclusion:

1) As the each refiniment factor is increased the plot is shifted toward the right hand side very sligtly.

2) To compare the peak value for each of the meshing factor in table is given as:

Meshing Grading Factor Velocity Magnitude peak Pressure at respective point
0.2 1.67489 27.9594
0.5 1.67768 27.9799
0.8 1.67808 27.9794
1 1.67125 28.1055

From above table we can say that with good refiniment factor the value get more accurate toward the actual one.

3) Comparing the value over the step for velocity magnitude we can see that from the figures, for the 0.2 as grading factor the flow get lower near to the step point and as we increase the grading factor the flow get lower some distance away from step point.

In above figure as we can see, we are comparing each of the case starting with top for 0.5 mesh grading factor, in the middle 0.2 grading factor and at bottom 0.8 grading factor. Hence from above image as it we can see the degradation of velocity near to step is more in 0.2 grading factor than rest of the two.

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.