Skip to content

Mesh

GUERNICA is built on top of MFEM and inherits its meshing infrastructure. In practice, this means that any mesh format supported by MFEM can also be used by GUERNICA. More information on MFEM mesh formats can be found in the MFEM mesh format documentation.

At present, GUERNICA supports 2D quadrilateral meshes only, with straight-sided (first-order) elements.

Location and usage

Meshes live in the mesh/ directory.

The mesh used for a simulation is set in the input file under [grid], as a path relative to the directory GUERNICA is run from:

[grid]
mesh_file = mesh/<name>

A copy of the mesh in MFEM .mesh format is saved to the output directory for each run with the name ex9.mesh.

MFEM .mesh structure

MFEM .mesh files are split into five sections:

  • dimension
  • elements
  • boundary
  • vertices
  • nodes

Each section is described below in the context of GUERNICA.

dimension

For GUERNICA, the dimension must currently be:

dimension
2

Only 2D meshes are supported.

elements

The elements section first lists the number of elements.

Each element is then defined as:

<attribute> <geometry type> <vertex 0> <vertex 1> <vertex 2> <vertex 3>

For GUERNICA, these must be quadrilateral elements (geometry type 3). The vertices should be listed starting at one corner and then proceeding anti-clockwise around the quad.

Element attributes are used to mark regions, for example plasma and vacuum regions for [plasma_interface] (see Boundary Conditions).

boundary

The boundary section first lists the number of non-periodic boundary faces.

Each boundary face is then defined as:

<attribute> <geometry type> <vertex 0> <vertex 1>

The ordering of boundary vertices should stay consistent throughout the entire mesh. For example, if one boundary edge is defined anti-clockwise, all boundary edges should follow that same convention.

Boundary attributes are used to assign boundary conditions in the input file through:

[components]
boundaries = <name>

[boundary:<name>]
attrs = <attribute list>
type = <type>

Boundary attributes that are not assigned to any [boundary:<name>] section are treated as absorbing.

vertices

The vertices section lists the number of unique vertices.

nodes

The nodes section starts with:

nodes
FiniteElementSpace
FiniteElementCollection: H1_2D_P1
VDim: 2
Ordering: 1

The FiniteElementCollection can be either:

  • H1_2D_P1
  • L2_T1_2D_P1

L2_T1_2D_P1

L2_T1_2D_P1 must be used when dealing with periodic boundary conditions.

It can still be used even without any periodic boundary conditions, but this is not recommended, since H1_2D_P1 is a little more straightforward.

Periodic boundary conditions are not handled explicitly by GUERNICA, so they are not defined in the boundary section of either the mesh or the input file. Instead, they are handled implicitly in the mesh by using shared vertices.

For L2_T1_2D_P1, the nodes are listed in groups of 4 for each element:

  1. one starting vertex,
  2. the two vertices connected to that first vertex,
  3. the final vertex, which is the one not connected directly to the first vertex.

H1_2D_P1

H1_2D_P1 cannot be used when periodic boundary conditions are desired.

It should be used when there are no periodic boundary conditions.

For H1_2D_P1, the nodes are listed in accordance with their numbering as defined in the elements and boundary sections. That is, node 0 goes first, followed by node 1, followed by node 2, and so on.

Practical notes

  • GUERNICA currently supports only 2D quad meshes.
  • Meshes live in mesh/.
  • The simulation mesh is set through [grid] mesh_file = mesh/<name>.
  • A copy of the mesh is written to the output directory as ex9.mesh.
  • Boundary attributes are used to assign boundary conditions in the input file.
  • H1_2D_P1 should be used for non-periodic meshes.
  • L2_T1_2D_P1 must be used for periodic meshes.

Gmsh meshes

MFEM reads Gmsh .msh files directly, so realistic geometries (for example the MAST-U meshes in mesh/) are generated with Gmsh and passed to mesh_file as is. A few points matter:

  • Save the mesh in ASCII format 2.2 (gmsh -2 -format msh22 file.geo, or Mesh.MshFileVersion = 2.2; in the .geo file).
  • Elements must be quadrilaterals. Recombine the triangulation into quads, for example with Mesh.RecombineAll = 1;, and keep Mesh.ElementOrder = 1.
  • Physical groups become MFEM attributes. A Physical Curve(k) sets boundary attribute k, which is referenced by attrs in [boundary:<name>]. A Physical Surface(k) sets element attribute k, which is used for example by [plasma_interface]. Only elements and boundary edges that belong to a physical group are written, so every surface and every wall curve should be in one.

Examples of .geo files are in mesh/. Since GUERNICA writes the mesh it actually used to ex9.mesh in the run directory (in MFEM format), scripts/plot_mesh_regions.py can be run on that file to check the element and boundary attributes.