feat(evaluate): measured point-location capability + NaN/RBF fallback ladder (#392)#395
Merged
Merged
Conversation
…Points on quad/hex meshes (#390) PETSc's point location uses a half-open cell convention: a query point sitting exactly on the domain's closed upper face (e.g. y = y_max on a StructuredQuadBox) belongs to the cell "above", which doesn't exist, so DMLocatePoints silently drops it and the evaluator zero-fills the result. Semi-Lagrangian stress-history trace-backs slide departure points along the top boundary of the shear box, so every step read psi* = 0 there instead of the true history. The BDF history update then amplified that boundary corruption exponentially — the test_1052 VEP "blow-up" (max|err| = 240 vs threshold 0.10). With this fix the run returns max|err| = 0.063, matching the value recorded when the test was written. This was a UW3 regression, not a PETSc 3.25 change: before 17a5a8d the kd-tree cell hint was always passed to DMInterpolationSetUp_UW and prefilled the dropped-point recovery map. When the hint pointer became the bypass switch (simplex/manifold only), quad/hex meshes lost the recovery. PETSc's plexgeometry.c is unchanged between 3.24.2 and 3.25.0. The fix separates the two roles with an explicit hintAuthoritative flag: - simplex / manifold meshes: hint is authoritative, DMLocatePoints is bypassed (unchanged behaviour); - quad / hex volume meshes: DMLocatePoints remains authoritative, but the hint again rescues points it drops, evaluated in the adjacent cell with reference-coordinate clamping (restored behaviour). Adds a level_1/tier_a regression test evaluating a linear field at points on every closed face of quad and simplex boxes. Underworld development team with AI support from Claude Code
… ladder (#392) The cell-wall estimator's authority is now a MEASURED mesh property, not an isSimplex() type flag. Mesh._location_capability() audits face planarity (sagitta) and cell convexity per mesh, cached against the mesh/topology version so deform() and adaptation refresh it: - "exact" — simplex, manifold, and any quad/hex mesh with planar faces and convex cells at machine level. This graduates ALL valid 2-D quad meshes (deformed included — straight edges are always planar, convexity is equivalent to an untangled mesh) and rectilinear/affine hex boxes to simplex-grade authoritative location: the hint bypasses DMLocatePoints. - "continuous" — warped hexes within a 5% sagitta tolerance (cubed-sphere class). Authoritative for continuous fields only: a misclassified point lands in the face-adjacent neighbour, where continuous FE interpolants agree to O(sagitta x gradient); a face-aligned jump would see O(jump) errors. - "none" — badly warped or non-convex cells: no authority. Evaluations that are NOT authoritative (capability "none", or "continuous" with a discontinuous variable in the mix) run DMLocatePoints, and points it drops — e.g. queries exactly on the domain's closed upper faces, the #390 class — are NaN-filled (never zeros), reported via a new unlocated mask, and filled per-variable through the RBF interpolant: bounded, topology-free, honest. NaN can only survive if that plumbing is bypassed, which is exactly when it should be visible. The policy lives in one place (Mesh._hint_is_authoritative) and joins the DMInterpolation cache key, since the same coords with a different field-continuity mix legitimately need different structures. Design record: issue #392 and docs/developer/design/point-location-capability.md. Validation: test_0503 11/11 (three new tests: capability grading, deformed- quad exactness, warped-hex RBF rung), test_1052 5/5, level_1+tier_a gate 440 passed, np2 parallel suite unchanged from baseline. Underworld development team with AI support from Claude Code
… crash The test job dies with zero pytest output ~2s into each batch — a hard crash during import underworld3 on the linux runner, before pytest's first stdout flush. Reproduce attempts on macOS (custom PETSc 3.25.0 and conda PETSc 3.25.3 dev env) all pass, so surface the crash point in CI with faulthandler. This commit will be reverted once the cause is fixed. Underworld development team with AI support from Claude Code
The PR #394 'failure' turned out to be a runner-side flake: pytest died during import underworld3 before its first stdout flush, so all eight serial batches failed with zero output — undiagnosable from the log. The identical code passed once re-run. Keep the 5-second faulthandler import step so any future import-time crash is loud and localised instead of silent. Underworld development team with AI support from Claude Code
…location-capability # Conflicts: # src/underworld3/function/_dminterp_wrapper.pyx # src/underworld3/function/petsc_tools.h # tests/test_0503_evaluate.py
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.
Closes #392. Re-opened continuation of #394, which was auto-closed when its stack base (#391, now merged to development) was deleted — the diff here is the capability-ladder work only. Full design discussion and CI history on #394 and issue #392.
What this does
Makes the cell-wall estimator's authority a measured mesh property instead of an
isSimplex()type flag, and completes the fallback ladder agreed on #392.Mesh._location_capability()audits face planarity (sagitta) and cell convexity, cached against(_mesh_version, _topology_version):exact— simplex, manifold, and any quad/hex mesh with planar faces and convex cells at machine level. Graduates all valid 2-D quad meshes, deformed included (verified 4000/4000 against exact polygon containment) and rectilinear/affine hex boxes to simplex-grade location: hint bypassesDMLocatePoints.continuous— warped hexes within 5% sagitta (cubed-sphere class). Authoritative for continuous fields only.none— badly warped / non-convex cells: no authority.The ladder: non-authoritative evaluations run
DMLocatePoints; dropped points are NaN-filled (never zeros), reported via an unlocated mask, and filled per-variable throughrbf_interpolate. The policy lives in one place (Mesh._hint_is_authoritative) and joins the DMInterpolation cache key.Also keeps the CI import smoke test (faulthandler) added while diagnosing the #394 runner flake — a permanent 5-second guard against silent import-time crashes.
Testing
Design record: issue #392 and
docs/developer/design/point-location-capability.md.Underworld development team with AI support from Claude Code