Skip to content

SegmentofSphere snaps its refined walls about its centroid (#949, item 4) - #1278

Merged
lmoresi merged 2 commits into
developmentfrom
bugfix/spherical-generators-949
Nov 20, 2026
Merged

lmoresi merged 2 commits into
developmentfrom
bugfix/spherical-generators-949

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

A refined SegmentofSphere with a centroid off the origin now keeps its walls on their spheres about the centroid. This is item 4 of #949. Item 1 is still live and is measured here, not fixed.

What changes

Item 4: fixed.

  • On development. The refinement callback snapped the Upper and Lower vertices onto spheres about the origin, not about centroid.
    • With the centroid at (0, 0, 0.3) and cell size 0.25, one refinement leaves an Upper vertex 0.0108 off its sphere.
    • The issue measured Lower vertices 0.25 to 0.55 from the centroid, against a wall at 0.547, at its own size.
    • The hierarchy guard holds some vertices back and warns.
  • Now. The callback snaps about the centroid. At the origin the arithmetic is the same as before.

Item 1: still live, and wider than the issue records. CubedSphere(simplex=True) holds wall vertices back at refinement, because the #946 flips act inside each wall patch and miss a crease on a curve between two patches. Measured on development, vertices held back by the refinement guard:

numElements refinement 1 refinement 2
2 0 24
3 1 21
4 0 0

The issue recorded numElements 2 as free of the crease; at refinement 2 it is not.

The transfinite surface arrangement does not cure it. With gmsh's Left (the default), Right, AlternateLeft and AlternateRight:

  • AlternateRight is the best: 0 and 4 vertices held at numElements 3;
  • numElements 2 at refinement 2 holds 24 under every arrangement.

So the fix is the cross-patch flip the issue names, not a diagonal choice. The TODO(BUG) in spherical.py now carries this table. A different default arrangement would also change every simplex CubedSphere users already build.

Tolerances and coordinate matches

The test asserts that each wall vertex lies at its radius from the centroid to 1e-12 relative. It is a geometric property of the snapped vertices, not a match between two meshes.

Tests

tests/test_0949_segment_of_sphere_snaps_about_its_centroid.py, level 2, tier B. A segment with cell size 0.25 is refined once, with its centroid at the origin and at (0, 0, 0.3), and the Upper and Lower vertices must lie on their spheres about the centroid. Off the origin the test fails on development (0.0108 off); at the origin it passes there too.

Serial runs (macOS, 12-core Apple M4): the new test, test_1177_spherical_generator_fixes, and the test files with "spher" in their names, 105 passed, 12 skipped, 1 xfailed.

Review

Adversarial review, below.

Issue state

#949:

Label fixed-in-PR for item 4 only.

Underworld development team with AI support from Claude Code

…m 4)

The refinement callback snapped the wall vertices onto spheres about the
origin, not about `centroid`. With the centroid at (0, 0, 0.3), refinement
moved wall vertices off their sphere: on development an Upper vertex ends
0.0108 off its sphere at cell size 0.25 (the issue measured Lower vertices
0.25 to 0.55 from the centroid against a wall at 0.547, at its own size),
and the hierarchy guard holds some back and warns. The callback now snaps
about the centroid; at the origin nothing changes.

Item 1 (CubedSphere simplex creases across wall patches) is still live, and
wider than recorded: its TODO now carries the measurement, including
numElements 2 at refinement 2 (24 vertices held) and that no transfinite
arrangement cures it.

test_0949: the refined walls lie on their spheres about the centroid, at
the origin and off it, to 1e-12 (fails on development off the origin).

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

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 d9bf875)

  • Rank asymmetry. The callback acts on each rank's local coordinates with the same centroid everywhere. It adds no communication, as before. The labelled points are read rank-locally, as before.
  • The origin case. With centroid at the origin, centre + offset * (r / |offset|) is the old coords * (r / |coords|) up to rounding in the subtraction and addition of zero, which is exact. The origin case of the test passes on both branches.
  • The Lower wall at the centroid. The 1e-16 guard against a zero radius is kept, now on the distance from the centroid.
  • Tests that cannot fail. The off-origin case fails on development (0.0108 off the sphere) and passes here. The origin case is the control.
  • CI reach. The test_09* batch in scripts/test.sh collects it.
  • Item 1. It is left open on purpose, with its measurement in the TODO and the body. The arrangement experiment used a temporary environment switch, which is not committed.

No findings.

Issue state: #949 item 4 is fixed by this branch; item 1 is still live; items 2, 3 and 5 were fixed earlier.

Underworld development team with AI support from Claude Code

test_0949 matched no glob: the serial band jumped from test_08* to the 10xx
lines, and check_test_coverage failed every shard of #1278. Batch 5 is the
lightest shard (22.6 min).

Underworld development team with AI support from Claude Code
@lmoresi

lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Correction to the round-1 review. It said that the test_09* batch in scripts/test.sh collects the new test. There was no such line: the serial band went from test_08* to the 10xx lines, so check_test_coverage failed every shard. Fixed in this branch: batch 5 tests/test_09*py, with a comment. check_test_coverage.py now passes locally (497 files reachable).

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 66fd34c into development Nov 20, 2026
10 checks passed
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