Download as pdf or txt
Download as pdf or txt
You are on page 1of 150

COMPUTATIONAL FLUID MECHANICS

Exercises - Block 3
by
José C. F. Pereira / José M. Chaves Pereira / Duarte M. S. Albuquerque
Mech. Eng. Dept. / LASEF / Pav. Mecânica I
jcfpereira@tecnico.ulisboa.pt / jose.chaves@tecnico.ulisboa.pt / duartealbuquerque@tecnico.ulisboa.pt

IST, MFC, 2022 Exercises 1


Unstructured Grid Generation

IST, MFC, 2022 Exercises 2


What should you know
in the end of the eighth lecture?
1 – How to create a triangle grid with the advancing front
method and understand its main strengths and limitations.

2 – What is the meaning of a Delaunay triangulation.

3 – How the Bowyer-Watson algorithm works and its


implications in the grid quality.

4 – Generate a polyhedral grid from


a triangular one.

These topics are also covered at Chapter 8


of this Book - Pages 190-196 / 203-215 / 221-226

IST, MFC, 2022 Exercises 3


Exercise 8.1: Advancing front method
with interior points
Consider the following domain and points in the figure.

a) Describe generically the advancing grid point method.

b) Obtain a triangular mesh with the advancing front method.


Consider the three interior points at the square domain:

a)
Starting from a grid point distribution at the boundary of the problem domain new grid cells are
systematically created successively, until finally the full problem domain is covered with a mesh.

Let us assume first that also the distribution of the interior grid points already is prescribed. In this
case the advancing front methods for generating triangular grids is as follows:

IST, MFC, 2022 Exercises 4


Exercise 8.1: Advancing front method
(i) All edges along the inner boundary of the problem domain are successively numbered
clockwise (not applicable if there are no inner boundaries). The edges along the outer boundary
are successively numbered counterclockwise. The full numbering is consecutively stored in a
vector k defining the advancing front.

The front advances from the outer boundary to


the interior. A different way could be followed.

(ii) For the last edge in the vector k all grid points are searched which are located on or within the
advancing front. From these (admissible) grid points one is selected according to certain criterion,
e.g., the one for which the sum of the distances to the two grid points or the last edge is smallest.
With the selected point and the two points from the last front edge a new triangle is formed.

(iii) The edges of the new triangle, which are contained in k, are deleted and the numbering of the
remaining edges in k is adjusted (compression). The edges of the new triangle, which are not
contained in k, are added at the end of k.

(iv) Steps (ii) and (iii) are repeated until all edges in k are deleted.

IST, MFC, 2022 Exercises 5


Exercise 8.1: Advancing front method
One of the first Examples of Advancing Front Method Publications:

IST, MFC, 2022 Exercises 6


Exercise 8.1: Advancing front method
b) Obtain a triangular mesh with the advancing front method.
Step (i) define your first edge for the front
and code structure to store edges in vectors

14 2
11
15 1
This will be our 12
front edge 4
1 2

1 2 … 11 12

15 4

IST, MFC, 2022 Exercises 7


Exercise 8.1: Advancing front method
12 14 13 Edges
Step (ii) Create a triangle from the front edge.

Example of a structure for triangles 1 …

Vertices
4 1 15 or Points
14 2
11
15 1
13 Define number’s order
12
4 14
1 15
1 2

1 2 … 11 13 14

4 1

IST, MFC, 2022 Exercises 8


Exercise 8.1: Advancing front method

The new front is chosen


in a clockwise way

Front is in black here,


restart from last built
edge

IST, MFC, 2022 Exercises 9


Exercise 8.1: Advancing front method

IST, MFC, 2022 Exercises 10


Exercise 8.1: Advancing front method
FINAL GRID

A different criteria
could be followed
Leading to two
distinct results

Euler’s formula for 2D


closed polygons:

V-E+F=1
15-30+16=1 OK!!!

IST, MFC, 2022 Exercises 11


Exercise 8.2: Advancing front method
without initial interior points distribution
a) Obtain a triangular mesh by the method of advancing grid
points with the introduction of three new points in the
geometry shown in the figure.

b) Describe the advantages and disadvantages of the


advancing front method.

a)

IST, MFC, 2022 Exercises 12


Exercise 8.2: Advancing front method without
initial interior points distribution

IST, MFC, 2022 Exercises 13


Exercise 8.2: Advancing front method without
initial interior points distribution

This example is covered with details in the recommend book at pages 207 to 215.

IST, MFC, 2022 Exercises 14


Exercise 8.2: Advancing front method without
initial interior points distribution
b)

IST, MFC, 2022 Exercises 15


What it is a Delaunay Triangulation?

The circumcenter of
Voronoi Diagram
a triangle can be
can be used to
computed by
compute the
parametrizing the
centers of the
bisector (PM) of the
circumcircles of
12 edge and check
each triangle.
when 𝑃2 = 𝑃3

In this example the


A triangle is circumcircle from BCD
Delaunay if its triangle contains point A
circumcircle does
not contain any This is one is not a
other vertices. Delaunay Triangle

IST, MFC, 2022 Exercises 16


The Bowyer-Watson Algorithm

When inserting a new point, all triangles whose circumcircles contain the new point are deleted.
Which means that their common edges will disappear. A new triangulation is generated by
connecting the new point with the corner points of the polygon which results from the deletion of
the triangles. The methodology is illustrated in the figure below:

erased edges

IST, MFC, 2022 Exercises 17


Exercise 8.3: Bowyer-Watson Application

a) Describe generically the Delaunay triangulation and particularly the Bowyer-Watson algorithm.

b) Generate a Delaunay mesh of:

c) Add a new point to the final grid and explore what could happen.

a)
The Bowyer-Watson algorithm is based on the property that the circle through the three corner
points (circumcircle) of an arbitrary triangle contains no other points (the circumference of a
triangle is uniquely determined and its midpoint is located at the intersection point of the
perpendicular bisectors of the triangle sides). The corresponding grid generation algorithm starts
from a (generally very coarse) initial triangulation of the problem domain. By adding at each time
one new point successively further grids are created, where the corresponding strategy is based
on the above mentioned circumcircle property.

IST, MFC, 2022 Exercises 18


Exercise 8.3: Bowyer-Watson Application
b)

The triangulation procedure can be started from a coarse approach by defining a ‘supertriangle’ fully
containing the problem domain. The nodes of the supertriangle are temporarily added to the list of
nodes and the point insertion procedure is carried out as described above. Finally, after having
inserted all points, all triangles which contain one or more vertices of the supertriangle are removed.

IST, MFC, 2022 Exercises 19


Exercise 8.3: Bowyer-Watson Application

Defining a ‘supertriangle’ one can produce a Delaunay triangulation using, e.g., Mathematica or
Matlab:

New grids have been gradually produced after point insertion…

IST, MFC, 2022 Exercises 20


Exercise 8.3: Bowyer-Watson Application
Grid sequence:

IST, MFC, 2022 Exercises 21


Exercise 8.3: Bowyer-Watson Application
Grid sequence:

FINAL GRID

IST, MFC, 2022 Exercises 22


Exercise 8.3: Bowyer-Watson Application
Details after point #7 insertion:

IST, MFC, 2022 Exercises 23


Exercise 8.3: Bowyer-Watson Application
Details after point #7 insertion:

IST, MFC, 2022 Exercises 24


Exercise 8.3: Bowyer-Watson Application
c) Add a new point to the final grid and explore what could happen.

This bottom triangle


(green) is safe but has
the circumcircle very
close to the insert point

IST, MFC, 2022 Exercises 25


Exercise 8.3: Bowyer-Watson Application

IST, MFC, 2022 Exercises 26


Exercise 8.3: Bowyer-Watson Application
In a different position more triangles could be affected:

IST, MFC, 2022 Exercises 27


Exercise 8.4: Advancing Front Method and
Bowyer-Watson Algorithm Combined.

For the problem geometry shown in figure


generate a triangular grid with the advancing front
method with the black grid points. Afterwards
insert the white grid points into the grid by means
of the Bowyer-Watson algorithm.

Defining a numbering sequence to have a starting front or edge:

1 2

14 5 6

IST, MFC, 2022 Exercises 28


Exercise 8.4: Advancing Front Method and
Bowyer-Watson Algorithm Combined.
Applying the advancing front method:

1 2 1 2

14 5 6 14 5 6

IST, MFC, 2022 Exercises 29


Exercise 8.4: Advancing Front Method and
Bowyer-Watson Algorithm Combined.

1 2 1 2
1 2 1 2

1414 6 14 6
55 6 14 55 6

IST, MFC, 2022 Exercises 30


Exercise 8.4: Advancing Front Method and
Bowyer-Watson Algorithm Combined.

1 2 1 2
1 2 1 2

14 6 14 6
14 55 6 14 55 6

Comparing with a
Delaunay triangulation
one can conclude the
mesh obtained is
Delaunay

IST, MFC, 2022 Exercises 31


Exercise 8.4: Advancing Front Method and
Bowyer-Watson Algorithm Combined.
Including the white grid points:
Mesh before
inserting
white points

IST, MFC, 2022 Exercises 32


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids
Given the mesh in the figure obtain the dual grids
based on cell faces and on cell centers.

What’s this?

In terms of cell faces, one have to generate lines perpendicular to the faces that pass through their
centers. These lines end when an intersection is found, this is the Voronoi diagram approach.

In terms of cell centers, this is done by connecting the centers of the cells around each vertex.

IST, MFC, 2022 Exercises 33


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids
In terms of cell faces we obtain the Voronoi diagram, shown in figure:

Voronoi diagram
from slide 15

IST, MFC, 2022 Exercises 34


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids
In terms of cell centers we obtain a typical polyhedral mesh (if 3D).
The ‘new’ centers of the polyhedral mesh are more aligned (relatively to a common face) than the
case of Voronoi.

Examples from
previous Thesis
supervised by the
Professor - DMSA

IST, MFC, 2022 Exercises 35


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids
StarCCM+ grids – surface view.
At left a tetrahedral grid at right a polyhedral one.
Slight differences in duality should be due to quality constrains.

IST, MFC, 2022 Exercises 36


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids

IST, MFC, 2022 Exercises 37


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids

In three dimensions, it is
difficult to obtain planar
faces, after applying the
dual grid process to a
tetraedral grid

IST, MFC, 2022 Exercises 38


Exercise 8.5: Dual Grids
Generation of Polyhedral Grids

