Skip to content

Mesh generators: rank-0 conversion no longer hangs at np 2; coarse internal-boundary shell builds; a missing import (#953, #949) - #1131

Merged
lmoresi merged 5 commits into
developmentfrom
bugfix/segmented-generators-np2-953-949
Nov 13, 2026
Merged

lmoresi merged 5 commits into
developmentfrom
bugfix/segmented-generators-np2-953-949

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Three small mesh-generator defects from a probe of old issues against development 01dec8d. No solver file is touched.

What changes

  • SegmentedSphericalShell and SegmentedSphericalBall hang at np 2: gmsh2dmplex runs inside a rank-0 block that reaches a barrier #953: generators that convert on rank 0 hang at two ranks. SegmentedSphericalShell, SegmentedSphericalBall and AnnulusWithSpokes read their gmsh file inside a rank-0 block, on COMM_SELF, because they edit the DM before it is distributed. The conversion (_gmsh_to_h5) ended with a barrier on the world communicator, which only rank 0 reached. The barrier is now skipped for a caller on a one-rank communicator; every collective caller keeps it. After review: each of these generators now destroys its HDF5 viewer inside the rank-0 block and all ranks meet in a barrier after it, so the file is written and closed before the collective read that follows. That ordering is what the removed barrier was meant to give and, reached by one rank only, never did.
  • Spherical mesh generators: five defects found while fixing #946, left open #949 item 2: a coarse shell with an internal boundary does not build. SphericalShellInternalBoundary told its volumes and surfaces apart to within half a cell. With radii 1/2, 3/4, 1 and cell size 1/2 that is the whole gap between two spheres, and the constructor raised "Could not identify the spherical-shell volume". The OCC radii are exact, so the tolerance is now a quarter of the smallest gap between the radii.
  • Spherical mesh generators: five defects found while fixing #946, left open #949 item 5: Mesh.meshVariable_mask_from_label raised NameError: MeshVariable; it now imports it.

Tests (written first)

test on development on this branch
tests/parallel/test_1176_rank0_generators_parallel.py: the three generators at np 2 hold the cells they have on one rank (the one-rank count comes from a single-rank child run in the same environment) hangs; the supervisor kills it (exit 124) 3 passed on every rank at np 2, 3 and 4 (np 2 to 5 in the independent review)
tests/test_1177_spherical_generator_fixes.py: the coarse shell builds, with Inner and Outer cells and its three registered radii RuntimeError passes
the same file: a mask from a label is 1 on the labelled vertices and 0 elsewhere NameError passes

A regression here is a rank blocked in an MPI barrier, which a pytest timeout does not interrupt; the supervisor that scripts/test.sh runs every parallel job under is what turns the hang into a failure. Under MPICH the shell case completes on the unfixed code, so the ball and the spoked annulus are the cases that guard the fix (both found in review).

Verification

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

check result
serial test files that build these meshes or use extract_region (181 tests, at e95fe4e) 179 passed; the 2 others are test_0858's np 3 and np 5 cases, which could not start from our copied test directory (they launch a helper script by path). Run in the repository, the np 3 case passes; the np 5 case was not rerun
parallel/test_1176, test_1175_shell_region_labels, test_0770_submesh_extract_mpi at np 2 and np 3, each with an empty mesh cache so the conversion runs 15 passed on every rank
the same parallel files plus test_1071_spherical_shell_geoid_parallel at np 2 and np 4 (at e95fe4e, before the review fixes) 16 passed on every rank
test_1177 serial, empty cache 2 passed
style gate; scripts/check_test_coverage.py pass; all 447 test files reachable

Not run: above np 4; the full suite (left to CI).

Not in this PR

From #949: item 1 (a CubedSphere crease), and items 3 and 4, which snap refined vertices onto the sphere and so move recorded accuracy anchors. Item 3 (the internal surface is not on its sphere after refinement) is being handled with the design question it belongs to. A side finding: SegmentedSphericalSurface2D does not build in serial either (PETSc error 75); not addressed here.

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

- Generators that convert their gmsh file inside a rank-0 block
  (SegmentedSphericalShell, SegmentedSphericalBall, AnnulusWithSpokes) must
  build at two ranks with the cells they have on one. On development the
  constructors hang; the file carries a timeout so that is a failure.
- SphericalShellInternalBoundary with radii 1/2, 3/4, 1 and cell size 1/2 must
  build. On development it raises.
- meshVariable_mask_from_label must return a mask. On development it raises
  NameError.

Underworld development team with AI support from Claude Code
…lumes told apart by radius; a missing import (#953; #949 items 2 and 5)

- _gmsh_to_h5 ended with a barrier on the world communicator. Generators that
  convert on rank 0 alone, on COMM_SELF, reached it on one rank only and never
  returned at two ranks. The barrier is now skipped for a COMM_SELF caller.
- SphericalShellInternalBoundary told its volumes and surfaces apart to within
  half a cell, which on a coarse shell is the whole gap between two radii. The
  tolerance is now a quarter of the smallest gap between the radii.
- Mesh.meshVariable_mask_from_label imports MeshVariable.

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

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.

claude and others added 3 commits November 13, 2026 16:34
…#1131)

The segmented generators and AnnulusWithSpokes write their edited DM to HDF5 on
rank 0 through a one-rank viewer and every rank then reads the file
collectively. The viewer was never destroyed and nothing ordered the write
before the read; the barrier removed earlier in this branch was meant to, and
never ran in parallel. Each generator now destroys its viewer inside the
rank-0 block and all ranks meet in a barrier after it.

_gmsh_to_h5 decides on the communicator's size, not its identity, so any
one-rank communicator skips the world barrier. The parallel test loses a
timeout marker that cannot interrupt a blocked barrier, and says which cases
guard the fix under MPICH.

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