Skip to content

mesh contour tree: a forced leaf that tops its split tree keeps one split tree - #886

Merged
transfix merged 1 commit into
masterfrom
fix/mesh-contour-tree-forced-root
Oct 30, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/mesh-contour-tree-forced-root

Conversation

@transfix

Copy link
Copy Markdown
Owner

Since #879, MeshContourTree.RandomFieldsOnLoopyDomainsStillGiveTrees fails on every macOS recipe lane: compute_contour_tree (mesh): internal error: a leaf with no split neighbour on the annulus with seed 21. That reds the macOS jobs of every open PR (#862, #865, #868, #877, #882, #884), because PR runs build the merge with master.

Cause

On a domain that isn't simply connected, the merge runs out of leaves. It then forces the highest remaining vertex out as an upper leaf and moves its split-tree kids up to that vertex's split parent (remove_upper with kids). When the forced vertex also tops its split tree, sup[x] is kNone. Each kid was then left a root, which made the split tree a forest. A later lower leaf then found no split neighbour, and remove_lower threw.

Fix

In that case the other kids now hang from the highest kid, which kids lists last because it's built in sweep order. That kid's sdn_n/sdn_x take them on, and one split tree remains, as cutting the loop at the forced vertex allows. The other paths are unchanged.

Why only macOS

The test drew values with std::uniform_int_distribution, whose mapping from the generator is up to each standard library. libc++ takes the low bits of a draw and redraws while they're out of range; libstdc++ and MSVC do something else. So only macOS ever tested the field that breaks the merge. The test now applies libc++'s mapping by hand, so every platform tests the same fields: Windows reproduced the macOS failure exactly with it.

Testing

Local build on Windows (MSVC 19.44, against the cvcpkg deps prefix), with asserts on:

  • Before the fix, with the portable draws: the test fails on annulus seed 21, the same error as macOS.
  • After: mesh_contour_test 13/13, contour_tree_test 40/40, tf_overlays_test 18/18.
  • A temporary stress test, not committed:
    • Domains: five annuli and five tori from 3×3 to 12×4, plus a 5×5×3 tet block with a hole through it.
    • Fields: values 0–3, 0–1000 and continuous.
    • 3,000 seeds per surface domain and 600 for the block: 91,800 runs.
    • Each must give one tree, from the global minimum to the global maximum, and the same tree when stepped 3 at a time.
    • Fixed: all pass. Unfixed: 21 throws within the first two domains (both annulus and torus) before its cutoff, all "a leaf with no split neighbour".

…plit tree

On a domain that is not simply connected, the merge runs out of leaves
and forces the highest remaining vertex out as an upper leaf, moving its
split-tree kids up to its own split parent. When that vertex also tops
its split tree there is no parent: each kid became a root, the split
tree a forest, and a later lower leaf found no split neighbour
("internal error: a leaf with no split neighbour"). The other kids now
hang from the highest kid, so one tree remains.

MeshContourTree.RandomFieldsOnLoopyDomainsStillGiveTrees failed this
way on macOS only (annulus seed 21): libc++'s uniform_int_distribution
maps the generator's draws differently from libstdc++'s and MSVC's. The
test now draws with libc++'s mapping by hand, so every platform tests
the same fields.
@transfix
transfix merged commit a872192 into master Oct 30, 2026
23 of 26 checks passed
@transfix
transfix deleted the fix/mesh-contour-tree-forced-root branch October 30, 2026 04:09
transfix added a commit that referenced this pull request Oct 30, 2026
… wider loopy sweep (#891)

Follow-up to #886, which fixed the merge for a forced leaf that tops its
split tree. The tests now hold that case on every platform, whatever
the sweep draws:

- AForcedLeafThatTopsItsSplitTreeStillGivesATree: the 9x7 annulus field
  that broke the merge on macOS (seed 21 of the sweep, as libc++ draws
  it), written out.
- draw(): #886's by-hand libc++ mapping as one helper. The grid
  comparison's plateau fields use it too; they still drew with
  std::uniform_int_distribution, so each standard library tested other
  grids there.
- The loopy sweep adds a 12x4 torus and annulus and runs 200 seeds. With
  the case unhandled, about 1 field in 10 broke the 12x4 annulus and 1 in
  300 the 9x7 one, so 40 seeds of 9x7 caught it on one platform by luck.
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.

1 participant