7.4 Examples

Example files for the ADRSolver are provided in solvers/ADRSolver/Examples

7.4.1 1D Advection equation

In this example, it will be demonstrated how the Advection equation can be solved on a one-dimensional domain.

7.4.1.1 Advection equation

We consider the hyperbolic partial differential equation:

∂u- + ∂f-= 0,
 ∂t   ∂x
(7.2)

where f = au is the advection flux.

7.4.1.2 Input file

The input for this example is given in the example file Advection1D.xml

The geometry section defines a 1D domain consisting of 10 segments. On each segment an expansion consisting of 4 Lagrange polynomials on the Gauss-Lobotto-Legendre points is used as specified by

1<EXPANSIONS> 
2    <E COMPOSITE="C[0]" FIELDS="u" TYPE="GLL_LAGRANGE_SEM" NUMMODES="4"/> 
3</EXPANSIONS>

Since we are solving the unsteady advection problem, we must specify this in the solver information. We also choose to use a discontinuous flux-reconstruction projection and use a Runge-Kutta order 4 time-integration scheme.

1<SOLVERINFO> 
2    <I PROPERTY="EQTYPE"                VALUE="UnsteadyAdvection"    /> 
3    <I PROPERTY="Projection"            VALUE="DisContinuous"        /> 
4    <I PROPERTY="AdvectionType"         VALUE="FRDG"                 /> 
5    <I PROPERTY="UpwindType"            VALUE="Upwind"               /> 
6    <I PROPERTY="TimeIntegrationMethod" VALUE="ClassicalRungeKutta4" /> 
7</SOLVERINFO>

We choose to advect our solution for 20 time units with a time-step of 0.01 and so provide the following parameters

1<P> FinTime         = 20                   </P> 
2<P> TimeStep        = 0.01                 </P> 
3<P> NumSteps        = FinTime/TimeStep     </P>

We also specify the advection velocity. We first define dummy parameters

1<P> advx            = 1                     </P> 
2<P> advy            = 0                     </P>

and then define the actual advection function as

1<FUNCTION NAME="AdvectionVelocity"> 
2    <E VAR="Vx" VALUE="advx" /> 
3</FUNCTION>

Two boundary regions are defined, one at each end of the domain, and periodicity is enforced

1<BOUNDARYREGIONS> 
2    <B ID="0"> C[1] </B> 
3    <B ID="1"> C[2] </B> 
4</BOUNDARYREGIONS> 
5 
6<BOUNDARYCONDITIONS> 
7    <REGION REF="0"> 
8        <P VAR="u" VALUE="[1]" /> 
9    </REGION> 
10    <REGION REF="1"> 
11        <P VAR="u" VALUE="[0]" /> 
12    </REGION> 
13</BOUNDARYCONDITIONS>

Finally, we specify the initial value of the solution on the domain

1<FUNCTION NAME="InitialConditions"> 
2    <E VAR="u" VALUE="exp(-20.0*x*x)" /> 
3</FUNCTION> 
4 
5<FUNCTION NAME="ExactSolution"> 
6    <E VAR="u" VALUE="exp(-20.0*x*x)" /> 
7</FUNCTION>

7.4.1.3 Running the code
ADRSolver Advection1D.xml

To visualise the output, we can convert it into either TecPlot or VTK formats

FieldConvert Advection1D.xml Advection1D.fld Advection1D.dat 
FieldConvert Advection1D.xml Advection1D.fld Advection1D.vtu

7.4.2 2D Helmholtz Problem

In this example, it will be demonstrated how the Helmholtz equation can be solved on a two-dimensional domain.

7.4.2.1 Helmholtz equation

We consider the elliptic partial differential equation:

  2
∇  u + λu = f
(7.3)

where ∇2 is the Laplacian and λ is a real positive constant.

7.4.2.2 Input file

The input for this example is given in the example file 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.

1<COMPOSITE> 
2     <C ID="0"> Q[22-47] </C> 
3     <C ID="1"> T[0-21] </C> 
4     <C ID="2"> E[0-1] </C> 
5     . 
6     . 
7     <C ID="10"> E[84,75,69,62,51,40,30,20,6] </C> 
8</COMPOSITE> 
9 
10<DOMAIN> C[0-1] </DOMAIN>

