|
GridFire v0.7.6rc4.0
General Purpose Nuclear Network
|
Scratchpad for storing CppAD automatic differentiation state for GraphEngine. More...
#include <engine_graph_scratchpad.h>
Public Types | |
| enum class | ADFunRegistrationResult : uint8_t { SUCCESS , ALREADY_REGISTERED } |
| Result codes for ADFun registration operations. More... | |
Public Member Functions | |
| bool | is_initialized () const override |
| Check whether the scratchpad has been initialized. | |
| void | initialize (const GraphEngine &engine) |
| Initialize the scratchpad from a GraphEngine. | |
| std::unique_ptr< AbstractScratchPad > | clone () const override |
| Create a deep copy of this scratchpad. | |
Public Member Functions inherited from gridfire::engine::scratch::AbstractScratchPad | |
| virtual | ~AbstractScratchPad ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
Public Attributes | |
| std::optional< CppAD::ADFun< double > > | rhsADFun |
| CppAD function object for evaluating the ODE right-hand side. | |
| CppAD::sparse_jac_work | jac_work |
| Work structure for sparse Jacobian calculations. | |
| std::vector< double > | local_abundance_cache |
| Local cache of abundance values for efficient RHS evaluation. | |
| std::unordered_map< size_t, StepDerivatives< double > > | stepDerivativesCache |
| Cache of step derivatives indexed by timestep identifier. | |
| std::unordered_map< size_t, CppAD::sparse_rcv< std::vector< size_t >, std::vector< double > > > | jacobianSubsetCache |
| Cache of sparse Jacobian subsets indexed by timestep identifier. | |
| std::unordered_map< size_t, CppAD::sparse_jac_work > | jacWorkCache |
| Cache of Jacobian work structures indexed by timestep identifier. | |
| std::optional< StepDerivatives< double > > | most_recent_rhs_calculation |
| The most recent RHS calculation result for warm-starting. | |
| bool | has_initialized = false |
| Flag indicating whether the scratchpad has been initialized. | |
Static Public Attributes | |
| static constexpr auto | ID = ScratchPadType::GRAPH_ENGINE_SCRATCHPAD |
| Unique identifier for this scratchpad type. | |
Scratchpad for storing CppAD automatic differentiation state for GraphEngine.
GraphEngineScratchPad provides thread-local storage for all CppAD-related objects needed during ODE integration with the GraphEngine. This includes the ADFun object for evaluating the right-hand side of the ODE and computing Jacobians, as well as various caches to improve performance.
|
strong |
|
inlinenodiscardoverridevirtual |
Create a deep copy of this scratchpad.
Creates an independent copy of all internal state, including the CppAD ADFun object and all caches. The clone can be safely used in a separate thread without affecting the original.
Implements gridfire::engine::scratch::AbstractScratchPad.
|
inline |
Initialize the scratchpad from a GraphEngine.
Copies the authoritative ADFun from the engine and clears all caches. This method is idempotent; calling it multiple times has no effect after the first successful initialization.
| engine | The GraphEngine to initialize from. |
|
inlinenodiscardoverridevirtual |
Check whether the scratchpad has been initialized.
Implements gridfire::engine::scratch::AbstractScratchPad.
| bool gridfire::engine::scratch::GraphEngineScratchPad::has_initialized = false |
Flag indicating whether the scratchpad has been initialized.
|
staticconstexpr |
Unique identifier for this scratchpad type.
| CppAD::sparse_jac_work gridfire::engine::scratch::GraphEngineScratchPad::jac_work |
Work structure for sparse Jacobian calculations.
Reused across Jacobian evaluations to avoid reallocation.
| std::unordered_map<size_t, CppAD::sparse_rcv<std::vector<size_t>, std::vector<double> > > gridfire::engine::scratch::GraphEngineScratchPad::jacobianSubsetCache |
Cache of sparse Jacobian subsets indexed by timestep identifier.
| std::unordered_map<size_t, CppAD::sparse_jac_work> gridfire::engine::scratch::GraphEngineScratchPad::jacWorkCache |
Cache of Jacobian work structures indexed by timestep identifier.
| std::vector<double> gridfire::engine::scratch::GraphEngineScratchPad::local_abundance_cache |
Local cache of abundance values for efficient RHS evaluation.
| std::optional<StepDerivatives<double> > gridfire::engine::scratch::GraphEngineScratchPad::most_recent_rhs_calculation |
The most recent RHS calculation result for warm-starting.
| std::optional<CppAD::ADFun<double> > gridfire::engine::scratch::GraphEngineScratchPad::rhsADFun |
CppAD function object for evaluating the ODE right-hand side.
Contains the computational graph for automatic differentiation.
| std::unordered_map<size_t, StepDerivatives<double> > gridfire::engine::scratch::GraphEngineScratchPad::stepDerivativesCache |
Cache of step derivatives indexed by timestep identifier.