# Structured Mesh Specificities

This page describes how to use special tools dedicated to Structured Meshes and the internal mesh extrusion to create such a structured mesh within a simulation. Examples using some of these features can be found in the course material of Edmonton in April 2013.

The different tools available within Elmer to create and/or work with Structured Meshes are presented below. More information can also be find in the Elmer documentation.

### Internal Mesh Extrusion

Starting from a 2D-footprint mesh of your favourite glacier, this footprint can be vertically extruded by specifying the number of vertical layers directly in the Simulation section:

```Simulation
...
Extruded Mesh Levels = Integer 20
Extruded Mesh Name = String my_extruded_mesh
...
End```

The second line is optional, and if included will cause Elmer to write the extruded mesh into the directory called my_extruded_mesh (or whatever you wish to call it, but note that this directory must exist prior to running Elmer, and that this functionality has so far been tested only in serial).

By default the mesh levels are evenly distributed in [0,1]. A geometric divisions can be specified by the keyword

```  Extruded Mesh Levels = Integer 20
Extruded Mesh Ratio = Real 0.25```

More complex distributions can be obtained with the density function (see material SVALI course Nov 2014) for example

```Extruded Mesh Density = Variable Coordinate 1
Real MATC "1+0.1*tx"```

where “Coordinate 1” is a dummy variable since only the function for the density distribution is used. The density function is a rel. height, so that a layer with density(i) has the height `height(i)=total_height*density(i)/sum_k(density(k).`

The functionality leaves the z-coordinate of the 3D mesh in [0,1]. The StructuredMeshMapper solver presented below allows to map the bottom and top surfaces.

Boundary conditions for the bottom and top surfaces are automatically created by the internal mesh extrusion. These boundaries are implicitly ordered (first for the bottom and then the top surface) in the sif file, and should be placed just after the boundaries having a number in the 2D-footprint mesh (the lateral boundaries). In case the 2D-footprint mesh has more than one body, a bottom and a top boundaries are created for each of these bodies.
Note: “Target Boundaries” must not be given in the bottom and top boundary sections in the sif-file, however they need to be Boundary Condition number i+1 and i+2 (i being the last lateral boundary of the 2D-footprint mesh).

##### Preserving footprint boundary labeling
```Preserve Baseline = Logical True
Preserve Edges = Logical True```

The “Preserve Baseline” allows the 1D boundary of the footprint to be used to prescribe boundary conditions to solvers run on this footprint (e.g. the GlaDs hydrology model). If the footprint has n boundary labels, the side wall boundaries after extrusion will be labeled from n+1 to 2n and the lower and upper surfaces after extrusion will be boundary conditions 2n+1 and 2n+2.

Note that if edge boundaries at the edge of the footprint are grouped together in the .sif, the same groupings must be applied to the wall boundaries directly above them.

Elmer stores information about edges in addition to element information. This information is not preserved by default through mesh extrusion. To ensure its preservation (this is strictly required if running GlaDs) use the “Preserve Edges” option.

### StructuredMeshMapper Solver

This solver is for mapping the mesh between given top and bottom surfaces. This solver assumes that the mesh is structural so that it could have been obtained by extrusion in the direction of interest. For the given direction the corresponding top and bottom node is computed for every node and this information is used to perform linear mapping in between. Contrary to the internal mesh extrusion feature presented previously, the StructuredMeshMapper Solver works in 2D and 3D. The direction of interest is specified by the keyword Active Coordinate, and the coordinate in the direction of interest of the initial mesh must be in [0,1]. This solver has to be executed before all other solver needing the correct node mapping.

```Solver 1
Equation = "MapCoordinate"
Procedure = "StructuredMeshMapper" "StructuredMeshMapper"

Active Coordinate = Integer 3
Mesh Velocity Variable = String "dSdt 3"
Mesh Update Variable = String "dS"
Mesh Velocity First Zero = Logical True
Mapped Mesh Name = String my_mapped_mesh
End```

There are three modes to define the Top Surface (same for the bottom, not shown here):

• Mode 1 assumes a flat surface given by the keyword Top Surface Level = Real in the Solver section
• Mode 2 is for prognostic simulations where the top free surface evolution is computed. In that case, the Top Surface is defined to be the variable for the top free surface, using the keyword Top Surface Variable Name = String “Zs Top” (for example) in the Solver section.
• Mode 3 defines the Top Surface from the keyword Top Surface = Real in the boundary condition corresponding to the top surface. The keyword Top Surface can be a variable of (x,y) for example to define a non-uniform top surface elevation. Typically, using NetCDF input data, the GridDataReader solver can be used for this purpose.

The last line is optional, and if included will cause Elmer to write the mapped mesh into the directory called my_mapped_mesh (or whatever you wish to call it, but note that this directory must exist prior to running Elmer, and that this functionality has so far been tested only in serial). The mesh will be written once only at the end of the first call to the structured mesh mapper.

Note: “Minimum Mesh Height” as keyword in the Solver in the sif-file is only checking for a minimum mesh height, but not imposing it. It has to be made sure (for example with a MATC function) elsewhere that the Top Surface always remains above the Bottom Surface.
Note: Exported Variable 1 = -DOFs 3 dSdt is needed in some Solver as well as the dimension of dSdt in the line Mesh Velocity Variable. Depending on the setup, it might also be necessary to set dSdt 1 (and 2) to zero.

### StructuredProjectToPlane Solver

This solver allows to perform some operations that are easier when the mesh is structured, as for example to compute the height or depth within the volume.

```Solver 1
Equation = "HeightDepth"
Procedure = "StructuredProjectToPlane" "StructuredProjectToPlane"
Active Coordinate = Integer 3

Operator 1 = depth
Operator 2 = height
End```

Other operations can be performed and more information can be found in the Elmer documentation (see models manual, sections 55 and 56 as of Jan 2016).