GridFire v0.7.6rc4.0 General Purpose Nuclear Network

Loading...
Searching...
No Matches
Classes | Namespaces
engine_multiscale_scratchpad.h File Reference

Scratchpad implementation for the MultiscalePartitioningEngineView. More...

`#include "gridfire/engine/views/engine_multiscale.h"`
`#include "gridfire/engine/scratchpads/scratchpad_abstract.h"`
`#include "gridfire/engine/scratchpads/types.h"`
`#include "fourdst/atomic/atomicSpecies.h"`
`#include <vector>`
`#include <memory>`
`#include <unordered_map>`
`#include "sundials/sundials_context.h"`
Include dependency graph for engine_multiscale_scratchpad.h:
This graph shows which files directly or indirectly include this file:

## Classes
struct | gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad
| Scratchpad for multiscale partitioning engine computations with QSE groups. More...

## Namespaces
namespace | gridfire
namespace | gridfire::engine
namespace | gridfire::engine::scratch
| Scratchpad memory management for computational engines.

## Detailed Description

Scratchpad implementation for the MultiscalePartitioningEngineView.

This header defines the MultiscalePartitioningEngineViewScratchPad, a concrete implementation of AbstractScratchPad designed for use with multiscale partitioning algorithms. It provides thread-local storage for QSE (Quasi-Static Equilibrium) groups, solvers, species classifications, and SUNDIALS contexts required for solving stiff subsystems.

Purpose
  The MultiscalePartitioningEngineViewScratchPad stores:
  - QSE groups representing clusters of species in quasi-static equilibrium
  - QSE solvers for each group (managed via unique_ptr)
  - Classification of species into dynamic vs. algebraic categories
  - A composition cache for efficient lookup of computed compositions
  - A SUNDIALS context for numerical solver operations

Examples
  #include "gridfire/engine/scratchpads/engine_multiscale_scratchpad.h"
  // Create and initialize the scratchpad
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad scratch;
  scratch.initialize();
  if (scratch.is_initialized()) {
  // Add QSE groups and species classifications
  scratch.dynamic_species.push_back(hydrogen);
  scratch.dynamic_species.push_back(helium);
  scratch.algebraic_species.push_back(carbon);
  // Use the SUNDIALS context for solver operations
  SUNContext ctx = scratch.sun_ctx;
  }
  // Clone for parallel execution (note: solvers not cloned)
  auto worker_scratch = scratch.clone();
  worker_scratch->initialize(); // Must re-initialize for new SUNContext
  engine_multiscale_scratchpad.h
  Scratchpad implementation for the MultiscalePartitioningEngineView.
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad
  Scratchpad for multiscale partitioning engine computations with QSE groups.
  Definition engine_multiscale_scratchpad.h:90
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::algebraic_species
  std::vector< Species > algebraic_species
  Species that are solved algebraically (fast timescale/QSE).
  Definition engine_multiscale_scratchpad.h:120
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::dynamic_species
  std::vector< Species > dynamic_species
  Species that evolve on the dynamic (slow) timescale.
  Definition engine_multiscale_scratchpad.h:117
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::sun_ctx
  SUNContext sun_ctx
  SUNDIALS context for solver operations.
  Definition engine_multiscale_scratchpad.h:127
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::clone
  std::unique_ptr< AbstractScratchPad > clone() const override
  Create a partial copy of this scratchpad.
  Definition engine_multiscale_scratchpad.h:199
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::initialize
  void initialize()
  Initialize the scratchpad by creating a SUNDIALS context.
  Definition engine_multiscale_scratchpad.h:153
  gridfire::engine::scratch::MultiscalePartitioningEngineViewScratchPad::is_initialized
  bool is_initialized() const override
  Check whether the scratchpad has been initialized.
  Definition engine_multiscale_scratchpad.h:133

Thread Safety
  This class is not thread-safe. Each thread must have its own instance because SUNDIALS contexts and QSE solvers maintain internal state. When cloning, the QSE solvers are not copied and the SUNContext is not cloned; the new instance must call initialize() to create its own context.

See also
  AbstractScratchPad
  MultiscalePartitioningEngineView
  SUNContext