You are on page 1of 34

27-Mar-1527-Mar-15

27-Mar15

Computational Fluid Dynamics

34

GEOMETRY GENERATION USING


OPEN SOURCE TOOLS

Computational Fluid Dynamics

35

Domain Definition
There many ways to creating a geometry, this

gives you the freedom to work in a way that is


comfortable to you.
There is no wrong or right way to generate a
geometry. The only rule you should keep in mind
is that by the end of the day you should get a
unique clean and watertight geometry.
The quality of the mesh and hence of the solution,
greatly depends on the geometry.
So always do your best when creating the
geometry.

27-Mar-1527-Mar-1

27-Mar-1527-Mar-15

Computational Fluid Dynamics

3
6

Potential geometry issues


Missing faces.

Cracks.

Small faces.
Misaligned faces.
Overlapping faces.
Sliver faces (high
aspect-ratio).
Repeated faces.
Several surfaces
connected to a single
surface.

Gaps.
Free faces, edges,
nodes.
Hard edges.
Small edges.
Sharp angles.
Repeated edges.
High curvature NURBS.

Computational Fluid Dynamics

37

NURBS

Non-uniform rational basis spline (NURBS) is a mathematical model commonly used in computer graphics for generating and
representing curves and surfaces.
It is a mathematically precise representation of freeform surfaces which could be exactly reproduced whenever technically needed,
like those used for
-

ship hulls,
aerospace exterior surfaces, and
car bodies,
Computational Fluid Dynamics

38

Potential geometry issues


In general, when generating the geometry and by using good geometry generation

practices, we should not experience these geometry issues. At the end, we should
get a smooth, clean, watertight body.
Usually, we find these issues when importing or exporting the geometry from/to

different formats.

Computational Fluid Dynamics

39

Preparing Geometry for Meshing

Delete hard edges.


Delete small edges/faces.
Fill holes.
Split surfaces with high curvature.
Sew faces.
Remove sliver faces.
Connect/disconnected edges/faces.
Delete sharp edges.
Remove unnecessary details (defeaturing). This includes points, edges and faces.
Decompose geometry into meshable sections.

27-Mar-1527-Mar-1

Computational Fluid Dynamics

41

Preparing Geometry for Meshing


Missing face

Computational Fluid Dynamics

42

Preparing Geometry for Meshing


NURBS
- To improve quality, split the single surface into two surfaces

27-Mar-1527-Mar-1

Computational Fluid Dynamics

43

Preparing Geometry for Meshing

Computational Fluid Dynamics

Preparing Geometry for Meshing

44

27-Mar-1527-Mar-1

Computational Fluid Dynamics

45

Preparing Geometry for Meshing

Too many surfaces connected


to a single surface

\
High aspect ratio face/Sliver face

Computational Fluid Dynamics

Preparing Geometry for Meshing

46

27-Mar-1527-Ma

Computational Fluid Dynamics

47

Preparing Geometry for Meshing

Many times, it is not necessary to model all the details of the geometry.

In these cases you should consider simplifying the geometry (geometry


defeaturing) it can save a lot of time when generating the mesh.

Computational Fluid Dynamics

48

27-Mar-1527-Mar

Computational Fluid Dynamics

49

MESHING

Computational Fluid Dynamics

50

Meshing Preliminaries

Mesh generation consist in dividing the physical domain into a finite number of discrete regions,
called control volumes or cells in which the solution is sought.
Meshes used for the FVM method can consist of tetrahedras, pyramids, prisms, hexahedras
or any kind of polyhedral element (or a mix of all of them).
The meshes can be unstructured or structured. In our discussion, when we talk about
unstructured or structured meshes we refer specifically to the method used to generate them.

27-Mar-15

Computational Fluid Dynamics

51

Meshing Preliminaries
The data structure of the meshes used in the FVM is
represented by the points and faces that make up each control
volume.

The connectivity information of each cell (how faces and cells are connected) and cell/face
neighbor information is also needed for FVM unstructured meshes.

Meshes used for the FDM method are made of hexahedra and they are known as single and/or
multi-block structured meshes.

The connectivity information of the meshes used in the FDM is expressed as a two or three
dimensional array, this is highly memory efficient as we do not need to store all the connectivity
information of the faces and cells.