Formiga
(FORced Mesh Improvement and
Generation Algorithm) by
Manuel Dias da Costa

This Matlab code is based in:


DistMesh - A Simple Mesh
Generator in MATLAB
from the Mathematical
Department of MIT

https://popersson.github.io
/distmesh/

IST, MFC, 2022 Exercises 39


Homework 1: From a Previous Test

IST, MFC, 2022 Exercises 40


Homework 2: From a Previous Exam

IST, MFC, 2022 Exercises 41


Homework 3: From a Previous Exam

IST, MFC, 2022 Exercises 42


Homework 4: From a Previous Exam

IST, MFC, 2022 Exercises 43


Homework 5: From a Previous Exam

IST, MFC, 2022 Exercises 44


Exercise 8.6: From a Previous Exam

IST, MFC, 2022 Exercises 45


IST, MFC, 2022 Exercises 46
The Bowyer-Watson algorithm starts by
eliminating all triangles with circumcircles that
contain the red point.
1𝟎%

Create triangles from the nearby


edges that include the red point.
𝟓𝟎%
1𝟎%

IST, MFC, 2022 Exercises 47


The initial grid is not Delaunay.

The Bowyer-Watson algorithm leads to the removal of


triangles that are not Delaunay due to the new point.

According to the Theorem, if the initial grid is


Delaunay, after applying the algorithm the new grid is
still Delaunay one.
𝟏𝟓%

Verify that the final grid is not Delaunay


because the blue circle contains a forth
vertices from a nearby triangle.
𝟏𝟓%

IST, MFC, 2022 Exercises 48


IST, MFC, 2022 Exercises 49
𝟏𝟎% 𝟓
The initial edge or front must be selected. It should be 𝟒
the last or the first one from the our numeration. The 𝟑 𝟔
new front will be the last edge from the last triangle in
a counter clockwise way, starting by the previous front. 𝟐 𝟕
𝟓
𝟒
𝟑 𝟔 𝟖
𝟏

𝟐 𝟕
𝟏𝟐 𝟗
𝟏𝟏
𝟖 𝟏𝟎
𝟏
The first triangle has more quality than the
rectangular option. The third triangle has
𝟏𝟐 𝟗
𝟏𝟏 an higher height than the alternative one
𝟏𝟎 with the boundary edge 2.
𝟓 𝟓
𝟒 𝟒
𝟔 𝟑 𝟔
𝟑
𝟒
𝟐 𝟐 𝟕
𝟕 𝟑

𝟖 𝟖
𝟏 𝟏
𝟏
𝟗 𝟏𝟐 𝟗
𝟏𝟐 𝟏𝟏
𝟏𝟏
𝟏𝟎 𝟗𝟎% 𝟏𝟎
IST, MFC, 2022 Exercises 50
𝟓
𝟒
The fifth triangle is better than 𝟑 𝟖 𝟔
the obtuse-angled alternative.
𝟕
𝟐 𝟕
𝟓
𝟒
𝟑 𝟔 𝟖
𝟏

𝟐 𝟓 𝟕
𝟏𝟐 𝟗
𝟏𝟏
𝟖 𝟏𝟎
𝟏
The seventh triangle is best option between
frame 2 and 3. The front goes to the top
𝟏𝟐 𝟗 edge of seventh triangle creating the eight
𝟏𝟏
𝟏𝟎 one at the top corner.
𝟓 𝟓
𝟒 𝟒
𝟔 𝟑 𝟔
𝟑

𝟐 𝟐 𝟕
𝟕

𝟖 𝟖
𝟏 𝟏

𝟗 𝟏𝟐 𝟗
𝟏𝟐 𝟏𝟏
𝟏𝟏
𝟏𝟎 𝟏𝟎
IST, MFC, 2022 Exercises 51
𝟓
After building the 10th triangle, the front goes 𝟒
to the new edge at the right, counter clockwise. 𝟑 𝟔
The algorithm will create two bad triangles 11 and 12.
This a limitation from the Advancing Front Method. 𝟐 𝟕
𝟓
𝟒
𝟑 𝟔 𝟖
𝟏 𝟏𝟎
𝟏𝟏
𝟐 𝟕
𝟏𝟐 𝟏𝟐 𝟗
𝟏𝟏
𝟖 𝟗𝟎% 𝟏𝟎
𝟏 𝟏𝟎
After the 12th triangle the front must go to the
last available edge from the stack. The final
𝟏𝟐 𝟗 grid configuration is driven from the selected
𝟏𝟏
algorithm and considered criteria.
𝟏𝟎
𝟓 𝟓
𝟒 𝟒
𝟔 𝟑 𝟔
𝟑

𝟐 𝟐 𝟕
𝟕

𝟖 𝟖
𝟏 𝟏𝟎 𝟏
𝟏𝟏
𝟗 𝟏𝟐 𝟗
𝟏𝟐 𝟏𝟏
𝟏𝟏
𝟏𝟎 𝟏𝟎
IST, MFC, 2022 Exercises 52
Finite Volume Discretization
in Unstructured Grids – Part I

IST, MFC, 2022 Exercises 53


What should you know
in the end of the eighth and ninth lectures?
1 – How to apply the finite volume method to an regular arbitrary cell.
(Diffusion, Cell-Centered Gradients and Convection Schemes).

2 – How to correct the diffusion scheme due to the effects of the


warp or non-orthogonality angle (grid quality parameter).

These topics are also covered at Chapter 8


from the Book of Moukalled

IST, MFC, 2022 Exercises 54


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid

IST, MFC, 2022 Exercises 55


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid

𝜕𝜑 𝜕𝜑
+ 𝛻 ∙ 𝑢𝜑 = 𝛻 ∙ 𝜗𝛻𝜑 𝑑𝑉 + 𝛻 ∙ 𝑢𝜑 𝑑𝑉 = 𝛻 ∙ 𝜗𝛻𝜑 𝑑𝑉
𝜕𝑡 𝜕𝑡
𝑉 𝑉 𝑉
integrating

𝜕𝜑
𝑑𝑉 + 𝑢𝜑 ∙ 𝑛𝑑𝑆 = 𝜗𝛻𝜑 ∙ 𝑛𝑑𝑆
𝑉 𝜕𝑡 𝑆 𝑆
Gauss theorem

𝜕𝜑
𝑉+ 𝑢𝑖 𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
fluxes 𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

up to second order

𝜕𝜑
𝑉+ 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

IST, MFC, 2022 Exercises 56


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
3
𝑑/2 = 0.5 × cos 30 =
4
3
𝑑=
2 𝑑
𝑑/2
60°

𝑙 = 0.5Δ = 0.5 𝑛1 = (0,1) 𝑛4 = (0, −1)


evident from the 3 1 3 1
equilateral triangle 𝑛2 = ( , ) 𝑛5 = (− ,− )
2 2 2 2
3 1 3 1
𝑛3 = ( , − ) 𝑛6 = (− , )
2 2 2 2
IST, MFC, 2022 Exercises 57
Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Temporal term

𝜕𝜑
𝑉+ 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜑𝑃𝑛+1 − 𝜑𝑃𝑛 𝑑 1 6 3 3 3
𝑉 𝑣𝑜𝑙 = 𝑉 = 6 × 𝑙 × × = × 0.5 × =
∆𝑡 2 2 4 2 8

Each polyhedral
Has 6 triangles

IST, MFC, 2022 Exercises 58


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Convective fluxes

𝜕𝜑
𝑉+ 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

1 3
time level=n+1 -> Implicit Euler 𝑣=( , )
2 2

𝜑𝑃 𝑣 ∙ 𝑛1 𝑙 + 𝜑𝑃 𝑣 ∙ 𝑛2 𝑙 + 0 + 𝜑𝑁4 𝑣 ∙ 𝑛4 𝑙 + 𝜑𝑁5 𝑣 ∙ 𝑛5 𝑙 + 0

IST, MFC, 2022 Exercises 59


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Convective fluxes

𝜕𝜑
𝑉+ 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

1 3
time level=n+1 -> Implicit Euler 𝑣=( , )
2 2

𝜑𝑃 𝑣 ∙ 𝑛1 𝑙 + 𝜑𝑃 𝑣 ∙ 𝑛2 𝑙 + 0 + 𝜑𝑁4 𝑣 ∙ 𝑛4 𝑙 + 𝜑𝑁5 𝑣 ∙ 𝑛5 𝑙 + 0

1 3 1 3 3 1 1 3
𝑙( × 0 × 𝜑𝑃 + × 1 × 𝜑𝑃 + × 𝜑𝑃 + × 𝜑𝑃 + × 0 × 𝜑4 + × −1 × 𝜑4 +
2 2 2 2 2 2 2 2

1 3 3 1 3 3
+ × (− )𝜑5 + × (− )𝜑5 ) = 0.5( 3𝜑𝑃 − 𝜑 − 𝜑 )
2 2 2 2 2 4 2 5

IST, MFC, 2022 Exercises 60


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Convective fluxes (rotated 60º version)
A clever student suggested
rotating the axis
system. I rotated the picture
60º clockwise.
The result has to be the same. 𝑣 = ( 1, 0 )

The normals are now shifted 𝑛1 -> 𝑛6 ; 𝑛6 -> 𝑛5

Identifying Upwind points is now more easy and


you may only consider 𝑛𝑥 . 𝑛𝑥6 = 𝑛𝑥3 = 0

𝜑𝑃 𝑣 ∙ 𝑛1 𝑙 + 𝜑𝑃 𝑣 ∙ 𝑛2 𝑙 + 0 + 𝜑𝑁4 𝑣 ∙ 𝑛4 𝑙 + 𝜑𝑁5 𝑣 ∙ 𝑛5 𝑙 + 0

3 3 3 3 3 3
𝑙 × 𝜑𝑃 + × 𝜑𝑃 + − × 𝜑4 + + − × 𝜑5 = 0.5( 3𝜑𝑃 − 𝜑4 − 𝜑 )
2 2 2 2 2 2 5

IST, MFC, 2022 Exercises 61


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Diffusive fluxes

𝜕𝜑
𝑉+ 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜕𝜑
𝜗 𝐴
𝜕𝑛 𝑖 𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜑𝑁1 − 𝜑𝑃 𝜑𝑁1 − 𝜑𝑃 3
𝜗𝑙 = 𝜗𝑙 𝑑=
Δ𝑛 𝑑
2

IST, MFC, 2022 Exercises 62


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Diffusive fluxes

