Skip to content

Rotated free slip: warn on a nonzero essential value at a shared node; document the solve's result keys and time= (#939, #887, #410) - #1127

Merged
lmoresi merged 13 commits into
developmentfrom
bugfix/rotated-corner-pin-warning-and-docs
Nov 13, 2026
Merged

lmoresi merged 13 commits into
developmentfrom
bugfix/rotated-corner-pin-warning-and-docs

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

A warning and documentation for the rotated free-slip solve, from a probe of old issues against development 01dec8d. No solve changes: no row of any system, no solver tolerance, no default. The warning itself makes three numerical decisions, listed below.

What changes

  • A warning for Rotated free slip meets a nonzero component Dirichlet pin: the corner's reduced constraint ignores the pinned value #939. Where a rotated wall shares a node with an essential condition, the wall-normal constraint at that node is built as if the pinned components were zero, so the wall-normal velocity there comes out as n_P·g_P: the pinned part of the wall normal against the prescribed value. Probe: unit box, rotated free slip on Top with normal (3/5, 4/5), u_z = 1/20 pinned on Left; at the shared corner n·v = 0.04 where zero was asked, with nothing printed. The solve now reports that quantity when it is not zero: once per solver and essential wall, with its size, gathered across ranks and printed through the rank-safe print. The value is evaluated at the node from constants, coordinates and the model clock; a field-valued pin is reported as "may have a component along the wall normal". Nodes with every component pinned are included. The proper fix (reducing the constraint against the pinned value) is not in this PR.
  • Documentation for Rotated solve and thin sheet: docs and messages behind the code #887. solve_rotated_freeslip's Returns section gains the keys it already returned without describing (ref, fnorm_rest, rnorm_history, line_search_alpha, vel_its_last, pres_its_last, the last two empty when a warm start converges at iteration 0), and rnorm0 is described as the residual the reference is set from. rotated-freeslip.md says where the reference comes from when the only forcing is a prescribed datum, and that the projected-out rotation component is kept as solver._rotated_rotation_gauge_residual.
  • A docstring correction for Time-dependent Dirichlet BCs are broken in solve(): essential values inserted at PETSC_MIN_REAL, mesh.t kernels see -1.8e308 #410. The solve docstrings said expressions using mesh.t evaluate at time=. They do not, anywhere: mesh.t carries the model clock, in source terms and in essential conditions alike. Measured here on a scalar wall value and a Stokes lid (with time=2 and the clock at 0 the wall holds 0; with the clock at 2 it holds 2), and in the review on a Poisson source and a Stokes body force. The three docstrings now say what time= sets and that mesh.t follows the clock. What time= should do is not decided here.
  • Planning guide. The rule for an enhancement request that was filed as an issue: it moves to the roadmap as a draft item and the issue is closed as "not planned" with a comment saying the work is not rejected.

The numerical decisions in the warning

They decide only whether a line is printed; nothing in the solve reads them.

  • An exact zero on the normal. A pinned component is considered only if some wall normal at the node has an entry on it that is not exactly 0.0. This is what keeps an inflow wall beside an axis-aligned lid silent.
  • An exact zero on the value. A pinned value that evaluates to exactly 0.0 at the node contributes nothing and is skipped.
  • A relative threshold of 1e-12. The size reported is the largest |n_P·g_P| over the node's normals. It is reported only if it exceeds 1e-12 times the largest pinned value at the node, so a normal that is axis-aligned up to round-off against a pinned value does not produce a line. It is a multiple of round-off, not a physical tolerance: a real conflict is of the order of the value itself.

After review

The first version of the warning looked only at whether a pinned value was provably zero. The review (above, by the session that owns the rotated free-slip code, run on macOS, 12-core Apple M4, serial) showed it warned where n·v was exactly zero (an inflow wall beside a flat lid; any symbolic value), was silent at nodes with every component pinned, and raised IndexError for an essential condition given in the older components= form. The check was rewritten as described above, and the review's corrections to the Returns section, the time= docstrings and the docs page are taken.

After the second review

