3. Graph representation of physical domains
A physics-aware graph neural network begins with a modeling decision that is easy to underestimate: how to turn a discretized continuum or a contact interface into a graph. The choice of nodes, edges, and edge features determines what information the network can ever learn to propagate, and it constrains whether the resulting model respects conservation laws, boundary conditions, and contact kinematics. This section develops a principled construction of the graph from a physical domain, then shows how message passing operates over that graph for both volumetric continua and contact interfaces.
From Discretization to Graph Topology
Any numerical discretization already provides a natural graph. In a finite element mesh, each element centroid or each node can serve as a graph node, and shared element faces or edges define adjacency. In a particle or material-point method, particles are nodes and a radius-based neighborhood defines edges. In a finite volume grid, cell centers are nodes and face neighbors are edges. The key principle is that the graph should mirror the stencil over which the governing equations couple unknowns. If the discrete Laplacian couples a node to its six axis-aligned neighbors, the graph should contain exactly those edges; adding long-range edges injects information the physics does not support, while removing them destroys the stencil.
Node features typically encode the local state and geometry: position x_i, displacement u_i, velocity v_i, material parameters such as Young's modulus E_i and Poisson ratio nu_i, and boundary flags. Edge features encode the geometric relationship between neighbors: the reference vector r_ij = x_j - x_i, its current length, the unit direction, and — critically for continua — the undeformed length L_ij^0 so the network can compute strain measures. A common and effective choice is to store the normalized direction and the scalar stretch lambda_ij = |r_ij| / L_ij^0 as separate edge channels.
Message Passing as a Discrete Differential Operator
Message passing on such a graph is best understood as a learned, nonlinear generalization of a finite-difference stencil. At layer k, each edge computes a message from the source node state, the destination node state, and the edge feature:
m_ij^(k) = phi_e( h_i^(k), h_j^(k), e_ij )
h_i^(k+1) = phi_v( h_i^(k), sum_{j in N(i)} m_ij^(k) )
where phi_e and phi_v are small MLPs and N(i) is the neighbor set. The aggregation is a permutation-invariant sum, which is what makes the operator consistent with the unordered nature of a stencil. Two design choices carry most of the physical meaning. First, using relative quantities (differences of displacement, edge direction) rather than absolute positions enforces translation invariance. Second, restricting messages to functions of r_ij and its invariants enforces rotational equivariance, so a rotated body produces rotated outputs rather than spurious stresses.
For a linear elastic continuum, a single message-passing layer with a linear phi_e and sum aggregation reproduces a weighted graph Laplacian applied to displacement — precisely the discrete equilibrium operator. Stacking layers extends the receptive field, analogous to increasing the stencil radius, and allows the network to represent multi-scale coupling. This is why depth in a physics-aware GNN should be chosen with the same care as stencil width in a finite-difference scheme.
Contact Interfaces as a Distinct Edge Class
Contact is where the graph construction becomes genuinely physics-specific. A contact interface is not a bulk stencil: it couples nodes that are geometrically close but topologically separate, and the coupling is inequality-constrained — it activates only when the gap closes. The standard approach is to introduce a separate edge type, a contact edge, between a slave node on one body and its closest projection on the master surface. These edges carry features the bulk edges do not: the signed normal gap g_n, the tangential slip vector, the surface normal n, and a contact state flag.
Two implementation details matter. First, contact edges must be rebuilt or re-associated as bodies move, because the closest-point projection changes; a common strategy is to recompute candidate pairs every few steps and cache the projection in the reference configuration. Second, the message function on contact edges should be conditioned on the gap sign so that the network learns a one-sided response: zero traction for g_n > 0 and a stiffening response as g_n → 0. A practical way to enforce this is to multiply the contact message by a smooth activation sigma(-g_n / g_0) with a regularization length g_0, so the transition is differentiable and the network can be trained end-to-end.
A Concrete Construction Example
Consider two elastic blocks, each discretized with a 20×20 structured grid of nodes, pressed together along a horizontal interface. The graph is built as follows. Bulk edges connect each node to its four axis-aligned neighbors within the same body, with edge features [r_ij / L_ij^0, lambda_ij]. Contact edges are generated by projecting each node on the lower face of the upper block onto the upper face of the lower block; a pair is retained if the horizontal distance is below half the node spacing. Each contact edge stores [g_n, n, slip]. Node features are [u_x, u_y, E, nu, boundary_flag].
With this graph, a two-layer message-passing network with 64 hidden channels is trained against a finite element reference on a set of prescribed displacement load cases. The observable to check is the normal traction distribution along the interface: it should be approximately uniform under pure compression and should drop to zero, not go negative, when the blocks are pulled apart. If the predicted traction becomes tensile during separation, inspect the contact-edge activation — the gap sign convention or the g_0 value is usually the culprit. If the bulk response is too stiff or too soft, check whether L_ij^0 was stored in the reference configuration; using deformed lengths as the reference silently removes the strain measure.
The broader lesson is that the graph is a modeling artifact with physical consequences. Nodes carry state, edges carry geometry and constitutive relationships, and message passing is a learned differential operator whose invariances must be built in deliberately. Contact interfaces deserve their own edge class precisely because their physics — one-sided, gap-dependent, and geometrically evolving — differs from the bulk. Getting this structure right is what allows the network to generalize across load cases rather than memorize a single mesh.