1.3 Pre-processing

The pre-processing step consists in generating the mesh in a Nektar++ compatible format. For doing so we can first use the open-source mesh-generator Gmsh to first create the geometry, that in our case is a square and successively the mesh. The mesh format provided by Gmsh shown in Fig. (1.1) - i.e. .msh extension - is not compatible with the Nektar++ solvers and, therefore, it needs to be converted.


pict

Figure 1.1: Mesh generated by Gmsh.


To do so, we need to run the pre-processing routine called MeshConvert within Nektar++. This routine requires two line arguments, the mesh file generated by Gmsh, ADR_mesh.msh, and the name of the Nektar++-compatible mesh file that MeshConvert will generate, for instance ADR_mesh.xml. The command line for this step is

nektar++/builds/utilities/MeshConvert/MeshConvert \ 
    ADR_mesh.msh  ADR_mesh.xml

The generated .xml mesh file is reported below. It contains 5 tags encapsulated within the GEOMETRY tag, which describes the mesh. The first tag, VERTEX, contains the spatial coordinates of the vertices of the various elements of the mesh. The second tag, EDGE contains the lines connecting the vertices. The third tag, ELEMENT, defines the elements (note that in this case we have both triangular - e.g. <T ID="0"> - as well as quadrilateral - e.g. <Q ID="85"> - elements). The fourth tag, COMPOSITE, is constituted by the physical regions of the mesh called composite, where the composites formed by elements represent the solution sub-domains - i.e. the mesh sub-domains where we want to solve the linear advection problem (note that we will use these composites to define expansion bases on each sub-domain in section 1.4) - while the composites formed by edges are the boundaries of the domain where we need to apply suitable boundary conditions (note that we will use these composites to specify the boundary conditions in section 1.4). Finally, the fifth tag, DOMAIN, formally specifies the overall solution domain as the union of the three composites forming the three solution subdomains (note that the specification of three subdomain - i.e. composites - in this case is necessary since they are constituted by different element shapes). For additional details on the GEOMETRY tag refer to the User-Guide.

1<?xml version="1.0" encoding="utf−8" ?> 
2<NEKTAR> 
3   <GEOMETRY DIM="2" SPACE="2"> 
4      <VERTEX> 
5         <V ID="0">2.00000000e−01 −1.00000000e+00 0.00000000e+00</V> 
6         <V ID="1">5.09667784e−01 −6.15240515e−01 0.00000000e+00</V> 
7         ... 
8         <V ID="68">−1.00000000e+00 1.25000000e−01 0.00000000e+00</V> 
9      </VERTEX> 
10      <EDGE> 
11         <E ID="0"> 0 1 </E> 
12         <E ID="1"> 1 2 </E> 
13         ... 
14         <E ID="153"> 40 68 </E> 
15      </EDGE> 
16      <ELEMENT> 
17         <T ID="0"> 0 1 2 </T> 
18         <T ID="1"> 3 4 5 </T> 
19         ... 
20         <Q ID="85"> 146 93 153 151 </Q> 
21     </ELEMENT> 
22      <COMPOSITE> 
23         <C ID="1"> T[0−30] </C> 
24         <C ID="2"> Q[62−85] </C> 
25         <C ID="3"> T[31−61] </C> 
26         <C ID="100"> E[46,12,20,10,45] </C> 
27         <C ID="200"> E[50,32,108,111,114,117,87,103] </C> 
28         <C ID="300"> E[100,64,74,66,99] </C> 
29         <C ID="400"> E[49,33,148,150,152−153,86,104] </C> 
30      </COMPOSITE> 
31      <DOMAIN> C[1,2,3] </DOMAIN> 
32   </GEOMETRY> 
33</NEKTAR>

After having generated the mesh file in a Nektar++-compatible format, ADR_mesh.xml, we can visualise the Jacobian distribution across the mesh in order to evaluate its quality. This step can be done by using the following Nektar++ built-in post-processing routine:

nektar++/builds/utilities/XmlToVtk -j ADR_mesh.xml

where the optional command -j calculate the Jacobian distribution for each element of the mesh. This will produce a ADR_mesh.vtu file which can be directly read by the open-source visualisation tool called Paraview. In Fig. 1.2 we show the Jacobian distribution for the mesh considered in this tutorial, ADR_mesh.xml.


PIC

Figure 1.2: Jacobian distribution.


Before configuring the input files, if we want to use periodic boundary conditions, we need to make sure that the edges of the two periodic boundaries (i.e. xb = [−1,1],yb) are properly aligned. Gmsh and the MeshConvert routine within Nektar++ does not guarantee proper alignment. However, MeshConvert provides a module, called peralign, that enforces the reordering of pair of edges (for more details refer to the User-Guide. We can apply this by using the following command:

nektar++/builds/utilities/MeshConvert/MeshConvert \ 
-m peralign:surf1=200:surf2=400:dir=x ADR_mesh.xml ADR_mesh_aligned.xml

where -m peralign is selecting the module for aligning the edges which are specified by surf1 and surf2 (their IDs in this case are 200 and 400) and dir is the direction to which the two periodic edges are perpendicular (in this case x).

After having typed the last command, we have a mesh, ADR_mesh_aligned.xml, which is fully compatible with Nektar++ and which allows us applying periodic boundary conditions without encountering errors.

We can therefore now configure the conditions: initial conditions, boundary conditions, parameters and solver settings.