A pinned value that is a bare coordinate (u_x = z on a side wall, simple shear) raised AttributeError inside the check. The check runs on the ranks that hold a shared node, ahead of the collective report, so a raise there would leave the other ranks waiting in the gather. The evaluated result is now a sympy object, and reading a value is guarded: anything it raises becomes the "could not be evaluated" report and every rank goes on to the gather.

The value is read when the rotation is built, and the rotation is kept across solves. A value that changes later (one that follows the model clock) is therefore not read again on the same solver until the rotation is rebuilt; the docstring and the warning say so. Evaluating per solve was the alternative and is not done here.

Tests

tests/test_1066_rotated_meets_essential.py gains seventeen cases, both directions. Reported: a tilted lid beside u_z = 1/20 (0.04); a node with every component pinned (0.07); one line per essential wall when two conflict; the largest size over a wall's shared nodes (0.05); a clock-following value once the clock is 2 (0.08); a field-valued pin, as "may"; the older components= form, which must also still solve; bare-coordinate pins u_z = z (0.8) and u_x = z (0.6); a value whose evaluation raises, reported as "could not be evaluated" with no exception. Silent: a zero pin; an inflow wall beside a flat lid; a profile that is zero at the corners; mesh.t at clock 0; an expression holding zero; u_z = x on the wall x = 0; a node with a prescribed wall-normal datum, which keeps its own warning. The warning tests assert, on every rank, on what rank 0 printed.

Verification

On a 96-thread Linux workstation (single system image, Intel Xeon Gold 6240R, MPICH 5.0.1, PETSc int32), head 0764729:

check result
test_1066_rotated_meets_essential.py, test_1018_rotated_freeslip, test_1085_build_rotation_setup 47 passed
the seventeen warning cases at np 2 and np 3 pass on every rank; no hang
parallel/test_1066_rotated_datum_parallel, test_1064_rotated_freeslip_parallel, test_1084_rotated_datum_collectives at np 2 and 3 pass on every rank
the whole of test_1066_rotated_meets_essential.py at np 2 and 3, head e4faf9b 19 passed on every rank (the existing lid test now takes its maxima over every rank)
collective-guard scan; style gate 5 passed; gate passes
at 1f3f27f, before this round: test_1131, test_0846, test_1077, test_1092 (without Maxwell) with the above 71 passed

Untested: that the report is made once per solver (the set that records reported walls has no test).

Established in review, not by us: shared corners on ranks other than rank 0 at np 2 and np 3, with all warning cases passing and no hang, and the bare-coordinate input hanging at the previous head and passing at 0764729. The library code is unchanged since 0764729; only one test changed after it.

Issues

Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9)
  • Bug fixes ship the regression test, written first, with level_* and tier_* markers (S8)
  • No hedging names (maybe_ / try_ / do_) and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4)
  • New data access uses .array / mesh.X.coords — no with ....access(...), no mesh.data (S7)
  • Parallel safety considered — np2/np4 checked where swarm/mesh/solver dispatch is touched (S11)
  • No pixi.toml / pixi.lock or other dependency changes riding in an unrelated PR
  • AI-assisted work carries the attribution line below

Underworld development team with AI support from Claude Code

