\end{lstlisting}
Finally, we specify the initial value of the solution on the domain
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
\subsubsection{Running the code}
\begin{lstlisting}[style=BashInputStyle]
ADRSolver Advection1D.xml
\end{lstlisting}
To visualise the output, we can convert it into either TecPlot or VTK formats
\begin{lstlisting}[style=BashInputStyle]
FieldConvert Advection1D.xml Advection1D.fld Advection1D.dat
FieldConvert Advection1D.xml Advection1D.fld Advection1D.vtu
\end{lstlisting}
\subsection{2D Helmholtz Problem}
In this example, it will be demonstrated how the Helmholtz equation can be solved on a two-dimensional domain.
\subsubsection{Helmholtz equation}
We consider the elliptic partial differential equation:
\begin{equation}
\nabla^2 u + \lambda u = f
\end{equation}
where $\nabla^2$ is the Laplacian and $\lambda$ is a real positive constant.
\subsubsection{Input file}
The input for this example is given in the example file
\inlsh{Helmholtz2D\_modal.xml}
The geometry for this problem is a two-dimensional octagonal plane containing
both triangles and quadrilaterals. Note that a mesh composite may only contain
one type of element. Therefore, we define two composites for the domain, while
the rest are used for enforcing boundary conditions.
\begin{lstlisting}[style=XMLStyle]
Q[22-47]
T[0-21]
E[0-1]
.
.
E[84,75,69,62,51,40,30,20,6]
C[0-1]
\end{lstlisting}
For both the triangular and quadrilateral elements, we use the modified Legendre
basis with $7$ modes (maximum polynomial order is $6$).
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
Only one parameter is needed for this problem. In this example $\lambda = 1$ and
the Continuous Galerkin Method is used as projection scheme to solve the
Helmholtz equation, so we need to specify the following parameters and solver
information.
\begin{lstlisting}[style=XMLStyle]

Lambda = 1

*
**
**
\end{lstlisting}
All three basic boundary condition types have been used in this example:
Dirichlet, Neumann and Robin boundary. The boundary regions are defined, each of
which corresponds to one of the edge composites defined earlier. Each boundary
region is then assigned an appropriate boundary condition.
\begin{lstlisting}[style=XMLStyle]
*** C[2] **
.
.
** C[10] **
.
.
\end{lstlisting}
We know that for $f = -(\lambda + 2 \pi^2)sin(\pi x)cos(\pi y)$, the exact
solution of the two-dimensional Helmholtz equation is $u = sin(\pi x)cos(\pi
y)$. These functions are defined specified to initialise the problem and verify
the correct solution is obtained by evaluating the $L_2$ and $L_{inf}$ errors.
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
\subsubsection{Running the code}
\begin{lstlisting}[style=BashInputStyle]
ADRSolver Test_Helmholtz2D_modal.xml
\end{lstlisting}
This execution should print out a summary of input file, the $L_2$ and
$L_{inf}$ errors and the time spent on the calculation.
\subsubsection{Post-processing}
Simulation results are written in the file Helmholtz2D\_modal.fld. We can choose
to visualise the output in Gmsh
\begin{lstlisting}[style=BashInputStyle]
FieldConvert Helmholtz2D_modal.xml Helmholtz2D_modal.fld Helmholtz2D_modal.vtu
\end{lstlisting}
which generates the file Helmholtz2D\_modal.vtu which can be visualised and is
shown in Fig.~\ref{f:adrsolver:helmholtz2D}
\begin{figure}
\begin{center}
\includegraphics[width=6cm]{img/Helmholtz2D}
\caption{Solution of the 2D Helmholtz Problem.}
\label{f:adrsolver:helmholtz2D}
\end{center}
\end{figure}
\subsection{Advection dominated mass transport in a pipe}
The following example demonstrates the application of the ADRsolver for
modelling advection dominated mass transport in a straight pipe.
Such a transport regime is encountered frequently when modelling mass transport
in arteries. This is because the diffusion coefficient of small blood borne
molecules, for example oxygen or adenosine triphosphate, is very small
$O(10^{-10})$.
\subsubsection{Background}
The governing equation for modelling mass transport is the unsteady advection
diffusion equation:
\begin{align*}
\dfrac{\partial u}{\partial t} + v\nabla u + \epsilon \nabla^2 u = 0
\end{align*}
For small diffusion coefficient, $\epsilon$, the transport is dominated by
advection and this leads to a very fine boundary layer adjacent to the surface
which must be captured in order to get a realistic representation of the wall
mass transfer processes. This creates problems not only from a meshing
perspective, but also numerically where classical oscillations are observed in
the solution due to under-resolution of the boundary layer.
The Graetz-Nusselt solution is an analytical solution of a developing mass (or
heat) transfer boundary layer in a pipe. Previously this solution has been used
as a benchmark for the accuracy of numerical methods to capture the fine
boundary layer which develops for high Peclet number transport (the ratio of
advection to diffusion). The solution is derived based on the assumption that
the velocity field within the mass transfer boundary layer is linear i.e. the
Schmidt number (the relative thickness of the momentum to mass transfer boundary
layer) is sufficiently large. The analytical solution for the non-dimensional
mass transfer at the wall is given by:
\begin{align*}
S h(z) = \dfrac{2^{4/3}(Pe R/z)^{1/3}}{g^{1/3}\Gamma(4/3)} ,
\end{align*}
where $z$ is the streamwise coordinate, $R$ the pipe radius, $\Gamma(4/3)$ an incomplete
Gamma function and $Pe$ the Peclet number given by:
\begin{align*}
Pe = \dfrac{2 U R}{\epsilon}
\end{align*}
In the following we will numerically solver mass transport in a pipe and compare
the calculated mass transfer at the wall with the Graetz-Nusselt solution. The
Peclet number of the transport regime under consideration is $750000$, which is
physiologically relevant.
\subsubsection{Input file}
The geometry under consideration is a pipe of radius, $R = 0.5$ and length $l =
0.5$
\begin{figure}[h!]
\begin{center}
\includegraphics[width=6cm]{img/pipe}
\caption{Pipe.}
\end{center}
\end{figure}
Since the mass transport boundary layer will be confined to a very small layer
adjacent to the wall we do not need to mesh the interior region, hence the mesh
consists of a layer of ten prismatic elements over a thickness of 0.036R. The
elements progressively grow over the thickness of domain.
In this example we utilise heterogeneous polynomial order, in which the
polynomial order normal to the wall is higher so that we avoid unphysical
oscillations, and hence the incorrect solution, in the mass transport boundary
layer. To do this we specify explicitly the expansion type, points type and
distribution in each direction as follows:
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
The above represents a quadratic polynomial order in the azimuthal and
streamwise direction and 4th order polynomial normal to the wall for a prismatic
element.
We choose to use a continuous projection and an first-order implicit-explicit
time-integration scheme. The \inltt{DiffusionAdvancement} and
\inltt{AdvectionAdvancement} parameters specify how these terms are treated.
\begin{lstlisting}[style=XMLStyle]
*
**
**
**
**
**
**
\end{lstlisting}
We integrate for a total of $30$ time units with a time-step of $0.0005$,
necessary to keep the simulation numerically stable.
\begin{lstlisting}[style=XMLStyle]
* TimeStep = 0.0005