Computational Fluid Dynamics

Meshing Examples
Single-block C-type structured grid around a NACA 4412 airfoil

53

27-Mar-1527-Mar-1

Computational Fluid Dynamics

54

Meshing Examples
Multi-block structured grid around a NLR 7301 airfoil with flap

Computational Fluid Dynamics

55

Meshing Examples
Unstructured triangular mesh around a NHLP-2D
three element airfoil

27-Mar-1527-Mar-1

Computational Fluid Dynamics

56

Meshing Examples
Overlapping structured grid around a NLR
7301 airfoil with flap

Computational Fluid Dynamics

Meshing Examples
Cartesian mesh around a
Drela DAE11 low
Reynolds airfoil

57

27-Mar-1527-Mar-1

Computational Fluid Dynamics

58

Meshing Comparison
STRUCTURED UNSTRUCTURED CARTESIAN OVERLAPPING
Geometric Flexibility/
Adaptation
Grid Adaptation/ Local
Refinement
Viscous Computation
Moving/Deforming
Meshes Quality
Interpolation/
Conservation
Grid generation
easiness

V Good

V Good

Average

Bad

V Good

V Good

V Good

Good

Good

Average

V Good

V Good

V Good

Good

Bad

V Good

V Good

Bad

V Good

Bad

V Good

V Good

Bad

V Good

V
Goo
d
V
Goo

V Bad

Memory
Requirements
CPU Requirements

V
Goo
d
V
Goo
d
V
Goo
V
Goo
d
Goo
d

Computational Fluid Dynamics

59

Structured Vs. Unstructured Mesh

A single block structured mesh may comprise of square elements (2D) or hexahedral elements (3D) which are orthogonal in i, j space (2D) or i, j, k space (3D).
Although it is also possible to have wedges (3D), triangles (2D) and pyramids (3D) in a structured mesh.
Looking at a 2D example, for simplicity:

Every node in a 2D structured mesh has a corresponding integer i and j index value which is unique.
The physical locations of the nodes are stored in a table or are functionally related to the mesh space (ie
(x,y)= f(i,j)).
The neigbours of node (ij) are (i-1,j), (i+1,j), (ij-1), (ij+1), (i-1,j-1), and (i+1,j+1).
A structured mesh makes it very easy to loop through neighbours and can be efficient with memory.

A structured mesh has many coding advantages, but it may be difficult to conform a single block to a complicated shape. Code developers have got around this by
allowing multiple blocks (multiblock unstructured), but this can make the internal memory strucutres more inefficient.
Another way to make the mesh generation simpler, and improve code performance is to throw away the block structure and replace indices with node numbers and a
connectivity table. This is known as an unstructured mesh, because it lacks the i,j,k structure.

27-Mar-1527-Mar-1

Computational Fluid Dynamics

60

Structured Vs. Unstructured Mesh


A structured
mesh requires
the blocking as
input.
Unstructured
meshes, only
requires the
element size on
the lines and
surfaces that
define the
geometry as
input.

Computational Fluid Dynamics

Structured Vs. Unstructured Mesh

Unstructured Hybrid
Mesh (tetras, prisms
and hexs)

Cell count: approx. 5


000 000

Structured Mesh
(hexahedrals)

Cell count: approx. 5


000 000

61

27-Mar-1527-Mar-1

Computational Fluid Dynamics

62

Structured Vs. Unstructured Mesh

Computational Fluid Dynamics

63

Structured Vs. Unstructured Mesh

Each mesh type has its advantages and disadvantages.

At the end of the day, the mesh you use must has a good overall quality and must
be smooth.

The mesh density should be high enough to capture all relevant flow features.

27-Mar-1527-Mar-1

Computational Fluid Dynamics

65

Mesh Quality
There is no written theory when it comes to mesh generation and the whole
process depends on user experience.
Rule of thumb: the elements shape and
distribution should be pleasing to the eye.


The user can rely on grid dependency studies, but they are time consuming
and expensive.
No single standard benchmark or metric exists that can effectively assess the
quality of a mesh, but you can rely on suggested best practices.

Computational Fluid Dynamics

Mesh Quality
The most common mesh quality metrics are:
-

