Repository navigation
#946: refining a spherical mesh no longer folds cells; a missing label moves nothing (#903) - #952
Conversation
…el moves nothing (#903) Parked work in progress: the serial tests pass, and the parallel test, the PR and the review are still to come (see the end). gmsh meshes a sphere in a parameter plane. Near a pole it can join four neighbouring wall nodes along the long diagonal, and a structured surface splits every quadrilateral the same way, so the wall creases toward the centre. On an inner or internal wall, the pocket under the crease is meshed as one cell with all four vertices on the sphere. The refinement callback then snaps the crease midpoint outward past the unlabelled midpoint of the other diagonal and folds the children. - meshing/_sphere_surface.py: `_flip_creased_sphere_edges` runs Lawson flips to the convex hull on every gmsh surface whose nodes lie on a sphere about the centre, between generate(2) and generate(3). It is called by SphericalShell, SphericalShellInternalBoundary, SegmentofSphere, CubedSphere, the segmented shell and ball, and both regional boxes. - Mesh._build_refined_hierarchy applies every refinement callback through `_apply_refinement_callback`. Of each cell the callback inverted, the vertex it moved furthest goes back where refinement placed it, until none is inverted, with a warning. Vertex flags are shared over the coordinate DM, so every copy agrees. - petsc_dm_find_labeled_points_local returns an empty array for a missing label instead of [0] (#903). A refined ball had a NaN vertex. Tests: tests/test_0001_sphere_refinement_folds.py has 7 cases. 6 fail on development 1f87430 (creases, folded cells, no warning, NaN) and all pass here. tests/parallel/test_0001_..._parallel.py has not run yet (np 2 and 4 go to kaiju). Left to do: - Merge origin/development (#947), and re-record test_1111's shell, whose mesh changes with the flips. - Run the 24 test files that build spherical meshes, on kaiju. - Measure the guard's cost on large meshes. - The segmented shell and ball still warn, because their Upper (and Lower) labels hold vertices off the wall: Upper reaches r 0.297 on the ball and r 0.72 on the shell. That is a labelling bug the guard now exposes. - CubedSphere(numElements=3) holds one vertex back: a crease on a patch-boundary curve, which a per-surface flip cannot reach. - TODO(BUG) markers: the internal-boundary shell's radius tolerance, and its unsnapped Internal surface. Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
…11's shell goes back to 0.5 (#946) The segmented shell and ball tagged their volume with 30, which is Upper's value, so the DM's Upper label took interior vertices (down to r 0.297 in the ball), and the refinement callback snapped them onto the outer sphere: 43 vertices of a refined ball and 2 of a shell had to be held back. The volume is now 99999, as in the other generators. New tests in test_0001 cover both meshes and fail without the change: every vertex a wall label carries lies on that wall, and refining leaves no cell inverted and no warning. With the walls triangulated as convex hulls, test_1111's shell needs no detour: - it is back at cell size 0.5, where the old mesh had folded; - its answer is recorded on the new mesh, 1.7753740524 at 5 / 17 iterations; - a dense SVD coarse solve set by hand gives the same value and iterations, in 91 s against 10 s. Its fold gate is removed. The hierarchy no longer lets a cell fold, so the gate could not fail; test_0001 asserts that directly. CubedSphere(simplex=True, numElements=3) still holds one vertex back: a crease on a curve between two wall patches, which the surface-by-surface flips do not reach. It is marked with a TODO(BUG). Underworld development team with AI support from Claude Code
…entry - custom-meshes.md: what the refinement-callback guard does and what its warning means. - GMSH_INTEGRATION_GUIDE.md: the guard, and that a gmsh generator meshing a sphere calls `_flip_creased_sphere_edges` between generate(2) and generate(3). - CHANGELOG: #946 and #903. Underworld development team with AI support from Claude Code
…ing, both #903 lookups, collective-safe parallel test Findings of the adversarial review of 20e352c: - #903's second lookup, uw.discretisation.petsc_dm_find_labeled_points_local, also returned [0] for a missing label; it now returns an empty array too. - The ball test could not fail on #903: the guard held the moved vertex back and the coordinates stayed finite. It now fails on the guard's warning. - The eight generate-flip-generate blocks are one helper, _generate_volume_on_convex_spheres(centre). SegmentofSphere passes its centroid, which the old call ignored. RegionalGeographicBox goes back to plain generate(3): its walls are not spheres, so the flip never acted there. - The guard returns its count, and the hierarchy warns once, with the second pass's sum. The first pass's vertices are held again by the second, so the sum is the total; before, one warning came from each pass. - The parallel test reduces every flag before it asserts, so a failure fails on every rank instead of hanging the others. Its inversion check copes with a rank that has no cells. A host whose gmsh builds the creased shell with no pocket skips that case. It is tier C until it has run at np > 1. - The docs and the CHANGELOG no longer claim more than was measured: which cells are checked, patches convex rather than the hull, the flip's cost, both lookups, and the CubedSphere crease that remains. - TODO(BUG) markers for two pre-existing defects found on the way: SegmentofSphere's callback snaps about the origin, not the centroid; and meshVariable_mask_from_label raises NameError (MeshVariable is not imported). Underworld development team with AI support from Claude Code
Hyperion ran the parallel file against development eddab70, which has no guard, at np 2 (with a stub for the missing helper module): - the folding callback left 2 inverted cells and no warning; the test failed; - the shell as built left 5 inverted cells and no warning; the test failed; - the creased-shell test skipped, because it skipped on any missing warning, and an unguarded build never warns. That skip is now taken only when there is no warning and nothing is inverted (a host whose gmsh built no pocket). Inverted cells without a warning fail. On this branch all three pass at np 2 and 4 on Linux, so the file is tier B. Underworld development team with AI support from Claude Code
Adversarial review, round 1 (20e352c against development eddab70)A separate agent reviewed the branch against Findings and what was done
Attacks that failed
Issue verdicts
Underworld development team with AI support from Claude Code |
…rallel test reads every level Hyperion's review of 2056044 found that the guard can leave inverted cells in parallel: - CubedSphere(numElements=2, simplex=True, refinement=2) has 5 inverted cells at np 8. - The callback moves a wall vertex only on ranks that hold a labelled facet of that wall, so copies of a vertex differ (by up to 0.0994). - Each rank checked its own copy, and the owner's value won at the clone. The fixes: - Every copy now takes the move made on any rank that moved the vertex, before any cell is checked. The moved copies are averaged; they agree, as the callback is a function of position. - The reconciled coordinates are written back whether or not anything is held. - This also fixes, at any rank count, wall vertices that ended off their wall depending on the partition, which predates the branch. - The parallel test read the clone (mesh.dm), so a rank-local mutant passed. It now checks every level of the hierarchy as well. - A new case has rank 0 alone nudge every vertex: the copies across the partition must take the move. - The hold-back loop excludes held vertices, so it ends even on non-finite coordinates. - A callback that writes a non-finite coordinate raises, where it was reported as a fold. - The warning says its total runs over the hierarchy's levels. - The residual is stated with measured counts. Meshes made of patches hold back up to 61 vertices at refinement 2. It is carried in the CHANGELOG and the CubedSphere TODO (#949). Underworld development team with AI support from Claude Code
Round 2: fixes for the independent review's findings (0306f83)Hyperion's independent review of 2056044 will post its own record. What this round changed in answer to it:
The rerun at np 2, 4 and 8, with mutants of the sharing and the reconciliation, is with hyperion. Underworld development team with AI support from Claude Code |
Copies agreeing does not show that every rank that holds a vertex held it. With the hold flagged on one rank only, hyperion found the copies still agreed at np 8, but 31 vertices were held instead of 24 and the mesh differed from the serial one. The new case kicks about a fifth of a box's interior vertices far enough to turn a cell over (267 held, serially) and compares the owned vertices with a serial child's, vertex for vertex. At np 2 about nine kicked vertices lie on the partition interface. Underworld development team with AI support from Claude Code
Adversarial review of #952 at 2056044 against eddab70Independent pass on hyperion (Linux, PETSc 3.25.3), np 1-8, from the diff; findings formed before reading the PR body and round 1, and none is addressed there. Probes are on hyperion in Status at 4f634b0: findings 1 to 3 and 6 to 8 addressed, with the reruns below. This record is of the pass at 2056044, kept as found. Verdict at 2056044: not ready. The serial fix holds. The guard's parallel contract does not, and the parallel test cannot detect that. Finding 1 was reproduced separately from a fresh script: Findings
Attacks that failed
Could not testmacOS, CI's runners, kaiju, np above 8; reading a pre-change checkpoint; solves on a mesh with the np 8 inversions; #949 items 2, 3, 5. Issue adjudications
Merge conditions
Underworld development team with AI support from Claude Code Rerun at 0306f83Fresh probe ( Mutants: reconciliation removed fails the new case at np 2 Rerun at 4f634b0
Underworld development team with AI support from Claude Code |
Recorded on hyperion at np 2 with the conda-forge stack CI uses, from the skip messages of 27df1f3: test_1063's iso, ti and raw-gauge annulus (430 cells), test_1064's annulus (612), shell (1395) and internal-boundary shell (1991), and test_1066's datum (612). Each sits beside its macOS anchor; the one whose fingerprint matches is used. The two shells are as development builds them; #952's wall flips change those meshes, and a skip will then print the values to add. Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
…from-mesh-906 Underworld development team with AI support from Claude Code # Conflicts: # docs/developer/CHANGELOG.md # src/underworld3/discretisation/discretisation_mesh.py
Refining a spherical mesh no longer folds cells (#946). A missing label no longer moves vertex 0 (#903).
The bug
gmsh meshes a sphere in its (longitude, latitude) parameter plane. Near a pole it can join four neighbouring wall nodes along the long diagonal of their quadrilateral instead of the short one, and the faceted wall then creases toward the centre.
On the inner wall of a shell (and either side of an internal surface), the pocket under such a crease lies inside the domain. The volume mesher fills it with one cell whose four vertices are all on the sphere. Regular refinement only subdivides that cell. The refinement callback then snaps the midpoint of the creased edge outward onto the sphere, past the midpoint of the cell's other diagonal, which carries no wall label and stays put, and the children between them turn inside out.
The change
meshing/_sphere_surface.pyadds_generate_volume_on_convex_spheres(centre), which every generator with spherical walls calls in place ofgenerate(3). It meshes the surfaces, then Lawson-flips every creased edge of each spherical surface until none is left, then meshes the volume.Mesh._build_refined_hierarchyapplies every refinement callback through_apply_refinement_callback.petsc_dm_find_labeled_points_local(Cython and Python) return no points for a missing label, where they returned[0]. A refined ball (radiusInner=0) had moved vertex 0 to the origin and then divided by its zero radius, which gave a NaN coordinate.Tests
tests/test_0001_sphere_refinement_folds.py, 11 cases. Every one asserts an exactness property that holds on any host:
On development eddab70, 10 of them fail (on Linux, hyperion); all 11 pass here.
tests/parallel/test_0001_sphere_refinement_folds_parallel.py, tier B, 4 cases. Every vertex copy is checked against its owner's on every level of the hierarchy, not only on the cloned DM. The fourth case has one rank alone move vertices, and every copy across the partition must take the move. The first three passed at np 2 and np 4 on Linux; [round-2 rerun at np 2, 4 and 8 on hyperion].
The files that build spherical meshes were run on hyperion (Linux, CI's conda-forge environment) on this branch and on development eddab70:
[XPASS(strict)], on test_lu_subsolve_fieldsplit_constrained_matches_default_nitsche_response: a strict xfail that now passes on development too, so it predates this branch. The file takes over 90 minutes on hyperion.test_1064's spherical accuracy anchors skip on both builds on Linux. Neither mesh matches the recorded fingerprint (1417 cells; development 1395, here 1386), so the flips do not change what that test asserts on this host, and nothing is re-recorded.
Issues
meshVariable_mask_from_label's NameError.CI note. The new parallel file shifts the MPI phase's six-file batches by one. #951 met a hang when test_1062 came to share a process with test_1064, and the dev hub is tracking it (a suspected cross-test state leak, perhaps #950). This branch may meet the same shift.
Reviews:
#903 and #946 carry the fixed-in-PR label. A merge to development does not close issues, so they move to fixed-in-development on merge, per the repo's issue-state rule. Its finding on test_1064's spherical anchors needed no change: they skip on Linux on development already.
Underworld development team with AI support from Claude Code