𝜕𝜑
𝑉+ 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜕𝜑
𝜗 𝐴
𝜕𝑛 𝑖 𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜑𝑁1 − 𝜑𝑃 𝜑𝑁1 − 𝜑𝑃 3
𝜗𝑙 = 𝜗𝑙 𝑑=
Δ𝑛 𝑑
2

𝜕𝜑 𝜗𝑙
𝜗 𝐴𝑖 = 𝜑𝑁1 − 𝜑𝑃 + (𝜑𝑁2 −𝜑𝑃 + (𝜑𝑁3 −𝜑𝑃 ) + (𝜑𝑁4 − 𝜑𝑃 )
𝜕𝑛 𝑖 𝑑
𝑖∈𝑓𝑎𝑐𝑒𝑠
1
+ 𝜑𝑁5 − 𝜑𝑃 + (𝜑𝑁6 −𝜑𝑃 )] = [−6𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 + 𝜑𝑁4 + 𝜑𝑁5 + 𝜑𝑁6 ]
100 3

IST, MFC, 2022 Exercises 63


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
Finally

time level=n+1

𝜑𝑃𝑛+1 − 𝜑𝑃𝑛 3 3 3
( ) + (2𝜑𝑃 − 𝜑𝑁4 − 𝜑𝑁5 )
∆𝑡 8 4
3
− −6𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 + 𝜑𝑁4 + 𝜑𝑁5 + 𝜑𝑁6 = 0
300

𝜑𝑃𝑛+1 − 𝜑𝑃𝑛 3
( ) + (2𝜑𝑃 −𝜑𝑁4 − 𝜑𝑁5 )
∆𝑡 2
1
− −6𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 + 𝜑𝑁4 + 𝜑𝑁5 + 𝜑𝑁6 = 0
75

IST, MFC, 2022 Exercises 64


Exercise 9.1: Convection-Diffusion Equation
in a Polyhedral Grid
2nd order for diffusive fluxes and first order for time and convective terms.

Very good mesh in terms of warp angle and skewness.

The flow is not aligned with the mesh.


This is not a mesh quality problem but a mesh suitability issue

IST, MFC, 2022 Exercises 65


Exercise 9.1: Cell-Centered Gradients
in a Polyhedral Grid

1
𝛻𝜑𝑖 = 𝜑𝑖 𝑛𝑖 𝑙𝑖
𝐴𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠

𝑛1 = (0,1) 𝑛4 = (0, −1)

3 1 3 1
𝑛2 = ( , ) 𝑛5 = (− ,− )
2 2 2 2

3 1 3 1
𝑛3 = ( , − ) 𝑛6 = (− , )
2 2 2 2

IST, MFC, 2022 Exercises 66


Exercise 9.1: Cell-Centered Gradients
in a Polyhedral Grid
1
𝛻𝜑𝑖 = 𝜑𝑖 𝑛𝑖 𝑙𝑖
𝐴
𝑖∈𝑓𝑎𝑐𝑒𝑠

1 1 1 1 3 1 1 1 3 1
𝜑𝑃 + 𝜑𝑁1 0,1 + 𝜑𝑃 + 𝜑𝑁2 ( , ) + 𝜑𝑃 + 𝜑𝑁3 ( , − ) +
1 2 2 2 2 2 2 2 2 2 2
𝛻𝜑𝑃 =
𝑉
1 1 1 1 3 1 1 1 3 1
𝜑𝑃 + 𝜑𝑁4 0, −1 + 𝜑𝑃 + 𝜑𝑁5 (− , − ) + 𝜑𝑃 + 𝜑𝑁6 (− , )
2 2 2 2 2 2 2 2 2 2

𝑛1 = (0,1) 𝑛4 = (0, −1)

3 1 3 1
𝑛2 = ( , ) 𝑛5 = (− ,− )
2 2 2 2

3 1 3 1
𝑛3 = ( ,− ) 𝑛6 = (− , )
2 2 2 2

IST, MFC, 2022 Exercises 67


Exercise 9.1: Cell-Centered Gradients
3 3 in a Polyhedral Grid
𝑉=
8
1 1 1 1 3 1 1 1 3 1
𝜑𝑃 + 𝜑𝑁1 0,1 + 𝜑𝑃 + 𝜑𝑁2 ( , ) + 𝜑𝑃 + 𝜑𝑁3 ( , − ) +
1 2 2 2 2 2 2 2 2 2 2
𝛻𝜑𝑃 =
𝑉
1 1 1 1 3 1 1 1 3 1
𝜑𝑃 + 𝜑𝑁4 0, −1 + 𝜑𝑃 + 𝜑𝑁5 (− , − ) + 𝜑𝑃 + 𝜑𝑁6 (− , )
2 2 2 2 2 2 2 2 2 2
𝒙𝒙:

𝜕𝜑 8 1 1 3 1 1 3 1 1 3 1 1 3
= 𝜑𝑃 + 𝜑𝑁2 + 𝜑𝑃 + 𝜑𝑁3 − 𝜑𝑃 + 𝜑𝑁5 − 𝜑𝑃 + 𝜑𝑁6
𝜕𝑥 3 3 2 2 2 2 2 2 2 2 2 2 2 2

𝜕𝜑 8 3 3 3 3
= 𝜑𝑃 + 𝜑𝑁2 + 𝜑𝑃 + 𝜑𝑁3 − 𝜑𝑃 + 𝜑𝑁5 − 𝜑𝑃 + 𝜑𝑁6
𝜕𝑥 3 3 8 8 8 8

Does not have 𝜑𝑃 ,


𝜕𝜑 1 normally in regular cells.
= 𝜑 + 𝜑𝑁3 − 𝜑𝑁5 − 𝜑𝑁6
𝜕𝑥 3 𝑁2 Constant values give
a zero derivative.

IST, MFC, 2022 Exercises 68


Exercise 9.1: Cell-Centered Gradients
in a Polyhedral Grid
1 1 1 1 3 1 1 1 3 1
𝜑𝑃 + 𝜑𝑁1 0,1 + 𝜑𝑃 + 𝜑𝑁2 ( , ) + 𝜑𝑃 + 𝜑𝑁3 ( , − ) +
1 2 2 2 2 2 2 2 2 2 2
𝛻𝜑𝑃 =
𝑉
1 1 1 1 3 1 1 1 3 1
𝜑𝑃 + 𝜑𝑁4 0, −1 + 𝜑𝑃 + 𝜑𝑁5 (− , − ) + 𝜑𝑃 + 𝜑𝑁6 (− , )
2 2 2 2 2 2 2 2 2 2

3 3
yy: 𝑉=
8
𝜕𝜑 8 1 1 1 1 1 1
= 𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑃 + 𝜑𝑁2 − 𝜑𝑃 + 𝜑𝑁3 − 𝜑𝑃 + 𝜑𝑁4 − 𝜑𝑃 + 𝜑𝑁5 + 𝜑𝑃 + 𝜑𝑁6
𝜕𝑦 3 3 4 8 8 4 8 8

Does not have 𝜑𝑃 ,


𝜕𝜑 1 normally in regular cells.
= 2𝜑𝑁1 + 𝜑𝑁2 − 𝜑𝑁3 − 2𝜑𝑁4 − 𝜑𝑁5 + 𝜑𝑁6 Constant values give
𝜕𝑦 3 3
a zero derivative.

IST, MFC, 2022 Exercises 69


Exercise 11.2: Choose your Cells and Faces
for the Unstructured Grid Discretization.

IST, MFC, 2022 Exercises 70


Exercise 9.2: Choose your Cells and Faces
for the Unstructured Grid Discretization.

IST, MFC, 2022 Exercises 71


𝑣
For the sake of simplicity,
a good option may be:

- convective flux

- diffusive flux

- cell grad

IST, MFC, 2022 Exercises 72


𝑣
For the sake of simplicity,
a good option may be:

- convective flux

- diffusive flux

- cell grad

IST, MFC, 2022 Exercises 73


Following the Finite Volume framework...

𝜕𝜑 𝜕𝜑
+ 𝛻 ∙ 𝑢𝜑 = 𝛻 ∙ 𝜗𝛻𝜑 𝑑𝑉 + 𝛻 ∙ 𝑢𝜑 𝑑𝑉 = 𝛻 ∙ 𝜗𝛻𝜑 𝑑𝑉
𝜕𝑡 𝑉 𝜕𝑡 𝑉 𝑉
Integrating

𝜕𝜑
𝑑𝑉 + 𝑢𝜑 ∙ 𝑛𝑑𝑆 = 𝜗𝛻𝜑 ∙ 𝑛𝑑𝑆
𝜕𝑡
Gauss theorem 𝑉 𝑆 𝑆

Convective fluxes
𝜕𝜑
𝑉+ 𝑢𝑖 𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝜕𝑡
using first order upwind 𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝑊 𝑃 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝑢𝜑𝑃 𝐿 − 𝑢𝜑𝑊 𝐿 = 𝑢𝐿(𝜑𝑃 − 𝜑𝑊 )


𝑖∈𝑓𝑎𝑐𝑒𝑠

IST, MFC, 2022 Exercises 74


𝜕𝜑 𝜑𝑁1 − 𝜑𝑃
Diffusive fluxes 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝐴 𝜗 𝐿 +⋯
𝜕𝑛 𝑖 𝑖 𝑑
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝑁5 𝑁6 𝐿 𝐿 3 1+ 3
𝑑= + 𝐿 𝑠𝑖𝑛60 = + 𝐿 =𝐿
2 2 2 2
𝑁4 𝑃 𝑁1

𝑁3 𝑁2
𝐿

3
𝐿
𝑑 2
𝑃
𝑑𝑃𝑁1 and 𝑛𝑃𝑁1 are parallel vectors

𝑑𝑃𝑁1
∙ 𝑛𝑃𝑁1 = 1
𝑑𝑃𝑁1

IST, MFC, 2022 Exercises 75


𝜕𝜑
Diffusive fluxes 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝐴
𝜕𝑥 𝑖 𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝑁5 𝑁6

1+ 3 𝑑𝑃𝑁1
𝑁4 𝑃 𝑁1 𝑑=𝐿 ∙ 𝑛𝑃𝑁1 = 1
2 𝑑𝑃𝑁1
𝑁3 𝑁2

𝜑𝑁1 − 𝜑𝑃 𝜑𝑁2 − 𝜑𝑃 𝜑𝑁3 − 𝜑𝑃 𝜑𝑁4 − 𝜑𝑃 𝜑𝑁5 − 𝜑𝑃 𝜑𝑁6 − 𝜑𝑃


𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝐿+𝜗 𝐿+𝜗 𝐿+𝜗 𝐿+𝜗 𝐿+𝜗 𝐿
𝑑 𝑑 𝑑 𝑑 𝑑 𝑑
𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜗𝐿
= 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 + 𝜑𝑁4 + 𝜑𝑁5 + 𝜑𝑁6 − 6𝜑𝑃
𝑑
2𝜗
= 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 + 𝜑𝑁4 + 𝜑𝑁5 + 𝜑𝑁6 − 6𝜑𝑃
1+ 3

IST, MFC, 2022 Exercises 76


Cell Gradients with Linear Interpolation – for the Average Interpolation check Exercise 9.1

1 𝐿 31 3𝐿2
𝛻𝜑𝑖 = 𝜑𝑖 𝑛𝑖 𝑙𝑖 𝑉𝑜𝑙 = 𝐿 =
𝑉𝑜𝑙 2 2 4
𝑓 𝑁1 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝑃 3 1 3 1
𝑁3 𝑁2 𝑛1 = (0,1) 𝑛2 = ( ,− ) 𝑛3 = (− ,− )
2 2 2 2

3 1 1
𝑑𝑃𝑓 = 0, × 𝐿 𝑑𝑁1𝑓 = 0, − 𝐿
𝑑𝑃𝑁1 = 𝑑𝑃𝑓 + 𝑑𝑁1𝑓 2 3 2

||𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 || ||𝑑𝑃1𝑓|| ||𝑑𝑃𝑓 ||


𝜑𝑓 = 𝜑𝑃 + 𝜑𝑁1 = (1 − ) 𝜑𝑃 + 𝜑𝑁1
||𝑑𝑃𝑓 +𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 +𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 +𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 +𝑑𝑁1𝑓 ||

IST, MFC, 2022 Exercises 77


Cell Gradients with Linear Interpolation – for the Average Interpolation check Exercise 9.1

1 𝐿 31 3𝐿2
𝛻𝜑𝑖 = 𝜑𝑖 𝑛𝑖 𝑙𝑖 𝑉𝑜𝑙 = 𝐿 =
𝑉𝑜𝑙 2 2 4
𝑓 𝑁1 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝑃 3 1 3 1
𝑁3 𝑁2 𝑛1 = (0,1) 𝑛2 = ( ,− ) 𝑛3 = (− ,− )
2 2 2 2

3 1 1
𝑑𝑃𝑓 = 0, × 𝐿 𝑑𝑁1𝑓 = 0, − 𝐿
𝑑𝑃𝑁1 = 𝑑𝑃𝑓 + 𝑑𝑁1𝑓 2 3 2

||𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 || ||𝑑𝑃1𝑓|| ||𝑑𝑃𝑓 ||


𝜑𝑓 = 𝜑𝑃 + 𝜑𝑁1 = (1 − ) 𝜑𝑃 + 𝜑𝑁1
||𝑑𝑃𝑓 +𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 +𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 +𝑑𝑁1𝑓 || ||𝑑𝑃𝑓 +𝑑𝑁1𝑓 ||

1 3 1 1 3 1 1 3 1
1 𝜑𝑁1 + 𝜑𝑃 𝜑𝑁2 + 𝜑𝑃 3 1 𝜑𝑁3 + 𝜑𝑃 3 1
𝛻𝜑𝑖 = 3 2 2 0,1 𝐿 + 3 2 2 ,− 𝐿 + 3 2 2 − ,− 𝐿
𝑉𝑜𝑙 1 3 1 1 3 1 2 2 1 3 1 2 2
+ + +
3 2 2 3 2 2 3 2 2

8 1 3 1 1 3 1 3 1 1 3 1 3 1
𝛻𝜑𝑖 = 𝜑𝑁1 + 𝜑𝑃 0,1 + 𝜑𝑁2 + 𝜑𝑃 ( , − ) + 𝜑𝑁3 + 𝜑𝑃 (− ,− )
1+ 3 𝐿 3 2 2 3 2 2 2 2 3 2 2 2 2

IST, MFC, 2022 Exercises 78


Cell gradient in the x direction

𝜕𝜑 8 1 3 1 3 1 3 1 3
= × 𝜑𝑁2 + 𝜑𝑃 − × 𝜑𝑁3 + 𝜑𝑃
𝜕𝑥 𝑃 1+ 3 𝐿 3 2 2 2 3 2 2 2

𝜕𝜑 8 1 3 1 3 𝜕𝜑 2
= × 𝜑𝑁2 − × 𝜑𝑁3 = 𝜑𝑁2 − 𝜑𝑁3
𝜕𝑥 𝑃 1+ 3 𝐿 3 4 3 4 𝜕𝑥 1+ 3 𝐿
𝑃

Cell gradient in the y direction

𝜕𝜑 8 1 3 1 1 3 1 1 3 1
= × 𝜑𝑁1 + 𝜑𝑃 − × 𝜑𝑁2 + 𝜑𝑃 − × 𝜑𝑁3 + 𝜑𝑃
𝜕𝑦 𝑃 1+ 3 𝐿 3 2 2 3 4 4 3 4 4

𝜕𝜑 2 3 𝑁1
= 2𝜑𝑁1 − 𝜑𝑁2 − 𝜑𝑁3
𝜕𝑦 𝑃 3+3 3 𝐿
𝑃
𝑁3 𝑁2

IST, MFC, 2022 Exercises 79


𝑣

IST, MFC, 2022 Exercises 80


𝑣

𝑁1
We have the gradient at cell P and can only apply the Linear Upwind
scheme because the grid has zero warp angle and skewness vector. 𝑃
So other alternatives cannot apply the cell centered gradients. 𝑁3 𝑁2

𝑢𝑖 𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝝋𝑷 + 𝜵𝝋 𝑷 . 𝒅𝑷𝒇 𝑢, 0 ∙ 𝑛2 𝐿 =

We will choose this face


𝜕𝜑 𝜕𝜑 𝐿 3
= 𝜑𝑃 + , . 𝑛2 𝑢, 0 ∙ 𝑛2 𝐿 = N2 since N1 does not have
𝜕𝑥 𝜕𝑦 2×3 a convection contribution.

𝜕𝜑 𝜕𝜑 3 1 𝐿 3 3 1
= 𝜑𝑃 + , . ,− 𝑢, 0 ∙ ,− 𝐿 =
𝜕𝑥 𝜕𝑦 2 2 2×3 2 2

𝜕𝜑 𝜕𝜑 3 1 𝐿 3 3 3 𝐿 𝜕𝜑 𝐿 3 𝜕𝜑
= 𝜑𝑃 + , . ,− 𝑢𝐿 = 𝑢𝐿(𝜑𝑃 + − )
𝜕𝑥 𝜕𝑦 2 2 2×3 2 2 4 𝜕𝑥 𝑃
12 𝜕𝑦 𝑃

IST, MFC, 2022 Exercises 81


𝑣

𝑁1
3 𝐿 𝜕𝜑 𝐿 3 𝜕𝜑 𝑃
𝑢𝑖 𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝑢𝐿(𝜑𝑃 + − )
2 4 𝜕𝑥 𝑃
12 𝜕𝑦 𝑃 𝑁3 𝑁2
𝜕𝜑 2
= 𝜑𝑁2 − 𝜑𝑁3
𝜕𝑥 𝑃 1+ 3 𝐿

We will choose this face


𝜕𝜑 2 3
= 2𝜑𝑁1 − 𝜑𝑁2 − 𝜑𝑁3 N2 since N1 does not have
𝜕𝑦 𝑃 3+3 3 𝐿 Convection contribution.

3 1 1
𝑢𝐿[𝜑𝑃 + 2𝜑𝑁2 − 2𝜑𝑁3 − 2𝜑𝑁1 − 𝜑𝑁2 − 𝜑𝑁3 ] =
2 1+ 3 6 1+ 3

3 1
𝑢𝐿[𝜑𝑃 + −2𝜑𝑁1 + 13𝜑𝑁2 − 11𝜑𝑁3 ]
2 6 1+ 3

IST, MFC, 2022 Exercises 82


Finite Volume Discretization
in Unstructured Grids – Part II

IST, MFC, 2022 Exercises 83


What should you know
in the end of this lecture?
1 – Exercise with the corrected diffusion scheme for grids with
a warp angle different from zero.

2 – How to correct the gradient and convection scheme due to the effects of the
skewness or eccentricity (grid quality parameter).

3 – Ready to make all exercises related with this part of the course.

All Unstructured Grids Topics are well covered in


Chapter 8, 9, 11 and 12 from the Book of Moukalled

IST, MFC, 2022 Exercises 84


What to do when you have a non-orthogonal face?

Star-CCM+ uses the term skewness angle?

Decomposition of the Face Normal into two Contributions for the Diffusion Scheme:

IST, MFC, 2022 Exercises 85


What to do when you have a non-orthogonal face?

Minimal Correction: 𝑬𝒇 and 𝑻𝒇 are orthogonal Orthogonal Correction: |𝑬𝒇 | = |𝑺𝒇 |


|𝑬𝒇 | decreases with the warp angle and |𝑬𝒇 | is independent of the warp angle

𝚫 = 𝑬𝒇 𝐤 = 𝑻𝒇

Images taken from the 1996 PhD of


Hrvoje Jasak (creator of OpenFOAM).
As a complement of pages 242-244
from the Moukalled’s book.
Over-relaxed Correction: 𝑺𝒇 and 𝑻𝒇 are orthogonal
|𝑬𝒇 | increases with the warp angle

IST, MFC, 2022 Exercises 86


What to do when you have a non-orthogonal face?
Decomposition of the Face Normal into two Contributions for the Diffusion Scheme:

𝑺𝒇 . 𝑺𝒇
𝑻𝒇 = 𝑬𝒇 − 𝑺𝒇 𝑬𝒇 = 𝒅
𝒅. 𝑺𝒇

𝜙𝐹 − 𝜙𝐶
𝛻𝜙 𝑓 . 𝐒𝐟 = 𝐸𝑓 + 𝛻𝜙 𝑓 . (𝐒𝐟 − 𝐄𝐟 )
𝑑𝐶𝐹

The Over-relaxed Correction is the most used due to its higher stability.
And the one we used in the course. This slide shows some variants of the same equations.

IST, MFC, 2022 Exercises 87


What to do when you have a non-orthogonal face?

Star-CCM+ uses the term skewness angle?

Decomposition of the Face Normal into two Contributions for the Diffusion Scheme:

IST, MFC, 2022 Exercises 88