FinalTime = 30

NumSteps = FinalTime/TimeStep

\end{lstlisting}
The value of the $\epsilon$ parameter is $\epsilon = 1/Pe$
\begin{lstlisting}[style=XMLStyle]
epsilon = 1.33333e-6

\end{lstlisting}
The analytical solution represents a developing mass transfer boundary layer in
a pipe. In order to reproduce this numerically we assume that the inlet
concentration is a uniform value and the outer wall concentration is zero; this
will lead to the development of the mass transport boundary layer along the
length of the pipe. Since we do not model explicitly the mass transfer in the
interior region of the pipe we assume that the inner wall surface concentration
is the same as the inlet concentration; this assumption is valid based on the
large Peclet number meaning the concentration boundary layer is confined to the
region in the immediate vicinity of the wall. The boundary conditions are
specified as follows in the input file:
\begin{lstlisting}[style=XMLStyle]
** C[3] **
** C[4] **
** C[2] **
** C[5] **
\end{lstlisting}
The velocity field within the domain is fully devqeloped pipe flow (Poiseuille
flow), hence we can define this through an analytical function as follows:
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
We assume that the initial domain concentration is uniform everywhere and the
same as the inlet. This is defined by,
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
\subsubsection{Results}
To compare with the analytical expression we numerically calculate the
concentration gradient at the surface of the pipe. This is then plotted against
the analytical solution by extracting the solution along a line in the
streamwise direction, as shown in Fig.~\ref{f:adrsolver:masstransport}.
\begin{figure}[h!]
\begin{center}
\includegraphics[width=7cm]{img/graetz-nusselt}
\caption{Concentration gradient at the surface of the pipe.}
\label{f:adrsolver:masstransport}
\end{center}
\end{figure}
\subsection{Unsteady reaction-diffusion systems}
Reaction-diffusion systems are prevalent in a number of areas relating to the
modelling of various physical phenomena, and are particularly prevalent in the
study of chemical interactions and pattern formation. The ADRSolver supports the
solution of a single-variable system
\[
\frac{\partial u}{\partial t} = \epsilon\nabla^2{u}{x} + R(u)
\]
where the diffusion coefficient $\epsilon$ and reaction term $R(u)$ are defined
using the session file.
\subsubsection{Numerical restrictions}
The reaction-diffusion system is only supported in a selected configuration,
which is mostly defined inside the \inltt{SOLVERINFO} block:
\begin{itemize}
\item use of a continuous Galerkin discretisation;
\item use an implicit-explicit (IMEX) timestepping scheme, such as
\inltt{IMEXOrder3};
\end{itemize}
This naturally leads to the following \inltt{SOLVERINFO} configuration:
\begin{lstlisting}[style=XMLStyle]
*
**
**
**
**
\end{lstlisting}
Further to this, the reaction term $R(u)$ is imposed by the definition of a body
forcing function. For example, the reaction term $R(u) = 0.1u$ may be defined
using the function:
\begin{lstlisting}[style=XMLStyle]
\end{lstlisting}
Note in particular the use of the \inltt{EVARS} (equation variables) attribute,
which permits the definition of this function in terms of the scalar variable
$u$. This function should be used together with an appropriate \inltt{FORCING}
block (as described in section~\ref{sec:xml:forcing}):
\begin{lstlisting}[style=XMLStyle]
BodyForce
\end{lstlisting}
An example of a simple unsteady reaction-diffusion problem can be found in the
\inltt{Tests} directory in the session file \inltt{ReactionDiffusion2D.xml}.
*