Skip to content

Issue quick-fix batch: units/pint crash, pressure gauge under units, two stale parallel tests, scalar-field default, penalty migration note#396

Merged
lmoresi merged 6 commits into
developmentfrom
bugfix/issue-quickfix-batch
Jul 23, 2026
Merged

Issue quick-fix batch: units/pint crash, pressure gauge under units, two stale parallel tests, scalar-field default, penalty migration note#396
lmoresi merged 6 commits into
developmentfrom
bugfix/issue-quickfix-batch

Conversation

@lmoresi

@lmoresi lmoresi commented Jul 23, 2026

Copy link
Copy Markdown
Member

Six small, well-understood fixes from the 2026-07-23 issue triage, one commit per issue. Closes #271, closes #292, closes #328, closes #331, closes #340, closes #367.

What each commit does

#328uw.non_dimensionalise(pint.Quantity) crashed (fix(units))
The protocol-5 branch built a UWQuantity with an invalid dimensionality= keyword, so any raw pint quantity with a resolvable scale raised TypeError. It now returns a plain float, and converts the input to SI base units before dividing so non-SI inputs (km, cm/year) cancel correctly.

#271set_pressure_gauge crashed under an active units model (fix(stokes))
The gauge callback runs inside the SNES non-dimensionalisation cordon where p.data is non-dimensional, but the boundary integral it computes is a dimensional quantity — the solve died with an object-dtype casting error. The mean's non-dimensional value is now taken before the shift. The docstring also records the issue's second finding: a pressure gauge is counter-productive with pressure-dependent plasticity (it moves the yield surface every iteration). The issue's in-cordon boundary-weights redesign stays on record there as a possible refinement; this makes the current mechanism correct.

#331test_0765 deformed-shell test failed at np2/np4 on every branch
It called the internal Mesh._deform_mesh() directly, which the live-mesh coordinate-mutation guard (PR #326) rejects. Ported to the public mesh.deform(). This removes the "known pre-existing failure" that has been polluting every PR's parallel gate since early July.

#340 — retire ptest_004 (stale nodal-swarm advection script)
Its premise is gone, not just its API: the SL trace-back no longer allocates a nodal swarm (_nswarm_psi is None by design), so there are no particles to count. The live coverage (parallel SL advection across ranks) is carried by test_0700::test_nodal_swarm_advection_basic — which was itself stale (missing the now-required degree/continuous arguments, invisible because it only runs at np4) and is repaired in the same commit.

#367SNES_Scalar default field created with num_components=mesh.dim
Investigation outcome: never a real over-allocation — MeshVariable forces num_components=1 for vtype=SCALAR, so the argument was ignored. The default now passes the honest value and a comment records why this is behaviour-identical.

#292 — migration note for the viscosity-scaled Stokes penalty (docs only)
The June 2026 change from a bare-constant to a viscosity-scaled grad-div penalty silently changes older scripts that tuned large constant penalties. The troubleshooting page (previously a stub) now carries the what/why/what-to-update note; the changelog Q2 section records the change.

Verification

Reminder for the merge: PRs land on development, so GitHub will not auto-close the six issues — they need manual closing (or use this PR's closing keywords when the change reaches main).

Underworld development team with AI support from Claude Code

lmoresi added 6 commits July 23, 2026 12:07
…328)

The protocol-5 branch constructed UWQuantity with an invalid
dimensionality= keyword, so any raw pint.Quantity with a resolvable scale
raised TypeError. The scaled result is now returned as a plain float,
matching the magnitude returns of the branch's other exits, and the
input is converted to SI base units before dividing (the scale is SI,
so a km or cm/year input must cancel through SI or the magnitude keeps
the unit prefactor).

Regression tests: tests/test_0819_units_nondim_regressions.py (SI and
non-SI inputs; shown to fail with the TypeError before the fix).

Closes #328

Underworld development team with AI support from Claude Code
…ore applying (#271)

set_pressure_gauge's callback fires inside the SNES non-dimensionalisation
cordon, where p.data holds non-dimensional values — but BdIntegral.evaluate()
returns a dimensional UWQuantity when a units model is active, so the solve
crashed with an object-dtype ufunc casting error (and stripping the wrapper
would still be wrong by the pressure scale). The mean's non-dimensional
value is now taken before the shift is applied.

Also documents in the docstring that a pressure gauge is counter-productive
for pressure-dependent plasticity (it shifts the yield surface every
iteration), per the finding recorded on the issue. The issue's in-cordon
boundary-mass-weights redesign remains recorded there as a possible later
refinement; this fix makes the current mechanism correct.

Regression test: test_0819 gauge-under-units Stokes solve (crashed before
the fix, exactly as reported).

Closes #271

Underworld development team with AI support from Claude Code
…() (#331)

The test predates the live-mesh coordinate-mutation guard (PR #326) and
called the internal Mesh._deform_mesh() directly on a mesh carrying a
variable — rejected by the guard, so the test failed at np2/np4 on every
branch and polluted parallel gates as a known pre-existing failure.
Verified green at np2 and np4 (3 passed each).

Closes #331

Underworld development team with AI support from Claude Code
The script counted DuDt._nswarm_psi particles before/after advection, but
the SL trace-back no longer allocates a nodal swarm (_nswarm_psi is None by
design — the trace-back evaluates through global_evaluate), so the script's
premise is gone, not just its API. Its live coverage (parallel SL advection
across ranks) is carried by test_0700_basic_parallel_operations::
test_nodal_swarm_advection_basic, which this commit repairs — it was itself
stale (SemiLagrangian now requires degree/continuous) and only runs at np4,
so the breakage was invisible. Verified: 13 passed at np4.

Closes #340

Underworld development team with AI support from Claude Code
…nents=1 (#367)

Investigation outcome: no over-allocation ever occurred — MeshVariable
forces num_components=1 whenever vtype=SCALAR, so the constructor's
num_components=mesh.dim was ignored. The default now states the truth and
the TODO(BUG) marker is replaced by a comment recording why this is
behaviour-identical. Existing default-field Poisson coverage
(test_0641 Wave-C shims) passes unchanged.

Closes #367

Underworld development team with AI support from Claude Code
The June 2026 change of the augmented-Lagrangian grad-div penalty from a
bare constant to a viscosity-scaled term silently changes older scripts
that tuned large constant penalties against the viscosity magnitude. The
troubleshooting page (previously a stub) now carries the migration note —
what changed, why, and what to update — and the changelog Q2 section
records the change with a pointer.

Closes #292

Underworld development team with AI support from Claude Code
Copilot AI review requested due to automatic review settings July 23, 2026 02:11

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.

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