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$$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?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$ ?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.EDITPerhaps 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 thingsshould I replace $u_h$ in the RHS?From there how can a matrix arise?I'm sure I am missing something in my development but I cannot see what it is.
Discontinuous Galerkin, residual orthogonal to test functions?
discontinuous galerkin