For both the triangular and quadrilateral elements, we use the modified Legendre basis with 7 modes (maximum polynomial order is 6).

1<EXPANSIONS> 
2    <E COMPOSITE="C[0]" NUMMODES="7" FIELDS="u" TYPE="MODIFIED" /> 
3    <E COMPOSITE="C[1]" NUMMODES="7" FIELDS="u" TYPE="MODIFIED" /> 
4</EXPANSIONS>

Only one parameter is needed for this problem. In this example λ = 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.

1<PARAMETERS> 
2    <P> Lambda = 1 </P> 
3</PARAMETERS> 
4 
5<SOLVERINFO> 
6    <I PROPERTY="EQTYPE"        VALUE="Helmholtz"  /> 
7    <I PROPERTY="Projection"    VALUE="Continuous" /> 
8</SOLVERINFO>

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.

1<BOUNDARYREGIONS> 
2    <B ID="0"> C[2] </B> 
3    . 
4    . 
5    <B ID="8"> C[10] </B> 
6</BOUNDARYREGIONS> 
7 
8<BOUNDARYCONDITIONS> 
9    <REGION REF="0"> 
10        <D VAR="u" VALUE="sin(PI*x)*sin(PI*y)" /> 
11    </REGION> 
12    <REGION REF="1"> 
13        <R VAR="u" VALUE="sin(PI*x)*sin(PI*y)-PI*sin(PI*x)*cos(PI*y)" 
14           PRIMCOEFF="1" /> 
15    </REGION> 
16    <REGION REF="2"> 
17        <N VAR="u" VALUE="(5/sqrt(61))*PI*cos(PI*x)*sin(PI*y)- 
18                          (6/sqrt(61))*PI*sin(PI*x)*cos(PI*y)" /> 
19    </REGION> 
20        . 
21        . 
22</BOUNDARYCONDITIONS>

We know that for f = -(λ + 2π2)sin(πx)cos(πy), the exact solution of the two-dimensional Helmholtz equation is u = sin(πx)cos(πy). These functions are defined specified to initialise the problem and verify the correct solution is obtained by evaluating the L2 and Linf errors.

1<FUNCTION NAME="Forcing"> 
2    <E VAR="u" VALUE="-(Lambda + 2*PI*PI)*sin(PI*x)*sin(PI*y)" /> 
3</FUNCTION> 
4 
5<FUNCTION NAME="ExactSolution"> 
6    <E VAR="u" VALUE="sin(PI*x)*sin(PI*y)" /> 
7</FUNCTION>

7.4.2.3 Running the code
ADRSolver Test_Helmholtz2D_modal.xml

This execution should print out a summary of input file, the L2 and Linf errors and the time spent on the calculation.

7.4.2.4 Post-processing

Simulation results are written in the file Helmholtz2D_modal.fld. We can choose to visualise the output in Gmsh

FieldConvert Helmholtz2D_modal.xml Helmholtz2D_modal.fld Helmholtz2D_modal.vtu

which generates the file Helmholtz2D_modal.vtu which can be visualised and is shown in Fig. 7.1


PIC

Figure 7.1: Solution of the 2D Helmholtz Problem.


7.4.3 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).

7.4.3.1 Background

The governing equation for modelling mass transport is the unsteady advection diffusion equation:

∂u-
∂t + v∇u + ϵ∇2u = 0

For small diffusion coefficient, ϵ, 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:

Sh(z) =  4∕3        1∕3
2--(P-eR∕z)----
  g1∕3Γ (4∕3),

where z is the streamwise coordinate, R the pipe radius, Γ(4∕3) an incomplete Gamma function and Pe the Peclet number given by:

Pe = 2UR--
 ϵ

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.

7.4.3.2 Input file

The geometry under consideration is a pipe of radius, R = 0.5 and length l = 0.5


PIC

Figure 7.2: Pipe.


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:

1<EXPANSIONS> 
2  <E COMPOSITE="C[0]" 
3     NUMMODES="3,5,3" 
4     BASISTYPE="Modified_A,Modified_A,Modified_B" 
5     NUMPOINTS="4,6,3" 
6     POINTSTYPE="GaussLobattoLegendre,GaussLobattoLegendre,GaussRadauMAlpha1Beta0" 
7     FIELDS="u" /> 
8</EXPANSIONS>

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 DiffusionAdvancement and AdvectionAdvancement parameters specify how these terms are treated.

