Skip to content

refactor: new set algebra#387

Merged
gouarin merged 90 commits intohpc-maths:mainfrom
alexandrehoffmann:trial_set_algebra_2
Feb 6, 2026
Merged

refactor: new set algebra#387
gouarin merged 90 commits intohpc-maths:mainfrom
alexandrehoffmann:trial_set_algebra_2

Conversation

@alexandrehoffmann
Copy link
Contributor

@alexandrehoffmann alexandrehoffmann commented Oct 1, 2025

Description

This PR implements a major refactoring of the set algebra system in samurai, replacing the old visitor-based approach with a new traverser-based architecture. The changes introduce a more modular and maintainable design for performing set operations (union, intersection, difference) on mesh cell arrays.

It also resolves a long-standing issue that resulted from the visitor-based approach that was previously implemented. This approach assumes that all sets in algebra are commutative, which is not the case. We now have a valid set algebra.

Changes:

  • Complete rewrite of the subset/set algebra implementation using a traverser-based architecture
  • Addition of new traverser classes for various operations (union, intersection, difference, expansion, contraction, projection, translation)
  • Replacement of old visitor pattern with a cleaner set base class and traverser interface
  • New utility functions for set operations and tuple/range iteration

Code of Conduct

By submitting this PR, you agree to follow our Code of Conduct

  • I agree to follow this project's Code of Conduct

@gouarin gouarin deleted the branch hpc-maths:main December 10, 2025 09:00
@gouarin gouarin closed this Dec 10, 2025
@gouarin gouarin reopened this Dec 10, 2025
@gouarin gouarin changed the base branch from master to main December 10, 2025 09:21
@gouarin gouarin force-pushed the trial_set_algebra_2 branch from 504e17a to 1a4c536 Compare February 2, 2026 16:39
Copy link

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 implements a major refactoring of the set algebra system in samurai, replacing the old visitor-based approach with a new traverser-based architecture. The changes introduce a more modular and maintainable design for performing set operations (union, intersection, difference) on mesh cell arrays.

Changes:

  • Complete rewrite of the subset/set algebra implementation using a traverser-based architecture
  • Addition of new traverser classes for various operations (union, intersection, difference, expansion, contraction, projection, translation)
  • Replacement of old visitor pattern with a cleaner set base class and traverser interface
  • New utility functions for set operations and tuple/range iteration

Reviewed changes

Copilot reviewed 47 out of 47 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
tests/test_subset.cpp Updated tests to use new API (vmin instead of compute_min), added expand_2d, expand_3d, contract tests, contains debug code
include/samurai/subset/visitor.hpp Deleted old visitor-based implementation
include/samurai/subset/start_end_fct.hpp Deleted old start/end function implementation
include/samurai/subset/concepts.hpp Deleted old concepts file
include/samurai/subset/utils.hpp Refactored with new utility functions, contains critical bug in enumerate_items
include/samurai/subset/traversers/*.hpp New traverser implementations for all set operations
include/samurai/subset/set_base.hpp New base class for set operations
include/samurai/subset/nary_set_operator.hpp New n-ary set operator implementation
include/samurai/subset/node.hpp Simplified to include only headers
include/samurai/level_cell_array.hpp Updated constructors to work with new set base, contains commented code
include/samurai/interval.hpp Modified equality operator to exclude index field
include/samurai/samurai_config.hpp Added configuration flags for new features
include/samurai/static_algorithm.hpp Added conditional logic for native expand
include/samurai/mesh.hpp Updated to call to_lca() on set operations
include/samurai/boundary.hpp Added const correctness
include/samurai/algorithm.hpp Updated for_each_interval for new API
demos/tutorial/set_operator.cpp Updated contraction to contract function call
demos/FiniteVolume/advection_3d.cpp New 3D advection demo

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

@gouarin
Copy link
Contributor

gouarin commented Feb 5, 2026

Can you check that all inline are changed by SAMURAI_INLINE ?

@gouarin
Copy link
Contributor

gouarin commented Feb 5, 2026

We could also just keep the version of 'ListOfIntervals' for the traversers and delete the rest.

@alexandrehoffmann
Copy link
Contributor Author

Can you check that all inline are changed by SAMURAI_INLINE ?

done.

@gouarin gouarin changed the title refactor: new trial set algebra refactor: new set algebra Feb 6, 2026
@gouarin gouarin merged commit 2de125c into hpc-maths:main Feb 6, 2026
17 of 18 checks passed
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