BlockMesh Drill down challenge
Objective: The objective of the problem is to produce mesh by using the OpenFOAM software, and to show the changes in post-processing of velocity and pressure gradients by using ParaView open source software for the given conditions.
OpenFOAM:
- OpenFOAM (for "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 continuum mechanics problems, most prominently including Computational Fluid Dynamics (CFD).
Advantages:
- The friendly syntax for partial differential equations
- Fully documented source code
- Unstructured polyhedral grid capabilities
- Automatic parallelization of applications written using OpenFOAM high-level syntax
- Wide range of applications and models ready to use
- Commercial support and training provided by the developers
- No license costs
Disadvantages:
- The development community suffers from fragmentation, giving rise to numerous forked projects.
- Absence of an integrated Graphical User Interface (stand-alone open-source and proprietary options are available).
- The Programmer's guide does not provide sufficient details, making the progress slow if you need to write new applications or add functionality.
Block:

Mesh Specifications:
- Number of cells along the x-direction (longer dimension) = 200
- Number of cells along the y-direction = 10
- Use a graded mesh. Grading factor near all walls should be 0.2, 0.5, 0.8
Boundary Condition Specification:
1. To create a geometry given below by providing respective boundary names and condition

2. Mesh
|
Along x- axis |
200 |
|
Along y-axis |
10 |
3. Observe the variation of velocity magnitude profile with change in grading factors 0.2, 0.5, 0.8. Measure the velocity profile at x = 0.085 m and represent using a line plot.
4.Contour plots of velocity and pressure.
Procedure:
1.Vertices of the geometry:
|
point |
Coordinates |
Point |
Coordinates |
|
0 |
(0 0 0) |
11 |
(0 0 1) |
|
1 |
(80 0 0) |
12 |
(80 0 1) |
|
2 |
(80 5 0) |
13 |
(80 5 1) |
|
3 |
(0 5 0) |
14 |
(0 5 1) |
|
4 |
(80 10 0) |
15 |
(80 10 1) |
|
5 |
(0 10 0) |
16 |
(0 10 1) |
|
6 |
(200 10 0) |
17 |
(200 10 1) |
|
7 |
(200 5 0) |
18 |
(200 5 1) |
|
8 |
(200 0 0) |
19 |
(200 0 1) |
|
9 |
(200 -5 0) |
20 |
(200 -5 1) |
|
10 |
(80 -5 0) |
21 |
(80 -5 1) |
The above tabular column contains coordinates for all the points starting from 0 to 21. Convert into meters by multiplying with 0.001.
2. Blocks:
The entire geometry is divided into 5 blocks each containing 8 vertices.
|
Block number |
Vertices |
|
1 |
0, 1, 2, 3, 11, 12, 13, 14 |
|
2 |
3, 2, 4, 5, 14, 13, 15, 16 |
|
3 |
2, 7, 6, 4, 13, 18, 17, 15 |
|
4 |
1, 8, 7, 2, 12, 19, 18, 13 |
|
5 |
10, 9, 8, 1, 21, 20, 19, 12 |
3. Meshing:
For the length of 80 mm '80' grid points are taken and for the length of 120 mm '120' grid points are taken along x axis for all the blocks
Along y axis for each block ten grid points are taken.
Along the z axis only one grid is taken because the problem being solved is 2D.
4. Mesh grading:
Mesh grading depends on grading factor(f) = end grid size/start grid size
if mesh grid size is less than 1, then the end grid is smaller compared to starting grid, by using this concept fine mesh can be obtained at the walls.
5. boundary names:
|
Boundary name |
Faces |
|
inlet |
(14 3 0 11) (16 5 3 14) |
|
outlet |
(9 8 19 20) (8 7 18 19) (7 6 17 18) |
|
No slip wall |
(15 4 5 16) (17 6 4 15) (12 1 10 21) (0 1 12 11) (10 9 20 21) |
|
Front And Back |
(2 1 0 3) (4 2 3 5) (8 9 10 1) (7 8 1 2) (6 7 2 4) (12 13 14 11) (13 15 16 14) (20 19 12 21) (19 18 13 12) (18 17 15 13) |
Simulation: (Steps)
- Open the terminal in the Linux Operating System
- just type 'cd $FOAM_TUTORIALS', to change directory to the in-built tutorial files of the OpenFOAM software. To view the contents in the tutorials type 'ls'.
- Type 'cd incompressible' to change directory to the incompressible directory file. To view the contents in the directory type 'ls'.
- Change directory icoFoam by typing 'cd icoFoam', then 'ls' to access the list.
- Select cavity by typing 'cd cavity' and 'ls' to list the contents.
- Copy and paste the cavity file to the run folder by typing 'cp -r cavity/ $FOAM_RUN/'.
- Now to access the run folder type 'cd $FOAM_RUN'.(NOTE: Never run your simulation directly in the tutorial file itself. It may corrupt the entire tutorial file if any mistakes or errors take place. And to recover those files we might need to re-install openFOAM.)
- In the run folder , open cavity folder, then system folder. Type 'ls' to check the contents.
- There we’ll get blockMeshDict, controlDict, fvschemes and fvslutions are text files which we need to edit the file according to our boundary conditions.
- Type 'gedit blockMeshDict'. Here generate the block by defining the vertices, apply the mesh grading, allocate the grid numbers to the respective points assumed and save the file.
- Likewise, edit the controlDict file also to give limits in words of time, like start time, end time, time interval and delta t.
- While selecting the 'delta t' value, be aware of the courant number. It should be less than one (< 1). Otherwise, the solution may diverge and stop forcibly by software itself.
- Come back to the cavity file using change directory command 'cd ..' .
- To edit the velocity and pressure files according to the problem, change directory to '0' file. The '0' file represents the Initial and boundary conditions for velocity and pressure.
- After editing the four files, come back to the 'cavity' directory. There generate the command 'blockMesh' to get mesh structured, and other mesh calculations done. After completing it check the mesh for any error. For that, 'checkMesh' command is used.
- If the mesh is stable type 'icoFoam' to calculate simulation or problem.
- After the completion of simulation, type 'paraFoam' for the post-processing. ParaView is an open-source multiple-platform application for interactive, scientific-visualization. It has a client-server architecture to facilitate remote visualization of datasets and generates level-of-detail (LOD) models to maintain interactive frame rates for large datasets. It is an application built on top of the visualization toolkit (VTK) libraries.
BlockMeshDict 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;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
(0 0 0)
(80 0 0)
(80 5 0)
(0 5 0)
(80 10 0)
(0 10 0)
(200 10 0)
(200 5 0)
(200 0 0)
(200 -5 0)
(80 -5 0)
(0 0 1)
(80 0 1)
(80 5 1)
(0 5 1)
(80 10 1)
(0 10 1)
(200 10 1)
(200 5 1)
(200 0 1)
(200 -5 1)
(80 -5 1)
);
blocks
(
hex (0 1 2 3 11 12 13 14) (80 10 1) simpleGrading (0.2 5 1)
hex (3 2 4 5 14 13 15 16) (80 10 1) simpleGrading (0.2 0.2 1)
hex (2 7 6 4 13 18 17 15) (120 10 1) simpleGrading (5 0.2 1)
hex (1 8 7 2 12 19 18 13) (120 10 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
(
(14 3 0 11)
(16 5 3 14)
);
}
outlet
{
type patch;
faces
(
(9 8 19 20)
(8 7 18 19)
(7 6 17 18)
);
}
Noslipwall
{
type wall;
faces
(
(15 4 5 16)
(17 6 4 15)
(12 1 10 21)
(0 1 12 11)
(10 9 20 21)
);
}
frontAndBack
{
type empty;
faces
(
(2 1 0 3)
(4 2 3 5)
(8 9 10 1)
(7 8 1 2)
(6 7 2 4)
(12 13 14 11)
(13 15 16 14)
(20 19 12 21)
(19 18 13 12)
(18 17 15 13)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
In the blockMeshDict file all the information regarding mesh and geometry is present, here grading factors can be changed and also number of grid points can be changed as per requirement.
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 0.3;
deltaT 0.0002;
writeControl timeStep;
writeInterval 200;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //
In controlDict file start time, end time, time step(deltaT) and others can be changed for a given problem to maintain the courant number < 1.
Courant number plays very important role while running icoFoam for maintaining accuracy and stability courant number must be less then 1
Courant number
C0=(δt|U|)/δx
Therefore courant number depends on time step, velocity, grid size and by varying these one can maintain courant number less than 1.
initial conditions are not varied to observe changes by varing grading factor and comparing with results of no mesh grading.
Initial and boundary conditions for velocity and pressure
For 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;
}
}
// ************************************************************************* //
For Kinematic 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
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
Noslipwall
{
type zeroGradient;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
Results:
1. For grading factor f = 0.2
Here grading factor is introduced to create a finer mesh at the walls and code in the blockMeshDict file is varied respctively.
|
Variable |
Value set to |
|
Thermal diffusivity |
0.001 |
|
time step(deltaT) |
2e-4 |
|
t start |
0 |
|
t end |
0.3 |
|
U_initial |
1 m/s |
Here maximum CFL for the final time step is found to be 0.755528.
Mesh:

Plot over line showing variation of velocity magnitude wrt width at x = 0.085 m for grading factor = 0.2.

2. For mesh grading factor = 0.5
|
Variable |
Value set to |
|
Thermal diffusivity |
0.001 |
|
time step(deltaT) |
2e-4 |
|
t start |
0 |
|
t end |
0.3 |
|
U_initial |
1 m/s |
Here the maximum value of CFL for the last time step is found to be 0.4645
Mesh:

Plot over line showing variation of velocity magnitude wrt width at x = 0.085 m for grading factor = 0.5:

3. For mesh grading factor = 0.8
|
Variable |
Value set to |
|
Thermal diffusivity |
0.001 |
|
time step(deltaT) |
2e-4 |
|
t start |
0 |
|
t end |
0.3 |
|
U_initial |
1 m/s |
Here the maximum value of CFL for the last time step is found to be 0.388754
Mesh:

Plot over line on Variation of velocity magnitude wrt width for mesh grading factor = 0.8

Conclusion:
From the above result we can conclude that for mesh grading factor = 0.2 one can obtain good results as there is sudden decrease in velocity near the walls and tending to zero at the walls due to no slip condition. so, by mesh refinement at the walls correct plots can be obtained and results will be realistic.
when the plot over line graphs are compared it can be seen that with increase in mesh grading from 0.2 to 1 it is difficult to capture the values at the bottom wall because of lack of refinement.
Also by varying mesh grading factor from 0.2 to 1 slight changes in contour plots can be observed especially in velocity contour plot at the walls.
Mesh grading factor of 0.2 is recommended for this case is recommended but needed to be carefully chosen to get realistic results because by using mesh grading factor end grid size is reduced and also start grid size is increased.