This section covers the implementation details of the C++ chemistry bridges linking the Fortran solver with external chemical kinetics, thermodynamics, and transport libraries.
Thermodynamic and transport property evaluations inside Cantera represent a primary computational bottleneck. The cantera_interface.cpp implements a State Cache Layer that stores physical states and corresponding properties, achieving >93% cache hit rates.
The cache utilizes contiguous memory arrays to store species mass fractions , temperature , and background pressure for every grid cell:
struct ThermoStateCache {
std::vector<double> Y;
std::vector<double> T;
std::vector<double> mu;
std::vector<double> cp;
std::vector<double> lambda;
std::vector<double> rho;
int ncells;
int nspecies;
};
cpp
void check_and_reserve(ThermoStateCache& cache, int required_cells, int nspecies) {
if (cache.Y.size() < (size_t)required_cells * nspecies) {
cache.Y.resize(required_cells * nspecies);
cache.T.resize(required_cells);
cache.mu.resize(required_cells);
}
}
This preserves the pre-allocated capacity across steps, eliminating memory allocation overhead.PelePhysics integrates AMReX (portable CPU/GPU grid managers) and SUNDIALS CVODE (stiff implicit ODE integration) into a unified thermodynamics and reaction network.
Reaction rates are modeled as a constant-pressure stiff ODE network: This system is integrated step-by-step using CVODE's Backward Differentiation Formulas (BDF) with Newton iteration.
pelephysics_interface.cpp pre-allocates matrix, linear solver, and state vector objects during startup, caching them in persistent static memory:
static SUNMatrix A = SUNDenseMatrix(nspecies + 1, nspecies + 1);
static SUNLinearSolver LS = SUNLinSol_Dense(y, A);
static void* cvode_mem = CVodeCreate(CV_BDF);
nvector_cuda), running matrix solves inside the GPU cores.