Removed unnecessary typedef for 'index_t'

This commit is contained in:
Ray Speth 2013-01-11 22:56:44 +00:00
parent 8e7e81570a
commit 31f90fe32d
7 changed files with 90 additions and 98 deletions

View file

@ -61,9 +61,6 @@ class MultiPhase
{
public:
//! Shorthand for an index variable that can't be negative
typedef size_t index_t;
//! Constructor.
/*!
* The constructor takes no arguments, since
@ -195,7 +192,7 @@ public:
/*!
* @param iph phase Index
*/
std::string phaseName(const index_t iph) const;
std::string phaseName(const size_t iph) const;
//! Returns the index, given the phase name
/*!
@ -210,14 +207,14 @@ public:
/*!
* @param n Index of the phase.
*/
doublereal phaseMoles(const index_t n) const;
doublereal phaseMoles(const size_t n) const;
//! Set the number of moles of phase with index n.
/*!
* @param n Index of the phase
* @param moles Number of moles in the phase (kmol)
*/
void setPhaseMoles(const index_t n, const doublereal moles);
void setPhaseMoles(const size_t n, const doublereal moles);
/// Return a %ThermoPhase reference to phase n.
/*! The state of phase n is
@ -228,7 +225,7 @@ public:
*
* @return Reference to the %ThermoPhase object for the phase
*/
ThermoPhase& phase(index_t n);
ThermoPhase& phase(size_t n);
//! Check that the specified phase index is in range
//! Throws an exception if m is greater than nPhases()
@ -246,7 +243,7 @@ public:
*
* @param kGlob Global species index k
*/
doublereal speciesMoles(index_t kGlob) const;
doublereal speciesMoles(size_t kGlob) const;
//! Return the global index of the species belonging to phase number \c p
//! with local index \c k within the phase.
@ -256,7 +253,7 @@ public:
* @param k local index of the species within the phase
* @param p index of the phase
*/
size_t speciesIndex(index_t k, index_t p) const {
size_t speciesIndex(size_t k, size_t p) const {
return m_spstart[p] + k;
}
@ -298,13 +295,13 @@ public:
/*!
* @param p Phase Index
*/
doublereal phaseCharge(index_t p) const;
doublereal phaseCharge(size_t p) const;
//! Total moles of global element \a m, summed over all phases.
/*!
* @param m Index of the global element
*/
doublereal elementMoles(index_t m) const;
doublereal elementMoles(size_t m) const;
//! Returns a vector of Chemical potentials.
/*!
@ -449,7 +446,7 @@ public:
doublereal cp() const;
/// Number of phases.
index_t nPhases() const {
size_t nPhases() const {
return m_np;
}
@ -458,7 +455,7 @@ public:
/*!
* @param kGlob index of the global species
*/
bool solutionSpecies(index_t kGlob) const;
bool solutionSpecies(size_t kGlob) const;
//! Returns the phase index of the Kth "global" species
/*!
@ -467,13 +464,13 @@ public:
* @return
* Returns the index of the owning phase.
*/
size_t speciesPhaseIndex(const index_t kGlob) const;
size_t speciesPhaseIndex(const size_t kGlob) const;
//! Returns the mole fraction of global species k
/*!
* @param kGlob Index of the global species.
*/
doublereal moleFraction(const index_t kGlob) const;
doublereal moleFraction(const size_t kGlob) const;
//! Set the Mole fractions of the nth phase
/*!
@ -484,7 +481,7 @@ public:
* @param n ID of the phase
* @param x Vector of input mole fractions.
*/
void setPhaseMoleFractions(const index_t n, const doublereal* const x);
void setPhaseMoleFractions(const size_t n, const doublereal* const x);
//! Set the number numbers of species in the MultiPhase
/*!
@ -550,7 +547,7 @@ public:
/*!
* @param p Index of the phase.
*/
bool tempOK(index_t p) const;
bool tempOK(size_t p) const;
// These methods are meant for internal use.
@ -658,7 +655,7 @@ private:
/**
* Number of phases in the MultiPhase object
*/
index_t m_np;
size_t m_np;
//! Current value of the temperature (kelvin)
doublereal m_temp;
@ -669,11 +666,11 @@ private:
/**
* Number of distinct elements in all of the phases
*/
index_t m_nel;
size_t m_nel;
/**
* Number of distinct species in all of the phases
*/
index_t m_nsp;
size_t m_nsp;
//! True if the init() routine has been called, and the MultiPhase frozen
bool m_init;

View file

@ -33,13 +33,11 @@ class MultiPhaseEquil
{
public:
typedef size_t index_t;
MultiPhaseEquil(MultiPhase* mix, bool start=true, int loglevel = 0);
virtual ~MultiPhaseEquil() {}
size_t constituent(index_t m) {
size_t constituent(size_t m) {
if (m < m_nel) {
return m_order[m];
} else {
@ -47,8 +45,8 @@ public:
}
}
void getStoichVector(index_t rxn, vector_fp& nu) {
index_t k;
void getStoichVector(size_t rxn, vector_fp& nu) {
size_t k;
nu.resize(m_nsp, 0.0);
if (rxn > nFree()) {
return;
@ -67,10 +65,10 @@ public:
doublereal error();
#if defined(WITH_HTML_LOGS)
std::string reactionString(index_t j);
std::string reactionString(size_t j);
void printInfo(int loglevel);
#else
inline std::string reactionString(index_t j) {
inline std::string reactionString(size_t j) {
return std::string("");
}
inline void printInfo(int loglevel) {}
@ -81,13 +79,13 @@ public:
finish();
}
size_t componentIndex(index_t n) {
size_t componentIndex(size_t n) {
return m_species[m_order[n]];
}
void reportCSV(const std::string& reportFile);
double phaseMoles(index_t iph) const;
double phaseMoles(size_t iph) const;
protected:
@ -124,13 +122,13 @@ protected:
}
//! Number of degrees of freedom
index_t nFree() const {
size_t nFree() const {
return (m_nsp > m_nel) ? m_nsp - m_nel : 0;
}
index_t m_nel_mix, m_nsp_mix, m_np;
index_t m_nel, m_nsp;
index_t m_eloc;
size_t m_nel_mix, m_nsp_mix, m_np;
size_t m_nel, m_nsp;
size_t m_eloc;
int m_iter;
MultiPhase* m_mix;
doublereal m_press, m_temp;

View file

@ -270,9 +270,6 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
class vcs_MultiPhaseEquil
{
public:
//! Typedef for an index variable
typedef size_t index_t;
//! Default empty constructor
vcs_MultiPhaseEquil();
@ -330,7 +327,7 @@ public:
* Length is equal to the number of species in
* the MultiPhase object.
*/
void getStoichVector(index_t rxn, Cantera::vector_fp& nu);
void getStoichVector(size_t rxn, Cantera::vector_fp& nu);
//! return the number of iterations
int iterations() const {

View file

@ -38,7 +38,7 @@ public:
/// Return a reference to phase n. The state of phase n is
/// also updated to match the state stored locally in the
/// mixture object.
LatticePhase& lattice(index_t n) {
LatticePhase& lattice(size_t n) {
return *(LatticePhase*)&phase(n);
}

View file

@ -93,7 +93,7 @@ MultiPhase& MultiPhase::operator=(const MultiPhase& right)
void MultiPhase::
addPhases(MultiPhase& mix)
{
index_t n;
size_t n;
for (n = 0; n < mix.m_np; n++) {
addPhase(mix.m_phase[n], mix.m_moles[n]);
}
@ -102,8 +102,8 @@ addPhases(MultiPhase& mix)
void MultiPhase::
addPhases(std::vector<ThermoPhase*>& phases, const vector_fp& phaseMoles)
{
index_t np = phases.size();
index_t n;
size_t np = phases.size();
size_t n;
for (n = 0; n < np; n++) {
addPhase(phases[n], phaseMoles[n]);
}
@ -136,7 +136,7 @@ addPhase(ThermoPhase* p, doublereal moles)
string ename;
// iterate over the elements in this phase
index_t m, nel = p->nElements();
size_t m, nel = p->nElements();
for (m = 0; m < nel; m++) {
ename = p->elementName(m);
@ -195,7 +195,7 @@ void MultiPhase::init()
if (m_init) {
return;
}
index_t ip, kp, k = 0, nsp, m;
size_t ip, kp, k = 0, nsp, m;
size_t mlocal;
string sym;
@ -257,7 +257,7 @@ void MultiPhase::init()
// Return a reference to phase n. The state of phase n is
// also updated to match the state stored locally in the
// mixture object.
ThermoPhase& MultiPhase::phase(index_t n)
ThermoPhase& MultiPhase::phase(size_t n)
{
if (!m_init) {
init();
@ -284,9 +284,9 @@ void MultiPhase::checkPhaseArraySize(size_t mm) const
//====================================================================================================================
/// Moles of species \c k.
doublereal MultiPhase::speciesMoles(index_t k) const
doublereal MultiPhase::speciesMoles(size_t k) const
{
index_t ip = m_spphase[k];
size_t ip = m_spphase[k];
return m_moles[ip]*m_moleFractions[k];
}
//====================================================================================================================
@ -294,10 +294,10 @@ doublereal MultiPhase::speciesMoles(index_t k) const
/*
* @param m Index of the global element
*/
doublereal MultiPhase::elementMoles(index_t m) const
doublereal MultiPhase::elementMoles(size_t m) const
{
doublereal sum = 0.0, phasesum;
index_t i, k = 0, ik, nsp;
size_t i, k = 0, ik, nsp;
for (i = 0; i < m_np; i++) {
phasesum = 0.0;
nsp = m_phase[i]->nSpecies();
@ -314,7 +314,7 @@ doublereal MultiPhase::elementMoles(index_t m) const
doublereal MultiPhase::charge() const
{
doublereal sum = 0.0;
index_t i;
size_t i;
for (i = 0; i < m_np; i++) {
sum += phaseCharge(i);
}
@ -341,7 +341,7 @@ size_t MultiPhase::speciesIndex(const std::string& speciesName, const std::strin
/// \f[ Q_p = N_p \sum_k F z_k X_k \f]
/// where the sum runs only over species in phase \a p.
/// @param p index of the phase for which the charge is desired.
doublereal MultiPhase::phaseCharge(index_t p) const
doublereal MultiPhase::phaseCharge(size_t p) const
{
doublereal phasesum = 0.0;
size_t ik, k, nsp = m_phase[p]->nSpecies();
@ -356,7 +356,7 @@ doublereal MultiPhase::phaseCharge(index_t p) const
/// Get the chemical potentials of all species in all phases.
void MultiPhase::getChemPotentials(doublereal* mu) const
{
index_t i, loc = 0;
size_t i, loc = 0;
updatePhases();
for (i = 0; i < m_np; i++) {
m_phase[i]->getChemPotentials(mu + loc);
@ -394,7 +394,7 @@ void MultiPhase::getChemPotentials(doublereal* mu) const
void MultiPhase::getValidChemPotentials(doublereal not_mu,
doublereal* mu, bool standard) const
{
index_t i, loc = 0;
size_t i, loc = 0;
updatePhases();
// iterate over the phases
@ -413,7 +413,7 @@ void MultiPhase::getValidChemPotentials(doublereal not_mu,
}
//====================================================================================================================
/// True if species \a k belongs to a solution phase.
bool MultiPhase::solutionSpecies(index_t k) const
bool MultiPhase::solutionSpecies(size_t k) const
{
if (m_phase[m_spphase[k]]->nSpecies() > 1) {
return true;
@ -425,7 +425,7 @@ bool MultiPhase::solutionSpecies(index_t k) const
/// The Gibbs free energy of the mixture (J).
doublereal MultiPhase::gibbs() const
{
index_t i;
size_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++) {
@ -439,7 +439,7 @@ doublereal MultiPhase::gibbs() const
/// The enthalpy of the mixture (J).
doublereal MultiPhase::enthalpy() const
{
index_t i;
size_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++) {
@ -453,7 +453,7 @@ doublereal MultiPhase::enthalpy() const
/// The internal energy of the mixture (J).
doublereal MultiPhase::IntEnergy() const
{
index_t i;
size_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++) {
@ -467,7 +467,7 @@ doublereal MultiPhase::IntEnergy() const
/// The entropy of the mixture (J/K).
doublereal MultiPhase::entropy() const
{
index_t i;
size_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++) {
@ -483,7 +483,7 @@ doublereal MultiPhase::entropy() const
/// the mixture with temperature.
doublereal MultiPhase::cp() const
{
index_t i;
size_t i;
doublereal sum = 0.0;
updatePhases();
for (i = 0; i < m_np; i++) {
@ -498,7 +498,7 @@ doublereal MultiPhase::cp() const
/// Set the mole fractions of phase \a n to the values in
/// array \a x.
void MultiPhase::setPhaseMoleFractions(const index_t n, const doublereal* const x)
void MultiPhase::setPhaseMoleFractions(const size_t n, const doublereal* const x)
{
if (!m_init) {
init();
@ -545,12 +545,12 @@ void MultiPhase::getMoles(doublereal* molNum) const
* First copy in the mole fractions
*/
copy(m_moleFractions.begin(), m_moleFractions.end(), molNum);
index_t ik;
size_t ik;
doublereal* dtmp = molNum;
for (index_t ip = 0; ip < m_np; ip++) {
for (size_t ip = 0; ip < m_np; ip++) {
doublereal phasemoles = m_moles[ip];
ThermoPhase* p = m_phase[ip];
index_t nsp = p->nSpecies();
size_t nsp = p->nSpecies();
for (ik = 0; ik < nsp; ik++) {
*(dtmp++) *= phasemoles;
}
@ -565,8 +565,8 @@ void MultiPhase::setMoles(const doublereal* n)
if (!m_init) {
init();
}
index_t ip, loc = 0;
index_t ik, k = 0, nsp;
size_t ip, loc = 0;
size_t ik, k = 0, nsp;
doublereal phasemoles;
for (ip = 0; ip < m_np; ip++) {
ThermoPhase* p = m_phase[ip];
@ -622,7 +622,7 @@ void MultiPhase::setState_TPMoles(const doublereal T, const doublereal Pres,
//====================================================================================================================
void MultiPhase::getElemAbundances(doublereal* elemAbundances) const
{
index_t eGlobal;
size_t eGlobal;
calcElemAbundances();
for (eGlobal = 0; eGlobal < m_nel; eGlobal++) {
elemAbundances[eGlobal] = m_elemAbundances[eGlobal];
@ -632,14 +632,14 @@ void MultiPhase::getElemAbundances(doublereal* elemAbundances) const
// Internal routine to calculate the element abundance vector
void MultiPhase::calcElemAbundances() const
{
index_t loc = 0;
index_t eGlobal;
index_t ik, kGlobal;
size_t loc = 0;
size_t eGlobal;
size_t ik, kGlobal;
doublereal spMoles;
for (eGlobal = 0; eGlobal < m_nel; eGlobal++) {
m_elemAbundances[eGlobal] = 0.0;
}
for (index_t ip = 0; ip < m_np; ip++) {
for (size_t ip = 0; ip < m_np; ip++) {
ThermoPhase* p = m_phase[ip];
size_t nspPhase = p->nSpecies();
doublereal phasemoles = m_moles[ip];
@ -1076,7 +1076,7 @@ void MultiPhase::getMoleFractions(doublereal* const x) const
std::copy(m_moleFractions.begin(), m_moleFractions.end(), x);
}
//====================================================================================================================
std::string MultiPhase::phaseName(const index_t iph) const
std::string MultiPhase::phaseName(const size_t iph) const
{
const ThermoPhase* tptr = m_phase[iph];
return tptr->id();
@ -1095,28 +1095,28 @@ int MultiPhase::phaseIndex(const std::string& pName) const
return -1;
}
//====================================================================================================================
doublereal MultiPhase::phaseMoles(const index_t n) const
doublereal MultiPhase::phaseMoles(const size_t n) const
{
return m_moles[n];
}
//====================================================================================================================
void MultiPhase::setPhaseMoles(const index_t n, const doublereal moles)
void MultiPhase::setPhaseMoles(const size_t n, const doublereal moles)
{
m_moles[n] = moles;
}
size_t MultiPhase::speciesPhaseIndex(const index_t kGlob) const
size_t MultiPhase::speciesPhaseIndex(const size_t kGlob) const
{
return m_spphase[kGlob];
}
//====================================================================================================================
doublereal MultiPhase::moleFraction(const index_t kGlob) const
doublereal MultiPhase::moleFraction(const size_t kGlob) const
{
return m_moleFractions[kGlob];
}
//====================================================================================================================
bool MultiPhase::tempOK(const index_t p) const
bool MultiPhase::tempOK(const size_t p) const
{
return m_temp_OK[p];
}
@ -1125,7 +1125,7 @@ bool MultiPhase::tempOK(const index_t p) const
/// Update the locally-stored species mole fractions.
void MultiPhase::uploadMoleFractionsFromPhases()
{
index_t ip, loc = 0;
size_t ip, loc = 0;
for (ip = 0; ip < m_np; ip++) {
ThermoPhase* p = m_phase[ip];
p->getMoleFractions(DATA_PTR(m_moleFractions) + loc);
@ -1148,7 +1148,7 @@ void MultiPhase::uploadMoleFractionsFromPhases()
/// mixture mole numbers.
void MultiPhase::updatePhases() const
{
index_t p, nsp, loc = 0;
size_t p, nsp, loc = 0;
for (p = 0; p < m_np; p++) {
nsp = m_phase[p]->nSpecies();
const doublereal* x = DATA_PTR(m_moleFractions) + loc;

View file

@ -61,7 +61,7 @@ MultiPhaseEquil::MultiPhaseEquil(MultiPhase* mix, bool start, int loglevel) : m_
m_press = mix->pressure();
m_temp = mix->temperature();
index_t m, k;
size_t m, k;
m_force = true;
m_nel = 0;
m_nsp = 0;
@ -118,7 +118,7 @@ MultiPhaseEquil::MultiPhaseEquil(MultiPhase* mix, bool start, int loglevel) : m_
// unphysical results above this temperature, leading
// (incorrectly) to Gibbs free energies at high temperature
// lower than for liquid water.
index_t ip;
size_t ip;
for (k = 0; k < m_nsp_mix; k++) {
ip = m_mix->speciesPhaseIndex(k);
if (!m_mix->solutionSpecies(k) &&
@ -155,7 +155,7 @@ MultiPhaseEquil::MultiPhaseEquil(MultiPhase* mix, bool start, int loglevel) : m_
m_dxi.resize(nFree());
// initialize the mole numbers to the mixture composition
index_t ik;
size_t ik;
for (ik = 0; ik < m_nsp; ik++) {
m_moles[ik] = m_mix->speciesMoles(m_species[ik]);
}
@ -257,7 +257,7 @@ doublereal MultiPhaseEquil::equilibrate(int XY, doublereal err,
void MultiPhaseEquil::updateMixMoles()
{
fill(m_work3.begin(), m_work3.end(), 0.0);
index_t k;
size_t k;
for (k = 0; k < m_nsp; k++) {
m_work3[m_species[k]] = m_moles[k];
}
@ -271,7 +271,7 @@ void MultiPhaseEquil::updateMixMoles()
void MultiPhaseEquil::finish()
{
fill(m_work3.begin(), m_work3.end(), 0.0);
index_t k;
size_t k;
for (k = 0; k < m_nsp; k++) {
m_work3[m_species[k]] = (m_moles[k] > 0.0 ? m_moles[k] : 0.0);
}
@ -290,7 +290,7 @@ void MultiPhaseEquil::finish()
/// non-negativity constraints.
int MultiPhaseEquil::setInitialMoles(int loglevel)
{
index_t ik, j;
size_t ik, j;
double not_mu = 1.0e12;
if (loglevel > 0) {
@ -396,7 +396,7 @@ int MultiPhaseEquil::setInitialMoles(int loglevel)
///
void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
{
index_t m, k, j;
size_t m, k, j;
// if the input species array has the wrong size, ignore it
// and consider the species for components in declaration order.
@ -410,8 +410,8 @@ void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
}
}
index_t nRows = m_nel;
index_t nColumns = m_nsp;
size_t nRows = m_nel;
size_t nColumns = m_nsp;
doublereal fctr;
// set up the atomic composition matrix
@ -433,7 +433,7 @@ void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
}
if (isZeroRow) {
// Find the last non-zero row
index_t n = nRows - 1;
size_t n = nRows - 1;
bool foundSwapCandidate = false;
for (; n > m; n--) {
for (k = m; k < nColumns; k++) {
@ -470,7 +470,7 @@ void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
// possible. We'll choose the species with greatest
// mole fraction that satisfies these criteria.
doublereal maxmoles = -999.0;
index_t kmax = 0;
size_t kmax = 0;
for (k = m+1; k < nColumns; k++) {
if (m_A(m,k) != 0.0) {
if (fabs(m_moles[m_order[k]]) > maxmoles) {
@ -553,7 +553,7 @@ void MultiPhaseEquil::getComponents(const std::vector<size_t>& order)
void MultiPhaseEquil::unsort(vector_fp& x)
{
copy(x.begin(), x.end(), m_work2.begin());
index_t k;
size_t k;
for (k = 0; k < m_nsp; k++) {
x[m_order[k]] = m_work2[k];
}
@ -562,7 +562,7 @@ void MultiPhaseEquil::unsort(vector_fp& x)
#if defined(WITH_HTML_LOGS)
void MultiPhaseEquil::printInfo(int loglevel)
{
index_t m, ik, k;
size_t m, ik, k;
if (loglevel > 0) {
beginLogGroup("info");
beginLogGroup("components");
@ -602,10 +602,10 @@ void MultiPhaseEquil::printInfo(int loglevel)
}
/// Return a string specifying the jth reaction.
string MultiPhaseEquil::reactionString(index_t j)
string MultiPhaseEquil::reactionString(size_t j)
{
string sr = "", sp = "";
index_t i, k;
size_t i, k;
bool rstrt = true;
bool pstrt = true;
doublereal nu;
@ -628,7 +628,7 @@ string MultiPhaseEquil::reactionString(index_t j)
void MultiPhaseEquil::step(doublereal omega, vector_fp& deltaN,
int loglevel)
{
index_t k, ik;
size_t k, ik;
if (loglevel > 0) {
beginLogGroup("MultiPhaseEquil::step");
}
@ -675,7 +675,7 @@ stepComposition(int loglevel)
}
m_iter++;
index_t ik, k = 0;
size_t ik, k = 0;
doublereal grad0 = computeReactionSteps(m_dxi);
// compute the mole fraction changes.
@ -780,7 +780,7 @@ stepComposition(int loglevel)
doublereal MultiPhaseEquil::computeReactionSteps(vector_fp& dxi)
{
index_t j, k, ik, kc, ip;
size_t j, k, ik, kc, ip;
doublereal stoich, nmoles, csum, term1, fctr, rfctr;
vector_fp nu;
doublereal grad = 0.0;
@ -859,7 +859,7 @@ doublereal MultiPhaseEquil::computeReactionSteps(vector_fp& dxi)
}
dxi[j] = -fctr*dg_rt;
index_t m;
size_t m;
for (m = 0; m < m_nel; m++) {
if (m_moles[m_order[m]] <= 0.0 && (m_N(m, j)*dxi[j] < 0.0)) {
dxi[j] = 0.0;
@ -937,7 +937,7 @@ doublereal MultiPhaseEquil::error()
return maxerr;
}
double MultiPhaseEquil::phaseMoles(index_t iph) const
double MultiPhaseEquil::phaseMoles(size_t iph) const
{
return m_mix->phaseMoles(iph);
}

View file

@ -1451,7 +1451,7 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
}
//====================================================================================================================
// This routine hasn't been checked yet
void vcs_MultiPhaseEquil::getStoichVector(index_t rxn, Cantera::vector_fp& nu)
void vcs_MultiPhaseEquil::getStoichVector(size_t rxn, Cantera::vector_fp& nu)
{
size_t nsp = m_vsolvePtr->m_numSpeciesTot;
nu.resize(nsp, 0.0);