What to do when you have a non-orthogonal face?

Minimal Correction: 𝑬𝒇 and 𝑻𝒇 are orthogonal Orthogonal Correction: |𝑬𝒇 | = |𝑺𝒇 |


|𝑬𝒇 | decreases with the warp angle and |𝑬𝒇 | is independent of the warp angle

𝚫 = 𝑬𝒇 𝐤 = 𝑻𝒇

Images taken from the 1996 PhD of


Hrvoje Jasak (creator of OpenFOAM).
As a complement of pages 242-244
from the Moukalled’s book.
Over-relaxed Correction: 𝑺𝒇 and 𝑻𝒇 are orthogonal
|𝑬𝒇 | increases with the warp angle

IST, MFC, 2022 Exercises 89


What to do when you have a non-orthogonal face?
Decomposition of the Face Normal into two Contributions for the Diffusion Scheme:

𝑺𝒇 . 𝑺𝒇
𝑻𝒇 = 𝑬𝒇 − 𝑺𝒇 𝑬𝒇 = 𝒅
𝒅. 𝑺𝒇

𝜙𝐹 − 𝜙𝐶
𝛻𝜙 𝑓 . 𝐒𝐟 = 𝐸𝑓 + 𝛻𝜙 𝑓 . (𝐒𝐟 − 𝐄𝐟 )
𝑑𝐶𝐹

The Over-relaxed Correction is the most used due to its higher stability.
And the one we used in the course. This slide shows some variants of the same equations.

IST, MFC, 2022 Exercises 90


Skewness and Possible Corrections in
Gradients and Convection Schemes

Talk in the blackboard about skewness as a grid quality


and possible corrections in gradients and convection schemes.

Page 254, Pages 274-283 for corrections in gradient schemes.


Slides 5 to 18 from theoretical class 17.

These corrections include the special case of the Linear Upwind Scheme.

𝝋𝒇 = 𝝋𝑷 + 𝜵𝝋 𝑷 . 𝒅𝑷𝒇

IST, MFC, 2022 Exercises 91


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.

IST, MFC, 2022 Exercises 92


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
Convective fluxes

𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

convective term is not affected in comparison to the previous mesh

from previous exercise:

3 3 3
𝜑𝑃 − 𝜑𝑁4 − 𝜑𝑁5
2 4 4

IST, MFC, 2022 Exercises 93


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
Using an origin centred in N8

𝑁8 = (0,0)

3
𝑃 = −0.5, +
4

3
𝑑𝑃𝑁8 = +0.5, −
4

𝑑/2 2
3 1 3 7
𝑑𝑃𝑁8 = 0.52 + = + =
4 4 16 16
3
𝑑/2 =
4
3 1
𝑛8 = ( ,− )
2 2
𝑙 = 0.5Δ = 0.5

IST, MFC, 2022 Exercises 94


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
Diffusive fluxes

𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

𝜕𝜑
𝜗 𝐴
𝜕𝑛 𝑖 𝑖
𝑖∈𝑓𝑎𝑐𝑒𝑠

the same has before but with some changes 𝜑𝑁1 − 𝜑𝑃 𝜑𝑁1 − 𝜑𝑃
in the diffusive flux across face P-N8 𝜗𝑙 = 𝜗𝑙
Δ𝑛 𝑑

𝜑𝑁1 − 𝜑𝑃 𝜑𝑁2 − 𝜑𝑃 𝜑𝑁4 − 𝜑𝑃 𝜑𝑁5 − 𝜑𝑃 𝜑𝑁6 − 𝜑𝑃


𝜗𝑙 + 𝜗𝑙 + 𝜗 𝛻𝜑 8 . 𝑆8 + 𝜗𝑙 + 𝜗𝑙 + 𝜗𝑙
𝑑 𝑑 𝑑 𝑑 𝑑

IST, MFC, 2022 Exercises 95


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
Without non-ortogonal corrections
𝜑𝑁8 − 𝜑𝑃 𝑑𝑃𝑁8
𝜗 𝛻𝜑 . 𝑆8 𝜗 ∙ 𝑆𝑃𝑁8
8 several approaches are available 𝑑𝑃𝑁8 𝑑𝑃𝑁8

Use the over-relaxed expression (more robust)


Minimal Correction

2
𝜑𝑁8 − 𝜑𝑃 𝑆𝑃𝑁8 𝑑𝑃𝑁8 𝑆𝑃𝑁8 𝑑𝑃𝑁8
𝜗 𝛻𝜑 8 . 𝑆8 = 𝜗 𝐸𝑁8 + 𝜗 𝛻𝜑 ∙ 𝑇𝑁8 𝐸𝑁8 = =
𝑑𝑃𝑁8 𝑑𝑃𝑁8 ∙ 𝑆𝑃𝑁8 𝑑𝑃𝑁8 ∙ 𝑛8

3 3 1 3 3 𝑆𝑃𝑁8 = 𝑙 = 0.5
𝑑𝑃𝑁8 ∙ 𝑛8 = +0.5, − ∙ ,− =
4 2 2 8

3
0.5 × 8 +0.5, − 4×3 1 21 7
𝐸𝑁8 = 4 = 2 3,−1 𝐸𝑁8 = + = =
3 3 9 3 81 9 81 27

IST, MFC, 2022 Exercises 96


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
3 1 2 3 1 3 1
𝑇𝑁8 = 𝑆𝑁8 − 𝐸𝑁8 = 0.5 ,− − ,− = + ,+
2 2 9 3 36 12

𝜑𝑁8 − 𝜑𝑃 16
𝜗 𝛻𝜑 8 . 𝑆8 = 𝜗 𝐸𝑁8 + 𝜗 𝛻𝜑 ∙ 𝑇𝑁8 = 𝜗 𝜑𝑁8 − 𝜑𝑃 + 𝜗 𝛻𝜑 ∙ 𝑇𝑁8 =
𝑑𝑃𝑁8 27

4 3 𝜕𝜑 3 𝜕𝜑 1
𝜗 𝛻𝜑 8 . 𝑆8 = 𝜗 𝜑𝑁8 − 𝜑𝑃 +𝜗 × +𝜗 ×
9 𝜕𝑥 36 𝜕𝑦 12

𝜕𝜑 𝜕𝜑 𝜕𝜑
= 0.5 + 0.5 Average of the Cell Centered Gradients
𝜕𝑥 𝜕𝑥 𝑃
𝜕𝑥 𝑁8

IST, MFC, 2022 Exercises 97


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.

𝜑𝑁8 − 𝜑𝑃 𝑑𝑃𝑁8
𝜗 ∙ 𝑆𝑃𝑁8 Example with Minimal Correction and 𝑇𝑁8 = 0
𝑑𝑃𝑁8 𝑑𝑃𝑁8

𝜑𝑁8 − 𝜑𝑃 𝜑𝑁8 − 𝜑𝑃 3 3 1
𝜗 𝑑𝑃𝑁8 ∙ 𝑆𝑃𝑁8 = 𝜗16 0.5, − ∙ ,− × 0.5
7 7 4 2 2
16

𝜑𝑁8 − 𝜑𝑃 3 3 3 3 𝜑𝑁8 − 𝜑𝑃 3 3
𝜗16 × 0.5 + = 𝜗8 × =𝜗 𝜑𝑁8 − 𝜑𝑃
7 4 8 8 7 7

4 3 3 3 Over-Relaxed correction increases with warp


Homework: 𝑇𝑁8 = ? > angle and the minimal correction decreases
9 7

IST, MFC, 2022 Exercises 98


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
𝜑𝑁8 − 𝜑𝑃
𝜗 𝑆𝑃𝑁8 Example with Ortogonal Correction and 𝑇𝑁8 = 0
𝑑𝑃𝑁8

𝜑𝑁8 − 𝜑𝑃 4 × 0.5 2 7
𝜗 0.5 = 𝜗 𝜑𝑁8 − 𝜑𝑃 = 𝜗 𝜑𝑁8 − 𝜑𝑃
7 7 7
16

4 3 2 7 3 3 Ortogonal Correction does not change


> > with the warp angle. It is in the middle
9 7 7 of the other two corrections.

IST, MFC, 2022 Exercises 99


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
Diffusive Schemes with the Non-Orthogonal
Correction have Higher-order Stencils

𝑁𝐶 𝑁𝐹 𝑁𝐹
𝑁𝐶

𝑁𝐹
𝑁𝐶
𝑁𝐶 𝑁𝐹
𝑁𝐶 𝑁𝐶 𝑁𝐹 𝑁𝐹

𝑁𝐶 – Neighbours of Cell C 𝑁𝐹 – Neighbours of Cell F

𝛻𝜑 ∙ 𝑇 = ?

IST, MFC, 2022 Exercises 100


Exercise 11.1: Polyhedral Grid
with a Non-Orthogonal Neighbour.
Diffusive Schemes with the Non-Orthogonal 𝛻𝜑 ∙ 𝑇 = ?
Correction have Higher-order Stencils

When considering all six faces, you get a high-order stencil


with second distance neighbours like in the figure.

IST, MFC, 2022 Exercises 101


Exercise 11.3: Exercise about
a Potato Being Heated in a Microwave.

IST, MFC, 2022 Exercises 102


Yes this appeared
in an MFC exam!

IST, MFC, 2022 Exercises 103


Yes this appear
in an MFC exam!

IST, MFC, 2022 Exercises 104


