Loading...
Searching...
No Matches
gridfire::engine::scratch::DefinedEngineViewScratchPad Struct Referencefinal

Scratchpad for storing working memory used by defined reaction network engines. More...

`#include <engine_defined_scratchpad.h>`

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

## Public Member Functions

bool | is_initialized () const override
| Check whether the scratchpad has been initialized.
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

bool | has_initialized = true
| Flag indicating whether the scratchpad is initialized (default: true).
std::set< fourdst::atomic::Species > | active_species
| Set of species active in the defined network.
reaction::ReactionSet | active_reactions
| Set of reactions active in the defined network.
std::vector< size_t > | species_index_map
| Mapping from local indices to global species indices.
std::vector< size_t > | reaction_index_map
| Mapping from local indices to global reaction indices.
std::optional< std::vector< fourdst::atomic::Species > > | active_species_vector_cache = std::nullopt
| Cached vector of active species for performance optimization.

## Static Public Attributes

static constexpr auto | ID = ScratchPadType::DEFINED_ENGINE_VIEW_SCRATCHPAD
| Unique identifier for this scratchpad type.

## Detailed Description

Scratchpad for storing working memory used by defined reaction network engines.

DefinedEngineViewScratchPad provides storage for species and reaction data in engines with statically defined reaction networks. It includes index mappings for efficient lookups and an optional cache for the active species vector.

Unlike adaptive scratchpads, the defined scratchpad is considered initialized by default (has_initialized = true), as the network structure is known at construction time.

Thread Safety
  This class is not thread-safe. Each thread should operate on its own independent instance. Use clone() to create copies for parallel execution.

## Member Function Documentation

## clone()

std::unique_ptr< AbstractScratchPad > gridfire::engine::scratch::DefinedEngineViewScratchPad::clone | ( |  | ) | const

inlineoverridevirtual

Create a deep copy of this scratchpad.

Creates an independent copy of all internal state, including active species, reactions, index mappings, and the species vector cache. The clone can be modified without affecting the original.

Returns
  A unique pointer to the cloned scratchpad.

Examples
  DefinedEngineViewScratchPad scratch;
  scratch.active_species.insert(species);
  scratch.species_index_map = {0, 1, 2};
  // Create independent copy for a worker thread
  auto worker_copy = scratch.clone();
  gridfire::engine::scratch
  Scratchpad memory management for computational engines.
  Definition blob.h:69
  gridfire::engine::scratch::DefinedEngineViewScratchPad
  Scratchpad for storing working memory used by defined reaction network engines.
  Definition engine_defined_scratchpad.h:80

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

## is_initialized()

bool gridfire::engine::scratch::DefinedEngineViewScratchPad::is_initialized | ( |  | ) | const

inlineoverridevirtual

Check whether the scratchpad has been initialized.

Returns
  true if initialized (always true by default for defined networks).

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

## Member Data Documentation

## active_reactions

reaction::ReactionSet gridfire::engine::scratch::DefinedEngineViewScratchPad::active_reactions

Set of reactions active in the defined network.

## active_species

std::set<fourdst::atomic::Species> gridfire::engine::scratch::DefinedEngineViewScratchPad::active_species

Set of species active in the defined network.

## active_species_vector_cache

std::optional<std::vector<fourdst::atomic::Species> > gridfire::engine::scratch::DefinedEngineViewScratchPad::active_species_vector_cache = std::nullopt

Cached vector of active species for performance optimization.

This optional cache avoids repeated conversion from set to vector.

## has_initialized

bool gridfire::engine::scratch::DefinedEngineViewScratchPad::has_initialized = true

Flag indicating whether the scratchpad is initialized (default: true).

## ID

auto gridfire::engine::scratch::DefinedEngineViewScratchPad::ID = ScratchPadType::DEFINED_ENGINE_VIEW_SCRATCHPAD

staticconstexpr

Unique identifier for this scratchpad type.

## reaction_index_map

std::vector<size_t> gridfire::engine::scratch::DefinedEngineViewScratchPad::reaction_index_map

Mapping from local indices to global reaction indices.

## species_index_map

std::vector<size_t> gridfire::engine::scratch::DefinedEngineViewScratchPad::species_index_map

Mapping from local indices to global species indices.

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

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