Skip to content

Commit

Permalink
Eliminate unnecessary counter member variables
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Dec 1, 2015
1 parent 2dfa43f commit 4887775
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 222 deletions.
5 changes: 1 addition & 4 deletions include/cantera/equil/MultiPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class MultiPhase

//! Number of phases.
size_t nPhases() const {
return m_np;
return m_phase.size();
}

//! Return true is species \a kGlob is a species in a multicomponent
Expand Down Expand Up @@ -617,9 +617,6 @@ class MultiPhase
*/
std::map<std::string, size_t> m_enamemap;

//! Number of phases in the MultiPhase object
size_t m_np;

//! Current value of the temperature (kelvin)
doublereal m_temp;

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/equil/MultiPhaseEquil.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class MultiPhaseEquil
return (m_nsp > m_nel) ? m_nsp - m_nel : 0;
}

size_t m_nel_mix, m_nsp_mix, m_np;
size_t m_nel_mix, m_nsp_mix;
size_t m_nel, m_nsp;
size_t m_eloc;
int m_iter;
Expand Down
2 changes: 0 additions & 2 deletions include/cantera/kinetics/GasKinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ class GasKinetics : public BulkKinetics
virtual void update_rates_C();

protected:
size_t m_nfall;

//! Reaction index of each falloff reaction
std::vector<size_t> m_fallindx;

Expand Down
10 changes: 0 additions & 10 deletions include/cantera/kinetics/ImplicitSurfChem.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,12 @@ class ImplicitSurfChem : public FuncEval

std::vector<size_t> m_specStartIndex;

//! Total number of surface phases.
/*!
* This is also equal to the number of InterfaceKinetics objects
* as there is a 1-1 correspondence between InterfaceKinetics objects
* and surface phases.
*/
size_t m_nsurf;

//! Total number of surface species in all surface phases
/*!
* This is the total number of unknowns in m_mode 0 problem
*/
size_t m_nv;

size_t m_numBulkPhases;
std::vector<size_t> m_nspBulkPhases;
size_t m_numTotalBulkSpecies;
size_t m_numTotalSpecies;

Expand Down
6 changes: 0 additions & 6 deletions include/cantera/kinetics/InterfaceKinetics.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,6 @@ class InterfaceKinetics : public Kinetics
*/
std::vector<size_t> m_irrev;

//! Number of irreversible reactions in the mechanism
size_t m_nirrev;

//! Number of reversible reactions in the mechanism
size_t m_nrev;

