<a name="Intro"></a>
<h1>An example of the MeshWorker framework with an advection problem</h1>

<h3>Overview</h3>

This example is devoted to the MeshWorker framework and the <em>discontinuous
Galerkin method</em>, or in short: DG method. It includes the following topics.
<ol>
  <li> Discretization of the linear advection equation with the DG method.
  <li> Assembling of the system matrix using the MeshWorker::loop().
</ol>

The particular concern of this program are the loops of DG methods. These turn
out to be especially complex, primarily because for the face terms, we have to
distinguish the cases of boundary, regular interior faces and interior faces
with hanging nodes, respectively. The MeshWorker framework implements the
standard loop over all cells and faces in MeshWorker::loop() and takes care of
distinguishing between all the different faces.

There are two things left to do if you use MeshWorker: first, you need
to write the local integrators for your problem. Second, you select
classes from the MeshWorker namespace and combine them to achieve your
goal.


<h3>Problem</h3>

The model problem solved in this example is the linear advection equation
@f[
  \nabla\cdot \left({\mathbf \beta} u\right)=0 \qquad\mbox{in }\Omega,
@f]
subject to the boundary conditions
@f[
u=g\quad\mbox{on }\Gamma_-,
@f]
on the inflow part $\Gamma_-$ of the boundary $\Gamma=\partial\Omega$
of the domain.  Here, ${\mathbf \beta}={\mathbf \beta}({\bf x})$ denotes a
vector field, $u$ the (scalar) solution
function, $g$ a boundary value function,
@f[
\Gamma_-:=\{{\bf x}\in\Gamma, {\mathbf \beta}({\bf x})\cdot{\bf n}({\bf x})<0\}
@f]
the inflow part of the boundary of the domain and ${\bf n}$ denotes
the unit outward normal to the boundary $\Gamma$. This equation is the
conservative version of the advection equation already considered in
step-9 of this tutorial.
In particular, we solve the advection equation on
$\Omega=[0,1]^2$ with ${\mathbf \beta}=\frac{1}{|x|}(-x_2, x_1)$
representing a circular counterclockwise flow field, and $g=1$
on ${\bf x}\in\Gamma_-^1:=[0,0.5]\times\{0\}$ and $g=0$ on ${\bf x}\in
\Gamma_-\setminus \Gamma_-^1$.

We apply the well-known upwind discontinuous Galerkin method. To this
end, we introduce the mesh dependent bilinear form

@f[
  -\sum_{T\in \mathbb T_h}\bigl(u_h,{\mathbf \beta}\cdot\nabla v_h\bigr)_T
  +\sum_{F\in\mathbb F_h^i} \bigl<u_h^-, \beta\cdot[v_h\mathbf n]\bigr>_{F}
  + \bigl<u_h, v_h \beta\cdot \mathbf n\bigr>_{\Gamma_+}
  =-\bigl<g, v_h \beta\cdot\mathbf n\bigr>_{\Gamma_-}.
@f]

Here, $\mathbb T_h$ is the set of all active cells of the triangulation
and $\mathbb F_h^i$ is the set of all active interior faces.
$(\cdot, \cdot)_T$ and $\left<\cdot, \cdot\right>_{F}$ denote the
<i>L<sup>2</sup></i>-inner products on the cell $T$ and a face $F$,
respectively.  The jump is defined as $[v\mathbf n] = v^+\mathbf n^+ +
v^-\mathbf n^-$, where the superscripts refer to the upwind ('+') and
downwind ('-') values at the face.

In order to implement this bilinear form, we need to compute the cell
terms $\bigl(u_h,{\mathbf \beta}\cdot\nabla v_h\bigr)_T$, the internal fluxes
$\bigl<u_h^-, \beta\cdot[v_h\mathbf n]\bigr>_{F}$, and the boundary terms $\bigl<u_h,
v_h \beta\cdot \mathbf n]\bigr>_{\Gamma_+}$ and $\bigl<g, \beta\cdot\mathbf n
v_h\bigr>_{\Gamma_-}$. The summation of all those is done by MeshWorker::integration_loop().

