# Discontinuous Galerkin, residual orthogonal to test functions?

I am a little confused about where does the mass and stiff matrix come from. In Discontinuous Galerkin we divide the domain in elements, $\Omega = \cup^K_{k=1} D^k$. Then assume the solution $u$ can be locally approximated by a polynomial as

$$u_h=\sum_{i=1}^{Np}\hat u_i^k \Phi_i$$

We then introduce the approximated solution into the conservation law to get the residual

$$\mathcal{R} = \frac{\partial u_h}{\partial t} + \frac{\partial au_h}{\partial x} = 0$$

We define now a space of test functions $V_h = \cup^K_{k=1}V_h^k$ where a locally defined member of $V_h^k$ is defined as

$$\phi_h^k=\sum_{j=1}^{N_p} \hat \phi_j^k \Phi_j$$

Finally we require that the residual to be orthogonal to all the test functions in $V_h$ yielding

$$\int_{D^k}\mathcal{R}(x,t)\Phi_j dx= 0$$

1. Why do we say that the residual must be orthogonal to all test functions? Shouldn't we need it to be just orthogonal to the functions locally?
2. In the inner product between the residual and the test functions, why are we using $\Phi_j$ instead of $\phi_h^k$? Is it because we are asking to be orthogonal to all the test functions, i.e. the basis of the test functions? So we don't care about the coefficients $\hat \phi_j^k$ ?
3. How does the mass/stiffness matrix appear? This is just notation probably, but I don't see how from the integral a matrix is built.

EDIT

Perhaps I didn't explain myself correctly. So, given the PDE we multiply by a test function and integrate by parts over spatial domain, gives

$$\int_{D^k} \frac{\partial u_h}{\partial t} \phi_j+ \frac{\partial au_h}{\partial x} \phi_j dx$$ $$\int_{D^k} \frac{\partial u_h}{\partial t} \phi_j+ \frac{\partial \phi_j}{\partial x} au_h = -[(au_h)\phi_j]^{k+1}_{k}$$

Now suppose $u_h = \sum_{i=1}^{N_p}\hat u_h \phi_i$

I get something like

$$\int_{D^k} \frac{\partial}{\partial t}(\sum_{i=1}^{N_p}\hat u_h \phi_i) \phi_j+ \frac{\partial \phi_j}{\partial x} (\sum_{i=1}^{N_p}\hat u_h \phi_i) = -[(au_h)\phi_j]^{k+1}_{k}$$

where in this last step, I'm confused about two things

1. should I replace $u_h$ in the RHS?
2. From there how can a matrix arise?

I'm sure I am missing something in my development but I cannot see what it is.

1. since the test functions are discontinuous, all test functions contain those with only element support.

2. in matrix-vector form, you would write the discrete variational problem (with boundary conditions) as $v^T A u = v^T f$ for all $v \in \mathbb{R}^n$ (I skipped the temporal derivative here for simplicity). Now, if $A$ is invertible, you could as well just solve the problem $Au=f$.

3. if you insert the expansions of your trial and test functions, you can simply compute the entries of the mass/stiffness-matrix. For instance for the mass part you obtain $M_{ij}^k = \int_{D_k}\Phi_j\Phi_i\,{\rm d}x$. This is explained in any finite element primer (which I suggest to read before the more advanced topics like DG).

That being said, the DG-formulation which you propose will most likely not produce any meaningful results if you don't introduce any sort of coupling between the cell-degrees of freedom. For continuous finite elements this coupling is introduced in the function space, for DG, you have to introduce it in the derivation via fluxes (which are usually suitably chosen for consistency/conservativeness/stability).

I am not sure about your mathematical background, but this and much more is covered in Di Pietro's and Ern's book. However, I would recommend to read about the basics of FEM/FV methods first.

• Could you recommend a good FEM reference? – BRabbit27 Jan 27 '15 at 9:47
• This really depends on your background. I learned the basics from Braess' finite element book, but it is really a matter of taste and previous knowledge. If you are not interested in theory too much, you can as well look at some engineering literature, although in my opinion the didactical approaches taken there are usually not helpful if you want to learn about nonconforming methods later. – Christian Waluga Jan 27 '15 at 15:01
• I've been exposed to numerical methos for sometime, i do like the math approach but when the book just becomes theorem after theorem I lose interest, i prefer something that also has some implementation (otherwise math on paper wont solve the problems hehe) – BRabbit27 Jan 27 '15 at 15:38