Block Mesh Training
Block Mesh Training
Block Mesh Training
blockMesh Training
Vanja Škurić
1 / 37
11th OpenFOAM Workshop
2 / 37
11th OpenFOAM Workshop
Contents
1 Introduction
3 Examples
FSB 3 / 37
11th OpenFOAM Workshop
Introduction
What is blockMesh?
It decomposes the domain into a set of one or more three dimensional hexahedral blocks:
The mesh is generated from a dictionary file named blockMeshDict located in the
constant/polyMesh (or system) directory of a case.
blockMesh reads this dictionary, generates the mesh and writes out the mesh
data to points, faces, cells and boundary files in the same directory.
FSB 4 / 37
11th OpenFOAM Workshop
Introduction
What is blockMesh?
FSB 5 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
Keyword Description
convertToMeters A scaling factor by which all vertex coordinates in the
mesh description are multiplied
vertices List of vertex coordinates
blocks Definitions of blocks (points, number of cells, ...)
edges Used to define type of edge
pacthes List of patches
mergePatchPair List of patches to be merged
FSB 6 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
vertices
The vertices of the blocks of the mesh are given as a standard list named vertices.
Each vertex can be accessed using its label, remembering that OpenFOAM always uses
the C++ convention that the first element of the list has label ’0’.
vertices
(
(0 0 0) //0
(2 0 0) //1
(2 1 0) //2
(0 1 0) //3
(0 0 1.2) //4
(2 0 1.2) //5
(2 1 1.2) //6
(0 1 1.2) //7
);
Figure 2 : Single block example
FSB 7 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
blocks
The block definitions are contained in a list named blocks.
Each block definition is a compound entry consisting of a list of vertex labels, a vector
giving the number of cells required in each direction, the type and list of cell expansion
ratio in each direction.
blocks
(
hex (0 1 2 3 4 5 6 7) // vertex numbers
(20 10 12) // numbers of cells in each direction
simpleGrading (3 2 1) // cell expansion ratios
);
FSB 8 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
The local coordinate system is defined by the order in which the vertices are presented
in the block definition.
In our example:
hex (0 1 2 3 4 5 6 7) (20 10 12) simpleGrading (3 2 1),
the local coordinate system is defined according to:
FSB 9 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
Number of cells in each direction and cell expansion ratios also follow the block local
coordinate system defined in the block definition.
In our example, number of cells and expansion ratios are:
FSB 10 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
simpleGrading (3 2 1)
FSB 11 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
2 edgeGrading
The full cell expansion description gives a ratio for each edge of the block,
numbered according to the scheme shown in Figure 4 with the arrows
representing the direction from first cell to last cell of the edge, e.g.:
edgeGrading (3 3 3 3 2 2 2 2 1 1 1 1)
In our example the ratio of cell widths along edges 0 - 3 is 3, along edges 4 - 7
is 2 and along 8 - 11 is 1 and is directly equivalent to the simpleGrading
example given above.
FSB 12 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
FSB 13 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
blocks
(
hex (0 1 2 3 4 5 6 7) (20 10 12)
simpleGrading
(
3 // x-direction expansion ratio
(
(0.2 0.3 4) // 20% y-dir, 30% cells, expansion = 4
(0.6 0.4 1) // 60% y-dir, 40% cells, expansion = 1
(0.2 0.3 0.25) // 20% y-dir, 30% cells, expansion = 0.25 (1/4)
)
1 // z-direction expansion ratio
)
);
FSB 14 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
FSB 15 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
edges
Each edge joining two vertex points is assumed to be straight by default.
However, any edge may be specified to be curved by entries in a list named edges. The
list is optional, and if the geometry contains no curved edges, it may be omitted.
Each curved edge entry is a compound entry consisting of a type of curve, labels of the
two vertices that the edge connects, and interpolation points through which the edge
passes.
edges
(
arc 2 4 (1.05 1.2 0)
);
FSB 16 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
FSB 17 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
boundary
The boundary of the mesh is given in a list named boundary.
Boundary is broken into patches (regions), where each patch in the list has its name as
the keyword (specified by the user).
Face points are specified by the right hand rule, where the thumb is pointing in the face
normal direction.
Note: blockMesh collects boundary faces not specified in the boundary list and assigns
them to a default patch named defaultFaces of type empty.
FSB 18 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
boundary
(
inlet // patch 0 name
{
type patch; // patch type for patch 0
faces
(
(0 4 7 3) // boundary block face in this patch
);
}
bottom // patch 1 name
{
type wall; // patch type for patch 1
faces
(
(0 3 2 1)
);
}
);
FSB 19 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
FSB 20 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
When mesh is created using more than one block the connection between blocks can
be accomplished by:
Face matching
The set of faces that comprise a patch from one block are formed from the same
set of vertices as a set of faces patch that comprise a patch from another block.
Face merging
A group of faces from a patch from one block are connected to another group
of faces from a patch from another block, to create a new set of internal faces
connecting the two blocks.
Face matching
To connect two blocks with face matching, the two patches that form the connection
should simply be omitted from the boundary (i.e. patches) list.
blockMesh then identifies that the faces do not form an external boundary and combines
each collocated pair into a single internal face that connects cells from the two blocks.
FSB 21 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
Face merging
Face merging requires that the block patches to be merged are first defined in the
boundary (i.e. patches) list.
Then, each pair of patches whose faces are to be merged must be included in an optional
list named mergePatchPairs.
FSB 22 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
The first specified patch becomes the master and the second becomes the slave.
FSB 23 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
A couple of things should be noted:
The consequence of face merging is that the original geometry of the slave
patch will not necessarily be completely preserved during merging.
A patch should not be merged twice, i.e. included twice in mergePatchPairs.
When two merging (not to each other) patches share a common edge, both
should be declared as a master patch.
FSB 24 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
FSB 25 / 37
11th OpenFOAM Workshop
How to use blockMesh
blockMesh dictionary
hex (0 1 2 3 4 5 5 4).
The collapsed face (4 5 5 4) is a block face of zero area which creates a patch with
no faces in the polyMesh.
The patch should be specified as empty in the blockMeshDict and the boundary
condition for any fields should consequently be empty also.
FSB 26 / 37
11th OpenFOAM Workshop
How to use blockMesh
Running blockMesh
In order to run blockMesh, while in the case directory run the following command:
blockMesh
FSB 27 / 37
11th OpenFOAM Workshop
Examples
1. Single block
Create a mesh of the following geometry using only one block:
FSB 28 / 37
11th OpenFOAM Workshop
Examples
1. Single block
FSB 29 / 37
11th OpenFOAM Workshop
Examples
2. 180° channel
FSB 30 / 37
11th OpenFOAM Workshop
Examples
2. 180° channel
FSB 31 / 37
11th OpenFOAM Workshop
Examples
2. 180° channel
FSB 32 / 37
11th OpenFOAM Workshop
Examples
3. Cylinder
Create a mesh of the following cylinder with variable radius and height using blockMesh
and m4 scripting.
FSB 33 / 37
11th OpenFOAM Workshop
Examples
3. Cylinder
FSB 34 / 37
11th OpenFOAM Workshop
Examples
4. Foil In Wind
Create a mesh for simulation of flow around a beam and foil. Foil thickness is 0.06 cm.
FSB 35 / 37
11th OpenFOAM Workshop
Examples
4. Foil In Wind
FSB 36 / 37
11th OpenFOAM Workshop
Examples
4. Foil In Wind
FSB 37 / 37