Orthogonality.
Skewness.
Aspect Ratio.
Smoothness.

66

27-Mar-1527-Mar-1

Computational Fluid Dynamics

67

Mesh Quality
Mesh orthogonality
-

It is the angular deviation of the vector S (located at the face center


connecting the two cell centers P and N.

) from the vector d

It affects the gradient of the face center f.


It adds diffusion to the solution.

Computational Fluid Dynamics

68

Mesh Quality
Mesh skewness

- Skewness is the deviation of the vector d that connects the two cells P and N, from the face
center f. The deviation vector is represented with A and the point where the vector d intersects
- It affects the interpolation of the cell centered
quantities to the face center f.

the face f is f-.

27-Mar-1527-Mar-1

Computational Fluid Dynamics

69

Mesh Quality
Mesh aspect ratio AR
-

Mesh aspect ratio AR is the ratio between the longest side Ax and the shortest side Ay .
Large AR are fine if gradients in the long direction are small.
High AR smear gradients.

Computational Fluid Dynamics

Mesh Quality
Smoothness
Smoothness, also known as expansion rate, growth factor or
uniformity, defines the transition in size between contiguous cells.
Large transition ratios between cells add diffusion to the solution.

70

27-Mar-1527-Mar-1

Computational Fluid Dynamics

71

Mesh Quality

The mesh density should be high enough to capture all relevant flow features. In areas where the
solution change slowly, you can use larger elements.
To keep cell count down, use non-uniform meshes to cluster cells only where they are needed. Use
local refinements and solution adaption to further refine only on selected areas.

For the same cell count, hexahedral meshes will give


more accurate solutions, especially if the grid lines are
aligned with the flow.

In boundary layers, quad, hex, and prism/wedge cells are preferred over triangles, tetrahedras,
or pyramids.
If you are not using wall functions (turbulence modeling), the mesh adjacent to the walls should be
fine enough to resolve the boundary layer flow. This will rocket the cell count.

Computational Fluid Dynamics

72

Mesh Quality
In
- WM_PROJ ECT_DIR/src/OpenFOAM/meshes/primitive
Mesh/primitiveMeshCheck/primitiveMeshCheck.C you will
find the quality metrics used in OpenFOAM.

Their maximum (or minimum) values are defined as


follows:
Foam::scalar Foam::primitiveMesh::closedThreshold_ = 1.0e-6; Foam::scalar
Foam::primitiveMesh::aspectThreshold_ = 1000; Foam::scalar
Foam::primitiveMesh::nonOrthThreshold_ = 70; // deg Foam::scalar
Foam::primitiveMesh::skewThreshold_ = 4; Foam::scalar
Foam::primitiveMesh::planarCosAngle_ = 1.0e-6;

27-Mar-1527-Mar-15

Computational Fluid Dynamics

73

Mesh Quality
OpenFOAM comes with the utility checkMesh which
checks the validity of the mesh.
checkMesh will look for/check for:
-

Mesh stats and overall number of cells of each type.


Check topology (boundary conditions definitions).
Check geometry and mesh quality (bounding box, cell
volumes, skewness, orthogonality, aspect ratio)

If for any reason checkMesh finds errors, it will give


you a message and it will tell you what check failed.
It will also write a set with the faulty cells, faces,
points. These sets are saved in the directory
constant/polyMesh/sets/

Computational Fluid Dynamics

74

Mesh Quality
Mesh topology and patch topology errors must be
repaired.

You will be able to run with mesh quality errors


such as skewness, aspect ratio, minimum face
area, and non-orthogonality. But remember, they
will severely tamper the solution accuracy and
eventually can make the solver blow-up.

checkMesh does not repair these errors. You will

27-Mar-1527-Mar-15

need to check the geometry for possible errors


and generate a new mesh.
Computational Fluid Dynamics

75

Mesh Conversion
It is also possible to export a mesh generated with a third party
software and use it in OpenFOAM. Some of the utilities available
formesh conversion are listed below:

ansysToFoam: converts an ANSYS input mesh file OpenFOAM format.


