GridFire 0.6.0
General Purpose Nuclear Network
Loading...
Searching...
No Matches
gridfire::QSECacheKey Struct Reference

Key struct for the QSE abundance cache. More...

#include <engine_multiscale.h>

Public Member Functions

 QSECacheKey (const double T9, const double rho, const std::vector< double > &Y)
 Constructs a QSECacheKey.
 
size_t hash () const
 Computes the hash value for this key.
 
bool operator== (const QSECacheKey &other) const
 Equality operator for QSECacheKey.
 

Static Public Member Functions

static long bin (double value, double tol)
 Converts a value to a discrete bin based on a tolerance.
 

Public Attributes

double m_T9
 
double m_rho
 
std::vector< double > m_Y
 Note that the ordering of Y must match the dynamic species indices in the view.
 
std::size_t m_hash = 0
 Precomputed hash value for this key.
 
QSECacheConfig m_cacheConfig
 

Detailed Description

Key struct for the QSE abundance cache.

Purpose
This struct is used as the key for the QSE abundance cache (m_qse_abundance_cache) within the MultiscalePartitioningEngineView. Its primary goal is to avoid expensive re-partitioning and QSE solves for thermodynamic conditions that are "close enough" to previously computed ones.
How
It works by storing the temperature (m_T9), density (m_rho), and species abundances (m_Y). A pre-computed hash is generated in the constructor by calling the hash() method. This method discretizes the continuous physical values into bins using the tolerances defined in QSECacheConfig. The operator== simply compares the pre-computed hash values for fast lookups in the std::unordered_map.

Constructor & Destructor Documentation

◆ QSECacheKey()

gridfire::QSECacheKey::QSECacheKey ( const double T9,
const double rho,
const std::vector< double > & Y )

Constructs a QSECacheKey.

Parameters
T9Temperature in units of 10^9 K.
rhoDensity in g/cm^3.
YSpecies molar abundances.
Postcondition
The m_hash member is computed and stored.

Member Function Documentation

◆ bin()

long gridfire::QSECacheKey::bin ( double value,
double tol )
static

Converts a value to a discrete bin based on a tolerance.

Parameters
valueThe value to bin.
tolThe tolerance (bin width) to use for binning.
Returns
The bin number as a long integer.
How
The algorithm is floor(value / tol).

◆ hash()

size_t gridfire::QSECacheKey::hash ( ) const

Computes the hash value for this key.

Returns
The computed hash value.
How
This method combines the hashes of the binned temperature, density, and each species abundance. The bin() static method is used for discretization.

◆ operator==()

bool gridfire::QSECacheKey::operator== ( const QSECacheKey & other) const

Equality operator for QSECacheKey.

Parameters
otherThe other QSECacheKey to compare to.
Returns
True if the pre-computed hashes are equal, false otherwise.

Member Data Documentation

◆ m_cacheConfig

QSECacheConfig gridfire::QSECacheKey::m_cacheConfig
Initial value:
= {
1e-3,
1e-1,
1e-3
}

◆ m_hash

std::size_t gridfire::QSECacheKey::m_hash = 0

Precomputed hash value for this key.

◆ m_rho

double gridfire::QSECacheKey::m_rho

◆ m_T9

double gridfire::QSECacheKey::m_T9

◆ m_Y

std::vector<double> gridfire::QSECacheKey::m_Y

Note that the ordering of Y must match the dynamic species indices in the view.


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