Skip to content

fix(evaluate): recover boundary-face query points dropped by DMLocatePoints on quad/hex meshes (#390)#391

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/dminterp-hint-fallback
Jul 23, 2026
Merged

fix(evaluate): recover boundary-face query points dropped by DMLocatePoints on quad/hex meshes (#390)#391
lmoresi merged 1 commit into
developmentfrom
bugfix/dminterp-hint-fallback

Conversation

@lmoresi

@lmoresi lmoresi commented Jul 22, 2026

Copy link
Copy Markdown
Member

What this fixes

Closes #390 (the test_1052 VEP stability failures) — but the root cause is not PETSc 3.25.

uw.function.evaluate was returning silent zeros for query points sitting exactly on the domain's closed upper boundary faces of quad/hex meshes (e.g. y = y_max on a StructuredQuadBox). PETSc's point location uses a half-open cell convention, so a point exactly on the top face belongs to the nonexistent cell "above" and gets dropped; the dropped point was then zero-filled by the evaluator.

Semi-Lagrangian stress-history trace-backs slide departure points along the top boundary of the VEP shear box, so every step read ψ* = 0 there instead of the true history. The BDF history update amplified that boundary corruption exponentially: max|err| = 240 against a threshold of 0.10. With this fix the same run gives max|err| = 0.063 — the value recorded in the test docstring when it was written.

Why this is a UW3 regression, not a PETSc one

  • Before 17a5a8d (May 24) the kd-tree cell hint was always passed into DMInterpolationSetUp_UW, and it prefilled the dropped-point recovery map — points PETSc dropped were evaluated in the adjacent hinted cell (with reference-coordinate clamping). When the hint pointer became the DMLocatePoints-bypass switch (simplex/manifold only), quad/hex volume meshes lost the recovery.
  • PETSc's plexgeometry.c (point location, grid hash) has only cosmetic changes between v3.24.2 and v3.25.0.
  • The failure reproduces byte-identically with conda-forge PETSc 3.25.3 and the custom 3.25.0 build, on any source branch that postdates May 24.

The fix

DMInterpolationSetUp_UW gains an explicit hintAuthoritative flag, separating the hint's two roles:

  • simplex / manifold meshes: hint is authoritative, DMLocatePoints is bypassed — unchanged behaviour;
  • quad / hex volume meshes: DMLocatePoints remains authoritative (the kd-tree nearest hint can be wrong on deformed cells), but the hint again rescues points it drops — restored behaviour.

For located points nothing changes: DMLocatePoints results always overwrite the hint. The evaluator's wrapper (_dminterp_wrapper.pyx) now always passes the hint and only varies the flag.

Testing

Underworld development team with AI support from Claude Code

…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
Copilot AI review requested due to automatic review settings July 22, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lmoresi

lmoresi commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

Design follow-up agreed with Louis: #391 stays scoped to restoring the hint recovery (exact for regular/near-regular quad geometry). The general resolution — NaN sentinel instead of zero-fill, plus an RBF fallback rung for deformed quad/hex meshes where the kd-tree hint is not trustworthy — is tracked as #392.

@lmoresi
lmoresi merged commit 1af82dd into development Jul 23, 2026
2 checks passed
@lmoresi
lmoresi deleted the bugfix/dminterp-hint-fallback branch July 23, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants