Sie sind auf Seite 1von 61

December 12, 2012

Introduction to discontinuous Galerkin


finite element methods (DG-FEMs)
Hamdullah YCEL
Computational Methods in Systems and Control Theory
Max Planck Institute for Dynamics of Complex Technical Systems
Magdeburg

MAX PLANCK INSTITUTE


FOR DYNAMICS OF COMPLEX
TECHNICAL SYSTEMS
MAGDEBURG

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

1/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Outline

Motiviation

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

2/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Outline

Motiviation

Elliptic Equations

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

2/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Outline

Motiviation

Elliptic Equations

Convection-diffusion Equations

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

2/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Outline

Motiviation

Elliptic Equations

Convection-diffusion Equations

Implementation

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

2/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Motiviation

Elliptic Equations

Convection-diffusion Equations

Implementation

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

3/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Finite difference methods

Main benefits
Simple to implement and fast
Explicit in time
Strong theory

Main problem
Simple local approximation and geometric flexibility are not
agreeable
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

4/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Finite volume methods

The local approximation is a cell average


Z x k +1/2
x k 1/2

k
uh (x)dx = hk u

Main benefits
Robust and fast due to locality
Complex geometries
Well suited for conservation laws
Explicit in time

Main problem
Inability to archive high-order accuracy on general grids
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

5/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Finite element methods


We begin by splitting the solution into elements as

The solution is defined in a nonlocal manner


N

uh (x) =

uk k (x)

k =1

Main benefits
Higher-order accuracy and complex geometries can be
combined

Main problem
Implicit in time
Not well suited for problems with direction
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

6/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Summary

FDM
FVM
FEM
DG

Max Planck Institute Magdeburg

Complex
geometries

X
X
X

Higher-order accuracy
and hp-adaptivity
X

X
X

Local mass
Conservation
X
X

H. Ycel, Introduction to DG-FEMs

7/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Summary

FDM
FVM
FEM
DG

Complex
geometries

X
X
X

Higher-order accuracy
and hp-adaptivity
X

X
X

Local mass
Conservation
X
X

What we need is a scheme that combines

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

7/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Summary

FDM
FVM
FEM
DG

Complex
geometries

X
X
X

Higher-order accuracy
and hp-adaptivity
X

X
X

Local mass
Conservation
X
X

What we need is a scheme that combines


The local-higher order/flexible element of FEM

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

7/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Summary

FDM
FVM
FEM
DG

Complex
geometries

X
X
X

Higher-order accuracy
and hp-adaptivity
X

X
X

Local mass
Conservation
X
X

What we need is a scheme that combines


The local-higher order/flexible element of FEM
The local statement on the equation for FVM

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

7/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Summary

FDM
FVM
FEM
DG

Complex
geometries

X
X
X

Higher-order accuracy
and hp-adaptivity
X

X
X

Local mass
Conservation
X
X

What we need is a scheme that combines


The local-higher order/flexible element of FEM
The local statement on the equation for FVM
These are exactly the components of the
Discontinuous Galerkin Finite Element Method
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

7/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes
Local conservation of physical quantities such as mass,
momentum, and energy

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes
Local conservation of physical quantities such as mass,
momentum, and energy
Increase of the robustness and accuracy

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes
Local conservation of physical quantities such as mass,
momentum, and energy
Increase of the robustness and accuracy
Facilitation of parallelization

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes
Local conservation of physical quantities such as mass,
momentum, and energy
Increase of the robustness and accuracy
Facilitation of parallelization

Cons:

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes
Local conservation of physical quantities such as mass,
momentum, and energy
Increase of the robustness and accuracy
Facilitation of parallelization

Cons:
Large number of degrees of freedom

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Discontinuous Galerkin Methods


DG is a class of FEMs which use discontinuous functions as
the solution (and the test functions)
Pros:
Flexibility for approximation order and complex meshes
Local conservation of physical quantities such as mass,
momentum, and energy
Increase of the robustness and accuracy
Facilitation of parallelization

