fix(meshing): mmpde metric — monotone RBF bake from nodal values#266
Merged
Conversation
Restores the intended "RBF metric eval" robustness. The mmpde mover's RBF/Shepard metric path baked the metric via an FE evaluation at the FIXED reference cloud `ref`; on a deformed mesh that reference can mis-locate / drift outside the deformed interior and the FE evaluation returns garbage (the P1 density — strictly positive by construction — comes back NEGATIVE, even at a field's own DOFs). A negative density is a non-SPD metric, which the mover then either NaN-bails on (a hidden stall) or, with the #259 SPD-floor, acts on as "coarsen hard here" → giant cells / holes / divergence in the adapted mesh. Fix: bake the metric at the CURRENT mesh NODES (its own DOF locations) and Shepard-interpolate from there. A Shepard (positive-weight, convex) average of the positive nodal values is GUARANTEED >= 0 (monotone) — the metric can never go non-SPD from the eval — and nodes are always inside the mesh (no out-of-domain / drift) and need no per-step cell location (fast). `ref` is kept for the _edge_mats reference frame. Best paired with #264 (deformed-mesh point-location fix), which makes the nodal FE bake exact; together the adapted mesh stays clean under forced every-step adaptation at R=5 (folded=0, cell-area-ratio flat) where it previously tore holes. Validated in a sibling worktree (this is a one-line source change; CI runs the full mover suite). Underworld development team with AI support from Claude Code
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the MMPDE mover’s metric_eval="rbf" fast-path to improve robustness on deformed meshes by changing where the metric is sampled (“baked”) before Shepard (k-NN inverse-distance) interpolation.
Changes:
- Bake the analytic metric at the current mesh node coordinates (
coords) instead of the cached fixed reference cloud (ref). - Build the k-NN tree from the node coordinates and interpolate metric values from those samples.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3152
to
+3155
| # * MONOTONE: a P1 density is positive by construction; Shepard is a convex | ||
| # (positive-weight) average of the sampled node values, so the result is | ||
| # GUARANTEED positive — no negative/non-SPD garbage, the SPD floor / NaN | ||
| # bail never has to fire. |
Comment on lines
3161
to
+3164
| if metric_eval == "rbf": | ||
| from scipy.spatial import cKDTree | ||
| M_ref = _eval_M_analytic(ref) # one analytic pass | ||
| _tree = cKDTree(ref) | ||
| M_src = _eval_M_analytic(coords) # nodal values (positive) | ||
| _tree = cKDTree(coords) |
Member
Author
|
This is a minor detail - the metric evaluation for the adaptive meshing needs to be 1) fast and 2) monotonic ... rbf is a good choice, especially since it does not require the full mesh interpolation infrastructure to be valid during mesh movement (a difficult task to sequence correctly) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restores the intended RBF metric-eval robustness for the mmpde mover (a design decision that had been undercut by an FE bake).
Problem
The mover's
metric_eval="rbf"path baked the metric via an FE evaluation at the fixed reference cloudref, then Shepard-interpolated. On a deformed mesh that FE evaluation mis-locates points and the P1 density — strictly positive by construction — comes back negative (measured ≈ −3, even at a field's own DOF coords). A negative density is a non-SPD metric, which the mover either NaN-bails on (a hidden stall) or, with the #259 SPD-floor, acts on as "coarsen hard here" → giant cells / holes / divergence in the adapted mesh.Fix
Bake the metric at the current mesh NODES (its own DOF locations) and Shepard-interpolate from there:
refis kept for the_edge_matsreference frame.Relationship to #264
Best paired with #264 (deformed-mesh point-location fix), which makes the nodal FE bake exact. With both, the adapted mesh stays clean under forced every-step adaptation at R=5 (folded=0, cell-area-ratio flat, vrms→18, Nu→1.86) where it previously tore holes (area-ratio spikes 189/96/875).
One-line source change; validated in a sibling worktree. CI runs the full mover suite.
Underworld development team with AI support from Claude Code