From bc9ec4851659dafffe715cd5bdb6d499c4ceb5fb Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 17 Jan 2012 04:11:51 +0000 Subject: [PATCH] Fixing compiler warnings, part 5 --- Cantera/clib/src/Cabinet.h | 6 +- Cantera/clib/src/Storage.cpp | 24 ++-- Cantera/clib/src/Storage.h | 10 +- Cantera/clib/src/ct.cpp | 115 ++++++++++---------- Cantera/clib/src/ct.h | 92 ++++++++-------- Cantera/clib/src/ctfunc.cpp | 12 +- Cantera/clib/src/ctfunc.h | 4 +- Cantera/clib/src/ctmultiphase.cpp | 14 +-- Cantera/clib/src/ctmultiphase.h | 14 +-- Cantera/clib/src/ctonedim.cpp | 28 ++--- Cantera/clib/src/ctonedim.h | 22 ++-- Cantera/clib/src/ctreactor.cpp | 2 +- Cantera/clib/src/ctreactor.h | 2 +- Cantera/clib/src/ctrpath.cpp | 2 +- Cantera/clib/src/ctrpath.h | 2 +- Cantera/clib/src/ctxml.cpp | 5 +- Cantera/python/src/ctfunc_methods.cpp | 2 +- Cantera/python/src/ctfuncs.cpp | 2 +- Cantera/python/src/ctkinetics_methods.cpp | 13 ++- Cantera/python/src/ctmultiphase_methods.cpp | 18 +-- Cantera/python/src/ctonedim_methods.cpp | 24 ++-- Cantera/python/src/ctphase_methods.cpp | 16 +-- Cantera/python/src/ctreactor_methods.cpp | 2 +- Cantera/python/src/ctrpath_methods.cpp | 2 +- Cantera/python/src/ctsurf_methods.cpp | 10 +- Cantera/python/src/ctthermo_methods.cpp | 11 +- Cantera/python/src/cttransport_methods.cpp | 2 +- Cantera/src/base/ctml.cpp | 10 +- Cantera/src/base/ctml.h | 4 +- Cantera/src/equil/MultiPhaseEquil.h | 2 +- Cantera/src/equil/vcs_rxnadj.cpp | 3 +- Cantera/src/equil/vcs_solve_TP.cpp | 4 +- Cantera/src/kinetics/Kinetics.h | 2 +- Cantera/src/kinetics/ReactionPath.cpp | 2 +- Cantera/src/kinetics/ReactionPath.h | 2 +- Cantera/src/kinetics/RxnRates.h | 2 +- Cantera/src/numerics/ArrayViewer.h | 36 +++--- Cantera/src/numerics/BandMatrix.cpp | 22 ++-- Cantera/src/numerics/BandMatrix.h | 42 +++---- Cantera/src/numerics/CVodeInt.cpp | 10 +- Cantera/src/numerics/CVodeInt.h | 4 +- Cantera/src/numerics/FuncEval.h | 2 +- Cantera/src/numerics/Integrator.h | 6 +- Cantera/src/numerics/ctlapack.h | 27 +++-- Cantera/src/oneD/Domain1D.cpp | 37 +++---- Cantera/src/oneD/Domain1D.h | 94 ++++++++-------- Cantera/src/oneD/Inlet1D.h | 34 +++--- Cantera/src/oneD/MultiJac.cpp | 4 +- Cantera/src/oneD/MultiJac.h | 4 +- Cantera/src/oneD/MultiNewton.cpp | 45 ++++---- Cantera/src/oneD/MultiNewton.h | 6 +- Cantera/src/oneD/OneDim.cpp | 31 +++--- Cantera/src/oneD/OneDim.h | 32 +++--- Cantera/src/oneD/Sim1D.cpp | 91 ++++++++-------- Cantera/src/oneD/Sim1D.h | 12 +- Cantera/src/oneD/StFlow.cpp | 104 +++++++++--------- Cantera/src/oneD/StFlow.h | 108 +++++++++--------- Cantera/src/oneD/boundaries1D.cpp | 64 +++++------ Cantera/src/oneD/newton_utils.cpp | 27 ++--- Cantera/src/oneD/refine.cpp | 26 ++--- Cantera/src/oneD/refine.h | 14 +-- Cantera/src/thermo/ThermoPhase.h | 6 +- Cantera/src/transport/L_matrix.h | 22 ++-- Cantera/src/transport/LiquidTransport.cpp | 16 +-- Cantera/src/transport/LiquidTransport.h | 2 +- Cantera/src/transport/MultiTransport.cpp | 8 +- Cantera/src/transport/MultiTransport.h | 2 +- Cantera/src/transport/SimpleTransport.cpp | 12 +- Cantera/src/transport/SimpleTransport.h | 2 +- Cantera/src/transport/SolidTransport.cpp | 10 +- Cantera/src/transport/SolidTransport.h | 2 +- Cantera/src/transport/TransportBase.cpp | 4 +- Cantera/src/transport/TransportBase.h | 8 +- Cantera/src/transport/TransportFactory.cpp | 8 +- Cantera/src/transport/TransportParams.h | 2 +- Cantera/src/zeroD/ConstPressureReactor.cpp | 47 ++++---- Cantera/src/zeroD/ConstPressureReactor.h | 2 +- Cantera/src/zeroD/FlowDevice.cpp | 6 +- Cantera/src/zeroD/FlowDevice.h | 6 +- Cantera/src/zeroD/FlowReactor.cpp | 8 +- Cantera/src/zeroD/FlowReactor.h | 2 +- Cantera/src/zeroD/Reactor.cpp | 32 +++--- Cantera/src/zeroD/Reactor.h | 10 +- Cantera/src/zeroD/ReactorBase.cpp | 6 +- Cantera/src/zeroD/ReactorBase.h | 18 +-- Cantera/src/zeroD/ReactorNet.cpp | 27 ++--- Cantera/src/zeroD/ReactorNet.h | 26 ++--- Cantera/src/zeroD/Wall.cpp | 12 +- Cantera/src/zeroD/Wall.h | 4 +- apps/bvp/AxiStagnBVP.cpp | 2 +- apps/bvp/AxiStagnBVP.h | 2 +- apps/bvp/blasius.cpp | 2 +- apps/bvp/stagnation.cpp | 2 +- tools/testtools/tok_input_util.cpp | 6 +- 94 files changed, 834 insertions(+), 859 deletions(-) diff --git a/Cantera/clib/src/Cabinet.h b/Cantera/clib/src/Cabinet.h index d86813db3..dd7c57545 100755 --- a/Cantera/clib/src/Cabinet.h +++ b/Cantera/clib/src/Cabinet.h @@ -159,11 +159,11 @@ public: /** * Return a pointer to object n. */ - M* item(int n) { - if (n >= 0 && n < int(__table.size())) + M* item(size_t n) { + if (n < __table.size()) return __table[n]; else { - throw Cantera::CanteraError("item","index out of range"+Cantera::int2str(n)); + throw Cantera::CanteraError("item","index out of range"+Cantera::int2str(int(n))); //return __table[0]; } } diff --git a/Cantera/clib/src/Storage.cpp b/Cantera/clib/src/Storage.cpp index 50c580d5a..741598f5d 100755 --- a/Cantera/clib/src/Storage.cpp +++ b/Cantera/clib/src/Storage.cpp @@ -19,11 +19,11 @@ Storage::Storage() { Storage::~Storage() { clear(); } -int Storage::addThermo(thermo_t* th) { +size_t Storage::addThermo(thermo_t* th) { if (th->index() != -1) return th->index(); __thtable.push_back(th); - int n = static_cast(__thtable.size()) - 1; + size_t n = __thtable.size() - 1; th->setIndex(n); //string id = th->id(); //if (__thmap.count(id) == 0) { @@ -37,24 +37,24 @@ int Storage::addThermo(thermo_t* th) { return n; } -int Storage::nThermo() { - return static_cast(__thtable.size()); +size_t Storage::nThermo() { + return __thtable.size(); } -int Storage::addKinetics(Kinetics* kin) { +size_t Storage::addKinetics(Kinetics* kin) { if (kin->index() != -1) return kin->index(); __ktable.push_back(kin); - int n = static_cast(__ktable.size()) - 1; + size_t n = __ktable.size() - 1; kin->setIndex(n); return n; } -int Storage::addTransport(Transport* tr) { +size_t Storage::addTransport(Transport* tr) { if (tr->index() != -1) return tr->index(); __trtable.push_back(tr); - int n = static_cast(__trtable.size()) - 1; + size_t n = __trtable.size() - 1; tr->setIndex(n); return n; } @@ -73,22 +73,22 @@ int Storage::addTransport(Transport* tr) { // } int Storage::clear() { - int i, n; - n = static_cast(__thtable.size()); + size_t i, n; + n = __thtable.size(); for (i = 1; i < n; i++) { if (__thtable[i] != __thtable[0]) { delete __thtable[i]; __thtable[i] = __thtable[0]; } } - n = static_cast(__ktable.size()); + n = __ktable.size(); for (i = 1; i < n; i++) { if (__ktable[i] != __ktable[0]) { delete __ktable[i]; __ktable[i] = __ktable[0]; } } - n = static_cast(__trtable.size()); + n = __trtable.size(); for (i = 1; i < n; i++) { if (__trtable[i] != __trtable[0]) { delete __trtable[i]; diff --git a/Cantera/clib/src/Storage.h b/Cantera/clib/src/Storage.h index 16b625dde..73335c73d 100755 --- a/Cantera/clib/src/Storage.h +++ b/Cantera/clib/src/Storage.h @@ -36,15 +36,15 @@ public: } - int addThermo(Cantera::ThermoPhase* th); - int addKinetics(Cantera::Kinetics* kin); - int addTransport(Cantera::Transport* tr); + size_t addThermo(Cantera::ThermoPhase* th); + size_t addKinetics(Cantera::Kinetics* kin); + size_t addTransport(Cantera::Transport* tr); // int addNewTransport(int model, char* dbase, int th, int loglevel); int clear(); void deleteKinetics(int n); void deleteThermo(int n); void deleteTransport(int n); - int nThermo(); + size_t nThermo(); static Storage* __storage; }; @@ -56,7 +56,7 @@ inline Cantera::Kinetics* kin(int n) { return Storage::__storage->__ktable[n]; } -inline Cantera::ThermoPhase* th(int n) { +inline Cantera::ThermoPhase* th(size_t n) { return Storage::__storage->__thtable[n]; } diff --git a/Cantera/clib/src/ct.cpp b/Cantera/clib/src/ct.cpp index a01c9fbc3..ae97174dc 100755 --- a/Cantera/clib/src/ct.cpp +++ b/Cantera/clib/src/ct.cpp @@ -84,7 +84,7 @@ static double pfprop(int n, int i, double v=0.0, double x=0.0) { #endif -inline int nThermo() { +inline size_t nThermo() { return Storage::storage()->nThermo(); } @@ -130,11 +130,11 @@ extern "C" { //--------------- Phase ---------------------// - int DLL_EXPORT phase_nElements(int n) { + size_t DLL_EXPORT phase_nElements(int n) { return ph(n)->nElements(); } - int DLL_EXPORT phase_nSpecies(int n) { + size_t DLL_EXPORT phase_nSpecies(int n) { return ph(n)->nSpecies(); } @@ -174,17 +174,17 @@ extern "C" { return ph(n)->meanMolecularWeight(); } - int DLL_EXPORT phase_elementIndex(int n, char* nm) { + size_t DLL_EXPORT phase_elementIndex(int n, char* nm) { string elnm = string(nm); return ph(n)->elementIndex(elnm); } - int DLL_EXPORT phase_speciesIndex(int n, char* nm) { + size_t DLL_EXPORT phase_speciesIndex(int n, char* nm) { string spnm = string(nm); return ph(n)->speciesIndex(spnm); } - int DLL_EXPORT phase_getMoleFractions(int n, int lenx, double* x) { + int DLL_EXPORT phase_getMoleFractions(int n, size_t lenx, double* x) { ThermoPhase* p = ph(n); if (lenx >= p->nSpecies()) { p->getMoleFractions(x); @@ -194,12 +194,12 @@ extern "C" { return -1; } - doublereal DLL_EXPORT phase_moleFraction(int n, int k) { + doublereal DLL_EXPORT phase_moleFraction(int n, size_t k) { ThermoPhase* p = ph(n); return p->moleFraction(k); } - int DLL_EXPORT phase_getMassFractions(int n, int leny, double* y) { + int DLL_EXPORT phase_getMassFractions(int n, size_t leny, double* y) { ThermoPhase* p = ph(n); if (leny >= p->nSpecies()) { p->getMassFractions(y); @@ -209,12 +209,12 @@ extern "C" { return -1; } - doublereal DLL_EXPORT phase_massFraction(int n, int k) { + doublereal DLL_EXPORT phase_massFraction(int n, size_t k) { ThermoPhase* p = ph(n); return p->massFraction(k); } - int DLL_EXPORT phase_setMoleFractions(int n, int lenx, double* x, int norm) { + int DLL_EXPORT phase_setMoleFractions(int n, size_t lenx, double* x, int norm) { ThermoPhase* p = ph(n); if (lenx >= p->nSpecies()) { if (norm) p->setMoleFractions(x); @@ -229,7 +229,7 @@ extern "C" { try { ThermoPhase* p = ph(n); compositionMap xx; - int nsp = p->nSpecies(); + size_t nsp = p->nSpecies(); for (int n = 0; n < nsp; n++) { xx[p->speciesName(n)] = -1; } @@ -241,7 +241,7 @@ extern "C" { //catch (...) {return ERR;} } - int DLL_EXPORT phase_setMassFractions(int n, int leny, + int DLL_EXPORT phase_setMassFractions(int n, size_t leny, double* y, int norm) { ThermoPhase* p = ph(n); if (leny >= p->nSpecies()) { @@ -257,7 +257,7 @@ extern "C" { try { ThermoPhase* p = ph(n); compositionMap yy; - int nsp = p->nSpecies(); + size_t nsp = p->nSpecies(); for (int n = 0; n < nsp; n++) { yy[p->speciesName(n)] = -1; } @@ -269,7 +269,7 @@ extern "C" { } int DLL_EXPORT phase_getAtomicWeights(int n, - int lenm, double* atw) { + size_t lenm, double* atw) { ThermoPhase* p = ph(n); if (lenm >= p->nElements()) { const vector_fp& wt = p->atomicWeights(); @@ -281,7 +281,7 @@ extern "C" { } int DLL_EXPORT phase_getMolecularWeights(int n, - int lenm, double* mw) { + size_t lenm, double* mw) { ThermoPhase* p = ph(n); if (lenm >= p->nSpecies()) { const vector_fp& wt = p->molecularWeights(); @@ -292,9 +292,9 @@ extern "C" { return -10; } - int DLL_EXPORT phase_getName(int n, int lennm, char* nm) { + int DLL_EXPORT phase_getName(int n, size_t lennm, char* nm) { string name = ph(n)->name(); - int lout = (int) min(lennm, (int) name.size()); + size_t lout = min(lennm, name.size()); copy(name.c_str(), name.c_str() + lout, nm); nm[lout] = '\0'; return 0; @@ -306,10 +306,10 @@ extern "C" { return 0; } - int DLL_EXPORT phase_getSpeciesName(int n, int k, int lennm, char* nm) { + int DLL_EXPORT phase_getSpeciesName(int n, size_t k, int lennm, char* nm) { try { string spnm = ph(n)->speciesName(k); - int lout = min(lennm, (int) spnm.size()); + size_t lout = min(lennm, spnm.size()); copy(spnm.c_str(), spnm.c_str() + lout, nm); nm[lout] = '\0'; return 0; @@ -318,10 +318,10 @@ extern "C" { //catch (...) {return ERR;} } - int DLL_EXPORT phase_getElementName(int n, int m, int lennm, char* nm) { + int DLL_EXPORT phase_getElementName(int n, size_t m, int lennm, char* nm) { try { string elnm = ph(n)->elementName(m); - int lout = min(lennm, (int) elnm.size()); + size_t lout = min(lennm, elnm.size()); copy(elnm.c_str(), elnm.c_str() + lout, nm); nm[lout] = '\0'; return 0; @@ -330,7 +330,7 @@ extern "C" { } - doublereal DLL_EXPORT phase_nAtoms(int n, int k, int m) { + doublereal DLL_EXPORT phase_nAtoms(int n, size_t k, size_t m) { try { return ph(n)->nAtoms(k,m); } @@ -384,7 +384,7 @@ extern "C" { // catch (CanteraError) { return -1; } // } - int DLL_EXPORT newThermoFromXML(int mxml) { + size_t DLL_EXPORT newThermoFromXML(int mxml) { try { XML_Node* x = _xml(mxml); thermo_t* th = newPhase(*x); @@ -397,7 +397,7 @@ extern "C" { // return th(n)->phase().index(); // } - int DLL_EXPORT th_nSpecies(int n) { + size_t DLL_EXPORT th_nSpecies(size_t n) { return th(n)->nSpecies(); } @@ -475,9 +475,9 @@ extern "C" { catch (CanteraError) {return DERR;} } - int DLL_EXPORT th_chemPotentials(int n, int lenm, double* murt) { + int DLL_EXPORT th_chemPotentials(int n, size_t lenm, double* murt) { thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); + size_t nsp = thrm->nSpecies(); if (lenm >= nsp) { thrm->getChemPotentials(murt); return 0; @@ -486,9 +486,9 @@ extern "C" { return -10; } - int DLL_EXPORT th_elementPotentials(int n, int lenm, double* lambda) { + int DLL_EXPORT th_elementPotentials(int n, size_t lenm, double* lambda) { thermo_t* thrm = th(n); - int nel = thrm->nElements(); + size_t nel = thrm->nElements(); if (lenm >= nel) { equilibrate(*thrm, "TP", 0); thrm->getElementPotentials(lambda); @@ -576,10 +576,10 @@ extern "C" { } - int DLL_EXPORT th_getEnthalpies_RT(int n, int lenm, double* h_rt) { + int DLL_EXPORT th_getEnthalpies_RT(int n, size_t lenm, double* h_rt) { try { thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); + size_t nsp = thrm->nSpecies(); if (lenm >= nsp) { thrm->getEnthalpy_RT_ref(h_rt); return 0; @@ -590,10 +590,10 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT th_getEntropies_R(int n, int lenm, double* s_r) { + int DLL_EXPORT th_getEntropies_R(int n, size_t lenm, double* s_r) { try { thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); + size_t nsp = thrm->nSpecies(); if (lenm >= nsp) { thrm->getEntropy_R_ref(s_r); return 0; @@ -604,10 +604,10 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT th_getCp_R(int n, int lenm, double* cp_r) { + int DLL_EXPORT th_getCp_R(int n, size_t lenm, double* cp_r) { try { thermo_t* thrm = th(n); - int nsp = thrm->nSpecies(); + size_t nsp = thrm->nSpecies(); if (lenm >= nsp) { thrm->getCp_R_ref(cp_r); return 0; @@ -710,7 +710,7 @@ extern "C" { //-------------- Kinetics ------------------// - int DLL_EXPORT newKineticsFromXML(int mxml, int iphase, + size_t DLL_EXPORT newKineticsFromXML(int mxml, int iphase, int neighbor1, int neighbor2, int neighbor3, int neighbor4) { try { @@ -755,33 +755,33 @@ extern "C" { return kin(n)->type(); } - int DLL_EXPORT kin_start(int n, int p) { + size_t DLL_EXPORT kin_start(int n, int p) { return kin(n)->kineticsSpeciesIndex(0,p); } - int DLL_EXPORT kin_speciesIndex(int n, const char* nm, const char* ph) { + size_t DLL_EXPORT kin_speciesIndex(int n, const char* nm, const char* ph) { return kin(n)->kineticsSpeciesIndex(string(nm), string(ph)); } //--------------------------------------- - int DLL_EXPORT kin_nSpecies(int n) { + size_t DLL_EXPORT kin_nSpecies(int n) { return kin(n)->nTotalSpecies(); } - int DLL_EXPORT kin_nReactions(int n) { + size_t DLL_EXPORT kin_nReactions(int n) { return kin(n)->nReactions(); } - int DLL_EXPORT kin_nPhases(int n) { + size_t DLL_EXPORT kin_nPhases(int n) { return kin(n)->nPhases(); } - int DLL_EXPORT kin_phaseIndex(int n, char* ph) { + size_t DLL_EXPORT kin_phaseIndex(int n, char* ph) { return kin(n)->phaseIndex(string(ph)); } - int DLL_EXPORT kin_reactionPhaseIndex(int n) { + size_t DLL_EXPORT kin_reactionPhaseIndex(int n) { return kin(n)->reactionPhaseIndex(); } @@ -797,7 +797,7 @@ extern "C" { return kin(n)->reactionType(i); } - int DLL_EXPORT kin_getFwdRatesOfProgress(int n, int len, double* fwdROP) { + int DLL_EXPORT kin_getFwdRatesOfProgress(int n, size_t len, double* fwdROP) { Kinetics* k = kin(n); try { if (len >= k->nReactions()) { @@ -810,7 +810,7 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT kin_getRevRatesOfProgress(int n, int len, double* revROP) { + int DLL_EXPORT kin_getRevRatesOfProgress(int n, size_t len, double* revROP) { Kinetics* k = kin(n); try { if (len >= k->nReactions()) { @@ -827,7 +827,7 @@ extern "C" { return (int)kin(n)->isReversible(i); } - int DLL_EXPORT kin_getNetRatesOfProgress(int n, int len, double* netROP) { + int DLL_EXPORT kin_getNetRatesOfProgress(int n, size_t len, double* netROP) { try { Kinetics* k = kin(n); if (len >= k->nReactions()) { @@ -840,7 +840,7 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT kin_getFwdRateConstants(int n, int len, double* kfwd) { + int DLL_EXPORT kin_getFwdRateConstants(int n, size_t len, double* kfwd) { try { Kinetics* k = kin(n); if (len >= k->nReactions()) { @@ -853,7 +853,7 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT kin_getRevRateConstants(int n, int doIrreversible, int len, double* krev) { + int DLL_EXPORT kin_getRevRateConstants(int n, int doIrreversible, size_t len, double* krev) { try { Kinetics* k = kin(n); bool doirrev = false; @@ -869,7 +869,7 @@ extern "C" { } - int DLL_EXPORT kin_getActivationEnergies(int n, int len, double* E) { + int DLL_EXPORT kin_getActivationEnergies(int n, size_t len, double* E) { try { Kinetics* k = kin(n); if (len >= k->nReactions()) { @@ -883,7 +883,7 @@ extern "C" { } - int DLL_EXPORT kin_getDelta(int n, int job, int len, double* delta) { + int DLL_EXPORT kin_getDelta(int n, int job, size_t len, double* delta) { try { Kinetics* k = kin(n); if (len < k->nReactions()) return ERR; @@ -923,7 +923,7 @@ extern "C" { } - int DLL_EXPORT kin_getCreationRates(int n, int len, double* cdot) { + int DLL_EXPORT kin_getCreationRates(int n, size_t len, double* cdot) { try { Kinetics* k = kin(n); if (len >= k->nTotalSpecies()) { @@ -936,7 +936,7 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT kin_getDestructionRates(int n, int len, double* ddot) { + int DLL_EXPORT kin_getDestructionRates(int n, size_t len, double* ddot) { try { Kinetics* k = kin(n); if (len >= k->nTotalSpecies()) { @@ -950,7 +950,7 @@ extern "C" { //catch (...) {return ERR;} } - int DLL_EXPORT kin_getNetProductionRates(int n, int len, double* wdot) { + int DLL_EXPORT kin_getNetProductionRates(int n, size_t len, double* wdot) { try { Kinetics* k = kin(n); if (len >= k->nTotalSpecies()) { @@ -963,7 +963,7 @@ extern "C" { catch (CanteraError) {return -1;} } - int DLL_EXPORT kin_getSourceTerms(int n, int len, double* ydot) { + int DLL_EXPORT kin_getSourceTerms(int n, size_t len, double* ydot) { try { Kinetics* k = kin(n); ThermoPhase* p = &k->thermo(); @@ -986,12 +986,11 @@ extern "C" { return kin(n)->multiplier(i); } - int DLL_EXPORT kin_phase(int n, int i) { + size_t DLL_EXPORT kin_phase(int n, size_t i) { return kin(n)->thermo(i).index(); - // return thermo_index(kin(n)->thermo(i).id()); } - int DLL_EXPORT kin_getEquilibriumConstants(int n, int len, double* kc) { + int DLL_EXPORT kin_getEquilibriumConstants(int n, size_t len, double* kc) { try { Kinetics* k = kin(n); if (len >= k->nReactions()) { @@ -1044,7 +1043,7 @@ extern "C" { //------------------- Transport --------------------------- - int DLL_EXPORT newTransport(char* model, + size_t DLL_EXPORT newTransport(char* model, int ith, int loglevel) { string mstr = string(model); thermo_t* t = th(ith); @@ -1186,7 +1185,7 @@ extern "C" { return 0; } - int DLL_EXPORT addCanteraDirectory(int buflen, char* buf) { + int DLL_EXPORT addCanteraDirectory(size_t buflen, char* buf) { addDirectory(string(buf)); return 0; } diff --git a/Cantera/clib/src/ct.h b/Cantera/clib/src/ct.h index fc113ed47..c591a8fd9 100755 --- a/Cantera/clib/src/ct.h +++ b/Cantera/clib/src/ct.h @@ -16,8 +16,8 @@ extern "C" { EEXXTT int DLL_CPREFIX ct_appdelete(); - EEXXTT int DLL_CPREFIX phase_nElements(int n); - EEXXTT int DLL_CPREFIX phase_nSpecies(int n); + EEXXTT size_t DLL_CPREFIX phase_nElements(int n); + EEXXTT size_t DLL_CPREFIX phase_nSpecies(int n); EEXXTT double DLL_CPREFIX phase_temperature(int n); EEXXTT int DLL_CPREFIX phase_setTemperature(int n, double t); EEXXTT double DLL_CPREFIX phase_density(int n); @@ -25,29 +25,29 @@ extern "C" { EEXXTT double DLL_CPREFIX phase_molarDensity(int n); EEXXTT int DLL_CPREFIX phase_setMolarDensity(int n, double ndens); EEXXTT double DLL_CPREFIX phase_meanMolecularWeight(int n); - EEXXTT double DLL_CPREFIX phase_moleFraction(int n, int k); - EEXXTT double DLL_CPREFIX phase_massFraction(int n, int k); - EEXXTT int DLL_CPREFIX phase_getMoleFractions(int n, int lenx, double* x); - EEXXTT int DLL_CPREFIX phase_getMassFractions(int n, int leny, double* y); - EEXXTT int DLL_CPREFIX phase_setMoleFractions(int n, int lenx, + EEXXTT double DLL_CPREFIX phase_moleFraction(int n, size_t k); + EEXXTT double DLL_CPREFIX phase_massFraction(int n, size_t k); + EEXXTT int DLL_CPREFIX phase_getMoleFractions(int n, size_t lenx, double* x); + EEXXTT int DLL_CPREFIX phase_getMassFractions(int n, size_t leny, double* y); + EEXXTT int DLL_CPREFIX phase_setMoleFractions(int n, size_t lenx, double* x, int norm); - EEXXTT int DLL_CPREFIX phase_setMassFractions(int n, int leny, + EEXXTT int DLL_CPREFIX phase_setMassFractions(int n, size_t leny, double* y, int norm); EEXXTT int DLL_CPREFIX phase_setMoleFractionsByName(int n, char* x); EEXXTT int DLL_CPREFIX phase_setMassFractionsByName(int n, char* y); - EEXXTT int DLL_CPREFIX phase_getAtomicWeights(int n, int lenm, double* atw); - EEXXTT int DLL_CPREFIX phase_getMolecularWeights(int n, int lenm, double* mw); - EEXXTT int DLL_CPREFIX phase_getElementName(int n, int k, int lennm, char* nm); - EEXXTT int DLL_CPREFIX phase_getSpeciesName(int n, int m, int lennm, char* nm); - EEXXTT int DLL_CPREFIX phase_getName(int n, int lennm, char* nm); + EEXXTT int DLL_CPREFIX phase_getAtomicWeights(int n, size_t lenm, double* atw); + EEXXTT int DLL_CPREFIX phase_getMolecularWeights(int n, size_t lenm, double* mw); + EEXXTT int DLL_CPREFIX phase_getElementName(int n, size_t k, int lennm, char* nm); + EEXXTT int DLL_CPREFIX phase_getSpeciesName(int n, size_t m, int lennm, char* nm); + EEXXTT int DLL_CPREFIX phase_getName(int n, size_t lennm, char* nm); EEXXTT int DLL_CPREFIX phase_setName(int n, const char* nm); - EEXXTT int DLL_CPREFIX phase_elementIndex(int n, char* nm); - EEXXTT int DLL_CPREFIX phase_speciesIndex(int n, char* nm); + EEXXTT size_t DLL_CPREFIX phase_elementIndex(int n, char* nm); + EEXXTT size_t DLL_CPREFIX phase_speciesIndex(int n, char* nm); EEXXTT int DLL_CPREFIX phase_report(int nth, int ibuf, char* buf, int show_thermo); EEXXTT int DLL_EXPORT write_phase(int nth, int show_thermo); - EEXXTT double DLL_CPREFIX phase_nAtoms(int n, int k, int m); + EEXXTT double DLL_CPREFIX phase_nAtoms(int n, size_t k, size_t m); EEXXTT int DLL_CPREFIX phase_addElement(int n, char* name, double weight); EEXXTT int DLL_CPREFIX phase_addSpecies(int n, char* name, int phase, @@ -56,10 +56,10 @@ extern "C" { double charge, double weight); //int DLL_CPREFIX newThermo(char* model); - EEXXTT int DLL_CPREFIX newThermoFromXML(int mxml); + EEXXTT size_t DLL_CPREFIX newThermoFromXML(int mxml); EEXXTT int DLL_CPREFIX th_thermoIndex(char* id); EEXXTT int DLL_CPREFIX th_phase(int n); - EEXXTT int DLL_CPREFIX th_nSpecies(int n); + EEXXTT size_t DLL_CPREFIX th_nSpecies(size_t n); EEXXTT int DLL_CPREFIX th_eosType(int n); EEXXTT double DLL_CPREFIX th_refPressure(int n); EEXXTT double DLL_CPREFIX th_minTemp(int n, int k=-1); @@ -79,11 +79,11 @@ extern "C" { EEXXTT double DLL_CPREFIX th_cp_mass(int n); EEXXTT double DLL_CPREFIX th_cv_mass(int n); EEXXTT double DLL_CPREFIX th_electricPotential(int n); - EEXXTT int DLL_CPREFIX th_chemPotentials(int n, int lenm, double* murt); - EEXXTT int DLL_CPREFIX th_elementPotentials(int n, int lenm, double* lambda); - EEXXTT int DLL_CPREFIX th_getEnthalpies_RT(int n, int lenm, double* h_rt); - EEXXTT int DLL_CPREFIX th_getEntropies_R(int n, int lenm, double* s_r); - EEXXTT int DLL_CPREFIX th_getCp_R(int n, int lenm, double* cp_r); + EEXXTT int DLL_CPREFIX th_chemPotentials(int n, size_t lenm, double* murt); + EEXXTT int DLL_CPREFIX th_elementPotentials(int n, size_t lenm, double* lambda); + EEXXTT int DLL_CPREFIX th_getEnthalpies_RT(int n, size_t lenm, double* h_rt); + EEXXTT int DLL_CPREFIX th_getEntropies_R(int n, size_t lenm, double* s_r); + EEXXTT int DLL_CPREFIX th_getCp_R(int n, size_t lenm, double* cp_r); EEXXTT int DLL_CPREFIX th_setElectricPotential(int n, double v); EEXXTT int DLL_CPREFIX get_eos(char* fname, char* phase_id); @@ -103,44 +103,44 @@ extern "C" { EEXXTT int DLL_CPREFIX th_setState_Psat(int n, double p, double x); EEXXTT int DLL_CPREFIX th_setState_Tsat(int n, double t, double x); - EEXXTT int DLL_CPREFIX newKineticsFromXML(int mxml, int iphase, + EEXXTT size_t DLL_CPREFIX newKineticsFromXML(int mxml, int iphase, int neighbor1=-1, int neighbor2=-1, int neighbor3=-1, int neighbor4=-1); EEXXTT int DLL_CPREFIX installRxnArrays(int pxml, int ikin, char* default_phase); - EEXXTT int DLL_CPREFIX kin_nSpecies(int n); - EEXXTT int DLL_CPREFIX kin_nReactions(int n); - EEXXTT int DLL_CPREFIX kin_nPhases(int n); - EEXXTT int DLL_CPREFIX kin_phaseIndex(int n, char* ph); - EEXXTT int DLL_CPREFIX kin_reactionPhaseIndex(int n); + EEXXTT size_t DLL_CPREFIX kin_nSpecies(int n); + EEXXTT size_t DLL_CPREFIX kin_nReactions(int n); + EEXXTT size_t DLL_CPREFIX kin_nPhases(int n); + EEXXTT size_t DLL_CPREFIX kin_phaseIndex(int n, char* ph); + EEXXTT size_t DLL_CPREFIX kin_reactionPhaseIndex(int n); EEXXTT double DLL_CPREFIX kin_reactantStoichCoeff(int n, int i, int k); EEXXTT double DLL_CPREFIX kin_productStoichCoeff(int n, int i, int k); EEXXTT int DLL_CPREFIX kin_reactionType(int n, int i); - EEXXTT int DLL_CPREFIX kin_getFwdRatesOfProgress(int n, int len, double* fwdROP); - EEXXTT int DLL_CPREFIX kin_getRevRatesOfProgress(int n, int len, double* revROP); - EEXXTT int DLL_CPREFIX kin_getNetRatesOfProgress(int n, int len, double* netROP); - EEXXTT int DLL_CPREFIX kin_getEquilibriumConstants(int n, int len, double* kc); + EEXXTT int DLL_CPREFIX kin_getFwdRatesOfProgress(int n, size_t len, double* fwdROP); + EEXXTT int DLL_CPREFIX kin_getRevRatesOfProgress(int n, size_t len, double* revROP); + EEXXTT int DLL_CPREFIX kin_getNetRatesOfProgress(int n, size_t len, double* netROP); + EEXXTT int DLL_CPREFIX kin_getEquilibriumConstants(int n, size_t len, double* kc); - EEXXTT int DLL_CPREFIX kin_getFwdRateConstants(int n, int len, double* kfwd); - EEXXTT int DLL_CPREFIX kin_getRevRateConstants(int n, int doIrreversible, int len, double* krev); - EEXXTT int DLL_CPREFIX kin_getActivationEnergies(int n, int len, double* E); - EEXXTT int DLL_CPREFIX kin_getDelta(int n, int job, int len, double* delta); - EEXXTT int DLL_CPREFIX kin_getCreationRates(int n, int len, double* cdot); - EEXXTT int DLL_CPREFIX kin_getDestructionRates(int n, int len, double* ddot); - EEXXTT int DLL_CPREFIX kin_getNetProductionRates(int n, int len, double* wdot); - EEXXTT int DLL_CPREFIX kin_getSourceTerms(int n, int len, double* ydot); + EEXXTT int DLL_CPREFIX kin_getFwdRateConstants(int n, size_t len, double* kfwd); + EEXXTT int DLL_CPREFIX kin_getRevRateConstants(int n, int doIrreversible, size_t len, double* krev); + EEXXTT int DLL_CPREFIX kin_getActivationEnergies(int n, size_t len, double* E); + EEXXTT int DLL_CPREFIX kin_getDelta(int n, int job, size_t len, double* delta); + EEXXTT int DLL_CPREFIX kin_getCreationRates(int n, size_t len, double* cdot); + EEXXTT int DLL_CPREFIX kin_getDestructionRates(int n, size_t len, double* ddot); + EEXXTT int DLL_CPREFIX kin_getNetProductionRates(int n, size_t len, double* wdot); + EEXXTT int DLL_CPREFIX kin_getSourceTerms(int n, size_t len, double* ydot); EEXXTT double DLL_CPREFIX kin_multiplier(int n, int i); EEXXTT int DLL_CPREFIX kin_getReactionString(int n, int i, int len, char* buf); EEXXTT int DLL_CPREFIX kin_setMultiplier(int n, int i, double v); EEXXTT int DLL_CPREFIX kin_isReversible(int n, int i); EEXXTT int DLL_CPREFIX kin_type(int n); - EEXXTT int DLL_CPREFIX kin_start(int n, int p); - EEXXTT int DLL_CPREFIX kin_speciesIndex(int n, const char* nm, const char* ph); + EEXXTT size_t DLL_CPREFIX kin_start(int n, int p); + EEXXTT size_t DLL_CPREFIX kin_speciesIndex(int n, const char* nm, const char* ph); EEXXTT int DLL_CPREFIX kin_advanceCoverages(int n, double tstep); - EEXXTT int DLL_CPREFIX kin_phase(int n, int i); + EEXXTT size_t DLL_CPREFIX kin_phase(int n, size_t i); - EEXXTT int DLL_CPREFIX newTransport(char* model, + EEXXTT size_t DLL_CPREFIX newTransport(char* model, int th, int loglevel); EEXXTT double DLL_CPREFIX trans_viscosity(int n); EEXXTT double DLL_CPREFIX trans_thermalConductivity(int n); @@ -163,7 +163,7 @@ extern "C" { EEXXTT int DLL_CPREFIX showCanteraErrors(); EEXXTT int DLL_CPREFIX write_HTML_log(char* file); EEXXTT int DLL_CPREFIX setLogWriter(void* logger); - EEXXTT int DLL_CPREFIX addCanteraDirectory(int buflen, char* buf); + EEXXTT int DLL_CPREFIX addCanteraDirectory(size_t buflen, char* buf); EEXXTT int DLL_CPREFIX clearStorage(); EEXXTT int DLL_CPREFIX delPhase(int n); EEXXTT int DLL_CPREFIX delThermo(int n); diff --git a/Cantera/clib/src/ctfunc.cpp b/Cantera/clib/src/ctfunc.cpp index 44a872ee3..d0e731028 100755 --- a/Cantera/clib/src/ctfunc.cpp +++ b/Cantera/clib/src/ctfunc.cpp @@ -17,7 +17,7 @@ typedef Func1 func_t; // Assign storage to the Cabinet static member template<> Cabinet* Cabinet::__storage = 0; -inline func_t* _func(int i) { +inline func_t* _func(size_t i) { return Cabinet::cabinet()->item(i); } @@ -25,9 +25,9 @@ extern "C" { // functions - int DLL_EXPORT func_new(int type, int n, int lenp, double* params) { + int DLL_EXPORT func_new(int type, int n, size_t lenp, double* params) { func_t* r=0; - int m = lenp; + size_t m = lenp; try { if (type == SinFuncType) { r = new Sin1(params[0]); @@ -140,12 +140,12 @@ extern "C" { return Cabinet::cabinet()->add(r); } - int DLL_EXPORT func_write(int i, int lennm, const char* arg, char* nm) { + int DLL_EXPORT func_write(int i, size_t lennm, const char* arg, char* nm) { try { string a = string(arg); string w = _func(i)->write(a); - int ws = w.size(); - int lout = (lennm > ws ? ws : lennm); + size_t ws = w.size(); + size_t lout = (lennm > ws ? ws : lennm); std::copy(w.c_str(), w.c_str() + lout, nm); nm[lout] = '\0'; return 0; diff --git a/Cantera/clib/src/ctfunc.h b/Cantera/clib/src/ctfunc.h index 491d36515..cc4935f27 100755 --- a/Cantera/clib/src/ctfunc.h +++ b/Cantera/clib/src/ctfunc.h @@ -7,14 +7,14 @@ #include "clib_defs.h" extern "C" { - EEXXTT int DLL_CPREFIX func_new(int type, int n, int lenp, double* p); + EEXXTT int DLL_CPREFIX func_new(int type, int n, size_t lenp, double* p); EEXXTT int DLL_CPREFIX func_del(int i); EEXXTT int DLL_CPREFIX func_copy(int i); EEXXTT int DLL_CPREFIX func_assign(int i, int j); EEXXTT double DLL_CPREFIX func_value(int i, double t); EEXXTT int DLL_CPREFIX func_derivative(int i); EEXXTT int DLL_CPREFIX func_duplicate(int i); - EEXXTT int DLL_CPREFIX func_write(int i, int lennm, const char* arg, char* nm); + EEXXTT int DLL_CPREFIX func_write(int i, size_t lennm, const char* arg, char* nm); } #endif diff --git a/Cantera/clib/src/ctmultiphase.cpp b/Cantera/clib/src/ctmultiphase.cpp index aff5fd9a2..d06313261 100644 --- a/Cantera/clib/src/ctmultiphase.cpp +++ b/Cantera/clib/src/ctmultiphase.cpp @@ -98,15 +98,15 @@ extern "C" { return 0; } - int DLL_EXPORT mix_nElements(int i) { + size_t DLL_EXPORT mix_nElements(int i) { return _mix(i)->nElements(); } - int DLL_EXPORT mix_elementIndex(int i, char* name) { + size_t DLL_EXPORT mix_elementIndex(int i, char* name) { return _mix(i)->elementIndex(string(name)); } - int DLL_EXPORT mix_nSpecies(int i) { + size_t DLL_EXPORT mix_nSpecies(int i) { return _mix(i)->nSpecies(); } @@ -122,7 +122,7 @@ extern "C" { return DERR; } - double DLL_EXPORT mix_nPhases(int i) { + size_t DLL_EXPORT mix_nPhases(int i) { return _mix(i)->nPhases(); } @@ -138,7 +138,7 @@ extern "C" { return 0; } - int DLL_EXPORT mix_setMoles(int i, int nlen, double* n) { + int DLL_EXPORT mix_setMoles(int i, size_t nlen, double* n) { try { if (nlen < _mix(i)->nSpecies()) throw CanteraError("setMoles","array size too small."); @@ -241,7 +241,7 @@ extern "C" { } } - int DLL_EXPORT mix_getChemPotentials(int i, int lenmu, double* mu) { + int DLL_EXPORT mix_getChemPotentials(int i, size_t lenmu, double* mu) { try { if (lenmu < _mix(i)->nSpecies()) throw CanteraError("getChemPotentials","array too small"); @@ -288,7 +288,7 @@ extern "C" { return _mix(i)->volume(); } - int DLL_EXPORT mix_speciesPhaseIndex(int i, int k) { + size_t DLL_EXPORT mix_speciesPhaseIndex(int i, int k) { return _mix(i)->speciesPhaseIndex(k); } diff --git a/Cantera/clib/src/ctmultiphase.h b/Cantera/clib/src/ctmultiphase.h index 2681596ff..f8bda233d 100644 --- a/Cantera/clib/src/ctmultiphase.h +++ b/Cantera/clib/src/ctmultiphase.h @@ -14,10 +14,10 @@ extern "C" { EEXXTT int DLL_CPREFIX mix_assign(int i, int j); EEXXTT int DLL_CPREFIX mix_addPhase(int i, int j, double moles); EEXXTT int DLL_CPREFIX mix_init(int i); - EEXXTT int DLL_CPREFIX mix_nElements(int i); - EEXXTT int DLL_CPREFIX mix_elementIndex(int i, char* name); + EEXXTT size_t DLL_CPREFIX mix_nElements(int i); + EEXXTT size_t DLL_CPREFIX mix_elementIndex(int i, char* name); EEXXTT size_t DLL_CPREFIX mix_speciesIndex(int i, int k, int p); - EEXXTT int DLL_CPREFIX mix_nSpecies(int i); + EEXXTT size_t DLL_CPREFIX mix_nSpecies(int i); EEXXTT int DLL_CPREFIX mix_setTemperature(int i, double t); EEXXTT double DLL_CPREFIX mix_temperature(int i); EEXXTT double DLL_CPREFIX mix_minTemp(int i); @@ -27,10 +27,10 @@ extern "C" { EEXXTT int DLL_CPREFIX mix_setPressure(int i, double p); EEXXTT double DLL_CPREFIX mix_pressure(int i); EEXXTT double DLL_CPREFIX mix_nAtoms(int i, int k, int m); - EEXXTT double DLL_CPREFIX mix_nPhases(int i); + EEXXTT size_t DLL_CPREFIX mix_nPhases(int i); EEXXTT double DLL_CPREFIX mix_phaseMoles(int i, int n); EEXXTT int DLL_CPREFIX mix_setPhaseMoles(int i, int n, double v); - EEXXTT int DLL_CPREFIX mix_setMoles(int i, int nlen, double* n); + EEXXTT int DLL_CPREFIX mix_setMoles(int i, size_t nlen, double* n); EEXXTT int DLL_CPREFIX mix_setMolesByName(int i, char* n); EEXXTT double DLL_CPREFIX mix_speciesMoles(int i, int k); EEXXTT double DLL_CPREFIX mix_elementMoles(int i, int m); @@ -40,7 +40,7 @@ extern "C" { int printLvl, int solver, double rtol, int maxsteps, int maxiter, int loglevel); - EEXXTT int DLL_CPREFIX mix_getChemPotentials(int i, int lenmu, double* mu); + EEXXTT int DLL_CPREFIX mix_getChemPotentials(int i, size_t lenmu, double* mu); EEXXTT int DLL_CPREFIX mix_getValidChemPotentials(int i, double bad_mu, int standard, int lenmu, double* mu); @@ -50,7 +50,7 @@ extern "C" { EEXXTT double DLL_CPREFIX mix_cp(int i); EEXXTT double DLL_CPREFIX mix_volume(int i); - EEXXTT int DLL_CPREFIX mix_speciesPhaseIndex(int i, int k); + EEXXTT size_t DLL_CPREFIX mix_speciesPhaseIndex(int i, int k); EEXXTT double DLL_CPREFIX mix_moleFraction(int i, int k); } diff --git a/Cantera/clib/src/ctonedim.cpp b/Cantera/clib/src/ctonedim.cpp index 5cb41fa7a..c824bf163 100644 --- a/Cantera/clib/src/ctonedim.cpp +++ b/Cantera/clib/src/ctonedim.cpp @@ -83,15 +83,15 @@ extern "C" { return _domain(i)->domainType(); } - int DLL_EXPORT domain_index(int i) { + size_t DLL_EXPORT domain_index(int i) { return _domain(i)->domainIndex(); } - int DLL_EXPORT domain_nComponents(int i) { + size_t DLL_EXPORT domain_nComponents(int i) { return _domain(i)->nComponents(); } - int DLL_EXPORT domain_nPoints(int i) { + size_t DLL_EXPORT domain_nPoints(int i) { return _domain(i)->nPoints(); } @@ -107,9 +107,9 @@ extern "C" { catch (CanteraError) { return -1; } } - int DLL_EXPORT domain_componentIndex(int i, char* name) { + size_t DLL_EXPORT domain_componentIndex(int i, char* name) { try { - int n = _domain(i)->componentIndex(string(name)); + size_t n = _domain(i)->componentIndex(string(name)); return n; } catch (CanteraError) { return -1; } @@ -167,7 +167,7 @@ extern "C" { catch (CanteraError) { return DERR; } } - int DLL_EXPORT domain_setupGrid(int i, int npts, double* grid) { + int DLL_EXPORT domain_setupGrid(int i, size_t npts, double* grid) { try { _domain(i)->setupGrid(npts, grid); return 0; @@ -302,7 +302,7 @@ extern "C" { int DLL_EXPORT reactingsurf_enableCoverageEqs(int i, int onoff) { try { ReactingSurf1D* srf = (ReactingSurf1D*)_bdry(i); - srf->enableCoverageEquations(bool(onoff)); + srf->enableCoverageEquations(onoff != 0); return 0; } @@ -372,8 +372,8 @@ extern "C" { catch (CanteraError) { return -1; } } - int DLL_EXPORT stflow_setFixedTempProfile(int i, int n, double* pos, - int m, double* temp) { + int DLL_EXPORT stflow_setFixedTempProfile(int i, size_t n, double* pos, + size_t m, double* temp) { try { int j; vector_fp vpos(n), vtemp(n); @@ -414,11 +414,11 @@ extern "C" { //------------------- Sim1D -------------------------------------- - int DLL_EXPORT sim1D_new(int nd, int* domains) { + int DLL_EXPORT sim1D_new(size_t nd, int* domains) { vector d; try { // cout << "nd = " << nd << endl; - for (int n = 0; n < nd; n++) { + for (size_t n = 0; n < nd; n++) { //writelog("n = "+int2str(n)+"\n"); //writelog("dom = "+int2str(domains[n])+"\n"); d.push_back(_domain(domains[n])); @@ -454,7 +454,7 @@ extern "C" { } int DLL_EXPORT sim1D_setProfile(int i, int dom, int comp, - int np, double* pos, int nv, double* v) { + size_t np, double* pos, size_t nv, double* v) { try { vector_fp vv, pv; for (int n = 0; n < np; n++) { @@ -487,7 +487,7 @@ extern "C" { return 0; } - int DLL_EXPORT sim1D_setTimeStep(int i, double stepsize, int ns, integer* nsteps) { + int DLL_EXPORT sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps) { try { _sim1D(i)->setTimeStep(stepsize, ns, nsteps); return 0; @@ -638,7 +638,7 @@ extern "C" { catch (CanteraError) { return DERR; } } - int DLL_EXPORT sim1D_size(int i) { + size_t DLL_EXPORT sim1D_size(int i) { try { return _sim1D(i)->size(); } diff --git a/Cantera/clib/src/ctonedim.h b/Cantera/clib/src/ctonedim.h index 36b4a9425..66d196cd5 100644 --- a/Cantera/clib/src/ctonedim.h +++ b/Cantera/clib/src/ctonedim.h @@ -17,11 +17,11 @@ extern "C" { EEXXTT int DLL_CPREFIX domain_clear(); EEXXTT int DLL_CPREFIX domain_del(int i); EEXXTT int DLL_CPREFIX domain_type(int i); - EEXXTT int DLL_CPREFIX domain_index(int i); - EEXXTT int DLL_CPREFIX domain_nComponents(int i); - EEXXTT int DLL_CPREFIX domain_nPoints(int i); + EEXXTT size_t DLL_CPREFIX domain_index(int i); + EEXXTT size_t DLL_CPREFIX domain_nComponents(int i); + EEXXTT size_t DLL_CPREFIX domain_nPoints(int i); EEXXTT int DLL_CPREFIX domain_componentName(int i, int n, int sz, char* nameout); - EEXXTT int DLL_CPREFIX domain_componentIndex(int i, char* name); + EEXXTT size_t DLL_CPREFIX domain_componentIndex(int i, char* name); EEXXTT int DLL_CPREFIX domain_setBounds(int i, int n, double lower, double upper); EEXXTT double DLL_EXPORT domain_lowerBound(int i, int n); @@ -30,7 +30,7 @@ extern "C" { double atol, int itime); EEXXTT double DLL_CPREFIX domain_rtol(int i, int n); EEXXTT double DLL_CPREFIX domain_atol(int i, int n); - EEXXTT int DLL_CPREFIX domain_setupGrid(int i, int npts, double* grid); + EEXXTT int DLL_CPREFIX domain_setupGrid(int i, size_t npts, double* grid); EEXXTT int DLL_CPREFIX domain_setID(int i, char* id); EEXXTT int DLL_CPREFIX domain_setDesc(int i, char* desc); EEXXTT double DLL_CPREFIX domain_grid(int i, int n); @@ -58,20 +58,20 @@ extern "C" { EEXXTT int DLL_CPREFIX stflow_setTransport(int i, int itr, int iSoret); EEXXTT int DLL_CPREFIX stflow_enableSoret(int i, int iSoret); EEXXTT int DLL_CPREFIX stflow_setPressure(int i, double p); - EEXXTT int DLL_CPREFIX stflow_setFixedTempProfile(int i, int n, double* pos, - int m, double* temp); + EEXXTT int DLL_CPREFIX stflow_setFixedTempProfile(int i, size_t n, double* pos, + size_t m, double* temp); EEXXTT int DLL_CPREFIX stflow_solveSpeciesEqs(int i, int flag); EEXXTT int DLL_CPREFIX stflow_solveEnergyEqn(int i, int flag); EEXXTT int DLL_CPREFIX sim1D_clear(); - EEXXTT int DLL_CPREFIX sim1D_new(int nd, int* domains); + EEXXTT int DLL_CPREFIX sim1D_new(size_t nd, int* domains); EEXXTT int DLL_CPREFIX sim1D_del(int i); EEXXTT int DLL_CPREFIX sim1D_setValue(int i, int dom, int comp, int localPoint, double value); EEXXTT int DLL_CPREFIX sim1D_setProfile(int i, int dom, int comp, - int np, double* pos, int nv, double* v); + size_t np, double* pos, size_t nv, double* v); EEXXTT int DLL_CPREFIX sim1D_setFlatProfile(int i, int dom, int comp, double v); EEXXTT int DLL_CPREFIX sim1D_showSolution(int i, char* fname); - EEXXTT int DLL_CPREFIX sim1D_setTimeStep(int i, double stepsize, int ns, integer* nsteps); + EEXXTT int DLL_CPREFIX sim1D_setTimeStep(int i, double stepsize, size_t ns, integer* nsteps); EEXXTT int DLL_CPREFIX sim1D_getInitialSoln(int i); EEXXTT int DLL_CPREFIX sim1D_solve(int i, int loglevel, int refine_grid); EEXXTT int DLL_CPREFIX sim1D_refine(int i, int loglevel); @@ -92,7 +92,7 @@ extern "C" { EEXXTT int DLL_CPREFIX sim1D_setFixedTemperature(int i, double temp); EEXXTT int DLL_CPREFIX sim1D_evalSSJacobian(int i); EEXXTT double DLL_CPREFIX sim1D_jacobian(int i, int m, int n); - EEXXTT int DLL_CPREFIX sim1D_size(int i); + EEXXTT size_t DLL_CPREFIX sim1D_size(int i); } diff --git a/Cantera/clib/src/ctreactor.cpp b/Cantera/clib/src/ctreactor.cpp index 3b8432d82..69a637dc2 100755 --- a/Cantera/clib/src/ctreactor.cpp +++ b/Cantera/clib/src/ctreactor.cpp @@ -172,7 +172,7 @@ extern "C" { return 0; } - int DLL_EXPORT reactor_nSensParams(int i) { + size_t DLL_EXPORT reactor_nSensParams(int i) { reactor_t* r = _reactor(i); if (r->type() >= ReactorType) return ((Reactor*)r)->nSensParams(); diff --git a/Cantera/clib/src/ctreactor.h b/Cantera/clib/src/ctreactor.h index a50761f28..975b8d63d 100755 --- a/Cantera/clib/src/ctreactor.h +++ b/Cantera/clib/src/ctreactor.h @@ -28,7 +28,7 @@ extern "C" { EEXXTT double DLL_CPREFIX reactor_intEnergy_mass(int i); EEXXTT double DLL_CPREFIX reactor_pressure(int i); EEXXTT double DLL_CPREFIX reactor_massFraction(int i, int k); - EEXXTT int DLL_CPREFIX reactor_nSensParams(int i); + EEXXTT size_t DLL_CPREFIX reactor_nSensParams(int i); EEXXTT int DLL_CPREFIX reactor_addSensitivityReaction(int i, int rxn); EEXXTT int DLL_CPREFIX flowReactor_setMassFlowRate(int i, double mdot); diff --git a/Cantera/clib/src/ctrpath.cpp b/Cantera/clib/src/ctrpath.cpp index 2fba56888..efb85baba 100755 --- a/Cantera/clib/src/ctrpath.cpp +++ b/Cantera/clib/src/ctrpath.cpp @@ -138,7 +138,7 @@ extern "C" { } int DLL_EXPORT rdiag_findMajor(int i, double threshold, - int lda, double* a) { + size_t lda, double* a) { _diag(i)->findMajorPaths(threshold, lda, a); return 0; } diff --git a/Cantera/clib/src/ctrpath.h b/Cantera/clib/src/ctrpath.h index 4ae6e886e..5866bd191 100755 --- a/Cantera/clib/src/ctrpath.h +++ b/Cantera/clib/src/ctrpath.h @@ -26,7 +26,7 @@ extern "C" { EEXXTT int DLL_CPREFIX rdiag_setTitle(int i, char* title); EEXXTT int DLL_CPREFIX rdiag_write(int i, int fmt, char* fname); EEXXTT int DLL_CPREFIX rdiag_add(int i, int n); - EEXXTT int DLL_CPREFIX rdiag_findMajor(int i, double threshold, int lda, double* a); + EEXXTT int DLL_CPREFIX rdiag_findMajor(int i, double threshold, size_t lda, double* a); EEXXTT int DLL_CPREFIX rdiag_setFont(int i, char* font); EEXXTT int DLL_CPREFIX rdiag_displayOnly(int i, int k); diff --git a/Cantera/clib/src/ctxml.cpp b/Cantera/clib/src/ctxml.cpp index 1b86cb48d..c06dda73f 100644 --- a/Cantera/clib/src/ctxml.cpp +++ b/Cantera/clib/src/ctxml.cpp @@ -254,18 +254,17 @@ extern "C" { bool conv = false; if (iconvert > 0) conv = true; getFloatArray(node, v, conv); - int nv = v.size(); + size_t nv = v.size(); // array not big enough if (n < nv) { throw CanteraError("ctml_getFloatArray", - "array must be dimensioned at least "+int2str(nv)); + "array must be dimensioned at least "+int2str(int(nv))); } for (int i = 0; i < nv; i++) { data[i] = v[i]; } - n = nv; } catch (CanteraError) { return -1; } return 0; diff --git a/Cantera/python/src/ctfunc_methods.cpp b/Cantera/python/src/ctfunc_methods.cpp index e64907dc3..ce7cd85d7 100644 --- a/Cantera/python/src/ctfunc_methods.cpp +++ b/Cantera/python/src/ctfunc_methods.cpp @@ -8,7 +8,7 @@ py_func_new(PyObject *self, PyObject *args) return NULL; PyArrayObject* coeffs = (PyArrayObject*)c; double* xd = (double*)coeffs->data; - int lenc = coeffs->dimensions[0]; + size_t lenc = coeffs->dimensions[0]; int nn = func_new(type, n, lenc, xd); if (nn < 0) return reportError(nn); return Py_BuildValue("i",nn); diff --git a/Cantera/python/src/ctfuncs.cpp b/Cantera/python/src/ctfuncs.cpp index 6a50f0c56..6c21c4522 100644 --- a/Cantera/python/src/ctfuncs.cpp +++ b/Cantera/python/src/ctfuncs.cpp @@ -47,7 +47,7 @@ ct_addDirectory(PyObject *self, PyObject *args) char* dir; if (!PyArg_ParseTuple(args, "s:addDirectory", &dir)) return NULL; - int n = strlen(dir); + size_t n = strlen(dir); addCanteraDirectory(n, dir); return Py_BuildValue("i",0); } diff --git a/Cantera/python/src/ctkinetics_methods.cpp b/Cantera/python/src/ctkinetics_methods.cpp index f61d77d2e..c46dbfee7 100644 --- a/Cantera/python/src/ctkinetics_methods.cpp +++ b/Cantera/python/src/ctkinetics_methods.cpp @@ -8,8 +8,8 @@ kin_newFromXML(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "iiiiii:newFromXML", &mxml, &iphase, &neighbor1, &neighbor2, &neighbor3, &neighbor4)) return NULL; - int n = newKineticsFromXML(mxml, iphase, neighbor1, neighbor2, - neighbor3, neighbor4); + int n = int(newKineticsFromXML(mxml, iphase, neighbor1, neighbor2, + neighbor3, neighbor4)); if (n < 0) return reportError(n); return Py_BuildValue("i",n); } @@ -157,17 +157,18 @@ kin_getarray(PyObject *self, PyObject *args) // array attributes int iok = -22; - int nrxns = kin_nReactions(kin); - int nsp = kin_nSpecies(kin); - int ix; + size_t nrxns = kin_nReactions(kin); + size_t nsp = kin_nSpecies(kin); + size_t ix; if (job < 45 || job >= 90) ix = nrxns; else ix = nsp; #ifdef HAS_NUMPY npy_intp nix = ix; PyArrayObject* x = (PyArrayObject*)PyArray_SimpleNew(1, &nix, PyArray_DOUBLE); #else + int nix = int(ix); PyArrayObject* x = - (PyArrayObject*)PyArray_FromDims(1, &ix, PyArray_DOUBLE); + (PyArrayObject*)PyArray_FromDims(1, &nix, PyArray_DOUBLE); #endif double* xd = (double*)x->data; diff --git a/Cantera/python/src/ctmultiphase_methods.cpp b/Cantera/python/src/ctmultiphase_methods.cpp index cefbaa126..10de6ff33 100644 --- a/Cantera/python/src/ctmultiphase_methods.cpp +++ b/Cantera/python/src/ctmultiphase_methods.cpp @@ -60,8 +60,8 @@ py_mix_nElements(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:mix_nElements", &i)) return NULL; - _val = mix_nElements(i); - if (int(_val) < -900) return reportCanteraError(); + _val = int(mix_nElements(i)); + if (_val < -900) return reportCanteraError(); return Py_BuildValue("i",_val); } @@ -74,8 +74,8 @@ py_mix_elementIndex(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is:mix_elementIndex", &i, &name)) return NULL; - _val = mix_elementIndex(i,name); - if (int(_val) < -900) return reportCanteraError(); + _val = int(mix_elementIndex(i,name)); + if (_val < -900) return reportCanteraError(); return Py_BuildValue("i",_val); } @@ -87,15 +87,15 @@ py_mix_nSpecies(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:mix_nSpecies", &i)) return NULL; - _val = mix_nSpecies(i); - if (int(_val) < -900) return reportCanteraError(); + _val = int(mix_nSpecies(i)); + if (_val < -900) return reportCanteraError(); return Py_BuildValue("i",_val); } static PyObject * py_mix_speciesIndex(PyObject *self, PyObject *args) { - int _val; + size_t _val; int i, k, p; if (!PyArg_ParseTuple(args, "iii:mix_speciesIndex", &i, &k, &p)) return NULL; @@ -307,7 +307,7 @@ py_mix_setMoles(PyObject *self, PyObject *args) PyArrayObject* n_array = (PyArrayObject*)n; double* n_data = (double*)n_array->data; - int n_len = n_array->dimensions[0]; + size_t n_len = n_array->dimensions[0]; _val = mix_setMoles(i,n_len,n_data); if (int(_val) < -900) return reportCanteraError(); @@ -387,7 +387,7 @@ py_mix_getChemPotentials(PyObject *self, PyObject *args) PyArrayObject* mu_array = (PyArrayObject*)mu; double* mu_data = (double*)mu_array->data; - int mu_len = mu_array->dimensions[0]; + size_t mu_len = mu_array->dimensions[0]; _val = mix_getChemPotentials(i, mu_len, mu_data); if (int(_val) < 0) return reportCanteraError(); diff --git a/Cantera/python/src/ctonedim_methods.cpp b/Cantera/python/src/ctonedim_methods.cpp index 4f28ed86f..f797dd3b4 100644 --- a/Cantera/python/src/ctonedim_methods.cpp +++ b/Cantera/python/src/ctonedim_methods.cpp @@ -47,7 +47,7 @@ py_domain_index(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:domain_index", &i)) return NULL; - _val = domain_index(i); + _val = int(domain_index(i)); if (int(_val) == -1) return reportCanteraError(); return Py_BuildValue("i",_val); } @@ -61,7 +61,7 @@ py_domain_nComponents(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:domain_nComponents", &i)) return NULL; - _val = domain_nComponents(i); + _val = int(domain_nComponents(i)); if (int(_val) == -1) return reportCanteraError(); return Py_BuildValue("i",_val); } @@ -75,7 +75,7 @@ py_domain_nPoints(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:domain_nPoints", &i)) return NULL; - _val = domain_nPoints(i); + _val = int(domain_nPoints(i)); if (int(_val) == -1) return reportCanteraError(); return Py_BuildValue("i",_val); } @@ -111,7 +111,7 @@ py_domain_componentIndex(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is:domain_componentIndex", &i, &name)) return NULL; - _val = domain_componentIndex(i,name); + _val = int(domain_componentIndex(i,name)); if (int(_val) == -1) return reportCanteraError(); return Py_BuildValue("i",_val); } @@ -224,7 +224,7 @@ py_domain_setupGrid(PyObject *self, PyObject *args) PyArrayObject* grid_array = (PyArrayObject*) PyArray_ContiguousFromObject(grid, PyArray_DOUBLE, 1, 1); double* grid_data = (double*)(grid_array->data); - int grid_len = grid_array->dimensions[0]; + size_t grid_len = grid_array->dimensions[0]; _val = domain_setupGrid(i,grid_len,grid_data); Py_DECREF(grid_array); @@ -542,7 +542,7 @@ py_stflow_setFixedTempProfile(PyObject *self, PyObject *args) PyArrayObject* pos_array = (PyArrayObject*) PyArray_ContiguousFromObject(pos, PyArray_DOUBLE, 1, 1); double* pos_data = (double*)(pos_array->data); - int pos_len = pos_array->dimensions[0]; + size_t pos_len = pos_array->dimensions[0]; PyArrayObject* temp_array = (PyArrayObject*) @@ -550,7 +550,7 @@ py_stflow_setFixedTempProfile(PyObject *self, PyObject *args) double* temp_data = (double*)(temp_array->data); - int temp_len = temp_array->dimensions[0]; + size_t temp_len = temp_array->dimensions[0]; _val = stflow_setFixedTempProfile(i,pos_len,pos_data,temp_len,temp_data); Py_DECREF(pos_array); @@ -616,7 +616,7 @@ py_sim1D_new(PyObject *self, PyObject *args) PyArray_ContiguousFromObject(domains, PyArray_DOUBLE, 1, 1); void * nTMPv = (void *) (domains_array->data); double * dd_data = (double *) nTMPv; - int domains_len = domains_array->dimensions[0]; + size_t domains_len = domains_array->dimensions[0]; int * domains_data = (int *) malloc(sizeof(int) * domains_len); for (int i = 0; i < domains_len; i++) { @@ -680,13 +680,13 @@ py_sim1D_setProfile(PyObject *self, PyObject *args) PyArrayObject* pos_array = (PyArrayObject*) PyArray_ContiguousFromObject(pos, PyArray_DOUBLE, 1, 1); double* pos_data = (double*)(pos_array->data); - int pos_len = pos_array->dimensions[0]; + size_t pos_len = pos_array->dimensions[0]; PyArrayObject* v_array = (PyArrayObject*) PyArray_ContiguousFromObject(v, PyArray_DOUBLE, 1, 1); double* v_data = (double*)(v_array->data); - int v_len = v_array->dimensions[0]; + size_t v_len = v_array->dimensions[0]; _val = sim1D_setProfile(i,dom,comp,pos_len,pos_data,v_len,v_data); Py_DECREF(pos_array); @@ -749,10 +749,10 @@ py_sim1D_setTimeStep(PyObject *self, PyObject *args) void * nTMPv = (void *) (nsteps_array->data); double * nsteps_data = (double *) nTMPv; - int nsteps_len = nsteps_array->dimensions[0]; + size_t nsteps_len = nsteps_array->dimensions[0]; int * nsteps_datai = (int *) malloc(sizeof(int) * nsteps_len); - for (int i = 0; i < nsteps_len; i++) { + for (size_t i = 0; i < nsteps_len; i++) { nsteps_datai[i] = (int) nsteps_data[i]; } _val = sim1D_setTimeStep(i, stepsize, nsteps_len, nsteps_datai); diff --git a/Cantera/python/src/ctphase_methods.cpp b/Cantera/python/src/ctphase_methods.cpp index fea2dcef2..3dc746e6f 100644 --- a/Cantera/python/src/ctphase_methods.cpp +++ b/Cantera/python/src/ctphase_methods.cpp @@ -79,7 +79,7 @@ py_elementindex(PyObject *self, PyObject *args) { int ph; char* nm; if (!PyArg_ParseTuple(args, "is:py_elementindex", &ph, &nm)) return NULL; - int k = phase_elementIndex(ph,nm); + size_t k = phase_elementIndex(ph,nm); return Py_BuildValue("i",k); } @@ -88,7 +88,7 @@ py_speciesindex(PyObject *self, PyObject *args) { int ph; char* nm; if (!PyArg_ParseTuple(args, "is:py_speciesindex", &ph, &nm)) return NULL; - int k = phase_speciesIndex(ph,nm); + size_t k = phase_speciesIndex(ph,nm); return Py_BuildValue("i",k); } @@ -127,13 +127,14 @@ phase_getarray(PyObject *self, PyObject *args) double* xd = 0; if (job > 10) { - int nsp = phase_nSpecies(ph); + size_t nsp = phase_nSpecies(ph); #ifdef HAS_NUMPY npy_intp nnn = nsp; x = (PyArrayObject*)PyArray_SimpleNew(1, &nnn, PyArray_DOUBLE); Py_INCREF(x); #else - x = (PyArrayObject*)PyArray_FromDims(1, &nsp, PyArray_DOUBLE); + int nnn = int(nsp); + x = (PyArrayObject*)PyArray_FromDims(1, &nnn, PyArray_DOUBLE); #endif xd = (double*)x->data; switch (job) { @@ -152,12 +153,13 @@ phase_getarray(PyObject *self, PyObject *args) } else { - int nel = phase_nElements(ph); + size_t nel = phase_nElements(ph); #ifdef HAS_NUMPY npy_intp nnn = nel; x = (PyArrayObject*)PyArray_SimpleNew(1, &nnn, PyArray_DOUBLE); #else - x = (PyArrayObject*)PyArray_FromDims(1, &nel, PyArray_DOUBLE); + int nnn = int(nel); + x = (PyArrayObject*)PyArray_FromDims(1, &nnn, PyArray_DOUBLE); #endif xd = (double*)x->data; switch (job) { @@ -260,7 +262,7 @@ phase_setarray(PyObject *self, PyObject *args) PyArrayObject* a = (PyArrayObject*) PyArray_ContiguousFromObject(seq, PyArray_DOUBLE, 1, 1); double* xd = (double*)a->data; - int len = a->dimensions[0]; + size_t len = a->dimensions[0]; switch (job) { case 1: iok = phase_setMoleFractions(ph, len, xd, norm); diff --git a/Cantera/python/src/ctreactor_methods.cpp b/Cantera/python/src/ctreactor_methods.cpp index 41bbcddd8..44cb368a4 100644 --- a/Cantera/python/src/ctreactor_methods.cpp +++ b/Cantera/python/src/ctreactor_methods.cpp @@ -87,7 +87,7 @@ py_reactor_nSensParams(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:reactor_nSensParams", &i)) return NULL; - _val = reactor_nSensParams(i); + _val = int(reactor_nSensParams(i)); return Py_BuildValue("i",_val); } diff --git a/Cantera/python/src/ctrpath_methods.cpp b/Cantera/python/src/ctrpath_methods.cpp index 46b318bf7..569ed7fd9 100644 --- a/Cantera/python/src/ctrpath_methods.cpp +++ b/Cantera/python/src/ctrpath_methods.cpp @@ -228,7 +228,7 @@ py_rdiag_findMajor(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "idO:rdiag_findMajor", &n, &thresh, &a)) return NULL; PyArrayObject* aa = (PyArrayObject*)a; - int lda = aa->dimensions[0]; + size_t lda = aa->dimensions[0]; double* x = (double*)aa->data; int iok = rdiag_findMajor(n, thresh, lda, x); if (iok < 0) return reportError(iok); diff --git a/Cantera/python/src/ctsurf_methods.cpp b/Cantera/python/src/ctsurf_methods.cpp index c04cf2d4a..329c00cc6 100644 --- a/Cantera/python/src/ctsurf_methods.cpp +++ b/Cantera/python/src/ctsurf_methods.cpp @@ -57,12 +57,13 @@ py_surf_getcoverages(PyObject *self, PyObject *args) PyArrayObject* cov; if (!PyArg_ParseTuple(args, "i:surf_getcoverages", &n)) return NULL; - int nsp = th_nSpecies(n); + size_t nsp = th_nSpecies(n); #ifdef HAS_NUMPY npy_intp nnsp = nsp; cov = (PyArrayObject*)PyArray_SimpleNew(1, &nnsp, PyArray_DOUBLE); #else - cov = (PyArrayObject*)PyArray_FromDims(1, &nsp, PyArray_DOUBLE); + int nnsp = int(nsp); + cov = (PyArrayObject*)PyArray_FromDims(1, &nnsp, PyArray_DOUBLE); #endif double* x = (double*)((PyArrayObject*)cov)->data; int iok = surf_getcoverages(n, x); @@ -77,12 +78,13 @@ py_surf_getconcentrations(PyObject *self, PyObject *args) PyArrayObject* c; if (!PyArg_ParseTuple(args, "i:surf_getconcentrations", &n)) return NULL; - int nsp = th_nSpecies(n); + size_t nsp = th_nSpecies(n); #ifdef HAS_NUMPY npy_intp nnsp = nsp; c = (PyArrayObject*)PyArray_SimpleNew(1, &nnsp, PyArray_DOUBLE); #else - c = (PyArrayObject*)PyArray_FromDims(1, &nsp, PyArray_DOUBLE); + int nnsp = int(nsp); + c = (PyArrayObject*)PyArray_FromDims(1, &nnsp, PyArray_DOUBLE); #endif double* x = (double*)((PyArrayObject*)c)->data; int iok = surf_getconcentrations(n, x); diff --git a/Cantera/python/src/ctthermo_methods.cpp b/Cantera/python/src/ctthermo_methods.cpp index d1a79953b..9300c7162 100644 --- a/Cantera/python/src/ctthermo_methods.cpp +++ b/Cantera/python/src/ctthermo_methods.cpp @@ -6,7 +6,7 @@ ct_newThermoFromXML(PyObject *self, PyObject *args) //char* id; if (!PyArg_ParseTuple(args, "i:ct_newThermoFromXML", &mxml)) return NULL; - int n = newThermoFromXML(mxml); + int n = int(newThermoFromXML(mxml)); if (n < 0) return reportCanteraError(); return Py_BuildValue("i",n); } @@ -187,9 +187,9 @@ thermo_getarray(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "ii:thermo_getarray", &th, &job)) return NULL; - int nsp = th_nSpecies(th); - int nel = phase_nElements(th); - int xlen = (job == 21 ? nel : nsp); + size_t nsp = th_nSpecies(th); + size_t nel = phase_nElements(th); + size_t xlen = (job == 21 ? nel : nsp); // array attributes int iok = -22; @@ -200,8 +200,9 @@ thermo_getarray(PyObject *self, PyObject *args) (PyArrayObject*)PyArray_SimpleNew(1, &nnn, PyArray_DOUBLE); Py_INCREF(x); #else + int nnn = int(xlen); PyArrayObject* x = - (PyArrayObject*)PyArray_FromDims(1, &xlen, PyArray_DOUBLE); + (PyArrayObject*)PyArray_FromDims(1, &nnn, PyArray_DOUBLE); #endif double* xd = (double*)x->data; switch (job) { diff --git a/Cantera/python/src/cttransport_methods.cpp b/Cantera/python/src/cttransport_methods.cpp index 1eb1d17db..1db414dc3 100644 --- a/Cantera/python/src/cttransport_methods.cpp +++ b/Cantera/python/src/cttransport_methods.cpp @@ -10,7 +10,7 @@ py_transport_new(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "sii:transport_new", &model, &ph, &loglevel)) return NULL; - int n = newTransport(model, ph, loglevel); + int n = int(newTransport(model, ph, loglevel)); if (n < 0) return reportError(n); return Py_BuildValue("i",n); } diff --git a/Cantera/src/base/ctml.cpp b/Cantera/src/base/ctml.cpp index bae797b6e..9753e3761 100644 --- a/Cantera/src/base/ctml.cpp +++ b/Cantera/src/base/ctml.cpp @@ -163,7 +163,7 @@ namespace ctml { * and codify that. unitsString shouldn't be here, since it's an int. * typeString should be codified as to its usage. */ - void addIntegerArray(Cantera::XML_Node& node, const std::string &title, const int n, + void addIntegerArray(Cantera::XML_Node& node, const std::string &title, const size_t n, const int* const vals, const std::string units, const std::string type, const doublereal minval, const doublereal maxval) { std::string fmt = "%8d"; @@ -178,7 +178,7 @@ namespace ctml { XML_Node& f = node.addChild("intArray",v); f.addAttribute("title",title); if (type != "") f.addAttribute("type",type); - f.addAttribute("size",n); + f.addAttribute("size", double(n)); if (units != "") f.addAttribute("units",units); if (minval != Undef) f.addAttribute("min",minval); if (maxval != Undef) f.addAttribute("max",maxval); @@ -295,12 +295,12 @@ namespace ctml { * and codify that. unitsString shouldn't be here, since it's an int. * typeString should be codified as to its usage. */ - void addFloatArray(Cantera::XML_Node& node, const std::string &title, const int n, + void addFloatArray(Cantera::XML_Node& node, const std::string &title, const size_t n, const doublereal* const vals, const std::string units, const std::string type, const doublereal minval, const doublereal maxval) { std::string fmt = "%17.9E"; - int i; + size_t i; std::string v = ""; for (i = 0; i < n; i++) { v += fp2str(vals[i],fmt); @@ -311,7 +311,7 @@ namespace ctml { XML_Node& f = node.addChild("floatArray",v); f.addAttribute("title",title); if (type != "") f.addAttribute("type",type); - f.addAttribute("size",n); + f.addAttribute("size", double(n)); if (units != "") f.addAttribute("units",units); if (minval != Undef) f.addAttribute("min",minval); if (maxval != Undef) f.addAttribute("max",maxval); diff --git a/Cantera/src/base/ctml.h b/Cantera/src/base/ctml.h index 1b22a4c09..ac2525535 100644 --- a/Cantera/src/base/ctml.h +++ b/Cantera/src/base/ctml.h @@ -210,7 +210,7 @@ namespace ctml { * typeString should be codified as to its usage. */ void addIntegerArray(Cantera::XML_Node& node, const std::string &titleString, - const int n, const int* const values, + const size_t n, const int* const values, const std::string unitsString="", const std::string typeString="", const doublereal minval=Cantera::Undef, const doublereal maxval=Cantera::Undef); @@ -268,7 +268,7 @@ namespace ctml { * typeString should be codified as to its usage. */ void addFloatArray(Cantera::XML_Node& node, const std::string &titleString, - const int n, const doublereal* const values, + const size_t n, const doublereal* const values, const std::string unitsString="", const std::string typeString="", const doublereal minval = Cantera::Undef, const doublereal maxval = Cantera::Undef); diff --git a/Cantera/src/equil/MultiPhaseEquil.h b/Cantera/src/equil/MultiPhaseEquil.h index 7dbfcbd6a..f5cabbcfe 100644 --- a/Cantera/src/equil/MultiPhaseEquil.h +++ b/Cantera/src/equil/MultiPhaseEquil.h @@ -73,7 +73,7 @@ namespace Cantera { finish(); } - index_t componentIndex(index_t n) { return m_species[m_order[n]]; } + size_t componentIndex(index_t n) { return m_species[m_order[n]]; } void reportCSV(const std::string &reportFile); diff --git a/Cantera/src/equil/vcs_rxnadj.cpp b/Cantera/src/equil/vcs_rxnadj.cpp index af79fde99..393d76e2f 100644 --- a/Cantera/src/equil/vcs_rxnadj.cpp +++ b/Cantera/src/equil/vcs_rxnadj.cpp @@ -395,7 +395,8 @@ namespace VCSnonideal { int VCS_SOLVE::vcs_rxn_adj_cg() { size_t irxn, j; size_t k = 0; - size_t kspec, soldel = 0; + size_t kspec; + int soldel = 0; double s, xx, dss; double *dnPhase_irxn; #ifdef DEBUG_MODE diff --git a/Cantera/src/equil/vcs_solve_TP.cpp b/Cantera/src/equil/vcs_solve_TP.cpp index 065d51fdd..daa119fba 100644 --- a/Cantera/src/equil/vcs_solve_TP.cpp +++ b/Cantera/src/equil/vcs_solve_TP.cpp @@ -99,7 +99,7 @@ namespace VCSnonideal { size_t iph; double dx, xx, par; size_t dofast, ll = 0, it1 = 0; - int lec, npb, iti, lnospec; + size_t lec, npb, iti, lnospec; int rangeErrorFound = 0; bool giveUpOnElemAbund = false; int finalElemAbundAttempts = 0; @@ -415,7 +415,7 @@ namespace VCSnonideal { * for the major species (do minor species in the future too) */ - soldel = vcs_RxnStepSizes(); + soldel = int(vcs_RxnStepSizes()); if (soldel == 2) { goto L_COMPONENT_CALC; diff --git a/Cantera/src/kinetics/Kinetics.h b/Cantera/src/kinetics/Kinetics.h index 43ceeb828..e9c0bda33 100644 --- a/Cantera/src/kinetics/Kinetics.h +++ b/Cantera/src/kinetics/Kinetics.h @@ -893,7 +893,7 @@ namespace Cantera { /*! * @param index input index */ - void setIndex(int index) { m_index = index; } + void setIndex(size_t index) { m_index = index; } protected: diff --git a/Cantera/src/kinetics/ReactionPath.cpp b/Cantera/src/kinetics/ReactionPath.cpp index db8dfc4cf..829278049 100644 --- a/Cantera/src/kinetics/ReactionPath.cpp +++ b/Cantera/src/kinetics/ReactionPath.cpp @@ -167,7 +167,7 @@ namespace Cantera { } } - void ReactionPathDiagram::findMajorPaths(doublereal athreshold, int lda, + void ReactionPathDiagram::findMajorPaths(doublereal athreshold, size_t lda, doublereal* a) { size_t nn = nNodes(); size_t n, m, k1, k2; diff --git a/Cantera/src/kinetics/ReactionPath.h b/Cantera/src/kinetics/ReactionPath.h index d6db9a5ba..3dc18e91c 100644 --- a/Cantera/src/kinetics/ReactionPath.h +++ b/Cantera/src/kinetics/ReactionPath.h @@ -197,7 +197,7 @@ namespace Cantera { std::vector& excluded() { return m_exclude; } std::vector species(); vector_int reactions(); - void findMajorPaths(doublereal threshold, int lda, doublereal* a); + void findMajorPaths(doublereal threshold, size_t lda, doublereal* a); void setFont(std::string font) { m_font = font; } diff --git a/Cantera/src/kinetics/RxnRates.h b/Cantera/src/kinetics/RxnRates.h index baeacea2e..9cf8057cf 100644 --- a/Cantera/src/kinetics/RxnRates.h +++ b/Cantera/src/kinetics/RxnRates.h @@ -288,7 +288,7 @@ namespace Cantera { protected: doublereal m_logA, m_b, m_E, m_A; doublereal m_acov, m_ecov, m_mcov; - vector_int m_sp, m_msp; + std::vector m_sp, m_msp; vector_fp m_ac, m_ec, m_mc; size_t m_ncov, m_nmcov; }; diff --git a/Cantera/src/numerics/ArrayViewer.h b/Cantera/src/numerics/ArrayViewer.h index 685f3736a..164bd3e48 100755 --- a/Cantera/src/numerics/ArrayViewer.h +++ b/Cantera/src/numerics/ArrayViewer.h @@ -45,41 +45,41 @@ namespace Cantera { /** * Constructor. Create an \c m by \c n array viewer for array v. */ - ArrayViewer(int m, int n, doublereal* v) + ArrayViewer(size_t m, size_t n, doublereal* v) : m_nrows(m), m_ncols(n) { data = v; } /// resize the array viewer - void resize(int n, int m) { + void resize(size_t n, size_t m) { m_nrows = n; m_ncols = m; } /// set the nth row to array rw - void setRow(int n, doublereal* rw) { - for (int j = 0; j < m_ncols; j++) { + void setRow(size_t n, doublereal* rw) { + for (size_t j = 0; j < m_ncols; j++) { data[m_nrows*j + n] = rw[j]; } } /// get the nth row - void getRow(int n, doublereal* rw) { - for (int j = 0; j < m_ncols; j++) { + void getRow(size_t n, doublereal* rw) { + for (size_t j = 0; j < m_ncols; j++) { rw[j] = data[m_nrows*j + n]; } } /// set the values in column m to those in array col - void setColumn(int m, doublereal* col) { - for (int i = 0; i < m_nrows; i++) { + void setColumn(size_t m, doublereal* col) { + for (size_t i = 0; i < m_nrows; i++) { data[m_nrows*m + i] = col[i]; } } /// get the values in column m - void getColumn(int m, doublereal* col) { - for (int i = 0; i < m_nrows; i++) { + void getColumn(size_t m, doublereal* col) { + for (size_t i = 0; i < m_nrows; i++) { col[i] = data[m_nrows*m + i]; } } @@ -87,14 +87,14 @@ namespace Cantera { /// Destructor. Does nothing. virtual ~ArrayViewer(){} - doublereal& operator()( int i, int j) {return value(i,j);} - doublereal operator() ( int i, int j) const {return value(i,j);} + doublereal& operator()(size_t i, size_t j) {return value(i,j);} + doublereal operator() (size_t i, size_t j) const {return value(i,j);} /// Return a reference to the (i,j) array element. - doublereal& value( int i, int j) {return data[m_nrows*j + i];} + doublereal& value(size_t i, size_t j) {return data[m_nrows*j + i];} /// Return the value of the (i,j) array element. - doublereal value( int i, int j) const {return data[m_nrows*j + i];} + doublereal value(size_t i, size_t j) const {return data[m_nrows*j + i];} /// Number of rows size_t nRows() const { return m_nrows; } @@ -111,14 +111,14 @@ namespace Cantera { protected: - int m_nrows, m_ncols; + size_t m_nrows, m_ncols; }; /// output the array inline std::ostream& operator<<(std::ostream& s, const ArrayViewer& m) { - int nr = static_cast(m.nRows()); - int nc = static_cast(m.nColumns()); - int i,j; + size_t nr = m.nRows(); + size_t nc = m.nColumns(); + size_t i,j; for (i = 0; i < nr; i++) { for (j = 0; j < nc; j++) { s << m(i,j) << ", "; diff --git a/Cantera/src/numerics/BandMatrix.cpp b/Cantera/src/numerics/BandMatrix.cpp index 69649fff7..bf19c99b3 100755 --- a/Cantera/src/numerics/BandMatrix.cpp +++ b/Cantera/src/numerics/BandMatrix.cpp @@ -32,7 +32,7 @@ namespace Cantera { * @param ku number of superdiagonals * @param v initial value (default = 0.0) */ - BandMatrix::BandMatrix(int n, int kl, int ku, doublereal v) + BandMatrix::BandMatrix(size_t n, size_t kl, size_t ku, doublereal v) : m_factored(false), m_n(n), m_kl(kl), m_ku(ku) { data.resize(n*(2*kl + ku + 1)); ludata.resize(n*(2*kl + ku + 1)); @@ -64,7 +64,7 @@ namespace Cantera { return *this; } - void BandMatrix::resize(int n, int kl, int ku, doublereal v) { + void BandMatrix::resize(size_t n, size_t kl, size_t ku, doublereal v) { m_n = n; m_kl = kl; m_ku = ku; @@ -81,8 +81,8 @@ namespace Cantera { * Multiply A*b and write result to \c prod. */ void BandMatrix::mult(const double* b, double* prod) const { - int nr = rows(); - int m, j; + size_t nr = rows(); + size_t m, j; double sum = 0.0; for (m = 0; m < nr; m++) { sum = 0.0; @@ -99,8 +99,8 @@ namespace Cantera { * Multiply b*A and write result to \c prod. */ void BandMatrix::leftMult(const double* b, double* prod) const { - int nc = columns(); - int n, i; + size_t nc = columns(); + size_t n, i; double sum = 0.0; for (n = 0; n < nc; n++) { sum = 0.0; @@ -138,12 +138,12 @@ namespace Cantera { - int BandMatrix::solve(int n, const doublereal* b, doublereal* x) { + int BandMatrix::solve(size_t n, const doublereal* b, doublereal* x) { copy(b, b+n, x); return solve(n, x); } - int BandMatrix::solve(int n, doublereal* b) { + int BandMatrix::solve(size_t n, doublereal* b) { int info = 0; if (!m_factored) info = factor(); if (info == 0) @@ -161,9 +161,9 @@ namespace Cantera { } ostream& operator<<(ostream& s, const BandMatrix& m) { - int nr = m.rows(); - int nc = m.columns(); - int i,j; + size_t nr = m.rows(); + size_t nc = m.columns(); + size_t i,j; for (i = 0; i < nr; i++) { for (j = 0; j < nc; j++) { s << m(i,j) << ", "; diff --git a/Cantera/src/numerics/BandMatrix.h b/Cantera/src/numerics/BandMatrix.h index ec27dcbb1..5e4c749e9 100755 --- a/Cantera/src/numerics/BandMatrix.h +++ b/Cantera/src/numerics/BandMatrix.h @@ -24,7 +24,7 @@ namespace Cantera { public: BandMatrix(); - BandMatrix(int n, int kl, int ku, doublereal v = 0.0); + BandMatrix(size_t n, size_t kl, size_t ku, doublereal v = 0.0); /// copy constructor BandMatrix(const BandMatrix& y); @@ -35,27 +35,27 @@ namespace Cantera { /// assignment. BandMatrix& operator=(const BandMatrix& y); - void resize(int n, int kl, int ku, doublereal v = 0.0); + void resize(size_t n, size_t kl, size_t ku, doublereal v = 0.0); void bfill(doublereal v) { std::fill(data.begin(), data.end(), v); m_factored = false; } - doublereal& operator()( int i, int j) { + doublereal& operator()(size_t i, size_t j) { return value(i,j); } - doublereal operator() ( int i, int j) const { + doublereal operator() (size_t i, size_t j) const { return value(i,j); } /// Return a reference to element (i,j). Since this method may /// alter the element value, it may need to be refactored, so /// the flag m_factored is set to false. - doublereal& value( int i, int j) { + doublereal& value(size_t i, size_t j) { m_factored = false; - if (i < j - m_ku || i > j + m_kl) { + if (i + m_ku < j || i > j + m_kl) { m_zero = 0.0; return m_zero; } @@ -64,15 +64,15 @@ namespace Cantera { /// Return the value of element (i,j). This method does not /// alter the array. - doublereal value( int i, int j) const { - if (i < j - m_ku || i > j + m_kl) return 0.0; + doublereal value(size_t i, size_t j) const { + if (i + m_ku < j || i > j + m_kl) return 0.0; return data[index(i,j)]; } /// Return the location in the internal 1D array corresponding to /// the (i,j) element in the banded array. - int index(int i, int j) const { - int rw = m_kl + m_ku + i - j; + size_t index(size_t i, size_t j) const { + size_t rw = m_kl + m_ku + i - j; return (2*m_kl + m_ku + 1)*j + rw; } @@ -80,27 +80,27 @@ namespace Cantera { /// bandwidth. For efficiency, this method does not check that /// (i,j) are within the bandwidth; it is up to the calling /// program to insure that this is true. - doublereal _value(int i, int j) const { + doublereal _value(size_t i, size_t j) const { return data[index(i,j)]; } /// Number of rows - int nRows() const { return m_n; } + size_t nRows() const { return m_n; } /// @deprecated Redundant. - int rows() const { return m_n; } + size_t rows() const { return m_n; } /// Number of columns - int nColumns() const { return m_n; } + size_t nColumns() const { return m_n; } /// @deprecated Redundant. - int columns() const { return m_n; } + size_t columns() const { return m_n; } /// Number of subdiagonals - int nSubDiagonals() const { return m_kl; } + size_t nSubDiagonals() const { return m_kl; } /// Number of superdiagonals - int nSuperDiagonals() const { return m_ku; } + size_t nSuperDiagonals() const { return m_ku; } - int ldim() const { return 2*m_kl + m_ku + 1; } + size_t ldim() const { return 2*m_kl + m_ku + 1; } vector_int& ipiv() { return m_ipiv; } /// Multiply A*b and write result to prod. @@ -113,8 +113,8 @@ namespace Cantera { //void solve(const vector_fp& b, vector_fp& x); - int solve(int n, const doublereal* b, doublereal* x); - int solve(int n, doublereal* b); + int solve(size_t n, const doublereal* b, doublereal* x); + int solve(size_t n, doublereal* b); vector_fp::iterator begin() { m_factored = false; @@ -133,7 +133,7 @@ namespace Cantera { bool m_factored; - int m_n, m_kl, m_ku; + size_t m_n, m_kl, m_ku; doublereal m_zero; vector_int m_ipiv; diff --git a/Cantera/src/numerics/CVodeInt.cpp b/Cantera/src/numerics/CVodeInt.cpp index 5204307fd..31291ef10 100644 --- a/Cantera/src/numerics/CVodeInt.cpp +++ b/Cantera/src/numerics/CVodeInt.cpp @@ -117,15 +117,15 @@ namespace Cantera { delete[] m_iopt; } - double& CVodeInt::solution(int k){ return N_VIth(nv(m_y),k); } + double& CVodeInt::solution(size_t k){ return N_VIth(nv(m_y), int(k)); } double* CVodeInt::solution(){ return N_VDATA(nv(m_y)); } - void CVodeInt::setTolerances(double reltol, int n, double* abstol) { + void CVodeInt::setTolerances(double reltol, size_t n, double* abstol) { m_itol = 1; - m_nabs = n; - if (n != m_neq) { + m_nabs = int(n); + if (m_nabs != m_neq) { if (m_abstol) N_VFree(nv(m_abstol)); - m_abstol = reinterpret_cast(N_VNew(n, 0)); + m_abstol = reinterpret_cast(N_VNew(m_nabs, 0)); } for (int i=0; i= 0) { copy(rtol, rtol + m_nv, m_rtol_ss.begin()); copy(atol, atol + m_nv, m_atol_ss.begin()); @@ -27,7 +27,7 @@ namespace Cantera { } void Domain1D:: - setTolerances(int n, doublereal rtol, doublereal atol, int ts) { + setTolerances(size_t n, doublereal rtol, doublereal atol, int ts) { if (ts >= 0) { m_rtol_ss[n] = rtol; m_atol_ss[n] = atol; @@ -69,28 +69,28 @@ namespace Cantera { } void Domain1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* mask, doublereal rdt) { - if (jg >=0 && (jg < firstPoint() - 1 || jg > lastPoint() + 1)) return; + if (jg != -1 && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; // if evaluating a Jacobian, compute the steady-state residual - if (jg >= 0) rdt = 0.0; + if (jg != -1) rdt = 0.0; // start of local part of global arrays doublereal* x = xg + loc(); doublereal* rsd = rg + loc(); integer* diag = mask + loc(); - int jmin, jmax, jpt, j, i; + size_t jmin, jmax, jpt, j, i; jpt = jg - firstPoint(); - if (jg < 0) { // evaluate all points + if (jg == -1) { // evaluate all points jmin = 0; jmax = m_points - 1; } else { // evaluate points for Jacobian - jmin = std::max(jpt-1, 0); + jmin = std::max(jpt-1, 0); jmax = std::min(jpt+1,m_points-1); } @@ -113,11 +113,10 @@ namespace Cantera { // called to set up initial grid, and after grid refinement - void Domain1D::setupGrid(int n, const doublereal* z) { + void Domain1D::setupGrid(size_t n, const doublereal* z) { if (n > 1) { resize(m_nv, n); - int j; - for (j = 0; j < m_points; j++) m_z[j] = z[j]; + for (size_t j = 0; j < m_points; j++) m_z[j] = z[j]; } } @@ -132,8 +131,8 @@ namespace Cantera { * Print the solution. */ void Domain1D::showSolution(const doublereal* x) { - int nn = m_nv/5; - int i, j, n; + size_t nn = m_nv/5; + size_t i, j, n; //char* buf = new char[100]; char buf[100]; doublereal v; @@ -157,7 +156,7 @@ namespace Cantera { } writelog("\n"); } - int nrem = m_nv - 5*nn; + size_t nrem = m_nv - 5*nn; drawline(); sprintf(buf, "\n z "); writelog(buf); @@ -181,14 +180,14 @@ namespace Cantera { // initial solution void Domain1D::_getInitialSoln(doublereal* x) { - for (int j = 0; j < m_points; j++) { - for (int n = 0; n < m_nv; n++) { + for (size_t j = 0; j < m_points; j++) { + for (size_t n = 0; n < m_nv; n++) { x[index(n,j)] = initialValue(n,j); } } } - doublereal Domain1D::initialValue(int n, int j) { + doublereal Domain1D::initialValue(size_t n, size_t j) { throw CanteraError("Domain1D::initialValue", "base class method called!"); return 0.0; diff --git a/Cantera/src/oneD/Domain1D.h b/Cantera/src/oneD/Domain1D.h index 374129616..8ca0aca87 100644 --- a/Cantera/src/oneD/Domain1D.h +++ b/Cantera/src/oneD/Domain1D.h @@ -43,7 +43,7 @@ namespace Cantera { * @param nv Number of variables at each grid point. * @param points Number of grid points. */ - Domain1D(int nv=1, int points=1, + Domain1D(size_t nv=1, size_t points=1, doublereal time = 0.0) : m_rdt(0.0), m_time(time), @@ -68,7 +68,7 @@ namespace Cantera { /** * The left-to-right location of this domain. */ - const int domainIndex() { return m_index; } + const size_t domainIndex() { return m_index; } /** * True if the domain is a connector domain. @@ -84,7 +84,7 @@ namespace Cantera { * Specify the container object for this domain, and the * position of this domain in the list. */ - void setContainer(OneDim* c, int index){ + void setContainer(OneDim* c, size_t index){ m_container = c; m_index = index; } @@ -113,7 +113,7 @@ namespace Cantera { * method setBandwidth to specify the bandwidth before passing * this domain to the Sim1D or OneDim constructor. */ - int bandwidth() { return m_bw; } + size_t bandwidth() { return m_bw; } /** * Initialize. This method is called by OneDim::init() for @@ -130,7 +130,7 @@ namespace Cantera { * This method is virtual so that subclasses can perform other * actions required to resize the domain. */ - virtual void resize(int nv, int np) { + virtual void resize(size_t nv, size_t np) { // if the number of components is being changed, then a // new grid refiner is required. if (nv != m_nv || !m_refiner) { @@ -157,29 +157,29 @@ namespace Cantera { Refiner& refiner() { return *m_refiner; } /// Number of components at each grid point. - int nComponents() const { return m_nv; } + size_t nComponents() const { return m_nv; } /// Number of grid points in this domain. - int nPoints() const { return m_points; } + size_t nPoints() const { return m_points; } /// Name of the nth component. May be overloaded. - virtual std::string componentName(int n) const { + virtual std::string componentName(size_t n) const { if (m_name[n] != "") return m_name[n]; - else return "component " + int2str(n); + else return "component " + int2str(int(n)); } - void setComponentName(int n, std::string name) { + void setComponentName(size_t n, std::string name) { m_name[n] = name; } - void setComponentType(int n, int ctype) { + void setComponentType(size_t n, int ctype) { if (ctype == 0) setAlgebraic(n); } /// index of component with name \a name. - int componentIndex(std::string name) const { - int nc = nComponents(); - for (int n = 0; n < nc; n++) { + size_t componentIndex(std::string name) const { + size_t nc = nComponents(); + for (size_t n = 0; n < nc; n++) { if (name == componentName(n)) return n; } throw CanteraError("Domain1D::componentIndex", @@ -189,27 +189,27 @@ namespace Cantera { /** * Set the lower and upper bounds for each solution component. */ - void setBounds(int nl, const doublereal* lower, - int nu, const doublereal* upper) { + void setBounds(size_t nl, const doublereal* lower, + size_t nu, const doublereal* upper) { if (nl < m_nv || nu < m_nv) throw CanteraError("Domain1D::setBounds", "wrong array size for solution bounds. " - "Size should be at least "+int2str(m_nv)); + "Size should be at least "+int2str(int(m_nv))); std::copy(upper, upper + m_nv, m_max.begin()); std::copy(lower, lower + m_nv, m_min.begin()); } - void setBounds(int n, doublereal lower, doublereal upper) { + void setBounds(size_t n, doublereal lower, doublereal upper) { m_min[n] = lower; m_max[n] = upper; } /// set the error tolerances for all solution components. - void setTolerances(int nr, const doublereal* rtol, - int na, const doublereal* atol, int ts = 0); + void setTolerances(size_t nr, const doublereal* rtol, + size_t na, const doublereal* atol, int ts = 0); /// set the error tolerances for solution component \a n. - void setTolerances(int n, doublereal rtol, doublereal atol, int ts = 0); + void setTolerances(size_t n, doublereal rtol, doublereal atol, int ts = 0); //added by Karl Meredith /// set scalar error tolerances. All solution components will @@ -223,16 +223,16 @@ namespace Cantera { void setTolerancesSS(doublereal rtol, doublereal atol); /// Relative tolerance of the nth component. - doublereal rtol(int n) { return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]); } + doublereal rtol(size_t n) { return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]); } /// Absolute tolerance of the nth component. - doublereal atol(int n) { return (m_rdt == 0.0 ? m_atol_ss[n] : m_atol_ts[n]); } + doublereal atol(size_t n) { return (m_rdt == 0.0 ? m_atol_ss[n] : m_atol_ts[n]); } /// Upper bound on the nth component. - doublereal upperBound(int n) const { return m_max[n]; } + doublereal upperBound(size_t n) const { return m_max[n]; } /// Lower bound on the nth component - doublereal lowerBound(int n) const { return m_min[n]; } + doublereal lowerBound(size_t n) const { return m_min[n]; } /** @@ -280,15 +280,15 @@ namespace Cantera { * @param x Soln vector. This is the input. * @param r residual this is the output. */ - virtual void eval(int j, doublereal* x, doublereal* r, + virtual void eval(size_t j, doublereal* x, doublereal* r, integer* mask, doublereal rdt=0.0); - virtual doublereal residual(doublereal* x, int n, int j) { + virtual doublereal residual(doublereal* x, size_t n, size_t j) { throw CanteraError("Domain1D::residual","residual function must be overloaded in derived class "+id()); } - int timeDerivativeFlag(int n) { return m_td[n];} - void setAlgebraic(int n) { m_td[n] = 0; } + int timeDerivativeFlag(size_t n) { return m_td[n];} + void setAlgebraic(size_t n) { m_td[n] = 0; } /** * Does nothing. @@ -297,8 +297,8 @@ namespace Cantera { doublereal time() const { return m_time;} void incrementTime(doublereal dt) { m_time += dt; } - size_t index(int n, int j) const { return m_nv*j + n; } - doublereal value(const doublereal* x, int n, int j) const { + size_t index(size_t n, size_t j) const { return m_nv*j + n; } + doublereal value(const doublereal* x, size_t n, size_t j) const { return x[index(n,j)]; } @@ -307,7 +307,7 @@ namespace Cantera { throw CanteraError("Domain1D::save","base class method called"); } - int size() const { return m_nv*m_points; } + size_t size() const { return m_nv*m_points; } /** * Find the index of the first grid point in this domain, and @@ -337,19 +337,19 @@ namespace Cantera { * Location of the start of the local solution vector in the global * solution vector, */ - virtual int loc(int j = 0) const { return m_iloc; } + virtual size_t loc(size_t j = 0) const { return m_iloc; } /** * The index of the first (i.e., left-most) grid point * belonging to this domain. */ - int firstPoint() const { return m_jstart; } + size_t firstPoint() const { return m_jstart; } /** * The index of the last (i.e., right-most) grid point * belonging to this domain. */ - int lastPoint() const { return m_jstart + m_points - 1; } + size_t lastPoint() const { return m_jstart + m_points - 1; } /** * Set the left neighbor to domain 'left.' Method 'locate' is @@ -387,7 +387,7 @@ namespace Cantera { /** * Value of component n at point j in the previous solution. */ - double prevSoln(int n, int j) const { + double prevSoln(size_t n, size_t j) const { return m_slast[m_nv*j + n]; } @@ -398,7 +398,7 @@ namespace Cantera { std::string id() { if (m_id != "") return m_id; - else return std::string("domain ") + int2str(m_index); + else return std::string("domain ") + int2str(int(m_index)); } /** @@ -414,7 +414,7 @@ namespace Cantera { virtual void restore(const XML_Node& dom, doublereal* soln) {} - doublereal z(int jlocal) const { + doublereal z(size_t jlocal) const { return m_z[jlocal]; } doublereal zmin() const { return m_z[0]; } @@ -437,11 +437,11 @@ namespace Cantera { vector_fp& grid() { return m_z; } const vector_fp& grid() const { return m_z; } - doublereal grid(int point) { return m_z[point]; } + doublereal grid(size_t point) { return m_z[point]; } - virtual void setupGrid(int n, const doublereal* z); + virtual void setupGrid(size_t n, const doublereal* z); - void setGrid(int n, const doublereal* z); + void setGrid(size_t n, const doublereal* z); /** * Writes some or all initial solution values into the global @@ -456,7 +456,7 @@ namespace Cantera { /** * Initial value of solution component \a n at grid point \a j. */ - virtual doublereal initialValue(int n, int j); + virtual doublereal initialValue(size_t n, size_t j); /** * In some cases, a domain may need to set parameters that @@ -479,8 +479,8 @@ namespace Cantera { protected: doublereal m_rdt; - int m_nv; - int m_points; + size_t m_nv; + size_t m_points; vector_fp m_slast; doublereal m_time; vector_fp m_max; @@ -489,7 +489,7 @@ namespace Cantera { vector_fp m_atol_ss, m_atol_ts; vector_fp m_z; OneDim* m_container; - int m_index; + size_t m_index; int m_type; //! Starting location within the solution vector for unknowns @@ -498,9 +498,9 @@ namespace Cantera { * Remember there may be multiple domains associated with * this problem */ - int m_iloc; + size_t m_iloc; - int m_jstart; + size_t m_jstart; Domain1D *m_left, *m_right; std::string m_id, m_desc; diff --git a/Cantera/src/oneD/Inlet1D.h b/Cantera/src/oneD/Inlet1D.h index 4366ff409..f001f6e0f 100644 --- a/Cantera/src/oneD/Inlet1D.h +++ b/Cantera/src/oneD/Inlet1D.h @@ -73,15 +73,15 @@ namespace Cantera { protected: - void _init(int n); + void _init(size_t n); StFlow *m_flow_left, *m_flow_right; - int m_ilr, m_left_nv, m_right_nv; - int m_left_loc, m_right_loc; - int m_left_points; - int m_nv, m_left_nsp, m_right_nsp; - int m_sp_left, m_sp_right; - int m_start_left, m_start_right; + size_t m_ilr, m_left_nv, m_right_nv; + size_t m_left_loc, m_right_loc; + size_t m_left_points; + size_t m_nv, m_left_nsp, m_right_nsp; + size_t m_sp_left, m_sp_right; + size_t m_start_left, m_start_right; ThermoPhase *m_phase_left, *m_phase_right; doublereal m_temp, m_mdot; @@ -154,7 +154,7 @@ namespace Cantera { virtual doublereal massFraction(int k) {return m_yin[k];} virtual std::string componentName(int n) const; virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); virtual void restore(const XML_Node& dom, doublereal* soln); @@ -163,7 +163,7 @@ namespace Cantera { int m_ilr; doublereal m_V0; - int m_nsp; + size_t m_nsp; vector_fp m_yin; std::string m_xstr; StFlow *m_flow; @@ -187,7 +187,7 @@ namespace Cantera { virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); @@ -218,7 +218,7 @@ namespace Cantera { virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); @@ -250,7 +250,7 @@ namespace Cantera { virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); @@ -298,14 +298,14 @@ namespace Cantera { virtual doublereal massFraction(int k) {return m_yres[k];} virtual std::string componentName(int n) const; virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); virtual void restore(const XML_Node& dom, doublereal* soln); protected: - int m_nsp; + size_t m_nsp; vector_fp m_yres; std::string m_xstr; StFlow *m_flow; @@ -331,7 +331,7 @@ namespace Cantera { virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); @@ -391,7 +391,7 @@ namespace Cantera { virtual void init(); - virtual void eval(int jg, doublereal* xg, doublereal* rg, + virtual void eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt); virtual void save(XML_Node& o, doublereal* soln); @@ -424,7 +424,7 @@ namespace Cantera { InterfaceKinetics* m_kin; SurfPhase* m_sphase; - int m_surfindex, m_nsp; + size_t m_surfindex, m_nsp; bool m_enabled; vector_fp m_work; vector_fp m_fixed_cov; diff --git a/Cantera/src/oneD/MultiJac.cpp b/Cantera/src/oneD/MultiJac.cpp index d99cec7b1..94d231a02 100644 --- a/Cantera/src/oneD/MultiJac.cpp +++ b/Cantera/src/oneD/MultiJac.cpp @@ -55,7 +55,7 @@ namespace Cantera { clock_t t0 = clock(); bfill(0.0); - int n, m, ipt=0, i, j, nv, mv, iloc; + size_t n, m, ipt=0, i, j, nv, mv, iloc; doublereal rdx, dx, xsave; for (j = 0; j < m_points; j++) { @@ -74,7 +74,7 @@ namespace Cantera { // compute nth column of Jacobian for (i = j - 1; i <= j+1; i++) { - if (i >= 0 && i < m_points) { + if (i != -1 && 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/MultiJac.h b/Cantera/src/oneD/MultiJac.h index 2041cc93d..135efc393 100644 --- a/Cantera/src/oneD/MultiJac.h +++ b/Cantera/src/oneD/MultiJac.h @@ -87,8 +87,8 @@ namespace Cantera { vector_int m_mask; int m_nevals; int m_age; - int m_size; - int m_points; + size_t m_size; + size_t m_points; }; } diff --git a/Cantera/src/oneD/MultiNewton.cpp b/Cantera/src/oneD/MultiNewton.cpp index a321d4006..eac3834d7 100644 --- a/Cantera/src/oneD/MultiNewton.cpp +++ b/Cantera/src/oneD/MultiNewton.cpp @@ -61,9 +61,7 @@ namespace Cantera { } MultiNewton::~MultiNewton() { - int n = static_cast(m_workarrays.size()); - int i; - for (i = 0; i < n; i++) { + for (size_t i = 0; i < m_workarrays.size(); i++) { delete[] m_workarrays[i]; } } @@ -71,11 +69,9 @@ namespace Cantera { /** * Prepare for a new solution vector length. */ - void MultiNewton::resize(int sz) { + void MultiNewton::resize(size_t sz) { m_n = sz; - int n = static_cast(m_workarrays.size()); - int i; - for (i = 0; i < n; i++) { + for (size_t i = 0; i < m_workarrays.size(); i++) { delete[] m_workarrays[i]; } m_workarrays.clear(); @@ -88,9 +84,8 @@ namespace Cantera { doublereal MultiNewton::norm2(const doublereal* x, const doublereal* step, OneDim& r) const { doublereal f, sum = 0.0;//, fmx = 0.0; - int n; - int nd = r.nDomains(); - for (n = 0; n < nd; n++) { + size_t nd = r.nDomains(); + for (size_t n = 0; n < nd; n++) { f = norm_square(x + r.start(n), step + r.start(n), r.domain(n)); sum += f; @@ -106,18 +101,18 @@ namespace Cantera { */ void MultiNewton::step(doublereal* x, doublereal* step, OneDim& r, MultiJac& jac, int loglevel) { - int n, iok; - int sz = r.size(); + int iok; + size_t sz = r.size(); r.eval(-1, x, step); #undef DEBUG_STEP #ifdef DEBUG_STEP vector_fp ssave(sz, 0.0); - for (n = 0; n < sz; n++) { + for (size_t n = 0; n < sz; n++) { step[n] = -step[n]; ssave[n] = step[n]; } #else - for (n = 0; n < sz; n++) { + for (size_t n = 0; n < sz; n++) { step[n] = -step[n]; } #endif @@ -127,28 +122,29 @@ namespace Cantera { // if iok is non-zero, then solve failed if (iok > 0) { iok--; - int nd = r.nDomains(); - for (n = nd-1; n >= 0; n--) + size_t nd = r.nDomains(); + size_t n; + for (n = nd-1; n != -1; n--) if (iok >= r.start(n)) { break; } Domain1D& dom = r.domain(n); - int offset = iok - r.start(n); - int pt = offset/dom.nComponents(); - int comp = offset - pt*dom.nComponents(); + size_t offset = iok - r.start(n); + size_t pt = offset/dom.nComponents(); + size_t comp = offset - pt*dom.nComponents(); throw CanteraError("MultiNewton::step", "Jacobian is singular for domain "+ dom.id() + ", component " +dom.componentName(comp)+" at point " - +int2str(pt)+"\n(Matrix row "+int2str(iok)+") \nsee file bandmatrix.csv\n"); + +int2str(int(pt))+"\n(Matrix row "+int2str(iok)+") \nsee file bandmatrix.csv\n"); } else if (iok < 0) throw CanteraError("MultiNewton::step", - "iok = "+int2str(iok)); + "iok = "+int2str(int(iok))); #ifdef DEBUG_STEP bool ok = false; Domain1D* d; if (!ok) { - for (n = 0; n < sz; n++) { + for (size_t n = 0; n < sz; n++) { d = r.pointDomain(n); int nvd = d->nComponents(); int pt = (n - d->loc())/nvd; @@ -168,11 +164,8 @@ namespace Cantera { */ doublereal MultiNewton::boundStep(const doublereal* x0, const doublereal* step0, const OneDim& r, int loglevel) { - - int i; doublereal fbound = 1.0; - int nd = r.nDomains(); - for (i = 0; i < nd; i++) { + for (size_t i = 0; i < r.nDomains(); i++) { fbound = fminn(fbound, bound_step(x0 + r.start(i), step0 + r.start(i), r.domain(i), loglevel)); diff --git a/Cantera/src/oneD/MultiNewton.h b/Cantera/src/oneD/MultiNewton.h index afd339f50..afa4157bb 100644 --- a/Cantera/src/oneD/MultiNewton.h +++ b/Cantera/src/oneD/MultiNewton.h @@ -24,7 +24,7 @@ namespace Cantera { MultiNewton(int sz); virtual ~MultiNewton(); - int size() { return m_n; } + size_t size() { return m_n; } /// Compute undamped step void step(doublereal* x, doublereal* step, @@ -48,7 +48,7 @@ namespace Cantera { void setOptions(int maxJacAge = 5) {m_maxAge = maxJacAge;} /// Change the problem size. - void resize(int points); + void resize(size_t points); protected: @@ -57,7 +57,7 @@ namespace Cantera { void releaseWorkArray(doublereal* work); std::vector m_workarrays; int m_maxAge; - int m_nv, m_np, m_n; + size_t m_nv, m_np, m_n; doublereal m_elapsed; private: diff --git a/Cantera/src/oneD/OneDim.cpp b/Cantera/src/oneD/OneDim.cpp index 728e02d0f..e72553fcd 100644 --- a/Cantera/src/oneD/OneDim.cpp +++ b/Cantera/src/oneD/OneDim.cpp @@ -100,8 +100,7 @@ namespace Cantera { char buf[100]; sprintf(buf,"\nStatistics:\n\n Grid Functions Time Jacobians Time \n"); writelog(buf); - int n = m_gridpts.size(); - for (int i = 0; i < n; i++) { + for (size_t i = 0; i < m_gridpts.size(); i++) { sprintf(buf,"%5i %5i %9.4f %5i %9.4f \n", m_gridpts[i], m_funcEvals[i], m_funcElapsed[i], m_jacEvals[i], m_jacElapsed[i]); @@ -142,20 +141,19 @@ namespace Cantera { * Call after one or more grids has been refined. */ void OneDim::resize() { - int i; m_bw = 0; - vector_int nvars, loc; - int lc = 0; + std::vector nvars, loc; + size_t lc = 0; // save the statistics for the last grid saveStats(); m_pts = 0; - for (i = 0; i < m_nd; i++) { + for (size_t i = 0; i < m_nd; i++) { Domain1D* d = m_dom[i]; - int np = d->nPoints(); - int nv = d->nComponents(); - for (int n = 0; n < np; n++) { + size_t np = d->nPoints(); + size_t nv = d->nComponents(); + for (size_t n = 0; n < np; n++) { nvars.push_back(nv); loc.push_back(lc); lc += nv; @@ -163,18 +161,18 @@ namespace Cantera { } // update the Jacobian bandwidth - int bw1, bw2 = 0; + size_t bw1, bw2 = 0; // bandwidth of the local block bw1 = d->bandwidth(); - if (bw1 < 0) + if (bw1 == -1) 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 < 0) + if (bw2 == -1) bw2 = m_dom[i-1]->nComponents(); bw2 += d->nComponents() - 1; } @@ -194,7 +192,7 @@ namespace Cantera { m_jac = new MultiJac(*this); m_jac_ok = false; - for (i = 0; i < m_nd; i++) + for (size_t i = 0; i < m_nd; i++) m_dom[i]->setJac(m_jac); } @@ -242,7 +240,7 @@ namespace Cantera { * Evaluate the multi-domain residual function, and return the * result in array r. */ - void OneDim::eval(int j, double* x, double* r, doublereal rdt, int count) { + void OneDim::eval(size_t j, double* x, double* r, doublereal rdt, int count) { clock_t t0 = clock(); fill(r, r + m_size, 0.0); fill(m_mask.begin(), m_mask.end(), 0); @@ -459,11 +457,10 @@ namespace Cantera { } - void Domain1D::setGrid(int n, const doublereal* z) { + void Domain1D::setGrid(size_t n, const doublereal* z) { m_z.resize(n); m_points = n; - int j; - for (j = 0; j < m_points; j++) m_z[j] = z[j]; + for (size_t j = 0; j < m_points; j++) m_z[j] = z[j]; } } diff --git a/Cantera/src/oneD/OneDim.h b/Cantera/src/oneD/OneDim.h index 3dfac1b15..756733dae 100644 --- a/Cantera/src/oneD/OneDim.h +++ b/Cantera/src/oneD/OneDim.h @@ -47,18 +47,18 @@ namespace Cantera { int solve(doublereal* x0, doublereal* x1, int loglevel); /// Number of domains. - int nDomains() const { return m_nd; } + size_t nDomains() const { return m_nd; } /// Return a reference to domain i. - Domain1D& domain(int i) const { return *m_dom[i]; } + Domain1D& domain(size_t i) const { return *m_dom[i]; } int domainIndex(std::string name); /// The index of the start of domain i in the solution vector. - int start(int i) const { return m_dom[i]->loc(); } + size_t start(size_t i) const { return m_dom[i]->loc(); } /// Total solution vector length; - int size() const { return m_size; } + size_t size() const { return m_size; } /// Pointer to left-most domain (first added). Domain1D* left() { return m_dom[0]; } @@ -67,22 +67,22 @@ namespace Cantera { Domain1D* right() { return m_dom.back(); } /// Number of solution components at global point jg. - int nVars(int jg) { return m_nvars[jg]; } + size_t nVars(size_t jg) { return m_nvars[jg]; } /** * Location in the solution vector of the first component of * global point jg. */ - int loc(int jg) { return m_loc[jg]; } + size_t loc(size_t jg) { return m_loc[jg]; } /// Jacobian bandwidth. - int bandwidth() const { return m_bw; } + size_t bandwidth() const { return m_bw; } /// Initialize. void init(); /// Total number of points. - int points() { return m_pts; } + size_t points() { return m_pts; } /** * Steady-state max norm of the residual evaluated using solution x. @@ -121,7 +121,7 @@ namespace Cantera { * the default value is used. * @param count Set to zero to omit this call from the statistics */ - void eval(int j, double* x, double* r, doublereal rdt=-1.0, + void eval(size_t j, double* x, double* r, doublereal rdt=-1.0, int count = 1); /// Pointer to the domain global point i belongs to. @@ -167,17 +167,17 @@ namespace Cantera { MultiNewton* m_newt; // Newton iterator doublereal m_rdt; // reciprocal of time step bool m_jac_ok; // if true, Jacobian is current - int m_nd; // number of domains - int m_bw; // Jacobian bandwidth - int m_size; // solution vector size + size_t m_nd; // number of domains + size_t m_bw; // Jacobian bandwidth + size_t m_size; // solution vector size std::vector m_dom, m_connect, m_bulk; bool m_init; - vector_int m_nvars; - vector_int m_loc; + std::vector m_nvars; + std::vector m_loc; vector_int m_mask; - int m_pts; + size_t m_pts; doublereal m_solve_time; // options @@ -188,7 +188,7 @@ namespace Cantera { // statistics int m_nevals; doublereal m_evaltime; - vector_int m_gridpts; + std::vector m_gridpts; vector_int m_jacEvals; vector_fp m_jacElapsed; vector_int m_funcEvals; diff --git a/Cantera/src/oneD/Sim1D.cpp b/Cantera/src/oneD/Sim1D.cpp index 01355ede1..7c28bf55d 100644 --- a/Cantera/src/oneD/Sim1D.cpp +++ b/Cantera/src/oneD/Sim1D.cpp @@ -48,10 +48,10 @@ namespace Cantera { // added by Karl Meredith void Sim1D::setInitialGuess(string component, vector_fp& locs, vector_fp& vals){ - for (int dom=0;dom(iloc)] = value; + m_x[iloc] = value; } @@ -80,7 +80,7 @@ namespace Cantera { * @param localPoint grid point within the domain, beginning with 0 for * the leftmost grid point in the domain. */ - doublereal Sim1D::value(int dom, int comp, int localPoint) const { + doublereal Sim1D::value(size_t dom, size_t comp, size_t localPoint) const { size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint); #ifdef DEBUG_MODE int j = static_cast(iloc); @@ -89,15 +89,15 @@ namespace Cantera { } if (j >= (int) m_x.size()) { throw CanteraError("Sim1D::value", "exceeded top of bounds: " + int2str(j) + - " >= " + int2str(m_x.size())); + " >= " + int2str(int(m_x.size()))); } #endif - return m_x[static_cast(iloc)]; + return m_x[iloc]; } - doublereal Sim1D::workValue(int dom, int comp, int localPoint) const { + doublereal Sim1D::workValue(size_t dom, size_t comp, size_t localPoint) const { size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint); - return m_xnew[static_cast(iloc)]; + return m_xnew[iloc]; } @@ -115,16 +115,14 @@ namespace Cantera { * linearly interpolated based on the (pos, values) * specification. */ - void Sim1D::setProfile(int dom, int comp, + void Sim1D::setProfile(size_t dom, size_t comp, const vector_fp& pos, const vector_fp& values) { Domain1D& d = domain(dom); - int np = d.nPoints(); - int n; doublereal z0 = d.zmin(); doublereal z1 = d.zmax(); doublereal zpt, frac, v; - for (n = 0; n < np; n++) { + for (size_t n = 0; n < d.nPoints(); n++) { zpt = d.z(n); frac = (zpt - z0)/(z1 - z0); v = linearInterp(frac, pos, values); @@ -157,7 +155,7 @@ namespace Cantera { } vector xd; - int sz = 0, np, nv, m; + size_t sz = 0, np, nv, m; for (m = 0; m < m_nd; m++) { XML_Node* d = f->findID(domain(m).id()); if (!d) { @@ -185,22 +183,22 @@ namespace Cantera { } - void Sim1D::setFlatProfile(int dom, int comp, doublereal v) { - int np = domain(dom).nPoints(); - int n; + void Sim1D::setFlatProfile(size_t dom, size_t comp, doublereal v) { + size_t np = domain(dom).nPoints(); + size_t n; for (n = 0; n < np; n++) { setValue(dom, comp, n, v); } } void Sim1D::showSolution(ostream& s) { - for (int n = 0; n < m_nd; n++) { + for (size_t n = 0; n < m_nd; n++) { if (domain(n).domainType() != cEmptyType) domain(n).showSolution_s(s, DATA_PTR(m_x) + start(n)); } } void Sim1D::showSolution() { - for (int n = 0; n < m_nd; n++) { + for (size_t n = 0; n < m_nd; n++) { if (domain(n).domainType() != cEmptyType) { writelog("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+domain(n).id() +" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); @@ -210,22 +208,22 @@ namespace Cantera { } void Sim1D::getInitialSoln() { - for (int n = 0; n < m_nd; n++) { + for (size_t n = 0; n < m_nd; n++) { domain(n)._getInitialSoln(DATA_PTR(m_x) + start(n)); } } void Sim1D::finalize() { - for (int n = 0; n < m_nd; n++) { + for (size_t n = 0; n < m_nd; n++) { domain(n)._finalize(DATA_PTR(m_x) + start(n)); } } - void Sim1D::setTimeStep(doublereal stepsize, int n, integer* tsteps) { + void Sim1D::setTimeStep(doublereal stepsize, size_t n, integer* tsteps) { m_tstep = stepsize; m_steps.resize(n); - for (int i = 0; i < n; i++) m_steps[i] = tsteps[i]; + for (size_t i = 0; i < n; i++) m_steps[i] = tsteps[i]; } @@ -270,8 +268,8 @@ namespace Cantera { writelog(" success.\n\n"); writelog("Problem solved on ["); for (int mm = 1; mm < nDomains(); mm+=2) { - writelog(int2str(domain(mm).nPoints())); - if (mm < nDomains() - 2) writelog(", "); + writelog(int2str(int(domain(mm).nPoints()))); + if (mm + 2 < nDomains()) writelog(", "); } writelog("]"); writelog(" point grid(s).\n\n"); @@ -331,14 +329,12 @@ namespace Cantera { * Refine the grid in all domains. */ int Sim1D::refine(int loglevel) { - int np = 0; + int ianalyze, np = 0; vector_fp znew, xnew; doublereal xmid, zmid; - int strt, n, m, i, ianalyze; - vector_int dsize; + std::vector dsize; - for (n = 0; n < m_nd; n++) { - strt = znew.size(); + for (size_t n = 0; n < m_nd; n++) { Domain1D& d = domain(n); Refiner& r = d.refiner(); @@ -350,19 +346,19 @@ namespace Cantera { if (loglevel > 0) { r.show(); } np += r.nNewPoints(); - int comp = d.nComponents(); + size_t comp = d.nComponents(); // loop over points in the current grid - int npnow = d.nPoints(); - int nstart = znew.size(); - for (m = 0; m < npnow; m++) { + size_t npnow = d.nPoints(); + size_t nstart = znew.size(); + for (size_t m = 0; m < npnow; m++) { if (r.keepPoint(m)) { // add the current grid point to the new grid znew.push_back(d.grid(m)); // do the same for the solution at this point - for (i = 0; i < comp; i++) { + for (size_t i = 0; i < comp; i++) { xnew.push_back(value(n, i, m)); } @@ -370,7 +366,7 @@ namespace Cantera { // interval to the right of point m, and if so, add // entries to znew and xnew for this new point - if (r.newPointNeeded(m) && m < npnow - 1) { + if (r.newPointNeeded(m) && m + 1 < npnow) { // add new point at midpoint zmid = 0.5*(d.grid(m) + d.grid(m+1)); @@ -380,7 +376,7 @@ namespace Cantera { // for each component, linearly interpolate // the solution to this point - for (i = 0; i < comp; i++) { + for (size_t i = 0; i < comp; i++) { xmid = 0.5*(value(n, i, m) + value(n, i, m+1)); xnew.push_back(xmid); } @@ -399,8 +395,8 @@ namespace Cantera { // themselves have not yet been modified. Now update each // domain with the new grid. - int gridstart = 0, gridsize; - for (n = 0; n < m_nd; n++) { + size_t gridstart = 0, gridsize; + for (size_t n = 0; n < m_nd; n++) { Domain1D& d = domain(n); // Refiner& r = d.refiner(); gridsize = dsize[n]; // d.nPoints() + r.nNewPoints(); @@ -433,9 +429,9 @@ namespace Cantera { doublereal xmid; doublereal zfixed,interp_factor; doublereal z1 = 0.0, z2 = 0.0, t1,t2; - int strt, n, m, i; - int m1 = 0,m2 = 0; - vector_int dsize; + size_t strt, n, m, i; + size_t m1 = 0; + std::vector dsize; for (n = 0; n < m_nd; n++) { @@ -443,11 +439,11 @@ namespace Cantera { strt = znew.size(); Domain1D& d = domain(n); - int comp = d.nComponents(); + size_t comp = d.nComponents(); // loop over points in the current grid to determine where new point is needed. - int npnow = d.nPoints(); - int nstart = znew.size(); + size_t npnow = d.nPoints(); + size_t nstart = znew.size(); for (m = 0; m < npnow-1; m++) { //cout << "T["<nSpecies(); + size_t nsp2 = m_thermo->nSpecies(); if (nsp2 != m_nsp) { m_nsp = nsp2; Domain1D::resize(m_nsp+4, points); @@ -187,7 +187,7 @@ namespace Cantera { /** * Change the grid size. Called after grid refinement. */ - void StFlow::resize(int ncomponents, int points) { + void StFlow::resize(size_t ncomponents, size_t points) { Domain1D::resize(ncomponents, points); m_rho.resize(m_points, 0.0); m_wtm.resize(m_points, 0.0); @@ -215,9 +215,9 @@ namespace Cantera { } - void StFlow::setupGrid(int n, const doublereal* z) { + void StFlow::setupGrid(size_t n, const doublereal* z) { resize(m_nv, n); - int j; + size_t j; m_z[0] = z[0]; for (j = 1; j < m_points; j++) { @@ -267,7 +267,7 @@ namespace Cantera { * Set the gas object state to be consistent with the solution at * point j. */ - void StFlow::setGas(const doublereal* x,int j) { + void StFlow::setGas(const doublereal* x, size_t j) { m_thermo->setTemperature(T(x,j)); const doublereal* yy = x + m_nv*j + c_offset_Y; m_thermo->setMassFractions_NoNorm(yy); @@ -279,11 +279,11 @@ namespace Cantera { * Set the gas state to be consistent with the solution at the * midpoint between j and j + 1. */ - void StFlow::setGasAtMidpoint(const doublereal* x,int j) { + void StFlow::setGasAtMidpoint(const doublereal* x, size_t j) { m_thermo->setTemperature(0.5*(T(x,j)+T(x,j+1))); const doublereal* yyj = x + m_nv*j + c_offset_Y; const doublereal* yyjp = x + m_nv*(j+1) + c_offset_Y; - for (int k = 0; k < m_nsp; k++) + for (size_t k = 0; k < m_nsp; k++) m_ybar[k] = 0.5*(yyj[k] + yyjp[k]); m_thermo->setMassFractions_NoNorm(DATA_PTR(m_ybar)); m_thermo->setPressure(m_press); @@ -291,9 +291,9 @@ namespace Cantera { void StFlow::_finalize(const doublereal* x) { - int k, j; + size_t k, j; doublereal zz, tt; - int nz = m_zfix.size(); + size_t nz = m_zfix.size(); bool e = m_do_energy[0]; for (j = 0; j < m_points; j++) { if (e || nz == 0) @@ -323,26 +323,26 @@ namespace Cantera { * */ - void AxiStagnFlow::eval(int jg, doublereal* xg, + void AxiStagnFlow::eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { // if evaluating a Jacobian, and the global point is outside // the domain of influence for this domain, then skip // evaluating the residual - if (jg >=0 && (jg < firstPoint() - 1 || jg > lastPoint() + 1)) return; + if (jg != -1 && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; // if evaluating a Jacobian, compute the steady-state residual - if (jg >= 0) rdt = 0.0; + if (jg != -1) rdt = 0.0; // start of local part of global arrays doublereal* x = xg + loc(); doublereal* rsd = rg + loc(); integer* diag = diagg + loc(); - int jmin, jmax, jpt; + size_t jmin, jmax, jpt; jpt = jg - firstPoint(); - if (jg < 0) { // evaluate all points + if (jg == -1) { // evaluate all points jmin = 0; jmax = m_points - 1; } @@ -352,11 +352,11 @@ namespace Cantera { } // properties are computed for grid points from j0 to j1 - int j0 = max(jmin-1,0); - int j1 = min(jmax+1,m_points-1); + size_t j0 = max(jmin-1,0); + size_t j1 = min(jmax+1,m_points-1); - int j, k; + size_t j, k; //----------------------------------------------------- @@ -571,11 +571,9 @@ namespace Cantera { * Update the transport properties at grid points in the range * from j0 to j1, based on solution x. */ - void StFlow::updateTransport(doublereal* x,int j0, int j1) { - int j,k,m; - + void StFlow::updateTransport(doublereal* x, size_t j0, size_t j1) { if (m_transport_option == c_Mixav_Transport) { - for (j = j0; j < j1; j++) { + for (size_t j = j0; j < j1; j++) { setGasAtMidpoint(x,j); m_visc[j] = (m_dovisc ? m_trans->viscosity() : 0.0); m_trans->getMixDiffCoeffs(DATA_PTR(m_diff) + j*m_nsp); @@ -585,8 +583,8 @@ namespace Cantera { else if (m_transport_option == c_Multi_Transport) { doublereal sum, sumx, wtm, dz; doublereal eps = 1.0e-12; - for (m = j0; m < j1; m++) { - setGasAtMidpoint(x,m); + for (size_t m = j0; m < j1; m++) { + setGasAtMidpoint(x,m); dz = m_z[m+1] - m_z[m]; wtm = m_thermo->meanMolecularWeight(); @@ -595,10 +593,10 @@ namespace Cantera { m_trans->getMultiDiffCoeffs(m_nsp, DATA_PTR(m_multidiff) + mindex(0,0,m)); - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { sum = 0.0; sumx = 0.0; - for (j = 0; j < m_nsp; j++) { + for (size_t j = 0; j < m_nsp; j++) { if (j != k) { sum += m_wt[j]*m_multidiff[mindex(k,j,m)]* ((X(x,j,m+1) - X(x,j,m))/dz + eps); @@ -629,26 +627,26 @@ namespace Cantera { * */ - void FreeFlame::eval(int jg, doublereal* xg, + void FreeFlame::eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { // if evaluating a Jacobian, and the global point is outside // the domain of influence for this domain, then skip // evaluating the residual - if (jg >=0 && (jg < firstPoint() - 1 || jg > lastPoint() + 1)) return; + if (jg != -1 && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) return; // if evaluating a Jacobian, compute the steady-state residual - if (jg >= 0) rdt = 0.0; + if (jg != -1) rdt = 0.0; // start of local part of global arrays doublereal* x = xg + loc(); doublereal* rsd = rg + loc(); integer* diag = diagg + loc(); - int jmin, jmax, jpt; + size_t jmin, jmax, jpt; jpt = jg - firstPoint(); - if (jg < 0) { // evaluate all points + if (jg == -1) { // evaluate all points jmin = 0; jmax = m_points - 1; } @@ -658,11 +656,11 @@ namespace Cantera { } // properties are computed for grid points from j0 to j1 - int j0 = max(jmin-1,0); - int j1 = min(jmax+1,m_points-1); + size_t j0 = max(jmin-1,0); + size_t j1 = min(jmax+1,m_points-1); - int j, k; + size_t j, k; //----------------------------------------------------- @@ -874,8 +872,8 @@ namespace Cantera { * Print the solution. */ void StFlow::showSolution(const doublereal* x) { - int nn = m_nv/5; - int i, j, n; + size_t nn = m_nv/5; + size_t i, j, n; //char* buf = new char[100]; char buf[100]; @@ -903,7 +901,7 @@ namespace Cantera { } writelog("\n"); } - int nrem = m_nv - 5*nn; + size_t nrem = m_nv - 5*nn; st_drawline(); sprintf(buf, "\n z "); writelog(buf); @@ -927,8 +925,8 @@ namespace Cantera { /** * Update the diffusive mass fluxes. */ - void StFlow::updateDiffFluxes(const doublereal* x, int j0, int j1) { - int j, k, m; + void StFlow::updateDiffFluxes(const doublereal* x, size_t j0, size_t j1) { + size_t j, k, m; doublereal sum, wtm, rho, dz, gradlogT; switch (m_transport_option) { @@ -966,7 +964,7 @@ namespace Cantera { } - string StFlow::componentName(int n) const { + string StFlow::componentName(size_t n) const { switch(n) { case 0: return "u"; case 1: return "V"; @@ -983,7 +981,7 @@ namespace Cantera { //added by Karl Meredith - int StFlow::componentIndex(string name) const { + size_t StFlow::componentIndex(string name) const { if(name=="u") {return 0;} @@ -1005,7 +1003,7 @@ namespace Cantera { void StFlow::restore(const XML_Node& dom, doublereal* soln) { vector ignored; - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_int did_species(nsp, 0); vector str; @@ -1027,7 +1025,7 @@ namespace Cantera { int nd = static_cast(d.size()); vector_fp x; - int n, np = 0, j, ks, k; + size_t n, np = 0, j, ks, k; string nm; bool readgrid = false, wrote_header = false; for (n = 0; n < nd; n++) { @@ -1036,7 +1034,7 @@ namespace Cantera { if (nm == "z") { getFloatArray(fa,x,false); np = x.size(); - writelog("Grid contains "+int2str(np)+ + writelog("Grid contains "+int2str(int(np))+ " points.\n"); readgrid = true; setupGrid(np, DATA_PTR(x)); @@ -1140,15 +1138,15 @@ namespace Cantera { void StFlow::save(XML_Node& o, doublereal* sol) { - int k; + size_t k; ArrayViewer soln(m_nv, m_points, sol + loc()); XML_Node& flow = (XML_Node&)o.addChild("domain"); flow.addAttribute("type",flowType()); flow.addAttribute("id",m_id); - flow.addAttribute("points",m_points); - flow.addAttribute("components",m_nv); + flow.addAttribute("points", double(m_points)); + flow.addAttribute("components", double(m_nv)); if (m_desc != "") addString(flow,"description",m_desc); XML_Node& gv = flow.addChild("grid_data"); diff --git a/Cantera/src/oneD/StFlow.h b/Cantera/src/oneD/StFlow.h index 582ba64db..dc69b387c 100644 --- a/Cantera/src/oneD/StFlow.h +++ b/Cantera/src/oneD/StFlow.h @@ -64,7 +64,7 @@ namespace Cantera { /// will be used to evaluate all thermodynamic, kinetic, and transport /// properties. /// @param nsp Number of species. - StFlow(igthermo_t* ph = 0, int nsp = 1, int points = 1); + StFlow(igthermo_t* ph = 0, size_t nsp = 1, size_t points = 1); /// Destructor. virtual ~StFlow(){} @@ -74,7 +74,7 @@ namespace Cantera { */ //@{ - virtual void setupGrid(int n, const doublereal* z); + virtual void setupGrid(size_t n, const doublereal* z); thermo_t& phase() { return *m_thermo; } kinetics_t& kinetics() { return *m_kin; } @@ -103,11 +103,10 @@ namespace Cantera { /// @todo remove? may be unused - virtual void setState(int point, const doublereal* state, + virtual void setState(size_t point, const doublereal* state, doublereal *x) { setTemperature(point, state[2]); - int k; - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { setMassFraction(point, k, state[4+k]); } } @@ -142,7 +141,7 @@ namespace Cantera { * disable the energy equation so that the solution will be * held to this value. */ - void setTemperature(int j, doublereal t) { + void setTemperature(size_t j, doublereal t) { m_fixedtemp[j] = t; m_do_energy[j] = false; } @@ -153,24 +152,24 @@ namespace Cantera { * solution will be held to this value. * note: in practice, the species are hardly ever held fixed. */ - void setMassFraction(int j, int k, doublereal y) { + void setMassFraction(size_t j, size_t k, doublereal y) { m_fixedy(k,j) = y; m_do_species[k] = true; // false; } /// The fixed temperature value at point j. - doublereal T_fixed(int j) const {return m_fixedtemp[j];} + doublereal T_fixed(size_t j) const {return m_fixedtemp[j];} /// The fixed mass fraction value of species k at point j. - doublereal Y_fixed(int k, int j) const {return m_fixedy(k,j);} + doublereal Y_fixed(size_t k, size_t j) const {return m_fixedy(k,j);} - virtual std::string componentName(int n) const; + virtual std::string componentName(size_t n) const; //added by Karl Meredith - int componentIndex(std::string name) const; + size_t componentIndex(std::string name) const; virtual void showSolution(const doublereal* x); @@ -206,8 +205,8 @@ namespace Cantera { needJacUpdate(); } - bool doSpecies(int k) { return m_do_species[k]; } - bool doEnergy(int j) { return m_do_energy[j]; } + 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) { @@ -229,20 +228,20 @@ namespace Cantera { void integrateChem(doublereal* x,doublereal dt); - void resize(int components, int points); + void resize(size_t components, size_t points); virtual void setFixedPoint(int j0, doublereal t0){} void setJac(MultiJac* jac); - void setGas(const doublereal* x,int j); - void setGasAtMidpoint(const doublereal* x,int j); + void setGas(const doublereal* x, size_t j); + void setGasAtMidpoint(const doublereal* x, size_t j); //Karl Meredith // doublereal density_unprotected(int j) const { // return m_rho[j]; // } - doublereal density(int j) const { + doublereal density(size_t j) const { return m_rho[j]; } @@ -251,23 +250,23 @@ namespace Cantera { protected: - doublereal component(const doublereal* x, int i, int j) const { + doublereal component(const doublereal* x, size_t i, size_t j) const { doublereal xx = x[index(i,j)]; return xx; } - doublereal conc(const doublereal* x,int k,int j) const { + doublereal conc(const doublereal* x, size_t k,size_t j) const { return Y(x,k,j)*density(j)/m_wt[k]; } - doublereal cbar(const doublereal* x,int k, int j) const { + doublereal cbar(const doublereal* x, size_t k, size_t j) const { return std::sqrt(8.0*GasConstant * T(x,j) / (Pi * m_wt[k])); } - doublereal wdot(int k, int j) const {return m_wdot(k,j);} + doublereal wdot(size_t k, size_t j) const {return m_wdot(k,j);} /// write the net production rates at point j into array m_wdot - void getWdot(doublereal* x,int j) { + void getWdot(doublereal* x, size_t j) { setGas(x,j); m_kin->getNetProductionRates(&m_wdot(0,j)); } @@ -276,9 +275,8 @@ namespace Cantera { * update the thermodynamic properties from point * j0 to point j1 (inclusive), based on solution x. */ - void updateThermo(const doublereal* x, int j0, int j1) { - int j; - for (j = j0; j <= j1; j++) { + void updateThermo(const doublereal* x, size_t j0, size_t j1) { + for (size_t j = j0; j <= j1; j++) { setGas(x,j); m_rho[j] = m_thermo->density(); m_wtm[j] = m_thermo->meanMolecularWeight(); @@ -291,7 +289,7 @@ namespace Cantera { // central-differenced derivatives //-------------------------------- - doublereal cdif2(const doublereal* x, int n, int j, + doublereal cdif2(const doublereal* x, size_t n, size_t j, const doublereal* f) const { doublereal c1 = (f[j] + f[j-1])*(x[index(n,j)] - x[index(n,j-1)]); doublereal c2 = (f[j+1] + f[j])*(x[index(n,j+1)] - x[index(n,j)]); @@ -304,44 +302,44 @@ namespace Cantera { //-------------------------------- - doublereal T(const doublereal* x,int j) const { + doublereal T(const doublereal* x, size_t j) const { return x[index(c_offset_T, j)]; } - doublereal& T(doublereal* x,int j) {return x[index(c_offset_T, j)];} - doublereal T_prev(int j) const {return prevSoln(c_offset_T, j);} + doublereal& T(doublereal* x, size_t j) {return x[index(c_offset_T, j)];} + doublereal T_prev(size_t j) const {return prevSoln(c_offset_T, j);} - doublereal rho_u(const doublereal* x,int j) const { + doublereal rho_u(const doublereal* x, size_t j) const { return m_rho[j]*x[index(c_offset_U, j)];} - doublereal u(const doublereal* x,int j) const { + doublereal u(const doublereal* x, size_t j) const { return x[index(c_offset_U, j)];} - doublereal V(const doublereal* x,int j) const { + doublereal V(const doublereal* x, size_t j) const { return x[index(c_offset_V, j)];} - doublereal V_prev(int j) const { + doublereal V_prev(size_t j) const { return prevSoln(c_offset_V, j);} - doublereal lambda(const doublereal* x,int j) const { + doublereal lambda(const doublereal* x, size_t j) const { return x[index(c_offset_L, j)]; } - doublereal Y(const doublereal* x,int k, int j) const { + doublereal Y(const doublereal* x, size_t k, size_t j) const { return x[index(c_offset_Y + k, j)]; } - doublereal& Y(doublereal* x,int k, int j) { + doublereal& Y(doublereal* x, size_t k, size_t j) { return x[index(c_offset_Y + k, j)]; } - doublereal Y_prev(int k, int j) const { + doublereal Y_prev(size_t k, size_t j) const { return prevSoln(c_offset_Y + k, j); } - doublereal X(const doublereal* x,int k, int j) const { + doublereal X(const doublereal* x, size_t k, size_t j) const { return m_wtm[j]*Y(x,k,j)/m_wt[k]; } - doublereal flux(int k, int j) const { + doublereal flux(size_t k, size_t j) const { return m_flux(k, j); } @@ -349,38 +347,38 @@ namespace Cantera { // convective spatial derivatives. These use upwind // differencing, assuming u(z) is negative - doublereal dVdz(const doublereal* x,int j) const { - int jloc = (u(x,j) > 0.0 ? j : j + 1); + doublereal dVdz(const doublereal* x, size_t j) const { + size_t jloc = (u(x,j) > 0.0 ? j : j + 1); return (V(x,jloc) - V(x,jloc-1))/m_dz[jloc-1]; } - doublereal dYdz(const doublereal* x,int k, int j) const { - int jloc = (u(x,j) > 0.0 ? j : j + 1); + doublereal dYdz(const doublereal* x, size_t k, size_t j) const { + size_t jloc = (u(x,j) > 0.0 ? j : j + 1); return (Y(x,k,jloc) - Y(x,k,jloc-1))/m_dz[jloc-1]; } - doublereal dTdz(const doublereal* x,int j) const { - int jloc = (u(x,j) > 0.0 ? j : j + 1); + doublereal dTdz(const doublereal* x, size_t j) const { + size_t jloc = (u(x,j) > 0.0 ? j : j + 1); return (T(x,jloc) - T(x,jloc-1))/m_dz[jloc-1]; } - doublereal shear(const doublereal* x,int j) const { + doublereal shear(const doublereal* x, size_t j) const { doublereal c1 = m_visc[j-1]*(V(x,j) - V(x,j-1)); doublereal c2 = m_visc[j]*(V(x,j+1) - V(x,j)); return 2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1)); } - doublereal divHeatFlux(const doublereal* x, int j) const { + doublereal divHeatFlux(const doublereal* x, size_t j) const { doublereal c1 = m_tcon[j-1]*(T(x,j) - T(x,j-1)); doublereal c2 = m_tcon[j]*(T(x,j+1) - T(x,j)); return -2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1)); } - int mindex(int k, int j, int m) { + size_t mindex(size_t k, size_t j, size_t m) { return m*m_nsp*m_nsp + m_nsp*j + k; } - void updateDiffFluxes(const doublereal* x, int j0, int j1); + void updateDiffFluxes(const doublereal* x, size_t j0, size_t j1); //--------------------------------------------------------- @@ -426,7 +424,7 @@ namespace Cantera { Array2D m_wdot; vector_fp m_surfdot; - int m_nsp; + size_t m_nsp; igthermo_t* m_thermo; kinetics_t* m_kin; @@ -454,7 +452,7 @@ namespace Cantera { doublereal m_efctr; bool m_dovisc; - void updateTransport(doublereal* x,int j0, int j1); + void updateTransport(doublereal* x, size_t j0, size_t j1); private: vector_fp m_ybar; @@ -467,10 +465,10 @@ namespace Cantera { */ class AxiStagnFlow : public StFlow { public: - AxiStagnFlow(igthermo_t* ph = 0, int nsp = 1, int points = 1) : + AxiStagnFlow(igthermo_t* ph = 0, size_t nsp = 1, size_t points = 1) : StFlow(ph, nsp, points) { m_dovisc = true; } virtual ~AxiStagnFlow() {} - virtual void eval(int j, doublereal* x, doublereal* r, + virtual void eval(size_t j, doublereal* x, doublereal* r, integer* mask, doublereal rdt); virtual std::string flowType() { return "Axisymmetric Stagnation"; } }; @@ -480,13 +478,13 @@ namespace Cantera { */ class FreeFlame : public StFlow { public: - FreeFlame(igthermo_t* ph = 0, int nsp = 1, int points = 1) : + FreeFlame(igthermo_t* ph = 0, size_t nsp = 1, size_t points = 1) : StFlow(ph, nsp, points) { m_dovisc = false; setID("flame"); } virtual ~FreeFlame() {} - virtual void eval(int j, doublereal* x, doublereal* r, + virtual void eval(size_t j, doublereal* x, doublereal* r, integer* mask, doublereal rdt); virtual std::string flowType() { return "Free Flame"; } virtual bool fixed_mdot() { return false; } diff --git a/Cantera/src/oneD/boundaries1D.cpp b/Cantera/src/oneD/boundaries1D.cpp index ad72b7652..cdcd29e8b 100644 --- a/Cantera/src/oneD/boundaries1D.cpp +++ b/Cantera/src/oneD/boundaries1D.cpp @@ -23,7 +23,7 @@ namespace Cantera { void Bdry1D:: - _init(int n) { + _init(size_t n) { if (m_index < 0) { throw CanteraError("Bdry1D", "install in container before calling init."); @@ -55,7 +55,7 @@ namespace Cantera { // if this is not the last domain, see what is connected on // the right - if (m_index < container().nDomains() - 1) { + if (m_index + 1 < container().nDomains()) { Domain1D& r = container().domain(m_index+1); if (r.domainType() == cFlowType) { m_flow_right = (StFlow*)&r; @@ -156,10 +156,10 @@ namespace Cantera { void Inlet1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { int k; - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -218,7 +218,7 @@ namespace Cantera { // right inlet. else { - int boffset = m_flow->nComponents(); + size_t boffset = m_flow->nComponents(); xb = x - boffset; rb = r - boffset; rb[1] -= m_V0; @@ -239,7 +239,7 @@ namespace Cantera { inlt.addAttribute("id",id()); inlt.addAttribute("points",1); inlt.addAttribute("type","inlet"); - inlt.addAttribute("components",nComponents()); + inlt.addAttribute("components", double(nComponents())); for (int k = 0; k < nComponents(); k++) { ctml::addFloat(inlt, componentName(k), s[k], "", "",lowerBound(k), upperBound(k)); } @@ -284,9 +284,9 @@ namespace Cantera { } void Empty1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -304,7 +304,7 @@ namespace Cantera { symm.addAttribute("id",id()); symm.addAttribute("points",1); symm.addAttribute("type","empty"); - symm.addAttribute("components",nComponents()); + symm.addAttribute("components", double(nComponents())); } void Empty1D:: @@ -342,9 +342,9 @@ namespace Cantera { } void Symm1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2< firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -355,7 +355,7 @@ namespace Cantera { r[0] = x[0]; diag[0] = 0; - int nc; + size_t nc; if (m_flow_right) { nc = m_flow_right->nComponents(); @@ -387,7 +387,7 @@ namespace Cantera { symm.addAttribute("id",id()); symm.addAttribute("points",1); symm.addAttribute("type","symmetry"); - symm.addAttribute("components",nComponents()); + symm.addAttribute("components", double(nComponents())); } void Symm1D:: @@ -428,9 +428,9 @@ namespace Cantera { void Outlet1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -441,7 +441,7 @@ namespace Cantera { r[0] = x[0]; diag[0] = 0; - int nc, k; + size_t nc, k; if (m_flow_right) { nc = m_flow_right->nComponents(); @@ -485,7 +485,7 @@ namespace Cantera { outlt.addAttribute("id",id()); outlt.addAttribute("points",1); outlt.addAttribute("type","outlet"); - outlt.addAttribute("components",nComponents()); + outlt.addAttribute("components", double(nComponents())); } void Outlet1D:: @@ -563,10 +563,10 @@ namespace Cantera { void OutletRes1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -578,7 +578,7 @@ namespace Cantera { // drive dummy component to zero r[0] = x[0]; diag[0] = 0; - int nc, k; + size_t nc, k; if (m_flow_right) { nc = m_flow_right->nComponents(); @@ -625,7 +625,7 @@ namespace Cantera { outlt.addAttribute("id",id()); outlt.addAttribute("points",1); outlt.addAttribute("type","outletres"); - outlt.addAttribute("components",nComponents()); + outlt.addAttribute("components", double(nComponents())); } void OutletRes1D:: @@ -668,9 +668,9 @@ namespace Cantera { void Surf1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -680,7 +680,7 @@ namespace Cantera { r[0] = x[0] - m_temp; diag[0] = 0; - int nc; + size_t nc; if (m_flow_right) { rb = r + 1; @@ -704,7 +704,7 @@ namespace Cantera { inlt.addAttribute("id",id()); inlt.addAttribute("points",1); inlt.addAttribute("type","surface"); - inlt.addAttribute("components",nComponents()); + inlt.addAttribute("components", double(nComponents())); for (int k = 0; k < nComponents(); k++) { ctml::addFloat(inlt, componentName(k), s[k], "", "",0.0, 1.0); } @@ -766,9 +766,9 @@ namespace Cantera { void ReactingSurf1D:: - eval(int jg, doublereal* xg, doublereal* rg, + eval(size_t jg, doublereal* xg, doublereal* rg, integer* diagg, doublereal rdt) { - if (jg >= 0 && (jg < firstPoint() - 2 || jg > lastPoint() + 2)) return; + if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return; // start of local part of global arrays doublereal* x = xg + loc(); @@ -793,8 +793,8 @@ namespace Cantera { // set the left gas state to the adjacent point - int leftloc = 0, rightloc = 0; - int pnt = 0; + size_t leftloc = 0, rightloc = 0; + size_t pnt = 0; if (m_flow_left) { leftloc = m_flow_left->loc(); @@ -813,7 +813,7 @@ namespace Cantera { //scale(m_work.begin(), m_work.end(), m_work.begin(), m_mult[0]); // bool enabled = true; - int ioffset = m_kin->kineticsSpeciesIndex(0, m_surfindex); + size_t ioffset = m_kin->kineticsSpeciesIndex(0, m_surfindex); if (m_enabled) { doublereal maxx = -1.0; @@ -842,7 +842,7 @@ namespace Cantera { xb = x + 1; rb[2] = xb[2] - x[0]; // specified T } - int nc; + size_t nc; if (m_flow_left) { nc = m_flow_left->nComponents(); const doublereal* mwleft = DATA_PTR(m_phase_left->molecularWeights()); @@ -863,7 +863,7 @@ namespace Cantera { inlt.addAttribute("id",id()); inlt.addAttribute("points",1); inlt.addAttribute("type","surface"); - inlt.addAttribute("components",nComponents()); + inlt.addAttribute("components", double(nComponents())); for (int k = 0; k < nComponents(); k++) { ctml::addFloat(inlt, componentName(k), s[k], "", "",0.0, 1.0); } diff --git a/Cantera/src/oneD/newton_utils.cpp b/Cantera/src/oneD/newton_utils.cpp index d837d4a65..63762c7e2 100644 --- a/Cantera/src/oneD/newton_utils.cpp +++ b/Cantera/src/oneD/newton_utils.cpp @@ -11,9 +11,9 @@ namespace Cantera { class Indx { public: - Indx(int nv, int np) : m_nv(nv), m_np(np) {} - int m_nv, m_np; - int operator()(int m, int j) { return j*m_nv + m; } + Indx(size_t nv, size_t np) : m_nv(nv), m_np(np) {} + size_t m_nv, m_np; + size_t operator()(size_t m, size_t j) { return j*m_nv + m; } }; @@ -26,11 +26,11 @@ namespace Cantera { Domain1D& r, int loglevel) { char buf[100]; - int np = r.nPoints(); - int nv = r.nComponents(); + size_t np = r.nPoints(); + size_t nv = r.nComponents(); Indx index(nv, np); doublereal above, below, val, newval; - int m, j; + size_t m, j; doublereal fbound = 1.0; bool wroteTitle = false; for (m = 0; m < nv; m++) { @@ -104,12 +104,10 @@ namespace Cantera { doublereal norm_square(const doublereal* x, const doublereal* step, Domain1D& r) { doublereal f, ewt, esum, sum = 0.0; - int n, j; + size_t n, j; doublereal f2max = 0.0; - int nmax = 0; - int jmax = 0; - int nv = r.nComponents(); - int np = r.nPoints(); + size_t nv = r.nComponents(); + size_t np = r.nPoints(); for (n = 0; n < nv; n++) { esum = 0.0; @@ -119,17 +117,10 @@ namespace Cantera { f = step[nv*j + n]/ewt; sum += f*f; if (f*f > f2max) { - jmax = j; - nmax = n; f2max = f*f; } } } -#undef DEBUG_NORM -#ifdef DEBUG_NORM - cout << "max step in domain " << r.id() << ": " << f2max << endl << - " for component " << r.componentName(nmax) << " at point " << jmax << endl; -#endif return sum; } } diff --git a/Cantera/src/oneD/refine.cpp b/Cantera/src/oneD/refine.cpp index 115a6c147..ccabbb76a 100644 --- a/Cantera/src/oneD/refine.cpp +++ b/Cantera/src/oneD/refine.cpp @@ -9,7 +9,7 @@ using namespace std; namespace Cantera { template - bool has_key(const M& m, int j) { + bool has_key(const M& m, size_t j) { if (m.find(j) != m.end()) return true; return false; } @@ -40,11 +40,11 @@ namespace Cantera { } - int Refiner::analyze(int n, const doublereal* z, + int Refiner::analyze(size_t n, const doublereal* z, const doublereal* x) { if (n >= m_npmax) { - writelog("max number of grid points reached ("+int2str(m_npmax)+".\n"); + writelog("max number of grid points reached ("+int2str(int(m_npmax))+".\n"); return -2; } @@ -70,14 +70,14 @@ namespace Cantera { /** * find locations where cell size ratio is too large. */ - int j; + size_t j; vector_fp dz(n-1, 0.0); string name; doublereal vmin, vmax, smin, smax, aa, ss; doublereal dmax, r; vector_fp v(n), s(n-1); - for (int i = 0; i < m_nv; i++) { + for (size_t i = 0; i < m_nv; i++) { if (m_active[i]) { name = m_domain->componentName(i); //writelog("refine: examining "+name+"\n"); @@ -173,23 +173,21 @@ namespace Cantera { dz[j] = z[j+1] - z[j]; if (dz[j] > m_ratio*dz[j-1]) { m_loc[j] = 1; - m_c["point "+int2str(j)] = 1; + m_c["point "+int2str(int(j))] = 1; } if (dz[j] < dz[j-1]/m_ratio) { m_loc[j-1] = 1; - m_c["point "+int2str(j-1)] = 1; + m_c["point "+int2str(int(j)-1)] = 1; } //if (m_loc.size() + n > m_npmax) goto done; } - - //done: //m_did_analysis = true; - return static_cast(m_loc.size()); + return int(m_loc.size()); } - double Refiner::value(const double* x, int i, int j) { + double Refiner::value(const double* x, size_t i, size_t j) { return x[m_domain->index(i,j)]; } @@ -200,9 +198,9 @@ namespace Cantera { writelog(string("Refining grid in ") + m_domain->id()+".\n" +" New points inserted after grid points "); - map::const_iterator b = m_loc.begin(); + map::const_iterator b = m_loc.begin(); for (; b != m_loc.end(); ++b) { - writelog(int2str(b->first)+" "); + writelog(int2str(int(b->first))+" "); } writelog("\n"); writelog(" to resolve "); @@ -232,7 +230,7 @@ namespace Cantera { } int jn = 0; - if (m_loc.size() == 0) { + if (m_loc.empty()) { copy(z, z + n, zn); return 0; } diff --git a/Cantera/src/oneD/refine.h b/Cantera/src/oneD/refine.h index cfb15536e..aab6e5927 100644 --- a/Cantera/src/oneD/refine.h +++ b/Cantera/src/oneD/refine.h @@ -21,18 +21,18 @@ namespace Cantera { } void setActive(int comp, bool state = true) { m_active[comp] = state; } void setMaxPoints(int npmax) { m_npmax = npmax; } - int analyze(int n, const doublereal* z, const doublereal* x); + int analyze(size_t n, const doublereal* z, const doublereal* x); int getNewGrid(int n, const doublereal* z, int nn, doublereal* znew); //int getNewSoln(int n, const doublereal* x, doublereal* xnew); int nNewPoints() { return static_cast(m_loc.size()); } void show(); - bool newPointNeeded(int j) { + bool newPointNeeded(size_t j) { return m_loc.find(j) != m_loc.end(); } - bool keepPoint(int j) { + bool keepPoint(size_t j) { return (m_keep[j] != -1); // m_keep.find(j) != m_keep.end(); } - double value(const double* x, int i, int j); + double value(const double* x, size_t i, size_t j); double maxRatio() { return m_ratio; } double maxDelta() { return m_slope; } double maxSlope() { return m_curve; } @@ -40,14 +40,14 @@ namespace Cantera { protected: - std::map m_loc; - std::map m_keep; + std::map m_loc; + std::map m_keep; std::map m_c; std::vector m_active; doublereal m_ratio, m_slope, m_curve, m_prune; doublereal m_min_range; Domain1D* m_domain; - int m_nv, m_npmax; + size_t m_nv, m_npmax; doublereal m_thresh; }; diff --git a/Cantera/src/thermo/ThermoPhase.h b/Cantera/src/thermo/ThermoPhase.h index 92e66c16e..76a80acfd 100644 --- a/Cantera/src/thermo/ThermoPhase.h +++ b/Cantera/src/thermo/ThermoPhase.h @@ -2013,7 +2013,7 @@ namespace Cantera { * location of a phase object in a list, and is used by the * interface library (clib) routines for this purpose. */ - int index() const { return m_index; } + size_t index() const { return m_index; } /** @@ -2026,7 +2026,7 @@ namespace Cantera { * * @param m Input the index number. */ - void setIndex(int m) { m_index = m; } + void setIndex(size_t m) { m_index = m; } //! Set the equation of state parameters @@ -2141,7 +2141,7 @@ namespace Cantera { * lead to unpredictable results if used in conjunction with * the interface library. */ - int m_index; + size_t m_index; //! Storred value of the electric potential for this phase /*! diff --git a/Cantera/src/transport/L_matrix.h b/Cantera/src/transport/L_matrix.h index aaaa6b287..a7312ae9e 100755 --- a/Cantera/src/transport/L_matrix.h +++ b/Cantera/src/transport/L_matrix.h @@ -21,7 +21,7 @@ namespace Cantera { const doublereal Min_C_Internal = 0.001; - bool MultiTransport::hasInternalModes(int j) { + bool MultiTransport::hasInternalModes(size_t j) { #ifdef CHEMKIN_COMPATIBILITY_MODE return (m_crot[j] > Min_C_Internal); #else @@ -147,9 +147,9 @@ namespace Cantera { void MultiTransport::eval_L1001(const doublereal* x) { doublereal prefactor = 32.00*m_temp/(5.00*Pi); - int i,j; + size_t i,j; doublereal constant, sum; - int n2 = 2*m_nsp; + size_t n2 = 2*m_nsp; int npoly = 0; for (j = 0; j < m_nsp; j++) { // collect terms that depend only on "j" @@ -174,8 +174,8 @@ namespace Cantera { //////////////////////////////////////////////////////////////////////// void MultiTransport::eval_L0001() { - int i, j; - int n2 = 2*m_nsp; + size_t i, j; + size_t n2 = 2*m_nsp; for (j = 0; j < m_nsp; j++) for (i = 0; i < m_nsp; i++) m_Lmatrix(i,j+n2) = 0.0; @@ -184,8 +184,8 @@ namespace Cantera { //////////////////////////////////////////////////////////////////////// void MultiTransport::eval_L0100() { - int i, j; - int n2 = 2*m_nsp; + size_t i, j; + size_t n2 = 2*m_nsp; for (j = 0; j < m_nsp; j++) for (i = 0; i < m_nsp; i++) m_Lmatrix(i+n2,j) = 0.0; // see Eq. (12.123) @@ -194,8 +194,8 @@ namespace Cantera { //////////////////////////////////////////////////////////////////////// void MultiTransport::eval_L0110() { - int i, j; - int n2 = 2*m_nsp; + size_t i, j; + size_t n2 = 2*m_nsp; for (j = 0; j < m_nsp; j++) for (i = 0; i < m_nsp; i++) m_Lmatrix(i+n2,j+m_nsp) = m_Lmatrix(j+m_nsp,i+n2); // see Eq. (12.123) @@ -210,8 +210,8 @@ namespace Cantera { const doublereal eightoverpi = 8.0 / Pi; doublereal prefactor = 4.00*m_temp; - int n2 = 2*m_nsp; - int i,k; + size_t n2 = 2*m_nsp; + size_t i,k; doublereal constant1, constant2, diff_int, sum; for (i = 0; i < m_nsp; i++) { if (hasInternalModes(i)) { diff --git a/Cantera/src/transport/LiquidTransport.cpp b/Cantera/src/transport/LiquidTransport.cpp index d9c33df41..7aff5a091 100644 --- a/Cantera/src/transport/LiquidTransport.cpp +++ b/Cantera/src/transport/LiquidTransport.cpp @@ -348,26 +348,26 @@ namespace Cantera { void LiquidTransport::getFluidMobilities(doublereal* const mobil_f) { getMixDiffCoeffs(DATA_PTR(m_spwork)); doublereal c1 = 1.0 / (GasConstant * m_temp); - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { mobil_f[k] = c1 * m_spwork[k]; } } //================================================================================================ void LiquidTransport::set_Grad_V(const doublereal* const grad_V) { - for (int a = 0; a < m_nDim; a++) { + for (size_t a = 0; a < m_nDim; a++) { m_Grad_V[a] = grad_V[a]; } } //================================================================================================ void LiquidTransport::set_Grad_T(const doublereal* const grad_T) { - for (int a = 0; a < m_nDim; a++) { + for (size_t a = 0; a < m_nDim; a++) { m_Grad_T[a] = grad_T[a]; } } //================================================================================================ void LiquidTransport::set_Grad_X(const doublereal* const grad_X) { - int itop = m_nDim * m_nsp; - for (int i = 0; i < itop; i++) { + size_t itop = m_nDim * m_nsp; + for (size_t i = 0; i < itop; i++) { m_Grad_X[i] = grad_X[i]; } update_Grad_lnAC(); @@ -392,7 +392,7 @@ namespace Cantera { } if (!m_cond_mix_ok) { doublereal sum1 = 0.0, sum2 = 0.0; - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { sum1 += m_molefracs[k] * m_condSpecies[k]; sum2 += m_molefracs[k] / m_condSpecies[k]; } @@ -413,7 +413,7 @@ namespace Cantera { * zeros. */ void LiquidTransport::getThermalDiffCoeffs(doublereal* const dt) { - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { dt[k] = 0.0; } } @@ -775,7 +775,7 @@ namespace Cantera { void LiquidTransport::stefan_maxwell_solve() { int i, j, a; doublereal tmp; - int VIM = m_nDim; + size_t VIM = m_nDim; m_B.resize(m_nsp, VIM); //! grab a local copy of the molecular weights const vector_fp& M = m_thermo->molecularWeights(); diff --git a/Cantera/src/transport/LiquidTransport.h b/Cantera/src/transport/LiquidTransport.h index 9c2e181f7..5804f33c0 100644 --- a/Cantera/src/transport/LiquidTransport.h +++ b/Cantera/src/transport/LiquidTransport.h @@ -729,7 +729,7 @@ namespace Cantera { /*! * Either 1, 2, or 3 */ - int m_nDim; + size_t m_nDim; private: diff --git a/Cantera/src/transport/MultiTransport.cpp b/Cantera/src/transport/MultiTransport.cpp index 8f5fd32b8..6874cd8cc 100755 --- a/Cantera/src/transport/MultiTransport.cpp +++ b/Cantera/src/transport/MultiTransport.cpp @@ -555,7 +555,7 @@ namespace Cantera { double* x1 = DATA_PTR(m_spwork1); double* x2 = DATA_PTR(m_spwork2); double* x3 = DATA_PTR(m_spwork3); - int n, nsp = m_thermo->nSpecies(); + size_t n, nsp = m_thermo->nSpecies(); m_thermo->restoreState(nsp+2, state1); double p1 = m_thermo->pressure(); double t1 = state1[0]; @@ -627,8 +627,8 @@ namespace Cantera { // use LAPACK to solve the equations int info=0; - int nr = m_aa.nRows(); - int nc = m_aa.nColumns(); + size_t nr = m_aa.nRows(); + size_t nc = m_aa.nColumns(); ct_dgetrf(nr, nc, m_aa.ptrColumn(0), nr, &m_aa.ipiv()[0], info); if (info == 0) { @@ -665,7 +665,7 @@ namespace Cantera { const doublereal* state2, doublereal delta, doublereal* fluxes) { getMassFluxes(state1, state2, delta, fluxes); - int k, nsp = m_thermo->nSpecies(); + size_t k, nsp = m_thermo->nSpecies(); for (k = 0; k < nsp; k++) { fluxes[k] /= m_mw[k]; } diff --git a/Cantera/src/transport/MultiTransport.h b/Cantera/src/transport/MultiTransport.h index 070fa5025..6fa289f3d 100644 --- a/Cantera/src/transport/MultiTransport.h +++ b/Cantera/src/transport/MultiTransport.h @@ -288,7 +288,7 @@ namespace Cantera { void eval_L1001(const doublereal* x); void eval_L0110(); void eval_L0101(const doublereal* x); - bool hasInternalModes(int j); + bool hasInternalModes(size_t j); doublereal pressure_ig() { return m_thermo->molarDensity() * GasConstant * m_thermo->temperature(); diff --git a/Cantera/src/transport/SimpleTransport.cpp b/Cantera/src/transport/SimpleTransport.cpp index 359402df1..60f492311 100644 --- a/Cantera/src/transport/SimpleTransport.cpp +++ b/Cantera/src/transport/SimpleTransport.cpp @@ -457,21 +457,21 @@ namespace Cantera { //================================================================================================ void SimpleTransport::set_Grad_V(const doublereal* const grad_V) { doMigration_ = false; - for (int a = 0; a < m_nDim; a++) { + for (size_t a = 0; a < m_nDim; a++) { m_Grad_V[a] = grad_V[a]; if (fabs(grad_V[a]) > 1.0E-13) doMigration_ = true; } } //================================================================================================ void SimpleTransport::set_Grad_T(const doublereal* const grad_T) { - for (int a = 0; a < m_nDim; a++) { + for (size_t a = 0; a < m_nDim; a++) { m_Grad_T[a] = grad_T[a]; } } //================================================================================================ void SimpleTransport::set_Grad_X(const doublereal* const grad_X) { - int itop = m_nDim * m_nsp; - for (int i = 0; i < itop; i++) { + size_t itop = m_nDim * m_nsp; + for (size_t i = 0; i < itop; i++) { m_Grad_X[i] = grad_X[i]; } } @@ -505,7 +505,7 @@ namespace Cantera { m_lambda = m_condSpecies[0]; } else if (compositionDepType_ == 1) { m_lambda = 0.0; - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_lambda += m_condSpecies[k] * m_molefracs[k]; } } @@ -522,7 +522,7 @@ namespace Cantera { * zeros. */ void SimpleTransport::getThermalDiffCoeffs(doublereal* const dt) { - for (int k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { dt[k] = 0.0; } } diff --git a/Cantera/src/transport/SimpleTransport.h b/Cantera/src/transport/SimpleTransport.h index 4604b074d..fc88813b5 100644 --- a/Cantera/src/transport/SimpleTransport.h +++ b/Cantera/src/transport/SimpleTransport.h @@ -432,7 +432,7 @@ namespace Cantera { private: //! Number of species in the mixture - int m_nsp; + size_t m_nsp; //! Temperature dependence type /*! diff --git a/Cantera/src/transport/SolidTransport.cpp b/Cantera/src/transport/SolidTransport.cpp index 21a22681b..882f4e358 100644 --- a/Cantera/src/transport/SolidTransport.cpp +++ b/Cantera/src/transport/SolidTransport.cpp @@ -47,12 +47,10 @@ namespace Cantera { * using the Einstein relation. */ void SolidTransport::getMobilities(doublereal* const mobil) { - int k; getMixDiffCoeffs(mobil); doublereal t = m_thermo->temperature(); - int nsp = m_thermo->nSpecies(); doublereal c1 = ElectronCharge / (Boltzmann * t); - for (k = 0; k < nsp; k++) { + for (size_t k = 0; k < m_thermo->nSpecies(); k++) { mobil[k] *= c1 * fabs(m_thermo->charge(k)); } } @@ -81,10 +79,8 @@ namespace Cantera { */ void SolidTransport::getMixDiffCoeffs(doublereal* const d) { doublereal temp = m_thermo->temperature(); - int nsp = m_thermo->nSpecies(); - int k; - for (k = 0; k < nsp; k++) d[k] = 0.0; - for (k = 0; k < m_nmobile; k++) { + for (size_t k = 0; k < m_thermo->nSpecies(); k++) d[k] = 0.0; + for (size_t k = 0; k < m_nmobile; k++) { d[m_sp[k]] = m_Adiff[k] * pow(temp, m_Ndiff[k]) * exp(-m_Ediff[k]/temp); } diff --git a/Cantera/src/transport/SolidTransport.h b/Cantera/src/transport/SolidTransport.h index 7f89f5cfa..ec7cb0441 100644 --- a/Cantera/src/transport/SolidTransport.h +++ b/Cantera/src/transport/SolidTransport.h @@ -45,7 +45,7 @@ virtual ~SolidTransport() {} private: - int m_nmobile; // number of mobile species + size_t m_nmobile; // number of mobile species vector_fp m_Adiff; vector_fp m_Ndiff; vector_fp m_Ediff; diff --git a/Cantera/src/transport/TransportBase.cpp b/Cantera/src/transport/TransportBase.cpp index faee061a2..6a896f913 100644 --- a/Cantera/src/transport/TransportBase.cpp +++ b/Cantera/src/transport/TransportBase.cpp @@ -72,7 +72,7 @@ namespace Cantera { return m_ready; } - int Transport::index() const { + size_t Transport::index() const { return m_index; } @@ -80,7 +80,7 @@ namespace Cantera { * Set an integer index number. This is for internal use of * Cantera, and may be removed in the future. */ - void Transport::setIndex(int i) { + void Transport::setIndex(size_t i) { m_index = i; } diff --git a/Cantera/src/transport/TransportBase.h b/Cantera/src/transport/TransportBase.h index 3aa2eafbe..140899902 100644 --- a/Cantera/src/transport/TransportBase.h +++ b/Cantera/src/transport/TransportBase.h @@ -125,13 +125,13 @@ namespace Cantera { * Returns an integer index number. This is for internal use * of Cantera, and may be removed in the future. */ - int index() const ; + size_t index() const ; /** * Set an integer index number. This is for internal use of * Cantera, and may be removed in the future. */ - void setIndex(int i); + void setIndex(size_t i); //! Set the number of dimensions to be expected in flux expressions /*! @@ -428,8 +428,8 @@ namespace Cantera { thermo_t* m_thermo; ///< pointer to the object representing the phase bool m_ready; ///< true if finalize has been called - size_t m_nmin; ///< number of species - int m_index; + size_t m_nmin; ///< number of species + size_t m_index; //! Number of dimensions used in flux expresions int m_nDim; diff --git a/Cantera/src/transport/TransportFactory.cpp b/Cantera/src/transport/TransportFactory.cpp index cda0cdaf4..6770163c0 100644 --- a/Cantera/src/transport/TransportFactory.cpp +++ b/Cantera/src/transport/TransportFactory.cpp @@ -388,7 +388,7 @@ namespace Cantera { // constant mixture attributes tr.thermo = thermo; tr.nsp_ = tr.thermo->nSpecies(); - int nsp = tr.nsp_; + size_t nsp = tr.nsp_; tr.tmin = thermo->minTemp(); tr.tmax = thermo->maxTemp(); @@ -518,7 +518,7 @@ namespace Cantera { // constant mixture attributes trParam.thermo = thermo; trParam.nsp_ = trParam.thermo->nSpecies(); - int nsp = trParam.nsp_; + size_t nsp = trParam.nsp_; trParam.tmin = thermo->minTemp(); trParam.tmax = thermo->maxTemp(); @@ -628,9 +628,9 @@ namespace Cantera { vector_fp::iterator dptr; doublereal dstar; - int nsp = tr.nsp_; + size_t nsp = tr.nsp_; int mode = tr.mode_; - int i, j; + size_t i, j; // Chemkin fits to sixth order polynomials int degree = (mode == CK_Mode ? 6 : COLL_INT_POLY_DEGREE); diff --git a/Cantera/src/transport/TransportParams.h b/Cantera/src/transport/TransportParams.h index 24eeaa1cd..1355b3a9e 100755 --- a/Cantera/src/transport/TransportParams.h +++ b/Cantera/src/transport/TransportParams.h @@ -20,7 +20,7 @@ namespace Cantera { TransportParams() : thermo(0), xml(0) {} virtual ~TransportParams(); - int nsp_; + size_t nsp_; // phase_t* mix; thermo_t* thermo; diff --git a/Cantera/src/zeroD/ConstPressureReactor.cpp b/Cantera/src/zeroD/ConstPressureReactor.cpp index 909cf4597..6f90a088f 100644 --- a/Cantera/src/zeroD/ConstPressureReactor.cpp +++ b/Cantera/src/zeroD/ConstPressureReactor.cpp @@ -46,7 +46,7 @@ namespace CanteraZeroD { // set the remaining components to the surface species // coverages on the walls - int loc = m_nsp + 2; + size_t loc = m_nsp + 2; SurfPhase* surf; for (int m = 0; m < m_nwalls; m++) { surf = m_wall[m]->surface(m_lr[m]); @@ -104,7 +104,7 @@ namespace CanteraZeroD { } m_vol = mass / m_thermo->density(); - int loc = m_nsp + 2; + size_t loc = m_nsp + 2; SurfPhase* surf; for (int m = 0; m < m_nwalls; m++) { surf = m_wall[m]->surface(m_lr[m]); @@ -127,24 +127,24 @@ namespace CanteraZeroD { void ConstPressureReactor::evalEqs(doublereal time, doublereal* y, doublereal* ydot, doublereal* params) { - int i, k, nk; + size_t nk; m_time = time; m_thermo->restoreState(m_state); Kinetics* kin; - int m, n, npar, ploc; + size_t npar, ploc; double mult; // process sensitivity parameters if (params) { npar = m_pnum.size(); - for (n = 0; n < npar; n++) { + for (size_t n = 0; n < npar; n++) { mult = m_kin->multiplier(m_pnum[n]); m_kin->setMultiplier(m_pnum[n], mult*params[n]); } ploc = npar; - for (m = 0; m < m_nwalls; m++) { + for (size_t m = 0; m < m_nwalls; m++) { if (m_nsens_wall[m] > 0) { m_wall[m]->setSensitivityParameters(m_lr[m], params + ploc); ploc += m_nsens_wall[m]; @@ -159,9 +159,9 @@ namespace CanteraZeroD { doublereal rs0, sum, wallarea; SurfPhase* surf; - int lr, ns, loc = m_nsp+2, surfloc; + size_t lr, ns, loc = m_nsp+2, surfloc; fill(m_sdot.begin(), m_sdot.end(), 0.0); - for (i = 0; i < m_nwalls; i++) { + for (size_t i = 0; i < m_nwalls; i++) { lr = 1 - 2*m_lr[i]; m_Q += lr*m_wall[i]->Q(time); kin = m_wall[i]->kinetics(m_lr[i]); @@ -175,7 +175,7 @@ namespace CanteraZeroD { kin->getNetProductionRates(DATA_PTR(m_work)); ns = kin->surfacePhaseIndex(); surfloc = kin->kineticsSpeciesIndex(0,ns); - for (k = 1; k < nk; k++) { + for (size_t k = 1; k < nk; k++) { ydot[loc + k] = m_work[surfloc+k]*rs0*surf->size(k); sum -= ydot[loc + k]; } @@ -183,7 +183,7 @@ namespace CanteraZeroD { loc += nk; wallarea = m_wall[i]->area(); - for (k = 0; k < m_nsp; k++) { + for (size_t k = 0; k < m_nsp; k++) { m_sdot[k] += m_work[k]*wallarea; } } @@ -204,7 +204,7 @@ namespace CanteraZeroD { else { fill(ydot + 2, ydot + 2 + m_nsp, 0.0); } - for (n = 0; n < m_nsp; n++) { + for (size_t n = 0; n < m_nsp; n++) { ydot[n+2] *= m_vol; // moles/s/m^3 -> moles/s ydot[n+2] += m_sdot[n]; ydot[n+2] *= mw[n]; @@ -233,11 +233,10 @@ namespace CanteraZeroD { // outlets - int n; doublereal mdot_out; - for (i = 0; i < m_nOutlets; i++) { + for (size_t i = 0; i < m_nOutlets; i++) { mdot_out = m_outlet[i]->massFlowRate(time); - for (n = 0; n < m_nsp; n++) { + for (size_t n = 0; n < m_nsp; n++) { ydot[2+n] -= mdot_out * mf[n]; } if (m_energy) { @@ -249,9 +248,9 @@ namespace CanteraZeroD { // inlets doublereal mdot_in; - for (i = 0; i < m_nInlets; i++) { + for (size_t i = 0; i < m_nInlets; i++) { mdot_in = m_inlet[i]->massFlowRate(time); - for (n = 0; n < m_nsp; n++) { + for (size_t n = 0; n < m_nsp; n++) { ydot[2+n] += m_inlet[i]->outletSpeciesMassFlowRate(n); } if (m_energy) { @@ -263,12 +262,12 @@ namespace CanteraZeroD { // reset sensitivity parameters if (params) { npar = m_pnum.size(); - for (n = 0; n < npar; n++) { + for (size_t n = 0; n < npar; n++) { mult = m_kin->multiplier(m_pnum[n]); m_kin->setMultiplier(m_pnum[n], mult/params[n]); } ploc = npar; - for (m = 0; m < m_nwalls; m++) { + for (size_t m = 0; m < m_nwalls; m++) { if (m_nsens_wall[m] > 0) { m_wall[m]->resetSensitivityParameters(m_lr[m]); ploc += m_nsens_wall[m]; @@ -277,22 +276,22 @@ namespace CanteraZeroD { } } - int ConstPressureReactor::componentIndex(string nm) const { + size_t ConstPressureReactor::componentIndex(string nm) const { if (nm == "H") return 0; if (nm == "V") return 1; // check for a gas species name - int k = m_thermo->speciesIndex(nm); - if (k >= 0) return k + 2; + size_t k = m_thermo->speciesIndex(nm); + if (k != -1) return k + 2; // check for a wall species - int walloffset = 0, kp = 0; + size_t walloffset = 0, kp = 0; thermo_t* th; - for (int m = 0; m < m_nwalls; m++) { + for (size_t m = 0; m < m_nwalls; m++) { if (m_wall[m]->kinetics(m_lr[m])) { 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 >= 0) { + if (k != -1) { return k + 2 + m_nsp + walloffset; } else { diff --git a/Cantera/src/zeroD/ConstPressureReactor.h b/Cantera/src/zeroD/ConstPressureReactor.h index ce0c92a35..530c2b126 100644 --- a/Cantera/src/zeroD/ConstPressureReactor.h +++ b/Cantera/src/zeroD/ConstPressureReactor.h @@ -51,7 +51,7 @@ namespace CanteraZeroD { virtual void updateState(doublereal* y); - virtual int componentIndex(std::string nm) const; + virtual size_t componentIndex(std::string nm) const; protected: diff --git a/Cantera/src/zeroD/FlowDevice.cpp b/Cantera/src/zeroD/FlowDevice.cpp index 60d9fdeef..084b05f59 100644 --- a/Cantera/src/zeroD/FlowDevice.cpp +++ b/Cantera/src/zeroD/FlowDevice.cpp @@ -22,7 +22,7 @@ namespace CanteraZeroD { m_nspin = mixin->nSpecies(); m_nspout = mixout->nSpecies(); string nm; - int ki, ko; + size_t ki, ko; for (ki = 0; ki < m_nspin; ki++) { nm = mixin->speciesName(ki); ko = mixout->speciesIndex(nm); @@ -45,9 +45,9 @@ namespace CanteraZeroD { * Mass flow rate of outlet species k. Returns zero if this * species is not present in the upstream mixture. */ - doublereal FlowDevice::outletSpeciesMassFlowRate(int k) { + doublereal FlowDevice::outletSpeciesMassFlowRate(size_t k) { if (k < 0 || k >= m_nspout) return 0.0; - int ki = m_out2in[k]; + size_t ki = m_out2in[k]; if (ki < 0) return 0.0; return m_mdot * m_in->massFraction(ki); } diff --git a/Cantera/src/zeroD/FlowDevice.h b/Cantera/src/zeroD/FlowDevice.h index 5ab10f00c..64a30b0d2 100644 --- a/Cantera/src/zeroD/FlowDevice.h +++ b/Cantera/src/zeroD/FlowDevice.h @@ -74,7 +74,7 @@ namespace CanteraZeroD { virtual void updateMassFlowRate(doublereal time) {} // mass flow rate of outlet species k - doublereal outletSpeciesMassFlowRate(int k); + doublereal outletSpeciesMassFlowRate(size_t k); // specific enthalpy doublereal enthalpy_mass(); @@ -162,10 +162,10 @@ namespace CanteraZeroD { private: - int m_nspin, m_nspout; + size_t m_nspin, m_nspout; ReactorBase* m_in; ReactorBase* m_out; - vector_int m_in2out, m_out2in; + std::vector m_in2out, m_out2in; void warn(std::string meth) { writelog(std::string("Warning: method ") + meth + " of base class " diff --git a/Cantera/src/zeroD/FlowReactor.cpp b/Cantera/src/zeroD/FlowReactor.cpp index 66bf62578..5b46dd01f 100644 --- a/Cantera/src/zeroD/FlowReactor.cpp +++ b/Cantera/src/zeroD/FlowReactor.cpp @@ -82,7 +82,7 @@ namespace CanteraZeroD { m_thermo->restoreState(m_state); double mult; - int n, npar; + size_t n, npar; // process sensitivity parameters if (params) { @@ -127,12 +127,12 @@ namespace CanteraZeroD { } - int FlowReactor::componentIndex(string nm) const { + size_t FlowReactor::componentIndex(string nm) const { if (nm == "X") return 0; if (nm == "U") return 1; // check for a gas species name - int k = m_thermo->speciesIndex(nm); - if (k >= 0) return k + 2; + size_t k = m_thermo->speciesIndex(nm); + if (k != -1) return k + 2; else return -1; } diff --git a/Cantera/src/zeroD/FlowReactor.h b/Cantera/src/zeroD/FlowReactor.h index 019910da7..46e0361b0 100644 --- a/Cantera/src/zeroD/FlowReactor.h +++ b/Cantera/src/zeroD/FlowReactor.h @@ -59,7 +59,7 @@ namespace CanteraZeroD { double speed() const { return m_speed; } double distance() const { return m_dist; } - virtual int componentIndex(std::string nm) const; + virtual size_t componentIndex(std::string nm) const; protected: diff --git a/Cantera/src/zeroD/Reactor.cpp b/Cantera/src/zeroD/Reactor.cpp index 668866a96..2413b516e 100644 --- a/Cantera/src/zeroD/Reactor.cpp +++ b/Cantera/src/zeroD/Reactor.cpp @@ -60,9 +60,9 @@ namespace CanteraZeroD { // set the remaining components to the surface species // coverages on the walls - int loc = m_nsp + 2; + size_t loc = m_nsp + 2; SurfPhase* surf; - for (int m = 0; m < m_nwalls; m++) { + for (size_t m = 0; m < m_nwalls; m++) { surf = m_wall[m]->surface(m_lr[m]); if (surf) { m_wall[m]->getCoverages(m_lr[m], y + loc); @@ -79,7 +79,7 @@ namespace CanteraZeroD { m_thermo->restoreState(m_state); m_sdot.resize(m_nsp, 0.0); m_nv = m_nsp + 2; - for (int w = 0; w < m_nwalls; w++) + for (size_t w = 0; w < m_nwalls; w++) if (m_wall[w]->surface(m_lr[w])) m_nv += m_wall[w]->surface(m_lr[w])->nSpecies(); @@ -106,10 +106,10 @@ namespace CanteraZeroD { m_init = true; } - int Reactor::nSensParams() { - if (m_nsens < 0) { + size_t Reactor::nSensParams() { + if (m_nsens == -1) { // determine the number of sensitivity parameters - int m, ns; + size_t m, ns; m_nsens = m_pnum.size(); for (m = 0; m < m_nwalls; m++) { ns = m_wall[m]->nSensParams(m_lr[m]); @@ -151,9 +151,9 @@ namespace CanteraZeroD { } //m_state[0] = temp; - int loc = m_nsp + 2; + size_t loc = m_nsp + 2; SurfPhase* surf; - for (int m = 0; m < m_nwalls; m++) { + for (size_t m = 0; m < m_nwalls; m++) { surf = m_wall[m]->surface(m_lr[m]); if (surf) { // surf->setTemperature(temp); @@ -177,12 +177,12 @@ namespace CanteraZeroD { void Reactor::evalEqs(doublereal time, doublereal* y, doublereal* ydot, doublereal* params) { - int i, k, nk; + size_t i, k, nk; m_time = time; m_thermo->restoreState(m_state); Kinetics* kin; - int m, n, npar, ploc; + size_t m, n, npar, ploc; double mult; // process sensitivity parameters if (params) { @@ -212,7 +212,7 @@ namespace CanteraZeroD { doublereal vdot, rs0, sum, wallarea; // Kinetics* kin; SurfPhase* surf; - int lr, ns, loc = m_nsp+2, surfloc; + size_t lr, ns, loc = m_nsp+2, surfloc; fill(m_sdot.begin(), m_sdot.end(), 0.0); for (i = 0; i < m_nwalls; i++) { lr = 1 - 2*m_lr[i]; @@ -343,17 +343,17 @@ namespace CanteraZeroD { } - int Reactor::componentIndex(string nm) const { + size_t Reactor::componentIndex(string nm) const { if (nm == "U") return 0; if (nm == "V") return 1; // check for a gas species name - int k = m_thermo->speciesIndex(nm); - if (k >= 0) return k + 2; + size_t k = m_thermo->speciesIndex(nm); + if (k != -1) return k + 2; // check for a wall species - int walloffset = 0, kp = 0; + size_t walloffset = 0, kp = 0; thermo_t* th; - for (int m = 0; m < m_nwalls; m++) { + for (size_t m = 0; m < m_nwalls; m++) { if (m_wall[m]->kinetics(m_lr[m])) { kp = m_wall[m]->kinetics(m_lr[m])->reactionPhaseIndex(); th = &m_wall[m]->kinetics(m_lr[m])->thermo(kp); diff --git a/Cantera/src/zeroD/Reactor.h b/Cantera/src/zeroD/Reactor.h index b1b287692..7aa66ecc6 100644 --- a/Cantera/src/zeroD/Reactor.h +++ b/Cantera/src/zeroD/Reactor.h @@ -102,13 +102,13 @@ namespace CanteraZeroD { */ virtual void updateState(doublereal* y); - virtual int nSensParams(); + virtual size_t nSensParams(); virtual void addSensitivityReaction(int rxn); virtual std::string sensParamID(int p) { return m_pname[p]; } // virtual std::string component(int k) const; - virtual int componentIndex(std::string nm) const; + virtual size_t componentIndex(std::string nm) const; protected: @@ -123,12 +123,12 @@ namespace CanteraZeroD { vector_fp m_sdot; // surface production rates bool m_chem; bool m_energy; - int m_nv; + size_t m_nv; - int m_nsens; + size_t m_nsens; vector_int m_pnum; std::vector m_pname; - vector_int m_nsens_wall; + std::vector m_nsens_wall; vector_fp m_mult_save; private: diff --git a/Cantera/src/zeroD/ReactorBase.cpp b/Cantera/src/zeroD/ReactorBase.cpp index 45e33976f..f14f9fe43 100644 --- a/Cantera/src/zeroD/ReactorBase.cpp +++ b/Cantera/src/zeroD/ReactorBase.cpp @@ -64,7 +64,7 @@ namespace CanteraZeroD { m_nwalls++; } - Wall& ReactorBase::wall(int n) { + Wall& ReactorBase::wall(size_t n) { return *m_wall[n]; } @@ -76,7 +76,7 @@ namespace CanteraZeroD { return mass()/mout; } - FlowDevice& ReactorBase::inlet(int n) { return *m_inlet[n]; } - FlowDevice& ReactorBase::outlet(int n) { return *m_outlet[n]; } + FlowDevice& ReactorBase::inlet(size_t n) { return *m_inlet[n]; } + FlowDevice& ReactorBase::outlet(size_t n) { return *m_outlet[n]; } } diff --git a/Cantera/src/zeroD/ReactorBase.h b/Cantera/src/zeroD/ReactorBase.h index b1ab2d43a..e84fb96f2 100644 --- a/Cantera/src/zeroD/ReactorBase.h +++ b/Cantera/src/zeroD/ReactorBase.h @@ -74,15 +74,15 @@ namespace CanteraZeroD { void addInlet(FlowDevice& inlet); void addOutlet(FlowDevice& outlet); - FlowDevice& inlet(int n = 0); - FlowDevice& outlet(int n = 0); + FlowDevice& inlet(size_t n = 0); + FlowDevice& outlet(size_t n = 0); - int nInlets() { return m_inlet.size(); } - int nOutlets() { return m_outlet.size(); } - int nWalls() { return m_wall.size(); } + size_t nInlets() { return m_inlet.size(); } + size_t nOutlets() { return m_outlet.size(); } + size_t nWalls() { return m_wall.size(); } void addWall(Wall& w, int lr); - Wall& wall(int n); + Wall& wall(size_t n); /** * Initialize the reactor. Must be called after specifying the @@ -131,7 +131,7 @@ namespace CanteraZeroD { doublereal pressure() const { return m_pressure; } doublereal mass() const { return m_vol * density(); } const doublereal* massFractions() const { return DATA_PTR(m_state) + 2; } - doublereal massFraction(int k) const { return m_state[k+2]; } + doublereal massFraction(size_t k) const { return m_state[k+2]; } //@} @@ -142,12 +142,12 @@ namespace CanteraZeroD { protected: - int m_nsp; + size_t m_nsp; thermo_t* m_thermo; doublereal m_time; doublereal m_vol, m_vol0; bool m_init; - int m_nInlets, m_nOutlets; + size_t m_nInlets, m_nOutlets; bool m_open; doublereal m_enthalpy; doublereal m_intEnergy; diff --git a/Cantera/src/zeroD/ReactorNet.cpp b/Cantera/src/zeroD/ReactorNet.cpp index 48a02776b..16c924970 100644 --- a/Cantera/src/zeroD/ReactorNet.cpp +++ b/Cantera/src/zeroD/ReactorNet.cpp @@ -40,7 +40,7 @@ namespace CanteraZeroD { } void ReactorNet::initialize(doublereal t0) { - int n, nv; + size_t n, nv; char buf[100]; m_nv = 0; m_reactors.clear(); @@ -79,7 +79,7 @@ namespace CanteraZeroD { m_connect.resize(m_nr*m_nr,0); m_ydot.resize(m_nv,0.0); - int i, j, nin, nout, nw; + size_t i, j, nin, nout, nw; ReactorBase *r, *rj; for (i = 0; i < m_nr; i++) { r = m_reactors[i]; @@ -180,9 +180,9 @@ namespace CanteraZeroD { void ReactorNet::eval(doublereal t, doublereal* y, doublereal* ydot, doublereal* p) { - int n; - int start = 0; - int pstart = 0; + size_t n; + size_t start = 0; + size_t pstart = 0; // use a try... catch block, since exceptions are not passed // through CVODE, since it is C code try { @@ -238,9 +238,8 @@ namespace CanteraZeroD { } void ReactorNet::updateState(doublereal* y) { - int n; - int start = 0; - for (n = 0; n < m_nreactors; n++) { + size_t start = 0; + for (size_t n = 0; n < m_nreactors; n++) { m_reactors[n]->updateState(y + start); start += m_size[n]; } @@ -248,20 +247,18 @@ namespace CanteraZeroD { void ReactorNet::getInitialConditions(doublereal t0, size_t leny, doublereal* y) { - int n; - int start = 0; - for (n = 0; n < m_nreactors; n++) { + size_t start = 0; + for (size_t n = 0; n < m_nreactors; n++) { m_reactors[n]->getInitialConditions(t0, m_size[n], y + start); start += m_size[n]; } } - int ReactorNet::globalComponentIndex(string species, int reactor) { - int start = 0; - int n; + size_t ReactorNet::globalComponentIndex(string species, size_t reactor) { + size_t start = 0; + size_t n; for (n = 0; n < reactor; n++) start += m_size[n]; return start + m_reactors[n]->componentIndex(species); } } - diff --git a/Cantera/src/zeroD/ReactorNet.h b/Cantera/src/zeroD/ReactorNet.h index 11ecd2846..300e0f032 100644 --- a/Cantera/src/zeroD/ReactorNet.h +++ b/Cantera/src/zeroD/ReactorNet.h @@ -92,12 +92,12 @@ namespace CanteraZeroD { void updateState(doublereal* y); - double sensitivity(int k, int p) { + double sensitivity(size_t k, size_t p) { return m_integ->sensitivity(k, p)/m_integ->solution(k); } - double sensitivity(std::string species, int p, int reactor=0) { - int k = globalComponentIndex(species, reactor); + double sensitivity(std::string species, size_t p, int reactor=0) { + size_t k = globalComponentIndex(species, reactor); return sensitivity(k, p); } @@ -112,16 +112,16 @@ namespace CanteraZeroD { doublereal* ydot, doublereal* p); virtual void getInitialConditions(doublereal t0, size_t leny, doublereal* y); - virtual int nparams() { return m_ntotpar; } + virtual size_t nparams() { return m_ntotpar; } - int globalComponentIndex(std::string species, int reactor=0); + size_t globalComponentIndex(std::string species, size_t reactor=0); - void connect(int i, int j) { + void connect(size_t i, size_t j) { m_connect[j*m_nr + i] = 1; m_connect[i*m_nr + j] = 1; } - bool connected(int i, int j) { + bool connected(size_t i, size_t j) { return (m_connect[m_nr*i + j] == 1); } @@ -129,20 +129,20 @@ namespace CanteraZeroD { std::vector m_r; std::vector m_reactors; - int m_nr; - int m_nreactors; + size_t m_nr; + size_t m_nreactors; Integrator* m_integ; doublereal m_time; bool m_init; - int m_nv; - vector_int m_size; + size_t m_nv; + std::vector m_size; vector_fp m_atol; doublereal m_rtol, m_rtolsens; doublereal m_atols, m_atolsens; doublereal m_maxstep; bool m_verbose; - int m_ntotpar; - vector_int m_nparams; + size_t m_ntotpar; + std::vector m_nparams; vector_int m_connect; vector_fp m_ydot; diff --git a/Cantera/src/zeroD/Wall.cpp b/Cantera/src/zeroD/Wall.cpp index 2cfd91e46..9aebc3823 100644 --- a/Cantera/src/zeroD/Wall.cpp +++ b/Cantera/src/zeroD/Wall.cpp @@ -40,10 +40,10 @@ namespace CanteraZeroD { void Wall::setKinetics(Kinetics* left, Kinetics* right) { m_chem[0] = left; m_chem[1] = right; - int ileft = 0, iright = 0; + size_t ileft = 0, iright = 0; if (left) { ileft = left->surfacePhaseIndex(); - if (ileft >= 0) { + if (ileft != -1) { 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 >= 0) { + if (iright != -1) { 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 < 0 || iright < 0) { + if (ileft == -1 || iright == -1) { throw CanteraError("Wall::setKinetics", "specified surface kinetics manager does not " "represent a surface reaction mechanism."); @@ -138,7 +138,7 @@ namespace CanteraZeroD { void Wall::setSensitivityParameters(int lr, double* params) { // process sensitivity parameters - int n, npar; + size_t n, npar; if (lr == 0) { npar = m_pleft.size(); for (n = 0; n < npar; n++) { @@ -158,7 +158,7 @@ namespace CanteraZeroD { } void Wall::resetSensitivityParameters(int lr) { - int n, npar; + size_t n, npar; if (lr == 0) { npar = m_pleft.size(); for (n = 0; n < npar; n++) { diff --git a/Cantera/src/zeroD/Wall.h b/Cantera/src/zeroD/Wall.h index 79097ed5a..1aa8199d0 100644 --- a/Cantera/src/zeroD/Wall.h +++ b/Cantera/src/zeroD/Wall.h @@ -124,7 +124,7 @@ namespace CanteraZeroD { void syncCoverages(int leftright); - int nSensParams(int lr) const { + size_t nSensParams(int lr) const { if (lr == 0) return m_pleft.size(); else @@ -150,7 +150,7 @@ namespace CanteraZeroD { ReactorBase* m_right; Cantera::Kinetics * m_chem[2]; Cantera::SurfPhase* m_surf[2]; - int m_nsp[2]; + size_t m_nsp[2]; doublereal m_area, m_k, m_rrth; doublereal m_emiss; Cantera::Func1 *m_vf; diff --git a/apps/bvp/AxiStagnBVP.cpp b/apps/bvp/AxiStagnBVP.cpp index b094e35f3..c2739d8fb 100644 --- a/apps/bvp/AxiStagnBVP.cpp +++ b/apps/bvp/AxiStagnBVP.cpp @@ -105,7 +105,7 @@ void StFlow::setGasAtMidpoint(const doublereal* x,int j) { // Specify the residual. This is where the ODE system and boundary // conditions are specified. The solver will attempt to find a solution // x so that this function returns 0 for all n and j. -doublereal AxiStagnFlow::residual(doublereal* x, int n, int j) { +doublereal AxiStagnFlow::residual(doublereal* x, size_t n, size_t j) { // if n = 0, return the residual for the continuity equation if (n == 0) { diff --git a/apps/bvp/AxiStagnBVP.h b/apps/bvp/AxiStagnBVP.h index 4f53eb670..ddc65702f 100644 --- a/apps/bvp/AxiStagnBVP.h +++ b/apps/bvp/AxiStagnBVP.h @@ -79,7 +79,7 @@ public: // Specify the residual. This is where the ODE system and boundary // conditions are specified. The solver will attempt to find a solution // x so that this function returns 0 for all n and j. - virtual doublereal residual(doublereal* x, int n, int j) { + virtual doublereal residual(doublereal* x, size_t n, size_t j) { // if n = 0, return the residual for the first ODE if (n == 0) { diff --git a/apps/bvp/blasius.cpp b/apps/bvp/blasius.cpp index dd9215c38..5b09cd991 100644 --- a/apps/bvp/blasius.cpp +++ b/apps/bvp/blasius.cpp @@ -67,7 +67,7 @@ public: // Specify the residual. This is where the ODE system and boundary // conditions are specified. The solver will attempt to find a solution // x so that this function returns 0 for all n and j. - virtual doublereal residual(doublereal* x, int n, int j) { + virtual doublereal residual(doublereal* x, size_t n, size_t j) { // if n = 0, return the residual for the first ODE if (n == 0) { diff --git a/apps/bvp/stagnation.cpp b/apps/bvp/stagnation.cpp index e000d23b1..983906224 100644 --- a/apps/bvp/stagnation.cpp +++ b/apps/bvp/stagnation.cpp @@ -125,7 +125,7 @@ AxiStagnBVP::AxiStagnBVP(igthermo_t* ph, int nsp, int points) : /** * Change the grid size. Called after grid refinement. */ - void AxiStagnBVP::resize(int ncomponents, int points) { + void AxiStagnBVP::resize(size_t ncomponents, size_t points) { Domain1D::resize(ncomponents, points); m_rho.resize(m_points, 0.0); m_wtm.resize(m_points, 0.0); diff --git a/tools/testtools/tok_input_util.cpp b/tools/testtools/tok_input_util.cpp index c3c67908c..c9dbb721b 100644 --- a/tools/testtools/tok_input_util.cpp +++ b/tools/testtools/tok_input_util.cpp @@ -1529,15 +1529,15 @@ void strip_item_from_token(int iword, TOKEN *tok) #ifdef WIN32 __w64 int ioffset = tok->tok_ptr[iword] - tok->tok_str; #else - int ioffset = tok->tok_ptr[iword] - tok->tok_str; + size_t ioffset = tok->tok_ptr[iword] - tok->tok_str; #endif size_t ilength = strlen(tok->tok_ptr[iword]); #ifdef WIN32 __w64 int i = ioffset; __w64 int j = ioffset + ilength; #else - int i = ioffset; - int j = ioffset + ilength; + size_t i = ioffset; + size_t j = ioffset + ilength; #endif if (j <= (int) strlen(tok->orig_str)) { while(tok->orig_str[j] != '\0') {