Cons:
Large number of degrees of freedom
Ill-conditioning and denser global matrix with increasing
approximation order

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

8/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Motiviation

Elliptic Equations

Convection-diffusion Equations

Implementation

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

9/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Model Problem
Let R2 be a bounded open polygonal domain,
Consider the following model problem
div(u(x)) + u(x) = f (x)
u(x) = gD (x)
u(x)

= gN (x)
n

x ,
x D ,
x N ,

where = D N .
f L2 (), gD H 1/2 (D ), gN L2 (N ) and is symmetric
and positive definite.

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

10/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

DG Discretization

Let {Th }h be a partition of a domain with the conformity


and shape regularity
Let Eh be the set of all edges and the interior edges,
Dirichlet and Neumann boundary edges are denoted by
Eh0 , Eh D , Eh N , respectively
An element and an edge are denoted by K and E,
respectively
Let |K | denote the area of triangle K and |E| denote the
length of edge E

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

11/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

DG Discretization
The solution is represented as
Nel Nloc

u(x) =

ujm mj (x)

m=1 j=1

Nel : Number of elements


local dimension with p approximation order
Nloc = (p+1)(p+2)
2

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

12/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

DG Discretization
The solution is represented as
Nel Nloc

u(x) =

ujm mj (x)

m=1 j=1

Nel : Number of elements


local dimension with p approximation order
Nloc = (p+1)(p+2)
2
Basic idea behind the construction of DGFEMs: Replace
integration-by-parts over by:
element-wise integration-by-parts, and
summing such formula over the elements in the finite
element partition of the domain.
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

12/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

DG Discretization-One Dimension

The jump operator []xk = |Ik (xk ) Ik +1 (xk )


The average operator {}xk = 21 (Ik (xk ) + Ik +1 (xk ))

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

13/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

DG Discretization-Two Dimensions
@
@
@
@

K1
@
@

@E
@
@

K2 @
nE

Scalar functions y
[[y ]] = (y |K E y |K E )nE ,
1

{{y }} =


1
y |K E + y |K E .
1
2
2

Vector field y
[[y ]] = (y |K E y |K E ) nE
1

Max Planck Institute Magdeburg

{{y }} =


1
y |K E + y |K E .
1
1
2
H. Ycel, Introduction to DG-FEMs

14/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

DG Solution

The DG finite element spaces on Th


Vh = Uh = {uh L2 () | u|K Pn (E), K Th }

DG approximation of the solution


Find uh Vh such that
ah (uh , vh ) = lh (v ),

Max Planck Institute Magdeburg

vh Vh ().

H. Ycel, Introduction to DG-FEMs

15/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Interior Penalty Galerkin Methods


ah (u, v ) =

K Th

Max Planck Institute Magdeburg

u v dx +

K Th

uv dx

H. Ycel, Introduction to DG-FEMs

16/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Interior Penalty Galerkin Methods


ah (u, v ) =

K Th

u v dx +

K Th

uv dx

{{u}} [[v ]] ds

EEh0 Eh D E

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

16/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Interior Penalty Galerkin Methods


ah (u, v ) =

K Th

u v dx +

EEh0 Eh D E

Max Planck Institute Magdeburg

K Th

uv dx

{{u}} [[v ]] ds +

{{v }} [[u]] ds

EEh0 Eh D E

H. Ycel, Introduction to DG-FEMs

16/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Interior Penalty Galerkin Methods


ah (u, v ) =

K Th

u v dx +

K Th

uv dx

{{u}} [[v ]] ds +

EEh0 Eh D E

|E|0
EE 0 E D
h

Max Planck Institute Magdeburg

{{v }} [[u]] ds

EEh0 Eh D E

[[u]] [[v ]] ds

H. Ycel, Introduction to DG-FEMs

16/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Interior Penalty Galerkin Methods


ah (u, v ) =

K Th

u v dx +

K Th

uv dx

{{u}} [[v ]] ds +

EEh0 Eh D E

|E|0
EE 0 E D
h

{{v }} [[u]] ds

EEh0 Eh D E

[[u]] [[v ]] ds

with penalty parameter and 0 superpenalization parameter.

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

16/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Interior Penalty Galerkin Methods


ah (u, v ) =

K Th

u v dx +

K Th

uv dx

{{u}} [[v ]] ds +

EEh0 Eh D E

|E|0
EE 0 E D
h

{{v }} [[u]] ds

EEh0 Eh D E

[[u]] [[v ]] ds

with penalty parameter and 0 superpenalization parameter.


if = 1, SIPG, i.e., symmetric interior penalty Galerkin,
if = 1, NIPG, i.e., nonsymmetric interior penalty Galerkin,
if = 0, IIPG, i.e., incomplete interior penalty Galerkin.

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

16/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Linear form

lh (v ) =

K Th

fv dx +

EEh D E

Max Planck Institute Magdeburg

|E|0
EE D

gD n [[v ]] ds

gD {{v }} ds +

gN v ds

EEh N E

H. Ycel, Introduction to DG-FEMs

17/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Properties of the DG methods

Method
Brezzi et al. [2000]
LDG [Cockburn-Shu,1998]
CDG [Peraire-Persson,2008]
SIPG [Arnold 1982]
Bassi et al. [1997]
NIPG [Riviere 1999]
Babuka-Zlmal [1973]
Baumann-Oden (p = 1) [1999]
Baumann-Oden (p 2) [1999]
IIPG [Wheeler 2004]

Cons.

A.C.

Stab.

H1

L2

X
X
X
X
X
X

X
X
X

X
X
X
X
X

X
X
X
X
X
X
X

hp
hp
hp
hp
hp
hp
hp

hp
hp

hp+1
hp+1
hp+1
hp+1
hp+1
hp
h p +1

hp
hp

D. N. Arnold, F. Brezzi, B. Cockburn, and L. D. Marini, Unified analysis of discontinuous Galerkin methods for elliptic
problems, 2002.
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

18/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Motiviation

Elliptic Equations

Convection-diffusion Equations

Implementation

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

19/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Model Problem

Consider the following convection-diffusion equation


u(x) + u(x) + u(x) = f (x)
u(x) = gD (x)
u(x)
= gN (x)

x ,
x D ,
x N ,

where = D N .
2
f L2 (), gD H 3/2 (D ), gN L2 (N ), W 1, () ,
L ()

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

20/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

The boundary edges are decomposed into the inflow and


outflow edges;
= {x : n(x) < 0} ,
+ = {x : n(x) 0}

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

21/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

The boundary edges are decomposed into the inflow and


outflow edges;
= {x : n(x) < 0} ,
+ = {x : n(x) 0}

We use upwind-discretization to discretize convection term




u|K 1 , if nE < 0,
u|K 2 , if nE < 0,
e
u=
u =
u|K 2 , if nE 0,
u|K 1 , if nE 0.

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

21/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

