GridFire v0.7.6rc4.0 General Purpose Nuclear Network

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad Struct Referencefinal

Scratchpad for multiscale partitioning engine computations with QSE groups. More...

`#include <engine_multiscale_scratchpad.h>`

Inheritance diagram for gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad:
[legend]
Collaboration diagram for gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad:
[legend]

## Public Types
using | QSEGroup = MultiscalePartitioningEngineView::QSEGroup
| Type alias for QSE group from the multiscale engine view.
using | QSESolver = MultiscalePartitioningEngineView::QSESolver
| Type alias for QSE solver from the multiscale engine view.
using | Species = fourdst::atomic::Species
| Type alias for atomic species.

## Public Member Functions
bool | is_initialized () const override
| Check whether the scratchpad has been initialized.
void | initialize ()
| Initialize the scratchpad by creating a SUNDIALS context.
| ~MultiscalePartitioningEngineViewScratchPad () override
| Destructor that properly releases SUNDIALS resources.
std::unique_ptr< AbstractScratchPad > | clone () const override
| Create a partial 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
bool | has_initialized = false
| Flag indicating whether the scratchpad has been initialized.
double | flux_coupling_threshold = 5.0
| @breif User configurable parameter to control flux coupling threshold used
std::vector< QSEGroup > | qse_groups
| Vector of QSE groups representing equilibrium clusters.
std::vector< std::unique_ptr< QSESolver > > | qse_solvers
| Vector of QSE solvers, one per QSE group.
std::vector< Species > | dynamic_species
| Species that evolve on the dynamic (slow) timescale.
std::vector< Species > | algebraic_species
| Species that are solved algebraically (fast timescale/QSE).
std::unordered_map< uint64_t, fourdst::composition::Composition > | composition_cache
| Cache of computed compositions indexed by a hash key.
SUNContext | sun_ctx = nullptr
| SUNDIALS context for solver operations.

## Static Public Attributes
static constexpr auto | ID = ScratchPadType::MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD
| Unique identifier for this scratchpad type.

## Detailed Description

Scratchpad for multiscale partitioning engine computations with QSE groups.

MultiscalePartitioningEngineViewScratchPad provides thread-local storage for the multiscale partitioning algorithm, which separates species into fast (algebraic/QSE) and slow (dynamic) timescale groups. This enables efficient integration of stiff reaction networks by solving QSE subsystems separately.

Thread Safety
  This class is not thread-safe. SUNDIALS contexts and QSE solver objects maintain internal state that cannot be shared across threads. Each thread must have its own scratchpad instance with its own SUNContext. When using clone(), the new instance starts uninitialized and must call initialize() to create a new SUNContext.

Note
  The destructor properly cleans up SUNDIALS resources by freeing the SUNContext after clearing all solvers that depend on it.

Warning
  QSE solvers are not cloned - they must be re-created in the cloned scratchpad as needed.

## Member Typedef Documentation

## ◆ QSEGroup

using gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::QSEGroup = MultiscalePartitioningEngineView::QSEGroup

Type alias for QSE group from the multiscale engine view.

## ◆ QSESolver

using gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::QSESolver = MultiscalePartitioningEngineView::QSESolver

Type alias for QSE solver from the multiscale engine view.

## ◆ Species

using gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::Species = fourdst::atomic::Species

Type alias for atomic species.

## Constructor & Destructor Documentation

## ◆ ~MultiscalePartitioningEngineViewScratchPad()

gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::~MultiscalePartitioningEngineViewScratchPad | ( |  | ) |
| inline override

Destructor that properly releases SUNDIALS resources.

Clears all QSE solvers before freeing the SUNContext to ensure proper cleanup order and avoid dangling references.

## Member Function Documentation

## ◆ clone()

std::unique_ptr< AbstractScratchPad > gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::clone | ( |  | ) | const
| inline nodiscard override virtual

Create a partial copy of this scratchpad.

Creates a copy with the QSE groups, species classifications, and composition cache.

Returns
  A unique pointer to the cloned scratchpad.

Note
  The new instance will automatically initialize a new SUNContext and clone the QSE solvers.

Examples
  MultiscalePartitioningEngineViewScratchPad scratch;
  scratch.initialize();
  scratch.dynamic_species = {hydrogen, helium};
  // Clone for a worker thread
  auto worker = scratch.clone();
  gridfire::engine::scratch
  Scratchpad memory management for computational engines.
  Definition blob.h:69
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad
  Scratchpad for multiscale partitioning engine computations with QSE groups.
  Definition engine_multiscale_scratchpad.h:90

Implements gridfire::engine::scratch::AbstractScratchPad.

## ◆ initialize()

void gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::initialize | ( |  | ) |
| inline

Initialize the scratchpad by creating a SUNDIALS context.

Creates a new SUNContext for use with SUNDIALS solvers. This method is idempotent; calling it multiple times has no effect after the first successful initialization.

Exceptions

  std::runtime_error | if SUNContext creation fails.

Examples
  MultiscalePartitioningEngineViewScratchPad scratch;
  scratch.initialize();
  // Now safe to use SUNContext for solver creation
  SUNContext ctx = scratch.sun_ctx;

## ◆ is_initialized()

bool gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::is_initialized | ( |  | ) | const
| inline nodiscard override virtual

Check whether the scratchpad has been initialized.

Returns
  true if initialized with a valid SUNContext, false otherwise.

Implements gridfire::engine::scratch::AbstractScratchPad.

## Member Data Documentation

## ◆ algebraic_species

std::vector<Species> gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::algebraic_species

Species that are solved algebraically (fast timescale/QSE).

## ◆ composition_cache

std::unordered_map<uint64_t, fourdst::composition::Composition> gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::composition_cache

Cache of computed compositions indexed by a hash key.

## ◆ dynamic_species

std::vector<Species> gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::dynamic_species

Species that evolve on the dynamic (slow) timescale.

## ◆ flux_coupling_threshold

double gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::flux_coupling_threshold = 5.0

@breif User configurable parameter to control flux coupling threshold used

## ◆ has_initialized

bool gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::has_initialized = false

Flag indicating whether the scratchpad has been initialized.

## ◆ ID

auto gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::ID = ScratchPadType::MULTISCALE_PARTITIONING_ENGINE_VIEW_SCRATCHPAD
| static constexpr

Unique identifier for this scratchpad type.

## ◆ qse_groups

std::vector<QSEGroup> gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::qse_groups

Vector of QSE groups representing equilibrium clusters.

## ◆ qse_solvers

std::vector<std::unique_ptr<QSESolver> > gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::qse_solvers

Vector of QSE solvers, one per QSE group.

Note
  These are not cloned; new instances must create their own solvers.

## ◆ sun_ctx

SUNContext gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::sun_ctx = nullptr

SUNDIALS context for solver operations.

Note
  Must be freed in destructor after clearing solvers.

The documentation for this struct was generated from the following file:

- src/include/gridfire/engine/scratchpads/engine_multiscale_scratchpad.h