Example files for the ADRSolver are provided in solvers/ADRSolver/Examples
to be completed
In this example, it will be demonstrated how the Helmholtz equation can be solved on a two-dimensional domain.
We consider the elliptic partial differential equation:
(7.2) |
where ∇2 is the Laplacian and λ is a real positive constant.
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>
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.
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
to be completed
to be completed
In this example, it will be demonstrated how the Advection equation can be solved on a one-dimensional domain.
We consider the hyperbolic partial differential equation:
(7.3) |
where a is the advection velocity.
The input for this example is given in the example file Advection1D_WeakDG_GLL_LAGRANGE.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<TIMEINTEGRATIONSCHEME> 2 <METHOD> RungeKutta </METHOD> 3 <ORDER> 4 </ORDER> 4</TIMEINTEGRATIONSCHEME> 5 6<SOLVERINFO> 7 <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvection" /> 8 <I PROPERTY="Projection" VALUE="DisContinuous" /> 9 <I PROPERTY="AdvectionType" VALUE="WeakDG" /> 10 <I PROPERTY="UpwindType" VALUE="Upwind" /> 11</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>
ADRSolver Advection1D_WeakDG_GLL_LAGRANGE.xml
To visualise the output, we can convert it into either Tecplot or VTK formats
FieldConvert Advection1D_WeakDG_GLL_LAGRANGE.xml Advection1D_WeakDG_GLL_LAGRANGE.fld Advection1D_WeakDG_GLL_LAGRANGE.dat FieldConvert Advection1D_WeakDG_GLL_LAGRANGE.xml Advection1D_WeakDG_GLL_LAGRANGE.fld Advection1D_WeakDG_GLL_LAGRANGE.vtu
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).
The governing equation for modelling mass transport is the unsteady advection diffusion equation:
+ a∇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) = , |
where z is the streamwise coordinate, R the pipe radius, Γ(4∕3) an incomplete Gamma function and Pe the Peclet number given by:
Pe = |
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.
The geometry under consideration is a pipe of radius, R = 0.5 and length l = 0.5
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<TIMEINTEGRATIONSCHEME> 2 <METHOD> IMEX </METHOD> 3 <ORDER> 1 </ORDER> 4</TIMEINTEGRATIONSCHEME> 5 6<SOLVERINFO> 7 <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvectionDiffusion" /> 8 <I PROPERTY="Projection" VALUE="Continuous" /> 9 <I PROPERTY="DiffusionAdvancement" VALUE="Implicit" /> 10 <I PROPERTY="AdvectionAdvancement" VALUE="Explicit" /> 11 <I PROPERTY="GlobalSysSoln" VALUE="IterativeStaticCond" /> 12</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>
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.
The ADRSolver supports the solution of a single-variable system
where the diffusion coefficient ϵ and the diagonal components of the anisotropic diffusion tensor D are defined using the session file.
The input for this example is given in the example file ImDiffusion_VarCoeff.xml
.
The two-dimensional geometry for this problem contains 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"> T[0-3] </C> 3 <C ID="1"> Q[4-5] </C> 4 <C ID="2"> E[2,7,4,9] </C> 5 <C ID="3"> E[0,1,10,11] </C> 6</COMPOSITE> 7 8<DOMAIN> C[0-1] </DOMAIN
For both the triangular and quadrilateral elements, we use the modified Legendre basis with 12 modes (maximum polynomial order is 11).
1<EXPANSIONS> 2 <E COMPOSITE="C[0]" NUMMODES="12" FIELDS="u" TYPE="MODIFIED" /> 3 <E COMPOSITE="C[1]" NUMMODES="12" FIELDS="u" TYPE="MODIFIED" /> 4</EXPANSIONS>
The Continuous Galerkin Method is used as projection scheme along with a third-order DIRK scheme to solve the diffusion equation, so we need to specify the following time-integration scheme and solver information.
1<TIMEINTEGRATIONSCHEME> 2 <METHOD> DIRK </METHOD> 3 <ORDER> 3 </ORDER> 4</TIMEINTEGRATIONSCHEME> 5 6<SOLVERINFO> 7 <I PROPERTY="EQTYPE" VALUE="UnsteadyDiffusion" /> 8 <I PROPERTY="Projection" VALUE="Continuous" /> 9 <I PROPERTY="DiffusionAdvancement" VALUE="Implicit" /> 10</SOLVERINFO>
For information, while the ADRSolver support both Continuous Galerkin and DisContinuous Galerkin projections with implicit time-integration, only the DisContinuous Galerkin projection is supported when using an explicit time-integration method for the unsteady diffusion problem.
We solve this unsteady problem by considering 200 time units with a time-step of 0.0001 along
with an anisotropic diffusion coefficients d00
and d11
of 0.5 and 2.0, respectively. Please note
that if one only desires to consider isotropic diffusion, the parameters d00
and d11
are not
required.
1<PARAMETERS> 2 <P> TimeStep = 0.0001 </P> 3 <P> NumSteps = 200 </P> 4 <P> FinTime = TimeStep*NumSteps</P> 5 <P> wavefreq = PI </P> 6 <P> epsilon = 1.0 </P> 7 <P> d00 = 0.5 </P> 8 <P> d11 = 2.0 </P> 9</PARAMETERS>
Both Dirichlet and Neumann boundary conditions are used to specify this problem.
1<BOUNDARYREGIONS> 2 <B ID="0"> C[2] </B> 3 <B ID="1"> C[3] </B> 4</BOUNDARYREGIONS> 5 6<BOUNDARYCONDITIONS> 7 <REGION REF="0"> 8 <D VAR="u" VALUE="0" /> 9 </REGION> 10 <REGION REF="1"> 11 <N VAR="u" VALUE="0" /> 12 </REGION> 13</BOUNDARYCONDITIONS
For this problem, we use the following initial condition
1<FUNCTION NAME="InitialConditions"> 2 <E VAR="u" VALUE="sin(wavefreq*x)*cos(wavefreq*y)" /> 3</FUNCTION>
ADRSolver ImDiffusion_VarCoeff.xml
To visualise the output, we can convert it into either Tecplot or VTK formats
FieldConvert ImDiffusion_VarCoeff.xml ImDiffusion_VarCoeff.fld ImDiffusion_VarCoeff.dat FieldConvert ImDiffusion_VarCoeff.xml ImDiffusion_VarCoeff.fld ImDiffusion_VarCoeff.vtu
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
where the diffusion coefficient ϵ, the diagonal components of the anisotropic diffusion tensor D, and reaction term R(u) are defined using the session file.
The input for this example is given in the example file ReactionDiffusion2D.xml
.
The geometry section defines a 2D domain consisting of 64 quadrilateral elements.
1<COMPOSITE> 2 <C ID="0"> Q[0-63] </C> 3 <C ID="1"> E[0,25,42,59,76,93,110,127] </C> 4 <C ID="2"> E[128,130,132,134,136,138,140,142] </C> 5 <C ID="3"> E[23,41,58,75,92,109,126,143] </C> 6 <C ID="4"> E[3,6,9,12,15,18,21,24] </C> 7</COMPOSITE> 8<DOMAIN> C[0] </DOMAIN>
For this example, we use the modified Legendre basis with 6 modes.
1<EXPANSIONS> 2 <E COMPOSITE="C[0]" NUMMODES="6" TYPE="MODIFIED" FIELDS="u" /> 3</EXPANSIONS>
We choose to solve our solution for 100 time units with a time-step of 0.001 and a diffusion
coefficient epsilon
of 0.2
1<P> TimeStep = 0.001 </P> 2<P> NumSteps = 100 </P> 3<P> epsilon = 0.2 </P>
The following TIMEINTEGRATIONSCHEME
and SOLVERINFO
configuration is used:
1<TIMEINTEGRATIONSCHEME> 2 <METHOD> IMEX </METHOD> 3 <ORDER> 3 </ORDER> 4</TIMEINTEGRATIONSCHEME> 5 6<SOLVERINFO> 7 <I PROPERTY="EQTYPE" VALUE="UnsteadyReactionDiffusion" /> 8 <I PROPERTY="Projection" VALUE="Continuous" /> 9 <I PROPERTY="DiffusionAdvancement" VALUE="Implicit" /> 10</SOLVERINFO>
Periodic boundary conditions are used
1<BOUNDARYCONDITIONS> 2 <REGION REF="0"> 3 <P VAR="u" VALUE="[2]" /> 4 </REGION> 5 <REGION REF="1"> 6 <P VAR="u" VALUE="[3]" /> 7 </REGION> 8 <REGION REF="2"> 9 <P VAR="u" VALUE="[0]" /> 10 </REGION> 11 <REGION REF="3"> 12 <P VAR="u" VALUE="[1]" /> 13 </REGION> 14</BOUNDARYCONDITIONS>
Further to this, the reaction term R(u) is imposed by the definition of a body forcing
function by first specifying an appropriate FORCING
block (as described in section 3.6):
1<FORCING> 2 <FORCE TYPE="Body"> 3 <BODYFORCE> BodyForce </BODYFORCE> 4 </FORCE> 5</FORCING>
The reaction term can then 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.
ADRSolver ReactionDiffusion2D.xml
To visualise the output, we can convert it into either Tecplot or VTK formats
FieldConvert ReactionDiffusion2D.xml ReactionDiffusion2D.fld ReactionDiffusion2D.dat FieldConvert ReactionDiffusion2D.xml ReactionDiffusion2D.fld ReactionDiffusion2D.vtu
to be completed
to be completed