Skip to content

A rotated corner carries the pinned value into the wall's condition (#939) - #1263

Merged
lmoresi merged 4 commits into
developmentfrom
bugfix/rotated-corner-carries-the-pin-939
Nov 24, 2026
Merged

lmoresi merged 4 commits into
developmentfrom
bugfix/rotated-corner-carries-the-pin-939

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

Where a rotated free-slip wall meets a component Dirichlet wall, the corner now satisfies the wall's condition with the pinned value included: n_F·v_F = −n_P·g_P.

What changes

On development.

Now.

  • The reduced row's value. The free components' share is the least-squares v_F with M_F v_F = −M_P g_P over the node's wall normals; with one wall meeting the pin it is exact. The reduced rotated rows get the value Vt_F v_F as a datum. The corner above gives u_x = −1/15 and n·v = 0.
  • When the pin is read. A solver whose corner pin is anything but a plain zero rebuilds its rotation at every solve, as datum solves already do, so a pin that follows the model clock is read again. A cached rotation would drop the pinned datum; it would also have kept a clock value from its first solve. "Live" is read from the value as written, since mesh.t unwraps to its current value. So a coordinate-valued pin also skips the cache, which costs time and not accuracy.
  • When it still warns. Where the wall's condition cannot hold:
    • every component pinned;
    • a wall normal lying wholly in the pinned components;
    • a least-squares residual (several walls asking for more than the free components can give);
    • a pin that cannot be evaluated at the node (a field). Here the row keeps the zero reduction, as before.
  • Docs. subsystems/rotated-freeslip.md describes the reduction, the rebuild and the remaining warnings.

Tolerances and coordinate matches

  • Library: the least-squares residual is reported when it exceeds 1e-12 relative to |M_P g_P| (round-off of the pinned values).
  • Tests:
    • corner velocities are read by uw.function.evaluate at the lid's ends (0, 1) and (1, 1);
    • n·v at the corner is asserted below 1e-9, at a solve tolerance of 1e-9;
    • the corner velocity is asserted to 1e-9 against the exact values.

Tests

tests/test_1066_rotated_meets_essential.py, tier B. Five cases changed or added; all five fail on development:

  • test_the_corner_carries_the_pinned_value_into_the_wall_condition:
    • u_z = 1/20 gives the corner (−1/15, 1/20);
    • u_x = 1/20 gives (1/20, −3/80);
    • n·v is zero to 1e-9 in both, and nothing is reported.
  • test_each_end_of_the_lid_carries_its_own_pin: u_z is 1/20 on the left and 7/100 on the right.
  • test_a_pinned_value_that_follows_the_clock_is_read_at_every_solve: u_z = t/20, solved at t = 0, 2, 1 on one solver. Development kept t = 0's rotation and missed the condition at t = 2.
  • test_a_pin_that_is_a_bare_coordinate_...[u_z = z]: now silent; the free u_x takes the pin up.

The cases that still warn keep their assertions and pass: every component pinned (0.07), a field-valued pin, a value that cannot be evaluated, the largest size over a wall's nodes (0.05, where the floor's normal lies in the pinned component), and the partial-datum node.

Serial runs (macOS, 12-core Apple M4):

  • test_1066 and the rotated slice (0846, 1018, 1058, 1061, 1113, 1131, 1136, 1143, 1158, 1159): 126 passed;
  • 17 further files that use rotated free slip or the boundary normal traction: 210 passed, 1 skipped.

Not run: any parallel case.

  • build_rotation gains one allreduce (the live flag), which every rank calls.
  • The pinned datum is set on owned rows only, as the wall datum is.
  • The conflict report was already gathered over the ranks.

Relation to the convergence-reference PRs

A corner with a nonzero pin makes the solve a datum solve. A cold start then lifts the datum in its first increment and takes the datum path whose reference #1261 changes. This branch does not change the reference logic.

Review

Adversarial review, below.

Issue state

#939: fixed by this branch (label fixed-in-PR).

Underworld development team with AI support from Claude Code

…939)

Where a rotated free-slip wall meets a component Dirichlet wall, the
reduced constraint held the pinned components at zero: n_F.v_F = 0. With a
nonzero pin the corner missed the wall's condition (lid normal (3/5, 4/5),
u_z = 1/20 pinned: u_x = 0 and n.v = 0.04). #1127 warned; the condition
was unchanged.

The reduced row now takes the value -n_P.g_P (least squares over the free
components, exact for one wall), as a datum on that row; the corner gives
u_x = -1/15 and n.v = 0. A solver whose corner pin is anything but a plain
zero rebuilds its rotation at every solve, so a pin that follows the clock
is read again (a cached rotation dropped it). The warning stays where the
condition cannot hold: every component pinned, a normal wholly in the
pinned components, a residual the free components cannot take, or a pin
that cannot be evaluated at the node.

test_1066: the corner holds both conditions (u_z or u_x pinned), each end
of the lid its own pin, a clock-following pin at t = 0, 2, 1 on one solver,
and u_z = z read silently. These five fail on development. The rotated
free-slip note says the same.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 20, 2026 06:00

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 20, 2026

Copy link
Copy Markdown
Member Author

Adversarial review, round 1 (head 78a9545)

Finding:

  • Low. No parallel case exercises a corner pin. tests/parallel/test_1066_rotated_datum_parallel.py covers wall datums only. I ask the reviewer to run this file's corner cases at np 2 alongside it.

Issue state:

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Correction to round 1 of this review.

The round-1 record said this branch "inherits #941 and does not widen it". That is wrong.

PR #1265 (#941) sums every component across ranks. It should merge before this one, and this branch's np 2 corner cases should be run on top of it.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Second-desk review by H7 (a Claude review session running parallel probes on a 96-thread Linux workstation: Intel Xeon Gold 6240R, AVX-512, MPICH). The base is development e7e02b9, the merge base of the rotated batch (#1260, #1261, #1262, #1265, #1263). #1261, #1262, #1265 and #1263 change only rotated_bc.py, so each was measured by placing the branch's file, or a clean three-way merge of the files, in a build of e7e02b9. #1260 was built from its own branch. Parallel runs were under the MPI supervisor, at most 4 ranks.

Verdict: passes on top of #1265, with one cost finding. Merge after #1265.

Measured

test_1066's lid-corner fixture: lid normal (3/5, 4/5), u_z = 1/20 on Left, cell size 0.25, tolerance 1e-9. "#1263" below is #1265 + #1263; "+ #1261" adds #1261.

build np 1 np 2 np 3 np 2, corner on a seam (c941a / c941b, held by 2 ranks)
development (0, 0.05), n·v 0.04 the same the same the same
#1263 (-1/15, 0.05), n·v 0 the same the same the same
#1263 + #1261 (-1/15, 0.05), n·v 0 the same the same the same

Findings

  • Medium (cost): a corner pin that is a nonzero constant counts as live, so the rotation is rebuilt at every solve. Ten re-solves of the cavity at cell size 0.05, serial, median per solve:

    build pin 0.05 pin 0
    development 0.043 s 0.045 s
    A rotated corner carries the pinned value into the wall's condition (#939) #1263 0.112 s 0.043 s

    A lid-driven box with a constant nonzero pin pays this every step without reading anything new. A numeric constant could be read once and cached, and only a pin that contains the model clock, a coordinate or a field treated as live.

  • Low (tests): test_1066's new corner assertions read the corners with uw.function.evaluate, which is rank-local. Under mpirun, the ranks that do not hold a corner fail (np 2: 1 and 4 failures on the two ranks). The file is serial, so CI is unaffected. The parallel corner values above use global_evaluate and are exact.

Underworld development team with AI support from Claude Code

…a field

H7's review of #1263 found that any nonzero pinned value at a rotated
corner rebuilt the rotation at every solve (0.04 to 0.11 s a re-solve).
Only a pin that can change between solves needs that: one holding a
named expression or the clock (a symbol other than a coordinate) or a
field (an applied function). A number, or an expression of the coordinates
alone, is fixed on a fixed mesh, and a moved mesh tears the cache down. A
fixed pin's datum is now stored with the cached rotation and used as the
datum map when the rotation is reused (cached solves otherwise carry none).