(Bilinear Form

ah (u, v ) =

K Th

u v dx

{{u}} [[v ]] ds +

EEh0 Eh D E

|E|0
EE 0 E D
h

K Th

Max Planck Institute Magdeburg

K \

{{v }} [[u]] ds

EEh0 Eh D E

[[u]] [[v ]] ds +

K Th

E
e

n(u u)v ds

uv + uv dx

K Th

nuv ds

H. Ycel, Introduction to DG-FEMs

22/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Linear Form

lh (v ) =

K Th

fv dx

|E|0
EE D
h

Z
E

K Th

Max Planck Institute Magdeburg

gD n [[v ]] ds +

n gD v ds +

gD {{v }} ds

EEh D E

gN v ds.

EEh N E

H. Ycel, Introduction to DG-FEMs

23/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Motiviation

Elliptic Equations

Convection-diffusion Equations

Implementation

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

24/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

The Implementation Structure

Global Matrices and RHS Vector

?
?

Volume
Contributions

?
Local matrices on volume

Max Planck Institute Magdeburg

Face
Contributions

?
?

Local matrices
on
interior faces

Local matrices
on
boundary faces

H. Ycel, Introduction to DG-FEMs

25/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Mapping between Physical and Reference Triangle


A1

A
3
K
FK : K

@
@
@

Q Q





A3

A
1

A
2

A2


FK

x
y

x
y



3

x = xi i (x , y ),

y = xi i (x , y ),

i=1

i=1

where
1 (x , y ) = 1 x y ,


x
y


= FK

2 (x , y ) = x ,
x
y

2 (x , y ) = y .
x
y

x3 x1
y3 y1

= BK

+ bK ,

where BK is an invertible matrix and bK is a translation vector

BK =

Max Planck Institute Magdeburg

K
a11
K
a21

K
a12
K
a22


=

x2 x1
y2 y1


,

bK =

x1
y1


.

H. Ycel, Introduction to DG-FEMs

26/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Local Matrices on Volume


For a fixed element K :
Z

(DK )i,j =

j,K i,K dx, (CK )i,j =

Z
K

j,K i,K dx, (RK )i,j =

Z
K

j,K i,K dx.

1 i, j, Nloc .
After a change of variable with the mapping FK ,
(DK )i,j

2|K |

(CK )i,j

2|K |

(RK )i,j

2|K |

i (B T )1
j dx,
(BKT )1
K
j i dx,
(BKT )1
( FK )j i dx.

The local right-hand side bK are (bK )i =

Max Planck Institute Magdeburg

f i,K dx.

H. Ycel, Introduction to DG-FEMs

27/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Algorithm 1: Computing local contributions from element K


initialize DK = 0, CK = 0, RK = 0
initialize the quadrature weights w and points s
loop over quadrature points : for k=1 to NG do
compute determinant of BK
for i=1 to Nloc do
compute values of basis functions i,K (s(k ))
compute derivatives of basis functions i,K (s(k ))
end
compute global coordinates x of quadrature points s(k)
compute source function f(x)
for i=1 to Nloc do
for j=1 to Nloc do
DK (i, j) = DK (i, j) + w(k )det(BK )j,K (s(k )) i,E (s(k ))
CK (i, j) = CK (i, j) + w(k )det(BK ) j,K (s(k ))i,K (s(k ))
RK (i, j) = RK (i, j) + w(k )det(BK )i,K (s(k ))j,K (s(k ))
end
bK (i) = bK (i) + w(k )det(BK )f (x)i,K (s(k ))
end
end
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

28/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Local matrices on faces-Diffusion Part


Let E Eh0 ,
TD =

1
2

Z
E

{uh nE }[] +

|E|0

Z
E

[uh ][].

1 1 ds,
E
E
E
E
|E|0 E j,Ke i,Ke
E
E
Z
Z
Z
1

j,K 2 nE i,K 2 ds
i,K 2 nE j,K 2 ds +
(DE22 )i,j =
2 2 ds,
E
E
E
E
2 E
2 E
|E|0 E j,KE i,KE
Z
Z
Z

1
j,K 2 nE i,K 1 ds
i,K 1 nE j,K 2 ds
2 1 ds,
(DE12 )i,j =
E
E
E
E
2 E
2 E
|E|0 E j,KE i,KE
Z
Z
Z
1

(DE21 )i,j =
j,K 1 nE i,K 2 ds +
i,K 2 nE j,K 1 ds
1 2 ds.
E
E
E
E
2 E
2 e
|E|0 E j,KE i,KE
(DE11 )i,j =

j,K 1 nE i,K 1 ds +

Max Planck Institute Magdeburg

{ nE }[uh ] +

i,K 1 nE j,K 1 ds +

H. Ycel, Introduction to DG-FEMs

29/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Local matrices on faces-Convection Part


TC =

K Th

n(u e u)v ds = cE11 + cE22 + cE12 + cE21 .

K \

By the upwind discretization [Lesaint,Raviert,1974-Reed,Hill,1973]




u|K 1 , if nE < 0,
u|K 2 , if nE < 0,
u=
ue =
u|K 2 , if nE 0,
u|K 1 , if nE 0.
The local matrices: E Eh0 satisfying nE < 0,
(CE11 )i,j =

Z
E

nE j,K 1 i,K 1 ,
E

(CE12 )i,j =

(CE21 )i,j =

nE j,K 2 i,K 1
E

and E Eh0 satisfying nE 0,


(CE22 )i,j =
Max Planck Institute Magdeburg

Z
E

nE j,K 2 i,K 2 ,
E

nE j,K 1 i,K 2 .
E

H. Ycel, Introduction to DG-FEMs

30/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation
Algorithm 2: Computing local contributions from interior edges
11 = D 22 = D 12 = D 21 = 0,C 11 = C 22 = C 12 = C 21 = 0
initialize DE
E
E
E
E
E
E
E
initialize the quadrature weights w and the points s on [1, 1]
compute edge length |E|, normal vector nE
get face neighbors KE1 and KE2
loop over quadrature points: for k=1 to NG do
compute local coordinates ss1 on KE1 and ss2 on KE2 of quadrature point s(k )
for i=1 to Nloc do
compute values of basis functions 1 (s(k )) and 2 (ss1)
i,K

i,K

compute derivatives of basis functions

i,K 1
E

end
for i=1 to Nloc do
for j=1 to Nloc do

(s(k )) and

i,K 2
E

(ss2)

11 (i, j) 0.5w(k )|E|


DE

11 (i, j)
DE

11 (i, j) + 0.5w(k )|E|


DE
(s(k ))( 1 (s(k )) nE )
j,K 1
i,K
E
E

11 (i, j)
DE

11 (i, j)
DE

21 (i, j)
DE

21 (i, j) + 0.5w(k )|E|


DE

21 (i, j)
DE

21 (i, j) + 0.5w(k )|E|


DE
(s(k ))( 2 (s(k )) nE )
j,K 1
i,Ke
E

21 (i, j)
DE

21 (i, j)
DE

11 (i, j)
DE

end
end
Max Planck Institute Magdeburg

i,K 1
E

|E|0

|E|0

j,K 1
E

w(k )|E|

i,K 1
E

i,K 2
E

w(k )|E|

(s(k )) nE )

(s(k ))(

(s(k ))

j,K 1
E

(s(k ))

j,K 1
E

(s(k )) nE )

(s(k ))(

i,K 2
E

(s(k ))

j,K 1
E

(s(k ))

H. Ycel, Introduction to DG-FEMs

31/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

if face is influx face do


for i=1 to Nloc do
for j=1 to Nloc do
CE11 (i, j)

CE11 (i, j) w(k )|E| ni,K 1 (s(k ))j,K 1 (s(k ))

CE12 (i, j)

CE12 (i, j) + w(k )|E| ni,K 2 (s(k ))j,K 1 (s(k ))

end
end
else if face is outflux face do
for i=1 to Nloc do
for j=1 to Nloc do
CE22 (i, j)

CE22 (i, j) w(k )|E| ni,K 2 (s(k ))j,K 2 (s(k ))

CE21 (i, j)

CE21 (i, j) + w(k )|E| ni,K 1 (s(k ))j,K 2 (s(k ))

end
end
end
end
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

32/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Volume Contributions
Algorithm 3: Volume Contributions
initialize k=0
loop over the elements: for k=1 to Nel do
compute local matrices DKk , CKk , RKk and bKk
for i=1 to Nel do
ie=i+k
for j=1 to Nel do
je=j+k
Dglobal (ie, je) = Dglobal (ie, je) + DK (i, j)
Cglobal (ie, je) = Cglobal (ie, je) + CK (i, j)
Rglobal (ie, je) = Rglobal (ie, je) + RK (i, j)
end
bglobal (ie) = bglobal (ie) + bEk (i)
k=k+Nloc
end
end
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

33/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Face Contributions
Algorithm 4: Face Contributions
loop over the edges: for k=1 to Nface do
get face neighbors Kk1 and Kk2
if face is an interior face do
compute local matrices Dk11 , Dk22 , Dk12 , Dk21 , Ck11 , Ck22 , Ck12 , Ck21
assemble Dk11 and Ck11 contributions:
for i=1 to Nloc do
ie = i + (Kk1 1)Nloc
for j=1 to Nloc do
je = j + (Kk1 1)Nloc

Dglobal (ie, je) = Dglobal (ie, je) + Dk11 (i, j)

Cglobal (ie, je) = Cglobal (ie, je) + Ck11 (i, j)


end
end
assemble Dk21 and Ck21 contributions:
for i=1 to Nloc do
ie = i + (Kk2 1)Nloc
for j=1 to Nloc do
je = j + (Kk1 1)Nloc

Dglobal (ie, je) = Dglobal (ie, je) + Dk21 (i, j)

Cglobal (ie, je) = Cglobal (ie, je) + Ck21 (i, j)


end
end
end
end
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

34/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Matlab Implementation

Goal: Faster program with less memory storage


Problem: the number of loops
Solution:
Sparse Matrix structure
Vectorization coding style
Multiple matrix multiplications (MULTIPROD)

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

35/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Multiple matrix multiplications (MULTIPROD)


Generalization for N-D arrays of the MATLAB matrix
multiplication operator (*)
Perform any kind of multiple scalar-by-matrix or matrix
multiplication:
Arrays of scalars by arrays of scalars, vectors (*) or
matrices.
Arrays of vectors (*) by arrays of scalars, vectors (*) or
matrices.
Arrays of matrices by arrays of scalars, vectors (*) or
matrices.

(*) internally converted by MULTIPROD into row or column


matrices
P. d. Leva, MULTIPROD TOOLBOX, Multiple matrix multiplications, with array expansion enabled, University of
Rome Foro Italico, Rome.
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

36/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

Example for MULTIPROD


Consider
% Building A and B
A = rand(2, 5);
B = rand(5, 3, 1000, 10);
% Multiplying A by all the matrices in B
for i = 1:1000
for j = 1:10
C(:,:,i,j) = A * B(:,:,i,j);
end
end
C = MULTIPROD(A, B),
Performance 380 times better.
Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

37/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

References
D. N. Arnold, An interior penalty finite element method with discontinuous
elements, SIAM J. Numer. Anal., 19:724-760, 1982.
D. N. Arnold, F. Brezzi, B. Cockburn, and L. D. Marini, Unified analysis of
discontinuous Galerkin methods for elliptic problems, 2002.
B. Ayuso, and L. D. Marini, Discontinuous Galerkin methods for
advection-diffusion-reaction problems, SIAM J. Numer. Anal., 47:1391-1420,
2009.
J. S. Hesthaven, and T. Warburton, Nodal Discontinuous Galerkin Methods:
Algorithms, Analysis, and Applications. Volume 54, Springer Texts in Applied
Mathematics, Springer Verlag, New York, 2008.
B. Rivire, Discontinuous Galerkin methods for solving elliptic and parabolic
equations, Theory and implementation, SIAM Volume 35, Frontiers in Applied
Mathematics, 2008.

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

38/39

Motiviation
Elliptic Equations
Convection-diffusion Equations
Implementation

THANK YOU !

Max Planck Institute Magdeburg

H. Ycel, Introduction to DG-FEMs

39/39

Das könnte Ihnen auch gefallen