Challenge

Week 8 - BlockMesh Drill down challenge

Objective: Create the geometry and mesh using BlockMesh and use the OpenFOAM software to show variations in velocity and pressure gradients with changes in mesh grading factor using paraView for post-processing.

Mesh Specifications

  1. Number of cells along the x-direction(horizontal) = 200
  2. Number of cells along y-direction(vertical) =10
  3. Graded mesh factors = 0.2, 0.5 ,0.8.

Geometry in 2D with dimensions-

General Theory

OpenFOAM (for “open-source Field Operation And Manipulation”) is C++ toolbox available on Linux platform for development of numerical solvers and pre/post processing utilities for solution of continuum mechanics problems, mostly computational fluid dynamics .

OpenFOAM comes with a suite of tutorials along with its solver. The tutorials encompass different physical scenarios and approximations to solving e.g.- incompressible flows and compressible flows. If in our problem we use a liquid flow where temperature variation and heat transfer are negligible density remains constant for all practical purposes therefore computation time can be reduced by using an incompressible solver.

Advantages of using OpenFOAM

  • User friendliness – code meticulously organized and easily manipulatable.
  • Tutorials available for beginners.
  • Solvers, preprocessors, and post processors all available under one roof.
  • Ability to import complex mesh files from ANSYS.
  • Unstructured polyhedral grid capabilities
  • Training provided by developers.
  • No license costs

Disadvantages of using OpenFOAM

  • Absence of integrated Graphical User Interface (GUI) as opposed to ANSYS Fluent for instance.
  • New application development can be tedious and slow.
  • Knowledge of Linux terminal required.

Steps followed –

  1. Installed Linux operating system along with terminal in a virtualBox
  2. Opened terminal and proceeded to the openFOAM tutorials section.
  3. Incompressible – icoFoam- cavity – cavity.
  4. The cavity folder was copied to $FOAM_RUN page in order to not disturb the original openFOAM tutorials. ‘cp -r cavity/$FOAM_RUN’.
  5. Once the cavity folder was copied, the blockMeshDict file was modified as shown. The mesh refinement factors were applied in such way as to increase the cell concentration near the step . Reciprocals were used to get correct direction . The step area was chosen since it is prone to turbulence and is the area of interest.
  6. ControlDict was modified as well. The time step was arrived after calculating the courant number.
  7. Boundary conditions in the ‘0’ folder of ‘U’ and ‘P’ was modified as shown.
  8. Blockmesh command excuted and results visualized using paraFoam .
  9. IcoFoam solver ran and gave the results in an approximate 9 minutes of simulation run time.
  10. Appropriate post processing and data exporting done using paraView and ‘plot line’.
  11. The graphs were plotted in MATLAB through importing.

Numbering scheme-

Structure as viewed in paraView

Mesh for grading factor = 0.5 , however other factors also appear similar . Concentration is increased near the step.

Velocity initial condition

Pressure initial condition

Velocity final ( approaching steady state)

Pressure final (approaching steady state)

Plots depecting the values along with the y-axis (height) at the step ( x= 0.085)

Grading factor -0.8

Velocity-

Pressure-

Grading Factor -0.5

Velocity-

Pressure-

Grading Factor -0.2

Velocity-

Pressure-

Post -processing results and conclusion

  • As it can be seen for three cases the velocity values are in close agreement however their difference is also apparent.
  • A higher impact of mesh grading is observed on pressure (scalar).
  • The values given by the 0.2 meshing must be considered as this is the most aggressive mesh refinement and would therefore give the most accurate results.

Comparison

Parameter

Grading factor -0.2

Grading factor -0.5

Grading factor -0.8

Velocity Magnitude

0.7657

0.7715

0.7742

Pressure

16.8369

16.9231

16.8846

Velocity magnitude-

Pressure -

C++ script used in Linux Terminal

BlockMeshDict - factor of 0.8-

/*--------------------------------*- C++ -*----------------------------------*
  =========                 |
  \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \    /   O peration     | Website:  https://openfoam.org
    \  /    A nd           | Version:  7
     \/     M anipulation  |
*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    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 1)
    (8 0 1)
    (8 0.5 1)
    (0 0.5 1)
    (8 1 1)
    (0 1 1)
    (20 1 1)
    (20 0.5 1)
    (20 0 1)
    (20 -1 1)
    (8 -1 1)
    
);

blocks
(
    hex (0 1 2 3 11 12 13 14) (200 10 1) simpleGrading (0.8 1.25 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.25 0.8 1)
    hex (1 8 7 2 12 19 18 13) (200 10 1) simpleGrading (1.25 1.25 1)
    hex (10 9 8 1 21 20 19 12) (200 10 1) simpleGrading (1.25 1.25 1)
);
boundary
(
	noslipWall
	{
		type wall;
		faces
		(
			(15 4 5 16)
			(17 6 4 15)
			(21 12 1 10)
			(11 0 1 12)
			(21 10 9 20)
		);
	}
	
	
	
	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)
			(2 4 6 7)
			(1 2 7 8)
			(10 1 8 9)
			(12 13 14 11)
			(13 15 16 14)
			(18 17 15 13)
			(19 18 13 12)
			(20 19 12 21)
		);
	}
		
);

edges
(
);

mergePatchPairs
(
);

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

BlockMeshDict for factor 0.5-

/*--------------------------------*- C++ -*----------------------------------*
  =========                 |
  \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \    /   O peration     | Website:  https://openfoam.org
    \  /    A nd           | Version:  7
     \/     M anipulation  |
*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    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 1)
    (8 0 1)
    (8 0.5 1)
    (0 0.5 1)
    (8 1 1)
    (0 1 1)
    (20 1 1)
    (20 0.5 1)
    (20 0 1)
    (20 -1 1)
    (8 -1 1)
    
);

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

edges
(
);

mergePatchPairs
(
);

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

BlockMeshDict for factor 0.2-

/*--------------------------------*- C++ -*----------------------------------*
  =========                 |
  \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \    /   O peration     | Website:  https://openfoam.org
    \  /    A nd           | Version:  7
     \/     M anipulation  |
*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    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 1)
    (8 0 1)
    (8 0.5 1)
    (0 0.5 1)
    (8 1 1)
    (0 1 1)
    (20 1 1)
    (20 0.5 1)
    (20 0 1)
    (20 -1 1)
    (8 -1 1)
    
);

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

edges
(
);

mergePatchPairs
(
);

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

ControlDict-

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

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.6;

deltaT          0.00001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

Initial Conditions 
Velocity

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

    noslipWall
    {
        type            noSlip;
    }

    frontAndBack
    {
        type            empty;
    }
}

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

Pressure -
/*--------------------------------*- C++ -*----------------------------------*
  =========                 |
  \      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \    /   O peration     | Website:  https://openfoam.org
    \  /    A nd           | Version:  7
     \/     M anipulation  |
*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    noslipWall
    {
        type            zeroGradient;
    }

   inlet
   {
   	type		zeroGradient;
   }
    outlet
    {
    	type		fixedValue;
    	value 		uniform 0;

    frontAndBack
    {
        type            empty;
    }
}

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

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.