Skip to content

Add space-filling curve mesh ordering - #4474

Open
garth-wells wants to merge 34 commits into
mainfrom
garth/sfc-mesh-ordering
Open

Add space-filling curve mesh ordering#4474
garth-wells wants to merge 34 commits into
mainfrom
garth/sfc-mesh-ordering

Conversation

@garth-wells

Copy link
Copy Markdown
Member

Summary

  • Add Morton and Hilbert space-filling-curve reorderers for mesh-cell centroids.
  • Generalise mesh cell reordering so it can dispatch to either a dual-graph or geometric reorderer.
  • Expose the SFC reorderers through the Python graph module and add C++/Python coverage.

Validation

  • clang-format --dry-run --Werror on changed C++ sources
  • ruff check and ruff format --check on changed Python sources
  • Focused C++ implementation and test translation units compiled with Spack GCC 16.1 and Spack Boost 1.90 under -Wall -Werror -Wextra -pedantic

AI assistance: I used Codex (GPT-5) to draft parts of this PR. I reviewed, edited, tested, and take responsibility for the final contribution.

Base automatically changed from garth/static-mdspan-assembly-extents to main September 3, 2026 04:16
Comment thread python/demo/demo_partition.py Fixed
@garth-wells garth-wells added the enhancement New feature or request label Sep 3, 2026
garth-wells and others added 2 commits September 3, 2026 08:34
compute_cell_centroids performs a collective MPI::distribute_data call
that can throw on a rank-local condition, but it was invoked outside
the try/MPI_Allreduce guard added for cell reordering/partitioning,
risking a deadlock if it failed asymmetrically. Fold it into the same
guarded region in both create_mesh and partition_cells via new
try_locally/mpi_check helpers, which also collapse three near-identical
hand-rolled try/catch+Allreduce blocks into one implementation.

Also split compute_cell_centroids into a serial cell_centroids_local
(no MPI_Comm) plus a thin collective wrapper, add num_vertices_per_cell_type
and owned_cell_vertices helpers to stop create_mesh and reorder_cells
independently re-deriving the same owned/ghost cell-vertex views, fix a
validation-order regression in graph::partition_sfc_* error messages,
and make GeometricReorderer a type alias for OpaquePartitioner instead
of reimplementing it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@garth-wells
garth-wells marked this pull request as ready for review September 3, 2026 09:12
garth-wells and others added 5 commits September 3, 2026 09:32
MPI::distribute_data's "non-empty data on null communicator" check was
a rank-local throw sandwiched between two comm0-wide collectives, so a
rank hitting it could exit before a later collective that other ranks
still entered -- wrapping the call in try_locally at a higher level
cannot fix a divergence inside the collective itself. Make the check
collective: reduce it across comm0, unconditionally, before any other
collective in the function, so every rank throws together or none do.

Also fix scaled_target in the SFC partitioner: its two-term int64 split
was justified by a comment claiming n and p are always int-bounded,
which is false for the sample_size call site (global point/weight
counts can exceed INT_MAX), silently producing a wrong result rather
than overflowing loudly. Compute the product in 128 bits instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant