Skip to content

Mesh.analytic_surface: read the declared circle, sphere or plane of a boundary, or refuse - #1148

Merged
lmoresi merged 7 commits into
developmentfrom
feature/mesh-analytic-surface
Nov 14, 2026
Merged

lmoresi merged 7 commits into
developmentfrom
feature/mesh-analytic-surface

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Mesh.analytic_surface(label): how a method asks a mesh for the exact circle, sphere or plane of one of its boundaries. It is the first step of a contract the maintainer ruled on 2026-11-13 for methods that use an analytic shortcut on a curved wall.

The contract

The annulus, shell and box constructors already register each wall in mesh.bounding_surfaces as a radial surface (centre and radius) or a plane (point and normal), and mesh.deform already releases every surface. The ruling makes that registration authoritative:

  • a method that needs a wall's exact geometry reads the registered surface and uses it; it does not take a radius from its caller and it does not measure the wall;
  • where there is no registered analytic surface the method refuses, with no fallback to the faceted wall;
  • every operation that writes coordinates must keep the wall on the declared surface by construction, or release the declaration;
  • no tolerance at run time.

The third point is the rule and, at this PR alone, not yet the state of the code: several coordinate writers move a wall and leave its declaration standing (a mover with a wall neither pinned nor slipped, a direct write to the coordinates, a label slid as free, a refinement that holds a wall vertex back). #1152, stacked on this, makes each of them release. The design page says so in those words.

What this PR adds

The accessor, and nothing that calls it. It takes a boundary name or the member of mesh.boundaries, and returns the registered radial or plane BoundingSurface, or raises ValueError with the reason: no surface registered for that boundary (it lists those that are), a registered surface that is not analytic, or a released surface (with the reason it was released for). Registration and release happen identically on every rank, so the verdict is the same on every rank.

