Skip to content

Commit

Permalink
[Kinetics] Deprecate 'reactants' and 'products' methods
Browse files Browse the repository at this point in the history
These methods are rarely used, and they expose a now-unused internal data
structure that isn't even correct for all reactions.
  • Loading branch information
speth committed Nov 7, 2014
1 parent 7eb726d commit 37f71bd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
9 changes: 9 additions & 0 deletions include/cantera/kinetics/Kinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "cantera/thermo/ThermoPhase.h"
#include "StoichManager.h"
#include "cantera/thermo/mix_defs.h"
#include "cantera/base/global.h"

namespace Cantera
{
Expand Down Expand Up @@ -652,8 +653,11 @@ class Kinetics
* index numbers for reaction i.
*
* @param i reaction index
* @deprecated To be removed after Cantera 2.2.
*/
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];
}

Expand All @@ -662,8 +666,11 @@ class Kinetics
* index numbers for reaction i.
*
* @param i reaction index
* @deprecated To be removed after Cantera 2.2.
*/
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];
}

Expand Down Expand Up @@ -912,6 +919,7 @@ class Kinetics
* stoichiometric coefficient.
* NOTE: These vectors will be wrong if there are real
* stoichiometric coefficients in the expression.
* @deprecated To be removed after Cantera 2.2.
*/
std::vector<std::vector<size_t> > m_reactants;

Expand All @@ -925,6 +933,7 @@ class Kinetics
* coefficient.
* NOTE: These vectors will be wrong if there are real
* stoichiometric coefficients in the expression.
* @deprecated To be removed after Cantera 2.2.
*/
std::vector<std::vector<size_t> > m_products;

Expand Down
10 changes: 4 additions & 6 deletions src/kinetics/InterfaceKinetics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,15 +811,13 @@ void InterfaceKinetics::addReaction(ReactionData& r)
m_rxnPhaseIsProduct.push_back(std::vector<bool>(nPhases(), false));

size_t i = m_ii - 1;
const std::vector<size_t>& vr = reactants(i);
for (size_t ik = 0; ik < vr.size(); ik++) {
size_t k = vr[ik];
for (size_t ik = 0; ik < r.reactants.size(); ik++) {
size_t k = r.reactants[ik];
size_t p = speciesPhaseIndex(k);
m_rxnPhaseIsReactant[i][p] = true;
}
const std::vector<size_t>& vp = products(i);
for (size_t ik = 0; ik < vp.size(); ik++) {
size_t k = vp[ik];
for (size_t ik = 0; ik < r.products.size(); ik++) {
size_t k = r.products[ik];
size_t p = speciesPhaseIndex(k);
m_rxnPhaseIsProduct[i][p] = true;
}
Expand Down
25 changes: 19 additions & 6 deletions src/kinetics/ReactionPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,15 @@ int ReactionPathBuilder::findGroups(ostream& logfile, Kinetics& s)

size_t nrnet = m_reac[i].size();
size_t npnet = m_prod[i].size();
const std::vector<size_t>& r = s.reactants(i);
const std::vector<size_t>& p = s.products(i);
std::vector<size_t> r, p;
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 np = p.size();
Expand Down Expand Up @@ -656,11 +663,17 @@ int ReactionPathBuilder::init(ostream& logfile, Kinetics& kin)

// all reactants / products, even ones appearing on both sides
// of the reaction
vector<vector<size_t> > allProducts;
vector<vector<size_t> > allReactants;
vector<vector<size_t> > allProducts(m_nr);
vector<vector<size_t> > allReactants(m_nr);
for (size_t i = 0; i < m_nr; i++) {
allReactants.push_back(kin.reactants(i));
allProducts.push_back(kin.products(i));
for (size_t k = 0; k < m_ns; k++) {
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
Expand Down

0 comments on commit 37f71bd

Please sign in to comment.