# Solving the Advection Equation with Forcing using the Discontinuous Galerkin Method

I've been learning about the Discontinous Galkerin Method by reading the book by Hesthaven and Warburton and have ran into a problem with the advection equation with forcing

$u_t + u_x = g(x,t)$

Following the book I've been able to implement a method that works when $g(x,t) = 0$ in Mathematica but am having trouble to get a stable method when the forcing function is active.

Additionally I've got the domain as $[0,1]$ with 4 elements and have tried both situations below with differing order of elements and boundary and initial conditions are

$u(0,t) = sin(t)$

$u(x,0) = -sin(x)$

I assume I'm missing something very obvious but I've tried implementing it as a 'direct method'

$\textbf{u}_t =-\mathcal{M}^{-1}\mathcal{S} \textbf{u} + \mathcal{M}^{-1}[\textbf{f}^*] + \mathcal{M}^{-1} \textbf{g}_h$

where

$[\textbf{f}^*]$ are the DG fluxes and

$\textbf{g}_h = \int g(x,t) l(x) dx$

and $l(x)$ is the Lagrange polynomial, which appears to work so long as the forcing function goes to zero at the origin but fails when it doesn't and is particularly bad when g(x,t) = 1

as well as an 'indirect' method where

$\textbf{u}_t =-\mathcal{M}^{-1}\mathcal{S} \textbf{u} + \mathcal{M}^{-1}[\textbf{f}^*] + g(x,t)$

i.e. Following the book the mass matrix you get from the discretisation of g (which I'm not 100% clear on but that's a different question) is cancelled out by the inverse mass matrix from $u_t$ term which doens't work at all.

The questions are, am I correct in assuming that in general $g(x,t)$ can be any function, including a non-zero constant, without additional corrections e.g. artificial viscosity?

And am I missing anything in the formulation, e.g. do the inter-element fluxes need to include additional terms from $g(x,t)$?

• Yes, in principle $g$ can be any function of $x$ and $t$. Nov 2 '17 at 8:57
• No it cannot be any function of $x$ and $t$. It must be bounded or well-posedness is lost. Jul 14 '19 at 13:51

Your numerical integration technique also need to be stable to $u_{t}=g(x,t)$ which may have different time step restrictions than the hyperbolic terms.