Skip to content

Dof reindexing for FESpaces#1299

Merged
JordiManyer merged 7 commits into
masterfrom
dof-reordering
May 12, 2026
Merged

Dof reindexing for FESpaces#1299
JordiManyer merged 7 commits into
masterfrom
dof-reordering

Conversation

@JordiManyer
Copy link
Copy Markdown
Member

Adds reindex_free_dof_ids(space, algorithm) to reorder the free DOF IDs of a FESpace to reduce the bandwidth, profile, or fill-in of the assembled stiffness matrix. Dirichlet DOF IDs are
left unchanged.

Algorithms

  • :rcm — Reverse Cuthill-McKee with George-Liu pseudo-peripheral node selection.
  • :sloan — Sloan's algorithm, minimising the active wavefront. Accepts w1, w2 weight kwargs.
  • :coordinates — Sort by DOF spatial coordinates (Lagrangian spaces). Accepts by and lt kwargs for custom key/comparator.

All algorithms are also reachable by calling reindex_free_dof_ids(space, iperm) directly with an externally computed permutation vector (e.g. from AMD).

New public API

  • reindex_free_dof_ids(space, algorithm; adj, by, lt, kwargs...) — main entry point.
  • reindex_free_dof_ids(space, free_dof_ids) — apply an externally supplied permutation.
  • reindex_free_and_dirichlet_dof_ids(space, free_dof_ids, dir_dof_ids) — abstract interface for concrete FESpace types; implemented for UnconstrainedFESpace and PolytopalFESpace.

renumber_free_and_dirichlet_dof_ids is kept as a legacy wrapper (to be deprecated in the next major release).

Internal additions

  • compute_adjacency(t::Table, nfree) in Arrays/Tables.jl — builds the symmetric DOF adjacency graph from a cell-to-DOF table.
  • compute_dof_permutation(adj, algorithm) in FESpaces — adjacency-based permutation computation (not exported).

@JordiManyer
Copy link
Copy Markdown
Member Author

@nichomueller this is what we talked about. I've added an API to do reordering of dofs after the space has been created. We can add more permutations if any are missing.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 96.61017% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.90%. Comparing base (48a26c4) to head (9d4fb09).

Files with missing lines Patch % Lines
src/FESpaces/FESpaceReindexing.jl 95.74% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1299      +/-   ##
==========================================
+ Coverage   88.84%   88.90%   +0.05%     
==========================================
  Files         227      228       +1     
  Lines       29799    30030     +231     
==========================================
+ Hits        26475    26698     +223     
- Misses       3324     3332       +8     
Flag Coverage Δ
drivers 39.61% <2.54%> (-0.31%) ⬇️
extensions 5.04% <1.27%> (-0.04%) ⬇️
unit-adaptivity 39.74% <1.27%> (-0.31%) ⬇️
unit-basics 14.60% <1.27%> (-0.12%) ⬇️
unit-celldata 20.95% <1.27%> (-0.17%) ⬇️
unit-fespaces-1 32.09% <1.27%> (-0.25%) ⬇️
unit-fespaces-2 39.36% <96.18%> (+0.53%) ⬆️
unit-fields 17.59% <0.00%> (-0.14%) ⬇️
unit-geometry 28.53% <1.27%> (-0.22%) ⬇️
unit-multifield 30.61% <1.27%> (-0.24%) ⬇️
unit-odes 28.49% <1.27%> (-0.22%) ⬇️
unit-referencefes 34.09% <1.27%> (-0.27%) ⬇️
unit-visualization 11.76% <1.27%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new public API to reorder (reindex) free DOF IDs in FESpaces to improve assembled matrix sparsity characteristics (bandwidth/profile/fill-in), adding built-in graph-based algorithms (RCM, Sloan) plus a coordinate-based ordering, along with supporting infrastructure and tests.

Changes:

  • Added reindex_free_dof_ids / reindex_free_and_dirichlet_dof_ids APIs and implementations for UnconstrainedFESpace and PolytopalFESpace, keeping renumber_free_and_dirichlet_dof_ids as a legacy wrapper.
  • Added compute_adjacency to build a symmetric DOF adjacency graph from cell-to-DOF connectivity, and internal permutation routines (RCM/Sloan/coordinates).
  • Added a dedicated testset covering API behavior and a basic end-to-end bandwidth reduction check; updated NEWS.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/FESpacesTests/runtests_2.jl Registers the new reindexing testset in the FESpaces test suite.
test/FESpacesTests/FESpaceReindexingTests.jl Adds tests for reindexing algorithms, custom coordinate keying, explicit adjacency reuse, and a bandwidth reduction sanity check.
src/Geometry/Geometry.jl Exports compute_graph.
src/FESpaces/UnconstrainedFESpaces.jl Renames the concrete renumbering implementation to the new reindex_free_and_dirichlet_dof_ids interface.
src/FESpaces/PolytopalFESpaces.jl Same as above for PolytopalFESpace.
src/FESpaces/PatchFESpaces.jl Updates internal call site to the new reindexing function name.
src/FESpaces/FESpaces.jl Exports the new reindexing API and includes the new implementation file; imports compute_adjacency.
src/FESpaces/FESpaceReindexing.jl New core implementation: abstract interface + RCM/Sloan/coordinates permutations + public entry point.
src/Arrays/Tables.jl Adjusts inverse_table to skip nonpositive entries and adds compute_adjacency.
src/Arrays/Arrays.jl Exports inverse_table.
Project.toml Adds AMD to compat/extras/test target.
NEWS.md Documents the new reindexing API under Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/FESpaces/FESpaceReindexing.jl Outdated
Comment thread src/FESpaces/FESpaceReindexing.jl Outdated
Comment thread src/Arrays/Tables.jl
JordiManyer and others added 4 commits May 12, 2026 00:18
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@JordiManyer JordiManyer merged commit 299690c into master May 12, 2026
58 checks passed
@JordiManyer JordiManyer deleted the dof-reordering branch May 12, 2026 04:05
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