MA557/MA578/CS557 Lecture 8 Spring 2003 Prof. Tim Warburton [email protected] 1 Discontinuous Galerkin Scheme • Recall that under sufficient conditions (i.e. smoothness) on an interval we obtained the density advection PDE q q u 0 t x • We again divide the pipe into sections divided by x1,x2,…,xN . • On each section we are going to solve a weak version of the advection equation. Find i P p xi , xi 1 such that v P p xi , xi 1 xi 1 xi v i u i dx v xi u i 1 xi i xi x t 2 1 3 2 x1 x2 x3 N 1 xN-1 xN In the i’th cell we will calculate an approximation of q, denoted by i . Typically, this will be a p’th order polynomial on the i’th interval. We will solve the following weak equation for i i=1,..,N-1 Find i P p xi , xi 1 such that v P p xi , xi 1 xi 1 xi i i v u dx v xi u i 1 xi i xi x t 3 Discretization of Pp • In order to work with the DG scheme we need to choose a basis for Pp and formulate the scheme as a finite dimensional problem Find i P p xi , xi 1 such that v P p xi , xi 1 i i v u dx v xi u i 1 xi i xi x t x i • We expand the density in terms of the Legendre m p polynomials xi 1 i i ,m Lm x m 0 where: i ,m is the m'th coefficient of the Legendre expansion of the density in the i'th cell. 2 x xi xi 1 x xi 1 xi 4 Discretization of Pp • The scheme: Find i P p xi , xi 1 such that v P p xi , xi 1 xi 1 xi i i v u dx v xi u i 1 xi i xi x t • Becomes: Find i ,m m 0,..., p such that dx 1 d i ,m Ln Lm dx m 0 dt dx 1 m p m p m p dx 1 dLm u Ln dx i ,m uLn 1 i 1,m Lm 1 uLn 1 i ,m Lm 1 dx dx m 0 m 0 m 0 1 m p 5 Simplify, simplify • Starting with: Find i ,m m 0,..., p such that dx 1 d i ,m Ln Lm dx m 0 dt dx 1 m p m p m p dx 1 dLm u Ln dx i ,m uLn 1 i 1,m Lm 1 uLn 1 i ,m Lm 1 dx dx m 0 m 0 m 0 1 m p • We define two matrices: 1 M nm dx Ln x Lm x dx dx 1 Dnm dx d Ln x Lm x dx dx 1 dx 1 1 dx dx d Ln x Lm x dx dx dx 1 dx 1 Ln x 1 d Lm x dx dx 6 Then: Find i ,m m 0,..., p such that dx 1 d i ,m Ln Lm dx m 0 dt dx 1 m p m p m p dx 1 dLm u Ln dx i ,m uLn 1 i 1,m Lm 1 uLn 1 i ,m Lm 1 dx dx m 0 m 0 m 0 1 m p Becomes: Find i ,m m 0,..., p such that m p m p m p d i ,m M nm u Dnm i ,m uLn 1 i 1,m Lm 1 uLn 1 i ,m Lm 1 dt m 0 m 0 m 0 m 0 m p 7 Questions • This raises the following questions how can we compute Mnm and Dnm • We will need some of the following results. 8 The Legendre Polynomials (used to discretize Pp) • Let’s introduce the Legendre polynomials. • The Legendre Lm x , m 0,1,... polynomials are defined as eigenfunctions of the singular Sturm-Liouville problem: d dLm x m(m 1) Lm x 0 1 x 1 x dx dx 9 Closed Form Formula for Lm • If we choose Lm(1) =1 then: 1 l floor ( m / 2) l m 2m 2l m2 l Lm x m 1 x 2 l 0 l m • Examples: L0 x 1 1 0 1 2 1 L1 x 1 x x 2 0 1 1 3x 2 1 0 2 4 2 1 2 2 0 L2 x 2 1 x 1 x 2 2 0 2 1 2 • Warning: this is not a stable way to compute the value of a Legendre polynomial (unstable as m increases) 10 Stable Formula for Computing Lm • We can also use the following recurrence relation to compute Lm 2m 1 m Lm1 x xLm x Lm1 x m 1 m 1 • Starting with L0=1 L1=x we obtain: 3 1 1 2 L2 x xL1 x L0 x 3x 1 2 2 2 • This is a more stable way to compute the Legendre polynomials at some x. 11 The Rodriguez Formula • We can also obtain the m’th order Legendre polynomial using the Rodriguez formula: m 1 dm 2 Lm x m x 1 m 2 m! dx 12 Orthogonality of the Legendre Polynomials • The Legendre polynomials are orthogonal to each other: 1 p m 1 dp 2 1 dm 2 1 Lp x Lm x dx 1 2 p p! dx p x 1 2m m! dx m x 1 dx 1 m p d m 1 1 1 dp 2 2 p x 1 x 1 dx m p m 1 2 p ! 2 m! dx dx m 1 p d m 1 1 1 d p 1 2 2 p x 1 x 1 dx m p 1 m 1 1 2 p ! 2 m! dx dx 1 p m p p d m 1 1 1 2 2 x 1 x 1 dx p m m p 1 2 p ! 2 m! dx 0 • Since 2m < m+p 13 Miscellaneous Relations Lm x 1, L m 1 1 -1 x 1 m m m 1 dLm , x dx 2 -1 x 1 dLm m m m 1 1 1 dx 2 1 2 2 1 Lm x dx 2m 1 14 Differentiation • Suppose we have a Legendre expansion for the density in a cell: m p i i ,m Lm x m 0 • We can find the coefficients of the Legendre expansion for the derivative of the function m p as: d i x (1) L x dx where: i ,m m m 0 i(1) , m 2m 1 j p i , j j m 1 j m odd 15 Coefficient Differentiation Matrix (1) i ,m j p 2 2m 1 i , j xi 1 xi j m 1 j m odd (2m 1) if j>m and j+m odd ˆ Dmj 0 otherwise j p 2 (1) i ,m Dˆ mj i , j xi 1 xi j 0 or ρi(1) 2 ˆ in matrix-vector notation Dρ i xi 1 xi i.e. if we create a vector of the Legendre coefficients for rho in the I’th cell then we can compute the Legendre coefficients of the derivative of rho in the I’th cell by pre-multiplying the vector of coefficients with the matrix: 2 ˆ D xi 1 xi 16 The D Matrix 1 dx Ln x Lm x dx dx 1 • We can use a simple trick to compute D M nm • Recall: dx d Dnm L x Lm x dx n dx 1 dx 1 1 dx d Dnm Ln x Lm x dx dx 1 dx simple change of variables 1 • We use: dx dx d L x Lm x dx n dx dx 1 dx 1 Ln x 1 d Lm x dx dx j p M nj Dˆ jm j 0 2 ˆ Dnm 2n 1 17 The Vandermonde Matrix • It will be convenient for future applications to be able to transform between data at a set of nodes and the Legendre coefficients of the p’th order polynomial which interpolates the data at these nodes. • Consider the I’th cell again, but imagine that there are p+1 nodes in that cell then we have: m p i xn i ,m Lm xn n=0,...,p m 0 • Notice that the Vandermonde matrix defined by Vnm Lm xn is square and we can obtain the coefficients by multiplying both sides by the inverse of V m p i xn Vnm i ,m m 0 n p i ,m V 1 i xn n 0 mn 18 Vandermonde • Reiterate: – that the inverse of the Vandermonde matrix is very useful for transforming nodal data to Legendre coefficients – that the Vandermonde matrix is very useful for transforming Legendre coefficients to nodal data 19 Results So Far • 0<=n,j,m<=p Mass matrix: x x i 1 i Ln x Lm x dx 0 2 1 1 M nm (n m) xi 1 xi 2 n=m = 2 2n 1 0 (n m) Coeff. Differentiation (2m 1) if j>m and j+m odd Dˆ mj 0 otherwise 1 Dnm Ln x Stiffness matrix Vandermonde matrix 1 dLm x dx dx 2 ˆ Dnm 2n 1 Vnm Lm xn 20 Homework 3 Q1) Code up a function (LEGENDRE) which takes a vector x and m as arguments and computes the m’th order Legendre polynomial at x using the stable recurrence relation. Q2) Create a function (LEGdiff) which takes p as argument and returns the coefficient differentiation matrix D Q3) Create a function (LEGmass) which takes p as argument and returns the mass matrix M 21 Homework 3 cont Q4) Create a function LEGvdm which returns the following matrix: Vij L j xi 0 i,j p Q5) Test them with the following matlab routine: 3) Compute the Chebychev nodes 4) Build the Vandermonde matrix using the Chebychev nodes and Legendre polynomials 7) Build the coefficient differentiation matrix 9) Build the Legendre mass matrix 12) Evaluate x^m at the Chebychev nodes 14) Compute the Legendre coefficients 16) Multiply by Dhat (i.e. differentiate in coeff space) 18) Evaluate at the nodes 20) Compute the error in the derivative 22 Homework 3 cont Q5cont) Explain the output from this test case 23 Next Lecture (9) • We will put everything together to build a 1D DG scheme for advection… 24
© Copyright 2026 Paperzz