normal= given a field (a mesh variable's .sym) passed the stray-symbol
check, since a field is a function of the coordinates, and failed inside
lambdify with a SyntaxError (H6; UNFILED 37). It is refused where the
condition is added, and in _normal_source for every other path, with a
message saying normal= takes an expression of the mesh coordinates.

test_1066: a fixed pin solved three times reuses the rotation on the 2nd
and 3rd solves and keeps u_x = -1/15 at the corner in each ([False, False,
False] on the branch before this commit); its docstring says the corner
tests are serial only (rank-local evaluate). test_1290: a field normal is
refused where it is added (no refusal before); a coordinate expression is
still taken.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Pushed eb9ee10, for H7's review and UNFILED 37:

  • A fixed pin keeps the cached rotation.
    • A pin is now live only if it can change between solves: a named expression or the clock (a symbol other than a coordinate), or a field (an applied function). A number, or an expression of the coordinates alone, is fixed. A moved mesh already tears the cache down.
    • A fixed pin's datum is stored with the cache and used as the datum map when the rotation is reused, since cached solves otherwise carry none.
    • test_1066: a fixed pin (None, 0.05), solved three times, reuses the rotation on the second and third solves, and keeps u_x = -1/15 at the corner in each. Before this commit it gave [False, False, False]. The clock test, the field test and the coordinate test still pass.
  • test_1066's docstring says its corner tests are serial only: they use a rank-local evaluate at the lid's ends.
  • normal= refuses a field (UNFILED 37).
    • A mesh variable's .sym passed the stray-symbol check and failed in lambdify with a SyntaxError.
    • It is now refused where the condition is added, and in _normal_source for every other path, with a message saying normal= takes an expression of the mesh coordinates.
    • test_1290 fails before the change (no refusal), and a coordinate expression is still taken. The refusal depends only on the expression, which is the same on every rank.
  • Serial runs (macOS, 12-core Apple M4): the 50 test files that use rotated free slip, add_fault_bc or fault contact, with test_0052, at levels 1 and 2: 557 passed, 1 skipped.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Re-check by H7 (a Claude review session running parallel probes on a 96-thread Linux workstation: Intel Xeon Gold 6240R, MPICH) at eb9ee10. It was built from the branch, with #1265's rotated_bc.py merged in (a clean three-way merge), on test_1066's lid-corner fixture (lid normal (3/5, 4/5), u_z pinned on Left, cell size 0.25).

Does the cache follow the pin? Three solves per row; np 1 and np 2 give identical results.

pin rotation reused corner (u_x, u_z), n·v
0.05, fixed False, True, True (-1/15, 0.05), 0 each time
clock, t/20 at t = 0, 2, 1 False, False, False (0, 0), (-0.1333, 0.1), (-0.0667, 0.05); n·v 0
named expression, 0.05 then 0.10 then 0.02 False, False, False follows each value; n·v 0
field, 0.05 then 0.10 False, False (0, 0.05), (0, 0.10); n·v 0.04, 0.08
0.05 z, solved twice, then the mesh stretched by 1.2 False, True, False (-0.0667, 0.05), the same, (-0.08, 0.06); n·v 0
  • The cache is invalidated correctly in every case. The clock, a named expression and a field rebuild the rotation at every solve, and a moved mesh tears it down, after which the coordinate pin is read again.
  • The field pin keeps the zero reduction (n·v = 0.04 at 0.05), which the body lists among the cases that still warn. Its rotation is rebuilt each solve, so a changed field is read.

The refusal is collective. add_rotated_freeslip_bc(0, "Upper", normal=<a mesh variable>.sym) on an annulus:

np development this branch
1, 2, 3 accepted on every rank (it fails later, UNFILED 37) ValueError on every rank

Cost. Ten re-solves at cell size 0.05, median per solve: pin 0.05 takes 0.043 s (0.112 s at 78a9545), and pin 0 takes 0.043 s. Our cost finding is resolved.

Tests. test_1066 (21) and test_1290 (2): 23 passed. test_1290 fails on development (1 failed, 1 passed).

The rank-local evaluate in test_1066's corner assertions (our earlier low finding) is unchanged. It does not matter while the file is serial.

#1263 passes. It merges after #1265.

Underworld development team with AI support from Claude Code

Brings in #1260, #1262 and #1265 (the summed normal this branch's corner
datum reads); the merge of rotated_bc.py is automatic.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Merged development, with #1265 at 853fea8, into this branch: 4c7f605. The merge of rotated_bc.py was automatic. Serial: the 50 rotated and fault test files with test_0052, levels 1 and 2, 566 passed, 1 skipped.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit dbe7733 into development Nov 24, 2026
10 checks passed
lmoresi added a commit that referenced this pull request Nov 24, 2026
The conflict in rotated_bc.py is two helpers added at the same place: this
branch's _datum_net_flux (UNFILED 36) and #1263's _refuse_a_field_normal
(UNFILED 37). Both are kept, with their call sites.

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.

2 participants