Skip to content

Commit

Permalink
[Kinetics] Fix cache invalidation corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Dec 4, 2021
1 parent d386d85 commit 6a6034f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
21 changes: 8 additions & 13 deletions src/kinetics/GasKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,15 @@ void GasKinetics::update_rates_T()
m_ROP_ok = false;
}

if (T != m_temp || P != m_pres) {

// loop over MultiBulkRates evaluators
// @todo ... address/reassess logic as this update can fail
// (see tests/kinetics/KineticsFromScratch.cpp:
// KineticsAddSpecies - add_species_sequential)
// a work-around is to call GasKinetics::invalidateCache()
for (auto& rates : m_bulk_rates) {
bool changed = rates->update(thermo(), *this);
if (changed) {
rates->getRateConstants(m_rfn.data());
}
// loop over MultiBulkRate evaluators for each reaction type
for (auto& rates : m_bulk_rates) {
bool changed = rates->update(thermo(), *this);
if (changed) {
rates->getRateConstants(m_rfn.data());
m_ROP_ok = false;
}

}
if (T != m_temp || P != m_pres) {
// P-log reactions (legacy)
if (m_plog_rates.nReactions()) {
m_plog_rates.update(T, logT, m_rfn.data());
Expand Down
3 changes: 0 additions & 3 deletions test/kinetics/kineticsFromScratch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,6 @@ class KineticsAddSpecies : public testing::Test
p.setState_TPX(1200, 5*OneAtm, X);
p_ref.setState_TPX(1200, 5*OneAtm, X);

// need to invalidate cache to force update
kin_ref->invalidateCache();

vector_fp k(kin.nReactions()), k_ref(kin_ref->nReactions());
vector_fp w(kin.nTotalSpecies()), w_ref(kin_ref->nTotalSpecies());

Expand Down

0 comments on commit 6a6034f

Please sign in to comment.