$ \newcommand{\div}{\mathop{\rm div}\nolimits} \newcommand{\llbracket}{[[} \newcommand{\rrbracket}{]]} $

In lecture notes related to the Discontinuous Galerkin method, there is mention of a magic formula which AFAIK first appeared on a paper1 by Douglas Arnold (at least in this context).

It has been proven and all, but it’s still called magic because its reasoning is not apparent at first glance. The magic formula is actually a superset of the divergence theorem, generalized to discontinuous fields. But to make that generalization, we need to abandon the standard formulation which starts by creating a triangular mesh, and consider arbitrary partitionings of a domain.

A domain Ω\Omega is partitioned into parts PiP^i, i=1,,ni=1,\dots,n as follows:

Ω=i=1nPi\Omega=\bigcup_{i=1}^{n} P^i P={P1,,Pn}\mathcal{P} = \{P^1,\dots,P^{n}\}

We call the set of parts P\mathcal{P} a partition of Ω\Omega.

Broken Hilbert Spaces

We allow the vector field u\boldsymbol{u} to be discontinuous at boundaries Pi\partial P^i and continuous in PiP^i, i=1,,ni=1,\dots,n. To this end, we define the broken Hilbert space over partition P\mathcal{P}

Hm(P):={vL2(Ω)ndPP,vPHm(P)}\begin{equation} H^m(\mathcal{P}) := \{\boldsymbol{v}\in L^2(\Omega)^{n_d} \mid \forall P\in\mathcal{P}, \boldsymbol{v}|_P \in H^m(P)\} \tag{1}\end{equation}

It can be seen that Hm(P)Hm(Ω)H^m(\mathcal{P})\subseteq H^m(\Omega).

Part Boundaries

Topologically, a part may share boundary with Ω\Omega, like P4P^4. In that case, the boundary of the part is divided into an interior boundary and exterior boundary:

Pexti=PiΩandPinti=PiPexti\begin{equation} \partial P_{\text{ext}}^i = \partial P^i \cap \partial\Omega \quad\text{and}\quad \partial P_{\text{int}}^i = \partial P^i \setminus \partial P_{\text{ext}}^i \tag{2}\end{equation}

If a part has an exterior boundary, it is said to be an external part (P3P^3, P4P^4, P5P^5, P6P^6). If it does not have any exterior boundary, it is said to be an internal part.(P1P^1, P2P^2).

Divergence theorem over parts

For a vector field vH1(P)\boldsymbol{v}\in H^1(\mathcal{P}), i=1,,ni=1,\dots,n, we can write the following integral as a sum and apply the divergence theorem afterward

ΩdivvdV=i=1nPidivvdV=i=1nPivndA=i=1nPextivndA+i=1nPintivndA\begin{equation} \begin{aligned} \int_\Omega \div{\boldsymbol{v}} \,dV &= \sum\limits_{i=1}^{n}\int_{P^i}\div\boldsymbol{v} \,dV = \sum\limits_{i=1}^{n}\int_{\partial P^i} \boldsymbol{v}\cdot\boldsymbol{n} \,dA \\ &= \sum\limits_{i=1}^{n}\int_{\partial P_{\text{ext}}^i} \boldsymbol{v}\cdot\boldsymbol{n} \,dA +\sum\limits_{i=1}^{n}\int_{\partial P_{\text{int}}^i} \boldsymbol{v}\cdot\boldsymbol{n} \,dA \end{aligned} \tag{3}\end{equation}

We define the portion Γij\Gamma^{ij} of the boundary that part PiP^i shares with PjP^j as the interface between PiP^i and PjP^j.

Γij=PiPj\begin{equation} \Gamma^{ij} = \partial P^i \cap \partial P^j \tag{4}\end{equation}

If PiP^i and PjP^j are not neighbors, we simply have Γij=\Gamma^{ij}=\emptyset.

Integrals over interior boundaries

For opposing parts PiP^i and PjP^j,

we have different values of the function vij=vΓij\boldsymbol{v}^{ij} = \boldsymbol{v}|_{\Gamma^{ij}} and conjugate normal vectors at the interface Γij\Gamma^{ij}:

vijvjiandnij=nji\begin{equation} \boldsymbol{v}^{ij}\neq\boldsymbol{v}^{ji} \quad\text{and}\quad \boldsymbol{n}^{ij} = -\boldsymbol{n}^{ji} \tag{5}\end{equation}

Since

Pinti=j=1nΓijfori=1,,n\begin{equation} \partial P_{\text{int}}^i = \bigcup_{j=1}^{n} \Gamma^{ij} \quad \text{for}\quad i=1,\dots,n \tag{6}\end{equation}

we can rearrange the integral over interior boundaries as

i=1nPintivndA=i=1nj=1nΓijvijnijdA\begin{equation} \sum\limits_{i=1}^{n}\int_{\partial P_{\text{int}}^i} \boldsymbol{v}\cdot\boldsymbol{n} \,dA = \sum\limits_{i=1}^{n}\sum\limits_{j=1}^{n}\int_{\Gamma^{ij}} \boldsymbol{v}^{ij}\cdot\boldsymbol{n}^{ij} \,dA \tag{7}\end{equation}

The jump operator

Integrals over the same interface can be grouped together:

i=1nj=1nΓijvijnijdA=i=1nj=inΓijΓji(vijnij+vjinji)dA\begin{equation} \sum\limits_{i=1}^{n}\sum\limits_{j=1}^{n}\int_{\Gamma^{ij}} \boldsymbol{v}^{ij}\cdot\boldsymbol{n}^{ij} \,dA = \sum\limits_{i=1}^{n}\sum\limits_{j=i}^{n}\int_{\Gamma^{ij}\equiv\Gamma^{ji}} (\boldsymbol{v}^{ij}\cdot\boldsymbol{n}^{ij} + \boldsymbol{v}^{ji}\cdot\boldsymbol{n}^{ji}) \,dA \tag{8}\end{equation}

Defining the jump of v\boldsymbol{v} across Γij\Gamma^{ij}

[[v]]Γij=vijvji\begin{equation} \llbracket\boldsymbol{v}\rrbracket_{\Gamma^{ij}} = \boldsymbol{v}^{ij} - \boldsymbol{v}^{ji} \tag{9}\end{equation}

The jump of a function measures its discontinuity across interfaces. We can write

Γij[[v]]ΓijnijdA=Γij(vijnij+vjinji)dA\begin{equation} \int_{\Gamma^{ij}} \llbracket\boldsymbol{v}\rrbracket_{\Gamma^{ij}}\cdot\boldsymbol{n}^{ij} \,dA = \int_{\Gamma^{ij}} (\boldsymbol{v}^{ij}\cdot\boldsymbol{n}^{ij} + \boldsymbol{v}^{ji}\cdot\boldsymbol{n}^{ji}) \,dA \tag{10}\end{equation}

We may drop the superscripts where there is no confusion.

Interfaces and external boundaries

It is convenient to group the interfaces:

I:={Γiji=1,,n;j=i,,n}\begin{equation} \boxed{ \mathcal{I} := \{\Gamma^{ij}\mid i=1,\dots,n; j=i,\dots,n\} } \tag{11}\end{equation}

which allows us to write

i=1nj=inΓij[[v]]ndA=ΓIΓ[[v]]ndA\begin{equation} \sum\limits_{i=1}^{n}\sum\limits_{j=i}^{n} \int_{\Gamma^{ij}} \llbracket\boldsymbol{v}\rrbracket\cdot\boldsymbol{n} \,dA = \sum\limits_{\Gamma\in\mathcal{I}} \int_{\Gamma} \llbracket\boldsymbol{v}\rrbracket\cdot\boldsymbol{n}\,dA \tag{12}\end{equation}

It’s obvious that the union of part external boundaries equals the domain boundary:

