Add invalidateCache() function to ThermoPhase and Kinetics
This can be used to invalidate cached data after a change to underlying data such as species thermo coefficients or reaction rate coefficients. Needs to be user-accessible so that dependent objects can be updated manually.
This commit is contained in:
parent
eda9fc8f23
commit
13fa0c7a4f
11 changed files with 35 additions and 0 deletions
|
|
@ -40,6 +40,7 @@ public:
|
|||
virtual bool ready() const;
|
||||
|
||||
virtual void setMultiplier(size_t i, double f);
|
||||
virtual void invalidateCache();
|
||||
|
||||
protected:
|
||||
virtual void addElementaryReaction(ElementaryReaction& r);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public:
|
|||
virtual void modifyReaction(size_t i, shared_ptr<Reaction> rNew);
|
||||
virtual void finalize();
|
||||
virtual bool ready() const;
|
||||
virtual void invalidateCache();
|
||||
//@}
|
||||
|
||||
void updateROP();
|
||||
|
|
|
|||
|
|
@ -803,6 +803,8 @@ public:
|
|||
m_perturb[i] = f;
|
||||
}
|
||||
|
||||
virtual void invalidateCache() {};
|
||||
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -724,6 +724,10 @@ public:
|
|||
return m_stateNum;
|
||||
}
|
||||
|
||||
//! Invalidate any cached values which are normally updated only when a
|
||||
//! change in state is detected
|
||||
virtual void invalidateCache();
|
||||
|
||||
protected:
|
||||
//! Cached for saved calculations within each ThermoPhase.
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -1537,6 +1537,8 @@ public:
|
|||
*/
|
||||
virtual void setStateFromXML(const XML_Node& state);
|
||||
|
||||
virtual void invalidateCache();
|
||||
|
||||
//! @}
|
||||
//! @name Derivatives of Thermodynamic Variables needed for Applications
|
||||
//! @{
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
|||
void addUndefinedElements() except +
|
||||
cbool addSpecies(shared_ptr[CxxSpecies]) except +
|
||||
void initThermo() except +
|
||||
void invalidateCache() except +
|
||||
|
||||
# basic thermodynamic properties
|
||||
double temperature() except +
|
||||
|
|
@ -361,6 +362,7 @@ cdef extern from "cantera/kinetics/Kinetics.h" namespace "Cantera":
|
|||
void addReaction(shared_ptr[CxxReaction]) except +
|
||||
void finalize() except +
|
||||
void modifyReaction(int, shared_ptr[CxxReaction]) except +
|
||||
void invalidateCache() except +
|
||||
|
||||
shared_ptr[CxxReaction] reaction(size_t) except +
|
||||
cbool isReversible(int) except +
|
||||
|
|
|
|||
|
|
@ -159,4 +159,11 @@ void BulkKinetics::setMultiplier(size_t i, double f) {
|
|||
m_ROP_ok = false;
|
||||
}
|
||||
|
||||
void BulkKinetics::invalidateCache()
|
||||
{
|
||||
Kinetics::invalidateCache();
|
||||
m_ROP_ok = false;
|
||||
m_temp += 0.13579;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,4 +402,10 @@ bool GasKinetics::ready() const
|
|||
return m_finalized;
|
||||
}
|
||||
|
||||
void GasKinetics::invalidateCache()
|
||||
{
|
||||
BulkKinetics::invalidateCache();
|
||||
m_pres += 0.13579;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -644,6 +644,7 @@ void Kinetics::modifyReaction(size_t i, shared_ptr<Reaction> rNew)
|
|||
rOld->productString(), rNew->productString());
|
||||
}
|
||||
m_reactions[i] = rNew;
|
||||
invalidateCache();
|
||||
}
|
||||
|
||||
shared_ptr<Reaction> Kinetics::reaction(size_t i)
|
||||
|
|
|
|||
|
|
@ -864,4 +864,8 @@ bool Phase::ready() const
|
|||
return (m_kk > 0);
|
||||
}
|
||||
|
||||
void Phase::invalidateCache() {
|
||||
m_cache.clear();
|
||||
}
|
||||
|
||||
} // namespace Cantera
|
||||
|
|
|
|||
|
|
@ -757,6 +757,11 @@ void ThermoPhase::setStateFromXML(const XML_Node& state)
|
|||
}
|
||||
}
|
||||
|
||||
void ThermoPhase::invalidateCache() {
|
||||
Phase::invalidateCache();
|
||||
m_tlast += 0.1234;
|
||||
}
|
||||
|
||||
void ThermoPhase::equilibrate(const std::string& XY, const std::string& solver,
|
||||
double rtol, int max_steps, int max_iter,
|
||||
int estimate_equil, int log_level)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue