Mesh
Mesh
Dynamics
Finite Volume Method for Complex
Geometry
1
Unit 2
• Finite Volume Method for Complex Geometry:
Body-fitted coordinate grids for complex
geometries, Cartesian vs. curvilinear grids,
difficulties of curvilinear grids, Block-structured
grids, unstructured grids and its discretization,
discretization of diffusion and convective terms,
treatment of source terms, assembly of
discretized equations, Pressure-velocity coupling
in unstructured meshes, staggered vs. co-located
grid arrangements, extension of face velocity
interpolation method to unstructured meshes.
2
References
• John D. Anderson, Jr.
Computational Fluid Dynamics: The Basics with
Applications
McGraw Hill, 1995
– Chapter 5: Grids with Appropriate Transformations
• H. K. Versteeg, W. Malalasekera,
An Introduction to Computational Fluid Dynamics:
The Finite Volume Method,
2nd edition, Pearson, Prentice Hall, 2007.
– Chapter 11: Method for dealing with complex geometries
• http://www.nd.edu/~gtryggva/CFD-Course/
3
4
Meshing
• Mesh generation is the practice of dividing a continuous geometric space into
discrete geometric and topological cells known as Grid or Mesh.
• Mesh cells are used as discrete local approximations of the larger domain.
• There is infinite possibilities to create a mesh for the given geometric space.
• Meshes are created by computer algorithms, often with human guidance through
a GUI , depending on the complexity of the domain and the type of mesh desired.
Most time consuming process.
• The goal is to create a mesh
– accurate solution, faster convergence, reduction of numerical diffusion,
through
– accurately captures the given domain geometry,
– with high-quality (well-shaped) cells, and
– without so many cells as to make subsequent calculations intractable.
• The mesh should also be fine or dense (have small elements) in the areas having
complex features and that are important for the subsequent calculations. But this
may result in unnecessary grid resolution which leads to local variation of solution
5
domain.
6
Grid Types
• Structured (Vertices having similar neighbourhood/ Fixed number of
neighbouring cells for Interior cell)
– Cartesian (x,y,z) and Curvilinear/Body-fitted (r,θ,z)
used for simple geometries used for curved boundary flows
– Orthogonal and Non-orthogonal
– Single block and Multiple blocks/zones/sub-regions (used for complex
geometries)
– Uniform and nested refinement
– Quadrilaterals (2D) and Hexahedral (3D) elements
• Unstructured (Vertices having variation in neighbourhood)
used for more complex flows
– Single block and Multiple block (offer unlimited flexibility, fast, used in industry)
• Hybrid
– Multiple block
• Patched and overset grids
• Adaptive meshes
7
Grids
• Type of cells
• a 0-simplex is a point,
• a 1-simplex is a line segment,
• a 2-simplex is a triangle,
• a 3-simplex is a tetrahedron,
• Structured/unstructured
– Quadrilateral
– Hexahedral (near wall)
– Triangle
– Tetrahedral
• Transition between tets & hex
– Pyramid
– Prisms:
8
Uniform Cartesian Grid
9
Cartesian Grid with 1D sizing
• Flow over cylinder
10
Cartesian Grid for nested refinement
• Transonic aerofoil
11
Multi-block structured Grid
12
Orthogonal curvilinear grid
the grid lines are perpendicular at intersection.
Time consuming and often difficult to generate
13
Orthogonal curvilinear grid
• Flow Past Air foil
• 14
Non-orthogonal Curvilinear grids
Easier to generate
Single block
Multi-block 15
Unstructured Grid
16
Unstructured Grid
• For complex geometries
17
Unstructured Grid
18
Unstructured Grid
Hybrid:
Structured Quadrilateral elements Polyhedral elements
near the walls and
Unstructured Triangular elements
in the remaining part 19
Hybrid
• Conformal
• Non-conformal
20
Modified Cartesian
• Modified cartesian mesh near a surface so that one side of
cell lies along the surface, highlighted by bold lines
21
Overset/Chimera
22
Combustion chamber of engine (Pent roof)
23
Structured non-orthogonal mesh
• Combustion chamber of engine (Pent roof)
24
Block structured grid
• Combustion chamber of engine (Pent roof)
with inlet and outlet ports
25
Example
26
Pb.1: Make a grid in circular pipe in 2-D
flow domain
27
Circular Pipe
• Structured curvilinear O-grid
28
29
Pb.2: Make a grid around a cylinder in 2-D
flow domain
30
Type of Grids
2-D domain of flow around cylinder Cartesian Grid Orthogonal Curvilinear Grid
32
Pb.3: Make a grid over staggered tube bank
33
Cartesian Grid (40x15)
34
Non orthogonal body fitted grid (40x15)
35
Predicted flow pattern
36
H-type Non-orthogonal Curvilinear Grid
37
Hybrid Grid
• Structural quadrilateral and unstructured triangular
38
Governing Equation
• The generation of an appropriate grid is one thing; the
solution of governing equations over such a grid is quite
another thing.
• It should be noted that the governing equations of fluid
flow are almost always written in orthogonal coordinate
system.
• A good grid should reflect this property for obtaining a
good solution, when solving the equations in differential
form.
• Thus, the grid lines should be orthogonal as much as
possible in the structured grid. 39
Cartesian Grid
• Many of the fluid flow equations are easily solved by
discretizing procedures using the Cartesian coordinate
system.
• In this system the implementation of finite volume
method is simpler and easier to understand. As studied
in CFD
• For a simple (regular) computational domain, everything
is fine in terms of mesh, grid, and grid (nodal) points.
• The boundary nodes are easily taken care of during
discretization of partial differential equations as long as
the grid is regular.
40
Governing Equations in Cartesian Coordinate
41
Limitations of Cartesian grid for Complex Geometries
• Cartesian meshes involve the governing equations in their
simplest form, but the discretization of flow problems
with curved domanl boundaries is inaccurate.
• The surface is a vital boundary condition for determining
flow. Hence, surface must be clearly and strongly seen by
the numerical solution.
However, the curve geometry of cylinder in Cartesian
coordinate system is approximated by using stepwise approximation.
• Stepwise approximation is not smooth and thus leads to significant error close to
wall.
• Though the grid can be refined by using a fine mesh to cover the wall region (e.g.,
nested refinement) but this leads to waste of computer memory resources.
• The cells inside the solid part of the cylinder (dead cells) are not involved in the
calculations so they should be removed otherwise they would consume extra space
in computer or other resources. Cartesian grid cells are wasted in dealing with
objects.
• Therefore, there are limitation in using CFD methods based on simple Cartesian
coordinate system as these systems fails while modeling of complex geometries
42
like that of an aerofoil, furnaces, gas turbine combustors, IC-engine etc.
• But most of the engineering problems deal with
complex geometries that don’t work well in the
Cartesian coordinate system.
• Difference between various techniques for complex
geometry lies in the fact that what type of grid
arrangement and what type of discretization
scheme are used to solve.
43
• Since the boundary geometry is irregular for the complex
geometry, tremendous difficulty is encounter in formulating
difference equations for the boundary nodes.
• We have two options if we decide to stick to finite differences.
• First option is: write difference (algebraic) equations manually for
EVERY grid point that lies on irregular boundary, as there is actually
no way to implement it automatically unless you involve some
intelligence there. The reason for that is one need to perform
interpolation for every irregular grid point, and eventually you may
lose accuracy even compared to internal (regular) grid points.
• The second option is, apply some "magic" transformation, so that
your initial irregular domain is mapped onto regular domain. Of
course, now one can easily write difference equations and apply
boundary conditions.
44
• Nothing is for free! All transformation leads to "modified" governing equations and
involve covariant and contrvariant tensors. At a price of more complexity in the
governing equations (the curvature terms) one can minimize the need for
interpolation (surface mass flow rates), minimize storage requirements and
minimize the effects of grid non-orthogonality. Moreover, it involves a lot of
cumbersome analytical work to get a proper mapping.
• Moreover, mapping can not be done for all complex geometries, while there is no
generality there. Applicable to structured (curvilinear) meshes. First generate a
nice looking mesh and then map it. If one accepts the cell-centered scheme, there
is no need to take anything else than the Cartesian velocity components. A
transformation that has been helpful for one geometry, may be of no use for the
others.
• Unstructured mesh, is more or less similar to the finite element mesh. Generally,
we do transform the governing equations for unstructured mesh, rather work with
the cartesian co-ordinate system. However, discretize PDEs into algebraic
equations directly within, say, finite element framework, or, utilize a sophisticated
control-(finite) volume approach that involves intrinsic interpolation functions to
represent temperature (velocity) variations within control volume. Will be
discussed later.
45
Structured Curvilinear (Body-fitted) Grid
• The domain boundaries coincide with the co ordinate lines (body
fitted) therefore all the geometrical details can be incorporated.
• The distribution of function is very fine in curvilinear grid, coarse
grids are able to capture flow details efficiently
• However, grids can be refined easily to capture important flow
features.
• Grid points are identified at the intersection of co-ordinate line.
• They can be arranged into an array and can be named by indices i,
j, k (in 3D)
• The memory resources required in curvilinear grids are less as
compared to Cartesian grids.
• However, integration over the control volume is now not so
straightforward, since cell edges are not aligned with the x and y
axes.
46
Cylindrical Coordinates
47
Spherical Coordinates
48
Mapping
• In curvilinear coordinate system it is difficult to solve the
complex governing flow equations and require separate
programme for each case.
• Therefore Mapping/transformation is used to generate
Simple/ Cartesian (quadrilateral for 2D, hexahedral for 3D)
Computational domain that includes all the features of
corresponding Curvilinear Physical flow domain
• Mapping involves calculating the coordinates of a point
known with respect to a coordinate system to a new
coordinate system.
• However, the equations in curvilinear co-ordinates are much
more complex.
• The mapping is quite tedious if it involves complex geometry.
• Thus, multi-block structured grid offers more flexibility. 49
Mapping of physical geometry to computational geometry
50
Mapping
Properties of Good
Grid
51
Type of Curvilinear Grids
52
Mapping
53
Mapping
54
Mapping
• The governing equation must be transformed from (x,y) to (ξ,η)
as the new independent variable
55
Mapping
• Here we outline how the finite volume method can
be applied on non-orthogonal curvilinear grids
• To transform the governing equations in physical
domain of x and y to computational domain of ξ
and η coordinates, one needs to know how to
transform different derivatives with respect to x
and y into ones with respect to ξ and η.
56
Mapping 1D
57
Mapping 1D
58
Mapping 1D
59
Mapping 1D
60
Mapping 2D
61
Mapping 2D
63
Mapping 2D
64
Mapping 2D
66
Alternatively
• Can also be derived by substituting
direct metrics with inverse metrics
67
Mapping 2D
68
Mapping 2D
69
Mapping 2D
70
Mapping 2D
• Non-splitted derivative is conservative form
71
Mapping 2D
72
Example: Unsteady flow in 2 spatial dimension with no source term
73
Mapping 2D: Second Derivative
• Second derivative using direct transformation
76
Mapping 2D
77
Mapping 2D
78
Mapping 2D
79
80
81
82
Mapping 2D
83
Mapping 2D
84
Mapping 2D
85
Mapping 2D
86
Mapping 2D
87
Mapping 2D
88
89
90
Mapping 2D
91
Mapping 2D
92
Mapping 2D
93
94
95
96
97
98
99
100
• Considering
• The u momentum equation
101
• Considering
• The U momentum equation can be arranged to
102
103
104
Assignment 2.1
105
106
107
108
109
110
• Problem 4
Obtain the momentum equations in polar coordinate systems from
the equation in cartesian system using the transformation/mapping
• Problem 5
Consider a viscous flow over a
flat surface as shown in figure
with physical as well as uniform
computational domains following
transformation ξ=x, η=ln(y+1) or
the inverse transformation x=ξ,
y=exp(η)-1. Transform the steady
state continuity equation from
physical to computational domain
111
Unstructured Grid
• It does not involve a structure of grid lines.
• Control volumes may be arbitrary shaped
• This simplifies the meshing of complex
geometries.
112
2D Unstructured Grid
114
• Conservation Equation in (Volume) Integral form
115
2D Control Volumes
118
• Diffusion term
, thus,
• However, we have used it equal to in discretization
• Thus, the discretization will be accurate, if ξ is parallel to n,
i.e. mesh is orthogonal
• For non-orthogonal mesh the correction is to be added as
cross-diffusion in the source term
• Nonorthogonality or Skewness: Angle between n and ξ
119
• As the grid becomes more skewed and non-orthogonal, these
additional source terms become greater, and the diffusion
effects included implicitly in the coefficients ae, aw, an and as
become smaller. This results in a “stiffer” set of equations,
meaning less numerical stability and slower convergence.
120
121
• Diffusion term evaluation
122
• Diffusion Flux
As source term
123
• Cross diffusion term evaluation
124
• If the grid is non-orthogonal, PA
and ab do not intersect at mid
point.
• Thus, central difference scheme
used will not be second order
accurate as expected.
• To reduce this error, every effort
should be made to control the
skewness and aspect ratio in
unstructured grid.
125
• Convective Term
• Where Fi is convective flux parameter
= mass flow rate normal to surface element
128
• For each node surrounding’0’
• Quick Scheme
• Scheme
• Generalisation
135
• Source term
136
• Discretised Steady Transport Equation
137
Velocity vector arrangement for curvilinear grid
Staggered Contravariant Co-located
139
140
• The linear interpolation leads to zero pressure
gradient for checkered board pressure field,
i.e. no flow.
• Physically the flow must be drawn into P cell
across e and w faces.
• Resulting solution can be oscillatory
141
Co-located Grid
• Rhie and Chow’s pressure interpolation: for pressure
velocity coupling in a co-located arrangement.
142
• Consider third derivative of pressure across face e
• Thus
144
• Interpolated face velocities may be obained using SIMPLE algorithm
for co-located meshes
• Velocity correction
• Pressure correction
145
• This addition does not compromise the solution accuracy, since the
remainder of the method is at best second-order accurate
• It provide damping of the spurious oscillation due to the co-located grid
arrangement
• The damping is caused by restored linkages between the pressure
differences across the control volume faces and the face velocities, which
appear in the continuity equation.
• The source term in the equation is the mass imbalance, which, in a constant
density flow, involves differences between the cell face velocities.
• The addition of a third-order pressure gradient term to each of these
velocities is equivalent to adding a fourth-order pressure gradient term to
their differences in the resulting pressure correction equation.
• It is referred as pressure smoothening term or added dissipation term.
• The method is successful in co-located curvilinear body-fitted and
146
unstructured grids.
• Rhie and Chow’s method for unstructured grid
147
• Generalized expression for face velocity uf in vector
notation for unstructured grid
148
Assignment 2.2
• Example 1: Application of the formulation to a convection–diffusion
problem in 1D Cartesian Grid using upwind differencing scheme
149
150
• Since the faces of the control volumes are perpendicular to
the lines joining nodes, no cross-diffusion terms arise in this
orthogonal grid. Thus, diffusion flux
151
• Mass flow rate through the east and west faces
154
• Mass flow rate through each face
155
• Same as obtained in CFD course
156
• Example 3: Calculate the temperature distribution in 2D hexagonal
ring geometry, given the temperature and flux boundary. The
thermal conductivity of the material is k = 50 W/m.K
157
• Equilateral triangle is orthogonal structured mesh, since normal
vector of the face lies along the lines joining centroids (skewness=0).
No cross diffusion. The value of (n . n/n . e) = 1 for this case.
• In general, the geometrical quantities are calculated using vector
algebra.
• Here, it is obtained using trigonometry as mesh being simple
(equilateral triangle).
• The area of all control volume faces is
• ΔAi = Δη = 2 × 10−2 m2
• and the distance between nodes is
• Δξ = 2/ √3 × 10−2 m
158
• The problem involves conduction only
• Thus, it is diffusion problem without source.
• The governing equation of heat conduction
• Due to symmetry, half the geometry is considered with symmetry
boundary conditions across lines HI and KJ
• Considering
• Discretized equation
159
• Node 1
• Flux through any face is
• Su = 2k√3TBE
• SP = −2k √3
• aP = a4 + a6 − SP = (1 + 1 + 2)k√3
• The discretised equation for node 3 is
• 4T3 = T2 + T4 + 800
• Node 4
• Same as node 2; boundary DF is an insulated boundary (no flux).
• The discretised equation for node 4 is
• 2T4 = T5 + T3 162
• Node 5
• Same as node 1; boundary FG is a
constant temperature boundary.
• Flux through FG is
• Su = 2k√3TFG
• SP = −2k√3
• aP = a4 + a6 − SP = (1 + 1 + 2)k√3
• The discretised equation for node 5 is 4T5 = T4 + T6 + 1000
• Nodes 6 and 8
• Similar to node 3; face EH is a constant temperature boundary, TEH =
200°C, and face BJ is a constant temperature boundary, TBJ = 200°C.
• The discretised equation for node 6 is 4T6 = T5 + T7 + 400
• The discretised equation for node 8 is 4T8 = T1 + T9 + 400 163
• Node 7
• Face HI is a symmetry boundary, so no flux.
Face GI is a constant temperature boundary, TGI = 500°C.
• Flux through GI is
• Su = 2k√3TGI
• SP = −2k√3
• aP = a6 − SP = (1 + 2)k√3
• The discretised equation for node 7 is 3T7 = T6 + 1000
• Node 9
• Same as node 7.
• The discretised equation for node 9 is 3T9 = T8 + 1000
164
• Summarising the discretised equations:
• 4T1 = T2 + T8 + 1000
• 2T2 = T1 + T3
• 4T3 = T2 + T4 + 800
• 2T4 = T5 + T3
• 4T5 = T4 + T6 + 1000
• 4T6 = T5 + T7 + 400
• 3T7 = T6 + 1000
• 4T8 = T1 + T9 + 400
• 3T9 = T8 + 1000
165
• Equations in matrix form:
167
• Heat Flux across the faces
168
• Problem 4:
• Solve the example 3 using OpenFOAM and
compare the results
169
Grid Properties
• General guidelines for generating a suitable grid
170
Grid Selection
• It is very difficult to determine a good grid a-priori except using the
following guidelines.
• The number of iterations needed depends on the local solution value
and gradient compared to the shape and size of local elements.
• The flow visualization can be very helpful in generating a good grid as
a first guess.
• In viscous flow regions such as boundary layers, a structured grid is
recommended. An unstructured grid is not desirable because it will
require too many cells to resolve the turbulent boundary layer
accurately or will result in an inaccurate solution due to long
elongated wafer-like triangular cells.
• The best approach in these situations is to employ a hybrid grid. The
solver will not know the difference so long as the two types of grids
are properly matched point-by-point at the interface.
171
Properties of Good Grid
• Structured Grids: It should be noted that the governing equations of
fluid flow are almost always written in orthogonal coordinate system.
A good grid should reflect this property for obtaining a good solution,
when solving the equations in differential form. Thus, the grid lines
should be orthogonal as much as possible.
• Additionally, they should not be skewed (in curvilinear) and should
not have any cross-overs and kinks. Even with the finite-volume
method, these properties are important for accurate calculation of
fluxes across the cell faces and cell volumes (Jacobians).
• As the grid becomes more skewed and non-orthogonal, these
additional source terms become greater, and the diffusion effects
included implicitly in the coefficients ae, aw, an and as become
smaller. This results in a “stiffer” set of equations, meaning less
numerical stability and slower convergence. 172
Grid Selection
• Unstructured Grids:
• These grids are most widely employed today, especially for treating
complex configurations.
• It is often difficult to use high order convection schemes (QUICK) that
involves φEE, φWW etc. such nodes are difficult to identify in an
unstructured grid.
• There is some memory and CPU overhead for unstructured
referencing.
• While orthogonality is not an issue with these grids, the skewness is a
major concern (<0.85).
• The more skewed the grid cells are, the slower and less stable the
convergence often is.
• Rate of convergence and accuracy depends on both the total number
of elements, and the type and shape of individual elements.
• Accuracy, including interpolated values within an element, depends
on the element type and shape. 173
Grid Selection
• The type of element depends on the physics of the problem and
computational requirements.
• If the accuracy is of the highest concern then hexahedral mesh is the
most preferable one. Hexahedral elements are more efficient so its
computationally more efficient than straight-tetrahedral elements.
For the same cell count, hexahedral meshes will give more accurate
solutions, especially if the grid lines are aligned with the flow.
• The elongated wafer-like cells are not desirable. However, Quad and
Hex cells can be stretched where the flow is fully developed and
one-dimensional.
174
Grid Selection
• Tetrahedral grids provide high resolution of complex geometry but
can take longer to solve.
• Polyhedral mesh: consists of arbitrary polyhedra. This has a lower
cell count compared to a tetrahedral grid, by 3-5 times, this will
reduce CPU resources with the expense of more RAM needed.
• Different mesh elements types should be tested on the model to
identify the best for the problem. Element count, RAM and Time be
compared for each element type.
175
176
Grid Selection
• Hybrid Grids: In some applications, a combination of structured
and unstructured grids is preferable to make use of the good
features of each type to preserve the accuracy in all regions
(boundary layers, shear layers etc.) of the flow.
• In such cases, it should be ensured that the grid points at the
interface of two types of grids are exactly matched. Mismatch
gives rise to inaccuracy and instability in the solution process.
• Can be non-conformal: grids lines don’t need to match at block
boundaries.
• Hex core uses tetrahedral elements on the surface and then are
hexahedral elements around the volume mesh.
• Poly hexcore grids (available in ANSYS 19.2) generate with poly
elements on the surface with hexcore in the volume.
177
Grid near wall
• Near solid or porous walls, the grid must be very fine normal to the
wall for calculating skin-friction and heat transfer.
• Generally quad, hex and prism cells are preferred over triangles,
tetrahedrons and pyramids near the wall
• For turbulent flow, the first grid point away from the wall should be
at y+ < 2, where and if a low Reynolds number
form of the two-equation turbulence model is employed.
• With standard model, with the use of wall functions, y+ ~ 20 may be
O.K. However, the use of wall functions in general is not
recommended, especially for complex flows.
178
Grid size/count
• The computation time of each iteration grows (linearly) with the number
of elements.
• A coarse grid will result in a less accurate solution; on the other hand a fine
grid will be inefficient. However, a coarse mesh may provide an accurate
solution if the solution is a constant.
• Also, a mesh of inferior quality may leave out important features such as
the boundary layer for fluid flow.
• In other regions of high flow or temperature gradients such as shear
layers, jets and wakes, the grid should be fine enough to capture the
gradients using a second-order solver. This requires some knowledge of
the expected flow features on the part of the user unless a
solution-adaptive grid approach is employed which automatically arranges
the grid density appropriately.
• A mesh convergence study consists of refining elements and comparing
the refined solutions to the coarse solutions. If further refinement (or
other changes) does not significantly change the solution, the mesh is an
"Independent Grid.“
179
Grid Count
180
181
182
Aspect ratio
• The shape of the elements is defined by aspect ratio (<100)
• It is ratio of longest to shortest sides of element.
• If the aspect ratio is large the speed of solver reduces while if this
ratio is small the solver speed increases.
• Large aspect ratio has another limitation of leading
to interpolation errors.
• But if the results vary with direction then we use large aspect ratio
• The aspect ratio of element
decide whether a particular
element would be good to
use or we should go for
another element with
different aspect ratio. 183
Smoothness
• There should not be sudden jumps in the size of the cell
because this may cause erroneous results at nearby nodes.
• The change in the size of adjacent cell should not vary by
more than 20%
184
Grid quality
185
Grid Quality Improvement
• Flipping involves combining two triangles to form a
quadrilateral. It is used to improve quality measures of a
triangle such as skewness.
• Splitting the quadrilateral in the other direction to
produce two new triangles.
• Mesh smoothing enhances element shapes and overall
mesh quality by adjusting the location of mesh vertices.
In mesh smoothing, core features are preserved as the
topology of the mesh remains invariant.
• Grid adaption adds more cells where needed to resolve
the flow field during computation
186
Knowing Grid Quality
187