IST, MFC, 2022 Exercises 105
𝜕𝑇
Applying the finite volume method = 𝛻 ∙ 𝑘𝛻𝑇 + 𝑆
𝜕𝑡
𝑡+∆𝑡 𝑡+∆𝑡 𝑡+∆𝑡
𝜕𝑇 𝜕𝑇
= 𝛻 ∙ 𝑘𝛻𝑇 + 𝑆 𝑑𝑉 𝑑𝑡 = 𝛻 ∙ 𝑘𝛻𝑇 𝑑𝑉 𝑑𝑡 + 𝑆 𝑑𝑉 𝑑𝑡
𝜕𝑡 𝑡 𝑉 𝜕𝑡 𝑡 𝑉 𝑡 𝑉
Integration
𝑡+∆𝑡 𝑡+∆𝑡 𝑡+∆𝑡
𝜕𝑇
𝑑𝑉 𝑑𝑡 = 𝑘𝛻𝑇 ∙ 𝑛𝑑𝑆 𝑑𝑡 + 𝑆 𝑑𝑉 𝑑𝑡
𝑡 𝑉 𝜕𝑡 𝑡 𝑆 𝑡 𝑉
Gauss Theorem
𝑡+∆𝑡 𝑡+∆𝑡 𝑡+∆𝑡
𝜕𝑇𝑃
∆𝑉𝑃 𝑑𝑡 = 𝑘 𝛻𝑇 ∙ 𝑛 𝑑𝑆 𝑑𝑡 + ∆𝑉𝑃 𝑆𝑃 𝑑𝑡
𝑡 𝜕𝑡 𝑡 𝑆 𝑡
Volume integration
in time term
𝑡+∆𝑡 𝑡+∆𝑡
∆𝑉𝑃 𝑇𝑃𝑡+∆𝑡 − 𝑇𝑃𝑡 = 𝑘 𝛻𝑇 ∙ 𝑛 𝑑𝑆 𝑑𝑡 + ∆𝑉𝑃 𝑆𝑃 𝑑𝑡
𝑡 𝑆 𝑡
Time integration
in time term
𝑡+∆𝑡
∆𝑉𝑃 𝑇𝑃𝑡+∆𝑡 − 𝑇𝑃𝑡 = 𝑘 𝛻𝑇 ∙ 𝑛 𝑑𝑆 ∆𝑡 + ∆𝑉𝑃 𝑆𝑃 𝑡+∆𝑡 ∆𝑡
Implicit Euler 𝑆

𝑡+∆𝑡
∆𝑉𝑃 𝑇𝑃𝑡+∆𝑡 − 𝑇𝑃𝑡 = 𝑘𝑓𝑡+∆𝑡 𝛻𝑇 𝑓
∙ 𝑛𝑓 ∆𝑡𝐴𝑓 + ∆𝑉𝑃 𝑆𝑃 𝑡+∆𝑡 ∆𝑡
𝑓∈𝑓𝑎𝑐𝑒𝑠 𝑃

Δ𝑡 𝑛+1
𝑇𝑃𝑛+1 = 𝑇𝑃𝑛 + 𝑘𝑓𝑛+1 𝛻𝑇 ∙ 𝑛𝑓 𝐴𝑓 + Δ𝑡𝑆𝑃𝑛+1
∆𝑉𝑃 𝑓
𝑓∈𝑓𝑎𝑐𝑒𝑠 𝑃

IST, MFC, 2022 Exercises 106


IST, MFC, 2022 Exercises 107
Δ𝑡 𝑛+1
𝑇𝑃𝑛+1 = 𝑇𝑃𝑛 + 𝑘𝑓𝑛+1 𝛻𝑇 ∙ 𝑛𝑓 𝐴𝑓 + Δ𝑡𝑆𝑃𝑛+1
∆𝑉𝑃 𝑓
𝐿𝑐𝑜𝑠 30° 𝐿 3
𝑓∈𝑓𝑎𝑐𝑒𝑠 𝑃
𝑑𝑃𝑁 = 2 × =
3 3

𝐿 × 𝐿𝑐𝑜𝑠 30° 𝐿2 3
𝑓1 𝑓2 ∆𝑉𝑃 = =
2 4

𝑓3

Δ𝑡 𝑇 𝑛+1 − 𝑇𝑃𝑛+1
𝑛+1 𝑁1
𝑇 𝑛+1 − 𝑇𝑃𝑛+1
𝑛+1 𝑁2
𝑇 𝑛+1 − 𝑇𝑃𝑛+1
𝑛+1 𝑁3
𝑇𝑃𝑛+1 = 𝑇𝑃𝑛 + 𝑘𝑓1 + 𝑘𝑓2 + 𝑘𝑓3 𝐿 + Δ𝑡𝑆𝑃𝑛+1
∆𝑉𝑃 𝑑𝑃𝑁 𝑑𝑃𝑁 𝑑𝑃𝑁

4Δ𝑡 𝑛+1 𝑛+1 𝑛+1 𝑛+1 𝑛+1 𝑛+1 𝑛+1 𝑛+1 𝑛+1
𝑇𝑃𝑛+1 = 𝑇𝑃𝑛 + 2
𝑘𝑓1 𝑇𝑁1 + 𝑘𝑓2 𝑇𝑁2 + 𝑘𝑓3 𝑇𝑁3 − 𝑘𝑓1 + 𝑘𝑓2 + 𝑘𝑓3 𝑇𝑃𝑛+1 + Δ𝑡𝛼𝑇𝑃𝑛+1
𝐿

2𝛽Δ𝑡 2 2 2 2 2 2 2 2 2 2
𝑇𝑃𝑛+1 = 𝑇𝑃𝑛 + ∗
𝑇𝑁1 + 𝑇𝑃∗ 𝑇𝑁1
𝑛+1 ∗
+ 𝑇𝑁2 + 𝑇𝑃∗ 𝑇𝑁2
𝑛+1 ∗
+ 𝑇𝑁3 + 𝑇𝑃∗ 𝑇𝑁3
𝑛+1 ∗
− 𝑇𝑁1 ∗
+ 𝑇𝑁2 ∗
+ 𝑇𝑁3 + 3𝑇𝑃∗ 𝑇𝑃𝑛+1 + Δ𝑡𝛼𝑇𝑃𝑛+1
𝐿2

This has to be converged until n+1

2𝛽Δ𝑡 ∗2 ∗2 ∗2 2 2𝛽Δ𝑡 ∗2 2 2𝛽Δ𝑡 ∗2 2 2𝛽Δ𝑡 ∗2 2


1+ 2 𝑇𝑁1 + 𝑇𝑁2 + 𝑇𝑁3 + 3𝑇𝑃∗ 𝑇𝑃𝑛+1 + 2 𝑇𝑁1 + 𝑇𝑃∗ 𝑇𝑁1
𝑛+1
+ 2 𝑇𝑁2 + 𝑇𝑃∗ 𝑇𝑁2
𝑛+1
+ 2 𝑇𝑁3 + 𝑇𝑃∗ 𝑇𝑁3
𝑛+1
= 𝑇𝑃𝑛 + Δ𝑡𝛼𝑇𝑃𝑛+1
𝐿 𝐿 𝐿 𝐿

IST, MFC, 2022 Exercises 108


IST, MFC, 2022 Exercises 109
Actually the used time scheme is first order. But
intention of the question was local (space) order.

Suppose that boundaries conditions are not changing


the local order of each cell.

Source term is integrated with a second-order


approximation in every cell.

The local diffusive scheme is only second-order if:

- warp angle is zero for the derivative at the face


- skewness is zero due to the thermal conductivity interpolation.

This will only happen in the equilateral triangles that have


Regular triangles has neibourghs, marked with a yellow star.

The triangle with a red star can also be include because of


the drawing but it can be an eye trick.

IST, MFC, 2022 Exercises 110


IST, MFC, 2022 Exercises 111
After each grid refinement the error is suppose to have a decay according to the order of the
implemented numerical scheme. The grids are geometrically equivalent (same pattern).

If the error increases while maintaining the same


geometric properties from the previous grid:

- The grid is still too coarse and it is in a non asymptotic


region, so is not possible to get the pretended order.

- Another clever student suggested that this numerical


error increase could be associated to the round-off error
from the floating point arithmetic (see next slide). This
can happen if the grid is too refined.
𝟑𝟎%
𝟑𝟎%

IST, MFC, 2022 Exercises 112


If the grid is too refined, the roundoff error can be higher
than the truncation error of the Finite Difference Formula.
The roundoff error depends if you are using float or double precision.
The roundoff error is normally discussed in introductory numerical analysis courses.

IST, MFC, 2022 Exercises 113


Exercise 11.4 (First Exercise from Previous Year): Finite Volume
Method of Convection-Diffusion Equation on Unstructured Grids

Regarding the convection-diffusion equation, apply the finite volume method to obtain the
discrete equations for cell P in a 2D unstructured grid for a steady problem.
Use upwind for convective fluxes and centred differences for diffusive fluxes.
Consider generic Dirichlet boundary values, a convective velocity = (1,1) and 𝜗=1.
𝜕𝜑
+ 𝛻 ∙ 𝑢𝜑 = 𝛻 ∙ 𝜗𝛻𝜑 + 𝑓
𝜕𝑡

∆𝑥 = ∆𝑦 = 1

P
𝑢

IST, MFC, 2022 Exercises 114


Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

𝜕𝜑 𝜕𝜑
+ 𝛻 ∙ 𝑢𝜑 = 𝛻 ∙ 𝜗𝛻𝜑 + 𝑓 𝑑𝑉 + 𝛻 ∙ 𝑢𝜑 𝑑𝑉 = 𝛻 ∙ 𝜗𝛻𝜑 𝑑𝑉 + 𝑓𝑑𝑉
𝜕𝑡 𝜕𝑡
𝑉 𝑉 𝑉 𝑉
Integrating

𝛻 ∙ 𝑢𝜑 𝑑𝑉 = 𝛻 ∙ 𝜗𝛻𝜑 𝑑𝑉 + 𝑓𝑑𝑉
Back to steady 𝑉 𝑉 𝑉

𝑢𝜑 ∙ 𝑛𝑑𝑆 = 𝜗𝛻𝜑 ∙ 𝑛𝑑𝑆 + 𝑓𝑑𝑉


𝑆 𝑆 𝑉
Gauss theorem

𝑢𝑖 𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 + 𝑓𝑉
Fluxes 𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠

up to second order

IST, MFC, 2022 Exercises 115


Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Let's start by the geometric entities,


𝑦 N2 N1

Unit face normals:


𝑥
𝑛𝑃𝑁1 = (0,1) N3
P

Vector distance projected N5


𝑛𝑃𝑁3 = (−1,0) N4
onto normal:
2 2 5
𝑛𝑃𝑁4 = ( ,− ) 𝑛𝑃𝑁1 ∙ 𝑑𝑃𝑁1 =
2 2 6
Vector distance to cell P: 2 𝑑𝑃𝑁1
𝑛𝑃𝑁3 ∙ 𝑑𝑃𝑁3 = 𝑛𝑃𝑁1
1 5 3
𝑑𝑃𝑁1 = ( , )
6 6 2 𝑑𝑃𝑁3
2 𝑛𝑃𝑁4 ∙ 𝑑𝑃𝑁4 = 𝑛𝑃𝑁3 𝑛𝑃𝑁4
𝑑𝑃𝑁3 = (− , 0) 3 𝑑𝑃𝑁4
3
1 1
𝑑𝑃𝑁4 = ( , − )
3 3
IST, MFC, 2022 Exercises 116
Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Some more geometrical entities,


𝑦 N2 N1

Squared distances to neighbours: i


2 26 𝑥 j
N3
𝑑𝑃𝑁1 = P
36 N5 k
2 4 N4
𝑑𝑃𝑁3 =
9
2 2
𝑑𝑃𝑁4 =
9
𝑑𝑃𝑁1
𝑛𝑃𝑁1
Face (edge) lengths:
𝑙𝑖 = 1 𝑑𝑃𝑁3
𝑛𝑃𝑁3 𝑑𝑃𝑁4 𝑛𝑃𝑁4
𝑙𝑗 = 2
𝑙𝑘 = 1

IST, MFC, 2022 Exercises 117


Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Convective fluxes 𝑑𝑃𝑁1


𝑛𝑃𝑁1
i
𝑢 𝑑𝑃𝑁3 j
𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 + 𝑓𝑉
𝑛𝑃𝑁3 𝑛𝑃𝑁4
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠 k 𝑑𝑃𝑁4

𝑢
𝑢

𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑃𝑁1 𝑙𝑖 + 𝜑𝑗 𝑢𝑗 ∙ 𝑛𝑃𝑁4 𝑙𝑗 + 𝜑𝑘 𝑢𝑘 ∙ 𝑛𝑃𝑁3 𝑙𝑘

using upwind first order

𝜑𝑃 1 × 1 + 𝜑𝑗 0 × 2 + 𝜑𝑁3 −1 1 = 𝜑𝑃 − 𝜑𝑁3
Check sum - OK
no need to compute

IST, MFC, 2022 Exercises 118


Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Convective fluxes 𝑑𝑃𝑁1


𝑛𝑃𝑁1
i
𝑢 𝑑𝑃𝑁3 j
𝑛𝑃𝑁3 𝑛𝑃𝑁4
k 𝑑𝑃𝑁4

𝑢
𝑢

Remarks:
• We assumed the 𝑢𝑖 values are available at face's centroid.
• If it is also cell centred values we need to interpolate with central differences if dealing
with incompressible (elliptic or parabolic) problems.
• However, in Navier-Stokes computations, it is very common to have these values already
stored at face's centres since some pressure correction methods (SIMPLE like methods
for pressure-velocity coupling) use and correct the velocities stored at faces.

IST, MFC, 2022 Exercises 119


Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Diffusive fluxes 𝑑𝑃𝑁1


𝑛𝑃𝑁1
i
𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 + 𝑓𝑉
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑑𝑃𝑁3 j
𝑛𝑃𝑁3 𝑛𝑃𝑁4
k 𝑑𝑃𝑁4
𝜗 is not included in the following just for clearness

𝜑𝑁1 − 𝜑𝑃 𝑑𝑃𝑁1 𝜑𝑁4 − 𝜑𝑃 𝑑𝑃𝑁4 𝜑𝑁3 − 𝜑𝑃 𝑑𝑃𝑁3


∙ 𝑛𝑃𝑁1 𝑙𝑖 + ∙ 𝑛𝑃𝑁4 𝑙𝑗 + ∙ 𝑛𝑃𝑁3 𝑙𝑘
𝑑𝑃𝑁1 𝑑𝑃𝑁1 𝑑𝑃𝑁4 𝑑𝑃𝑁4 𝑑𝑃𝑁3 𝑑𝑃𝑁3

substituting 𝜑𝑁1 − 𝜑𝑃 5 𝜑𝑁4 − 𝜑𝑃 2 𝜑𝑁3 − 𝜑𝑃 2


1+ 2+ 1
26 6 2 3 4 3
36 9 9
simplifying
30 3
𝜑𝑁1 − 𝜑𝑃 + 3 𝜑𝑁4 − 𝜑𝑃 + 𝜑𝑁3 − 𝜑𝑃 This is second order only if
26 2 centroids line connection is
aligned with face normal
147 30 3
− 𝜑𝑃 + 𝜑𝑁1 + 3𝜑𝑁4 + 𝜑𝑁3 Check sum - OK
26 26 2
IST, MFC, 2022 Exercises 120
Exercise 8.1: Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Source term 𝑑𝑃𝑁1


𝑛𝑃𝑁1
i
𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑖 𝐴𝑖 = 𝜗 𝛻𝜑𝑖 ∙ 𝑛𝑖 𝐴𝑖 + 𝑓𝑉
𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑖∈𝑓𝑎𝑐𝑒𝑠 𝑑𝑃𝑁3 j
𝑛𝑃𝑁3 𝑛𝑃𝑁4
k 𝑑𝑃𝑁4

1
𝑓𝑉=𝑓 = 0.5𝑓 This is second order accurate due to centroid definition.
2
The integral of any plane centred on cell is equal to cell's
volume (area) times the function's value at centroid

IST, MFC, 2022 Exercises 121


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
N3 𝑑𝑃𝑁3
P j

What about gradient corrections? N5 𝑛𝑃𝑁3 k 𝑑


𝑃𝑁4
𝑛𝑃𝑁4

(non-orthogonal corrections) N4

IST, MFC, 2022 Exercises 122


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids
To perform gradient corrections to the diffusive fluxes, the cell gradient
must be computed.
Our choice is to interpolate the values to the face, thus weighting with N2 N1
𝑑𝑃𝑁1
distances.
𝑛𝑃𝑁1
i
To obtain gradients at cell P, face i is the only one where the interpolating N3 𝑑𝑃𝑁3 j
P
factors are not 0.5. It is also the only one where the flux must be corrected!
N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
𝑃𝑁4

N4

1 1 2 1
𝑓𝑐𝑖 − 𝑃 ∙ 𝑛𝑃𝑁1 ( , 1) − ( , ) ∙ (0,1) 6
𝜂𝑖𝑁1 = = 2 3 3 3
= =
𝑁1 − 𝑃 ∙ 𝑛𝑃𝑁1 1 3 1 2 5 15
( , ) − ( , ) ∙ (0,1)
2 2 3 3 6
6 9
𝜂𝑖𝑃 =1− = A coordinate system
15 15
centred on was used

IST, MFC, 2022 Exercises 123


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

IST, MFC, 2022 Exercises 124


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids
6 9
𝜂𝑖𝑁1 = 𝜂𝑖𝑃 =
15 15 N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
N3 𝑑𝑃𝑁3
P j

N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
𝑃𝑁4

N4

1 1 1 1 1 2 2 9 6
𝛻𝜑𝑃 = 𝜑𝑃 + 𝜑𝑁3 1 −1,0 + 𝜑𝑃 + 𝜑𝑁4 2 ,− + 𝜑𝑃 + 𝜑𝑁1 1 0,1
𝐴 2 2 2 2 2 2 15 15

1 1 1 1 1 9 6
𝛻𝜑𝑃 = − 𝜑𝑁3 + 𝜑𝑁4 𝑒𝑥 + − 𝜑𝑃 − 𝜑𝑁4 + 𝜑𝑃 + 𝜑 𝑒
𝐴 2 2 2 2 15 15 𝑁1 𝑦

IST, MFC, 2022 Exercises 125


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

simplifying:
N2 N1
𝑑𝑃𝑁1
1 1 1 1 1 6 𝑛𝑃𝑁1
𝛻𝜑𝑃 = − 𝜑𝑁3 + 𝜑𝑁4 𝑒𝑥 + − 𝜑𝑁4 + 𝜑𝑃 + 𝜑𝑁1 𝑒𝑦 i
𝐴 2 2 2 10 15
N3 𝑑𝑃𝑁3
P j
1 1 1 1 1 6 N5 𝑛𝑃𝑁3 k 𝑑
𝑃𝑁4
𝑛𝑃𝑁4
𝛻𝜑𝑃 = − 𝜑𝑁3 + 𝜑𝑁4 𝑒𝑥 + − 𝜑𝑁4 + 𝜑𝑃 + 𝜑𝑁1 𝑒𝑦
0.5 2 2 2 10 15
N4

1 12
𝛻𝜑𝑃 = −𝜑𝑁3 + 𝜑𝑁4 𝑒𝑥 + −𝜑𝑁4 + 𝜑𝑃 + 𝜑 𝑒
5 15 𝑁1 𝑦

Indeed if we check against a linear function, e.g.,


Check sum - OK
𝑓 𝑥, 𝑦 = 𝑥 + 𝑦
it means the scheme is exact for a constant field
the result in y direction is not exact. The scheme is not
second order accurate in y direction.
However, for the present purposes it led us to an
improvement relatively to convection and diffusion
discretizations performed above.

IST, MFC, 2022 Exercises 126


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Regarding cell N1:


N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
𝑓𝑁1𝑟 and 𝑓𝑁1𝑡 are boundary values in the right N3 𝑑𝑃𝑁3 j
P
and top sides, respectively. 𝑛𝑃𝑁4
N5 𝑛𝑃𝑁3 k 𝑑
𝑃𝑁4

N4
𝐴=1

1 1 9 6
𝛻𝜑𝑁1 = 𝜑𝑁1 + 𝜑𝑁2 1 −1,0 + 𝜑𝑃 + 𝜑𝑁1 1 0, −1 + 𝑓𝑁1𝑟 1 1,0 + 𝑓𝑁1𝑡 1 0,1
2 2 15 15

1 1 9 6
𝛻𝜑𝑁1 = − 𝜑𝑁1 − 𝜑𝑁2 + 𝑓𝑁1𝑟 𝑒𝑥 + − 𝜑𝑃 − 𝜑 + 𝑓𝑁1𝑡 𝑒𝑦
2 2 15 15 𝑁1

IST, MFC, 2022 Exercises 127


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Regarding cell N3:


N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
N3 𝑑𝑃𝑁3
P j

N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
𝑃𝑁4

N4

1 1 1 9 6 1 1 2 2
𝛻𝜑𝑁3 = 𝜑𝑃 + 𝜑𝑁3 1 1,0 + 𝜑𝑁3 + 𝜑𝑁2 1 0,1 + 𝜑𝑁5 + 𝜑𝑁3 2 − ,−
𝐴 2 2 15 15 2 2 2 2

1 12
𝛻𝜑𝑁3 = 𝜑𝑃 − 𝜑𝑁5 𝑒𝑥 + 𝜑 + 𝜑 − 𝜑𝑁5 𝑒𝑦
5 𝑁3 15 𝑁2

IST, MFC, 2022 Exercises 128


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Regarding cell N4:


N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
N3 𝑑𝑃𝑁3
P j

N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
𝑃𝑁4

N4

