You are on page 1of 16

An Introduction to Discontinuous Galerkin

Methods
Module 2: A Simple 1D DG Solver

J. Bevan

Department of Mechanical Engineering, Grad Student


University of Massachusetts at Lowell
Module 2: A Simple 1D DG Solver
Linear Solution Approximation
Definition
Bases and Resultant Approximation
Test Function Choice (Galerkin)
Upwind Flux
Mass Matrix
Stiffness Matrix
Putting it all Together
Semi-discrete system
Time Discretization: Forward Euler
Investigation- h-Convergence
Investigation- t-Convergence
Investigation- Stability (CFL)
Linear Solution Approximation: Definition

I The exact sol’n q(x) is not usually obtainable, the best we can

do is an approximate sol’n q(x)
I We can think of the approximate solution belonging to some

finite vector space q ∈ Vh , this vector space must have a set
of basis vectors ψ such that
M
∼ X
q(x) = ai ψi (x) (1)
i=0

I We will choose Vh in this simple example to be the space of


all polynomials of order 1 and less: PM , M = 1
I Because M = 1, we must have two basis functions. We shall
choose two ramp functions, let’s see what they look like...
Bases and Resultant Approximation
I Basis funs (blue) ψ0 (x) = 1 − x and (red) is ψ1 (x) = x.

Resultant approximation is linear: q(x) = a0 (1 − x) + a1 (x)
Test Function Choice (Galerkin)

I We have now defined our approximation space, but what


about the weighting function in the weak form: φ?
I We will discuss this in greater detail, but as in a FEM, DG
chooses the space of weighting functions to be the same as
the approximation space, φ ∈ Vh
I This means our weighting functions are ramp functions as well
φ0 (x) = ψ0 (x), φ1 (x) = ψ1 (x)
I In order to solve for the approximation, our weak form sol’n
must be satisfied for each weighting function.
Upwind Flux

I If our flow is incompressible and the global domain is 1D, we


must have a constant flow with velocity c everywhere.
∼−
I Let’s assume that c > 1, the numerical flux is then c q at all
boundaries
I Note that there are two distinct numerical fluxes for element
k, on the left it is cq − (xL ) and the right cq − (xR ) , where
q − (xL ) doesn’t necessarily equal q − (xR )
Mass Matrix

Z ∼ xR Z
∂q ∼ ∼ dφj
φj dx + [f ( q)φj ] − f ( q) dx = 0 f or all j ≤ N

k ∂t x L k dx
(2)

I From convention for dynamic systems the left integral in the


weak form is called the mass matrix

I We now have explicit formula for q and φ, substituting
Z ∼ M Z
∂q X dai (t)
φn dx = ψi (x)φj (x) (3)
k ∂t i=0
dt k
Mass Matrix
Z ∼ M Z
∂q X dai (t)
φn dx = ψi (x)φj (x) dx
k ∂t dt
i=0 k

I Let’s substitute in our expressions for approximation and the


first weighting basis and analytically integrate
Z 1
ψi (x)φ0 (x) dx = (4)


k 0

I Do this for each weighting basis to get 2x2 matrix: Mj,i


I If the time derivative of each of the approximation coefficients
is a vector a0 then
M Z
X dai (t)
ψi (x)φj (x) dx = M a0 (5)
dt k
i=0
Stiffness Matrix

Z xR Z
∂q dφ
φ dx + [f (q)φ] − f (q) dx = 0

k ∂t xL k dx

I Similar to mass matrix, substitute our approximation and


bases into the third term.
Z M Z
dφ X
f (q) dx = cai (t) ψi (x)φ0j (x) dx (6)
k dx k
i=0

I The integral for all weighting bases combine to form the


stiffness matrix K, we can analytically integrate for this
simple case
Stiffness Matrix

I Similar to the mass matrix, we have a vector of our element


approximation coefficients a, such that
M
X Z
cai (t) ψi (x)φ0j (x) dx = K a (7)
i=0 k

I Let’s substitute in our expressions for approximation and the


first weighting basis and analytically integrate
Z 1
ψi (x)φ00 (x) dx = (8)


k 0
Putting it all Together

I Just need to calculate the numerical flux vector now.


xR
ˆ
[f (q)φ] = cqk (xR )φj (xR ) − cqk−1 (xR )φj (xL )

(9)
xL

I φj will be zero sometimes, depending on j


I So what do we get?
I f̂ =
Semi-discrete system

I We can now express the semi-discrete system compactly in


matrix/vector form

M a0 + f̂ − cK a = 0 (10)

I For each time step we have a, starting with a0 from ICs


I We’d like to calculate the time rate of change of our
coefficients to use in our time discretization, so solve for a0
h i
a0 = cK a − f̂ M−1 (11)
Time Discretization: Forward Euler

I Now we need to complete the method by discretizing in time


the semi-discrete system
I Let’s use a Forward Euler approach; very simple explicit ODE
solver
at+1 = at + a0t ∆t (12)
I We can overwrite our previous timestep’s coefficients with the
new ones to save memory
I We may want to periodically save a for plotting
I We must choose ∆t carefully, can you predict why?
Investigation- h-Convergence

I What do we expect for h-convergence?


I How coarse can our elements be and still get a
”good-enough” answer?
I What effect does the shape/smoothness of the solution have
on convergence?
Investigation- t-Convergence

I How big can we make ∆t?


I Do we expect periodic solutions to stay steady over time?
I How do h and t convergence relate?
Investigation- Stability (CFL)

I As was seen, too large of a timestep lead to issues, why?


I What happens if a parcel of quantity moves fast enough to
skip elements between timesteps?
I We need to ensure
c∆t
CF L = ≤ Cmax = 1 (13)
∆x
for explicit methods. Implicit methods relax this restriction to
permit higher values.

You might also like