//! Array of concentrations for each species in the kinetics mechanism
/*!
* An array of generalized concentrations \f$ C_k \f$ that are defined
Expand Down
5 changes: 2 additions & 3 deletions include/cantera/kinetics/RxnRates.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ class SurfaceArrhenius
m_mcov = 0.0;
size_t k;
doublereal th;
for (size_t n = 0; n < m_ncov; n++) {
for (size_t n = 0; n < m_ac.size(); n++) {
k = m_sp[n];
m_acov += m_ac[n] * theta[k];
m_ecov += m_ec[n] * theta[k];
}
for (size_t n = 0; n < m_nmcov; n++) {
for (size_t n = 0; n < m_mc.size(); n++) {
k = m_msp[n];
th = std::max(theta[k], Tiny);
m_mcov += m_mc[n]*std::log(th);
Expand Down Expand Up @@ -177,7 +177,6 @@ class SurfaceArrhenius
doublereal m_acov, m_ecov, m_mcov;
std::vector<size_t> m_sp, m_msp;
vector_fp m_ac, m_ec, m_mc;
size_t m_ncov, m_nmcov;
};


Expand Down
21 changes: 6 additions & 15 deletions include/cantera/numerics/Func1.h
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,8 @@ class Poly1 : public Func1
public:
Poly1(size_t n, doublereal* c) :
Func1() {
m_n = n+1;
m_cpoly.resize(n+1);
std::copy(c, c+m_n, m_cpoly.begin());
std::copy(c, c+m_cpoly.size(), m_cpoly.begin());
}

Poly1(const Poly1& b) :
Expand All @@ -836,7 +835,6 @@ class Poly1 : public Func1
}
Func1::operator=(right);
m_cpoly = right.m_cpoly;
m_n = right.m_n;
m_parent = 0;
return *this;
}
Expand All @@ -847,16 +845,15 @@ class Poly1 : public Func1
}

virtual doublereal eval(doublereal t) const {
doublereal r = m_cpoly[m_n-1];
for (size_t n = 1; n < m_n; n++) {
doublereal r = m_cpoly[m_cpoly.size()-1];
for (size_t n = 1; n < m_cpoly.size(); n++) {
r *= t;
r += m_cpoly[m_n - n - 1];
r += m_cpoly[m_cpoly.size() - n - 1];
}
return r;
}

protected:
size_t m_n;
vector_fp m_cpoly;
};

Expand All @@ -875,7 +872,6 @@ class Fourier1 : public Func1
Fourier1(size_t n, doublereal omega, doublereal a0,
doublereal* a, doublereal* b) :
Func1() {
m_n = n;
m_omega = omega;
m_a0_2 = 0.5*a0;
m_ccos.resize(n);
Expand All @@ -898,7 +894,6 @@ class Fourier1 : public Func1
m_a0_2 = right.m_a0_2;
m_ccos = right.m_ccos;
m_csin = right.m_csin;
m_n = right.m_n;
m_parent = 0;
return *this;
}
Expand All @@ -911,7 +906,7 @@ class Fourier1 : public Func1
virtual doublereal eval(doublereal t) const {
size_t n, nn;
doublereal sum = m_a0_2;
for (n = 0; n < m_n; n++) {
for (n = 0; n < m_ccos.size(); n++) {
nn = n + 1;
sum += m_ccos[n]*std::cos(m_omega*nn*t)
+ m_csin[n]*std::sin(m_omega*nn*t);
Expand All @@ -920,7 +915,6 @@ class Fourier1 : public Func1
}

protected:
size_t m_n;
doublereal m_omega, m_a0_2;
vector_fp m_ccos, m_csin;
};
Expand All @@ -937,7 +931,6 @@ class Arrhenius1 : public Func1
public:
Arrhenius1(size_t n, doublereal* c) :
Func1() {
m_n = n;
m_A.resize(n);
m_b.resize(n);
m_E.resize(n);
Expand All @@ -959,7 +952,6 @@ class Arrhenius1 : public Func1
return *this;
}
Func1::operator=(right);
m_n = right.m_n;
m_A = right.m_A;
m_b = right.m_b;
m_E = right.m_E;
Expand All @@ -974,14 +966,13 @@ class Arrhenius1 : public Func1

virtual doublereal eval(doublereal t) const {
doublereal sum = 0.0;
for (size_t n = 0; n < m_n; n++) {
for (size_t n = 0; n < m_A.size(); n++) {
sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
}
return sum;
}

protected:
size_t m_n;
vector_fp m_A, m_b, m_E;
};

Expand Down
13 changes: 5 additions & 8 deletions include/cantera/oneD/OneDim.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class OneDim

/// Number of domains.
size_t nDomains() const {
return m_nd;
return m_dom.size();
}

/// Return a reference to domain i.
Expand All @@ -60,17 +60,17 @@ class OneDim
//! Check that the specified domain index is in range.
//! Throws an exception if n is greater than nDomains()-1
void checkDomainIndex(size_t n) const {
if (n >= m_nd) {
throw IndexError("checkDomainIndex", "domains", n, m_nd-1);
if (n >= m_dom.size()) {
throw IndexError("checkDomainIndex", "domains", n, m_dom.size()-1);
}
}

//! Check that an array size is at least nDomains().
//! Throws an exception if nn is less than nDomains(). Used before calls
//! which take an array pointer.
void checkDomainArraySize(size_t nn) const {
if (m_nd > nn) {
throw ArraySizeError("checkDomainArraySize", nn, m_nd);
if (m_dom.size() > nn) {
throw ArraySizeError("checkDomainArraySize", nn, m_dom.size());
}
}

Expand Down Expand Up @@ -264,9 +264,6 @@ class OneDim
doublereal m_rdt; //!< reciprocal of time step
bool m_jac_ok; //!< if true, Jacobian is current

//! number of domains
size_t m_nd;

size_t m_bw; //!< Jacobian bandwidth
size_t m_size; //!< solution vector size

Expand Down
18 changes: 7 additions & 11 deletions include/cantera/thermo/AdsorbateThermo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ class Adsorbate : public SpeciesThermoInterpType
{
public:
//! Empty constructor
Adsorbate() :
m_nFreqs(0) {
}
Adsorbate() {}

//! Full Constructor
/*!
Expand All @@ -43,10 +41,9 @@ class Adsorbate : public SpeciesThermoInterpType
Adsorbate(double tlow, double thigh, double pref, const double* coeffs)
: SpeciesThermoInterpType(tlow, thigh, pref)
{
m_nFreqs = int(coeffs[0]);
m_freq.resize(int(coeffs[0]));
m_be = coeffs[1];
m_freq.resize(m_nFreqs);
std::copy(coeffs+2, coeffs + 2 + m_nFreqs, m_freq.begin());
std::copy(coeffs+2, coeffs + 2 + m_freq.size(), m_freq.begin());
}

virtual SpeciesThermoInterpType*
Expand Down Expand Up @@ -76,23 +73,22 @@ class Adsorbate : public SpeciesThermoInterpType
tlow = m_lowT;
thigh = m_highT;
pref = m_Pref;
coeffs[0] = static_cast<double>(m_nFreqs);
coeffs[0] = static_cast<double>(m_freq.size());
coeffs[1] = m_be;
for (size_t i = 2; i < m_nFreqs+2; i++) {
for (size_t i = 2; i < m_freq.size()+2; i++) {
coeffs[i] = m_freq[i-2];
}
}

protected:
size_t m_nFreqs;
//! array of vib frequencies
vector_fp m_freq;
doublereal m_be;

doublereal _energy_RT(double T) const {
doublereal x, hnu_kt, hnu, sum = 0.0;
doublereal kt = T*Boltzmann;
for (size_t i = 0; i < m_nFreqs; i++) {
for (size_t i = 0; i < m_freq.size(); i++) {
hnu = Planck * m_freq[i];
hnu_kt = hnu/kt;
x = exp(-hnu_kt);
Expand All @@ -104,7 +100,7 @@ class Adsorbate : public SpeciesThermoInterpType
doublereal _free_energy_RT(double T) const {
doublereal x, hnu_kt, sum = 0.0;
doublereal kt = T*Boltzmann;
for (size_t i = 0; i < m_nFreqs; i++) {
for (size_t i = 0; i < m_freq.size(); i++) {
hnu_kt = Planck * m_freq[i] / kt;
x = exp(-hnu_kt);
sum += log(1.0 - x);
Expand Down
3 changes: 0 additions & 3 deletions include/cantera/thermo/LatticeSolidPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,6 @@ class LatticeSolidPhase : public ThermoPhase
//! Current value of the molar density
doublereal m_molar_density;

//! Number of sublattice phases
size_t m_nlattice;

//! Vector of sublattic ThermoPhase objects
std::vector<LatticePhase*> m_lattice;

Expand Down
3 changes: 0 additions & 3 deletions include/cantera/thermo/Nasa9PolyMultiTempRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ class Nasa9PolyMultiTempRegion : public SpeciesThermoInterpType
virtual void modifyParameters(doublereal* coeffs);

protected:
//! Number of temperature regions
size_t m_numTempRegions;

//! Lower boundaries of each temperature regions
vector_fp m_lowerTempBounds;

Expand Down
Loading

0 comments on commit 4887775

Please sign in to comment.