i=1nPexti=Ω\begin{equation} \bigcup_{i=1}^{n} \partial P_{\text{ext}}^i = \partial \Omega \tag{13}\end{equation}

which allows us to write

i=1nPextivndA=ΩvndA\begin{equation} \sum\limits_{i=1}^{n}\int_{\partial P_{\text{ext}}^i} \boldsymbol{v}\cdot\boldsymbol{n} \,dA = \int_{\partial\Omega} \boldsymbol{v}\cdot\boldsymbol{n} \,dA \tag{14}\end{equation}

With the results obtained, we put forward a generalized version of the divergence theorem: Let vH1(P)\boldsymbol{v}\in H^1(\mathcal{P}) be a vector field. Then we have

ΩdivvdV=ΩvndA+ΓIΓ[[v]]ndA\begin{equation} \boxed{ \int_\Omega \div\boldsymbol{v} \,dV = \int_{\partial\Omega} \boldsymbol{v}\cdot\boldsymbol{n} \,dA + \sum\limits_{\Gamma\in\mathcal{I}} \int_{\Gamma} \llbracket\boldsymbol{v}\rrbracket\cdot\boldsymbol{n} \,dA } \tag{15}\end{equation}

Verbally, the integral of the divergence of a vector field over a domain Ω\Omega equals its integral over the domain boundary Ω\partial\Omega, plus the integral of its jump over part interfaces I\mathcal{I}.

In the case of a continuous field, the jumps vanish and this reduces to the regular divergence theorem.

The Magic Formula

There are different versions of the magic formula for scalar, vector and tensor fields, and for different IBVPs. I won’t try to derive them all, but give an example: If we were substitute a linear mapping Av\boldsymbol{A}\boldsymbol{v} instead of v\boldsymbol{v}, we would have the jump [[Av]]\llbracket \boldsymbol{A}\boldsymbol{v} \rrbracket on the right-hand side.

We introduce the vector and tensor average operator {}\{\cdot\}

{v}Γij=12(vij+vji)and{A}Γij=12(Aij+Aji)\begin{equation} \{\boldsymbol{v}\}_{\Gamma^{ij}} = \frac{1}{2} (\boldsymbol{v}^{ij} + \boldsymbol{v}^{ji}) \quad\text{and}\quad \{\boldsymbol{A}\}_{\Gamma^{ij}} = \frac{1}{2} (\boldsymbol{A}^{ij} + \boldsymbol{A}^{ji}) \tag{16}\end{equation}

and tensor jump operator [[]]\llbracket\cdot\rrbracket

[[A]]Γij=AijAji\begin{equation} \llbracket\boldsymbol{A}\rrbracket_{\Gamma^{ij}} = \boldsymbol{A}^{ij} - \boldsymbol{A}^{ji} \tag{17}\end{equation}

We also note the boundary jump/average property which is used on the integral over Ω\partial\Omega

{v}=[[v]]=vonΩ\begin{equation} \boxed{ \{\boldsymbol{v}\} = \llbracket\boldsymbol{v}\rrbracket = \boldsymbol{v} \quad \text{on}\quad\partial\Omega } \htmlId{eq:property1}{} \tag{18}\end{equation}

(This property is used implicitly in many places, and often causes confusion).

These definitions allow us to write the identity

[[Av]]=[[A]]{v}+{A}[[v]]\begin{equation} \boxed{ \llbracket\boldsymbol{A}\boldsymbol{v}\rrbracket = \llbracket\boldsymbol{A}\rrbracket\{\boldsymbol{v}\} + \{\boldsymbol{A}\}\llbracket\boldsymbol{v}\rrbracket } \tag{19}\end{equation}

which is easily proven when expanded.

The different versions of the magic formula are obtained by substituting the identities above—or their analogs—in the discontinuous divergence theorem.

  1. Douglas N. Arnold. An interior penalty finite element method with discontinuous elements. SIAM J. Numer. Anal., 19(4):742–760, 1982.