Lecture 2
Lecture 2
1
Lecture 2: What we will learn
2
Deterministic Solution of PDEs
There are many well-established methods for solving PDEs.
The most commonly used ones are
• Finite Difference Method (FDM)
• Finite Volume Method (FVM)
• Finite Element Method (FEM)
• Boundary Element Method (BEM)
• Discontinuous Galerkin Method
• Mesh-less Method (MLM)
• Spectral Element/Volume Method (SEM)
• Others…
5
Types of Meshes
Structured
• Block structured
• Body fitted (coordinate transformed)
Unstructured
What is a structured mesh?
A structured mesh is one that is i, j, k ordered
The biggest advantage of a
j=M structured mesh is that the
connectivity is implicit
For example, if we examine
the cell (2,3), we know
exactly which cell are its
j=1 neighbors: (1,3), (3,3), (2,2)
i=N and (2,4). It is not necessary
i=1 i=2
to state (or store) that
explicitly. 6
Types of Meshes
Advantages of a structured mesh
• Connectivity is implicit: need not be stored => saves memory
• Coefficient matrix is banded => advantageous for solver development
BLOCK 1
BLOCK 2
j=1
i=1 i=6
Note: j = 1 in B1 corresponds to j = 4 in B2.
Such maps have to be stored. Sometimes
j=1
the i , j, k of one block may be j, k, i in the
other. This leads to additional complexity. i=1 i=4
7
Types of Meshes
If the geometry is irregular (such as a bent pipe section), it is necessary to
invoke a coordinate transformation
y h
x
x
In the old days of numerical analysis, only Cartesian meshes were used,
and irregular geometries were treated using stair-step approximations at
the boundary. This results in serious inaccuracy in some cases (imagine
approximating an airfoil by a stair-step!!!)
This serious deficiency prompted discovery and use of body fitted meshes
8
Types of Meshes
Despite the ability of structured meshes to treat complex geometries by
coordinate transformation and use of multiple blocks, structured meshes
still suffer from the following disadvantages:
Structured meshes necessitate that opposite edges (in 2D) and faces (in
3D) have the same number of nodes. This makes creation of a mesh for
certain geometries very difficult, e.g., how do you mesh a triangle?
Computational domain
Square
Wasted refinement
11
Types of Meshes
Disadvantages of Structured Mesh continued…
With unstructured mesh, we can attain our goal
12
Types of Meshes
What is an unstructured mesh?
An unstructured mesh is one in which
Ø The cells can have any shape as long as they are convex polygons (in
2D) or convex polyhedrons (in 3D)
Ø The cells are not numbered in any particular order
Most modern codes for numerical analysis use an unstructured solver, i.e.,
the governing equations are discretized and solved without relying upon
any special ordering of the cells.
Most of the disadvantages are faced by and dealt with by the numerical
code developer.
The end user of an unstructured code does not witness any difference
(difficulty) in using such a code.
On the other hand, the end user can reap all the benefits discussed
earlier.
14
Unstructured Mesh topology
2D
• Triangles
• Quadrilaterals (structured)
• Arbitrary polygons
3D
• Tetrahedrons
• Hexahedrons/ Rectangular prisms (structured)—extruded quads
• Triangular Prisms—extruded triangles
• Pyramids
• Arbitrary polyhedrons
15
Finite Difference Method for 1D
Consider a 1D Poisson Equation
x
This problem can be solved analytically
d 2f 𝜙(0) = 𝜙"
GE = Sf BCs
2 𝜙(𝐿) = 𝜙!
dx
Closed-form analytical 𝜙! − 𝜙" 𝑥 𝐿−𝑥
𝜙 𝑥 = 𝜙" + 𝑥 − 𝑆#
solution (for constant Sf) 𝐿 2
i-1 i i+1
W O E
d 2f (Dx)4 d 4f
fE + fW = 2fO + (Dx) 2
+ + ...
dx 2 O
12 dx 4
O
18
Finite Difference Method for 1D
Rearranging, we get
d 2f fE + fW - 2fO (Dx)2 d 4f
= - + ...
dx2 O
(Dx) 2
12 dx 4 O
Rule: to derive an n-th derivative, one must use at least n+1 points in
the stencil and at least n Taylor series expansions.
For example, it is not possible to derive a second derivative using just
2 points and 1 expansion.
If more expansions (greater than the minimum allowable) are used, it
is possible to eliminate more higher order terms, and therefore, derive
a higher order approximation.
22
Finite Difference Method for 1D
General Procedure for Deriving FD Approximations
Example: Derive a FD approximation for d3f/dx3
Following our rule, we need at least 3 expansions for third derivative
Dx Dx Dx
d 3f
Noting that » AfE + BfW + CfWW - ( A + B + C )fO we get
dx3 O
df3
1 3 1 3
» f
3 E
+ f
3 W
- f
3 WW
- f
3 O
dx3 O
(Dx) (Dx) (Dx) (Dx)
(Dx)4 d 4f 1 d 4f
Error: e » ( A + B + 16C ) 4
= - Dx 4
24 dx O 2 dx O
24
Example 1. Let 𝑢 𝑥 = sin 𝑥 and 𝑥" = 1; Now we calculate 𝑢′ 1 using the four
approximations and compare results with the exact result 𝑢$ 1 = cos 1 .
Approximations of 𝑢′ 𝑥" :
𝑢 𝑥" + ℎ − 𝑢 𝑥" 𝑢 𝑥" − 𝑢 𝑥" − ℎ
1: 𝐷! 𝑢 𝑥" = 2: 𝐷# 𝑢 𝑥" =
ℎ ℎ
𝑢 𝑥" + ℎ − 𝑢 𝑥" − ℎ
3: 𝐷" 𝑢 𝑥" =
2ℎ
2𝑢 𝑥" + ℎ + 3𝑢 𝑥" − 6𝑢 𝑥" − ℎ + 𝑢 𝑥" − 2ℎ
4: 𝐷$ 𝑢 𝑥" =
6ℎ
0% 0& 0'
𝑢 𝑥, + ℎ = 𝑢 𝑥, + ℎ𝑢) 𝑥, + -
𝑢)) 𝑥, + 1
𝑢))) 𝑥, + -2
𝑢)))) 𝑥, + 𝑂(ℎ3)
0% 0& 0'
𝑢 𝑥, − ℎ = 𝑢 𝑥, − ℎ𝑢) 𝑥, + -
𝑢)) 𝑥, − 1
𝑢))) 𝑥, + -2
𝑢)))) 𝑥, + 𝑂(ℎ3)
-0 % -0 & -0 '
𝑢 𝑥, − 2ℎ = 𝑢 𝑥, − 2ℎ𝑢) 𝑥, + 𝑢)) 𝑥, − 𝑢))) 𝑥, + 𝑢)))) 𝑥, + 𝑂(ℎ3)
- 1 -2
26