…and a zero one is not (#939)

On development the first test fails: the solve prints nothing, and the
wall-normal velocity at the corner is 0.04 where the rotated wall asks for
zero. The second passes.

Underworld development team with AI support from Claude Code
…node (#939); document the rotated solve's result keys (#887)

The reduced constraint at a node shared with an essential condition is built
as if the pinned components were zero. Where the essential value is not zero
the wall-normal velocity there is not the prescribed one: 0.04 where zero was
asked for, with u_z = 1/20 pinned beside a wall of normal (3/5, 4/5). The
solve now says so, once, naming the essential wall, in the words of the
existing partial-datum warning. A warning only: no row of any solve changes,
and the affine reduction itself is not implemented here.

solve_rotated_freeslip's Returns section gains the keys it already returned
without describing: ref, fnorm_rest, rnorm_history, line_search_alpha,
vel_its_last and pres_its_last (empty when a warm start converges at
iteration 0). rnorm0 is described as the residual the reference is set from,
which on a datum-only cold start is the lifted iterate's, not the initial one.

Underworld development team with AI support from Claude Code
…sidual (#887); moving an enhancement issue to the roadmap

rotated-freeslip.md says where the reference comes from when the only forcing
is a prescribed datum, and that the projected-out rotation component is kept
as solver._rotated_rotation_gauge_residual. planning-on-github.md records the
rule for an enhancement request filed as an issue (Louis, 2026-11-13).

Underworld development team with AI support from Claude Code
…esh.t (#410)

Both solve docstrings said expressions using mesh.t evaluate at time=. For the
residual and Jacobian kernels that is the documented path. An essential
condition is evaluated at the model clock instead: with time=2 and the clock
at 0, a wall prescribed as mesh.t holds 0, and it holds 2 once the clock is
2 (measured on a scalar solve and on Stokes). The docstrings now say so. No
behaviour changes; what time= should do there is not decided here.

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

uw.systems.Stokes.solve overrides the base method and has its own docstring;
the note added to the base class did not reach it.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 13, 2026 03:34

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 insufficient remaining quota. Try requesting a review at a lower effort level.

@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Adversarial review at 65a02da

Cross-review by W1 (the integration session, which owns the rotated free-slip code), with a fresh reviewing agent, against development 01dec8d. Run on macOS (12-core Apple M4), serial only: nothing here was run on more than one rank. Comparisons with development were made by executing its rotated_bc.py into the installed module in memory; mutants the same way.

Result. The solve is bitwise unchanged on every ordinary input we probed. One input now raises where development solved (finding 3). The warning is wrong in both directions: it fires where v.n is exactly what was asked, and it is silent at fully pinned nodes that do conflict. We would fix 1 to 3 before merge.

Findings

1. The check does not look at the wall normal, so it warns where nothing is wrong. _walls_pinning_nonzero asks whether a pinned component has a value not known to be zero. The reduced constraint is wrong only when the normal has a component along a pinned direction that carries a nonzero value. Unit box, cell size 0.25, P2/P1:

Rotated lid Essential wall Warned n.v at the shared corner
flat, normal (0, 1) Left and Right (0.05, None) yes 0 exactly
flat, normal (0, 1) Left (0.05 cos(2 pi z), None) yes 0 exactly
tilted, normal (3/5, 4/5) Left (None, 0.05) yes 0.04 (the case of the PR)

The first row is an axis-aligned free-slip lid beside an inflow wall, and the message tells that user "v.n at the node is not the prescribed one". Counting component c only when some normal at the node has a nonzero entry in c removes these.

2. Every symbolic value is read as nonzero, and the message states it as fact. The test is sympify(bc.fn[c]).is_zero is not True. With the tilted lid, all of these warn, and n.v at the corner is at round-off:

Value on Left n.v at the corner
(None, x) 7.9e-18
(None, z(1-z)/5), zero at both corners 1.8e-17
(None, uw.expression(..., 0.0)) 0
(None, 0.05*mesh.t), clock at 0 0
(None, 1e-18) 8e-19

The helper's docstring says "not known to be zero"; the printed text says "prescribes a nonzero essential value there". Either evaluate the value at the node or word the message as "may be nonzero".

3. A new exception in the solve. bc.fn[c] indexes the stored value by field component. With the deprecated components= argument the stored value can be shorter than the field: add_dirichlet_bc(0.05, "Left", 1) stores fn=[0.05], components=[1]. At this head the solve raises IndexError: index out of range inside build_rotation; with development's rotated_bc the same fixture solves. (What development prescribes on that route is itself wrong, a separate matter that goes to the hub.) "No solve changes" in the PR body needs this exception, or one guard.

4. Silent where the conflict is largest. A node with every component pinned is skipped (if not free: continue) before the new check. Tilted lid with Left (0.05, 0.05): no warning, n.v = 0.07 at the corner; Left (1.0, 0.0): no warning, n.v = 0.6. By reading, a fault pair node with a pinned component and a datum wall (which takes the partial-datum warning) are not covered either. The sentence in the PR body reads as covering these. Does not block; the body should state the scope.

5. "Once" is once per process and rank. The guard is a module global. Left (None, 0.05) with Right (None, 0.07) prints one line naming 'Left' only; the Top-Right corner has n.v = 0.056. A second and a third solver in the same process, the third pinning a different component, are silent with n.v = 0.04 and 0.03. The tests see the warning because they reset the flag. Does not block.

6. Bare print, before the ownership test (Charter §11). The module header says "Rank-safe printing only (mpi.pprint)". By reading, not run: the call precedes the ownership test, so on several ranks the owner and every rank holding a ghost copy of the node print; a plain uw.pprint would print nothing when rank 0 does not hold the node. No collective call is on the path, so there is no hang. The call after the ownership test would give one line from the owning rank. The pattern is the one of _warn_once_partial_datum beside it.

7. The time= docstrings keep a sentence that is measured false. The solver docstrings still say expressions using mesh.t evaluate at time= in the pointwise residual and Jacobian functions.

Case clock 0, time=2 clock 2, no time= clock 2, time=5
Poisson source f = mesh.t, max|u| 0 0.147121 0.147121
Stokes body force (0, mesh.t cos(pi x)), max|v| 0 2.0545e-2 2.0545e-2
Poisson wall value mesh.t 0 2 2

time= reaches nothing written with mesh.t. The wall row agrees with what the PR says (and gives no NaN); the correction covers the essential condition and leaves the wrong sentence for source terms beside it.

8. Returns section of solve_rotated_freeslip. line_search_alpha is also 0 when the line search stalls, not only on a step-norm exit. Entries of vel_its_last / pres_its_last are None on the direct and vector routes, and both lists are empty for a cold start with zero residual and no datum (measured: nonlinear_iterations=0, lists []). The other new entries match what we measured: fnorm_rest is None on a cold start and measured on a warm one; ref = max(rnorm0, fnorm_rest).

9. rotated-freeslip.md. "Such a solve takes two increments where the lift alone would do" holds for a linear model: the annulus datum fixture of test_1018 with zero body force takes 2 increments linear and 14 with a power law. _rotated_pressure_gauge_residual exists only with petsc_use_pressure_nullspace; the page names it beside the rotation attribute, which is set after every solve.

10. The two new tests can fail and pin little. Mutants:

Mutant Result
development's rotated_bc reported-test fails, silent-test passes
warning call removed killed
any value counts as nonzero killed
wrong wall named killed
once-guard removed survives
symbolic values silent (is False) survives
label-membership test removed survives
c in pinned filter removed survives

The assertions are substring checks. The count, the symbolic branch, a second wall and the flat-normal case of finding 1 are untested.

11. Scope. docs/developer/guides/planning-on-github.md gains a planning rule outside the title's territory (Charter §9).

What holds

  • Against development's rotated_bc in memory, u and p are bitwise equal with the same outer, velocity and pressure counts and residual histories on three fixtures: nonzero pin under a tilted lid (1 / 20 / 10), zero pin under a tilted lid (1 / 21 / 10), flat lid with inflow and outflow (1 / 18 / 8). With the check on against off, four fixtures including an expression pin are bitwise equal.
  • Cost: the check runs inside build_rotation only (2 calls for one solve, 2 for three solves of one solver, 2 at 3938 velocity unknowns), about 2 microseconds a node for each essential condition.
  • At this head: test_1066 4 passed, test_1018 27, test_1085 1, test_1131 28. scripts/check_test_coverage.py passes.

Not checked

Anything on more than one rank (finding 6 is by reading; the parallel tests the PR body lists; the collective-guard scan). test_1092. 3-D and edge nodes. The fault pair path and a datum with a pin, by probe. pixi run docs-build. CI shards 1, 3, 4 and 5 had not reported when we read them.

Issue verdicts

Underworld development team with AI support from Claude Code

The warning must depend on the pinned value's component along the wall normal
at the shared node: reported for a tilted lid beside u_z = 1/20 (0.04), for a
node with every component pinned (0.07), once per essential wall, for a
clock-following value once it is nonzero, as 'may' for a field-valued pin; and
silent for a zero pin, an inflow wall beside a flat lid, a profile that is zero
at the corners, mesh.t at clock 0 and an expression holding zero. The older
components= form of an essential condition must still solve. Seven of these
fail at the previous head.

Underworld development team with AI support from Claude Code
…ode (review of #1127)

The first version warned whenever a pinned component had a value not provably
zero. It warned for an inflow wall beside a flat lid, where n.v is exactly
zero, and for any symbolic value; it was silent at a node with every component
pinned; and it raised IndexError for an essential condition given in the older
components= form.

The check is now the quantity #939 is about: the pinned part of the wall
normal against the prescribed value, n_P . g_P, with the value evaluated at
the node (constants, coordinates and the model clock; a field-valued pin is
reported as possibly nonzero). Pinned components are read from the section, so
ghost copies agree with owners, and nodes with every component pinned are
included. Conflicts are gathered across ranks and reported once per solver and
essential wall through mpi.pprint, with the size. No row of any solve changes.

The Returns entries for line_search_alpha, vel_its_last and pres_its_last are
completed as the review measured them.

Underworld development team with AI support from Claude Code
…tated free-slip page (review of #1127)

The review measured that an expression written with mesh.t follows the model
clock in source terms as well as in essential conditions, so the sentence that
time= evaluates mesh.t in the residual and Jacobian kernels was wrong too. The
three solve docstrings now say what time= sets and that mesh.t follows the
clock. rotated-freeslip.md limits the two-increment remark to a linear model
and says when the pressure-gauge residual attribute exists.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Adversarial review, round 2, at 1f3f27f

Re-check by W1 (the integration session, which owns the rotated free-slip code) of the three findings we asked to be fixed before merge, with the comparison against development rerun at this head. Run on macOS (12-core Apple M4), serial only: nothing here was run on more than one rank. development's rotated_bc.py (unchanged from 01dec8d to 70b240c) was executed into the installed module in memory for the comparisons; mutants the same way.

Result. Findings 1, 2 and 4 to 9 of round 1 are closed. One input class now raises where development solves (finding A), and it is a common way to write a wall value. We would fix A before merge. B is a limit the tests and the PR body should state. C goes away with #1129.

Findings

A. A pinned value that is a bare coordinate raises AttributeError in the solve. _value_at_point ends with expr.xreplace(at_x) and then expr.is_number. When the value is a coordinate symbol by itself, xreplace returns the Python float it was given, which has no is_number. Unit box, cell size 0.25, P2/P1, rotated lid on Top, no slip on Bottom, rotated free slip on Right:

Lid normal Value on Left This head development
(3/5, 4/5) (None, x) AttributeError: 'float' object has no attribute 'is_number' solves, n.v at the corner 7.9e-18
(3/5, 4/5) (None, z) same error solves, n.v = 0.8
(0, 1) (None, z) same error solves, n.v = 1.0
(3/5, 4/5) (z, 0) same error solves, n.v = 0.6
(3/5, 4/5) (None, 2*z) solves, one warning solves

(None, x) was a row of finding 2 in round 1. u = (z, 0) on a side wall is the usual way to write simple shear. sympy.sympify(expr.xreplace(at_x)) is enough. A case with a bare coordinate belongs in the "silent" and "reported" tests.

The raise is made inside the node loop, on a rank that holds a shared node, before the new gather. By reading, not run: on several ranks the others would wait in allgather. Any exception out of _pinned_value_along_normal has that shape (a value that is infinite at a shared node, 0.05/z at the bottom corner, gives TypeError: Cannot convert complex to float the same way; not compared with development), so the check should not be able to raise: catch what the evaluation can throw and report the value as not evaluated, which the message already has words for.

B. The check runs when the rotation is built, not at each solve. The default (iterative, no datum) route keeps the rotation across solves. One solver, u_z = t/20 pinned on Left, tilted lid:

Solve Clock Rotation reused Warnings n.v at the corner
1 0 no 0 0
2 2 yes 0 0.08
3 2 yes 0 0.08

test_a_pinned_value_that_follows_the_clock_is_reported_once_it_is_nonzero passes because it builds a new solver at clock 2. A time-stepping run that starts from a zero value is never told. Either evaluate the check at each solve (it costs 18 to 180 microseconds a shared node here) or say in the message's docstring, the PR body and the test name that the value is read once, at set-up. Does not block.

C. components= with a value shorter than the components it names still raises. add_dirichlet_bc(0.05, "Left", 1) and ((0.05,), "Left", (1,)) now solve and warn (0.04). ((0.05,), "Left", (0, 1)) raises IndexError: index out of range in _essential_value; development solves it (with the wrong wall values of #1129). When #1129 refuses a short value in add_condition this cannot be reached. Does not block; the PR body's "must also still solve" covers the one-for-one form only.

D. Tests. test_1066: 13 passed. In-memory mutants of the new code:

Mutant Result
report never called killed (6 tests)
size ignores the normal killed (5)
no value can be evaluated killed (10)
wrong wall named killed (2)
label-membership test removed killed (1)
threshold 1e-12 changed to 1 killed (4)
components= form indexed by field component killed (1)
nodes with a datum are checked too survives
"once per solver" set ignored survives
largest over a wall's nodes changed to smallest survives
gather replaced by this rank's list survives, as it must on one rank

The first three survivors are untested lines: no test has a datum wall beside a pin, a second build on one solver, or a wall with two shared nodes of different size. The last needs the warning tests on two ranks or more, which the PR body says were not run; one case there with the shared corner on a rank other than 0 would pin the gather and the print.

E. Tolerances in the change, for the PR body. size <= 1e-12 * max|g| (a normal that is axis-aligned up to round-off); number == 0.0 exactly, so a pinned value of 1e-18 is reported with size 8e-19. No coordinate match: the wall is found by label membership of the mesh point and the pinned components are read from the section.

F. Scope. The paragraph added to docs/developer/guides/planning-on-github.md is still outside this PR's territory (round 1, finding 11). Does not block.

What holds

  • No solve changes, apart from A and C. Against development's rotated_bc in memory, u and p are bitwise equal, with the same linear iteration counts and residual histories, on nine fixtures: tilted lid with Left (None, 0.05), (None, 0), (0.05, 0.05), (None, z(1-z)/5), a field-valued pin, (0.0, 0.05) with components=(1,); Left (None, 0.05) with Right (None, 0.07); flat lid with inflow and outflow; and no slip on Bottom in place of a rotated wall.
  • Round 1, finding 1. A flat lid beside (0.05, None) is silent; a flat lid beside (None, 0.05) reports 0.05; a tilted lid beside (0.04, -0.03), where the pinned value is tangential, is silent.
  • Finding 2. (None, z(1-z)/5), an expression holding zero and mesh.t at clock 0 are silent; (None, z/20), a Piecewise, an expression holding 0.05 and the base-scalar form of the coordinate are reported with the size computed by hand. A field value reports "may have".
  • Finding 4 and 5. A node with every component pinned is reported (0.07); two essential walls give two lines with their own sizes (0.04, 0.056); the record of what was reported is per solver.
  • Finding 6. One allgather, called by every rank after the node loop with no exit between the loop and the call, then mpi.pprint. The walls reported and the per-solver record are the same on every rank, so the print is called the same number of times everywhere. The only way to miss the gather is an exception in the loop (A).
  • Findings 7 to 9. The three time= docstrings, the Returns section and the two sentences of rotated-freeslip.md now say what we measured.
  • Cost. Two calls in one solve at cell size 0.25 and at 0.05 (the shared corners only); 18 microseconds a call for a constant, 51 for a transcendental expression, 180 for a Piecewise.
  • At this head, serial: test_1066 13 passed; the collective-guard scan (test_0052), test_1085, test_1018_rotated_freeslip, test_1131, test_1141, test_0062 and test_1065, 78 passed. scripts/check_test_coverage.py passes.

Not checked

Anything on more than one rank: the warning at np 2 or more, whether a ghost copy of a shared node reports the same size as its owner on a wall with mesh normals, and the hang we read in A. 3-D and edge nodes. A fault pair node with a pinned component. pixi run docs-build.

Issue verdicts

Underworld development team with AI support from Claude Code

… warns and does not raise (second review of #1127)

Four fail at the previous head: the three bare-coordinate pins raise
AttributeError inside the check, and a value whose evaluation raises is not
caught. Two more cases pin behaviour the review's mutants showed untested: the
size reported is the largest over a wall's shared nodes, and a node with a
prescribed wall-normal datum is left to its own warning.

Underworld development team with AI support from Claude Code
…(second review of #1127)

A pinned value that is a bare coordinate raised AttributeError in
_value_at_point: xreplace on a lone symbol returns a plain float. The check
runs on the ranks that hold a shared node, ahead of the collective report, so
a raise there leaves the other ranks waiting in the gather. The result is now
sympified, and reading a value (the stored entry and its evaluation) is
guarded: anything it raises becomes the 'could not be evaluated' report, and
every rank goes on to the gather.

The value is read when the rotation is built and the rotation is kept across
solves; the docstring and the warning text now say that a value which changes
later is not read again while the rotation is kept.

The warning tests assert on what rank 0 printed, on every rank, so they can be
run in parallel.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

The parallel half at 0764729: READY, with one test to make rank-safe. Measured by H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)). The branch was built at 0764729. The first-review head 1f3f27f was run as its rotated_bc.py laid over that build, since the compiled code is identical between the two heads. Every MPI job ran under the supervisor.

Shared corners off rank 0. Before the runs, a probe recorded which rank owns and which ranks hold the lid's ends, (0, 1) and (1, 1), on _lid_against_a_pinned_wall's mesh:

np layout (0, 1): owner, held by (1, 1): owner, held by
2 natural 0, [0] 1, [1]
2 rand1 (shell) 1, [1] 1, [0, 1]
2 rand5 (shell) 1, [0, 1] 1, [0, 1]
3 natural 1, [1] 1, [1]
3 rand1 (shell) 2, [1, 2] 2, [1, 2]
3 rand5 (shell) 1, [0, 1] 2, [0, 2]

So in every run below at least one shared corner is owned off rank 0, and in the shell layouts the corners are also held by two ranks.

test_1066 at np 2 and 3, on every rank:

np natural rand1 rand5
2 18 passed, 1 failed on one rank 19 passed 19 passed
3 18 passed, 1 failed on one rank 19 passed 19 passed

The seventeen warning cases pass on every rank in every layout, with no hang.

The one failure is test_rotated_lid_holds_its_corners. Its fixture is a StructuredQuadBox, so the shell layouts do not reach it. The rank that holds no lid node raises "zero-size array to reduction operation maximum which has no identity" at np.abs(u[top, 1]).max(). That is the test, not the library.

  • CI runs tests/ serially, so CI is unaffected.
  • Suggestion: make it rank-safe in this PR, since the file is otherwise rank-safe now. The fix is two lines: max(initial=0.0) on both maxima, then an allreduce(MAX) of each.

W1's A input on the old head. test_a_pin_that_is_a_bare_coordinate_solves_and_is_read_at_the_node (u_z = x, u_z = z, u_x = z) at np 2:

  • 1f3f27f: hangs. The supervisor stopped it after 120 s of silence, with the native frames not moving. Rank 1, which holds the corner, is in _report_pinned_values_along_normals in an Allgather. Rank 0 has gone on to _free_petsc_garbage, in an Allreduce.
  • 0764729: all three pass on both ranks.

Not run: np above 3; the bitwise comparison against development (W1's).

Underworld development team with AI support from Claude Code

A rank that holds no lid node raised on the maximum of an empty array. The
whole file now passes on every rank at two and three ranks.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Adversarial review, round 3, at e4faf9b

Re-check by W1 (the integration session, which owns the rotated free-slip code) of round 2's findings, with the comparison against development rerun. Run on macOS (12-core Apple M4), serial only: nothing here was run on more than one rank; the parallel half is in the comment above. The library runs were made on a build of 0764729; e4faf9b changes one test and no library file, and test_1066 was rerun at e4faf9b. development's rotated_bc.py (unchanged from 01dec8d to d66c7da) was executed into the installed module in memory for the comparisons; mutants the same way.

Result. Findings A, B and C of round 2 are closed. Nothing here blocks the merge. Two small items remain for the body and the tests (1 and 2 below).

Round 2's findings

A. A bare-coordinate pin raised in the check: closed. Every input that raised at 1f3f27f now solves, with the same corner value as development:

Lid normal Value on Left This head development
(3/5, 4/5) (None, x) solves, silent, n.v at the corner 7.9e-18 same value
(3/5, 4/5) (None, z) solves, one warning, 0.8 0.8
(0, 1) (None, z) solves, one warning, 1.0 1.0
(3/5, 4/5) (z, 0) solves, one warning, 0.6 0.6
(3/5, 4/5) (None, 2*z) solves, one warning, 1.6 1.6
(3/5, 4/5) (None, 0.05/z), infinite at the bottom corner solves, one warning, 0.04 0.04
(3/5, 4/5) (None, 0.05/(1-z)), infinite at the shared corner solves, one warning, 3.6e14 3.6e14
(3/5, 4/5) (None, sqrt(z-2)), complex the linear solve fails (KSP_DIVERGED_NANORINF) the same error

The last two are bad inputs on both; what matters here is that the check adds no exception of its own. The guard's comment states the sanctioned failure mode. Three mutants of the fix are each killed: the sympify removed (3 tests fail), the guard narrowed to ZeroDivisionError (1), a value that cannot be read made silent (1).

B. The check runs when the rotation is built: closed by documenting it. Unchanged in behaviour (one solver, u_z = t/20: clock 0, then 2, then 2 gives 0, 0, 0 warnings and n.v = 0, 0.08, 0.08 with the rotation reused), and the docstring and the PR body now say so.

C. ((0.05,), "Left", (0, 1)) raised IndexError: closed. It solves with one warning and n.v = 0.7228 at the corner, as on development. The wrong wall values of that form are #1129, which PR #1139 refuses at add_condition.

D. Mutants that survived. test_1066 at this head: 19 passed.

Mutant Round 2 Now
nodes with a datum are checked too survived killed (1 test)
largest over a wall's nodes changed to smallest survived killed (1)
"once per solver" set ignored survived survives
gather replaced by this rank's list survived, as it must on one rank the same; the parallel half ran the warning cases at np 2 and 3 with the shared corner off rank 0
the seven killed in round 2 killed killed (10, 7, 15, 3, 1, 7 and 1 tests)

Remaining, neither blocks

1. The body says "no tolerance"; the warning has two. size <= 1e-12 * max|g| (a normal that is axis-aligned up to round-off) and number == 0.0 exactly, so a pin of 1e-18 is reported with size 8e-19. They decide what is printed, not what is solved, and the body's first line is about the solve; one sentence listing them would make it complete. No coordinate match: the wall is found by label membership of the mesh point and the pinned components are read from the section.

2. "Once per solver and essential wall" is still an untested line. No test builds the rotation twice on one solver. A second build after a wall value is reassigned, asserting no second line, would pin it.

The paragraph in docs/developer/guides/planning-on-github.md is still outside this PR's territory (round 1, finding 11); the body now names it.

What holds

  • No solve changes. Against development's rotated_bc in memory, u and p are bitwise equal, with the same linear iteration counts and residual histories, on fourteen fixtures: the nine of round 2, and five with no slip on Bottom and Left (None, x), (None, z) under a tilted and a flat lid, (z, 0) and (None, 2 z).
  • Sizes. (None, 0.05) reports 0.04; (0.05, None) 0.03; (0.04, -0.03), tangential, is silent with n.v = 5.6e-20; the one-for-one components= form reports 0.04.
  • e4faf9b. test_rotated_lid_holds_its_corners now takes both maxima over every rank with one reduction each, reached by every rank. On one rank the assertion is unchanged.
  • At 0764729, serial: test_1066, the collective-guard scan (test_0052), test_1085, test_1018_rotated_freeslip, test_1131, test_0062 and test_1065, 133 passed; test_1141, 11 passed. scripts/check_test_coverage.py passes.

Not checked

Anything on more than one rank. 3-D and edge nodes. A fault pair node with a pinned component. pixi run docs-build. CI at e4faf9b was still running when this was written (one shard of six finished, passing).

Issue verdicts

Unchanged from round 2.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 805dd61 into development Nov 13, 2026
10 checks passed
lmoresi pushed a commit that referenced this pull request Nov 13, 2026
…1129, with #1127)

#1127's test called add_dirichlet_bc(0.05, "Left", 1), the one-entry value naming
component 1 that this branch refuses. It now asserts the refusal: the same message on
every rank, naming the missing entry and the full-length form (None, 0.05).

Underworld development team with AI support from Claude Code
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.

3 participants