3. Mapping mesh entities to graph elements

Once a finite element mesh has been parsed into a neutral in-memory representation, the next decision determines almost everything downstream: how do mesh entities become graph elements? A mesh is a collection of typed entities with incidence relations — nodes, edges, faces, cells — while a graph is a collection of vertices and edges (or hyperedges). The mapping is not unique, and the choice of strategy directly controls what a graph neural network (GNN) can learn, how much memory the dataset consumes, and whether the resulting model respects the physics encoded in the mesh.

This section examines the two dominant mapping families — node-to-vertex and element-to-edge/hyperedge — together with the hybrid patterns used in practice. The goal is to give you a decision framework grounded in concrete data structures, not abstract advice.

Node-to-vertex: the primal graph

In the node-to-vertex strategy, every mesh node becomes a graph vertex, and every mesh element induces edges between its nodes. For a first-order tetrahedral mesh, each tet contributes six undirected edges (all pairwise connections among its four nodes); for a hexahedral mesh, each hex contributes 28 edges (all pairs among eight nodes) if you use the clique expansion, or 12 edges if you connect only the topological element edges. These two variants are not equivalent, and the difference matters.

The clique expansion produces a dense local neighborhood: a hex node may see up to 26 neighbors, which gives a GNN rich local context but inflates edge count roughly by a factor of 2.3 relative to topological edges. The topological-edge variant preserves the mesh's actual edge topology and keeps the graph sparse, but a node's one-hop neighborhood then contains only its edge-adjacent peers, so information about face-diagonal or body-diagonal neighbors must propagate over multiple layers.

A practical construction in Python-like pseudocode, assuming a neutral mesh object with nodes (N×3 coordinates) and elements (connectivity lists):

import numpy as np

def node_to_vertex(mesh, mode="topological"):
    n_nodes = len(mesh.nodes)
    edges = set()
    for conn in mesh.elements:
        k = len(conn)
        if mode == "clique":
            for i in range(k):
                for j in range(i + 1, k):
                    edges.add((min(conn[i], conn[j]),
                               max(conn[i], conn[j])))
        else:  # topological: use element-local edge table
            for (a, b) in mesh.element_edges(conn):
                edges.add((min(a, b), max(a, b)))
    edge_index = np.array(sorted(edges)).T  # shape (2, E)
    x = mesh.nodes                        # node features
    return x, edge_index

Node features typically include coordinates, displacement or temperature values, boundary-condition flags, and material-region IDs. Because every node carries a feature vector, node-to-vertex is the natural choice when the prediction target is nodal — stress recovery at nodes, nodal temperature fields, or nodal displacement prediction.

Element-to-edge and element-to-hyperedge

The element-centric view treats each finite element as a graph entity. Two sub-strategies exist:

  • Element-to-edge (dual graph): each element becomes a vertex, and two elements are connected by an edge if they share a face (face-adjacency), an edge (edge-adjacency), or at least one node (node-adjacency). Face-adjacency is the most physically meaningful for solid mechanics because it corresponds to traction continuity across element boundaries.
  • Element-to-hyperedge: each element becomes a hyperedge connecting its constituent nodes. The resulting hypergraph preserves the exact incidence structure — a tet is a 4-uniform hyperedge, a hex an 8-uniform hyperedge — without the information loss of pairwise clique expansion.

The dual graph is compact: for a mesh with M elements, the vertex count is M rather than N, and face-adjacency edges number roughly 2M for a well-shaped tetrahedral mesh. Element features (centroid coordinates, volume, material ID, averaged stress) live on the dual vertices. This makes the dual graph attractive for element-wise classification tasks such as error estimation, material-region segmentation, or element-quality prediction.

Hypergraphs are the more faithful representation but require hypergraph neural network layers (e.g., HyperGCN or UniGNN-style message passing). The two-stage incidence — node-to-hyperedge and hyperedge-to-node — lets a hyperedge aggregate all its nodes before distributing information back, which is exactly the finite element assembly pattern. If your downstream model already implements hypergraph convolution, element-to-hyperedge avoids the artificial edges introduced by clique expansion.

A useful sanity check: for a single linear tetrahedron, the clique expansion adds six edges, but the element has only six topological edges — they coincide. The divergence appears at second-order elements and at hexahedra, where clique edges connect nodes that share no mesh edge. If your GNN's receptive field must match the element's stiffness-coupling pattern, prefer topological edges or hyperedges.

