1.4 Configuring the expansion bases and the conditions

To set the various parameters, the solver settings and the initial and boundary conditions needed, we create a new file called ADR_conditions.xml, which can be found within the resources provided for this tutorial. This new file contains the CONDITIONS tag where we can specify the parameters of the simulations, the solver settings, the initial conditions, the boundary conditions and the exact solution and contains the EXPANSIONS tag where we can specify the polynomial order to be used inside each element of the mesh, the type of expansion bases and the type of points.

We begin to describe the ADR_conditions.xml file from the CONDITIONS tag, and in particular from the boundary conditions, initial conditions and exact solution sections:

1<CONDITIONS> 
2   ... 
3   ... 
4   ... 
5   <VARIABLES> 
6      <V ID="0"> u </V> 
7   </VARIABLES> 
8 
9   <BOUNDARYREGIONS> 
10      <B ID="0"> C[100] </B> 
11      <B ID="1"> C[200] </B> 
12      <B ID="2"> C[300] </B> 
13      <B ID="3"> C[400] </B> 
14   </BOUNDARYREGIONS> 
15 
16   <BOUNDARYCONDITIONS> 
17      <REGION REF="0"> 
18         <D VAR="u" USERDEFINEDTYPE="TimeDependent" 
19         VALUE="sin(k∗(x−advx∗t))∗cos(k∗(y−advy∗t))" /> 
20      </REGION> 
21      <REGION REF="1"> 
22         <P VAR="u" VALUE="[3]" /> 
23      </REGION> 
24      <REGION REF="2"> 
25         <D VAR="u" USERDEFINEDTYPE="TimeDependent" 
26         VALUE="sin(k∗(x−advx∗t))∗cos(k∗(y−advy∗t))" /> 
27      </REGION> 
28      <REGION REF="3"> 
29         <P VAR="u" VALUE="[1]" /> 
30      </REGION> 
31   </BOUNDARYCONDITIONS> 
32 
33   <FUNCTION NAME="InitialConditions"> 
34      <E VAR="u" VALUE="sin(k∗x)∗cos(k∗y)" /> 
35   </FUNCTION> 
36 
37   <FUNCTION NAME="AdvectionVelocity"> 
38      <E VAR="Vx" VALUE="advx" /> 
39      <E VAR="Vy" VALUE="advy" /> 
40   </FUNCTION> 
41 
42   <FUNCTION NAME="ExactSolution"> 
43      <E VAR="u" VALUE="sin(k∗(x−advx∗t))∗cos(k∗(y−advy∗t))" /> 
44   </FUNCTION> 
45</CONDITIONS>

In the above piece of .xml, we first need to specify the non-optional tag called VARIABLES that sets the solution variable (in this case u).

The second tag that needs to be specified is BOUNDARYREGIONS through which the user can specify the regions where to apply the boundary conditions. For instance, <B ID="0"> C[100] </B> indicates that composite 100 (which has been introduced in section 1.3) has a boundary ID equal to 0. This boundary ID is successively used to prescribe the boundary conditions.

The third tag is BOUNDARYCONDITIONS by which the boundary conditions are actually specified for each boundary ID specified in the BOUNDARYREGIONS tag. The syntax <D VAR="u" corresponds to a Dirichlet boundary condition for the variable u (note that in this case we used the additional tag USERDEFINEDTYPE="TimeDependent" which is a special option when using time-dependent boundary conditions), while <P VAR="u" corresponds to Periodic boundary conditions. For additional details on the various options possible in terms of boundary conditions refer to the User-Guide.

Finally, <FUNCTION NAME="InitialConditions"> allows the specification of the initial conditions, <FUNCTION NAME="AdvectionVelocity"> specifies the advection velocities in both the x- and y-direction (for this two-dimensional case) and is a non-optional parameters for the unsteady advection equation and <FUNCTION NAME="ExactSolution"> permits us to provide the exact solution, against which the L2 and L errors are computed.

After having configured the VARIABLES tag, the initial and boundary conditions, the advection velocity and the exact solution we can complete the tag CONDITIONS prescribing the parameters necessary (PARAMETERS)and the solver settings (SOLVERINFO):

1<CONDITIONS> 
2   <PARAMETERS> 
3      <P> FinTime = 1.0 </P> 
4      <P> TimeStep = 0.001 </P> 
5      <P> NumSteps = FinTime/TimeStep </P> 
6      <P> IO_CheckSteps = 100 </P> 
7      <P> IO_InfoSteps = 100 </P> 
8      <P> advx = 2.0 </P> 
9      <P> advy = 0.0 </P> 
10      <P> k = 2∗PI </P> 
11   </PARAMETERS> 
12 
13   <SOLVERINFO> 
14      <I PROPERTY="EQTYPE" VALUE="UnsteadyAdvection" /> 
15      <I PROPERTY="Projection" VALUE="DisContinuous" /> 
16      <I PROPERTY="AdvectionType" VALUE="WeakDG" /> 
17      <I PROPERTY="UpwindType" VALUE="Upwind" /> 
18      <I PROPERTY="TimeIntegrationMethod" VALUE="ClassicalRungeKutta4"/> 
19   </SOLVERINFO> 
20   ... 
21   ... 
22   ...

In the PARAMETERS tag, FinTime is the final physical time of the simulation, TimeStep is the time-step, NumSteps is the number of steps, IO_CheckSteps is the step-interval when a output file is written, IO_InfoSteps is the step-interval when some information about the simulation are printed to the screen, advx and advy are the advection velocities Vx and Vy, respectively and k is the κ parameter. Note that advx, advy and k are used in the boundary and initial conditions tags as well as in the specification of the advection velocities.

In the SOLVERINFO tag, EQTYPE is the type of equation to be solved, Projection is the spatial projection operator to be used (which in this case is specified to be ‘DisContinuous’), AdvectionType is the advection operator to be adopted (where the VALUE ‘WeakDG’ implies the use of a weak Discontinuous Galerkin technique), UpwindType is the numerical flux to be used at the element interfaces when a discontinuous projection is used, TimeIntegrationMethod allows selecting the time-integration scheme. For additional solver-setting options refer to the User-Guide.

Finally, we need to specify the expansion bases we want to use in each of the three composites or sub-domains (COMPOSITE="..") introduced in section 1.3:

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

In particular, for all the composites, COMPOSITE="C[i]" with i=1,2,3 we select identical basis functions and polynomial order, where NUMMODES is the number of coefficients we want to use for the basis functions (that is commonly equal to P+1 where P is the polynomial order of the basis functions), TYPE allows selecting the basis functions FIELDS is the solution variable of our problem and COMPOSITE are the mesh regions created by Gmsh. For additional details on the EXPANSIONS tag refer to the User-Guide.