Xiangyu/discrete variable initialization #935
Merged
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 pull request refactors the initialization and registration of discrete variables throughout the codebase, centralizing initialization logic within the
DiscreteVariableclass and removing redundant initialization functions from other classes. The changes simplify variable creation, improve maintainability, and ensure consistent default initialization, especially for matrix types.Key changes include:
Centralization and Simplification of Discrete Variable Initialization
DiscreteVariableclass to support initialization with a default value, an initialization function, or by copying from another variable, moving all initialization logic into this class.initializeVariablefunctions from bothBaseParticlesandBaseCellLinkedList, as their logic is now handled by the newDiscreteVariableconstructors. [1] [2] F99d5537L93R93, [3]Updates to Variable Registration Methods
BaseParticlesandBaseCellLinkedListto directly forward initialization arguments to the newDiscreteVariableconstructors, removing manual initialization steps. [1] [2] [3]Improved Zero Initialization for Matrix Types
ZeroDatastruct to correctly handle zero initialization for Eigen matrix types, ensuring matrices are initialized with zeros by default.Code Cleanup
These changes collectively make variable management more robust and easier to maintain, while reducing code duplication and potential errors from inconsistent initialization.