[Kinetics] Deprecate 'reactants' and 'products' methods

These methods are rarely used, and they expose a now-unused internal data
structure that isn't even correct for all reactions.
This commit is contained in:
Ray Speth 2014-11-07 02:14:50 +00:00
parent 7eb726d3d9
commit 37f71bd912
3 changed files with 32 additions and 12 deletions

View file

@ -13,6 +13,7 @@
#include "cantera/thermo/ThermoPhase.h" #include "cantera/thermo/ThermoPhase.h"
#include "StoichManager.h" #include "StoichManager.h"
#include "cantera/thermo/mix_defs.h" #include "cantera/thermo/mix_defs.h"
#include "cantera/base/global.h"
namespace Cantera namespace Cantera
{ {
@ -652,8 +653,11 @@ public:
* index numbers for reaction i. * index numbers for reaction i.
* *
* @param i reaction index * @param i reaction index
* @deprecated To be removed after Cantera 2.2.
*/ */
virtual const std::vector<size_t>& reactants(size_t i) const { virtual const std::vector<size_t>& reactants(size_t i) const {
warn_deprecated("Kinetics::reactants",
"To be removed after Cantera 2.2.");
return m_reactants[i]; return m_reactants[i];
} }
@ -662,8 +666,11 @@ public:
* index numbers for reaction i. * index numbers for reaction i.
* *
* @param i reaction index * @param i reaction index
* @deprecated To be removed after Cantera 2.2.
*/ */
virtual const std::vector<size_t>& products(size_t i) const { virtual const std::vector<size_t>& products(size_t i) const {
warn_deprecated("Kinetics::products",
"To be removed after Cantera 2.2.");
return m_products[i]; return m_products[i];
} }
@ -912,6 +919,7 @@ protected:
* stoichiometric coefficient. * stoichiometric coefficient.
* NOTE: These vectors will be wrong if there are real * NOTE: These vectors will be wrong if there are real
* stoichiometric coefficients in the expression. * stoichiometric coefficients in the expression.
* @deprecated To be removed after Cantera 2.2.
*/ */
std::vector<std::vector<size_t> > m_reactants; std::vector<std::vector<size_t> > m_reactants;
@ -925,6 +933,7 @@ protected:
* coefficient. * coefficient.
* NOTE: These vectors will be wrong if there are real * NOTE: These vectors will be wrong if there are real
* stoichiometric coefficients in the expression. * stoichiometric coefficients in the expression.
* @deprecated To be removed after Cantera 2.2.
*/ */
std::vector<std::vector<size_t> > m_products; std::vector<std::vector<size_t> > m_products;

View file

@ -811,15 +811,13 @@ void InterfaceKinetics::addReaction(ReactionData& r)
m_rxnPhaseIsProduct.push_back(std::vector<bool>(nPhases(), false)); m_rxnPhaseIsProduct.push_back(std::vector<bool>(nPhases(), false));
size_t i = m_ii - 1; size_t i = m_ii - 1;
const std::vector<size_t>& vr = reactants(i); for (size_t ik = 0; ik < r.reactants.size(); ik++) {
for (size_t ik = 0; ik < vr.size(); ik++) { size_t k = r.reactants[ik];
size_t k = vr[ik];
size_t p = speciesPhaseIndex(k); size_t p = speciesPhaseIndex(k);
m_rxnPhaseIsReactant[i][p] = true; m_rxnPhaseIsReactant[i][p] = true;
} }
const std::vector<size_t>& vp = products(i); for (size_t ik = 0; ik < r.products.size(); ik++) {
for (size_t ik = 0; ik < vp.size(); ik++) { size_t k = r.products[ik];
size_t k = vp[ik];
size_t p = speciesPhaseIndex(k); size_t p = speciesPhaseIndex(k);
m_rxnPhaseIsProduct[i][p] = true; m_rxnPhaseIsProduct[i][p] = true;
} }

View file

@ -439,8 +439,15 @@ int ReactionPathBuilder::findGroups(ostream& logfile, Kinetics& s)
size_t nrnet = m_reac[i].size(); size_t nrnet = m_reac[i].size();
size_t npnet = m_prod[i].size(); size_t npnet = m_prod[i].size();
const std::vector<size_t>& r = s.reactants(i); std::vector<size_t> r, p;
const std::vector<size_t>& p = s.products(i); for (size_t k = 0; k < s.nTotalSpecies(); k++) {
if (s.reactantStoichCoeff(k,i)) {
r.push_back(k);
}
if (s.productStoichCoeff(k,i)) {
p.push_back(k);
}
}
size_t nr = r.size(); size_t nr = r.size();
size_t np = p.size(); size_t np = p.size();
@ -656,11 +663,17 @@ int ReactionPathBuilder::init(ostream& logfile, Kinetics& kin)
// all reactants / products, even ones appearing on both sides // all reactants / products, even ones appearing on both sides
// of the reaction // of the reaction
vector<vector<size_t> > allProducts; vector<vector<size_t> > allProducts(m_nr);
vector<vector<size_t> > allReactants; vector<vector<size_t> > allReactants(m_nr);
for (size_t i = 0; i < m_nr; i++) { for (size_t i = 0; i < m_nr; i++) {
allReactants.push_back(kin.reactants(i)); for (size_t k = 0; k < m_ns; k++) {
allProducts.push_back(kin.products(i)); if (kin.reactantStoichCoeff(k, i)) {
allReactants[i].push_back(k);
}
if (kin.productStoichCoeff(k, i)) {
allProducts[i].push_back(k);
}
}
} }
// m_reac and m_prod exclude indices for species that appear on // m_reac and m_prod exclude indices for species that appear on