(Galerkin) Finite Element Approximations: e N e 1 e e e
(Galerkin) Finite Element Approximations: e N e 1 e e e
The finite element method (FEM): special choice for the shape functions .
Ne = 5 Subdivide into elements e:
Ne
[
= e
e=1
1 2 3 4 5 e1 e2 =
x=a x=b
Approximate u on each element separately by a polynomial of some degree p, for
example by Lagrangian interpolation (using p + 1 nodal points per element). The
end points of an element must be nodal points.
Example: linear elements
Ne = 5 n
X
1 uh(x) = uii(x) = T (x)u
3(x)
i=1
B Hierarchical base functions: end points are nodes but internal shape functions
have no nodes (similar to Legrende polynomials). (hp-FEM).
4
X
Ne = 3 uh(x) uh(x) = uii(x) = T (x)u
i=1
u2 u3
u1 u4 u1 1(x)
1 2 3 u2 2(x)
u=
, (x) =
x1 = a x2 x3 x4 = b u3
3(x)
1 u4 4(x)
Ne = 3 3(x)
1 2 3
x1 = a x2 x3 x4 = b
Local numbering in elements
dvh duh
( ,A ) + vh(b)hb = (vh, f ) for all vh Vh
dx dx
Split:
XNe XNe
dvh duh
( ,A ) + vh(b)hb = (vh, f ) for all vh Vh
e=1
dx dx e=1
Write in each element e:
2
X 2
X
ueh(x) = ueii(x) = T (x)ue, vhe (x) = viei(x) = T (x)v e
i=1 i=1
We get:
Ne
X Ne
X
(v Te K eue) + vnhb = v Te f e
e=1
e=1
where
d dT Z
d dT
Ke = ,A = A dx
dx dx e e dx dx
Z
fe = (, f )e = f dx
e
Ne
X Ne
X X
Ne
v Te K eue = v T
P Te K eP e u
=v T
K e u
| {z }
e=1
e=1 e=1
K e
XNe XNe X
Ne
v Te f e = v T P Te f e = v T f e
e=1
e=1
|
{z } e=1
f e
Weak form
vT K u = vT f for all v
or
Ku = f
with
Ne
X
K= K e
e=1
0
Ne
X 0
.
f= f e +
.
e=1 0
hb
Example (1)
For example:
u1
u2 0 1 0 0 u2 = P 2u
u2 = =
u3 0 0 1 0 u3
| {z }
P2 u4
0 0
2
1 0 K11 K12 2
0 1 0 0
K 2 = P T2 K 2P 2 =
0 1 K21 2 2
K22 0 0 1 0
0 0
0 0 0 0
0 K11 2 2
K12 0
=
0 K21 K22 0
2 2
0 0 0 0
Example (2)
Assembly of K :
1 1
K11 K12 0 0 0 0 0 0 0 0 0 0
K211
K 1
0 0 0 K11 2
K122
0 0
K= 22 + + 0 0 0
0 0 0 0 0 K21 2
K222
0 0 3 3
0 K11 K12
3 3
0 0 0 0 0 0 0 0 0 0 K21 K22
1 1
K11 K12 0 0
K211 1
K22 2
+ K11 2
K12 0
= 2 2 3
3
0 K21 K22 + K11 K12
3 3
0 0 K21 K22
The bandwidth of K for linear shape functions is 3. How large is the bandwidth
for K when using polynomial shape functions of order k, k 1?
Dirichlet conditions
u u u
+ a (A ) + bu = f
t x x x
and
u = ua(t), at x = a, t > 0 (D )
du
A = hb(t) at x = b, t > 0 (N )
dx
Notes:
5
+ = 2D
where
5
= L LT
or
+ ~u L LT + = 2 D
t
|{z} | {z } | {z } |
{z }
u a u bu f
t x
Scaling:
U u aU u AU 2u
+
2 2
+ bU u =f
tc t L x L x
Relative to convection:
L u u 1 2u bL L
+ + u = f
atc t x Pe x2 a aU
aL
Pe = : Peclet number, convection/diffusion.
A
Dimensionless form (2)
Time scales:
L
B convection:
a
2
L
B diffusion:
A
1
B source: (relaxation time)
b
B time scales in b.c.
B externally or internally generated frequencies (von Karman vortex)
u u 1 2u
+ + b u = f
t x Pe x2
bL L
with b = and f = f . Pe > 1 : convection dominated
a aU
Exercise 6
L2
Assume b = 0 and f = 0. We take for the typical time scale tc = (diffusion
A
time scale). Show that we now have the non-dimensional form
u u 2u
+ Pe 2 = 0
t x x
When will this non-dimensional form be preferable over the one on the previous
slide?
Steady state 1D convection-diffusion-reaction equation
du d du
L(u) = a (A ) + bu = f
dx dx dx
u = ua, at x = a (D )
du
A = hb at x = b (N )
dx
Weak form
Partial integration of the diffusion term and inserting b.c. we get: Find u S
such that
dv du du
( , A ) + (v, a ) + (v, bu) + v(b)hb = (v, f ) for all v V
dx dx dx
where (x) are global shape functions. Substituting this into the weak form gives:
Find uh Sh such that
and thus
Ku = f
with
d dT di dj
K = ( , A ) or Kij = ( ,A )
dx dx dx dx
dT dj
+ (, a ) + (i, a )
dx dx
+ (, bT ) + (i, bj )
f = (, f ) hb(b) fi = (i, f ) hbi(b)
Galerkin FEM approximations (3)
Build from element matrices. For example with constant coefficients and linear
element shape functions:
d dT 1 1 1
( , )e = stiffness matrix
dx dx h 1 1
dT 1 1 1
(, )e = convection matrix
dx 2 1 1
h 2 1
(, T )e = mass matrix
6 1 2
ui1 + ui+1 du
= (xi) + O(h2)
2h dx
Global mass matrix
In that case: X
fi = (i, f ) = (i, k )fk
k
with (i, k ) the mass matrix.
Finite difference scheme: (divide by h)
a. Verify the element stiffness, convection and mass matrix by performing the
integrations.
b. Assume a non-equidistant grid and denote the element sizes by h1, h2,. . . ,hNe .
How does the global stiffness matrix now look like? Has the global convection
matrix still a zero on the diagonal?
Example: 1D steady convection-diffusion (1)
Equation:
du 1 d2u
=0 on (0, 1)
dx Pe dx2
with b.c.
u(0) = 0, u(1) = 1
Exact solution:
1 exp(Pex)
u(x) =
1 exp(Pe)
Example: 1D steady convection-diffusion (2)
1
Pe=1 exact
Pe=1 GFEM
0.8 Pe=10 exact
Pe=10 GFEM
0.6 Pe=100 exact
Pe=100 GFEM
0.4
0.2
u(x)
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
Example: 1D steady convection-diffusion (2)
Ne = 10, 20; Pe = 25
1
Pe=25 exact
Pe=25 Ne=10
Pe=25 Ne=20
0.8
0.6
u(x)
0.4
0.2
-0.2
0 0.2 0.4 0.6 0.8 1
x
Observations (1)
1
B Boundary layer of width .
Pe
B Global upstream wiggles appear when the boundary layer is not resolved by
the mesh.
B Governed by the mesh Peclet number Peh:
ah 1h
Peh = = Pe
2A 2 L
where wiggles appear when
h 2
Peh > 1 or >
L Pe
or wiggle-free when
h 2
<
L Pe
Observations (2)
As long as the length scale is resolved GFEM works well for convection-diffusion
problems.
Example: 1D steady convection with source term (1)
Equation (Pe ):
du
=f on (0, 1)
dx
with
1 (x 12 )2
u(0) = 0, f = exp[ ]
2
Exact solution:
1h x 21 1 i
u(x) = erf( ) + erf( )
2 2
Notes:
B length scale
B for 0
1
u(x) = H(x ) (Heaviside)
2
du 1
= f (x) = (x )
dx 2
Example: 1D steady convection with source term (2)
1
=0.45 exact
=0.45 GFEM
=0.15 exact
0.8 =0.15 GFEM
=0.05 exact
=0.05 GFEM
0.6
u(x)
0.4
0.2
-0.2
0 0.2 0.4 0.6 0.8 1
x
Example: 1D steady convection with source term (3)
1
=0.05 exact
=0.05 Ne=11
=0.05 Ne=20
0.8 =0.05 Ne=21
0.6
u(x)
0.4
0.2
-0.2
0 0.2 0.4 0.6 0.8 1
x
Observations
B Inaccurate solutions and upstream wiggles when layer with small length scale
is not resolved by the mesh.
h 1
<
2
Problem is again lack of resolution for rapidly changing solutions (large gradients).
Summary of the examples
B GFEM works well for smooth solutions and the mesh resolves rapidly changing
solutions.
B For non-smooth solutions and/or a too coarse mesh wiggles can easily appear.
B The GFEM is not robust and local errors can easily be amplified throughout
the domain.
Some might consider the latter a good thing (Dont suppress wiggles they tell
you something). However:
B In many practical problems resolving all large gradients is not an option and
would require too much computer resources.
B In viscoelastic flow problems the GFEM method often performs very poorly.
Stabilization necessary
Analysis of the discrete equations
Equidistant mesh (mesh size h), inner node i:
B central differencing
B for f = 0:
1
ui+1 ui1 (ui+1 2ui + ui1) = 0
Peh
or
1 + Peh
ui+1 ui = (ui ui1)
1 Peh
or
ah
For Peh = = 1 we have a diffusivity of:
2A
ah
A = A =
2
d2 u
Adding A 2 to the equations, or
dx
du d2u
a (A + A) 2 = f
dx dx
removes wiggles, but we solve a modified equation. New mesh Peclet:
h= ah Peh
Pe ah
= <1
2(A + 2 ) 1 + Peh
Artificial diffusion (2)
Discretized equations with equidistant mesh (mesh size h), inner node i:
ui ui+1
ui1
xi1 xi xi+1
h h
ui ui1 du
= (xi) + O(h)
h dx
Artificial diffusion (2)
In general artificial diffusivity:
ah
A =
2
with examples:
B = 1, upwind differencing
h = 1 for Peh > 1:
B Pe
(
0 for Peh 1
=
1 Pe1 for Peh > 1
h
du d2u
a A 2 = constant
dx dx
gives:
1
= coth(Peh)
Peh
(Peh)
1
coth(x)-1/x
1-1/x
x/3
0.8
0.6
0.4
0.2
0
0 2 4 6 8 10
Exercise 8
1 ui+1 ui 1 ui ui1 du
2 (1 )
h
+ 2 (1 + )
h
= (xi) + O(h)
dx
1
Pe=25 exact
GFEM
0.8 =1
=0 for Peh1, 1-1/Peh for Peh>1
=coth(Peh)-1/Peh
0.6
u(x)
0.4
0.2
-0.2
0 0.2 0.4 0.6 0.8 1
x
Observations
1.2
=0.05 exact
GFEM Ne=20
1 GFEM Ne=40
AD =1 Ne=20
0.8 AD =1 Ne=40
0.6
u(x)
0.4
0.2
-0.2
0 0.2 0.4 0.6 0.8 1
x
Example: 1D steady convection with source term
0.002
AD =1 Ne=3000
0.0015 GFEM Ne=100
0.001
maxk|uk-uexact|
0.0005
-0.0005
-0.001
-0.0015
-0.002
0 0.2 0.4 0.6 0.8 1
x
Observations
B GFEM: global wiggles and inaccuracy for Ne = 20 but very accurate for
Ne = 40 (fast convergence)
B Upwind: no wiggles (robust) but convergence is very slow near large gradients.
Seems to be accurate outside the layer with large gradients.
Question: Can we combine the accuracy (fast convergence) of GFEM with the
robustness of upwind?
Set of equations (flow of a visco-elastic fluid)
~u
( + ~u ~u) (2sD) + p = ~b, in
t
~u = 0, in
( + ~u L LT ) + = 2D, in
t
Weak form of modified equation by AD
du d du ah
a (A + A) + bu = f, with A =
dx dx dx 2
where we assume also the modified boundary condition:
u = ua, at x = a (D )
du
(A + A) = hb at x = b (N )
dx
For the weak form we get: Find u S such that
dv du du
( , (A + A) ) + (v, a ) + (v, bu) + v(b)hb = (v, f ) for all v V
dx dx dx
Streamline upwinding (SU) (1)
xi1 xi xi+1
2
hi hi+1
Consistent weighting
Hughes & Brooks (1982): problem with SU in inconsistency : The exact solution
does not satisfy the weak form. Their solution is to modify the weighting of the
differential equation from the standard form
to
h dv
(v + , Lu f ) = 0 for all v
2 dx
where
du d du
L(u) = a (A ) + bu
dx dx dx
The space of the weight functions (not V !) is in effect different from the space
of shape functions when applying Vh = Uh like in the Galerkin method (
Petrov-Galerkin).
Interpretation of second-derivatives
h dv h dv
(v + , Lu f ) = (v, Lu f ) + ( , Lu f ) = 0 for all v
2 dx | {z } | 2 dx {z }
I II
h dv X h dv
( , Lu f ) = ( , Lu f )e =
2 dx e
2 dx
Streamline upwind Petrov-Galerkin (SUPG)
dv du du
( , A ) + (v, a ) + (v, bu) + v(b)hb
dx dx dx
X h dv du d du
+ , a (A ) + bu f
2 dx dx dx dx e
e |{z}
a
= (v, f ) for all v V
Notes:
P
B A = 0 (no diffusion): e can be removed (viscoelastic CE)
B consistency
h
B usual definition: a = with time scale
2
h1 ah 1 1
= = = A
2a 2 a2 a2
d du
B constant A, linear elements: (A ) = 0 in the interior of the element. If
dx dx
reaction term bu and source term f are also absent (convection-diffusion only)
SU=SUPG!
Ne = 20; = 0.05
1.2
=0.05 exact
GFEM Ne=20
1 AD =1 Ne=20
SUPG =1 Ne=20
0.8
0.6
u(x)
0.4
0.2
-0.2
0 0.2 0.4 0.6 0.8 1
x
Example: 1D steady convection with source term (2)
1
AD
SUPG
GFEM
0.1
maxk|uk-uexact|
0.01
0.001
10 100
Ne
Example: 1D steady convection with source term (3)
1
AD
SUPG
GFEM
7/x
10/x2
0.1
maxk|uk-uexact|
0.01
0.001
10 100
Ne
Observations
u
+ ~a u (Au) + bu = f on
t | {z }
Lu
Multiply by testfunction v:
u
(v, + Lu f ) = 0 for all v
t
where the standard inner product on L2() is
Z
(a, b) = ab dx
With
Au v = A(u)v) Au v
and the divergence theorem (Gauss):
Z Z
~a dx = ~n ~a d
Weak form (2)
u
(v, ) + (v, ~a u) + (v, Au) + (v, bu) + (v, hN )N = (v, f )
t
B v = 0 on D , u = uD on D
B we have silently introduced:
Z
(~a, ~b) = ~a ~b d
Z
(a, b) = ab d
GFEM (1)
= ee, e f = for e 6= f
1(~x) 3(~x)
30 2(~x)
1
1
0 1
0
1 2
03
1 03
1 03
1
1
0 1
0 1
0
1 1 1
1
0 1
0 1
0
2 2 2
GFEM (2)
n
X
uh(~x, t) = ui(t)i(~x) = T (~x)u(t)
i=1
n
X
vh(~x, t) = vi(t)i(~x) = T (~x)v (t)
i=1
where (~x) are global shape functions. Substituting into the weak form:
v T M u + v T K u = v T f for all v
or
M u + K u = f
GFEM (2)
K = (, AT ) or Kij = (i, Aj )
T
+ (, ~a ) + (i, ~a j )
T
+ (, b ) + (i, bj )
f = (, f ) (, hN )N fi = (i, f ) (i, hN )N
Example: 2D steady convection with source term (1)
|~a| = 1
u=0
u=0
u u
ax + ay =f on (0, 1) (0, 1)
x y
1
1
with (ax, ay ) = ( 2 2, 2 2) and
1 (x + y 1)2
u(x, 0) = 0, u(0, y) = 0, f = exp[ 2
]
2
Exact solution goes from 0 for x + y < 1 to 1 for x + y > 1 over a length scale
of .
Example: 2D steady convection with source term (2)
1.03E+00
7.61E01
4.92E01
2.23E01
4.57E02
3.15E01
max: 1.03E+00
min:3.15E01
Example: 2D steady convection with source term (3)
1.02E+00
8.08E01
5.99E01
3.89E01
1.79E01
3.08E02
max: 1.02E+00
min:3.08E02
Example: 2D steady convection with source term (4)
1.00E+00
7.99E01
5.95E01
3.91E01
1.88E01
1.61E02
max: 1.00E+00
min:1.61E02
Example: 2D steady convection with source term (5)
1.00E+00
8.01E01
6.00E01
3.99E01
1.98E01
3.47E03
max: 1.00E+00
min:3.47E03
Example: 2D steady convection with discontinuous inflow (1)
|~a| = 1
u=1
u=0
u u
ax + ay =0 on (0, 1) (0, 1)
x y
with (ax, ay ) = ( 12 2, 12 2) and
u(x, 0) = 0, u(0, y) = 1
Ne = 15 15; GFEM
1.06E+00
8.38E01
6.13E01
3.88E01
1.63E01
6.22E02
max: 1.06E+00
min:6.22E02
Example: 2D steady convection with discontinuous inflow (3)
Ne = 30 30; GFEM
1.06E+00
8.38E01
6.13E01
3.88E01
1.63E01
6.22E02
max: 1.06E+00
min:6.22E02
Observations for GFEM in 2D
B Inaccurate solutions and global upstream wiggles when layer with small length
scale is not resolved by the mesh.
B Almost wiggle free, very localized cross-stream jumps possible even for coarse
meshes.
1D added diffusion:
d2 u ah
A 2 with A =
dx 2
which stabilizes
du
a
dx
3D added diffusion:
|a|h
(Au) with A =
2
which stabilizes
~a u
however, in all directions. This is too much added diffusion. Only diffusion in the
direction of ~a is needed since
u ~a
~a u = |~a|~e u = |~a| with ~e =
e |~a|
Artificial diffusion (2)
(A~e~e u)
or
~a~a
(A u) with A = A~e~e = A 2
|~a|
In the weak form we get an extra term:
(v, A u)
SU (1)
with
A h
= 2=
|~a| 2|~a|
SU (2)
v = v + ~a v
SUPG
u X u
v, + Lu f + ~a v, + Lu f =0
t e
t e
A
B = 2 , with A the amount of streamline diffusion. When the real diffusion
|~a|
ah
A 6= 0, we need to generalize A = (Peh) to more dimensions. There are
2
various ways to do this. For example for a bilinear quadrilateral:
~h1 = h1~e1 ~a0
~h2 = h2~e2
h
=
2U
|~a| = 1
u=0
u=0
u u
ax + ay =f on (0, 1) (0, 1)
x y
1
1
with (ax, ay ) = ( 2 2, 2 2) and
1 (x + y 1)2
u(x, 0) = 0, u(0, y) = 0, f = exp[ 2
]
2
Exact solution goes from 0 for x + y < 1 to 1 for x + y > 1 over a length scale
of .
Example: 2D steady convection with source term (2)
1.02E+00
8.14E01
6.08E01
4.03E01
1.98E01
7.67E03
max: 1.02E+00
min:7.67E03
Example: 2D steady convection with source term (3)
1.00E+00
8.03E01
6.02E01
4.01E01
2.00E01
4.83E04
max: 1.00E+00
min:4.83E04
Example: 2D steady convection with discontinuous inflow (1)
|~a| = 1
u=1
u=0
u u
ax + ay =0 on (0, 1) (0, 1)
x y
with (ax, ay ) = ( 12 2, 12 2) and
u(x, 0) = 0, u(0, y) = 1
Ne = 15 15; SUPG
1.05E+00
8.27E01
6.09E01
3.91E01
1.73E01
4.47E02
max: 1.05E+00
min:4.47E02
Example: 2D steady convection with discontinuous inflow (3)
Ne = 30 30; SUPG
1.05E+00
8.30E01
6.11E01
3.91E01
1.72E01
4.70E02
max: 1.05E+00
min:4.70E02
Example: 2D steady convection with discontinuous inflow (4)
1.00E+00
8.00E01
6.00E01
4.00E01
2.00E01
0.00E+00
max: 1.00E+00
min: 0.00E+00
Example: 2D steady convection with discontinuous inflow (5)
1.00E+00
8.00E01
6.00E01
4.00E01
2.00E01
0.00E+00
max: 1.00E+00
min: 0.00E+00
Observations for SUPG in 2D