Project

BlockMesh Drill down challenge

AIM :- For th e following diagram, use the icoFoam from incompressible solver to simulate the flow through Backward facing step. You will be creating multiple meshes and will be comparing the results obtained from each mesh.

Mesh Specifications :-

1. Number of cells along the X-direction (longer dimension) =200mm

2. Number of cells along the Y-direction = 10mm

3. Use the Graded Mesh. Grading factor near all walls should be 0.2.

Boundary Condition Specification :-

Follow the specifications that are provided in the following figure.

Desired Output :-

1. How does the velocity magnitude profile change as a function of mesh grading factor. Use factors 0.2, 0.5, 0.8.

2. Measure the velocity profile at 0.085m from the inlet of the geometry.

3. Plot must be a line plot.

4. Compare velocity magnitude contours near the step region for the above mentioned grading factors.

EXPLAINATIONS :-

First off all I created 5-different blocks and numbering and rotation shown on it for creating vertices, inlet outlet wall, Back and Front wall and No slip wall as shown in following figure.

# What is OpenFoam ?

Ans :- OpenFoam (for \"open source field operation and manipulation\") is a C++ toolbox for the development of custemised numerical solvers and pre/post processing utilities for the solution of continum mechanics problem, most prominently including Computational Fluid Dynamics (CFD).

Advantage :-

  1. The friendly syntax for partial differential equations.
  2. Fully documented source code.
  3. Unstructured polyhedral grid capabilities.
  4. Automatic parallelization of applications written using OpenFoam high level syntax.
  5. Wide range of applications and models ready to use.
  6. Commercial support and training provided by the developers.
  7. No license costs.

Disadvantages :-

  1. The development community suffers from fragmentation, giving rise to numerous forked projects.
  2. Absence of an Intigrated Graphical User Interface (stand alone open source and propriatory options are available).
  3. The programmers guide does not provide sufficient details, making the progress slow if you need to write new applications or add functionality.

Simulations(i.e. steps) :-

Inside the Linux OS download virtual Box in 18.04 version which is long life working conditions. Inside virtual Box install openFoam V7 which is latest version.After installing OpenFoam follow the following procedures are-

  1. Open the terminal window by clicking RHS button on mouse and select last one terminal options or by shortcut keys \"ctrl+Alt+T\" buttons on keyboard in the Linux Operating System
  2. Just type \'tutorials\' or simply \'tut\' and by clicking enter button you will see all in-built tutorial files of the OpenFoam software. type \'ls\' (i.e. list) to view the contents in the tutorials.
  3. Type \'cd incompressible\' (because of icoFoam is already given in the problem) and then type \'ls\' it takes into the incompressible directory files.
  4. Type \'cd icoFoam\', then \'ls\'. This step takes into the icoFoam directory file.
  5. After that, we need to copy the cavity directory file located in icoFoam.
  6. Type \'cp -r (i.e. random) cavity $FOAM_RUN/*** \' this command copies the cavity file and pastes directly in the run folder. To check....
  7. Type \'cd\'. Type \'run\'. It takes to the run folder which creates automatically by the software and we can file copied.
  8. Type cavity we can see three files i.e. 0, constant, system.
  9. First off all open the system file write \'gedit blockMeshDict\' to editing blockMesh file.
  10. To create bolckMesh file (for creating blockMesh file clearly write all vertex point for which design required.
  11. then write suitable unit for \'convertInMeter\' option.
  12. Then write all respected boundary conditions.
  13. After creating BlockMesh file come outside by typing \'cd ..\' .
  14. Then type \'cd 0\' we will see \'p\' and \'U\' files.
  15. Edited that files by typing gedit \'p\' or \'U\' and use fixed pressure, uniform pressure...etc and start velocity, deltachange velocity.
  16. After creating \'p\' and \'U\' files come back to cavity by typing \'cd ..\' in main directory.
  17. Then run \'blockMesh\' file and corrected all fatal errors.
  18. After successfully running blockMesh file run \'icoFoam\' file for simulation but keep in mind its inside the cavity directory.
  19. Corrected all respected error and create simulations.
  20. Then open the paraFoam by typing \'paraFoam\' on terminal window.
  21. One things keep in mind that before simulation \'p\' and \'U\' must be hided and then apply.
  22. if once simulations done successfully then dont hide anything and apply directly.
  23. then use \'solid color\' option and \'surface with edge\' option and then take slice option then click on \'line over plot\' option and click on Z-axis which is inside the proparty and click on apply.
  24. Now, we can see \'U\' and \'p\' line plot with mesh file, see for different quantity i.e. along X-axis, Along Y-axis and along p, if there ie no changes the check the time.
  25. Before checking time delete the plot over line and menion maximum time and hit enter, we can see decreases the size of block which is inside the mesh.
  26. now take \'plot over line\' mention X,Y and Z axis along two points and plot line velocity graph along \'Y-axis\'.
  27. Before completing all process in the paraFoam hided the traingular and cover line which is inside the proparty.
  28. At last suggest suitable title and label left axis (i.e. Y) and bottom axis (i.e. X)
  29. Go inside file menu and select the save screenshot option and save with propar name in .png file.
  30. First create sample file with considering grading factor=1, and then respected to given grading factor values i. for 0.2, 0.5 and 0.8 by using the following formula- First cell = grading factor * last cell
  31. Keep in mind that Courant factor must be less by the formula of \" Courant No. =u*(deltat)*(deltax)\" by decreasing the value of deltat value because other value we cant modified.

The directory of files is as follows-

blockMeshDict Code :-

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

vertices
(
    (0 0 0)
    (0.08 0 0)
    (0.08 0.005 0)
    (0 0.005 0)
    (0.08 0.01 0)
    (0 0.01 0)
    (0.2 0.01 0)
    (0.2 0.005 0)
    (0.2 0 0)
    (0.2 -0.01 0)
    (0.08 -0.01 0)
    (0 0 0.01)
    (0.08 0 0.01)
    (0.08 0.005 0.01)
    (0 0.005 0.01)
    (0.08 0.01 0.01)
    (0 0.01 0.01)
    (0.2 0.01 0.01)
    (0.2 0.005 0.01)
    (0.2 0 0.01)
    (0.2 -0.01 0.01)
    (0.08 -0.01 0.01)
);

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

mergePatchPairs
(
);

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

This is the code for grading factor=0.2. In this file only grading factor should change and all file remains unchanged. Merge patch pairs use only when more than one face.

Below shown the controlDict file is as-

controlDict file :-

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

deltaT          0.0001;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;


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

In this file start time must be take zero and end time must be 1 second and deltaT value must be consider as small as possible (in my case I consider 0.0001 sec) and remaining value must be constant.

Velocity code is given below as-

Velocity Code :-

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

    frontAndBack
    {
        type            empty;
    }
    noSlipWalls
    {
    	type		noSlip;
    }
    
    
}

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

In velocity code all boundary conditions must be explained.

The pressure code is as follows-

Pressure Code :-

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

    Outlet
    {
        type            fixedValue;
	value		uniform 0;
    }

    frontAndBack
    {
        type            empty;
    }
    noSlipWalls
    {
	type		zeroGradient;
    }
   
}

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