cfx4ToFoam: converts a CFX 4 mesh to OpenFOAM format.
fluent3DMeshToFoam: converts a Fluent mesh to OpenFOAM format.
gambitToFoam: converts a GAMBIT mesh to OpenFOAM format.
gmshToFoam: reads .msh file as written by Gmsh.
ideasUnvToFoam: I-Deas unv format mesh conversion.
plot3dToFoam: plot3d mesh (ascii/formatted format) converter.
star4ToFoam: converts a STAR-CD (v4) PROSTAR mesh into
OpenFOAM format.
tetgenToFoam: Converts .ele and .node and .face files, written by tetgen.

Computational Fluid Dynamics

76

Mesh Conversion
OpenFOAM also comes with many mesh manipulation
utilities.
Some of them are listed below:
-

checkMesh: checks validity of a mesh.


refineMesh: utility to refine cells in multiple directions.
renumberMesh: renumbers the cell list in order to reduce
the bandwidth, reading and renumbering all fields from all
the time directories
transformPoints: transforms the mesh points in the
polyMesh directory according to the translate, rotate and
scale options.
mirrorMesh: mirrors a mesh around a given plane.
setSet: manipulate a cell/face/point/ set or zone
refineWallLayer: utility to refine cells next to patches.

27-Mar-1527-Mar-15

Computational Fluid Dynamics

77

Mesh Conversion
-

For simple geometries, the mesh generation utility blockMesh (supplied


with OpenFOAM), can be used. The blockMesh utility creates multiblock
meshes. The mesh is generated from a dictionary file named
blockMeshDict located in the constant/polyMesh directory.

blockMesh
snappyHexMesh

For complex geometries, the mesh generation utility snappyHexMesh


(supplied with OpenFOAM), can be used. The snappyHexMesh utility
generates 3D meshes containing hexahedra and split-hexahedra from a
triangulated surface geometry in Stereolithography (STL) format. The
mesh is generated from a dictionary file named snappyHexMeshDict
located in the system directory and a triangulated surface geometry file
located in the directory constant/triSurface.

Computational Fluid Dynamics

78

Meshing Examples
Working with lid driven cavity
blocks
(
hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
);

27-Mar-1527-Mar-15

Computational Fluid Dynamics

79

Meshed Cavity - Grading 1 1 1


Max aspect ratio = 1 OK.

Minumum face area = 2.5e-05. Maximum face area =


5e-05. Face area magnitudes
OK.
Min volume = 2.5e-07. Max
volume = 2.5e-07. Total volume
= 0.0001. Cell volumes OK.

Mesh non-orthogonality Max: 0

average: 0

Non-orthogonality check OK.


Face pyramids OK.

Max skewness = 1e-08 OK.

Coupled point location match


(average 0) OK.

Computational Fluid Dynamics

80

Meshed Cavity - Grading 4 1 1

Max aspect ratio = 2.18175 OK.


Minumum face area = 1.14587e5. Maximum face area = 9.16694e- 05. Face area magnitudes OK.
Min volume = 1.14587e-07. Max volume = 4.58347e-07. Total
volume = 0.0001. Cell volumes OK.
Mesh non-orthogonality Max: 0
average: 0
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 2.18175e-08 OK.
Coupled point location match
(average 0) OK.

27-Mar-1527-Mar-15

Computational Fluid Dynamics

81

Meshed Cavity- Grading 4 4 1


Max aspect ratio = 4 OK.
Minumum face area = 5.25205e6. Maximum face area = 9.16694e- 05.
Face area magnitudes OK.
Min volume = 5.25205e-08. Max
volume = 8.40328e-07. Total volume
= 0.0001. Cell volumes OK.
Mesh non-orthogonality Max: 0
average: 0
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 4.41922e-08 OK.
Coupled point location match
(average 0) OK.

Computational Fluid Dynamics

Meshed Cavity - Grading 0.25 1 1


Max aspect ratio = 2.18175 OK.
Minumum face area = 1.14587e- 05. Maximum face area =
9.16694e- 05. Face area magnitudes OK.
Min volume = 1.14587e-07. Max
volume = 4.58347e-07. Total volume
= 0.0001. Cell volumes OK.
Mesh non-orthogonality Max: 0
average: 0
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 2.18175e-08 OK.
Coupled point location match
(average 0) OK.

82

27-Mar-1527-Mar-15