Choosing a strategy: a decision framework

The choice should be driven by three questions: What is the prediction target? What physics must the graph respect? What is the compute budget? The table below summarizes the trade-offs for a representative mesh of 50,000 nodes and 30,000 linear tetrahedra.

Strategy Vertices Edges / Hyperedges Best for Main risk
Node-to-vertex, topological 50,000 ~180,000 Nodal field prediction Slow long-range propagation
Node-to-vertex, clique 50,000 ~180,000 (tets) Rich local context Edge inflation on hex meshes
Element-to-edge (dual) 30,000 ~60,000 Element-wise classification Loses nodal detail
Element-to-hyperedge 50,000 nodes + 30,000 hyperedges 120,000 incidences Assembly-faithful learning Requires hypergraph layers

For linear tetrahedra the topological and clique edge counts coincide, which is why tet meshes are forgiving; the distinction becomes critical for quadratic elements and hexahedra. The counts above are illustrative estimates for the stated mesh size, not measured results.

Hybrid mapping and feature placement

Many production pipelines use a hybrid: a node-to-vertex graph for the GNN backbone, augmented with element-level attributes aggregated onto nodes (e.g., the volume-weighted average of incident element stresses). This keeps the graph sparse while injecting element information. The reverse hybrid — a dual graph whose vertex features include aggregated nodal quantities — is common for element-wise error estimators.

Feature placement deserves explicit attention. In node-to-vertex, node features are straightforward, but edge features (if your GNN supports them) can encode the mesh edge vector, its length, or the local material contrast. In the dual graph, edge features can encode the shared face area and normal, which is precisely the quantity appearing in flux continuity conditions. Encoding these geometric quantities as edge features often improves accuracy more than increasing model depth.

Validation of the mapping

Before training, verify the mapping with three checks. First, incidence consistency: every mesh element must appear in the graph exactly as intended — for hypergraphs, the sum of hyperedge degrees equals the total node incidences; for dual graphs, each interior face must yield exactly one dual edge. Second, connectivity: the graph should have one connected component per contiguous mesh region; isolated vertices usually indicate a parsing bug or a disconnected part. Third, symmetry and self-loop absence: remove duplicate edges and self-loops, and confirm that edge_index is symmetric for undirected graphs. A quick check in code:

assert edge_index.shape[0] == 2
assert not (edge_index[0] == edge_index[1]).any()   # no self-loops
pairs = set(map(tuple, edge_index.T.tolist()))
assert all((b, a) in pairs for (a, b) in pairs)      # symmetric

Typical failure symptoms are instructive: a dual graph with roughly half the expected edge count usually means face-adjacency was computed with a node-keyed dictionary that collapsed orientation; a node graph with unexpectedly high degree often signals clique expansion applied to a hex mesh when topological edges were intended. Catching these before training saves hours of debugging a model that learns from a structurally wrong graph.

Source mesh (2 tets sharing a face) n0 n1 n2 n3 n4 T0 = (n0,n1,n2,n3) T1 = (n1,n4,n2,n3) A. Node-to-vertex (primal graph) vertices = nodes edges = element-induced features on nodes B. Element-to-edge (dual graph) T0 T1 vertices = elements edge = shared face features on elements C. Element-to-hyperedge e0 (T0) e1 (T1) hyperedges = elements incidence = connectivity no clique inflation

The figure contrasts the three mappings on the same two-tetrahedron mesh. Note that in the dual graph the shared face (n1, n2, n3) becomes a single edge between T0 and T1, while in the hypergraph both elements remain distinct hyperedges that both contain n1, n2, and n3 — the incidence structure is preserved exactly. The node-to-vertex graph, by contrast, connects all node pairs within each element, so the shared face's three nodes form a triangle in the primal graph.

In summary, node-to-vertex is the default when nodal fields are the target and the mesh is tetrahedral; element-to-edge is the efficient choice for element-wise tasks; element-to-hyperedge is the faithful choice when the assembly pattern must be preserved and the model supports hypergraph layers. Whichever you choose, validate incidence counts, connectivity, and symmetry before training — the graph is the model's only view of the mesh, and a structural error there is invisible to the loss curve until it is expensive to fix.