Explain the pressure\'s boundary condition at inlet, outlet, front and back and no slip conditions.

Mesh Grading Factor :-

1. It is a technique called mesh stretching.

2. Grading factor values range from 1 to 10. A value of 1 produces the most uniform mesh transition. A value of 10 produces the least uniform mesh transition. Increasing the value can reduce the number of elements and local mesh quality. Decreasing the value (minimum is 0.1) can drastically increase the number of elements and increase the mesh quality.

3. A smaller grading factor produces a more uniform mesh.

f = (size of end cell) / (size of starting cell)

Following the results for each grading factor values as follows -

Mesh Geometry :-

Velocity magnitude profile for grading factor=0.2 :-

Velocity Magnitude profile for grading factor = 0.5 :-

Velocity Magnitude profile for grading factor = 0.8 :-

Comparison between grading factors :-

Following Grading factor comparison shows clear view of comparison between in each case as-

Mesh Grading Factor	 Velocity magnitude	 Pressure vector	   Executing Time
  (second)
    0.2	                    1.67494	            27.9632	         96.25
    0.5	                    1.67758	            27.9887	         97.48
    0.8	                    1.67817	            27.9842	         98.21
    1.0	                    1.67064	            28.1027	         100.71
  1. By observing above plots, we can see that how the gradation of Mesh appears.
  2. From the plots seen above, we can see that definitely there will be some effect on simulation by changing the Mesh grading factor.
  3. In total, we perform simulation for Mesh gradation of 0.2, 0.5, 0.8 and 1.0. All these simulation through the simillar plots.
  4. Although these have similar plots, the difference has been observed by zoom into the plot at the maximum velocity and pressure point. For the convenience given a comparison table above.werivwe g
  5. If we take a look at the velocity plots, we observe that the plot has bent to its the right side. This is because we were given the condition of the walls as a no-slip condition throughout the block.
  6. The maximum velocity point is located somewhere in between 0.13 to 0.14. But it has to be in the centre of the plot.
  7. This because of pressure developed by the internal force generated by the velocity.
  8. The formation of pressure plot is, change in the pressure is like first increasing and then decreasing. This is because if there is an increase in velocity, an increase in pressure also observed.
  9. Coming to the executing time, for grading mesh 0.2 takes less time to compare to others.
  10. For line plot require total two points which are in X, Y, Z direction as- (0.085, -0.01, 0.005) and (0.085, 0.01, 0.005) Here point along X-axis is given and remaining consider according to required conditions.

(Note :- For better observance and understanding the simulation use \'Jet\' color map).

Conclusions :-

At the time of finding grading factor there have complexity but, first off all takes the normal from free walls and find out the grading points. In Inlet and Outlet wall no any grading factor i.e. always takes 1. As we know the space between starting cell is more than the ending cell keep this in mind and find out all grading factor along each block.

For each grading factor no more change takesplace in velocity profile but very less changes takesplace in case of staring slope. The range is fixed from 0.001 to 0.02.

In this way I finding all grading factor along each wall and create the Mesh and velocity profile for each grading factor. o, in this way I completed this project successfully and write and plot everythings which required for this project.

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.