0% found this document useful (0 votes)
13 views

Lecture 2

The document discusses various methods for solving partial differential equations including finite difference, finite volume, and finite element methods. It covers topics like the steps in engineering analysis, classification of PDEs, overview of mesh generation techniques, and finite difference derivation for 1D problems.

Uploaded by

Md. Ragib Rownak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Lecture 2

The document discusses various methods for solving partial differential equations including finite difference, finite volume, and finite element methods. It covers topics like the steps in engineering analysis, classification of PDEs, overview of mesh generation techniques, and finite difference derivation for 1D problems.

Uploaded by

Md. Ragib Rownak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Lecture 1: What we learnt

Ø Why is engineering analysis important?


Ø What are the main steps in engineering analysis?
§ Verification and Validation
§ Sanity Checks
Ø Essentials of MECHENG 6507
§ What it teaches you
§ What it does not teach you
Ø Classification of Partial Differential Equations

1
Lecture 2: What we will learn

Ø Overview of Methods for Solving PDEs


Ø Overview of Types of Meshes
Ø The Finite Difference Method (FDM)
§ Procedure for derivation of discrete equations

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…

All methods require reformulation of the PDE using a set of


discrete points called nodes
The process of conversion of the PDE to a set of algebraic
equations (one for each node) that a digital computer can
solve is called discretization. 3
Deterministic Solution of PDEs
In the finite difference method (FDM), the differential
equation is discretized directly.
Therefore, the solution is known as the strong form solution.

In the finite volume method (FVM), the differential equation


is not discretized directly. It is first integrated analytically
over a control volume. This results in an integral equation.
The integral equation is then discretized and solved.
Since the original differential equation is not solved directly,
but rather, a modified form is solved, the solution is known
as a weak form solution.
In the finite element method (FEM), both approaches are
possible depending on which form (original DE versus
integral equation) the basis functions are applied to. 4
Overview of Mesh Generation
The discretization of the computational domain into smaller
control volumes is called mesh or grid generation
In the early days of numerical analysis, mesh generation was not
an issue. Typical geometries under study were regular
(rectangles, cylinders, spheres etc.). Such geometries are easily
discretizable.
With the advent of faster computers, it is now possible to solve
the governing equations for complex geometries, and
accordingly, mesh generation has become a discipline of its own.

Mesh generation algorithms and tools are typically developed by


applied mathematicians or computer scientists, and is beyond the
scope of MECHENG 6507.

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

If the geometry is more complex, we need to use multiple blocks that


communicate through interfaces. This results in a block structured mesh
j=5 j=8

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

Cartesian Mesh Body fitted mesh

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?

Bad cells with 180o between h and x


directions, instead of the desired 90o.
This will result in a failed transformation.

Certain geometrical shapes are very


difficult to discretize with a structured
mesh.
These include triangles, spirals, toroids
etc., especially if we want to mesh both
the inside and outside of the body.
9
Types of Meshes
Disadvantages of Structured Mesh continued…
Local mesh refinement leads to large mesh count (total cells)

Consider flow over a 2D square

Computational domain

Square

Most of the flow physics (separation, vortices, wakes, re-attachment etc.)


is concentrated to the region around the square. Therefore, we would like
to have finer mesh in that region. 10
Types of Meshes
Disadvantages of Structured Mesh continued…
Local mesh refinement leads to large mesh count (total cells)

Wasted refinement

Number of cells = 3100

11
Types of Meshes
Disadvantages of Structured Mesh continued…
With unstructured mesh, we can attain our goal

Local refinement only

Number of cells = 5105


If each quad was simply split into 2 triangles, we should get 3100x2 =
6200 cells
Thus, we have gained in cell count

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

A structured mesh is a special case of an unstructured mesh—one in


which the cells are numbered in a certain sequence

Therefore, if a solver is designed for an unstructured mesh, it will


work for a structured mesh (since it does not rely upon i,j,k ordering)

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.

This quality makes them truly general-purpose and powerful.


13
Types of Meshes
Disadvantages of unstructured mesh
• Geometric connectivity information has to be stored explicitly since there
is no implicit ordering => more book-keeping, more storage, more memory
• Coefficient matrix is sparse but not banded => certain powerful special
solvers that make use of the i,j,k ordering cannot be used => convergence
could suffer in some cases.

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

The objective is to find the


constant Sf distribution of f within the
𝜙 = 𝜙" 𝜙 = 𝜙!
slab
L

x
This problem can be solved analytically

d 2f 𝜙(0) = 𝜙"
GE = Sf BCs
2 𝜙(𝐿) = 𝜙!
dx
Closed-form analytical 𝜙! − 𝜙" 𝑥 𝐿−𝑥
𝜙 𝑥 = 𝜙" + 𝑥 − 𝑆#
solution (for constant Sf) 𝐿 2

We will later use this closed-form analytical solution for verification of


16
the numerical results
Finite Difference Method for 1D
In the FDM, we will seek the solution of the DE at discrete points within
the computational domain, called nodes.
In general, the node spacing may be equal or unequal.

i=1 i=2 i = N-1 i=N


Dx

For simplicity, let us assume that we have uniform discretization.


Therefore, the grid spacing may be expressed as
L
Dx =
N -1
In order to enable a digital computer to solve this problem, we must
express the second derivative in the form of one or more algebraic
equations.
Generally, the objective is to express the derivative in terms of the nodal
values of f, which in turn, becomes the unknowns that we solve for. 17
Finite Difference Method for 1D
In order to express the derivatives in terms of nodal values, employ
Taylor series expansions.
Dx Dx

i-1 i i+1
W O E

We perform two Taylor series expansions—one forward and one


backward
df (Dx)2 d 2f (Dx)3 d 3f (Dx) 4 d 4f
fE = fO + Dx + + + + ...
dx O 2! dx 2 O
3! dx3 O
4! dx 4 O

df (Dx)2 d 2f (Dx)3 d 3f (Dx) 4 d 4f


fW = fO - Dx + - + + ...
dx O 2! dx 2 O
3! dx3 O
4! dx 4 O

Adding the two expressions, we get

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

Clearly, the fourth derivative of f is an unknown, and therefore, it does


not serve any purpose to retain it.
We can throw out that term and all other higher order terms from the
above equation with the understanding that this will lead to an error.
This implies
d 2f fE + fW - 2fO FD approximation of the derivative

dx 2 O
(Dx) 2

Error introduced by the FD


(Dx) 2 d 4f
e =- + ... approximation, i.e., in converting the
12 dx 4 O derivative to an algebraic equivalent

Since this error is introduced due to truncation of the Taylor series or


due to discretization, it is known as Truncation or Discretization Error 19
Finite Difference Method for 1D
Properties of the Truncation Error
(Dx)2 d 4f
e =- + ...
12 dx 4 O
Note that the error in this case is proportional to the square of the grid
spacing, i.e., e µ (Dx)2
This means that if the number of nodes is doubled (or the grid spacing is
halved), the error will decrease by a factor or 4.
It also implies that as the grid spacing tends to a small value, the error
will also approach a small value but much faster. This is known as the
consistency condition of a scheme.
This is the reason we endeavor to use “fine” mesh in numerical
computations.
The term shown in the above expression is the so-called leading order
error term. All other higher order terms will have higher powers of Dx.
This implies that those terms will approach zero even faster, and
therefore, we need not worry about them. The accuracy of our
computation will be dominated by the leading order error term. 20
Finite Difference Method for 1D
Order of FD Approximation
(Dx)2 d 4f
e =- + ...
12 dx 4 O
Note that the error in this case is proportional to the square of the grid
spacing, i.e., e µ (Dx)2
The power to which the grid spacing is raised to in the leading order
error term is known as the Order of the FD scheme.
In this case it is second order.
As long as the power is a positive definite number, it is a valid scheme.

Dx Dx Recall that to obtain our FD approximation, we


used 2 TSEs, one forward and one backward. The
i-1 i i+1 pivot point, O, is located centrally.
W O E
Such an approximation is known as the
Central Difference Approximation or Scheme
21
Finite Difference Method for 1D
General Procedure for Deriving FD Approximations
Dx Dx This figure is called the stencil
i-1 i i+1
W O E

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

i-2 i-1 i i+1


WW W O E
df (Dx) 2 d 2f (Dx)3 d 3f ( Dx) 4 d 4f
Ax fE = fO + Dx + + + + ...
dx O 2! dx 2 O
3! dx 3 O
4! dx 4 O

df (Dx) 2 d 2f (Dx)3 d 3f (Dx) 4 d 4f


Bx fW = fO - Dx + - + + ...
dx O 2! dx 2 O
3! dx3 O
4! dx 4 O

df (2Dx) 2 d 2f (2Dx)3 d 3f (2Dx) 4 d 4f


Cx fWW = fO - 2Dx + - + + ...
dx O 2! dx 2 O
3! dx 3 O
4! dx 4 O

In this case, it is not clear how the equations should be manipulated to


obtain the third derivative. Thus, we multiply the three equations by A,
B and C, respectively. 23
Finite Difference Method for 1D
General Procedure for Deriving FD Approximations
We want to cancel the first and second derivatives. Therefore,
A – B – 2C = 0 (cancel first derivative)
A + B + 4C = 0 (cancel second derivative)
We also want to set the coefficients of the third derivative summing to
unity. Therefore,
A - B - 8C = 6/(Dx)3
Solving 3 equations with 3 unknowns, we get
A = 1/(Dx)3 B = 3/(Dx)3 C = -1/(Dx)3

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ℎ

Table 1. Errors in various finite difference approximations to 𝑢) 1


𝒉 𝑫!𝒖 𝟏 − 𝐜𝐨𝐬 𝟏 𝑫"𝒖 𝟏 − 𝐜𝐨𝐬 𝟏 𝑫𝟎 𝒖 𝟏 − 𝐜𝐨𝐬 𝟏 𝑫𝟑 𝒖 𝟏 − 𝐜𝐨𝐬 𝟏
0.1 -4.2939E-02 4.1138E-02 -9.0005E-04 6.8207E-05
0.05 -2.1257E-02 2.0807E-02 -2.2510E-04 8.6491E-06
0.01 -4.2163E-03 4.1983E-03 -9.0050E-06 6.9941E-08
0.005 -2.1059E-03 2.1014E-03 -2.2513E-06 8.7540E-09
0.001 -4.2083E-04 4.2065E-04 -9.0050E-08 6.9979E-11

From the table we see that


𝐷*𝑢 𝑥 − 𝑢′ 𝑥 ≈ −0.42ℎ
𝐷+𝑢 𝑥 − 𝑢′ 𝑥 ≈ 0.42ℎ
𝐷,𝑢 𝑥 − 𝑢′ 𝑥 ≈ −0.09ℎ-
𝐷.𝑢 𝑥 − 𝑢′ 𝑥 ≈ 0.007ℎ.
So the error behaves like
𝐸 ℎ = 𝐶ℎ/ where 𝑝 is the order of the accuracy. 25
Exercise
Please verify the following approximation to u’ is third order accurate

2𝑢 𝑥" + ℎ + 3𝑢 𝑥" − 6𝑢 𝑥" − ℎ + 𝑢 𝑥" − 2ℎ


𝐷% 𝑢 𝑥" =
6ℎ

0% 0& 0'
𝑢 𝑥, + ℎ = 𝑢 𝑥, + ℎ𝑢) 𝑥, + -
𝑢)) 𝑥, + 1
𝑢))) 𝑥, + -2
𝑢)))) 𝑥, + 𝑂(ℎ3)

0% 0& 0'
𝑢 𝑥, − ℎ = 𝑢 𝑥, − ℎ𝑢) 𝑥, + -
𝑢)) 𝑥, − 1
𝑢))) 𝑥, + -2
𝑢)))) 𝑥, + 𝑂(ℎ3)

-0 % -0 & -0 '
𝑢 𝑥, − 2ℎ = 𝑢 𝑥, − 2ℎ𝑢) 𝑥, + 𝑢)) 𝑥, − 𝑢))) 𝑥, + 𝑢)))) 𝑥, + 𝑂(ℎ3)
- 1 -2

26

You might also like