0% found this document useful (0 votes)
26 views39 pages

FDM Fem

This document provides an overview of finite difference and finite element methods. It begins by introducing differential equations and how derivatives can be approximated using finite differences. It then discusses Taylor series approximations and how they can be used to represent functions. The document outlines how finite difference methods provide natural approximations to derivatives that can be used to solve differential equations numerically.

Uploaded by

seena_smile89
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)
26 views39 pages

FDM Fem

This document provides an overview of finite difference and finite element methods. It begins by introducing differential equations and how derivatives can be approximated using finite differences. It then discusses Taylor series approximations and how they can be used to represent functions. The document outlines how finite difference methods provide natural approximations to derivatives that can be used to solve differential equations numerically.

Uploaded by

seena_smile89
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/ 39

Outline Finite Differences Difference Equations FDM FEM

Finite Difference and Finite Element Methods

Georgy Gimel’farb

COMPSCI 369 Computational Science

1 / 39
Outline Finite Differences Difference Equations FDM FEM

1 Finite Differences

2 Difference Equations

3 Finite Difference Methods: Euler FDMs

4 Finite Element Methods (FEM) [optional]

Learning outcomes:
• Be familiar with the finite difference models and methods (Euler FDMs)
• Optional: Runge-Kutta FDMs, more accurate FEMs

Recommended reading:
• M. T. Heath, Scientific Computing: An Introductory Survey. McGraw-Hill, 2002: Chapters 5, 8 – 11
• M. Shäfer, Computational Engineering - Introduction to Numerical Methods. Springer, 2006: Chapters 3, 5
• G. Strang, Computational Science and Engineering. Wellesley-Cambridge Press, 2007: Chapters 1.2, 3, 6

2 / 39
Outline Finite Differences Difference Equations FDM FEM

Let’s Recall Differential Equations

Modern science and engineering assume our world is continuous


and described by differential equations and integral equations
du(x)
Example I: 1st -order differential equation dx = 2; u(0) = 0
General solution: u(x) = 2x + A
Boundary condition: u(0) = 0 gives A = 0
Final solution: → u(x) = 2x

Unknown u(x) is specified by a known instant speed of changes:

du(x) u(x + ∆x) − u(x)


= lim
dx ∆x→0 ∆x

3 / 39
Outline Finite Differences Difference Equations FDM FEM

Let’s Recall Differential Equations, continued


d2 u(x)
Example II: 2nd -order DE dx2
= 2; u(0) = u(1) = 0
General solution: u(x) = x2 + Ax + B
Boundary conditions: u(0) = 0; u(1) = 0 give B = 0; A = 1
Final solution: → u(x) = x2 − x

Unknown u(x) is specified by a known instant acceleration of


changes:
 
d2 u(x) 1 du(x+∆x) du(x)
dx2
= lim ∆x dx − dx
∆x→0
 
1 u(x+2∆x)−u(x+∆x) u(x+∆x)−u(x)
= lim −
∆x→0 ∆x ∆x ∆x

u(x+2∆x)−2u(x+∆x)+u(x)
= lim ∆x2
∆x→0
4 / 39
Outline Finite Differences Difference Equations FDM FEM

Physical Oscillating Second-order Systems


2
• Non-damped mass on a spring: −m d dtx(t) 2 = kx
• x(t) – a displacement
• k – a spring constant (the Hooke’s law)
• m – a mass

Mass m
x
Displacement x

• Damped mass on a spring θ


(γ – the friction constant): R
2 m
−m d dtx(t)
2 = γ dx(t)
dt + kx
2
• Pendulum: −mR2 ddt2θ = mgR sin θ
2 g mg
⇔ − ddt2θ = R sin θ
5 / 39
Outline Finite Differences Difference Equations FDM FEM

Differences Vs. Derivatives

Finite differences: natural approximations to derivatives

du(x) u(x + ∆x) − u(x) ∆u(x) u(x + ∆x) − u(x)


= lim ⇔ ≡
dx ∆x→0 ∆x ∆x ∆x

u u

x x
∆x

