Sunteți pe pagina 1din 37

11th OpenFOAM Workshop

blockMesh Training

Vanja Škurić

Faculty of Mechanical Engineering and Naval Architecture, University of Zagreb


vanja.skuric@fsb.hr

June 28, 2016

1 / 37
11th OpenFOAM Workshop

This presentation is based on the blockMesh User Guide by CFD Direct.


http://cfd.direct/openfoam/user-guide/blockmesh/

2 / 37
11th OpenFOAM Workshop

Contents

1 Introduction

2 How to use blockMesh

3 Examples

FSB 3 / 37
11th OpenFOAM Workshop
Introduction

What is blockMesh?

blockMesh is a mesh generation utility supplied with OpenFOAM (and foam-extend).

It decomposes the domain into a set of one or more three dimensional hexahedral blocks:

Block is defined by 8 vertices, one at each corner of hexahedron.


Edges of the blocks can be straight lines, arcs or splines.

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?

Figure 1 : Mesh examples created with blockMesh

FSB 5 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

blockMeshDict takes the following keywords:

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

Local block coordinate system


Each block has a right-handed local coordinate system (x1 , x2 , x3 ).

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:

the axis origin is the first entry in the block definition


(vertex 0 in our example);
the x1 direction (corresponding to x axis in our example)
is described by moving from vertex 0 to vertex 1;
the x2 direction (corresponding to y axis in our example)
is described by moving from vertex 1 to vertex 2;

FSB 9 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

vertices 0, 1, 2, 3 define the plane x3 = 0;


vertex 4 is found by moving from vertex 0 in the x3 (z in
our example) direction;
vertices 5,6 and 7 are similarly found by moving in the x3
direction from vertices 1, 2 and 3 respectively.

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:

Direction Number of cells Cell expansion ratios


x1 (x) 20 3
x2 (y) 10 2
x3 (z) 12 1

FSB 10 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

Cell expansion ratios


Cell expansion ratios enables the mesh to be graded, or refined, in specified directions
(determined by the local coordinate system).
Cell expansion ratio is the ratio of the width of the end cell δe and the width of the
start cell δs along one edge of a block.

There are two types of grading specification available in blockMesh:


1 simpleGrading
The simple description specifies uniform expansions in the local x1 , x2 and x3
directions respectively with only 3 expansion ratios, e.g.:

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.

Figure 3 : Mesh grading along a block edge

FSB 12 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

3 simpleGrading with multi-grading of a block

OpenFOAM v2.4+ includes multi-grading functionality that can divide a block in


an given direction and apply different grading within each division.
Multi-grading is specified by replacing any single value expansion ratio in the
grading specification of the block.

Multi-grading with the following specifications is presented:


The block is split into 3 divisions in the y-direction, representing 20%,
60% and 20% of the block length;
30% of the total cells in the y-direction (10) is included in divisions 1 and
3 each and the remaining 40% is included in division 2;
1:4 expansion ratio is applied to divisions 1 and 3, and 1:1 expansion to
division 2.

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
)
);

Note: Block and cell fraction values are normalized.

FSB 14 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

Note: Edge numbering


Edge label and orientation is defined by the following rule:
Edges that are in the direction of x1 axis, have the orientation of the x1 axis and are
numbered by right hand rule (x1 axis direction is the thumb).
The x1 axis edges are counted first, then the x2 axis and finally the x3 axis edges.

Figure 4 : Edge numbering of a block

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.

For example, in case of an arc type edge:

edges
(
arc 2 4 (1.05 1.2 0)
);

FSB 16 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

The following edge types are available in the blockMeshDict:

Keyword Description Additional entries


arc Circular arc Single interpolation point
spline Spline curve List of interpolation points
polyLine Set of lines List of interpolation points
BSpline B-spline curve List of interpolation points
line Straight line -

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).

Patch information specified inside a sub-dictionary contains:


type - type of the patch (generic patch or particular geometric condition)
faces - a list of block faces forming the patch

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

In foam-extend a deprecated dictionary called patches is used instead of boundary,


where patch type is specified next to the patch name.

The previous example in foam-extend looks like this:


patches
(
patch inlet // patch 0 type and name
(
(0 4 7 3) // boundary block face in this patch
)
}
wall bottom // patch 1 type and name
(
(0 3 2 1)
)
);

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.

The mergePatchPairs list has the following form:


mergePatchPairs
(
( <masterPatch> <slavePatch> ) // merge patch pair 0
( <masterPatch> <slavePatch> ) // merge patch pair 1
...
);

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.

The rules for merging are as follows:


The faces of the master patch remain as originally defined, with all vertices in
their original location;
The faces of the slave patch are projected onto the master patch where there
is some separation between slave and master patch;
The location of any vertex of a slave face might be adjusted by blockMesh to
eliminate any face edge that is shorter than a minimum tolerance;
If patches overlap as shown in Figure 5, each face that does not merge remains
as an external face of the original patch, on which boundary conditions must
then be applied;
If all the faces of a patch are merged, then the patch itself will contain no faces
and is removed.

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.

Figure 5 : Merging overlapping patches

FSB 24 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

Block with less than 8 vertices


In order to create a block with less than 8 vertices, one or more pairs of vertices have
to be collapsed onto each other.
The most common example of collapsing vertices is when creating a six-sided wedge
shaped block, Figure 6.

Figure 6 : Wedge block

FSB 25 / 37
11th OpenFOAM Workshop
How to use blockMesh

blockMesh dictionary

For wedge block on Figure 6, block definition says:

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

An appropriate blockMeshDict file must exist in the system or constant/polyMesh


directory.

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:

Figure 7 : Block geometry

FSB 28 / 37
11th OpenFOAM Workshop
Examples

1. Single block

Figure 8 : Block mesh points

FSB 29 / 37
11th OpenFOAM Workshop
Examples

2. 180° channel

Create a mesh of the following channel.

Figure 9 : Channel geometry

FSB 30 / 37
11th OpenFOAM Workshop
Examples

2. 180° channel

Figure 10 : Channel dimensions (height is 0.5 m)

FSB 31 / 37
11th OpenFOAM Workshop
Examples

2. 180° channel

Figure 11 : Channel mesh points

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.

Figure 12 : Cylinder geometry

FSB 33 / 37
11th OpenFOAM Workshop
Examples

3. Cylinder

Figure 13 : Cylinder mesh points

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.

Figure 14 : Foil in wind - geometry

FSB 35 / 37
11th OpenFOAM Workshop
Examples

4. Foil In Wind

Figure 15 : Foil in wind - block

FSB 36 / 37
11th OpenFOAM Workshop
Examples

4. Foil In Wind

Figure 16 : Foil in wind - points

FSB 37 / 37

S-ar putea să vă placă și