fix(meshing): honest 2D-only guard for the MMPDE mover (BF-09)#309
Open
lmoresi wants to merge 1 commit into
Open
fix(meshing): honest 2D-only guard for the MMPDE mover (BF-09)#309lmoresi wants to merge 1 commit into
lmoresi wants to merge 1 commit into
Conversation
The MMPDE mover (_winslow_mmpde) advertised "Dimension-general (d = 2, 3)"
but its 3D code path assigned signed_vol = _signed_volumes, a function that
was never implemented anywhere in the package, so any 3D invocation died
with a NameError deep inside the mover. Maintainer decision (D8) is not to
implement the 3D discretization now.
The fix raises a clear NotImplementedError ("MMPDE mesh movement is
currently 2D-only ...") at the top of _winslow_mmpde, before any metric
parsing or DM work, removes the dead 3D branch that referenced the phantom
function, and makes the docstrings honestly 2D-only (the mover docstring,
a new mmpde bullet in smooth_mesh_interior's method list, and the
_tet_cells helper note). The 2D path is untouched: the cells/signed-area
selection collapses to the identical 2D assignments.
Regression tests (tests/test_0850_mesh_smoothing.py, level_1/tier_a):
a real 3D simplex box through smooth_mesh_interior(method="mmpde") raises
NotImplementedError with the clear message (this test fails with NameError
on the unfixed build); a cdim stand-in locks the guard-before-any-mesh-work
contract; and a small 2D mmpde smoke invocation still runs and moves nodes.
Audit reference: docs/reviews/2026-07 READ-01 / REMEDIATION-WORKLIST BF-09.
Underworld development team with AI support from Claude Code
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the Huang–Kamenski MMPDE mesh mover in underworld3.meshing.smoothing honestly 2D-only, replacing a broken (and never-implemented) 3D branch that previously failed at runtime with a NameError (_signed_volumes).
Changes:
- Add an early
NotImplementedErrorguard in_winslow_mmpdeforcdim != 2and remove the dead 3D branch that referenced_signed_volumes. - Update documentation strings to clearly state that the MMPDE mover is currently limited to 2D triangle meshes.
- Add regression tests verifying: (1) 3D raises
NotImplementedErrorvia the public API, (2) the guard triggers before any DM/metric work (via a minimalcdimstand-in), and (3) a basic 2D MMPDE call still runs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/underworld3/meshing/smoothing.py |
Adds an explicit 2D-only guard for _winslow_mmpde, removes the broken 3D code path, and updates docstrings/method docs accordingly. |
tests/test_0850_mesh_smoothing.py |
Adds regression coverage ensuring 3D fails with a clear NotImplementedError and that 2D MMPDE still executes successfully. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Finding
BF-09 / READ-01 from the 2026-07 quality audit
(
docs/reviews/2026-07/REMEDIATION-WORKLIST.md,docs/reviews/2026-07/READABILITY-REVIEW.md)._winslow_mmpde(src/underworld3/meshing/smoothing.py) claimed"Dimension-general (d = 2, 3)" in its docstring, but the
cdim == 3branchassigned
signed_vol = _signed_volumes— a function that is defined nowhere inthe package — so any 3D MMPDE invocation died with a
NameErrordeep insidethe mover. Maintainer decision (D8): do NOT implement the 3D discretization;
make the mover honestly 2D-only.
Reproduction
On the unfixed build:
The new regression test fails with exactly this NameError on the unfixed
build (confirmed in the pre-fix gate run).
Fix
NotImplementedError("MMPDE mesh movement is currently2D-only ...") at the top of
_winslow_mmpde, before any metric parsing orDM work, so both the public
smooth_mesh_interior(method="mmpde")path andthe bare dispatch hit an honest message immediately.
_signed_volumes;the 2D path collapses to the identical
_tri_cells/_signed_areas/fact = 2.0assignments (no behaviour change in 2D)._winslow_mmpdedocstring, a new"mmpde"bullet insmooth_mesh_interior's method documentation, and the_tet_cellshelper note (that helper stays —_ot_adapt.pyuses it for 3Dboundary-face extraction).
No solver or 2D mover numerics are touched.
Tests
New
TestMMPDEDimensionGuardintests/test_0850_mesh_smoothing.py(level_1, tier_a):
test_mmpde_3d_raises_not_implemented— real small 3D simplex box throughthe public API raises
NotImplementedErrormatching "MMPDE mesh movement iscurrently 2D-only" (fails with
NameErrorpre-fix).test_mmpde_3d_guard_fires_before_any_mesh_work— cdim stand-in locks theguard-runs-first contract (same pattern as test_0762's non2d tests).
test_mmpde_2d_smoke_still_works— small 2D mmpde invocation runs, movesnodes, leaves finite coordinates.
Gate results (serial, worktree env):
pytest tests/ -m "level_1 and tier_a" -x -q: 217 passed; the ONLYfailure is the new 3D regression test hitting the pre-fix
NameError(the intended failing-first reproduction).
failed (skips/xfails/xpass all pre-existing).
test_0855) + new tests: 50 passed.
MPI runs not required for this item: the change is a dimension guard plus
dead-branch removal; the executable 2D path is byte-for-byte semantically
identical, so no partition-sensitive behaviour changes.
Underworld development team with AI support from Claude Code