From 1ff7c2386079aa54a8c072e5276c2b1a5e00a793 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 17 Jan 2012 23:58:48 +0000 Subject: [PATCH] Fixed signed/unsigned equality comparisons --- Cantera/clib/src/Storage.cpp | 6 +-- Cantera/src/base/ct_defs.h | 2 + Cantera/src/base/ctml.cpp | 4 +- Cantera/src/equil/ChemEquil.cpp | 10 ++--- Cantera/src/equil/MultiPhase.cpp | 10 ++--- Cantera/src/equil/MultiPhaseEquil.cpp | 4 +- Cantera/src/equil/vcs_Gibbs.cpp | 2 +- Cantera/src/equil/vcs_MultiPhaseEquil.cpp | 2 +- Cantera/src/equil/vcs_VolPhase.cpp | 12 ++--- Cantera/src/equil/vcs_elem.cpp | 2 +- Cantera/src/equil/vcs_internal.h | 1 + Cantera/src/equil/vcs_prob.cpp | 2 +- Cantera/src/equil/vcs_solve.h | 4 +- Cantera/src/equil/vcs_solve_TP.cpp | 24 +++++----- Cantera/src/kinetics/AqueousKinetics.cpp | 2 +- Cantera/src/kinetics/GasKinetics.cpp | 2 +- Cantera/src/kinetics/InterfaceKinetics.cpp | 10 ++--- Cantera/src/kinetics/Kinetics.cpp | 14 +++--- Cantera/src/kinetics/ReactionPath.cpp | 6 +-- Cantera/src/kinetics/importKinetics.cpp | 4 +- Cantera/src/oneD/Domain1D.cpp | 6 +-- Cantera/src/oneD/MultiJac.cpp | 2 +- Cantera/src/oneD/MultiNewton.cpp | 4 +- Cantera/src/oneD/OneDim.cpp | 4 +- Cantera/src/oneD/StFlow.cpp | 16 +++---- Cantera/src/oneD/StFlow.h | 12 ++--- Cantera/src/oneD/boundaries1D.cpp | 14 +++--- Cantera/src/thermo/ConstDensityThermo.h | 3 +- Cantera/src/thermo/Constituents.cpp | 2 +- Cantera/src/thermo/DebyeHuckel.cpp | 4 +- Cantera/src/thermo/GeneralSpeciesThermo.cpp | 6 +-- Cantera/src/thermo/HMWSoln_input.cpp | 44 +++++++++---------- Cantera/src/thermo/IdealGasPhase.h | 3 +- Cantera/src/thermo/IdealMolalSoln.cpp | 2 +- Cantera/src/thermo/IdealSolidSolnPhase.cpp | 13 +++--- Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp | 2 +- Cantera/src/thermo/MargulesVPSSTP.cpp | 8 ++-- Cantera/src/thermo/MineralEQ3.cpp | 2 +- Cantera/src/thermo/MolalityVPSSTP.cpp | 10 ++--- Cantera/src/thermo/MolalityVPSSTP.h | 2 +- Cantera/src/thermo/Mu0Poly.cpp | 8 ++-- Cantera/src/thermo/NasaThermo.h | 12 ++--- Cantera/src/thermo/PDSS_HKFT.cpp | 2 +- Cantera/src/thermo/Phase.cpp | 6 +-- Cantera/src/thermo/PseudoBinaryVPSSTP.cpp | 2 +- Cantera/src/thermo/ShomateThermo.h | 12 ++--- Cantera/src/thermo/SimpleThermo.h | 14 +++--- Cantera/src/thermo/SpeciesThermoFactory.cpp | 2 +- .../src/thermo/SpeciesThermoInterpType.cpp | 2 +- Cantera/src/thermo/SpeciesThermoInterpType.h | 2 +- Cantera/src/thermo/SpeciesThermoMgr.h | 4 +- Cantera/src/thermo/State.cpp | 5 +-- Cantera/src/thermo/VPSSMgr.cpp | 6 +-- Cantera/src/thermo/VPSSMgr_IdealGas.cpp | 2 +- Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp | 2 +- Cantera/src/thermo/WaterSSTP.cpp | 4 +- Cantera/src/transport/TransportFactory.cpp | 2 +- Cantera/src/zeroD/ConstPressureReactor.cpp | 4 +- Cantera/src/zeroD/FlowReactor.cpp | 2 +- Cantera/src/zeroD/Reactor.cpp | 4 +- Cantera/src/zeroD/Wall.cpp | 6 +-- tools/testtools/tok_input_util.cpp | 2 +- 62 files changed, 192 insertions(+), 195 deletions(-) diff --git a/Cantera/clib/src/Storage.cpp b/Cantera/clib/src/Storage.cpp index 741598f5d..f6c4db931 100755 --- a/Cantera/clib/src/Storage.cpp +++ b/Cantera/clib/src/Storage.cpp @@ -20,7 +20,7 @@ Storage::Storage() { Storage::~Storage() { clear(); } size_t Storage::addThermo(thermo_t* th) { - if (th->index() != -1) + if (th->index() != npos) return th->index(); __thtable.push_back(th); size_t n = __thtable.size() - 1; @@ -42,7 +42,7 @@ size_t Storage::nThermo() { } size_t Storage::addKinetics(Kinetics* kin) { - if (kin->index() != -1) + if (kin->index() != npos) return kin->index(); __ktable.push_back(kin); size_t n = __ktable.size() - 1; @@ -51,7 +51,7 @@ size_t Storage::addKinetics(Kinetics* kin) { } size_t Storage::addTransport(Transport* tr) { - if (tr->index() != -1) + if (tr->index() != npos) return tr->index(); __trtable.push_back(tr); size_t n = __trtable.size() - 1; diff --git a/Cantera/src/base/ct_defs.h b/Cantera/src/base/ct_defs.h index 08c360b53..a71e6182f 100644 --- a/Cantera/src/base/ct_defs.h +++ b/Cantera/src/base/ct_defs.h @@ -225,6 +225,8 @@ namespace Cantera { //! typedef for a pointer to temporary work storage which is treated as constant typedef const doublereal* const_workPtr; + //! index returned by functions to indicate "no position" + const size_t npos = -1; } // namespace diff --git a/Cantera/src/base/ctml.cpp b/Cantera/src/base/ctml.cpp index 9a3c5411d..12b93347c 100644 --- a/Cantera/src/base/ctml.cpp +++ b/Cantera/src/base/ctml.cpp @@ -1149,7 +1149,7 @@ namespace ctml { break; } } - if (irow == -1) { + if (irow == npos) { throw CanteraError("getMatrixValues","Row not matched by string: " + key1); } @@ -1159,7 +1159,7 @@ namespace ctml { break; } } - if (icol == -1) { + if (icol == npos) { throw CanteraError("getMatrixValues","Col not matched by string: " + key2); } diff --git a/Cantera/src/equil/ChemEquil.cpp b/Cantera/src/equil/ChemEquil.cpp index fbd9b4ff8..005dfcf12 100755 --- a/Cantera/src/equil/ChemEquil.cpp +++ b/Cantera/src/equil/ChemEquil.cpp @@ -148,7 +148,7 @@ namespace Cantera { // if negative atom numbers have already been specified // for some element other than this one, throw // an exception - if (mneg != -1 && mneg != m) + if (mneg != npos && mneg != m) throw CanteraError("ChemEquil::initialize", "negative atom numbers allowed for only one element"); mneg = m; @@ -1573,7 +1573,7 @@ namespace Cantera { if (n_i_calc[k] > nCutoff) { if (fabs(nAtoms(k,m)) > 0.001) { nSpeciesWithElem++; - if (kMSp != -1) { + if (kMSp != npos) { kMSp2 = k; double factor = fabs(nAtoms(kMSp,m) / nAtoms(kMSp2,m)); for (n = 0; n < m_mm; n++) { @@ -1763,7 +1763,7 @@ namespace Cantera { */ modifiedMatrix = false; for (m = 0; m < m_mm; m++) { - size_t sameAsRow = -1; + size_t sameAsRow = npos; for (size_t im = 0; im < m; im++) { bool theSame = true; for (n = 0; n < m_mm; n++) { @@ -1776,7 +1776,7 @@ namespace Cantera { sameAsRow = im; } } - if (sameAsRow != -1 || lumpSum[m]) { + if (sameAsRow != npos || lumpSum[m]) { #ifdef DEBUG_MODE if (ChemEquil_print_lvl > 0) { if (lumpSum[m]) { @@ -1897,7 +1897,7 @@ namespace Cantera { * */ void ChemEquil::adjustEloc(thermo_t &s, vector_fp & elMolesGoal) { - if (m_eloc == -1) return; + if (m_eloc == npos) return; if (fabs(elMolesGoal[m_eloc]) > 1.0E-20) return; s.getMoleFractions(DATA_PTR(m_molefractions)); size_t k; diff --git a/Cantera/src/equil/MultiPhase.cpp b/Cantera/src/equil/MultiPhase.cpp index 8edba916c..1d8fe19ec 100644 --- a/Cantera/src/equil/MultiPhase.cpp +++ b/Cantera/src/equil/MultiPhase.cpp @@ -144,7 +144,7 @@ namespace Cantera { nsp = p->nSpecies(); mlocal = p->elementIndex(sym); for (kp = 0; kp < nsp; kp++) { - if (mlocal != -1) { + if (mlocal != npos) { m_atoms(m, k) = p->nAtoms(kp, mlocal); } if (m == 0) { @@ -159,12 +159,12 @@ namespace Cantera { } } - if (m_eloc >= 0) { + if (m_eloc != npos) { doublereal esum; for (k = 0; k < m_nsp; k++) { esum = 0.0; for (m = 0; m < m_nel; m++) { - if (int(m) != m_eloc) + if (m != m_eloc) esum += m_atoms(m,k) * m_atomicNumber[m]; } //m_atoms(m_eloc, k) += esum; @@ -226,11 +226,11 @@ namespace Cantera { size_t MultiPhase::speciesIndex(std::string speciesName, std::string phaseName) { size_t p = phaseIndex(phaseName); - if (p == -1) { + if (p == npos) { throw CanteraError("MultiPhase::speciesIndex", "phase not found: " + phaseName); } size_t k = m_phase[p]->speciesIndex(speciesName); - if (k == -1) { + if (k == npos) { throw CanteraError("MultiPhase::speciesIndex", "species not found: " + speciesName); } return m_spstart[p] + k; diff --git a/Cantera/src/equil/MultiPhaseEquil.cpp b/Cantera/src/equil/MultiPhaseEquil.cpp index 6c6f5775d..0393fc4bf 100644 --- a/Cantera/src/equil/MultiPhaseEquil.cpp +++ b/Cantera/src/equil/MultiPhaseEquil.cpp @@ -460,7 +460,7 @@ namespace Cantera { // The left m_nel columns of A are now upper-diagonal. Now // reduce the m_nel columns to diagonal form by back-solving for (m = nRows-1; m > 0; m--) { - for (size_t n = m-1; n != -1; n--) { + for (size_t n = m-1; n != npos; n--) { if (m_A(n,m) != 0.0) { fctr = m_A(n,m); for (k = m; k < m_nsp; k++) { @@ -828,7 +828,7 @@ namespace Cantera { } ok = false; for (ij = 0; ij < m_nel; ij++) { - if (int(k) == m_order[ij]) ok = true; + if (k == m_order[ij]) ok = true; } if (!ok || m_force) { getComponents(m_sortindex); diff --git a/Cantera/src/equil/vcs_Gibbs.cpp b/Cantera/src/equil/vcs_Gibbs.cpp index 8d2a36c18..c3e184442 100644 --- a/Cantera/src/equil/vcs_Gibbs.cpp +++ b/Cantera/src/equil/vcs_Gibbs.cpp @@ -64,7 +64,7 @@ namespace VCSnonideal { * @param w Species mole number vector * @param fe vector of partial molar free energies of the species. */ - double VCS_SOLVE::vcs_GibbsPhase(int iphase, const double * const w, + double VCS_SOLVE::vcs_GibbsPhase(size_t iphase, const double * const w, const double * const fe) { double g = 0.0; double phaseMols = 0.0; diff --git a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp index 1377a3054..56a4e0af7 100644 --- a/Cantera/src/equil/vcs_MultiPhaseEquil.cpp +++ b/Cantera/src/equil/vcs_MultiPhaseEquil.cpp @@ -1334,7 +1334,7 @@ namespace VCSnonideal { kT++; } - if (volPhase->phiVarIndex() != -1) { + if (volPhase->phiVarIndex() != npos) { size_t kphi = volPhase->phiVarIndex(); size_t kglob = volPhase->spGlobalIndexVCS(kphi); vprob->w[kglob] = tPhase->electricPotential(); diff --git a/Cantera/src/equil/vcs_VolPhase.cpp b/Cantera/src/equil/vcs_VolPhase.cpp index 35727d9a3..0dd3fa0c3 100644 --- a/Cantera/src/equil/vcs_VolPhase.cpp +++ b/Cantera/src/equil/vcs_VolPhase.cpp @@ -291,7 +291,7 @@ namespace VCSnonideal { IndSpecies.resize(nspecies, -1); - if ((int) ListSpeciesPtr.size() >= m_numSpecies) { + if (ListSpeciesPtr.size() >= m_numSpecies) { for (size_t i = 0; i < m_numSpecies; i++) { if (ListSpeciesPtr[i]) { delete ListSpeciesPtr[i]; @@ -646,7 +646,7 @@ namespace VCSnonideal { * Update the electric potential if it is a solution variable * in the equation system */ - if (m_phiVarIndex != -1) { + if (m_phiVarIndex != npos) { kglob = IndSpecies[m_phiVarIndex]; if (m_numSpecies == 1) { Xmol[m_phiVarIndex] = 1.0; @@ -1468,7 +1468,7 @@ namespace VCSnonideal { size_t vcs_VolPhase::transferElementsFM(const Cantera::ThermoPhase * const tPhase) { size_t e, k, eT; std::string ename; - size_t eFound = -2; + size_t eFound = npos; /* * */ @@ -1492,7 +1492,7 @@ namespace VCSnonideal { elemResize(ne); - if (ChargeNeutralityElement != -1) { + if (ChargeNeutralityElement != npos) { m_elementType[ChargeNeutralityElement] = VCS_ELEM_TYPE_CHARGENEUTRALITY; } @@ -1524,7 +1524,7 @@ namespace VCSnonideal { } } } - if (eFound == -2) { + if (eFound == npos) { eFound = ne; m_elementType[ne] = VCS_ELEM_TYPE_ELECTRONCHARGE; m_elementActive[ne] = 0; @@ -1568,7 +1568,7 @@ namespace VCSnonideal { fm[e][k] = tPhase->nAtoms(k, eT); e++; } - if (eFound != -2) { + if (eFound != npos) { fm[eFound][k] = - tPhase->charge(k); } } diff --git a/Cantera/src/equil/vcs_elem.cpp b/Cantera/src/equil/vcs_elem.cpp index d880c3b68..b0453d67d 100644 --- a/Cantera/src/equil/vcs_elem.cpp +++ b/Cantera/src/equil/vcs_elem.cpp @@ -127,7 +127,7 @@ namespace VCSnonideal { /*****************************************************************************/ /*****************************************************************************/ - void VCS_SOLVE::vcs_elabPhase(int iphase, double * const elemAbundPhase) + void VCS_SOLVE::vcs_elabPhase(size_t iphase, double * const elemAbundPhase) /************************************************************************* * diff --git a/Cantera/src/equil/vcs_internal.h b/Cantera/src/equil/vcs_internal.h index 33d9e5e59..cc8e12cfb 100644 --- a/Cantera/src/equil/vcs_internal.h +++ b/Cantera/src/equil/vcs_internal.h @@ -20,6 +20,7 @@ #include "global.h" namespace VCSnonideal { + using Cantera::npos; //! Points to the data in a std::vector<> object #define VCS_DATA_PTR(vvv) (&(vvv[0])) diff --git a/Cantera/src/equil/vcs_prob.cpp b/Cantera/src/equil/vcs_prob.cpp index 6110b6138..2178e91ef 100644 --- a/Cantera/src/equil/vcs_prob.cpp +++ b/Cantera/src/equil/vcs_prob.cpp @@ -376,7 +376,7 @@ namespace VCSnonideal { foundPos = e; } } - if (foundPos == -1) { + if (foundPos == npos) { int elType = volPhase->elementType(eVP); int elactive = volPhase->elementActive(eVP); e = addElement(enVP.c_str(), elType, elactive); diff --git a/Cantera/src/equil/vcs_solve.h b/Cantera/src/equil/vcs_solve.h index 79ec859d0..7f2ce49f3 100644 --- a/Cantera/src/equil/vcs_solve.h +++ b/Cantera/src/equil/vcs_solve.h @@ -1012,7 +1012,7 @@ public: void vcs_elab(); int vcs_elabcheck(int ibound); - void vcs_elabPhase(int iphase, double * const elemAbundPhase); + void vcs_elabPhase(size_t iphase, double * const elemAbundPhase); int vcs_elcorr(double aa[], double x[]); @@ -1054,7 +1054,7 @@ public: * @param fe vector of partial molar free energies of all of the * species */ - double vcs_GibbsPhase(int iphase, const double * const w, + double vcs_GibbsPhase(size_t iphase, const double * const w, const double * const fe); //! Transfer the results of the equilibrium calculation back to VCS_PROB diff --git a/Cantera/src/equil/vcs_solve_TP.cpp b/Cantera/src/equil/vcs_solve_TP.cpp index 09bb1ef28..b1889e929 100644 --- a/Cantera/src/equil/vcs_solve_TP.cpp +++ b/Cantera/src/equil/vcs_solve_TP.cpp @@ -107,8 +107,8 @@ namespace VCSnonideal { bool justDeletedMultiPhase = false; size_t usedZeroedSpecies; /* return flag from basopt indicating that one of the components had a zero concentration */ - size_t doPhaseDeleteIph = -1; - size_t doPhaseDeleteKspec = -1; + size_t doPhaseDeleteIph = npos; + size_t doPhaseDeleteKspec = npos; vcs_VolPhase *Vphase; double *sc_irxn = NULL; /* Stoichiometric coefficients for cur rxn */ double *dnPhase_irxn; @@ -395,10 +395,10 @@ namespace VCSnonideal { * */ soldel = -1; - if (iphasePop != -1) { + if (iphasePop != npos) { soldel = vcs_popPhaseRxnStepSizes(iphasePop); if (soldel == 3) { - iphasePop = -1; + iphasePop = npos; #ifdef DEBUG_MODE if (m_debug_print_lvl >= 2) { plogf(" --- vcs_popPhaseRxnStepSizes() was called but stoich " @@ -407,7 +407,7 @@ namespace VCSnonideal { #endif } } - if (iphasePop == -1) { + if (iphasePop == npos) { /* * Figure out the new reaction step sizes * for the major species (do minor species in the future too) @@ -429,8 +429,8 @@ namespace VCSnonideal { } #endif lec = FALSE; - doPhaseDeleteIph = -1; - doPhaseDeleteKspec = -1; + doPhaseDeleteIph = npos; + doPhaseDeleteKspec = npos; /* * Zero out the net change in moles of multispecies phases */ @@ -486,7 +486,7 @@ namespace VCSnonideal { #ifdef DEBUG_MODE ANOTE[0] = '\0'; #endif - if (iphasePop != -1) { + if (iphasePop != npos) { if (iph == iphasePop) { dx = m_deltaMolNumSpecies[kspec]; m_molNumSpecies_new[kspec] = m_molNumSpecies_old[kspec] + m_deltaMolNumSpecies[kspec]; @@ -865,7 +865,7 @@ namespace VCSnonideal { */ if ((dx != 0.0) && (m_molNumSpecies_old[kspec] > 0.0) && - (doPhaseDeleteIph == -1) && + (doPhaseDeleteIph == npos) && (m_speciesUnknownType[kspec] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE)) { double dx_old = dx; @@ -935,7 +935,7 @@ namespace VCSnonideal { } L_MAIN_LOOP_END_NO_PRINT: ; #endif - if (doPhaseDeleteIph != -1) { + if (doPhaseDeleteIph != npos) { if (DEBUG_MODE_ENABLED && m_debug_print_lvl >= 2) { plogf(" --- "); plogf("%-12.12s Main Loop Special Case deleting phase with species: ", @@ -1335,7 +1335,7 @@ namespace VCSnonideal { for (i = 0; i < m_numRxnRdc; ++i) { l = m_indexRxnToSpecies[i]; if (m_speciesUnknownType[l] != VCS_SPECIES_TYPE_INTERFACIALVOLTAGE) { - for (j = m_numComponents - 1; j != -1; j--) { + for (j = m_numComponents - 1; j != npos; j--) { bool doSwap = false; if (m_SSPhase[j]) { doSwap = (m_molNumSpecies_old[l] * m_spSize[l]) > @@ -3198,7 +3198,7 @@ namespace VCSnonideal { } } } - if (kfound == -1) { + if (kfound == npos) { double gmin = 0.0; kfound = k; for (kspec = ncTrial; kspec < m_numSpeciesTot; kspec++) { diff --git a/Cantera/src/kinetics/AqueousKinetics.cpp b/Cantera/src/kinetics/AqueousKinetics.cpp index 799d90043..e46c6163e 100644 --- a/Cantera/src/kinetics/AqueousKinetics.cpp +++ b/Cantera/src/kinetics/AqueousKinetics.cpp @@ -331,7 +331,7 @@ namespace Cantera { m_rxnstoich->multiplyRevProducts(&m_conc[0], &ropr[0]); //m_revProductStoich.multiply(m_conc.begin(), ropr.begin()); - for (int j = 0; j != m_ii; ++j) { + for (size_t j = 0; j != m_ii; ++j) { ropnet[j] = ropf[j] - ropr[j]; } diff --git a/Cantera/src/kinetics/GasKinetics.cpp b/Cantera/src/kinetics/GasKinetics.cpp index e707ef212..3feaa7ba2 100644 --- a/Cantera/src/kinetics/GasKinetics.cpp +++ b/Cantera/src/kinetics/GasKinetics.cpp @@ -370,7 +370,7 @@ namespace Cantera { m_rxnstoich->multiplyRevProducts(&m_conc[0], &ropr[0]); //m_revProductStoich.multiply(m_conc.begin(), ropr.begin()); - for (int j = 0; j != m_ii; ++j) { + for (size_t j = 0; j != m_ii; ++j) { ropnet[j] = ropf[j] - ropr[j]; } diff --git a/Cantera/src/kinetics/InterfaceKinetics.cpp b/Cantera/src/kinetics/InterfaceKinetics.cpp index 5112fd5ef..f51c66fc7 100644 --- a/Cantera/src/kinetics/InterfaceKinetics.cpp +++ b/Cantera/src/kinetics/InterfaceKinetics.cpp @@ -318,7 +318,7 @@ namespace Cantera { for (size_t i = 0; i < m_nrev; i++) { size_t irxn = m_revindex[i]; - if (irxn == -1 || irxn >= nReactions()) { + if (irxn == npos || irxn >= nReactions()) { throw CanteraError("InterfaceKinetics", "illegal value: irxn = "+int2str(int(irxn))); } @@ -1129,8 +1129,8 @@ namespace Cantera { Kinetics::finalize(); m_rwork.resize(nReactions()); size_t ks = reactionPhaseIndex(); - if (ks == -1) throw CanteraError("InterfaceKinetics::finalize", - "no surface phase is present."); + if (ks == npos) throw CanteraError("InterfaceKinetics::finalize", + "no surface phase is present."); m_surf = (SurfPhase*)&thermo(ks); if (m_surf->nDim() != 2) throw CanteraError("InterfaceKinetics::finalize", @@ -1231,8 +1231,8 @@ namespace Cantera { void EdgeKinetics::finalize() { m_rwork.resize(nReactions()); size_t ks = reactionPhaseIndex(); - if (ks == -1) throw CanteraError("EdgeKinetics::finalize", - "no edge phase is present."); + if (ks == npos) throw CanteraError("EdgeKinetics::finalize", + "no edge phase is present."); m_surf = (SurfPhase*)&thermo(ks); if (m_surf->nDim() != 1) throw CanteraError("EdgeKinetics::finalize", diff --git a/Cantera/src/kinetics/Kinetics.cpp b/Cantera/src/kinetics/Kinetics.cpp index 3fdd84e32..bb6c512f1 100644 --- a/Cantera/src/kinetics/Kinetics.cpp +++ b/Cantera/src/kinetics/Kinetics.cpp @@ -173,9 +173,7 @@ namespace Cantera { * return * - If a match is found, the position in the species list * is returned. - * - If a specific phase is specified and no match is found, - * the value -1 is returned. - * - If no match is found in any phase, the value -2 is returned. + * - If no match is found, the value -1 (npos) is returned. */ size_t Kinetics::kineticsSpeciesIndex(std::string nm, std::string ph) const { size_t np = m_thermo.size(); @@ -185,7 +183,7 @@ namespace Cantera { id = thermo(n).id(); if (ph == id) { k = thermo(n).speciesIndex(nm); - if (k == -1) return -1; + if (k == npos) return npos; return k + m_start[n]; } else if (ph == "") { @@ -194,10 +192,10 @@ namespace Cantera { * ThermoPhase object to find a match. */ k = thermo(n).speciesIndex(nm); - if (k != -1) return k + m_start[n]; + if (k != npos) return k + m_start[n]; } } - return -2; + return npos; } /** @@ -212,7 +210,7 @@ namespace Cantera { string id; for (size_t n = 0; n < np; n++) { k = thermo(n).speciesIndex(nm); - if (k != -1) return thermo(n); + if (k != npos) return thermo(n); } throw CanteraError("speciesPhase", "unknown species "+nm); return thermo(0); @@ -226,7 +224,7 @@ namespace Cantera { * species. */ size_t Kinetics::speciesPhaseIndex(size_t k) { - for (size_t n = m_start.size()-1; n != -1; n--) { + for (size_t n = m_start.size()-1; n != npos; n--) { if (k >= m_start[n]) { return n; } diff --git a/Cantera/src/kinetics/ReactionPath.cpp b/Cantera/src/kinetics/ReactionPath.cpp index a2922ab92..cc8450a67 100644 --- a/Cantera/src/kinetics/ReactionPath.cpp +++ b/Cantera/src/kinetics/ReactionPath.cpp @@ -296,7 +296,7 @@ namespace Cantera { { k2 = m_speciesNumber[i2]; flx = netFlow(k1, k2); - if (m_local != -1) { + if (m_local != npos) { if (k1 != m_local && k2 != m_local) flx = 0.0; } if (flx != 0.0) @@ -383,7 +383,7 @@ namespace Cantera { for (size_t i = 0; i < nPaths(); i++) { p = path(i); flxratio = p->flow()/flmax; - if (m_local != -1) { + if (m_local != npos) { if (p->begin()->number != m_local && p->end()->number != m_local) flxratio = 0.0; } @@ -678,7 +678,7 @@ namespace Cantera { size_t nsp = p->nSpecies(); size_t mlocal = p->elementIndex(sym); for (size_t kp = 0; kp < nsp; kp++) { - if (mlocal != -1) { + if (mlocal != npos) { m_atoms(k, m) = p->nAtoms(kp, mlocal); } k++; diff --git a/Cantera/src/kinetics/importKinetics.cpp b/Cantera/src/kinetics/importKinetics.cpp index 8b5f5e179..986b0b3ac 100644 --- a/Cantera/src/kinetics/importKinetics.cpp +++ b/Cantera/src/kinetics/importKinetics.cpp @@ -213,7 +213,7 @@ namespace Cantera { * for the species in all phases defined in the kinetics operator. */ size_t isp = kin.kineticsSpeciesIndex(sp,""); - if (isp == -2) { + if (isp == npos) { if (rule == 1) return false; else { @@ -1105,7 +1105,7 @@ namespace Cantera { // if no phase with this id has been added to //the kinetics manager yet, then add this one - if (kin.phaseIndex(phase_id) == -1) { + if (kin.phaseIndex(phase_id) == npos) { kin.addPhase(*th[m]); } } diff --git a/Cantera/src/oneD/Domain1D.cpp b/Cantera/src/oneD/Domain1D.cpp index a17fe4abd..c5745d21c 100644 --- a/Cantera/src/oneD/Domain1D.cpp +++ b/Cantera/src/oneD/Domain1D.cpp @@ -72,10 +72,10 @@ namespace Cantera { eval(size_t jg, doublereal* xg, doublereal* rg, integer* mask, doublereal rdt) { - if (jg != -1 && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; + if (jg != npos && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; // if evaluating a Jacobian, compute the steady-state residual - if (jg != -1) rdt = 0.0; + if (jg != npos) rdt = 0.0; // start of local part of global arrays doublereal* x = xg + loc(); @@ -85,7 +85,7 @@ namespace Cantera { size_t jmin, jmax, jpt, j, i; jpt = jg - firstPoint(); - if (jg == -1) { // evaluate all points + if (jg == npos) { // evaluate all points jmin = 0; jmax = m_points - 1; } diff --git a/Cantera/src/oneD/MultiJac.cpp b/Cantera/src/oneD/MultiJac.cpp index 3eee1c255..e1824b5f9 100644 --- a/Cantera/src/oneD/MultiJac.cpp +++ b/Cantera/src/oneD/MultiJac.cpp @@ -73,7 +73,7 @@ namespace Cantera { // compute nth column of Jacobian for (i = j - 1; i <= j+1; i++) { - if (i != -1 && i < m_points) { + if (i != npos && i < m_points) { mv = m_resid->nVars(i); iloc = m_resid->loc(i); for (m = 0; m < mv; m++) { diff --git a/Cantera/src/oneD/MultiNewton.cpp b/Cantera/src/oneD/MultiNewton.cpp index ae0e85e50..584b2555d 100644 --- a/Cantera/src/oneD/MultiNewton.cpp +++ b/Cantera/src/oneD/MultiNewton.cpp @@ -45,7 +45,7 @@ namespace Cantera { "-----------------------------------------------------------------"; const doublereal DampFactor = sqrt(2.0); - const int NDAMP = 7; + const size_t NDAMP = 7; @@ -124,7 +124,7 @@ namespace Cantera { iok--; size_t nd = r.nDomains(); size_t n; - for (n = nd-1; n != -1; n--) + for (n = nd-1; n != npos; n--) if (iok >= r.start(n)) { break; } Domain1D& dom = r.domain(n); size_t offset = iok - r.start(n); diff --git a/Cantera/src/oneD/OneDim.cpp b/Cantera/src/oneD/OneDim.cpp index c2b2656d4..bd8de714f 100644 --- a/Cantera/src/oneD/OneDim.cpp +++ b/Cantera/src/oneD/OneDim.cpp @@ -165,14 +165,14 @@ namespace Cantera { // bandwidth of the local block bw1 = d->bandwidth(); - if (bw1 == -1) + if (bw1 == npos) bw1 = 2*d->nComponents() - 1; // bandwidth of the block coupling the first point of this // domain to the last point of the previous domain if (i > 0) { bw2 = m_dom[i-1]->bandwidth(); - if (bw2 == -1) + if (bw2 == npos) bw2 = m_dom[i-1]->nComponents(); bw2 += d->nComponents() - 1; } diff --git a/Cantera/src/oneD/StFlow.cpp b/Cantera/src/oneD/StFlow.cpp index 87a79bc11..791aca5bc 100644 --- a/Cantera/src/oneD/StFlow.cpp +++ b/Cantera/src/oneD/StFlow.cpp @@ -328,10 +328,10 @@ namespace Cantera { // if evaluating a Jacobian, and the global point is outside // the domain of influence for this domain, then skip // evaluating the residual - if (jg != -1 && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; + if (jg != npos && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; // if evaluating a Jacobian, compute the steady-state residual - if (jg != -1) rdt = 0.0; + if (jg != npos) rdt = 0.0; // start of local part of global arrays doublereal* x = xg + loc(); @@ -341,7 +341,7 @@ namespace Cantera { size_t jmin, jmax, jpt; jpt = jg - firstPoint(); - if (jg == -1) { // evaluate all points + if (jg == npos) { // evaluate all points jmin = 0; jmax = m_points - 1; } @@ -632,10 +632,10 @@ namespace Cantera { // if evaluating a Jacobian, and the global point is outside // the domain of influence for this domain, then skip // evaluating the residual - if (jg != -1 && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; + if (jg != npos && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; // if evaluating a Jacobian, compute the steady-state residual - if (jg != -1) rdt = 0.0; + if (jg != npos) rdt = 0.0; // start of local part of global arrays doublereal* x = xg + loc(); @@ -645,7 +645,7 @@ namespace Cantera { size_t jmin, jmax, jpt; jpt = jg - firstPoint(); - if (jg == -1) { // evaluate all points + if (jg == npos) { // evaluate all points jmin = 0; jmax = m_points - 1; } @@ -1051,7 +1051,7 @@ namespace Cantera { getFloatArray(fa,x,false); if (nm == "u") { writelog("axial velocity "); - if ((int) x.size() == np) { + if (x.size() == np) { for (j = 0; j < np; j++) { soln[index(0,j)] = x[j]; } @@ -1065,7 +1065,7 @@ namespace Cantera { } else if (nm == "V") { writelog("radial velocity "); - if ((int) x.size() == np) { + if (x.size() == np) { for (j = 0; j < np; j++) soln[index(1,j)] = x[j]; } diff --git a/Cantera/src/oneD/StFlow.h b/Cantera/src/oneD/StFlow.h index 0a6d239a8..9a205c728 100644 --- a/Cantera/src/oneD/StFlow.h +++ b/Cantera/src/oneD/StFlow.h @@ -192,8 +192,8 @@ namespace Cantera { needJacUpdate(); } - void fixTemperature(int j=-1) { - if (j < 0) + void fixTemperature(size_t j=npos) { + if (j == npos) for (size_t i = 0; i < m_points; i++) { m_do_energy[i] = false; } @@ -207,8 +207,8 @@ namespace Cantera { bool doSpecies(size_t k) { return m_do_species[k]; } bool doEnergy(size_t j) { return m_do_energy[j]; } - void solveSpecies(int k=-1) { - if (k == -1) { + void solveSpecies(size_t k=npos) { + if (k == npos) { for (size_t i = 0; i < m_nsp; i++) m_do_species[i] = true; } @@ -216,8 +216,8 @@ namespace Cantera { needJacUpdate(); } - void fixSpecies(int k=-1) { - if (k == -1) { + void fixSpecies(size_t k=npos) { + if (k == npos) { for (size_t i = 0; i < m_nsp; i++) m_do_species[i] = false; } diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index 3651eed44..b18b85c51 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -158,7 +158,7 @@ namespace Cantera { void Inlet1D:: eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -285,7 +285,7 @@ namespace Cantera { void Empty1D:: eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -343,7 +343,7 @@ namespace Cantera { void Symm1D:: eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2< firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2< firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -429,7 +429,7 @@ namespace Cantera { void Outlet1D:: eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -565,7 +565,7 @@ namespace Cantera { eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -669,7 +669,7 @@ namespace Cantera { void Surf1D:: eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -766,7 +766,7 @@ namespace Cantera { void ReactingSurf1D:: eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; + if (jg != npos && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); diff --git a/Cantera/src/thermo/ConstDensityThermo.h b/Cantera/src/thermo/ConstDensityThermo.h index 544108fb0..ec9d4ec31 100644 --- a/Cantera/src/thermo/ConstDensityThermo.h +++ b/Cantera/src/thermo/ConstDensityThermo.h @@ -285,8 +285,7 @@ namespace Cantera { //! of the solution and the reference pressure for the species. const array_fp& expGibbs_RT() const { _updateThermo(); - int k; - for (k = 0; k != m_kk; k++) m_expg0_RT[k] = std::exp(m_g0_RT[k]); + for (size_t k = 0; k != m_kk; k++) m_expg0_RT[k] = std::exp(m_g0_RT[k]); return m_expg0_RT; } diff --git a/Cantera/src/thermo/Constituents.cpp b/Cantera/src/thermo/Constituents.cpp index ec2619643..c906cd44c 100644 --- a/Cantera/src/thermo/Constituents.cpp +++ b/Cantera/src/thermo/Constituents.cpp @@ -286,7 +286,7 @@ namespace Cantera { const vector_fp &aw = m_Elements->atomicWeights(); if (charge != 0.0) { size_t eindex = m_Elements->elementIndex("E"); - if (eindex != -1) { + if (eindex != npos) { doublereal ecomp = compNew[eindex]; if (fabs (charge + ecomp) > 0.001) { if (ecomp != 0.0) { diff --git a/Cantera/src/thermo/DebyeHuckel.cpp b/Cantera/src/thermo/DebyeHuckel.cpp index 899af3d5d..a5c764be3 100644 --- a/Cantera/src/thermo/DebyeHuckel.cpp +++ b/Cantera/src/thermo/DebyeHuckel.cpp @@ -1152,7 +1152,7 @@ namespace Cantera { break; } } - if (m_indexSolvent == -1) { + if (m_indexSolvent == npos) { cout << "DebyeHuckel::initThermoXML: Solvent Name not found" << endl; throw CanteraError("DebyeHuckel::initThermoXML", @@ -1484,7 +1484,7 @@ namespace Cantera { break; } } - if (jmap != -1) { + if (jmap != npos) { const XML_Node& sp = *xspecies[jmap]; if (sp.hasChild("stoichIsMods")) { double val = getFloat(sp, "stoichIsMods"); diff --git a/Cantera/src/thermo/GeneralSpeciesThermo.cpp b/Cantera/src/thermo/GeneralSpeciesThermo.cpp index c94a7687f..4457c773c 100644 --- a/Cantera/src/thermo/GeneralSpeciesThermo.cpp +++ b/Cantera/src/thermo/GeneralSpeciesThermo.cpp @@ -309,7 +309,7 @@ namespace Cantera { * value applies only to the species with that index. */ doublereal GeneralSpeciesThermo::minTemp(size_t k) const { - if (k == -1) + if (k == npos) return m_tlow_max; else { SpeciesThermoInterpType *sp = m_sp[k]; @@ -321,7 +321,7 @@ namespace Cantera { } doublereal GeneralSpeciesThermo::maxTemp(size_t k) const { - if (k == -1) { + if (k == npos) { return m_thigh_min; } else { SpeciesThermoInterpType *sp = m_sp[k]; @@ -333,7 +333,7 @@ namespace Cantera { } doublereal GeneralSpeciesThermo::refPressure(size_t k) const { - if (k == -1) { + if (k == npos) { return m_p0; } else { SpeciesThermoInterpType *sp = m_sp[k]; diff --git a/Cantera/src/thermo/HMWSoln_input.cpp b/Cantera/src/thermo/HMWSoln_input.cpp index 982fbf557..28f0d213d 100644 --- a/Cantera/src/thermo/HMWSoln_input.cpp +++ b/Cantera/src/thermo/HMWSoln_input.cpp @@ -83,7 +83,7 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } string ispName = speciesName(iSpecies); @@ -91,7 +91,7 @@ namespace Cantera { throw CanteraError("HMWSoln::readXMLBinarySalt", "cation charge problem"); } size_t jSpecies = speciesIndex(jName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } string jspName = speciesName(jSpecies); @@ -289,14 +289,14 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(ispName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] >= 0) { throw CanteraError("HMWSoln::readXMLThetaAnion", "anion1 charge problem"); } size_t jSpecies = speciesIndex(jspName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } if (charge[jSpecies] >= 0) { @@ -376,14 +376,14 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(ispName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] <= 0) { throw CanteraError("HMWSoln::readXMLThetaCation", "cation1 charge problem"); } size_t jSpecies = speciesIndex(jspName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } if (charge[jSpecies] <= 0) { @@ -467,7 +467,7 @@ namespace Cantera { * an error to not find the species */ size_t kSpecies = speciesIndex(kName); - if (kSpecies == -1) { + if (kSpecies == npos) { return; } if (charge[kSpecies] <= 0) { @@ -475,7 +475,7 @@ namespace Cantera { "cation charge problem"); } size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] >= 0) { @@ -483,7 +483,7 @@ namespace Cantera { "anion1 charge problem"); } size_t jSpecies = speciesIndex(jName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } if (charge[jSpecies] >= 0) { @@ -613,14 +613,14 @@ namespace Cantera { * an error to not find the species */ size_t kSpecies = speciesIndex(kName); - if (kSpecies == -1) { + if (kSpecies == npos) { return; } if (charge[kSpecies] >= 0) { throw CanteraError("HMWSoln::readXMLPsiCommonAnion", "anion charge problem"); } size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] <= 0) { @@ -628,7 +628,7 @@ namespace Cantera { "cation1 charge problem"); } size_t jSpecies = speciesIndex(jName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } if (charge[jSpecies] <= 0) { @@ -759,7 +759,7 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] != 0) { @@ -767,7 +767,7 @@ namespace Cantera { "neutral charge problem"); } size_t jSpecies = speciesIndex(jName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } @@ -842,7 +842,7 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] != 0) { @@ -928,7 +928,7 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } if (charge[iSpecies] != 0.0) { @@ -936,7 +936,7 @@ namespace Cantera { } size_t jSpecies = speciesIndex(jName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } if (charge[jSpecies] <= 0.0) { @@ -944,7 +944,7 @@ namespace Cantera { } size_t kSpecies = speciesIndex(kName); - if (kSpecies == -1) { + if (kSpecies == npos) { return; } if (charge[kSpecies] >= 0.0) { @@ -1307,7 +1307,7 @@ namespace Cantera { break; } } - if (m_indexSolvent == -1) { + if (m_indexSolvent == npos) { std::cout << "HMWSoln::initThermo: Solvent Name not found" << std::endl; throw CanteraError("HMWSoln::initThermoXML", @@ -1503,7 +1503,7 @@ namespace Cantera { break; } } - if (jmap != -1) { + if (jmap != npos) { const XML_Node& sp = *xspecies[jmap]; getOptionalFloat(sp, "stoichIsMods", m_speciesCharge_Stoich[k]); // if (sp.hasChild("stoichIsMods")) { @@ -1525,7 +1525,7 @@ namespace Cantera { map::const_iterator _b = msIs.begin(); for (; _b != msIs.end(); ++_b) { size_t kk = speciesIndex(_b->first); - if (kk != -1) { + if (kk != npos) { double val = fpValue(_b->second); m_speciesCharge_Stoich[kk] = val; } @@ -1625,7 +1625,7 @@ namespace Cantera { map::const_iterator _b = msEST.begin(); for (; _b != msEST.end(); ++_b) { size_t kk = speciesIndex(_b->first); - if (kk != -1) { + if (kk != npos) { string est = _b->second; if ((m_electrolyteSpeciesType[kk] = interp_est(est)) == -1) { throw CanteraError("HMWSoln::initThermoXML", diff --git a/Cantera/src/thermo/IdealGasPhase.h b/Cantera/src/thermo/IdealGasPhase.h index 4e5c350a0..5eab5089f 100644 --- a/Cantera/src/thermo/IdealGasPhase.h +++ b/Cantera/src/thermo/IdealGasPhase.h @@ -806,8 +806,7 @@ namespace Cantera { */ const array_fp& expGibbs_RT_ref() const { _updateThermo(); - int k; - for (k = 0; k != m_kk; k++) m_expg0_RT[k] = std::exp(m_g0_RT[k]); + for (size_t k = 0; k != m_kk; k++) m_expg0_RT[k] = std::exp(m_g0_RT[k]); return m_expg0_RT; } diff --git a/Cantera/src/thermo/IdealMolalSoln.cpp b/Cantera/src/thermo/IdealMolalSoln.cpp index d268c2659..ee2d4a975 100644 --- a/Cantera/src/thermo/IdealMolalSoln.cpp +++ b/Cantera/src/thermo/IdealMolalSoln.cpp @@ -1023,7 +1023,7 @@ namespace Cantera { break; } } - if (m_indexSolvent == -1) { + if (m_indexSolvent == npos) { std::cout << "IdealMolalSoln::initThermo: Solvent Name not found" << std::endl; throw CanteraError("IdealMolalSoln::initThermo", diff --git a/Cantera/src/thermo/IdealSolidSolnPhase.cpp b/Cantera/src/thermo/IdealSolidSolnPhase.cpp index b17a07a92..bdcdb0b03 100644 --- a/Cantera/src/thermo/IdealSolidSolnPhase.cpp +++ b/Cantera/src/thermo/IdealSolidSolnPhase.cpp @@ -906,7 +906,7 @@ namespace Cantera { */ void IdealSolidSolnPhase::getEnthalpy_RT_ref(doublereal *hrt) const { _updateThermo(); - for (int k = 0; k != m_kk; k++) { + for (size_t k = 0; k != m_kk; k++) { hrt[k] = m_h0_RT[k]; } } @@ -919,7 +919,7 @@ namespace Cantera { */ void IdealSolidSolnPhase::getGibbs_RT_ref(doublereal *grt) const { _updateThermo(); - for (int k = 0; k != m_kk; k++) { + for (size_t k = 0; k != m_kk; k++) { grt[k] = m_g0_RT[k]; } } @@ -933,7 +933,7 @@ namespace Cantera { void IdealSolidSolnPhase::getGibbs_ref(doublereal *g) const { _updateThermo(); double tmp = GasConstant * temperature(); - for (int k = 0; k != m_kk; k++) { + for (size_t k = 0; k != m_kk; k++) { g[k] = tmp * m_g0_RT[k]; } } @@ -960,7 +960,7 @@ namespace Cantera { */ void IdealSolidSolnPhase::getEntropy_R_ref(doublereal *er) const { _updateThermo(); - for (int k = 0; k != m_kk; k++) { + for (size_t k = 0; k != m_kk; k++) { er[k] = m_s0_R[k]; } } @@ -973,7 +973,7 @@ namespace Cantera { */ void IdealSolidSolnPhase::getCp_R_ref(doublereal *cpr) const { _updateThermo(); - for (int k = 0; k != m_kk; k++) { + for (size_t k = 0; k != m_kk; k++) { cpr[k] = m_cp0_R[k]; } } @@ -999,8 +999,7 @@ namespace Cantera { */ const array_fp& IdealSolidSolnPhase::expGibbs_RT_ref() const { _updateThermo(); - int k; - for (k = 0; k != m_kk; k++) m_expg0_RT[k] = exp(m_g0_RT[k]); + for (size_t k = 0; k != m_kk; k++) m_expg0_RT[k] = exp(m_g0_RT[k]); return m_expg0_RT; } diff --git a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp index b9dffbd4a..2bf665842 100644 --- a/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/Cantera/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -881,7 +881,7 @@ namespace Cantera { break; case cIonSolnType_SINGLEANION: - for (size_t k = 0; k < (int) cationList_.size(); k++) { + for (size_t k = 0; k < cationList_.size(); k++) { //! Get the id for the next cation icat = cationList_[k]; jNeut = fm_invert_ionForNeutral[icat]; diff --git a/Cantera/src/thermo/MargulesVPSSTP.cpp b/Cantera/src/thermo/MargulesVPSSTP.cpp index b62619e5d..a5ac704fe 100644 --- a/Cantera/src/thermo/MargulesVPSSTP.cpp +++ b/Cantera/src/thermo/MargulesVPSSTP.cpp @@ -178,7 +178,7 @@ namespace Cantera { size_t iLiCl = speciesIndex("LiCl(L)"); - if (iLiCl == -1) { + if (iLiCl == npos) { throw CanteraError("MargulesVPSSTP test1 constructor", "Unable to find LiCl(L)"); } @@ -186,7 +186,7 @@ namespace Cantera { size_t iKCl = speciesIndex("KCl(L)"); - if (iKCl == -1) { + if (iKCl == npos) { throw CanteraError("MargulesVPSSTP test1 constructor", "Unable to find KCl(L)"); } @@ -974,7 +974,7 @@ namespace Cantera { * an error to not find the species */ size_t iSpecies = speciesIndex(iName); - if (iSpecies == -1) { + if (iSpecies == npos) { return; } string ispName = speciesName(iSpecies); @@ -982,7 +982,7 @@ namespace Cantera { throw CanteraError("MargulesVPSSTP::readXMLBinarySpecies", "speciesA charge problem"); } size_t jSpecies = speciesIndex(jName); - if (jSpecies == -1) { + if (jSpecies == npos) { return; } string jspName = speciesName(jSpecies); diff --git a/Cantera/src/thermo/MineralEQ3.cpp b/Cantera/src/thermo/MineralEQ3.cpp index 859ca948b..bfb3aaec7 100644 --- a/Cantera/src/thermo/MineralEQ3.cpp +++ b/Cantera/src/thermo/MineralEQ3.cpp @@ -540,7 +540,7 @@ namespace Cantera { return -1.0; #else size_t iE = elementIndex(elemName); - if (iE == -1) { + if (iE == npos) { throw CanteraError("PDSS_HKFT::LookupGe", "element " + elemName + " not found"); } doublereal geValue = entropyElement298(iE); diff --git a/Cantera/src/thermo/MolalityVPSSTP.cpp b/Cantera/src/thermo/MolalityVPSSTP.cpp index d44ac1220..0243aec0c 100644 --- a/Cantera/src/thermo/MolalityVPSSTP.cpp +++ b/Cantera/src/thermo/MolalityVPSSTP.cpp @@ -700,7 +700,7 @@ namespace Cantera { } } // We have failed if we can't find the Cl element index - if (eCl == -1) { + if (eCl == npos) { return -1; } for (size_t e = 0; e < ne; e++) { @@ -711,8 +711,8 @@ namespace Cantera { } } // We have failed if we can't find the E element index - if (eE == -1) { - return -1; + if (eE == npos) { + return npos; } for (size_t k = 1; k < m_kk; k++) { doublereal nCl = nAtoms(k, eCl); @@ -816,7 +816,7 @@ namespace Cantera { getActivities(&actMolal[0]); size_t iHp = speciesIndex("H+"); - if (iHp != -1) { + if (iHp != npos) { double pH = -log(actMolal[iHp]) / log(10.0); sprintf(p, " pH %12.4g \n", pH); s += p; @@ -964,7 +964,7 @@ namespace Cantera { pNames.push_back("Molal Activity"); data.push_back(temp); size_t iHp = speciesIndex("H+"); - if (iHp != -1) { + if (iHp != npos) { double pH = -log(temp[iHp]) / log(10.0); csvFile << setw(tabL) << "pH = " << setw(tabS) << pH << endl; } diff --git a/Cantera/src/thermo/MolalityVPSSTP.h b/Cantera/src/thermo/MolalityVPSSTP.h index 699187573..63e60eb89 100644 --- a/Cantera/src/thermo/MolalityVPSSTP.h +++ b/Cantera/src/thermo/MolalityVPSSTP.h @@ -855,7 +855,7 @@ namespace Cantera { /*! * Currently the index of the solvent is hard-coded to the value 0 */ - int m_indexSolvent; + size_t m_indexSolvent; //! Scaling to be used for output of single-ion species activity //! coefficients. diff --git a/Cantera/src/thermo/Mu0Poly.cpp b/Cantera/src/thermo/Mu0Poly.cpp index a44b6f45f..9bf738e9d 100644 --- a/Cantera/src/thermo/Mu0Poly.cpp +++ b/Cantera/src/thermo/Mu0Poly.cpp @@ -198,7 +198,7 @@ namespace Cantera { h298 = getFloat(Mu0Node, "H298", "actEnergy"); } - int numPoints = 1; + size_t numPoints = 1; if (Mu0Node.hasChild("numPoints")) { numPoints = getInteger(Mu0Node, "numPoints"); } @@ -248,7 +248,7 @@ namespace Cantera { * Fix up dimensionless Mu0 values if input */ if (dimensionlessMu0Values) { - for (int i = 0; i < numPoints; i++) { + for (size_t i = 0; i < numPoints; i++) { cValues[i] *= cTemperatures[i] / 273.15; } } @@ -258,7 +258,7 @@ namespace Cantera { c[0] = numPoints; c[1] = h298; - for (int i = 0; i < numPoints; i++) { + for (size_t i = 0; i < numPoints; i++) { c[2+i*2] = cTemperatures[i]; c[2+i*2+1] = cValues[i]; } @@ -365,7 +365,7 @@ namespace Cantera { mu2 = m_mu0_R_int[iT298]; m_h0_R_int[iT298] = m_H298; m_s0_R_int[iT298] = - (mu2 - m_h0_R_int[iT298]) / T2; - for (i = iT298 - 1; i != -1; i--) { + for (i = iT298 - 1; i != npos; i--) { T1 = m_t0_int[i]; mu1 = m_mu0_R_int[i]; T2 = m_t0_int[i+1]; diff --git a/Cantera/src/thermo/NasaThermo.h b/Cantera/src/thermo/NasaThermo.h index 79a2581b9..7df61a86b 100644 --- a/Cantera/src/thermo/NasaThermo.h +++ b/Cantera/src/thermo/NasaThermo.h @@ -194,7 +194,7 @@ namespace Cantera { if (tlow > m_tlow_max) m_tlow_max = tlow; if (thigh < m_thigh_min) m_thigh_min = thigh; - if ((int) m_tlow.size() < index + 1) { + if (m_tlow.size() < index + 1) { m_tlow.resize(index + 1, tlow); m_thigh.resize(index + 1, thigh); } @@ -313,8 +313,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(size_t k=-1) const { - if (k == -1) + virtual doublereal minTemp(size_t k=npos) const { + if (k == npos) return m_tlow_max; else return m_tlow[k]; @@ -330,8 +330,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal maxTemp(size_t k=-1) const { - if (k == -1) + virtual doublereal maxTemp(size_t k=npos) const { + if (k == npos) return m_thigh_min; else return m_thigh[k]; @@ -350,7 +350,7 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal refPressure(size_t k = -1) const { + virtual doublereal refPressure(size_t k=npos) const { return m_p0; } diff --git a/Cantera/src/thermo/PDSS_HKFT.cpp b/Cantera/src/thermo/PDSS_HKFT.cpp index d4bb8081a..5fb2ba722 100644 --- a/Cantera/src/thermo/PDSS_HKFT.cpp +++ b/Cantera/src/thermo/PDSS_HKFT.cpp @@ -1215,7 +1215,7 @@ namespace Cantera { return -1.0; #else size_t iE = m_tp->elementIndex(elemName); - if (iE == -1) { + if (iE == npos) { throw CanteraError("PDSS_HKFT::LookupGe", "element " + elemName + " not found"); } doublereal geValue = m_tp->entropyElement298(iE); diff --git a/Cantera/src/thermo/Phase.cpp b/Cantera/src/thermo/Phase.cpp index 0c4534693..1503a73c3 100644 --- a/Cantera/src/thermo/Phase.cpp +++ b/Cantera/src/thermo/Phase.cpp @@ -147,7 +147,7 @@ namespace Cantera { } void Phase::restoreState(size_t lenstate, const doublereal* state) { - if (int(lenstate) >= nSpecies() + 2) { + if (lenstate >= nSpecies() + 2) { setMassFractions_NoNorm(state + 2); setTemperature(state[0]); setDensity(state[1]); @@ -312,7 +312,7 @@ namespace Cantera { doublereal Phase::moleFraction(std::string name) const { size_t iloc = speciesIndex(name); - if (iloc != -1) return State::moleFraction(iloc); + if (iloc != npos) return State::moleFraction(iloc); else return 0.0; } @@ -322,7 +322,7 @@ namespace Cantera { doublereal Phase::massFraction(std::string name) const { size_t iloc = speciesIndex(name); - if (iloc != -1) return massFractions()[iloc]; + if (iloc != npos) return massFractions()[iloc]; else return 0.0; } diff --git a/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp b/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp index dec1be676..7927e26b5 100644 --- a/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp +++ b/Cantera/src/thermo/PseudoBinaryVPSSTP.cpp @@ -179,7 +179,7 @@ namespace Cantera { for (k = 0; k < m_kk; k++) { moleFractionsTmp_[k] = moleFractions_[k]; } - for (k = 0; k < (int) cationList_.size(); k++) { + for (k = 0; k < cationList_.size(); k++) { sumCat += moleFractions_[cationList_[k]]; } sumAnion = moleFractions_[anionList_[k]]; diff --git a/Cantera/src/thermo/ShomateThermo.h b/Cantera/src/thermo/ShomateThermo.h index d959af4f6..8f529d2b3 100644 --- a/Cantera/src/thermo/ShomateThermo.h +++ b/Cantera/src/thermo/ShomateThermo.h @@ -188,7 +188,7 @@ namespace Cantera { if (tlow > m_tlow_max) m_tlow_max = tlow; if (thigh < m_thigh_min) m_thigh_min = thigh; - if ((int) m_tlow.size() < index + 1) { + if (m_tlow.size() < index + 1) { m_tlow.resize(index + 1, tlow); m_thigh.resize(index + 1, thigh); } @@ -311,8 +311,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(size_t k=-1) const { - if (k == -1) + virtual doublereal minTemp(size_t k=npos) const { + if (k == npos) return m_tlow_max; else return m_tlow[k]; @@ -328,8 +328,8 @@ namespace Cantera { * * @param k species index */ - virtual doublereal maxTemp(size_t k=-1) const { - if (k == -1) + virtual doublereal maxTemp(size_t k=npos) const { + if (k == npos) return m_thigh_min; else return m_thigh[k]; @@ -348,7 +348,7 @@ namespace Cantera { * * @param k species index */ - virtual doublereal refPressure(size_t k=-1) const { + virtual doublereal refPressure(size_t k=npos) const { return m_p0; } diff --git a/Cantera/src/thermo/SimpleThermo.h b/Cantera/src/thermo/SimpleThermo.h index 14c4b8648..c67455fe5 100644 --- a/Cantera/src/thermo/SimpleThermo.h +++ b/Cantera/src/thermo/SimpleThermo.h @@ -164,7 +164,7 @@ namespace Cantera { if (tlow > m_tlow_max) m_tlow_max = tlow; if (thigh < m_thigh_min) m_thigh_min = thigh; - if ((int) m_tlow.size() < index + 1) { + if (m_tlow.size() < index + 1) { m_tlow.resize(index + 1, tlow); m_thigh.resize(index + 1, thigh); } @@ -253,8 +253,8 @@ namespace Cantera { * * @param k Species index */ - virtual doublereal minTemp(size_t k=-1) const { - if (k == -1) + virtual doublereal minTemp(size_t k=npos) const { + if (k == npos) return m_tlow_max; else return m_tlow[m_loc[k]]; @@ -270,8 +270,8 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal maxTemp(size_t k=-1) const { - if (k == -1) + virtual doublereal maxTemp(size_t k=npos) const { + if (k == npos) return m_thigh_min; else return m_thigh[m_loc[k]]; @@ -290,7 +290,7 @@ namespace Cantera { * * @param k Species Index */ - virtual doublereal refPressure(size_t k=-1) const {return m_p0;} + virtual doublereal refPressure(size_t k=npos) const {return m_p0;} //! This utility function reports the type of parameterization //! used for the species with index number index. @@ -344,7 +344,7 @@ namespace Cantera { */ virtual void modifyParams(size_t index, doublereal *c) { size_t loc = m_loc[index]; - if (loc == -1) { + if (loc == npos) { throw CanteraError("SimpleThermo::modifyParams", "modifying parameters for species which hasn't been set yet"); } diff --git a/Cantera/src/thermo/SpeciesThermoFactory.cpp b/Cantera/src/thermo/SpeciesThermoFactory.cpp index 410dceef5..57a0ae7ca 100644 --- a/Cantera/src/thermo/SpeciesThermoFactory.cpp +++ b/Cantera/src/thermo/SpeciesThermoFactory.cpp @@ -445,7 +445,7 @@ namespace Cantera { return -1.0; #else size_t iE = th_ptr->elementIndex(elemName); - if (iE == -1) { + if (iE == npos) { throw CanteraError("PDSS_HKFT::LookupGe", "element " + elemName + " not found"); } doublereal geValue = th_ptr->entropyElement298(iE); diff --git a/Cantera/src/thermo/SpeciesThermoInterpType.cpp b/Cantera/src/thermo/SpeciesThermoInterpType.cpp index c7adc6d51..0e98a949d 100644 --- a/Cantera/src/thermo/SpeciesThermoInterpType.cpp +++ b/Cantera/src/thermo/SpeciesThermoInterpType.cpp @@ -72,7 +72,7 @@ namespace Cantera { } - void STITbyPDSS::initAllPtrs(int speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr) { + void STITbyPDSS::initAllPtrs(size_t speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr) { AssertThrow(speciesIndex == m_speciesIndex, "STITbyPDSS::initAllPtrs internal confusion"); m_vpssmgr_ptr = vpssmgr_ptr; m_PDSS_ptr = PDSS_ptr; diff --git a/Cantera/src/thermo/SpeciesThermoInterpType.h b/Cantera/src/thermo/SpeciesThermoInterpType.h index 30be1b764..e0858e577 100644 --- a/Cantera/src/thermo/SpeciesThermoInterpType.h +++ b/Cantera/src/thermo/SpeciesThermoInterpType.h @@ -347,7 +347,7 @@ namespace Cantera { * @param PDSS_ptr Pointer to the PDSS object that handles calls for this object * */ - void initAllPtrs(int speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr); + void initAllPtrs(size_t speciesIndex, VPSSMgr *vpssmgr_ptr, PDSS *PDSS_ptr); //! Returns the minimum temperature that the thermo //! parameterization is valid diff --git a/Cantera/src/thermo/SpeciesThermoMgr.h b/Cantera/src/thermo/SpeciesThermoMgr.h index 38a4bffc5..0c94dc6f3 100644 --- a/Cantera/src/thermo/SpeciesThermoMgr.h +++ b/Cantera/src/thermo/SpeciesThermoMgr.h @@ -715,7 +715,7 @@ namespace Cantera { template doublereal SpeciesThermo1::minTemp(size_t k) const { - if (k == -1) + if (k == npos) return _minTemp(m_thermo.begin(), m_thermo.end()); else return m_thermo[k].minTemp(); @@ -724,7 +724,7 @@ namespace Cantera { template doublereal SpeciesThermo1::maxTemp(size_t k) const { - if (k == -1) + if (k == npos) return _maxTemp(m_thermo.begin(), m_thermo.end()); else return m_thermo[k].maxTemp(); diff --git a/Cantera/src/thermo/State.cpp b/Cantera/src/thermo/State.cpp index 47cdda2bd..acde8ec2e 100644 --- a/Cantera/src/thermo/State.cpp +++ b/Cantera/src/thermo/State.cpp @@ -193,16 +193,15 @@ namespace Cantera { } void State::setConcentrations(const doublereal* const conc) { - int k; doublereal sum = 0.0, norm = 0.0; - for (k = 0; k != m_kk; ++k) { + for (size_t k = 0; k != m_kk; ++k) { sum += conc[k]*m_molwts[k]; norm += conc[k]; } m_mmw = sum/norm; setDensity(sum); doublereal rsum = 1.0/sum; - for (k = 0; k != m_kk; ++k) { + for (size_t k = 0; k != m_kk; ++k) { m_ym[k] = conc[k] * rsum; m_y[k] = m_ym[k] * m_molwts[k]; } diff --git a/Cantera/src/thermo/VPSSMgr.cpp b/Cantera/src/thermo/VPSSMgr.cpp index a90f0d7ba..6bd985829 100644 --- a/Cantera/src/thermo/VPSSMgr.cpp +++ b/Cantera/src/thermo/VPSSMgr.cpp @@ -429,7 +429,7 @@ namespace Cantera { /*****************************************************************/ doublereal VPSSMgr::minTemp(size_t k) const { - if (k != -1) { + if (k != npos) { const PDSS *kPDSS = m_vptp_ptr->providePDSS(k); return kPDSS->minTemp(); } @@ -437,7 +437,7 @@ namespace Cantera { } doublereal VPSSMgr::maxTemp(size_t k) const { - if (k != -1) { + if (k != npos) { const PDSS *kPDSS = m_vptp_ptr->providePDSS(k); return kPDSS->maxTemp(); } @@ -445,7 +445,7 @@ namespace Cantera { } doublereal VPSSMgr::refPressure(size_t k) const { - if (k != -1) { + if (k != npos) { const PDSS *kPDSS = m_vptp_ptr->providePDSS(k); return kPDSS->refPressure(); } diff --git a/Cantera/src/thermo/VPSSMgr_IdealGas.cpp b/Cantera/src/thermo/VPSSMgr_IdealGas.cpp index 409af3ee0..75622b2fa 100644 --- a/Cantera/src/thermo/VPSSMgr_IdealGas.cpp +++ b/Cantera/src/thermo/VPSSMgr_IdealGas.cpp @@ -101,7 +101,7 @@ namespace Cantera { "ideal_gas: " + speciesNode.name()); } } - if ((int) m_Vss.size() < k+1) { + if (m_Vss.size() < k+1) { m_Vss.resize(k+1, 0.0); } diff --git a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp index bb0f0bedf..1a0f661ea 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp +++ b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp @@ -286,7 +286,7 @@ namespace Cantera { "standardState model for species isn't " "constant_incompressible: " + speciesNode.name()); } - if ((int) m_Vss.size() < k+1) { + if (m_Vss.size() < k+1) { m_Vss.resize(k+1, 0.0); } m_Vss[k] = getFloat(*ss, "molarVolume", "toSI"); diff --git a/Cantera/src/thermo/WaterSSTP.cpp b/Cantera/src/thermo/WaterSSTP.cpp index e99bd74a6..bdd596e19 100644 --- a/Cantera/src/thermo/WaterSSTP.cpp +++ b/Cantera/src/thermo/WaterSSTP.cpp @@ -213,13 +213,13 @@ namespace Cantera { * a consistent H2O molecular weight based on that. */ size_t nH = elementIndex("H"); - if (nH == -1) { + if (nH == npos) { throw CanteraError("WaterSSTP::initThermo", "H not an element"); } double mw_H = atomicWeight(nH); size_t nO = elementIndex("O"); - if (nO == -1) { + if (nO == npos) { throw CanteraError("WaterSSTP::initThermo", "O not an element"); } diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index 21d303587..7bca50e46 100644 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -1116,7 +1116,7 @@ namespace Cantera { char s[100]; #endif // number of points to use in generating fit data - const int np = 50; + const size_t np = 50; int mode = tr.mode_; int degree = (mode == CK_Mode ? 3 : 4); diff --git a/Cantera/src/zeroD/ConstPressureReactor.cpp b/Cantera/src/zeroD/ConstPressureReactor.cpp index 4ca0b984b..098ab4619 100644 --- a/Cantera/src/zeroD/ConstPressureReactor.cpp +++ b/Cantera/src/zeroD/ConstPressureReactor.cpp @@ -281,7 +281,7 @@ namespace CanteraZeroD { if (nm == "V") return 1; // check for a gas species name size_t k = m_thermo->speciesIndex(nm); - if (k != -1) return k + 2; + if (k != npos) return k + 2; // check for a wall species size_t walloffset = 0, kp = 0; @@ -291,7 +291,7 @@ namespace CanteraZeroD { kp = m_wall[m]->kinetics(m_lr[m])->reactionPhaseIndex(); th = &m_wall[m]->kinetics(m_lr[m])->thermo(kp); k = th->speciesIndex(nm); - if (k != -1) { + if (k != npos) { return k + 2 + m_nsp + walloffset; } else { diff --git a/Cantera/src/zeroD/FlowReactor.cpp b/Cantera/src/zeroD/FlowReactor.cpp index 5b46dd01f..322a1628d 100644 --- a/Cantera/src/zeroD/FlowReactor.cpp +++ b/Cantera/src/zeroD/FlowReactor.cpp @@ -132,7 +132,7 @@ namespace CanteraZeroD { if (nm == "U") return 1; // check for a gas species name size_t k = m_thermo->speciesIndex(nm); - if (k != -1) return k + 2; + if (k != npos) return k + 2; else return -1; } diff --git a/Cantera/src/zeroD/Reactor.cpp b/Cantera/src/zeroD/Reactor.cpp index 1d57c4337..10961e0a3 100644 --- a/Cantera/src/zeroD/Reactor.cpp +++ b/Cantera/src/zeroD/Reactor.cpp @@ -107,7 +107,7 @@ namespace CanteraZeroD { } size_t Reactor::nSensParams() { - if (m_nsens == -1) { + if (m_nsens == npos) { // determine the number of sensitivity parameters size_t m, ns; m_nsens = m_pnum.size(); @@ -347,7 +347,7 @@ namespace CanteraZeroD { if (nm == "V") return 1; // check for a gas species name size_t k = m_thermo->speciesIndex(nm); - if (k != -1) return k + 2; + if (k != npos) return k + 2; // check for a wall species size_t walloffset = 0, kp = 0; diff --git a/Cantera/src/zeroD/Wall.cpp b/Cantera/src/zeroD/Wall.cpp index 476f43fa1..f80cd42a0 100644 --- a/Cantera/src/zeroD/Wall.cpp +++ b/Cantera/src/zeroD/Wall.cpp @@ -43,7 +43,7 @@ namespace CanteraZeroD { size_t ileft = 0, iright = 0; if (left) { ileft = left->surfacePhaseIndex(); - if (ileft != -1) { + if (ileft != npos) { m_surf[0] = (SurfPhase*)&left->thermo(ileft); m_nsp[0] = m_surf[0]->nSpecies(); m_leftcov.resize(m_nsp[0]); @@ -52,14 +52,14 @@ namespace CanteraZeroD { } if (right) { iright = right->surfacePhaseIndex(); - if (iright != -1) { + if (iright != npos) { m_surf[1] = (SurfPhase*)&right->thermo(iright); m_nsp[1] = m_surf[1]->nSpecies(); m_rightcov.resize(m_nsp[1]); m_surf[1]->getCoverages(DATA_PTR(m_rightcov)); } } - if (ileft == -1 || iright == -1) { + if (ileft == npos || iright == npos) { throw CanteraError("Wall::setKinetics", "specified surface kinetics manager does not " "represent a surface reaction mechanism."); diff --git a/tools/testtools/tok_input_util.cpp b/tools/testtools/tok_input_util.cpp index c9dbb721b..9c358165b 100644 --- a/tools/testtools/tok_input_util.cpp +++ b/tools/testtools/tok_input_util.cpp @@ -1539,7 +1539,7 @@ void strip_item_from_token(int iword, TOKEN *tok) size_t i = ioffset; size_t j = ioffset + ilength; #endif - if (j <= (int) strlen(tok->orig_str)) { + if (j <= strlen(tok->orig_str)) { while(tok->orig_str[j] != '\0') { tok->orig_str[i] = tok->orig_str[j]; i++;