Discrete step ∆x can be small but it does not tend to zero!

6 / 39
Outline Finite Differences Difference Equations FDM FEM

Differences Vs. Derivatives

• Three possibilities for the finite difference:

Test for u(x) = x2


Forward difference u(x+h)−u(x) (x+h)2 −x2
h h = 2x + h

Backward difference u(x)−u(x−h) x2 −(x−h)2


h h = 2x − h

Centred difference u(x+h)−u(x−h) (x+h)2 −(x−h)2


2h 2h = 2x

• Results of testing:
du(x)
• The centred difference gives the exact derivative dx = 2x

• The forward and the backward differences differ by h

7 / 39
Outline Finite Differences Difference Equations FDM FEM

Taylor Series Approximation


• Let u(x) be an arbitrary infinitely differentiable function
• In plain words, let all its derivatives exist:

dn u(x)
; 1≤n≤∞
dxn
n u(x)

• Given u(x0 ) and d dxn ; n = 1, 2, . . ., at x = x0 , the
x=x0
value u(x0 + h) at x = x0 + h is represented by the Taylor’s
series of the values at x = x0 :
∞ n dn (u(x)

P h
u(x0 + h) = u(x0 ) + n! n

n=1 dx
| {z x=x}0
≡u[n] (x0 )

P hn [n]
≡ u(x0 ) + n! u (x0 )
n=1

8 / 39
Outline Finite Differences Difference Equations FDM FEM

A Few Famous Taylor Series


dex

• Exponential function u(x) = ex ⇔ e0 = 1; dx x=0 = ex |x=0 = 1:
h2 h3 h4
⇒ u(0 + h) ≡ eh = 1 + h + + + + ...
2 6 24
• Polynomial ratio
1 du(x) −2x
u(x) = 1+x 2 ⇔ u(0) = 1; dx = (1+x2 )2 = 0;
 x=0
x=0
2
d u(x) 2 8x
= − (1+x 2 )2 + = −2:

dx 2 (1+x2 )3
x=0 x=0

1 1
u(0+h) ≡ 2
= 1−h2 +h4 −. . . ⇒ u(1) = = 1 − 1 + 1 − 1 + . . .
1+h 2
• Trivial for any polynomial
du(x) d2 u(x) d3 u(x)
• u(x) = x3 − 2 ⇔ u(1) = 1; dx
= 3x2 ; dx2
= 6x; dx3
= 6:

h2 h3
⇒ u(1 + h) = −1 + 3h + 6 +6 = −1 + 3h + 3h2 + h3
2 6
9 / 39
Outline Finite Differences Difference Equations FDM FEM

Accuracy of Finite Differences


Taylor series approximations:

u(x + h) = u(x) + hu0 (x) + 12 h2 u00 (x) + 61 h3 u[3] (x) + . . .

u(x − h) = u(x) − hu0 (x) + 21 h2 u00 (x) − 16 h3 u[3] (x) + . . .

• The first-order accuracy O(h) of the one-sided differences:

u(x+h)−u(x)
h = u0 (x) + 12 hu00 (x) + . . .
u(x)−u(x−h)
h = u0 (x) + 12 hu00 (x) + . . .

• The second-order accuracy O(h2 ) of the centred differences:

u(x + h) − u(x − h) 1
= u0 (x) + h2 u[3] (x) + . . .
2h 6

10 / 39
Outline Finite Differences Difference Equations FDM FEM

Second Difference
The second difference approximation of the second derivative:

d2 u ∆2 u u(x + ∆x) − 2u(x) + u(x − ∆x)


2
≈ 2
=
dx ∆x ∆x2

• The second order accuracy O(h2 ) due to the centred ∆2 u:

u(x + ∆x) − 2u(x) + u(x − ∆x) 1


2
= u00 (x) + h2 u[4] (x) + . . .
∆x 12
2 2 +(x−h)2
• Exact second derivatives (x+h) −2x
h2
= 2 for u(x) = x2
(x+h)3 −2x3 +(x−h)3
and h2
= 6x for u(x) = x3
4 4 4
• O(h2 ) accuracy (x+h) −2xh2
+(x−h)
= 12x2 + h2 for u(x) = x4 with
00
the true second derivative u (x) = 12x2
11 / 39
Outline Finite Differences Difference Equations FDM FEM

Finite Difference Equations


2
The 2nd -order differential equation − d dx
u(x)
2 = f (x)
• Known source function f (x)
• Known boundary conditions, e.g. u(0) = 0 and u(1) = 0
Its discrete form – the 2nd -order finite difference equation:
1
• Divide the interval [0, 1] into equal pieces of length h = n+1
that meet at the points x = h, x = 2h, . . . , x = nh:

• Approximate the goal values u(h), . . . , u(nh) at n discrete


points [h, 2h, . . . , nh] inside the interval [0, 1] with the values
2u
u1 , . . . , un , respectively, using the finite difference ∆
∆x2
:

u0 − 2u1 + u2 = f1 ≡ f (h); u1 − 2u2 + u3 = f2 ≡ f (2h);


... un−1 − 2un + un+1 = fn ≡ f (nh)

12 / 39
Outline Finite Differences Difference Equations FDM FEM

Finite Difference Equations: Matrix-Vector Form

For the n unknowns u1 , u2 , . . . , un and the boundary conditions


d2
u0 = un+1 = 0, the differential operator dx 2 is replaced with the
n × (n + 2) matrix:
    
1 −2 1 u0 = 0 f1
 1 −2 1   u1   f2
  
1  . . .

.   ..

− 2
 .. .. ..   .. = .

h 
 
   
 1 −2 1   un   fn−1 
1 −2 1 un+1 = 0 fn

where the source values are specified as fi = f (ih)


2
• For the special case ddxu2 = 1 with the above boundary conditions,
the finite differences give an exact match between u(ih) and ui

13 / 39
Outline Finite Differences Difference Equations FDM FEM

Example with the Constant Source f (x) = 1

2
• Differential equation: − ddxu2 = 1 with u(0) = u(1) = 0
• Complete solution ucomplete = upart + unull :
a particular one for u00 = 1 plus the nullspace one for u00 = 0
2 2
• Particular solution: − ddxu2 = 1 is solved by upart = − x2
2
• Nullspace solution: − ddxu2 = 0 is solved by unull = Cx + D
2
• u(x) = x2 + Cx + D ⇒ From the boundary conditions:
• u(0) = D = 0
• u(1) = − 12 + C + D = 0 → C = − 21 ⇒
2
• u(x) = x−x2

• Difference equation: −ui−1 +2u


h2
i −ui+1
= 1 with u0 = un+1 = 0
2 2
• (!) Just the same parabolic solution: ui = ih−i2 h
• However such a perfect agreement between the discrete ui and
the exact continuous u(ih) is very unusual

14 / 39
Outline Finite Differences Difference Equations FDM FEM

Another Example: Free End Boundary Condition (optional)

Free end condition: zero slope u0 (0) = 0 at x = 0 and u(1) = 0


2
• Differential equation: − ddxu2 = 1 with du
dx (0) = u(1) = 0
2 2
• The complete solution: u(x) = − x2 + Cx + D = 1−x 2
• Boundary conditions:
u0 (0) = C = 0; u(1) = −0.5 + C + D = 0 → D = 0.5
• Difference equation: −ui−1 +2u
h2
i −ui+1
= 1 with u1 −u
h
0
=0
and un+1 = 0
    
1 −1 u1 1
 −1 2 −1  u2   1 
1  .. .. ..

..
 
..

− 2 =
    
. . . . .
h 
 
   
 −1 2 1   un−1   1 
−1 2 un 1
| {z }
Tn

15 / 39
Outline Finite Differences Difference Equations FDM FEM

Free End Boundary Condition, continued

    
u1 n n − 1 n − 2 ... 1 1

 u2 


 n − 1 n − 1 n − 2 ... 1 
 1 

.. n − 2 n − 2 n − 2 ... 1 ..
 = h2 
    
 .  . 
   .. .. .. ..  
 un−1   . . . . 1  1 
un 1 1 1 ... 1 1
| {z }
T−1
n

Discrete solution: ui = h2 (n+i)(n+1−i)


2
• Error w.r.t. the exact solution:
   
i2
u(ih) − ui ≡ u n+1 i
− ui = 12 1 − (n+1) 2 − 12 (n+i)(n+1−i)
(n+1)2
 
= 12 (n+1)
n+1−i
2 = 2
1 1 i
n+1 − (n+1)2 ⇒ O(h)

16 / 39
Outline Finite Differences Difference Equations FDM FEM

Free End Boundary Condition, continued

• Therefore, the one-sided boundary conditions change the


matrix and may result in O(h) error
• A more accurate difference equation can be constructed by
centring the boundary conditions
• Centred difference equation will have 2nd -order errors O(h2 )
• Previous and similar differential and difference equations can
be met in many practical problems
• Simple physical examples of oscillators (see Slide 5):
• a non-damped mass on a spring
• a damped mass on a spring
• a pendulum

17 / 39
Outline Finite Differences Difference Equations FDM FEM

Stiff Differential Equations

A
  z
 }| {      
d v −50 49 v v(0) 2
Example: dt = ; =
w 49 −50 w w(0) 0
Solution: v(t) = e−t + e−99t and w(t) = e−t − e−99t
• Time scales differ by a factor of 99 (the condition number of A)
• Solution decays at the slow time scale of e−t , but computing e−99t
may require a very small step ∆t for stability
• Thus, ∆t is controlled by the fast decaying component, and this is
really counterproductive!
Stiffness comes with any problem involving very different time
scales (chemical kinetics, control theory, circuit simulations, etc.)

18 / 39
Outline Finite Differences Difference Equations FDM FEM

Forward and Backward Euler Methods (optional)

• Differential equation du(t)


dt = f (u, t); an initial value u(0)
• The rate of change u0 is determined by the current state u at
any moment t
• Forward Euler:
un+1 − un
= f (un , tn ) ⇒ un+1 = un + ∆t · fn
∆t
• Backward Euler:
un+1 − un
= f (un+1 , tn+1 ) ⇒ un+1 − ∆t · fn+1 = un
∆t

• Implicit method: if f is linear in u, a linear system is solved at


each step

19 / 39
Outline Finite Differences Difference Equations FDM FEM

Forward and Backward Euler Methods, continued


du(t)
Example: Linear differential equation u0 = au (i.e. dt = au);
u(0) = u0 > 0, with the exact solution: u(t) = eat u(0) ≡ u0 eat

Generally, a is a complex number: a = (Re a) + (Im a) −1
• Forward Euler:
one step un+1 = (1 + a∆t)un → un = (1 + a∆t)n u0
• Convergence: (1 + a∆t)T /∆t → eaT as ∆t → 0
• Sharp instability border 1 + a∆t = −1, i.e. for a = −2/∆t
• Backward Euler:
one step (1 − a∆t)un+1 = un → un = (1 − a∆t)−n u0
• Convergence: (1 − a∆t)−1 = 1 + a∆t+ higher order terms, so
that (1 − a∆t)−T /∆t → eaT as ∆t → 0
• Stability whenever u0 = au is stable (i.e. for a having the
negative real part: Re a < 0)

20 / 39
Outline Finite Differences Difference Equations FDM FEM

Forward and Backward Euler Methods, continued

Since forward and backward differences are first order accurate, the
errors from both methods are O(∆t)
Second-order methods:
• Formal notation: fn = f (un , tn ) and fn+1 = f (un+1 , tn+1 )
• Crank-Nicolson:

un+1 − un fn+1 + fn 1 + 12 a∆t


= ⇒ un+1 = un
∆t 2 1 − 12 a∆t

• Stable even for stiff equations, when a  0

21 / 39
Outline Finite Differences Difference Equations FDM FEM

Forward and Backward Euler Methods, continued


Second-order methods:
• Explicit forward Euler:

un+1 − un 3fn − fn−1


=
∆t 2

• Stable if ∆t is small enough: −a∆t ≤ 1 if a is real


• But explicit systems always impose a limit on ∆t
• Implicit backward difference:

3un+1 − 4un + un−1


= fn+1
2∆t

• More stable and accurate than the Crank-Nicolson method


(trapezoidal rule)
22 / 39
Outline Finite Differences Difference Equations FDM FEM

Explicit and Implicit Multistep Methods (optional)

With p earlier values of un , the accuracy is increased to order p

∇u = u(t) − u(t − ∆t)


∇2 u = u(t) − 2u(t − ∆t) + u(t − 2∆t)
∇3 u = u(t) − 3u(t − ∆t) + 3u(t − 2∆t) − u(t − 3∆t)
...
∇p u = u(t) − pt(y − ∆t) + . . . + (−1)p u(t − p∆t)

• Backward
 differences: 
∇ + 12 ∇2 + . . . + p1 ∇p un+1 = ∆t · f (un+1 , tn+1 )

• Backward Euler method: p = 1


• Implicit backward difference method: p = 2

23 / 39
Outline Finite Differences Difference Equations FDM FEM

Explicit and Implicit Multistep Methods, continued

An alternative: using older values of f (un , tn ) instead of un


• Explicit forward Euler methods:

un+1 − un = ∆t · (b1 fn + . . . + bp fn−p+1 )

order of b1 b2 b3 b4 limit on −a∆t


accuracy for stability
p=1 1 2
p=2 3/2 -1/2 1
p=3 23/12 -16/12 5/12 6/11
p=4 55/24 -59/24 37/24 -9/24 3/10

• The like implicit methods are even more stable and accurate

24 / 39
Outline Finite Differences Difference Equations FDM FEM

Runge-Kutta Methods (optional)

• Highly competitive and self-starting if evaluations of f (u, t)


are not too expensive
• Compound 1-step methods, using Euler’s un + ∆tfn inside
the function f
• Simplified RKM:
 
un+1 − un 1
= fn + f (un + ∆tf n , tn+1 )

∆t 2 | {z }
compounding of f

25 / 39
Outline Finite Differences Difference Equations FDM FEM

Simplified Runge-Kutta Method (optional)

• 2nd -order accuracy


• An example for u0 = au:

un + 21 ∆t[aun + a(u
un+1 =  n + ∆taun )]
1 2 2
= 1 + a∆t + a ∆t un
2
| {z }
Growth factor G

• This growth factor G reproduces the exact ea∆t through the


third term 21 a2 (∆t)2 of the Taylor’s series

26 / 39
Outline Finite Differences Difference Equations FDM FEM

Higher-order Runge-Kutta Method (optional)

−un
• Fourth-order RKM: un+1
∆t = 13 (k1 + 2k2 + 2k3 + k4 ) where

k1 = 12 f (un , tn ) k3 = 21 f un + ∆tk2 , tn+1/2




k2 = 21 f un + ∆tk1 , tn+1/2 k4 = 21 f (un + 2∆tk3 , tn+1 )




• This 1-step method needs no special starting instructions


• It is simple to change ∆t during computations
• The growth factor reproduces ea∆t through the fifth term
1 4 4
24 a (∆t) of the Taylor’s series
• Among highly accurate methods, RKM is especially easy
to code and run – probably the easiest there is!
• The stability threshold is −a∆t < 2.78

27 / 39
Outline Finite Differences Difference Equations FDM FEM

Finite Element Methods (FEM) [optional]

Finite difference methods (FDM) approximate the differential equation


(+) Very easy implementation
(−) Low accuracy between grid points
Finite element methods (FEM) approximate directly the solution of the
differential equation
(+) Easy handling of complex geometry and boundaries of a problem
domain
(±) Usually, more accurate than FDM but this depends on a problem
• Unknown solution u(x) as a combination of n basis functions φ(x):
u(x) = u1 φ1 (x) + . . . + un φn (x)
• FDM are special cases of the FEM with specific basis functions

28 / 39
Outline Finite Differences Difference Equations FDM FEM

Finite Element Methods: Weak Form

• Weak (or variational) form of the differential equation


−u00 (x) = f (x) in [0, 1] with u(0) = u(1) = 0:
• For any smooth function ν(x) satisfying the boundary
conditions ν(0) = ν(1) = 0:

Z1 Z1 Z1
00
f (x)ν(x)dx = − u (x)ν(x)dx = u0 (x)ν 0 (x)dx
0 0 0

Recall the calculus: Integration by parts


Zb Zb
0
y(s)z (s)ds = y(s)z(s)|ba − y 0 (s)z(s)ds
a a

29 / 39
Outline Finite Differences Difference Equations FDM FEM

Galerkin’s FEM: −u00 = f in the discrete weak form


Discretisation of ν(x) with n “test functions” ν1 (x), . . . , νn (x)
• The weak form gives one equation for each νj (x) involving
numerical coefficients u1 , . . . , un :
R1 P R1
n 
dφi (x) dνj (x)
ui dx dx dx = f (x)νj (x)dx; j = 1, . . . , n
0 i=1 0

⇒ Ku = f ,
n
P
that is, Kij ui = fj ; j = 1, . . . , n, where
i=1

Z1   Z1
dφi (x) dνj (x)
Kij = dx and fj = f (x)νj (x)dx
dx dx
0 0

30 / 39
Outline Finite Differences Difference Equations FDM FEM

Galerkin’s FEM: −u00 = f (cont.)

• Mostly, the test functions νi ’s are the same as the basis


functions φi ’s for u(x)
• Then the stiffness matrix K is symmetric and positive
definite
• Integrals of products of φi (x) and νi (x) giving the matrix
components Kij should be finite (−∞ < Kij < ∞)
• So step functions are not allowed as the basis and test
functions!
• Derivative of a step-function is the delta-function δ, and the
squared delta-function δ 2 has an infinite integral
• Linear hat functions (having step functions as their derivatives)
can be used as the basis and test functions

31 / 39
Outline Finite Differences Difference Equations FDM FEM

Linear Finite Elements: Hat Functions

1
h = ; u(x) = u1 φ1 (x) + u2 φ2 (x) + u3 φ3 (x)
3
Basis and test functions φi (x) = νi (x); i = 1, 2, 3:
φ1 (x) φ2 (x) φ3 (x)
1

0 h 2h 1
φ1 (x) φ2 (x) φ3 (x)
1
0≤x≤ 3 3x 0 0
1 2
3 ≤x≤ 3 2 − 3x 3x − 1 0
2
3 ≤x≤1 0 3 − 3x 3x − 2
32 / 39
Outline Finite Differences Difference Equations FDM FEM

Linear Finite Elements: An Example with Hat Functions


φ1 (x) φ2 (x) φ3 (x)
1 0.5 u(x)

u1 u2 u3

0 h 2h 1 0 h 2h 1
Piecewise-linear function u(x) = u1 φ1 (x) + u2 φ2 (x) + u3 φ3 (x)
• Differential equation: −u00 = 1 (i.e. f (x) = 1)
Free-end border conditions u(0) = 0; u0 (0) = 1
• Complete solution of this differential eqution:
2
u(x) = A + Bx − x2 (nullspace + a particular solution);
x2
A = 0 and B = 1 (from the border conditions) ⇒ u(x) = x − 2
• Test functions:
νi : hats φ1 and φ2 and one half-hat φ3 ; h = 31

33 / 39
Outline Finite Differences Difference Equations FDM FEM

FEM Example with Hat Functions (cont.)


Stiffness matrix:
 3  
Z1 6 −3 0
dφi (x) dφj (x) 
K = Kij = dx =  −3 6 −3 
dx dx
0 i,j=1
0 −3 3
dφ1 (x) dφ2 (x) dφ3 (x)
dx dx dx
1
0≤x≤ 3 3 0 0
1 2
3 ≤x≤ 3 −3 3 0
2
3 ≤x≤1 0 −3 3
E.g.
R1  dφ1 (x) 2 1 1 1
K11 = dx dx = 9 · 3 +9· 3 +0· 3 =6
0
R1 dφ1 (x) dφ2 (x) 1 1 1
K12 = dx dx dx =0· 3 −9· 3 +0· 3 = −3
0

34 / 39
Outline Finite Differences Difference Equations FDM FEM

FEM Example with Hat Functions (cont.)


1 1 T
1
Vector f = [f1 , f2 , f3 ]T =

3, 3, 6 :

R1 1/3
R 2/3
R
f1 = φ1 (x)dx = 3xdx + (2 − 3x)dx
0 0 1/3
1/3   2/3
3x2 3x2 1 1 1
= + 2x − = + =

2 2 6 6 3
0 1/3
R1 2/3
R R1
f2 = φ2 (x)dx = (3x − 1)dx + (3 − 3x)dx
0 1/3 2/3
  2/3   1
3x2 3x2 1 1 1
= − x + 3x − = + =

2 2 6 6 3
1/3 2/3
R1 R1
f3 = φ3 (x)dx = (3x − 2)dx
0 2/3
  1
3x2 1
= − 2x =

2 6
2/3

35 / 39
Outline Finite Differences Difference Equations FDM FEM

FEM Example with Hat Functions (cont.)


Solving the finite element equation Ku = f for the mesh values in u:
    
6 −3 0 u1 1/3
 −3 6 −3   u2  =  1/3 
0 −3 3 u3 1/6
| {z } | {z } | {z }
 K  u f 
u1 5/18  5/18 x = 1/3
x2
⇒  u2  =  4/9  ⇔ u(x) = x − 2 = 4/9 x = 2/3
u3 1/2 1/2 x = 1

| {z }
K−1 f

• All three values u1 , u2 , u3 agree exactly with the true solution of


2
the differential equation u(x) = x − x2 at the mesh points
• Values ui by the finite differences were not exact for this equation
36 / 39
Outline Finite Differences Difference Equations FDM FEM

Finite Element Methods Vs. Finite Differences

FEM: two- and three-dimensional meshes of arbitrary geometry,


compared to the inflexibility of a finite difference grid
• Using numerical integration for K and f , FEM allows for any
functions f (x) and c(x)
 in solving
 the differential equation
d du(x)
dx c(x) dx = f (x)
• Linear finite elements:
• 2nd -order accuracy O(h2 ) in u(x) and
• 1st -order accuracy O(h) in du(x)
dx
• Better accuracy – the higher-degree finite elements
• E.g. piecewise cubic polynomials with continuous slopes
• Adding to the hat functions the bubble functions: quadratic
parabolas staying inside each mesh interval

37 / 39
Outline Finite Differences Difference Equations FDM FEM

More Accurate Finite Elements (optional)

Hat + bubble functions → piecewise linear slope u0 (x):

u(x) = u1 φ1 (x)+u2 φ2 (x)+u3 φ3 (x)+u4 φ4 (x)+u5 φ5 (x)+u6 φ6 (x)

u(0.5) = u5 + (u1 + u2 )/2


u(x)
φ4 φ1 φ5 φ2 φ6 φ3 u0 = u2 −u1
1 h

u1 u2 u3

0 h 2h 1 0 h 0.5 2h 1

• Expected accuracy: 3rd -order O(h3 ) in u(x) and


2nd -order O(h2 ) in u0 (x)
• This higher accuracy – without a very fine mesh required by
only linear elements!

38 / 39
Outline Finite Differences Difference Equations FDM FEM

Numerical Linear Algebra

• Applied Mathematics (AM) Vs. Computational Science (CS):


• (AM) Stating a problem and building an equation to describe it
• (CS) Solving that equation using mostly numerical methods
• Numerical linear algebra represents this “build up, break down”
process in its clearest form, with matrix models like Ku = f
• Crucial properties of K:
The algorithm becomes
• symmetric or not
• sparse or not
clearest when it is seen as
• banded or not a factorisation into:
• well conditioned or not triangular matrices or
• Often the computations
orthogonal matrices or
very sparse matrices
break K into simpler pieces

39 / 39

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy