Repository navigation
Conversation
…t contains every user-defined functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new Setup Class system to encapsulate user-defined functions (boundary conditions, source terms, etc.) in a clean, object-oriented way. It replaces raw function pointers with std::function and lambdas for better flexibility and maintainability.
Core Changes: Setup Class System
a. Function Type Definitions
b. Setup Base Class and Factory
c. Updated main.cpp
auto mysetup = SetupRegistry::Create(input, grid, data, output);d. User-Defined Setup Example
Users now define their setup class and register it using REGISTER_SETUP (e.g., test/HD/MachReflection_newsetup/setup.cpp):
Consequential Refactoring: EOS and Drag
The new setup system required device-compatible refactoring of the Equation of State (EOS) and Drag Class to ensure compatibility with GPU execution.
Pros
✅ Clean OOP design with proper encapsulation.
✅ Flexible - supports both member functions and free functions (backward compatible).
✅ No more global variables/state.
✅ Improved maintainability - user-defined functions are logically grouped in a single class.
✅ Device compatibility - EOS and Drag refactoring ensures compatibility with GPU execution.
✅ Simplified setup registration - REGISTER_SETUP macro makes it easy to define and register user setups.
Cons
❌ Enrollment becomes more verbose due to lambda usage.
❌ Requires modifications to all tests to adapt to the new implementation.
❌ Slight overhead due to runtime polymorphism (negligible in most cases).
❌ Learning curve for users transitioning from the old approach.
❌ EOS and Drag refactoring introduces complexity for developers maintaining the codebase.