If we use CG elements (continuous Galerkin), the boundary integration in FEM can be easily converted to sum over quadrature points using node basis functions of the edges. However, in DG elements (discontinuous Galerkin), there is no shared node basis and each elements have its own node basis. So each edge has multiple set of nodes belonging to different cells.


1. How the boundary integration can be done in DG case?
2. There is a concept of topology used to describe elements. By assigning DOF to node, edge, element. This topology is very different in CG vs DG. Is it possible to generalize, this transformation of integration to finite sum, using this topology?



Boundary integration of weak form in FEM using DG elements
Discontinuous Galerkin is the name, not for a single method, but for an extremely broad family of methods. Consider the BVP $$\nabla \cdot a\nabla u = f \text{ in } \Omega \text{ and } u=0 \text{ on } \partial \Omega.$$
Assume $\bar{\Omega} = \cup\_k \bar{K}\_k$ is a triangulation of $\bar{\Omega}$. Multiply the BVP by a piecewise smooth test function $v$ and formally integrate by parts to arrive at:
$$\tag{1} 
\sum\_k \int\_{\partial K\_k} \left(\nabla u(x)\right) a(x) \nu\_k(x) v(x) \, dx -
\sum\_k \int\_{K\_k} (\nu(x)^T a(x) \nabla u(x))^T \, dx 
= \int\_{\Omega} fv.
$$
Here, $\nu\_k(x)$ is the outer-pointing normal to $\partial K\_k$.
Implied in the BVP is that $u$ is continuous, so the jump $[u]$ of $u$ must be zero along $\Gamma = \cup\_k \partial K\_k \cap \Omega$:
$$\tag{2} \int\_\Gamma [u]v \, dx =0 \text{ on } \Gamma.$$
Furthermore, $u=0$ on $\partial \Omega$.


I have now answered your question 1, because I have integrated by parts. Nevertheless, I suspect that you are still not satisfied. In my humble opinion, this is because of the still large distance between (1),(2) and a MATLAB implementation.


In DG, the basis functions are not indexed by $\phi\_{j}$, where $j$ indicates a vertex, but indeed by $\phi\_{i,k}$, where $i \in \{1,2,3\}$ indicates a vertex and $k$ indicates a face. If there are $k=1\ldots K$ faces, then there are $3K$ basis functions in DG. If you combine (1), (2), as well as the b.c. $u=0$ on $\partial \Omega$, you obtain a fully-determined linear system for the coefficients $u\_{i,k}$ of $u(x) = \sum\_{i,k} u\_{i,k} \phi\_{i,k}(x)$.


The programming of this is tedious.


