Strain Recovery — Weighted SPR-C

Implemented in: results_strain_recovery.py — compute_nodal_strain()

1. The Strain Recovery Problem in Meshfree Analysis

In the MLPG5 method, the displacement field is approximated by MLS shape functions, which are smooth (Ck, k ≥ 1) over the domain. Nodal strain can be computed by direct differentiation:

εxx = ∂ux/∂x = ∂φJ/∂x ⋅ ux,J,    εyy = ∂uy/∂y,    γxy = ∂ux/∂y + ∂uy/∂x

However, direct MLS differentiation at nodal positions is less accurate than at interior integration points, because nodal positions lie at the edge of — or outside — the quadrature region. The standard engineering remedy is Superconvergent Patch Recovery (SPR), which exploits the higher accuracy of integration-point strains to reconstruct a smooth, superconvergent nodal strain field.

GearMaster implements a variant called Weighted SPR with Constraints (SPR-C), adapted for meshfree analysis. For free boundary nodes, an additional traction-free constraint σ⋅n = 0 is enforced via a KKT system, which is the "C" (Constrained) extension to standard SPR (Zienkiewicz & Zhu, 1992b).

2. Three-Stage Algorithm

Stage 1 — Strain Sampling Points (Delaunay Gauss points or legacy grid)

The strain samples are taken at Gauss points. Two sources exist, selected by the solver setting recovery_sampling (Analysis Settings → Results post-processing):

Validation. On the weld-joint case (ANSYS von Mises at 1.1×103 nodes, nodes within 1.5 mm of any corner excluded) the normalised RMS error of the von Mises stress with a spacing floor of 0.2 is 0.06–0.07 with Delaunay sampling against 0.37–0.88 with the regular grid.

(Legacy description of the grid:) cell size = median nearest-neighbour distance hmed, covering the node bounding box. In each cell, ngauss2 Gauss points are placed.

At each Gauss point xg, the MLS shape function derivatives ∂φJ/∂x and ∂φJ/∂y are evaluated, and strain is computed:

ε(xg) = [∑J ∂φJ/∂x ⋅ ux,J,  ∑J ∂φJ/∂y ⋅ uy,J,  ∑J (∂φJ/∂y ⋅ ux,J + ∂φJ/∂x ⋅ uy,J)]

For non-convex domains (when domain_polygon is available), Gauss points outside the domain polygon are skipped using matplotlib.path.Path.contains_points(). This prevents spurious strain samples in void regions (e.g. the corner of an L-shaped geometry).

Stage 2 — Local Patch Assembly for Each Node

For each node i, all Gauss-point strain samples within a local patch of radius rsupp,i are gathered via cKDTree. If fewer than 6 samples are found, the search radius is progressively widened (1.5×, then 2× the support radius). If still fewer than 3 samples remain, a direct MLS differentiation fallback is used.

The local polynomial basis is chosen adaptively:

Number of samplesPolynomialTerms (n_poly)
≥ 6Quadratic: [1, Δx, Δy, Δx2, ΔxΔy, Δy2]6
3 – 5Linear: [1, Δx, Δy]3
< 3Direct MLS differentiation (fallback)—

Coordinates are shifted to the node position: Δx = xg − xi, Δy = yg − yi. The polynomial value at node i is therefore the constant term a0 (only the intercept survives when Δx = Δy = 0).

Stage 3 — Weighted Least-Squares and SPR-C Constraints

Distance weights are computed with a Gaussian kernel centred at node i:

wg = exp(− dg2 / rsupp,i2)

where dg = |xg − xi|. Integration-point strains close to node i receive higher weight.

Case A — Interior and Fixed-Support Nodes: Unconstrained Weighted LS

For each strain component c ∈ {εxx, εyy, γxy}, the weighted least-squares problem is:

minac ∑g wg (Ag ac − εc,g)2  ⇒  (ATWA) ac = ATW εc

Solved via numpy.linalg.lstsq. The nodal strain is the constant term: εc,i = a0,c.

Case B — Free Boundary Nodes: SPR-C with Traction Constraints

On a free (Neumann) boundary edge, the physical traction must satisfy:

t = NT σ = NT D ε = 0

where NT = [nx, 0, ny; 0, ny, nx] is the traction-normal matrix. Since the polynomial is centred at node i, the traction constraint acts only on the constant terms [a0,εxx, a0,εyy, a0,γxy]:

T [a0,εxx, a0,εyy, a0,γxy]T = 0,     T = NTDi ∈ ℜ2×3

All three strain components are solved simultaneously via a block KKT system of size 3 npoly + 2:

[ATWA (block-diag 3×)   CT;   C   0] ⋅ [aεxx; aεyy; aγxy; λ] = [ATW εxx; ATW εyy; ATW γxy; 0]

where Ceq, c⋅npoly+0 = Teq,c encodes that the constraint acts on the intercept of each component. The KKT system is solved with numpy.linalg.solve; if it is singular (degenerate geometry), the code falls back to unconstrained weighted LS.

Free vs. fixed boundary: Fixed-support nodes (belonging to a GM_Joint) are excluded from SPR-C traction constraints: they are Dirichlet boundaries where t = 0 is not the correct physical condition. The fixed_dof_mask array distinguishes the two boundary types.

3. Crack-Aware Strain Recovery

When a crack propagation analysis is active, the standard SPR-C procedure above must be modified to prevent the MLS gradient fit from sampling displacement values on the far side of the crack. Without this filter, the apparent displacement jump across the open gap produces a spurious, growing stress field at crack-isolated nodes (see Fracture — Section 4.5 for physical motivation).

The function compute_nodal_strain() accepts an optional crack_visibility parameter (a BrokenEdgeConnectivity object). When provided, the algorithm inserts two additional filters:

Filter 1 — Gauss-point stage (Stage 2)

Before evaluating MLS shape function derivatives at Gauss point xg, the candidate support node set is filtered via:

candidates ← crack_visibility.filter_support_from_point(xg, candidates)

This removes any support node J for which the segment xg → nodes[J] crosses a broken Voronoi ridge. If fewer than min_supp visible nodes remain (3 for linear basis, 6 for quadratic), the Gauss point is skipped and contributes no samples to any node patch.

Filter 2 — Node recovery stage (Stage 3)

After gathering all Gauss-point samples within the patch of node i, each sample is tested individually:

if crack_visibility.segment_crosses_crack(nodes[i], xg): discard sample

If fewer than min_supp samples survive, node i is classified as crack-isolated and its strain is set to zero:

strain[i] = 0      (crack-isolated node fallback)
Backward compatibility: when crack_visibility=None (no crack), both filters are completely absent and the function produces byte-for-byte identical results to the original implementation.
Performance: both filter_support_from_point and segment_crosses_crack use the spatially cached broken-ridge KD-tree described in the Fracture reference, so their cost is bounded regardless of how many edges have been broken. The additional overhead per Gauss point is typically negligible compared to the MLS shape-function evaluation.

4. Full Algorithm Summary

compute_nodal_strain() — Full Algorithm

  1. Build the sampling points (Delaunay Gauss points, or the legacy background grid with cell size = hmed).
  2. For each Gauss point in each cell:
    • If domain_polygon given, skip if outside polygon.
    • (Crack-aware) If crack_visibility given, filter candidate support nodes via filter_support_from_point(x_g, candidates); skip Gauss point if < min_supp nodes remain visible.
    • Evaluate MLS derivatives → compute εg.
    • Store (xg, εg) in lists.
  3. Build cKDTree of all Gauss-point coordinates.
  4. For each node i:
    1. Query Gauss points within rsupp,i (widen if <6 or <3).
    2. (Crack-aware) If crack_visibility given, discard samples where segment_crosses_crack(nodes[i], x_g) is True; if < min_supp survive → strain[i] = 0, skip to next node.
    3. Choose polynomial degree (quadratic if ≥6 pts, else linear).
    4. Compute Gaussian distance weights wg.
    5. If free boundary node with ≥6 pts: solve KKT system (SPR-C).
    6. Else: solve unconstrained weighted LS via lstsq.
    7. Extract a0 → strain[i].

5. Derived Strain Quantities

QuantityFormulaFunction
Von Mises strain εVM = √(εxx2 + εyy2 − εxxεyy + ¾γxy2) von_mises_strain()
Principal strains ε1,2 = (εxx+εyy)/2 ± √[(εxx−εyy)2/4 + (γxy/2)2] principal_strains()
Von Mises strain formula: The implementation uses the simplified ν-independent form (equivalent to setting ν′ = 0), consistent with the convention adopted by most commercial finite element packages.

6. References