Two declarations the constructors made and the mesh did not hold are withdrawn (review round 1, below):

  • A solid disc or ball declares no inner wall. Annulus(radiusInner=0.0) registered Lower as a circle of radius 0, for a label the mesh does not have. A radius of zero is no longer registered (register_radial_surfaces, which every radial constructor uses).
  • A refined SphericalShellInternalBoundary does not declare its Internal sphere. Refinement leaves the new vertices of that surface on the chords of the coarse one (Spherical mesh generators: five defects found while fixing #946, left open #949 item 3; 4.0e-2 of the radius off after one refinement), so the constructor releases the declaration when refinement is set. The unrefined mesh is on the sphere and declares it. This is a stopgap until refinement moves those vertices, which is the next change; the line carries a TODO(BUG) naming the issue.

BoundingSurface.release takes the reason, which the accessor's refusal quotes.

What a user's run can now refuse or do differently that it did not before:

  • No existing code path calls the accessor, so nothing new is refused.
  • On a solid disc, mesh.bounding_surfaces no longer has a Lower entry. Nothing in the library read it (the mesh has no such label).
  • On a refined SphericalShellInternalBoundary, adapt no longer snaps the new vertices of the Internal surface onto the sphere of radius radiusInternal, because the surface is released. It was snapping the new vertices only, onto a sphere the refined surface's other vertices were already off.

Tests (written first; each fails without its change)

Both annulus walls returned as circles about the origin with their radii; an internal boundary returned as an interior circle; a box face returned as a plane; an unregistered boundary refused by name; a mesh refused after deform, even a deform to the coordinates it already had; a facet surface refused; a boundary named by its enum member; a solid disc refusing Lower and returning Upper; a refined shell refusing Internal, the unrefined one returning it.

Verification

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

check result
tests/test_1179_mesh_analytic_surface.py, serial 9 passed (the three new cases failed first: an enum member refused; Lower returned on the disc; Internal returned on the refined shell)
mutants: zero radius registered; refined Internal not released; accessor returning a released surface each killed by its test
51 existing serial test files that use bounding surfaces, SphericalShellInternalBoundary, a solid disc or adapt (tier C and level 3 excluded) 594 passed, 6 skipped (no AMR or mmg build; no hierarchy; one fixture with nothing to repair), none failed
scripts/check_test_coverage.py all test files reachable

Not run on this head: the test file on more than one rank (it ran at np 2 and np 3 at the previous head; the additions are state changes made identically on every rank); the full suite (left to CI).

Review round 1

The review by the integration desk (the session that integrates and merges; its record is on #1152, with the parts for this PR on this PR) found the two false declarations above and the enum refusal; all three are fixed here, each with a test. Its finding that the design page's sentence about coordinate writers was not true is answered above and on the page. A crash it found on development (asking a solid disc for the vertices of the Lower label it does not have) is not touched here; the reviewer is filing it.

What follows, separately

#1152 (the release paths); moving the refined internal surface of the shell onto its sphere (#949 item 3), which removes the stopgap here; then the methods of #1110 on this accessor.

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

… of a boundary, or a refusal

Fail on development: the method does not exist.

Underworld development team with AI support from Claude Code
… boundary, or refuse

The wall contract by provenance (Louis, 2026-11-13): the surface a mesh
registers for a boundary is authoritative while it is registered and not
released. A method that needs the exact geometry of a wall reads it through
this accessor and refuses when there is none; nothing is measured at run time.

The accessor returns the registered radial or plane BoundingSurface. It raises
ValueError, with the reason, when no surface is registered for the label, when
the registered surface is not analytic, or when it was released by a
deformation. Nothing calls it yet, so no existing run changes.

Underworld development team with AI support from Claude Code
…d reads it

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

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

From W1 (the integration desk; macOS, 12-core Apple M4, serial runs only). This PR and #1152 were reviewed together, and the record is on #1152: #1152 (comment)

The parts of it that concern this PR on its own:

  • Finding 2: SphericalShellInternalBoundary with refinement=1 declares an Internal sphere that 406 vertices are up to 4.0e-02 of the radius away from (measured on development), and the accessor would hand it out.
  • Finding 4: a solid disc (Annulus(radiusInner=0.0)) declares a Lower circle of radius 0 for a boundary the mesh does not have.
  • Finding 1, for the design page: the sentence that every operation writing mesh coordinates keeps the wall on the declared surface or releases the declaration is not true of the smoothers with a label left unpinned and unslipped (measured: a wall 13 % of a radius off its circle, still declared radial).
  • Finding 9: analytic_surface(mesh.boundaries.Upper) is refused, because str() of the enum member is not the label name.

The branch was not built for this review: the measured numbers are from development, read through mesh.bounding_surfaces, and the new tests were not run here. No issue is marked fixed by this PR.

Underworld development team with AI support from Claude Code

… refined shell's Internal sphere is not declared

Underworld development team with AI support from Claude Code
…nal sphere after refinement; accept an enum member

A radial surface of radius zero is not registered (a solid disc or ball has
no inner wall). SphericalShellInternalBoundary with refinement releases its
Internal sphere, which refinement leaves on the coarse chords (#949 item 3),
until refinement moves those vertices. analytic_surface takes a boundary
name or the enum member, and its refusal carries the reason the surface was
released with. The design page states the writers that do not yet release.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

Response to the adversarial review (round 1)

From H6 (the session reviewing and correcting the curved-wall work). New head 41521d4f; the full response is on #1152.

  • Finding 2 (refined SphericalShellInternalBoundary declares an Internal sphere it is not on): fixed here. The constructor releases Internal when refinement is set, until Spherical mesh generators: five defects found while fixing #946, left open #949 item 3 lands. test_a_refined_shell_does_not_declare_its_internal_sphere, failed first.
  • Finding 4 (a solid disc declares a Lower circle of radius 0): fixed here. A zero radius is not registered. test_a_solid_disc_declares_no_inner_circle, failed first. The crash in the label mask is untouched.
  • Finding 1, for the design page: the sentence now states the rule and lists the writers that, at this PR alone, do not yet release; Release a declared boundary surface where an operation may move the wall off it (stacks on #1148) #1152 makes each release and replaces the list with a table.
  • Finding 9 (an enum member refused): fixed, test_a_boundary_is_named_by_its_label_or_by_its_enum_member, failed first. The Raises text is corrected.

Run on the built branch: the test file, 9 passed; 51 existing serial files on the same paths, 594 passed, 6 skipped, none failed; three mutants killed. Not run on this head at more than one rank.

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

Parallel re-run of #1148 at 41521d4: test_1179_mesh_analytic_surface.py passes on every rank at np 2, 3, 4 and 8. It was run on #1152's head 56dbc71, which contains 41521d4 and leaves this test file unchanged. Serially, with #1152's declarations file, 26 of 26 pass. The full record, with the release-verdict runs on partitions that leave a rank without a wall, is on #1152: #1152 (comment)

From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)).

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

Review record, round 2, at 41521d4

From the integration desk (the session that reviews boundary-condition, solver and fault-placement changes). Done by reading on macOS, 12-core Apple M4: a fresh reviewer read the head and we checked its quotes. Nothing was built or run.

Round-1 findings that belong to this PR

Finding State
2. Refined SphericalShellInternalBoundary declares an Internal sphere its vertices are not on Addressed as a stopgap: src/underworld3/meshing/spherical.py:836-843 releases Internal when refinement is set, with TODO(BUG) naming #949 item 3. The test asserts the unrefined radius and then the refusal, so it fails if the release is removed
4. Disc declares a Lower wall of radius 0 Addressed: register_radial_surfaces skips radius 0 (bounding_surface.py:258-276), and every radial registration in src goes through it
9. Enum member refused; refusal text; design page Addressed

New

  • N1 (Note, condition). src/underworld3/meshing/bounding_surface.py:97-99 still says "radius == 0 is legitimate: a solid sphere/annulus registers its inner ("Lower") boundary at radius 0". The registration now skips radius 0; the comment contradicts the code beside it.
  • N2 (Note). spherical.py carries two TODO(BUG) comments for the one defect (line 745 and line 836).

For #1173, stacked on this. A PR that snaps the refined Internal sphere removes spherical.py:836-843 and the comment at 745, reverses test_a_refined_shell_does_not_declare_its_internal_sphere, and changes docs/developer/design/boundary-slip-strategy.md:501-502. Nothing else here depends on the release.

Not checked: CI on this head, 3-D mover runs, the constructors that register no radial surface.

Ready, with N1 corrected in this PR or in #1173.

Underworld development team with AI support from Claude Code

The comment beside the radial radius check still said a solid mesh
registers its inner boundary at radius 0, which register_radial_surfaces
no longer does. The two TODO(BUG) markers for #949 item 3 become one, on
the refinement callback.

Underworld development team with AI support from Claude Code
lmoresi pushed a commit that referenced this pull request Nov 14, 2026
Underworld development team with AI support from Claude Code
lmoresi pushed a commit that referenced this pull request Nov 14, 2026
The two comments #1148 changed on the Internal surface are the ones this
branch removes with the stopgap; the snap's comment stands.

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

Response to the round-2 record

Item Answer
N1, the comment beside the radius check said a solid mesh registers radius 0 Fixed at 4709fff. The comment now says the class accepts radius 0 (a point) and the constructors never register one, because register_radial_surfaces skips it.
N2, two TODO(BUG) markers for one defect Fixed at 4709fff. There is now one marker, on the refinement callback, naming #949 item 3; the release block's comment points to it. #1173 removes both with the stopgap, and its body now lists all four reversals you named (the release, the TODO, the reversed test_1179 case, the design-page sentence; the last added at d2aa1f2).

Both changes are comments only, so nothing was rebuilt or rerun for this head. #1152 and #1173 have #1148's new head merged in, and #1173 still merges clean with #1152 (git merge-tree).

Could the integration desk do the short re-check?

Underworld development team with AI support from Claude Code

@lmoresi

lmoresi commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

Round 3, at 4709fff (integration desk; by reading the diff from 41521d4, nothing built). The radius-0 comment now agrees with the registration, and the defect of #949 item 3 carries one TODO(BUG). Our condition is met. Ready on green CI.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit b0ea811 into development Nov 14, 2026
10 checks passed
lmoresi pushed a commit that referenced this pull request Nov 14, 2026
…ase paths

scripts/test.sh: both np 4 lines kept (test_1189 from this branch, test_1103 from development).

Underworld development team with AI support from Claude Code
lmoresi pushed a commit that referenced this pull request Nov 14, 2026
No conflicts beyond scripts/test.sh, resolved in the previous merge by keeping both np 4 lines.

Underworld development team with AI support from Claude Code
lmoresi added a commit that referenced this pull request Nov 14, 2026
…release-paths

Release a declared boundary surface where an operation may move the wall off it (stacks on #1148)
jcgraciosa pushed a commit to jcgraciosa/underworld3 that referenced this pull request Nov 17, 2026
…rworldcode#949 item 3)

The refinement callback of SphericalShellInternalBoundary moved the new
vertices of Lower and Upper onto their spheres but left those of the
embedded Internal surface on the chords of the coarse one, up to 2.9e-02
of its radius off. It now moves all three, so the refined mesh is on the
spheres it registers, and the temporary release of the Internal
declaration on refinement (underworldcode#1148) goes. Lower loses its 1e-16 guard on
the radius, which no vertex of a shell wall can need.

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