An Introduction to the Discontinuous Galerkin Method Krzysztof J. Fidkowski Aerospace Computational Design Lab Massachusetts Institute of Technology March 16, 2005 Computational Prototyping Group Seminar 1/53
Overview What is DG? An Example Why DG for Computational Fluid Dynamics? Project X DG vs. Finite Volume DG for Elliptic Problems p-multigrid for Higher-order DG Discretizations Grid Adaptation Conclusions and Ongoing Work Computational Prototyping Group Seminar 2/53
Finite Element Example Examine 1-D convection equation with source term: au x = cos(x) on [0, π] Homogenous Dirichlet BCs Exact solution: u(x) = sin(x) a Standard FEM procedure: N elements Approximate: u(x) = j U jφ j (x) φ 0 φ 1 φ 2 φ 3 φ 4 φ j are hat basis functions n 0 n 1 n 2 n 3 n 4 N + 1 basis functions in 1-D Computational Prototyping Group Seminar 3/53
FEM Example (ctd.) Goal: solve for the coefficients U j (discrete vector U) Weak form of equations: Ω au x φ i dx = Ω ] ΩR auφ i,x dx + [(au)φ i Ω L = Ω Ω cos(x)φ i dx cos(x)φ i dx Substitute u(x) = j U jφ j (x) U j aφ j φ i,x dx + au N φ i (π) au 0 φ i (0) = j Ω Linear System: AU = F Ω cos(x)φ i dx Computational Prototyping Group Seminar 4/53
Solutions to Example For a = 1, u e = sin(x), we obtain: 1 N = 4 N = 8 N = 16 10 1 U 0.8 0.6 0.4 e = max(u u e ) 10 2 10 3 e = O(h 2 ) 0.2 0 0 pi/4 pi/2 3pi/4 pi x 10 4 4 8 16 32 N Computational Prototyping Group Seminar 5/53
Where Discontinous Galerkin Differs Formulation is the same as standard FEM. DG difference is in the choice of basis. Specifically, no continuity constraint between elements. φ 0 φ 1 φ 2 φ 3 φ 4 φ 5 φ 6 φ 7 0 1 2 3 φ j associated with elements. 2N linear basis functions in 1-D. Computational Prototyping Group Seminar 6/53
DG Weak Form { au x φ i dx = cos(x)φ i dx Ω Ω au x φ i dx = cos(x)φ i dx } ] +1/2 auφ i,x dx + [(au)φ i = cos(x)φ i dx 1/2 ] +1/2 auφ i,x dx + [(au)φ i = cos(x)φ i dx 1/2 Computational Prototyping Group Seminar 7/53
What About Element Interfaces? Discontinuity creates problem in the weak form: auφ i,x dx + [(au)φ i ] +1/2 1/2 (au) is multi-valued at element interfaces. = cos(x)φ i dx u R u L Fortunately, this problem has been well studied by the Finite Volume community. Solution: use numerical flux function +1/2 +1 (au) H(u L, u R, a). In this case use pure upwinding. Computational Prototyping Group Seminar 8/53
DG Solution For the same 1-D problem, u e = sin(x), we obtain: 1 N = 4 N = 8 N = 16 10 1 DG FEM U 0.8 0.6 0.4 e = max(u u e ) 10 2 10 3 e = O(h 2 ) 0.2 0 0 pi/4 pi/2 3pi/4 pi x 10 4 4 8 16 32 N Computational Prototyping Group Seminar 9/53
Why DG? DG seems to add additional DOFs for no reason. Why do we want to use DG over standard FEM? Main Benefit: Easy to Introduce Higher Order (p > 1) interpolation Lagrange Basis Functions: p = 2 φ 0 φ 1 φ 2 0 1 2 3 ref (p + 1) Basis Functions per element Computational Prototyping Group Seminar 10/53
Other Benefits of DG Basic iterative solution schemes (e.g. block Jacobi) are stable for higher order (i.e. no need for multistaging). Discretization lends itself to solution via p-multigrid. Easy parallelization. In the field of CFD for aerodynamics, these benefits seem to outweigh the cost of extra DOFs. Computational Prototyping Group Seminar 11/53
Project-X DG solver package for computational fluid dynamics. Started in the Fall of 2002. Involved in seven M.S. theses and six ongoing Ph.D. theses. Currently: Approximately 100,000 lines of code. Capability ranges from grid generation to visualization. Various side projects: grid adaptation, geometry optimization, turbulence modeling, shock limiting, unsteady studies. End goal is full Reynolds-Averaged Navier-Stokes in 3-D. Computational Prototyping Group Seminar 12/53
Project-X Goal Project X Team Goal: To improve the aerothermal design process for complex 3D configurations by significantly reducing the time from geometry to solution at engineering-required accuracy using high-order adaptive methods Who are we? Todd Oliver Chris Fidkowski Garrett Barter Bob Haimes Prof. David Darmofal Prof. Jaime Peraire Tan Bui Shannon Cheng James Lu Pete Whitney Doug Quattrochi Computational Prototyping Group Seminar 13/53
Accuracy of Current CFD Methods Results of an AIAA Drag Prediction Workshop comparing the performance of industry-standard CFD codes: Computational Prototyping Group Seminar 14/53
Motivation for higher order in CFD State of CFD in applied aerodynamics Finite-volume with at best second order accuracy Questions exist whether current discretizations are capable of achieving desired accuracy levels in practical time Decrease computational time and gridding requirements by increasing solution order ( log T = wd 1 ) p log E + log p log F + const T = time to solution p = discretization order E = desired error level (E << 1) w = solution complexity d = dimension of problem F = computational speed Computational Prototyping Group Seminar 15/53
Euler Equations of Gas Dynamics u t + F i (u) = 0 u is the state vector and F i is the inviscid flux. In two dimensions: u = ρ ρu ρv ρe F x i = ρu ρu 2 + p ρuv ρuh, Fy i = ρv ρuv ρv 2 + p ρvh. Computational Prototyping Group Seminar 16/53
Integral Form Integrate Euler equations over triangle 0 and use Green s theorem: 2 3 0 1 d dt A 0 udx+ 3 k=1 0k F i (u) ˆnds = 0 If we assume u is constant in each triangle... Computational Prototyping Group Seminar 17/53
First-order Accurate Finite Volume u constant in each triangle: du 0 dt A 0 + 3 k=1 0k H i (u 0,u k, ˆn 0k ) ds = 0 2 3 0 1 H i (u L,u R, ˆn LR ) is flux function that determines inviscid flux in ˆn LR direction from left and right states, u L and u R. Example flux functions: Godunov, Roe, Osher, Van Leer, Lax-Friedrichs, etc. This discretization has a solution error which is O(h) where h is mesh size. Computational Prototyping Group Seminar 18/53
Second-order Accurate Finite Volume In each triangle, reconstruct a linear solution, ũ, using neighboring averages: ũ 0 u 0 + (x x 0 ) u 0, 7 u 0 u 0 (u 0,u 1,u 2,u 3 ). 6 2 0 1 5 Apply conservation law on triangle: 8 3 9 4 du 0 dt A 0 + 3 k=1 0k H i (ũ 0,ũ k, ˆn 0k ) ds = 0 On smooth meshes and flows, solution error is O(h 2 ). Computational Prototyping Group Seminar 19/53
Pros/Cons of Higher-order Finite Volume + Increased accuracy on given mesh without additional degrees of freedom 6 2 7 0 1 5 Difficulty in achieving higher-order on unstructured meshes and near boundaries 8 3 9 4 Stabilizing multi-stage methods necessary for local iterative schemes Matrix fill-in results in high-memory requirements Computational Prototyping Group Seminar 20/53
Instability of Local Iterative Methods Consider steady state problem and define discrete residual for cell j, R j (u) 3 k=1 jk H i (ũ j,ũ k, ˆn jk ) ds = 0. A Jacobi iterative method to solve this problem is, u n+1 j = u n j ω ( R j / u j ) 1 R j (u). For any finite ω, Jacobi is unstable for higher-order. One solution is a multi-stage method, u n+1 j û j = u n j ˆω ( R j / u j ) 1 R j (u n ) = u n j ω ( R j / u j ) 1 R j (û) Requires two residual evaluations. Computational Prototyping Group Seminar 21/53
Matrix Fill for Higher-order Finite Volume 550 500 450 400 350 300 250 200 150 100 0 First-order 0 50 50 100 150 200 250 300 350 400 450 500 550 Second-order 0 Third-order 5 5 5 10 10 10 15 15 15 20 20 20 25 25 25 30 30 30 35 35 35 40 40 40 45 0 5 10 15 20 25 30 35 40 45 nz = 115 45 0 5 10 15 20 25 30 35 40 45 nz = 355 45 0 5 10 15 20 25 30 35 40 45 nz = 601 Computational Prototyping Group Seminar 22/53
DG for the Euler Equations Start from strong form of governing equations: Look for a solution u h V p h. u t + F i (u) = 0. Multiply governing equation by weight function v h V p h and integrate over element T h : v T h [(u h) t + F i ] dx = 0. Integrate second term by parts (assume interior element): v T h (u h) t dx v T h F i dx + v + h T Hi (u + h,u h, ˆn)ds = 0. Computational Prototyping Group Seminar 23/53
DG and Finite Volume DG weighted residual: v T h (u h) t dx v T h F i dx + v + h T Hi (u + h,u h, ˆn)ds = 0. For p = 0 solution, this reduces to: (u ) t A + H i (u + h,u h, ˆn)ds = 0. Thus, p = 0 DG is identical to first-order finite volume. Computational Prototyping Group Seminar 24/53
DG discretization: Global view Find u h V p h such that v h V p h, + Γ i v + h T h { v T h (u h) t dx T Hi (u + h,u h, ˆn) ds + Ω } vh T F i dx v + T h H b i (u + h,ub h, ˆn) ds = 0. Boundary conditions enforced weakly through Hi b(u+ h,ub h, ˆn) where u b h is determined from desired boundary conditions and outgoing characteristics. For smooth problems, the error of this scheme is expected to be O(h p+1 ). Computational Prototyping Group Seminar 25/53
Pros/Cons of Higher-order DG Increased accuracy on given mesh requires additional degrees of freedom + Higher-order accuracy not hampered on unstructured meshes nor near boundaries + Local iterative methods are stable + Matrix fill-in maintains block sparsity of p = 0 v T h (u h) t dx v T h F i dx + v + h T Hi (u + h,u h, ˆn)ds = 0. Computational Prototyping Group Seminar 26/53
Stability of Local Iterative Methods for DG An elemental block Jacobi iterative method to solve this problem is, u n+1 j = u n j ω ( R j / u j ) 1 R j (u). where R j / u j is the diagonal block for the element j. For 0 < ω < 1, elemental block Jacobi is stable independent of p. Computational Prototyping Group Seminar 27/53
Matrix Fill for Higher-order DG 550 500 450 400 350 300 250 200 150 100 First-order (p = 0) 0 50 50 100 150 200 250 300 350 400 450 500 550 Second-order (p = 1) 0 Third-order (p = 2) 0 5 10 20 50 15 20 40 60 100 25 30 80 150 35 100 200 40 45 0 5 10 15 20 25 30 35 40 45 nz = 115 120 0 20 40 60 80 100 120 nz = 1035 250 0 50 100 150 200 250 nz = 4140 Computational Prototyping Group Seminar 28/53
Inviscid Flow Example 1 0.3 0.2 0.1 0 0.1 0.2 NACA 0012 M = 0.5, α = 2 o Pressure Coefficient 0.5 0 0.5 1 p = 0 0.3 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 x/c 1 1 0.5 0.5 Pressure Coefficient 0 0.5 p = 1 Pressure Coefficient 0 0.5 p = 2 1 1 1.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 x/c 1.5 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 x/c Computational Prototyping Group Seminar 29/53
Navier-Stokes Equations Navier-Stokes Equations: u t + F i (u) F v (u, u) = 0 F v = A v u = (F x v,f y v) is the viscous flux vector F x v = F y v = 2 2 3 µ(2 u x v y 2 3 µ(2 v 0 3 µ(2 u µ( u y + v x v y ) x ) )u + µ( u y + v x 2 y u x 0 µ( u y + v x ) y u x ) 3 µ(2 v )v + µ( u y + v x )v + T x )u + T y, Computational Prototyping Group Seminar 30/53
DG for Elliptic Operators: First Attempt Model problem for viscous terms of N-S: 1-D, scalar Poisson s equation u xx = f on [ 1,1] Proceed as for Euler: Triangulate domain into non-overlapping elements T h Define solution and test function space V p h Discrete formulation: Find u h V p h such that v h V p h, T h { [ v h û x ] x+1/2 x 1/2 + } (v h ) x (u h ) x dx = { } v h fdx T h Need to define û x Computational Prototyping Group Seminar 31/53
DG for Elliptic Operators: First Attempt No upwinding mechanism choose central flux û x = 1 2 ((u h) L x + (u h ) R x ) Discrete formulation becomes: Find u h V p h such that v h V p h, T h + { [ 1 ] 2 v h((u h ) L x + (u h ) R x+1/2 x ) x 1/2 } (v h ) x (u h ) x dx PROBLEM: Scheme is inconsistent! = { } v h fdx T h Computational Prototyping Group Seminar 32/53
Inconsistency Examine Laplace s equation with homogeneous Dirichlet BCs u xx = 0 on [ 1,1] u( 1) = u(1) = 0 Exact solution: u(x) = 0 R(u h)=0 u h x If (u h ) x = 0 everywhere, discrete equations satisfied exactly regardless of magnitude of u h Computational Prototyping Group Seminar 33/53
First Order System Approach Introduce new variable, q = u x, such that q x = f q u x = 0 Discrete formulation: Find u h V p h and q h V p h such that v h V p h and τ h V p h, T h { [ ] x+1/2 v h q + x 1/2 T h { Need to choose q and û τ h q h dx + } (v h ) x q h dx { } v h fdx T h (τ h ) x u h dx [ ] x+1/2 } τ h û x 1/2 = 0 = 0 Computational Prototyping Group Seminar 34/53
Bassi-Rebay Schemes Scheme 1: no upwinding mechanism choose central fluxes û = 1 2 (ul h + ur h ); q = 1 2 (ql h + qr h ) Sub-optimal order of accuracy for odd p Stencil no longer compact Scheme 2: With s = s L s R and {s} = 0.5(s L + s R ), û = {u h }; q = {(u h ) x } η f {δ f } New variable, δ f ( u ), is a jump penalty term. Optimal accuracy and compact stencil. Computational Prototyping Group Seminar 35/53
Iterative Solver Nonlinear discrete equations can be written R(u h ) = 0 Use a preconditioned iterative scheme u n+1 h = u n h P 1 R(u n h ) Preconditioner Block-element smoothing P = M block Block diagonal of the Jacobian Line-element smoothing P = M line Block tridiagonal systems from Jacobian Computational Prototyping Group Seminar 36/53
Line Solver Motivation: Transport of information in Navier-Stokes equations characterized by convection-diffusion like phenomena Inviscid regions: characteristic directions set by convection Viscous regions: diffusion effects can be stronger Procedure: Construct lines of elements based on measure of influence Build and invert M line, which is a set of block tridiagonal systems from the full Jacobian Computational Prototyping Group Seminar 37/53
Example Lines and Performance Trailing edge of NACA 0012 10 2 Convection Diffusion Lines Convection Only Lines 10 0 10 2 R L1 10 4 10 6 10 8 10 10 0 500 1000 1500 2000 2500 3000 3500 Line Solver Iters Computational Prototyping Group Seminar 38/53
p-multigrid Solver: Motivation Observation: Smoothers are inefficient at eliminating low frequency error modes on fine level h-multigrid Spatially coarse grid used to correct solution on fine grid Grid coarsening is complex on unstructured meshes p-multigrid (Ronquist & Patera, Helenbrook et al., Fidkowski & Darmofal) Low order (p 1) approximation used to correct high order (p) solution Natural implementation in DG discretization on unstructured meshes Computational Prototyping Group Seminar 39/53
p-multigrid Solver: Full Multigrid Iterate on coarsest levels first and use these solutions as initial guesses for fine level solutions. Line solver used as smoother Full Approximation Scheme (FAS) used to deal with non-linearity p=3 p=2 p=1 p=0 Computational Prototyping Group Seminar 40/53
NACA 0012 Test Case M = 0.5, Re = 5000, α = 0 Grids are from Swanson at NASA Langley 2112 element mesh Mach contours Computational Prototyping Group Seminar 41/53
Drag Error Convergence 10000* c d c d,e 10 4 10 2 10 0 10 2 6.88 p = 0 p = 1 p = 2 p = 3 0.85 2.42 3.99 3.22 10000* c d c d,e 10 2 10 1 10 0 10 1 10 2 10 3 p = 1 p = 2 p = 3 FUN2D 10 4 0 0.5 1 1.5 2 log (h /h) 2 0 10 4 10 4 10 5 10 6 DOF Computational Prototyping Group Seminar 42/53
CPU Timing 10 2 10 1 p = 1 p = 2 p = 3 10000* c d c d,e 10 0 10 1 10 2 10 3 10 2 10 3 10 4 CPU Time (s) Computational Prototyping Group Seminar 43/53
h-adaptation For smooth flows, large high-order elements are ideal for accuracy and efficiency When singularities are present, h-adaptation is necessary to maintain accuracy Where to adapt? One option is output-based adaptation (Venditti & Darmofal) Pick output of interest (lift, drag) and a desired error tolerance Solve for output adjoint in addition to the flow solution Use adjoint and flow solutions to estimate which elements contribute most/least to output error Refine/coarsen mesh until the output error tolerance is met Computational Prototyping Group Seminar 44/53
h-adaptation Example NACA 0012 Transonic test case: M = 0.8, α = 1.25 o Computational Prototyping Group Seminar 45/53
NACA 0012: M = 0.8, α = 1.25 o P1 49,836 DOF C d C d,exact = 4.0 10 5 P2 30,288 DOF C d C d,exact = 1.2 10 5 Computational Prototyping Group Seminar 46/53
Ongoing Work Turbulence modeling (Todd Oliver) Shocks (Garrett Barter) Adaptation (Mike Park and Chris Fidkowski) Optimization (James Lu) Unsteady + Frequency Domain Solver (Tan Bui) Axisymmetric Solver + Plasma Physics (Shannon Cheng) Explicit solver (Pete Whitney) Hypersonic Flow (Doug Quattrochi) Computational Prototyping Group Seminar 47/53
Questions? Computational Prototyping Group Seminar 48/53
BR1 Scheme No upwinding mechanism choose central fluxes û = 1 2 (ul h + ur h ); q = 1 2 (ql h + qr h ) Sub-optimal order of accuracy for odd p Stencil no longer compact q q u k -1 k -1 u k-2 k -1 R k q k u k q k q k+1 u k -1 u k u k+1 q k+1 u k u k+1 u k+2 Computational Prototyping Group Seminar 49/53
BR1 Scheme Define jump,, and average, { }, operators: Central fluxes become s = s L s R and {s} = 1 2 (sl + s R ) û = {u h }; q = {(u h ) x } {δ} δ given by following problem: Find δ V p h such that τ h V p h, T h τ h δdx = n [ ] u h {τ h } Computational Prototyping Group Seminar 50/53
BR1 Scheme BR1 becomes: Find u h V p h and such that v h V p h, T h n (v h ) x (u h ) x dx [ ] u h {(v h ) x } + v h ({(u h ) x } {δ}) = Th v h fdx u k-1 R k δ k-1 u k δ k u k +1 δ k+1 δ k-1 u k-2 u k-1 u k Stencil extended by δ dependence on u h k-1 δ k u u k u k +1 δ k+1 u k u k +1 u k+2 Computational Prototyping Group Seminar 51/53
BR2 Scheme Goal: Eliminate extended stencil Approach: Modify auxiliary variable, δ, previously defined by: T h τ h δdx = n [ ] u h {τ h } New variable, δ f, given by: Find δ f V p h such that τ h V p h, L/R τ h δ L/R f dx = New fluxes have same form as before [ u h {τ h } L/R] n f û = {u h }; q = {(u h ) x } η f {δ f } Computational Prototyping Group Seminar 52/53
BR2 Scheme Replacing {δ} in BR1 by η f {δ f } gives BR2 For proper choice of η f, can prove optimal order of accuracy Stencil is compact R k u k -1 +/- δ k-1/2 u k u +/- k +1 δ k+1/2 +/- δ k-1/2 u k -1 u k +/- δ k+1/2 u k u k +1 Computational Prototyping Group Seminar 53/53