1<SOLVERINFO> 
2    <I PROPERTY="EQTYPE"                VALUE="UnsteadyAdvectionDiffusion" /> 
3    <I PROPERTY="Projection"            VALUE="Continuous"                 /> 
4    <I PROPERTY="DiffusionAdvancement"  VALUE="Implicit"                   /> 
5    <I PROPERTY="AdvectionAdvancement"  VALUE="Explicit"                   /> 
6    <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder1"                 /> 
7    <I PROPERTY="GlobalSysSoln"         VALUE="IterativeStaticCond"        /> 
8</SOLVERINFO>

We integrate for a total of 30 time units with a time-step of 0.0005, necessary to keep the simulation numerically stable.

1<P> TimeStep = 0.0005              </P> 
2<P> FinalTime = 30                 </P> 
3<P> NumSteps = FinalTime/TimeStep  </P>

The value of the ϵ parameter is ϵ = 1∕Pe

1<P> epsilon = 1.33333e-6           </P>

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:

1<BOUNDARYREGIONS> 
2   <B ID="0"> C[3] </B>  <!-- inlet --> 
3   <B ID="1"> C[4] </B>  <!-- outlet --> 
4   <B ID="2"> C[2] </B>  <!-- outer surface --> 
5   <B ID="3"> C[5] </B>  <!-- inner surface --> 
6</BOUNDARYREGIONS> 
7 
8<BOUNDARYCONDITIONS> 
9  <REGION REF="0"> 
10    <D VAR="u" VALUE="1" /> 
11  </REGION> 
12  <REGION REF="1"> 
13    <N VAR="u" VALUE="0" /> 
14  </REGION> 
15  <REGION REF="2"> 
16    <D VAR="u" VALUE="0" /> 
17  </REGION> 
18  <REGION REF="3"> 
19    <D VAR="u" VALUE="1" /> 
20  </REGION> 
21</BOUNDARYCONDITIONS>

The velocity field within the domain is fully devqeloped pipe flow (Poiseuille flow), hence we can define this through an analytical function as follows:

1<FUNCTION NAME="AdvectionVelocity"> 
2  <E VAR="Vx" VALUE="0" /> 
3  <E VAR="Vy" VALUE="0" /> 
4  <E VAR="Vz" VALUE="2.0*(1-(x*x+y*y)/0.25)" /> 
5</FUNCTION>

We assume that the initial domain concentration is uniform everywhere and the same as the inlet. This is defined by,

1<FUNCTION NAME="InitialConditions"> 
2  <E VAR="u" VALUE="1" /> 
3</FUNCTION>
7.4.3.3 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. 7.3.


PIC

Figure 7.3: Concentration gradient at the surface of the pipe.


7.4.4 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

∂u-     2
∂t = ϵ∇  ux+ R (u)

where the diffusion coefficient ϵ and reaction term R(u) are defined using the session file.

7.4.4.1 Numerical restrictions

The reaction-diffusion system is only supported in a selected configuration, which is mostly defined inside the SOLVERINFO block:

This naturally leads to the following SOLVERINFO configuration:

1<SOLVERINFO> 
2    <I PROPERTY="EQTYPE"                VALUE="UnsteadyReactionDiffusion" /> 
3    <I PROPERTY="Projection"            VALUE="Continuous"                /> 
4    <I PROPERTY="DiffusionAdvancement"  VALUE="Implicit"                  /> 
5    <I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder3"                /> 
6</SOLVERINFO>

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:

1<!-- Body force to enforce reaction term --> 
2<FUNCTION NAME="BodyForce"> 
3    <E VAR="u" EVARS="u" VALUE="0.1*u" /> 
4</FUNCTION>

Note in particular the use of the 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 FORCING block (as described in section 3.5):

1<FORCING> 
2    <FORCE TYPE="Body"> 
3        <BODYFORCE> BodyForce </BODYFORCE> 
4    </FORCE> 
5</FORCING>

An example of a simple unsteady reaction-diffusion problem can be found in the Tests directory in the session file ReactionDiffusion2D.xml.