1 1 1 2 2
𝛻𝜑𝑁4 = 𝜑𝑃 + 𝜑𝑁4 2 − , + 𝑓𝑁4𝑟 1 1,0 + 𝑓𝑁4𝑏 1 0, −1
𝐴 2 2 2 2

𝛻𝜑𝑁4 = −𝜑𝑃 − 𝜑𝑁4 + 2 𝑓𝑁4𝑟 𝑒𝑥 + 𝜑𝑃 + 𝜑𝑁4 − 2 𝑓𝑁4𝑏 𝑒𝑦

IST, MFC, 2022 Exercises 129


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Convective fluxes N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑃𝑁1 𝑙𝑖 + 𝜑𝑗 𝑢𝑗 ∙ 𝑛𝑃𝑁4 𝑙𝑗 + 𝜑𝑘 𝑢𝑘 ∙ 𝑛𝑃𝑁3 𝑙𝑘
N3 𝑑𝑃𝑁3
P j
𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
using 'second order' upwind N5 𝑃𝑁4

N4

IST, MFC, 2022 Exercises 130


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Convective fluxes N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
𝜑𝑖 𝑢𝑖 ∙ 𝑛𝑃𝑁1 𝑙𝑖 + 𝜑𝑗 𝑢𝑗 ∙ 𝑛𝑃𝑁4 𝑙𝑗 + 𝜑𝑘 𝑢𝑘 ∙ 𝑛𝑃𝑁3 𝑙𝑘
N3 𝑑𝑃𝑁3
P j
𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
using 'second order' upwind N5 𝑃𝑁4

N4
1 1 1 1 12
𝜑𝑃 + − , ∙ −𝜑𝑁3 + 𝜑𝑁4 𝑒𝑥 + −𝜑𝑁4 + 𝜑𝑃 + 𝜑 𝑒 𝑢𝑖 ∙ 𝑛𝑃𝑁1 𝑙𝑖 + 𝝋𝒋 𝟎 𝒍𝒋
2 3 3 5 15 𝑁1 𝑦

1 1 1 1 12
+ 𝜑𝑁3 + ,− + ∙ 𝜑𝑃 − 𝜑𝑁5 𝑒𝑥 + 𝜑𝑁3 + 𝜑 − 𝜑𝑁5 𝑒𝑦 𝑢𝑘 ∙ 𝑛𝑃𝑁3 𝑙𝑘
3 2 3 5 15 𝑁2

1 1 2 1 4 2 2 1 2 1
𝜑𝑃 − 𝜑𝑁3 + 𝜑𝑁4 − 𝜑𝑁4 + 𝜑𝑃 + 𝜑𝑁1 − 𝜑𝑁3 + 𝜑𝑃 − 𝜑𝑁5 − 𝜑𝑁3 − 𝜑𝑁2 + 𝜑𝑁5
6 6 6 15 15 6 6 30 15 6

22 17 1 4 2 1 gives zero for a constant fi


𝜑𝑃 − 𝜑𝑁3 − 𝜑𝑁4 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁5
30 15 6 15 15 6
Check sum - OK

IST, MFC, 2022 Exercises 131


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Convective fluxes N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
N3 𝑑𝑃𝑁3
P j

N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
𝑃𝑁4

N4

1 1 1
− ,
2 3 3
1 1 1
,− +
3 2 3

IST, MFC, 2022 Exercises 132


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids
Already integrated
Diffusive fluxes N2 N1
𝑑𝑃𝑁1
𝜑𝑁1 − 𝜑𝑃 1 𝑛𝑃𝑁1
𝛻𝜑𝑓 ∙ 𝑆𝑓 = ∆ + 𝛻𝜑𝑃 + 𝛻𝜑𝑁1 ∙ 𝑡 i
𝑑𝑃𝑁1 2
N3 𝑑𝑃𝑁3
P j
The correction approach to be employed considers an
N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
already integrated flux comprising a directional 𝑃𝑁4

derivative (as above... but eventually scaled) plus a N4


correction tangent to the face. Since the final result
should be aligned with normal, the next decomposition
𝑡 = 𝑆𝑛𝑓 − ∆
is to be considered:

0,1 ∙ (0,1) 1 5 1
𝑆𝑛𝑓 ∙ 𝑆𝑛𝑓 ∆= ∙ , = ,1
∆ 𝑆𝑛𝑓 ∆= ∙𝑑 1 5 6 6 5
0,1 ∙ ( , )
𝑆𝑛𝑓 ∙ 𝑑 6 6
𝑑𝑃𝑁1 1 1
𝑡 = 0,1 − ,1 = − ,0
5 5
∆ is a scaling factor to
account for an integrated flux 26 26
value (multiplied by face length). ∆ = 𝑑𝑃𝑁1 =
𝑡 5 6

IST, MFC, 2022 Exercises 133


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Slide from Theoretical class


The most used!

IST, MFC, 2022 Exercises 134


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Slide from Theoretical class

IST, MFC, 2022 Exercises 135


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids
Slide from Theoretical class

IST, MFC, 2022 Exercises 136


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Diffusive fluxes N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
Face to be corrected: i
N3 𝑑𝑃𝑁3
P j

N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
𝜑𝑁1 − 𝜑𝑃 1 𝑃𝑁4
𝛻𝜑𝑓 ∙ 𝑆𝑓 = ∆ + 𝑡 𝛻𝜑𝑃 + 𝛻𝜑𝑁1
𝑑𝑃𝑁1 2 N4

𝜑𝑁1 − 𝜑𝑃 26 1 1 1 12 1 1 9 6
𝛻𝜑𝑓 = + − ,0 −𝜑𝑁3 + 𝜑𝑁4 𝑒𝑥 + −𝜑𝑁4 + 𝜑𝑃 + 𝜑𝑁1 𝑒𝑦 + − 𝜑𝑁1 − 𝜑𝑁2 + 𝑓𝑁1𝑟 𝑒𝑥 + − 𝜑𝑃 − 𝜑𝑁1 + 𝑓𝑁1𝑡 𝑒𝑦
26 5 5 2 5 15 2 2 15 15
6

6 1 1 1
𝛻𝜑𝑓 = 𝜑𝑁1 − 𝜑𝑃 − −𝜑𝑁3 + 𝜑𝑁4 − 𝜑𝑁1 − 𝜑𝑁2 + 𝑓𝑁1𝑟
5 10 2 2

6 5 1 1 1 1
𝛻𝜑𝑓 = − 𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 − 𝜑𝑁4 − 𝑓𝑁1𝑟
5 4 20 10 10 10

IST, MFC, 2022 Exercises 137


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Diffusive fluxes N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
i
Now we just need to replace the already computed N3 𝑑𝑃𝑁3
P j
diffusive flux at face i by the new flux (with gradient
𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
correction) N5 𝑃𝑁4

N4

𝜑𝑁1 − 𝜑𝑃 𝑑𝑃𝑁1 𝜑𝑁4 − 𝜑𝑃 𝑑𝑃𝑁4 𝜑𝑁3 − 𝜑𝑃 𝑑𝑃𝑁3


∙ 𝑛𝑃𝑁1 𝑙𝑖 + ∙ 𝑛𝑃𝑁4 𝑙𝑗 + ∙ 𝑛𝑃𝑁3 𝑙𝑘
𝑑𝑃𝑁1 𝑑𝑃𝑁1 𝑑𝑃𝑁4 𝑑𝑃𝑁4 𝑑𝑃𝑁3 𝑑𝑃𝑁3

substituting 𝜑𝑁1 − 𝜑𝑃 5 𝜑𝑁4 − 𝜑𝑃 2 𝜑𝑁3 − 𝜑𝑃 2


1+ 2+ 1
26 6 2 3 4 3
36 9 9

6 5 1 1 1 1
𝛻𝜑𝑓 = − 𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 − 𝜑𝑁4 − 𝑓𝑁1𝑟
5 4 20 10 10 10

IST, MFC, 2022 Exercises 138


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Diffusive fluxes

obtaining:
6 5 1 1 1 1 3 2 3
− 𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 − 𝜑𝑁4 − 𝑓𝑁1𝑟 + 𝜑𝑁4 − 𝜑𝑃 + 𝜑𝑁3 − 𝜑𝑃
5 4 20 10 10 10 2 2
27 + 15 2 5 1 16 15 2 − 1 1
− 𝜑𝑃 + 𝜑𝑁1 + 𝜑𝑁2 + 𝜑𝑁3 + 𝜑𝑁4 − 𝑓𝑁1𝑟
10 4 20 10 10 10

!!!gives zero for a constant field


Check sum - OK N2 N1
𝑑𝑃𝑁1
𝑛𝑃𝑁1
Remark: i
if you check, for instance, against the linear function used before, N3 𝑑𝑃𝑁3 j
P
you'll find the scheme is not second order accurate. However, the
N5 𝑛𝑃𝑁3 k 𝑑 𝑛𝑃𝑁4
scheme with gradient corrections, conducted to an error 5 times lower 𝑃𝑁4

if compared with the non corrected scheme. N4

IST, MFC, 2022 Exercises 139


Exercise 8.1 : Finite Volume Discretization of Convection-
Diffusion Equation on Unstructured Grids

Some final remarks

Grad schemes are used for:

- computing pressure gradients in the momentum equation.


- computing corrections for diffusive and convective schemes due to grid quality
- computing certain terms of the turbulence models

The corrections of the diffusive and convective schemes are assembled using the
deferred correction method.

The corrections in the case of the diffusive term are used to correct the warp angle
grid quality parameter.

The corrections in the case of the convective term are used to correct the skewness (or
eccentricity) grid quality parameter.

IST, MFC, 2022 Exercises 140


Homework 1: Test 2 from Last Year

IST, MFC, 2022 Exercises 141


Homework 2: From a Previous Test

IST, MFC, 2022 Exercises 142


Homework 3: From a Previous Exam

IST, MFC, 2022 Exercises 143


Homework 4: Theoretical Question – Part A

IST, MFC, 2022 Exercises 144


Homework 5: From a Previous Test

IST, MFC, 2022 Exercises 145


Homework 5a): Big Exercise from Previous Test

IST, MFC, 2022 Exercises 146


Homework 5b): Big Exercise from Previous Test

IST, MFC, 2022 Exercises 147


Homework 6a): Big Exercise from Previous Test

IST, MFC, 2022 Exercises 148


Homework 6b): Big Exercise from Previous Test

IST, MFC, 2022 Exercises 149


IST, MFC, 2022 Exercises 150

You might also like