Computational Fluid Dynamics

83

Meshed Cavity - Grading 0.25 0.25 1


Max aspect ratio = 4 OK.
Minumum face area = 5.25205e- 06.
Maximum face area = 9.16694e- 05.
Face area magnitudes OK.
Min volume = 5.25205e-08. Max
volume = 8.40328e-07. Total volume
= 0.0001. Cell volumes OK.
Mesh non-orthogonality Max: 0
average: 0
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 4.75371e-08 OK.
Coupled point location match
(average 0) OK.

Computational Fluid Dynamics

Dense Cavity

84

Max aspect ratio = 4 OK.


Minumum face area = 5.86845e7. Maximum face area = 3.06423e05. Face area magnitudes OK.

hex ( 0 1 4 3 910 13 12) (30 30 1) simpleGrading (4 4 1) // bottom left quadrant hex (1 2 5 4


1011 14 13) (30 30 1) simpleGrading (0.25 4 1) // bottom right quadrant hex (3 4 7 6 12 13 16
15) (30 30 1) simpleGrading (4 0.25 1) // top left quadrant hex (4 5 8 7 13 14 17 16) (30 30 1)
simpleGrading (0.25 0.25 1) // top right quadrant
);

Max skewness = 4.25763e-07 OK.


Coupled point location match (average 0) OK.

27-Mar-1527-Mar-15

Computational Fluid Dynamics

85

Arched Cavity

Max aspect ratio = 294.73 OK.


Minumum face area = 1.10919e-08.
Maximum face area = 4.81143e-05.
Face area magnitudes OK.
Min volume = 1.10919e-10. Max volume =
1.47263e-07. Total volume = 0.0001. Cell
volumes OK.
Mesh non-orthogonality Max: 89.3105
average: 52.3784
*Number of severely non-orthogonal faces:
1309.
Non-orthogonality check OK.
<<Writing 1309 non-orthogonal faces to set
nonOrthoFaces
Face pyramids OK.
Max skewness = 1.57064 OK.
Coupled point location match (average 0)
OK.

Computational Fluid Dynamics

86

Arched Curved Cavity

Max aspect ratio = 294.73 OK.


Minumum face area = 1.10919e-08. Maximum face area = 4.81143e-05.
Face area magnitudes OK.
I\/lin \/nli imp 1 1 DQ1 Qp-1 D IV/IPV
edges
(
arc 12 (0.8 0.4 0) arc 1011(0.8 0.4 0.1) arc
4 5(0.8 0.9 0) arc 13 14 (0.8 0.9 0.1) arc 7
8(0.81.4 0) arc 1617 (0.8 1.4 0.1)
);

Face pyramids OK.


Max skewness = 1.57064 OK.
Coupled point location match (average
0) OK.

27-Mar-1527-Mar-15
Computational Fluid Dynamics

89

Problem

You are required to simulate 2D circular domain, of radius R = 2 m.


Draw a figure highlighting the vertices that will be used in the blockMeshDict to create
the geometry in OF.

27-Mar-1527-Mar-15

Computational Fluid Dynamics

90

Partial Solution

(0,2,0)
(2,0,0)

Computational Fluid Dynamics

91

Examples of 3D Shapes using BlockMesh

27-Mar-1527-Mar-15

Computational Fluid Dynamics

92

Examples of 3D Shapes using BlockMesh

Computational Fluid Dynamics

3D Cylinder using blockMesh: Step1

93

27-Mar-1527-Mar-15

Computational Fluid Dynamics

94

3D Cylinder using blockMesh: Step2

Computational Fluid Dynamics

3D Cylinder using blockMesh: Step3

95

27-Mar-1527-Mar-15

Computational Fluid Dynamics

96

Dome using blockMesh: Stepl

Computational Fluid Dynamics

Dome using blockMesh: Step2

97

27-Mar-1527-Mar-15

Computational Fluid Dynamics

99

QUIZ

Computational Fluid Dynamics

Problem
You are required to
simulate a 2D domain
shown.
Draw a figure
highlighting the vertices
that will be used in the
blockMeshDict to create
the geometry in OF.

100

Computational Fluid Dynamics

Partial Solution
27
M
ar15

102

You might also like