From e8b04fb2b46953faf42b8ddbbff6192eded4d32f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 17 Feb 2012 20:29:10 +0000 Subject: [PATCH] Fixed numerous compiler warnings from MSVC --- include/cantera/base/Array.h | 2 +- include/cantera/base/mdp_allo.h | 7 +- include/cantera/base/stringUtils.h | 6 + include/cantera/base/utilities.h | 25 +- include/cantera/numerics/BandMatrix.h | 6 +- include/cantera/numerics/DenseMatrix.h | 6 +- include/cantera/numerics/GeneralMatrix.h | 4 +- include/cantera/numerics/NonlinearSolver.h | 2 +- include/cantera/numerics/SquareMatrix.h | 4 +- include/cantera/numerics/ctlapack.h | 85 +++--- include/cantera/numerics/solveProb.h | 12 +- include/cantera/thermo/Constituents.h | 6 +- include/cantera/thermo/Elements.h | 2 +- include/cantera/thermo/GibbsExcessVPSSTP.h | 4 +- .../cantera/thermo/IonsFromNeutralVPSSTP.h | 2 +- include/cantera/thermo/LatticeSolidPhase.h | 8 +- include/cantera/thermo/MargulesVPSSTP.h | 2 +- .../cantera/thermo/MixedSolventElectrolyte.h | 8 +- include/cantera/thermo/MolalityVPSSTP.h | 2 +- include/cantera/thermo/MolarityIonicVPSSTP.h | 6 +- .../cantera/thermo/PhaseCombo_Interaction.h | 4 +- include/cantera/thermo/ThermoPhase.h | 6 +- include/cantera/transport/LiquidTransport.h | 2 +- include/cantera/transport/MixTransport.h | 4 +- include/cantera/transport/TransportBase.h | 4 +- src/base/ctml.cpp | 12 +- src/base/mdp_allo.cpp | 2 - src/base/stringUtils.cpp | 13 +- src/equil/vcs_MultiPhaseEquil.cpp | 6 +- src/equil/vcs_VolPhase.cpp | 7 +- src/equil/vcs_VolPhase.h | 6 +- src/equil/vcs_internal.h | 2 +- src/equil/vcs_phaseStability.cpp | 48 ++-- src/equil/vcs_rxnadj.cpp | 4 +- src/equil/vcs_solve.cpp | 2 +- src/equil/vcs_solve.h | 6 +- src/equil/vcs_solve_TP.cpp | 14 +- src/equil/vcs_solve_phaseStability.cpp | 12 +- src/equil/vcs_util.cpp | 32 +-- src/kinetics/InterfaceKinetics.cpp | 5 +- src/numerics/BandMatrix.cpp | 6 +- src/numerics/DenseMatrix.cpp | 43 ++-- src/numerics/NonlinearSolver.cpp | 46 ++-- src/numerics/SquareMatrix.cpp | 10 +- src/numerics/solveProb.cpp | 28 +- src/thermo/Constituents.cpp | 14 +- src/thermo/Elements.cpp | 2 +- src/thermo/FixedChemPotSSTP.cpp | 3 +- src/thermo/IonsFromNeutralVPSSTP.cpp | 4 +- src/thermo/LatticeSolidPhase.cpp | 16 +- src/thermo/MargulesVPSSTP.cpp | 14 +- src/thermo/MixedSolventElectrolyte.cpp | 32 +-- src/thermo/MolarityIonicVPSSTP.cpp | 8 +- src/thermo/PhaseCombo_Interaction.cpp | 41 ++- src/thermo/RedlichKisterVPSSTP.cpp | 42 +-- src/thermo/RedlichKisterVPSSTP.h | 8 +- src/thermo/ThermoPhase.cpp | 8 +- src/transport/LiquidTranInteraction.cpp | 241 +++++++++--------- src/transport/LiquidTransport.cpp | 4 +- src/transport/SimpleTransport.cpp | 20 +- src/transport/SolidTransport.cpp | 4 +- src/transport/TransportBase.cpp | 4 +- src/transport/TransportFactory.cpp | 22 +- 63 files changed, 493 insertions(+), 517 deletions(-) diff --git a/include/cantera/base/Array.h b/include/cantera/base/Array.h index ac0a4a073..7a51aa0e2 100644 --- a/include/cantera/base/Array.h +++ b/include/cantera/base/Array.h @@ -238,7 +238,7 @@ public: //! Set all of the entries to zero inline void zero() { - int nn = m_nrows * m_ncols; + size_t nn = m_nrows * m_ncols; if (nn > 0) { /* * Using memset is the fastest way to zero a contiguous diff --git a/include/cantera/base/mdp_allo.h b/include/cantera/base/mdp_allo.h index 925aee73b..458062578 100644 --- a/include/cantera/base/mdp_allo.h +++ b/include/cantera/base/mdp_allo.h @@ -715,13 +715,13 @@ extern void mdp_init_int_1(int* const v, const int value, const int len); * * @param tmp number to be checked */ -extern void checkZeroFinite(const double tmp) throw(std::range_error); +extern void checkZeroFinite(const double tmp); //! Utility routine to check to see that a number is finite. /*! * @param tmp number to be checked */ -extern void checkFinite(const double tmp) throw(std::range_error); +extern void checkFinite(const double tmp); //! Utility routine to link checkFinte() to fortran program /*! @@ -741,8 +741,7 @@ extern "C" void checkfinite_(double* tmp); * @param tmp Number to be checked * @param trigger bounds on the number. Defaults to 1.0E20 */ -extern void checkMagnitude(const double tmp, const double trigger = 1.0E20) -throw(std::range_error); +extern void checkMagnitude(const double tmp, const double trigger = 1.0E20); } /* end of mdp namespace */ /****************************************************************************/ diff --git a/include/cantera/base/stringUtils.h b/include/cantera/base/stringUtils.h index 21a12abf4..8e8ca9ce3 100644 --- a/include/cantera/base/stringUtils.h +++ b/include/cantera/base/stringUtils.h @@ -50,6 +50,12 @@ std::string int2str(const int n, const std::string& fmt); */ std::string int2str(const int n); +//! Convert an unsigned integer to a string +/*! + * @param n int to be converted + */ +std::string int2str(const size_t n); + //! Strip the leading and trailing white space //! from a string /*! diff --git a/include/cantera/base/utilities.h b/include/cantera/base/utilities.h index 8431b1389..a6a7eddaf 100644 --- a/include/cantera/base/utilities.h +++ b/include/cantera/base/utilities.h @@ -707,39 +707,20 @@ R poly3(D x, R* c) template void deepStdVectorPointerCopy(const std::vector &fromVec, std::vector &toVec) { - int is = toVec.size(); - for (int i = 0; i < is; is++) { + size_t is = toVec.size(); + for (size_t i = 0; i < is; is++) { if (toVec[i]) { delete(toVec[i]); } } is = fromVec.size(); toVec.resize(is); - for (int i = 0; i < is; is++) { + for (size_t i = 0; i < is; is++) { toVec[i] = new D(*(fromVec[i])); } } - //@} } - #endif - - - - - - - - - - - - - - - - - diff --git a/include/cantera/numerics/BandMatrix.h b/include/cantera/numerics/BandMatrix.h index 052e5af0e..2b63c4c5f 100644 --- a/include/cantera/numerics/BandMatrix.h +++ b/include/cantera/numerics/BandMatrix.h @@ -165,7 +165,7 @@ public: * * @return returns the number of rows and columns in the matrix. */ - virtual size_t nRowsAndStruct(int* const iStruct = 0) const; + virtual size_t nRowsAndStruct(size_t* const iStruct = 0) const; //! Number of columns size_t nColumns() const; @@ -190,7 +190,7 @@ public: * @param b Vector to do the rh multiplcation * @param prod OUTPUT vector to receive the result */ - virtual void mult(const doublereal* const b, doublereal* const prod) const; + virtual void mult(const doublereal* b, doublereal* prod) const; //! Multiply b*A and write result to prod. /*! @@ -231,7 +231,7 @@ public: * 0 indicates a success * ~0 Some error occurred, see the LAPACK documentation */ - int solve(doublereal* const b); + int solve(doublereal* b); //! Returns an iterator for the start of the band storage data diff --git a/include/cantera/numerics/DenseMatrix.h b/include/cantera/numerics/DenseMatrix.h index 3a89e1fba..b503f95c4 100644 --- a/include/cantera/numerics/DenseMatrix.h +++ b/include/cantera/numerics/DenseMatrix.h @@ -83,7 +83,7 @@ public: * @param m New number of columns * @param v Default fill value. defaults to zero. */ - DenseMatrix(int n, int m, doublereal v = 0.0); + DenseMatrix(size_t n, size_t m, doublereal v = 0.0); //! Copy constructor /*! @@ -108,7 +108,7 @@ public: * @param m New number of columns * @param v Default fill value. defaults to zero. */ - void resize(int n, int m, doublereal v = 0.0); + void resize(size_t n, size_t m, doublereal v = 0.0); //! Return a vector of const pointers to the columns /*! @@ -269,7 +269,7 @@ void increment(const DenseMatrix& A, const double* const b, double* const prod); * @param nn Size of A. This defaults to -1, which means that the number * of rows is used as the default size of n */ -int invert(DenseMatrix& A, int nn=-1); +int invert(DenseMatrix& A, size_t nn=npos); } diff --git a/include/cantera/numerics/GeneralMatrix.h b/include/cantera/numerics/GeneralMatrix.h index 25430f74a..1be0f1b67 100644 --- a/include/cantera/numerics/GeneralMatrix.h +++ b/include/cantera/numerics/GeneralMatrix.h @@ -69,7 +69,7 @@ public: * @param b Vector to do the rh multiplcation * @param prod OUTPUT vector to receive the result */ - virtual void mult(const doublereal* const b, doublereal* const prod) const = 0; + virtual void mult(const doublereal* b, doublereal* prod) const = 0; //! Multiply b*A and write result to prod. /*! @@ -143,7 +143,7 @@ public: * * @return returns the number of rows and columns in the matrix. */ - virtual size_t nRowsAndStruct(int* const iStruct = 0) const = 0; + virtual size_t nRowsAndStruct(size_t* const iStruct = 0) const = 0; //! clear the factored flag virtual void clearFactorFlag() = 0; diff --git a/include/cantera/numerics/NonlinearSolver.h b/include/cantera/numerics/NonlinearSolver.h index cf67d02e8..0952f660d 100644 --- a/include/cantera/numerics/NonlinearSolver.h +++ b/include/cantera/numerics/NonlinearSolver.h @@ -929,7 +929,7 @@ private: int solnType_; //! Local copy of the number of equations - int neq_; + size_t neq_; //! Soln error weights std::vector m_ewt; diff --git a/include/cantera/numerics/SquareMatrix.h b/include/cantera/numerics/SquareMatrix.h index 69b745d7f..92798e71c 100644 --- a/include/cantera/numerics/SquareMatrix.h +++ b/include/cantera/numerics/SquareMatrix.h @@ -88,7 +88,7 @@ public: * @param b Vector to do the rh multiplcation * @param prod OUTPUT vector to receive the result */ - virtual void mult(const doublereal* const b, doublereal* const prod) const; + virtual void mult(const doublereal* b, doublereal* prod) const; //! Multiply b*A and write result to prod. /*! @@ -216,7 +216,7 @@ public: * * @return returns the number of rows and columns in the matrix. */ - size_t nRowsAndStruct(int* const iStruct = 0) const; + size_t nRowsAndStruct(size_t* const iStruct = 0) const; //! Duplicate this object virtual GeneralMatrix* duplMyselfAsGeneralMatrix() const; diff --git a/include/cantera/numerics/ctlapack.h b/include/cantera/numerics/ctlapack.h index 81b0f69c8..327dece0f 100644 --- a/include/cantera/numerics/ctlapack.h +++ b/include/cantera/numerics/ctlapack.h @@ -395,30 +395,30 @@ inline void ct_dscal(int n, doublereal da, doublereal* dx, int incx) cblas_dscal(n, da, dx, incx); } //==================================================================================================================== -inline void ct_dgeqrf(int m, int n, doublereal* a, int lda, doublereal* tau, - doublereal* work, int lwork, int& info) +inline void ct_dgeqrf(size_t m, size_t n, doublereal* a, size_t lda, doublereal* tau, + doublereal* work, size_t lwork, int& info) { - integer f_m = m; - integer f_n = n; - integer f_lda = lda; - integer f_lwork = lwork; + integer f_m = static_cast(m); + integer f_n = static_cast(n); + integer f_lda = static_cast(lda); + integer f_lwork = static_cast(lwork); integer f_info = info; _DGEQRF_(&f_m, &f_n, a, &f_lda, tau, work, &f_lwork, &f_info); info = f_info; } //==================================================================================================================== -inline void ct_dormqr(ctlapack::side_t rlside, ctlapack::transpose_t trans, int m, - int n, int k, doublereal* a, int lda, doublereal* tau, doublereal* c, int ldc, +inline void ct_dormqr(ctlapack::side_t rlside, ctlapack::transpose_t trans, size_t m, + size_t n, size_t k, doublereal* a, size_t lda, doublereal* tau, doublereal* c, size_t ldc, doublereal* work, size_t lwork, int& info) { char side = left_right[rlside]; char tr = no_yes[trans]; - integer f_m = m; - integer f_n = n; - integer f_k = k; + integer f_m = static_cast(m); + integer f_n = static_cast(n); + integer f_k = static_cast(k); integer f_lwork = static_cast(lwork); - integer f_lda = lda; - integer f_ldc = ldc; + integer f_lda = static_cast(lda); + integer f_ldc = static_cast(ldc); integer f_info = info; #ifdef NO_FTN_STRING_LEN_AT_END _DORMQR_(&side, &tr, &f_m, &f_n, &f_k, a, &f_lda, tau, c, &f_ldc, work, &f_lwork, &f_info); @@ -434,7 +434,7 @@ inline void ct_dormqr(ctlapack::side_t rlside, ctlapack::transpose_t trans, int } //==================================================================================================================== inline void ct_dtrtrs(ctlapack::upperlower_t uplot, ctlapack::transpose_t trans, const char* diag, - int n, int nrhs, doublereal* a, int lda, doublereal* b, int ldb, int& info) + size_t n, size_t nrhs, doublereal* a, size_t lda, doublereal* b, size_t ldb, int& info) { char uplo = upper_lower[uplot]; char tr = no_yes[trans]; @@ -442,10 +442,10 @@ inline void ct_dtrtrs(ctlapack::upperlower_t uplot, ctlapack::transpose_t trans, if (diag) { dd = diag[0]; } - integer f_n = n; - integer f_nrhs = nrhs; - integer f_lda = lda; - integer f_ldb = ldb; + integer f_n = static_cast(n); + integer f_nrhs = static_cast(nrhs); + integer f_lda = static_cast(lda); + integer f_ldb = static_cast(ldb); integer f_info = info; #ifdef NO_FTN_STRING_LEN_AT_END _DTRTRS_(&uplo, &tr, &dd, &f_n, &f_nrhs, a, &f_lda, b, &f_ldb, &f_info); @@ -466,7 +466,7 @@ inline void ct_dtrtrs(ctlapack::upperlower_t uplot, ctlapack::transpose_t trans, * @param iwork Must be dimensioned equal to or greater than N */ inline doublereal ct_dtrcon(const char* norm, ctlapack::upperlower_t uplot, const char* diag, - int n, doublereal* a, int lda, doublereal* work, int* iwork, int& info) + size_t n, doublereal* a, size_t lda, doublereal* work, int* iwork, int& info) { char uplo = upper_lower[uplot]; char dd = 'N'; @@ -477,8 +477,8 @@ inline doublereal ct_dtrcon(const char* norm, ctlapack::upperlower_t uplot, con if (norm) { nn = norm[0]; } - integer f_n = n; - integer f_lda = lda; + integer f_n = static_cast(n); + integer f_lda = static_cast(lda); integer f_info = info; doublereal rcond; #ifdef NO_FTN_STRING_LEN_AT_END @@ -500,11 +500,11 @@ inline doublereal ct_dtrcon(const char* norm, ctlapack::upperlower_t uplot, con * @param work Must be dimensioned equal to greater than 3N * @param iwork Must be dimensioned equal to or greater than N */ -inline void ct_dpotrf(ctlapack::upperlower_t uplot, int n, doublereal* a, int lda, int& info) +inline void ct_dpotrf(ctlapack::upperlower_t uplot, size_t n, doublereal* a, size_t lda, int& info) { char uplo = upper_lower[uplot]; - integer f_n = n; - integer f_lda = lda; + integer f_n = static_cast(n); + integer f_lda = static_cast(lda); integer f_info = info; #ifdef NO_FTN_STRING_LEN_AT_END @@ -524,14 +524,14 @@ inline void ct_dpotrf(ctlapack::upperlower_t uplot, int n, doublereal* a, int ld //! /*! */ -inline void ct_dpotrs(ctlapack::upperlower_t uplot, int n, int nrhs, doublereal* a, int lda, - doublereal* b, int ldb, int& info) +inline void ct_dpotrs(ctlapack::upperlower_t uplot, size_t n, size_t nrhs, doublereal* a, size_t lda, + doublereal* b, size_t ldb, int& info) { char uplo = upper_lower[uplot]; - integer f_n = n; - integer f_nrhs = nrhs; - integer f_lda = lda; - integer f_ldb = ldb; + integer f_n = static_cast(n); + integer f_nrhs = static_cast(nrhs); + integer f_lda = static_cast(lda); + integer f_ldb = static_cast(ldb); integer f_info = info; #ifdef NO_FTN_STRING_LEN_AT_END @@ -552,15 +552,15 @@ inline void ct_dpotrs(ctlapack::upperlower_t uplot, int n, int nrhs, doublereal* //! /*! */ -inline doublereal ct_dgecon(const char norm, int n, doublereal* a, int lda, doublereal anorm, +inline doublereal ct_dgecon(const char norm, size_t n, doublereal* a, size_t lda, doublereal anorm, doublereal* work, int* iwork, int& info) { char cnorm = '1'; if (norm) { cnorm = norm; } - integer f_n = n; - integer f_lda = lda; + integer f_n = static_cast(n); + integer f_lda = static_cast(lda); integer f_info = info; doublereal rcond; @@ -582,17 +582,18 @@ inline doublereal ct_dgecon(const char norm, int n, doublereal* a, int lda, doub //! /*! */ -inline doublereal ct_dgbcon(const char norm, int n, int kl, int ku, doublereal* a, int ldab, int* ipiv, doublereal anorm, +inline doublereal ct_dgbcon(const char norm, size_t n, size_t kl, size_t ku, + doublereal* a, size_t ldab, int* ipiv, doublereal anorm, doublereal* work, int* iwork, int& info) { char cnorm = '1'; if (norm) { cnorm = norm; } - integer f_n = n; - integer f_kl = kl; - integer f_ku = ku; - integer f_ldab = ldab; + integer f_n = static_cast(n); + integer f_kl = static_cast(kl); + integer f_ku = static_cast(ku); + integer f_ldab = static_cast(ldab); integer f_info = info; doublereal rcond; @@ -614,16 +615,16 @@ inline doublereal ct_dgbcon(const char norm, int n, int kl, int ku, doublereal* //! /*! */ -inline doublereal ct_dlange(const char norm, int m, int n, doublereal* a, int lda, +inline doublereal ct_dlange(const char norm, size_t m, size_t n, doublereal* a, size_t lda, doublereal* work) { char cnorm = '1'; if (norm) { cnorm = norm; } - integer f_m = m; - integer f_n = n; - integer f_lda = lda; + integer f_m = static_cast(m); + integer f_n = static_cast(n); + integer f_lda = static_cast(lda); doublereal anorm; #ifdef NO_FTN_STRING_LEN_AT_END diff --git a/include/cantera/numerics/solveProb.h b/include/cantera/numerics/solveProb.h index 88437e4ba..a222c1e7b 100644 --- a/include/cantera/numerics/solveProb.h +++ b/include/cantera/numerics/solveProb.h @@ -232,25 +232,25 @@ private: #endif //! Printing routine that gets called after every iteration - virtual void printIteration(int ioflag, doublereal damp, int label_d, int label_t, + virtual void printIteration(int ioflag, doublereal damp, int label_d, size_t label_t, doublereal inv_t, doublereal t_real, int iter, doublereal update_norm, doublereal resid_norm, doublereal netProdRate[], doublereal CSolnSP[], doublereal resid[], - doublereal wtSpecies[], int dim, bool do_time); + doublereal wtSpecies[], size_t dim, bool do_time); //! Print a summary of the solution /*! * */ - virtual void printFinal(int ioflag, doublereal damp, int label_d, int label_t, + virtual void printFinal(int ioflag, doublereal damp, int label_d, size_t label_t, doublereal inv_t, doublereal t_real, int iter, doublereal update_norm, doublereal resid_norm, doublereal netProdRateKinSpecies[], const doublereal CSolnSP[], const doublereal resid[], const doublereal wtSpecies[], const doublereal wtRes[], - int dim, bool do_time); + size_t dim, bool do_time); //! Calculate a conservative delta T to use in a pseudo-steady state //! algorithm @@ -284,7 +284,7 @@ private: * @return Returns the 1. / delta T to be used on the next step */ virtual doublereal calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[], - int* label, int* label_old, + size_t* label, size_t* label_old, doublereal* label_factor, int ioflag); //! Calculate the solution and residual weights @@ -364,7 +364,7 @@ private: * @param dim Size of the solution vector * @param label return int, stating which solution component caused the most damping. */ - virtual doublereal calc_damping(doublereal x[], doublereal dxneg[], int dim, int* label); + virtual doublereal calc_damping(doublereal x[], doublereal dxneg[], size_t dim, int* label); //! residual function pointer to be solved. ResidEval* m_residFunc; diff --git a/include/cantera/thermo/Constituents.h b/include/cantera/thermo/Constituents.h index 850d4d806..95170a8f4 100644 --- a/include/cantera/thermo/Constituents.h +++ b/include/cantera/thermo/Constituents.h @@ -137,7 +137,7 @@ public: */ int atomicNumber(size_t m) const; - int elementType(int m) const; + int elementType(size_t m) const; /// Return a read-only reference to the vector of element names. const std::vector& elementNames() const; @@ -232,8 +232,8 @@ public: * @param elem_type Specifies the type of the element constraint equation. This defaults * to CT_ELEM_TYPE_ABSPOS, i.e., an element. */ - int addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, - doublereal entropy298 = ENTROPY298_UNKNOWN, int elem_type = CT_ELEM_TYPE_ABSPOS); + size_t addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, + doublereal entropy298 = ENTROPY298_UNKNOWN, int elem_type = CT_ELEM_TYPE_ABSPOS); //@} diff --git a/include/cantera/thermo/Elements.h b/include/cantera/thermo/Elements.h index 175f9c378..780627739 100644 --- a/include/cantera/thermo/Elements.h +++ b/include/cantera/thermo/Elements.h @@ -205,7 +205,7 @@ public: * * @return Returns the element type */ - int elementType(int m) const; + int elementType(size_t m) const; //! Change the element type of the mth constraint /*! diff --git a/include/cantera/thermo/GibbsExcessVPSSTP.h b/include/cantera/thermo/GibbsExcessVPSSTP.h index 5a000d4fe..3d34ce5de 100644 --- a/include/cantera/thermo/GibbsExcessVPSSTP.h +++ b/include/cantera/thermo/GibbsExcessVPSSTP.h @@ -332,7 +332,7 @@ public: /*! * @param lnac Output vector of ln activity coefficients. Length: m_kk. */ - virtual void getActivityCoefficients(doublereal* const ac) const; + virtual void getActivityCoefficients(doublereal* ac) const; //! Get the array of temperature derivatives of the log activity coefficients @@ -368,7 +368,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) { + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) { err(" getdlnActCoeffdlnN: nonzero and nonimplemented"); } diff --git a/include/cantera/thermo/IonsFromNeutralVPSSTP.h b/include/cantera/thermo/IonsFromNeutralVPSSTP.h index 435fbe586..66da5fd31 100644 --- a/include/cantera/thermo/IonsFromNeutralVPSSTP.h +++ b/include/cantera/thermo/IonsFromNeutralVPSSTP.h @@ -391,7 +391,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) ; + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ; //! Get the Salt Dissociation Coefficients diff --git a/include/cantera/thermo/LatticeSolidPhase.h b/include/cantera/thermo/LatticeSolidPhase.h index a75b94c6e..baf3c19c5 100644 --- a/include/cantera/thermo/LatticeSolidPhase.h +++ b/include/cantera/thermo/LatticeSolidPhase.h @@ -165,7 +165,7 @@ public: * @param k index of the species. Default is -1, which will return the max of the min value * over all species. */ - virtual doublereal minTemp(int k = -1) const; + virtual doublereal minTemp(size_t k = npos) const; //! Maximum temperature for which the thermodynamic data for the species //! are valid. @@ -179,7 +179,7 @@ public: * @param k index of the species. Default is -1, which will return the min of the max value * over all species. */ - virtual doublereal maxTemp(int k = -1) const; + virtual doublereal maxTemp(size_t k = npos) const; //! Returns the reference pressure in Pa. This function is a wrapper @@ -715,9 +715,7 @@ protected: //! Temporary vector mutable vector_fp tmpV_; - std::vector nspLattice_; - - std::vector lkstart_; + std::vector lkstart_; private: diff --git a/include/cantera/thermo/MargulesVPSSTP.h b/include/cantera/thermo/MargulesVPSSTP.h index f72d8cca3..c4b430999 100644 --- a/include/cantera/thermo/MargulesVPSSTP.h +++ b/include/cantera/thermo/MargulesVPSSTP.h @@ -801,7 +801,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) ; + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ; //@} diff --git a/include/cantera/thermo/MixedSolventElectrolyte.h b/include/cantera/thermo/MixedSolventElectrolyte.h index 57be8bffd..fae09593e 100644 --- a/include/cantera/thermo/MixedSolventElectrolyte.h +++ b/include/cantera/thermo/MixedSolventElectrolyte.h @@ -806,7 +806,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) ; + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ; //@} @@ -829,7 +829,7 @@ private: /*! * @param num Number of binary Margules interaction terms */ - void resizeNumInteractions(const int num); + void resizeNumInteractions(const size_t num); //! Initialize lengths of local variables after all species have @@ -948,14 +948,14 @@ protected: * Each Margules excess Gibbs free energy term involves two species, A and B. * This vector identifies species A. */ - vector_int m_pSpecies_A_ij; + std::vector m_pSpecies_A_ij; //! vector of species indices representing species B in the interaction /*! * Each Margules excess Gibbs free energy term involves two species, A and B. * This vector identifies species B. */ - vector_int m_pSpecies_B_ij; + std::vector m_pSpecies_B_ij; //! form of the Margules interaction expression /*! diff --git a/include/cantera/thermo/MolalityVPSSTP.h b/include/cantera/thermo/MolalityVPSSTP.h index b7858dba6..a89ead41d 100644 --- a/include/cantera/thermo/MolalityVPSSTP.h +++ b/include/cantera/thermo/MolalityVPSSTP.h @@ -810,7 +810,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) { + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) { getdlnActCoeffdlnN_numderiv(ld, dlnActCoeffdlnN); } diff --git a/include/cantera/thermo/MolarityIonicVPSSTP.h b/include/cantera/thermo/MolarityIonicVPSSTP.h index 4567c9ffa..dfd57e273 100644 --- a/include/cantera/thermo/MolarityIonicVPSSTP.h +++ b/include/cantera/thermo/MolarityIonicVPSSTP.h @@ -515,15 +515,15 @@ protected: mutable std::vector PBMoleFractions_; //! Vector of cation indecises in the mixture - std::vector cationList_; + std::vector cationList_; //! Number of cations in the mixture size_t numCationSpecies_; - std::vector anionList_; + std::vector anionList_; size_t numAnionSpecies_; - std::vector passThroughList_; + std::vector passThroughList_; size_t numPassThroughSpecies_; size_t neutralPBindexStart; diff --git a/include/cantera/thermo/PhaseCombo_Interaction.h b/include/cantera/thermo/PhaseCombo_Interaction.h index 9dec6b998..37137d649 100644 --- a/include/cantera/thermo/PhaseCombo_Interaction.h +++ b/include/cantera/thermo/PhaseCombo_Interaction.h @@ -802,7 +802,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN); + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN); //@} @@ -825,7 +825,7 @@ private: /*! * @param num Number of binary Margules interaction terms */ - void resizeNumInteractions(const int num); + void resizeNumInteractions(const size_t num); //! Initialize lengths of local variables after all species have diff --git a/include/cantera/thermo/ThermoPhase.h b/include/cantera/thermo/ThermoPhase.h index d9c647824..8eff52ed9 100644 --- a/include/cantera/thermo/ThermoPhase.h +++ b/include/cantera/thermo/ThermoPhase.h @@ -1160,7 +1160,7 @@ public: /*! * @param lnac Output vector of ln activity coefficients. Length: m_kk. */ - virtual void getLnActivityCoefficients(doublereal* const lnac) const; + virtual void getLnActivityCoefficients(doublereal* lnac) const; //@} /// @name Partial Molar Properties of the Solution @@ -2198,9 +2198,9 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN); + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN); - virtual void getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dlnActCoeffdlnN); + virtual void getdlnActCoeffdlnN_numderiv(const size_t ld, doublereal* const dlnActCoeffdlnN); /** * @} diff --git a/include/cantera/transport/LiquidTransport.h b/include/cantera/transport/LiquidTransport.h index b35bde925..a05e5a4d0 100644 --- a/include/cantera/transport/LiquidTransport.h +++ b/include/cantera/transport/LiquidTransport.h @@ -591,7 +591,7 @@ public: * Flat vector with the m_nsp in the inner loop. * length = ldx * ndim */ - virtual void getSpeciesFluxes(int ndim, const doublereal* const grad_T, + virtual void getSpeciesFluxes(size_t ndim, const doublereal* const grad_T, int ldx, const doublereal* const grad_X, int ldf, doublereal* const fluxes); diff --git a/include/cantera/transport/MixTransport.h b/include/cantera/transport/MixTransport.h index 86bd40c59..52b5d4d77 100644 --- a/include/cantera/transport/MixTransport.h +++ b/include/cantera/transport/MixTransport.h @@ -144,7 +144,7 @@ public: /*! * @param visc Vector of species viscosities */ - virtual void getSpeciesViscosities(doublereal* visc) { + virtual void getSpeciesViscosities(doublereal* const visc) { update_T(); updateViscosity_T(); copy(m_visc.begin(), m_visc.end(), visc); @@ -271,7 +271,7 @@ public: * Flat vector with the m_nsp in the inner loop. * length = ldx * ndim */ - virtual void getSpeciesFluxes(size_t ndim, const doublereal* grad_T, + virtual void getSpeciesFluxes(size_t ndim, const doublereal* grad_T, int ldx, const doublereal* grad_X, int ldf, doublereal* fluxes); diff --git a/include/cantera/transport/TransportBase.h b/include/cantera/transport/TransportBase.h index e91096e05..4ef3c9e7c 100644 --- a/include/cantera/transport/TransportBase.h +++ b/include/cantera/transport/TransportBase.h @@ -185,7 +185,7 @@ public: * * @see TransportFactory */ - Transport(thermo_t* thermo=0, int ndim = 1); + Transport(thermo_t* thermo=0, size_t ndim = 1); //! Destructor. virtual ~Transport(); @@ -544,7 +544,7 @@ public: * Flat vector with the m_nsp in the inner loop. * length = ldx * ndim */ - virtual void getSpeciesFluxes(int ndim, const doublereal* const grad_T, + virtual void getSpeciesFluxes(size_t ndim, const doublereal* const grad_T, int ldx, const doublereal* const grad_X, int ldf, doublereal* const fluxes); diff --git a/src/base/ctml.cpp b/src/base/ctml.cpp index a354da20c..ee228a3c5 100644 --- a/src/base/ctml.cpp +++ b/src/base/ctml.cpp @@ -210,7 +210,7 @@ void addIntegerArray(Cantera::XML_Node& node, const std::string& title, const si if (type != "") { f.addAttribute("type",type); } - f.addAttribute("size",n); + f.addAttribute("size", static_cast(n)); #ifndef CTML_VERSION_1_4 f.addAttribute("vtype", "intArray"); #endif @@ -1026,7 +1026,7 @@ doublereal getFloatDefaultUnits(const Cantera::XML_Node& parent, std::string nam * @verbatim std::string modelName = ""; bool exists = getOptionalModel(transportNode, "compositionDependence", - modelName); + modelName); @endverbatim * * Reads the corresponding XML file: @@ -1263,7 +1263,7 @@ size_t getFloatArray(const Cantera::XML_Node& node, std::vector & v, return v.size(); } //==================================================================================================================== -int getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector & v, +size_t getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& nodeName, std::vector & v, const bool convert, const std::string unitsString) { std::string::size_type icom; @@ -1326,7 +1326,7 @@ int getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& * would appear to be odd. So, we keep the * possibilty in for backwards compatibility. */ - int nlen = strlen(val.c_str()); + size_t nlen = strlen(val.c_str()); if (nlen > 0) { dtmp = atofCheck(val.c_str()); v.push_back(dtmp); @@ -1343,8 +1343,8 @@ int getNamedFloatArray(const Cantera::XML_Node& parentNode, const std::string& " is above upper limit of " +fp2str(vmin)+".\n"); } } - int nv = v.size(); - for (int n = 0; n < nv; n++) { + size_t nv = v.size(); + for (size_t n = 0; n < nv; n++) { v[n] *= funit; } if (nv != expectedSize) { diff --git a/src/base/mdp_allo.cpp b/src/base/mdp_allo.cpp index 96a44a61f..4e645e471 100644 --- a/src/base/mdp_allo.cpp +++ b/src/base/mdp_allo.cpp @@ -70,8 +70,6 @@ const int MDP_ALLOC_INTERFACE_ERROR = -230346; /****************************************************************************/ static void mdp_alloc_eh(const char* const rname, const int bytes) -throw(std::bad_alloc, std::exception) - /************************************************************************* * * mdp_alloc_eh: diff --git a/src/base/stringUtils.cpp b/src/base/stringUtils.cpp index d4b254507..d4769c22e 100644 --- a/src/base/stringUtils.cpp +++ b/src/base/stringUtils.cpp @@ -21,7 +21,7 @@ #include "cantera/base/ctml.h" #include - +#include #include #include #include @@ -89,6 +89,17 @@ std::string int2str(const int n) return std::string(" "); } //================================================================================================ +// Convert an int to a string +/* + * @param n int to be converted + */ +std::string int2str(const size_t n) +{ + std::stringstream ss; + ss << n; + return ss.str(); +} +//================================================================================================ std::string lowercase(const std::string& s) { int n = static_cast(s.size()); diff --git a/src/equil/vcs_MultiPhaseEquil.cpp b/src/equil/vcs_MultiPhaseEquil.cpp index 3f2be29a7..d4e9f1d84 100644 --- a/src/equil/vcs_MultiPhaseEquil.cpp +++ b/src/equil/vcs_MultiPhaseEquil.cpp @@ -1538,9 +1538,9 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int clockWC tickTock; - int nsp = m_mix->nSpecies(); - int nel = m_mix->nElements(); - int nph = m_mix->nPhases(); + size_t nsp = m_mix->nSpecies(); + size_t nel = m_mix->nElements(); + size_t nph = m_mix->nPhases(); if (m_vprob == 0) { m_vprob = new VCS_PROB(nsp, nel, nph); } diff --git a/src/equil/vcs_VolPhase.cpp b/src/equil/vcs_VolPhase.cpp index 4063edaa8..8ac58a62b 100644 --- a/src/equil/vcs_VolPhase.cpp +++ b/src/equil/vcs_VolPhase.cpp @@ -1207,14 +1207,15 @@ double vcs_VolPhase::molefraction(size_t k) const /***************************************************************************/ void vcs_VolPhase::setCreationMoleNumbers(const double* const n_k, - const std::vector &creationGlobalRxnNumbers) + const std::vector &creationGlobalRxnNumbers) { vcs_dcopy(VCS_DATA_PTR(creationMoleNumbers_), n_k, m_numSpecies); - vcs_icopy(VCS_DATA_PTR(creationGlobalRxnNumbers_), VCS_DATA_PTR(creationGlobalRxnNumbers), m_numSpecies); + creationGlobalRxnNumbers_ = creationGlobalRxnNumbers; + } /***************************************************************************/ -const std::vector & vcs_VolPhase::creationMoleNumbers(std::vector &creationGlobalRxnNumbers) const +const std::vector & vcs_VolPhase::creationMoleNumbers(std::vector &creationGlobalRxnNumbers) const { creationGlobalRxnNumbers = creationGlobalRxnNumbers_; return creationMoleNumbers_; diff --git a/src/equil/vcs_VolPhase.h b/src/equil/vcs_VolPhase.h index c586068fa..c0b7bd80d 100644 --- a/src/equil/vcs_VolPhase.h +++ b/src/equil/vcs_VolPhase.h @@ -425,13 +425,13 @@ public: /*! * @param F_k Pointer to a vector of n_k's */ - void setCreationMoleNumbers(const double* const n_k, const std::vector &creationGlobalRxnNumbers); + void setCreationMoleNumbers(const double* const n_k, const std::vector &creationGlobalRxnNumbers); //! Return a const reference to the creationMoleNumbers storred in the object. /*! * @return Returns a const reference to the vector of creationMoleNumbers */ - const std::vector & creationMoleNumbers(std::vector &creationGlobalRxnNumbers) const; + const std::vector & creationMoleNumbers(std::vector &creationGlobalRxnNumbers) const; //! Returns whether the phase is an ideal solution phase bool isIdealSoln() const; @@ -895,7 +895,7 @@ private: * that the global reaction number will go out of order when the species positions * are swapped. So, this number has to be recalculated. */ - std::vector creationGlobalRxnNumbers_; + std::vector creationGlobalRxnNumbers_; //! If the potential is a solution variable in VCS, it acts as a species. //! This is the species index in the phase for the potential diff --git a/src/equil/vcs_internal.h b/src/equil/vcs_internal.h index f50888493..2fc8a7db2 100644 --- a/src/equil/vcs_internal.h +++ b/src/equil/vcs_internal.h @@ -191,7 +191,7 @@ int vcsUtil_mlequ(double* c, size_t idem, size_t n, double* b, size_t m); * (each column is a new rhs) * @param m number of rhs's */ -int vcsUtil_gaussj(double* c, int idem, int n, double* b, int m); +int vcsUtil_gaussj(double* c, size_t idem, size_t n, double* b, size_t m); //! Swap values in vector of doubles /*! diff --git a/src/equil/vcs_phaseStability.cpp b/src/equil/vcs_phaseStability.cpp index 3fceb9384..75d0a861a 100644 --- a/src/equil/vcs_phaseStability.cpp +++ b/src/equil/vcs_phaseStability.cpp @@ -109,7 +109,7 @@ bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const // Second we are here if the component is a reactant in the reaction, and the reaction goes backwards. else if (m_stoichCoeffRxnMatrix[jrxn][kspec] < 0.0) { foundJrxn = true; - int jspec = jrxn + m_numComponents; + size_t jspec = jrxn + m_numComponents; if (m_molNumSpecies_old[jspec] <= VCS_DELETE_ELEMENTABS_CUTOFF*0.5) { foundJrxn = false; continue; @@ -133,14 +133,14 @@ bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const } //==================================================================================================================== -int inList(const std::vector &list, int val) +size_t inList(const std::vector &list, size_t val) { - for (int i = 0; i < (int) list.size(); i++) { + for (size_t i = 0; i < list.size(); i++) { if (val == list[i]) { return i; } } - return -1; + return npos; } //==================================================================================================================== @@ -172,7 +172,7 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() * It does not count species with positive stoichiometric values if that species * already has a positive mole number. The phase is already popped. */ - std::vector< std::vector > zeroedComponentLinkedPhasePops(m_numComponents); + std::vector< std::vector > zeroedComponentLinkedPhasePops(m_numComponents); /* * The logic below calculates zeroedComponentLinkedPhasePops */ @@ -180,11 +180,11 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() if (m_elType[j] == VCS_ELEM_TYPE_ABSPOS) { molComp = m_molNumSpecies_old[j]; if (molComp <= 0.0) { - std::vector &jList = zeroedComponentLinkedPhasePops[j]; + std::vector &jList = zeroedComponentLinkedPhasePops[j]; size_t iph = m_phaseID[j]; jList.push_back(iph); for (size_t irxn = 0; irxn < m_numRxnTot; irxn++) { - size_t kspec = irxn + m_numComponents; + size_t kspec = irxn + m_numComponents; iph = m_phaseID[kspec]; Vphase = m_VolPhaseList[iph]; int existence = Vphase->exists(); @@ -206,12 +206,12 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() * which have a species with a negative stoichiometric value wrt one or more species in the phase. * Cut out components which have a pos stoichiometric value with another species in the phase. */ - std::vector< std::vector > zeroedPhaseLinkedZeroComponents(m_numPhases); + std::vector< std::vector > zeroedPhaseLinkedZeroComponents(m_numPhases); /* * The logic below calculates zeroedPhaseLinkedZeroComponents */ for (size_t iph = 0; iph < m_numPhases; iph++) { - std::vector &iphList = zeroedPhaseLinkedZeroComponents[iph]; + std::vector &iphList = zeroedPhaseLinkedZeroComponents[iph]; iphList.clear(); Vphase = m_VolPhaseList[iph]; int existence = Vphase->exists(); @@ -240,7 +240,7 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() } } if (!foundPos) { - if (inList(iphList, j) != -1) { + if (inList(iphList, j) != npos) { iphList.push_back(j); } } @@ -260,15 +260,15 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() Vphase = m_VolPhaseList[iph]; int existence = Vphase->exists(); if (existence < 0) { - std::vector &iphList = zeroedPhaseLinkedZeroComponents[iph]; - std::vector popProblem(0); + std::vector &iphList = zeroedPhaseLinkedZeroComponents[iph]; + std::vector popProblem(0); popProblem.push_back(iph); for (size_t i = 0; i < iphList.size(); i++) { - size_t j = iphList[i]; - std::vector &jList = zeroedComponentLinkedPhasePops[j]; - for (int jjl = 0; jjl < (int) jList.size(); jjl++) { - int jph = jList[jjl]; - if (inList(popProblem, jph) != -1) { + size_t j = iphList[i]; + std::vector &jList = zeroedComponentLinkedPhasePops[j]; + for (size_t jjl = 0; jjl < jList.size(); jjl++) { + size_t jph = jList[jjl]; + if (inList(popProblem, jph) != npos) { popProblem.push_back(jph); } } @@ -285,12 +285,12 @@ int VCS_SOLVE::vcs_phasePopDeterminePossibleList() // Decision as to whether a phase pops back into existence /* * @return returns the phase id of the phases that pops back into - * existence. Returns -1 if there are no phases + * existence. Returns npos if there are no phases */ -int VCS_SOLVE::vcs_popPhaseID(std::vector & phasePopPhaseIDs) +size_t VCS_SOLVE::vcs_popPhaseID(std::vector & phasePopPhaseIDs) { - int iphasePop = -1; - int irxn, kspec; + size_t iphasePop = npos; + size_t irxn, kspec; doublereal FephaseMax = -1.0E30; doublereal Fephase = -1.0E30; vcs_VolPhase* Vphase = 0; @@ -401,7 +401,7 @@ int VCS_SOLVE::vcs_popPhaseID(std::vector & phasePopPhaseIDs) } } phasePopPhaseIDs.resize(0); - if (iphasePop >= 0) { + if (iphasePop != npos) { phasePopPhaseIDs.push_back(iphasePop); } @@ -447,7 +447,7 @@ int VCS_SOLVE::vcs_popPhaseRxnStepSizes(const size_t iphasePop) size_t kspec = Vphase->spGlobalIndexVCS(0); // Identify the formation reaction for that species size_t irxn = kspec - m_numComponents; - std::vector creationGlobalRxnNumbers; + std::vector creationGlobalRxnNumbers; doublereal s; // Calculate the initial moles of the phase being born. @@ -656,7 +656,7 @@ double VCS_SOLVE::vcs_phaseStabilityTest(const size_t iph) vector fracDelta_new(Vphase->nSpecies(), 0.0); vector fracDelta_old(Vphase->nSpecies(), 0.0); vector fracDelta_raw(Vphase->nSpecies(), 0.0); - vector creationGlobalRxnNumbers(Vphase->nSpecies(), -1); + vector creationGlobalRxnNumbers(Vphase->nSpecies(), npos); vcs_dcopy(VCS_DATA_PTR(m_deltaGRxn_Deficient), VCS_DATA_PTR(m_deltaGRxn_old), m_numRxnRdc); vector m_feSpecies_Deficient(m_numComponents, 0.0); diff --git a/src/equil/vcs_rxnadj.cpp b/src/equil/vcs_rxnadj.cpp index d0c38d14c..4cb7f5641 100644 --- a/src/equil/vcs_rxnadj.cpp +++ b/src/equil/vcs_rxnadj.cpp @@ -41,10 +41,10 @@ namespace VCSnonideal * in this routine. The species is a noncomponent * - 2 : Same as one but, the zeroed species is a component. */ -int VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) +size_t VCS_SOLVE::vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial) { size_t kspec, iph; - int iphDel = -1; + size_t iphDel = npos; double s, xx, dss; size_t k = 0; vcs_VolPhase* Vphase = 0; diff --git a/src/equil/vcs_solve.cpp b/src/equil/vcs_solve.cpp index 9bffefa7a..92f0643e1 100644 --- a/src/equil/vcs_solve.cpp +++ b/src/equil/vcs_solve.cpp @@ -591,7 +591,7 @@ int VCS_SOLVE::vcs_prob_specifyFully(const VCS_PROB* pub) } } else { if (m_doEstimateEquil == 0) { - double sum; + double sum = 0; for (size_t j = 0; j < nelements; j++) { m_elemAbundancesGoal[j] = 0.0; for (size_t kspec = 0; kspec < nspecies; kspec++) { diff --git a/src/equil/vcs_solve.h b/src/equil/vcs_solve.h index 3c062a4b0..523fc6ff7 100644 --- a/src/equil/vcs_solve.h +++ b/src/equil/vcs_solve.h @@ -544,7 +544,7 @@ public: * @return returns the phase id of the phase that pops back into * existence. Returns -1 if there are no phases */ - int vcs_popPhaseID(std::vector &phasePopPhaseIDs); + size_t vcs_popPhaseID(std::vector &phasePopPhaseIDs); //! Calculates the deltas of the reactions due to phases popping //! into existence @@ -579,7 +579,7 @@ public: * * @return Returns an int representing which phase may need to be zeroed */ - int vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial); + size_t vcs_RxnStepSizes(int& forceComponentCalc, size_t& kSpecial); //! Calculates the total number of moles of species in all phases. /*! @@ -1987,7 +1987,7 @@ public: */ std::vector m_chargeSpecies; - std::vector > phasePopProblemLists_; + std::vector > phasePopProblemLists_; //! Vector of pointers to thermostructures which identify the model //! and parameters for evaluating the thermodynamic functions for that diff --git a/src/equil/vcs_solve_TP.cpp b/src/equil/vcs_solve_TP.cpp index f7574f18c..9b25f150a 100644 --- a/src/equil/vcs_solve_TP.cpp +++ b/src/equil/vcs_solve_TP.cpp @@ -110,7 +110,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit) bool uptodate_minors = true; bool justDeletedMultiPhase = false; bool usedZeroedSpecies; /* return flag from basopt indicating that - one of the components had a zero concentration */ + one of the components had a zero concentration */ size_t doPhaseDeleteIph = npos; vcs_VolPhase* Vphase; double* sc_irxn = NULL; /* Stoichiometric coefficients for cur rxn */ @@ -119,7 +119,7 @@ int VCS_SOLVE::vcs_solve_TP(int print_lvl, int printDetails, int maxit) size_t iphasePop; int forceComponentCalc = 1; size_t iphaseDelete; /* integer that determines which phase is being deleted */ - std::vector phasePopPhaseIDs(0); + std::vector phasePopPhaseIDs(0); #ifdef DEBUG_MODE char ANOTE[128]; /* @@ -4647,7 +4647,7 @@ void VCS_SOLVE::vcs_printSpeciesChemPot(const int stateCalc) const mfValue = molNum[kspec]/tMoles[iphase]; } } else { - int klocal = m_speciesLocalPhaseIndex[kspec]; + size_t klocal = m_speciesLocalPhaseIndex[kspec]; mfValue = Vphase->moleFraction(klocal); } double volts = Vphase->electricPotential(); @@ -5304,10 +5304,10 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc) for (size_t kspec = 0; kspec < m_numSpeciesTot; kspec++) { - int irxn = kspec - m_numComponents; + size_t irxn = kspec - m_numComponents; double mfValue = 1.0; - int iphase = m_phaseID[kspec]; + size_t iphase = m_phaseID[kspec]; const vcs_VolPhase* Vphase = m_VolPhaseList[iphase]; if ((m_speciesStatus[kspec] == VCS_SPECIES_ZEROEDMS) || (m_speciesStatus[kspec] == VCS_SPECIES_ZEROEDPHASE) || @@ -5323,7 +5323,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc) mfValue = molNumSpecies[kspec] / tPhMoles_ptr[iphase]; } } else { - int klocal = m_speciesLocalPhaseIndex[kspec]; + size_t klocal = m_speciesLocalPhaseIndex[kspec]; mfValue = Vphase->moleFraction(klocal); } if (zeroedPhase) { @@ -5342,7 +5342,7 @@ void VCS_SOLVE::vcs_printDeltaG(const int stateCalc) printf(" % -12.4e", mfValue); printf(" % -12.4e", feSpecies[kspec] * RT); printf(" % -12.4e", feFull * RT); - if (irxn >= 0) { + if (irxn != npos) { printf(" % -12.4e", deltaGRxn[irxn] * RT); printf(" % -12.4e", (deltaGRxn[irxn] + feFull - feSpecies[kspec]) * RT); diff --git a/src/equil/vcs_solve_phaseStability.cpp b/src/equil/vcs_solve_phaseStability.cpp index 0f669539a..6b2e1d451 100644 --- a/src/equil/vcs_solve_phaseStability.cpp +++ b/src/equil/vcs_solve_phaseStability.cpp @@ -47,9 +47,9 @@ int VCS_SOLVE::vcs_PS(VCS_PROB* vprob, int iphase, int printLvl, double& feStabl * This function is called to create the private data * using the public data. */ - int nspecies0 = vprob->nspecies + 10; - int nelements0 = vprob->ne; - int nphase0 = vprob->NPhase; + size_t nspecies0 = vprob->nspecies + 10; + size_t nelements0 = vprob->ne; + size_t nphase0 = vprob->NPhase; vcs_initSizes(nspecies0, nelements0, nphase0); @@ -161,8 +161,8 @@ int VCS_SOLVE::vcs_PS(VCS_PROB* vprob, int iphase, int printLvl, double& feStabl vprob->mf[kstart + k] = mfPop[k]; } VPphase->setMoleFractionsState(Vphase->totalMoles(), - VCS_DATA_PTR(Vphase->moleFractions()), - VCS_STATECALC_TMP); + VCS_DATA_PTR(Vphase->moleFractions()), + VCS_STATECALC_TMP); */ vcs_prob_update(vprob); /* @@ -207,7 +207,7 @@ int VCS_SOLVE::vcs_solve_phaseStability(const int iph, const int ifunc, { double test = -1.0E-10; bool usedZeroedSpecies; - std::vector phasePopPhaseIDs(0); + std::vector phasePopPhaseIDs(0); int iStab = 0; std::vector sm(m_numElemConstraints*m_numElemConstraints, 0.0); diff --git a/src/equil/vcs_util.cpp b/src/equil/vcs_util.cpp index a79424ca7..b8ebfa61d 100644 --- a/src/equil/vcs_util.cpp +++ b/src/equil/vcs_util.cpp @@ -342,7 +342,7 @@ static void mlequ_matrixDump(double* c, int idem, int n) * @param irowa first row to swap * @param irowb second row to swap */ -static void vcsUtil_swapRows(double* c, int idem, int n, double* b, int m, int irowa, int irowb) +static void vcsUtil_swapRows(double* c, size_t idem, size_t n, double* b, size_t m, size_t irowa, size_t irowb) { double t1; int j; @@ -365,15 +365,15 @@ static void vcsUtil_swapRows(double* c, int idem, int n, double* b, int m, int i * @param b RHS of the Ax=b problem to solve * @param m Number of rhs to solve */ -static void vcsUtil_mlequ_preprocess(double* c, int idem, int n, double* b, int m) +static void vcsUtil_mlequ_preprocess(double* c, size_t idem, size_t n, double* b, size_t m) { - int j = 0; + size_t j = 0; std::vector irowUsed(n, 0); for (j = 0; j < n; j++) { int numNonzero = 0; - int inonzero = -1; - for (int i = 0; i < n; i++) { + size_t inonzero = npos; + for (size_t i = 0; i < n; i++) { if (c[i + j * idem] != 0.0) { numNonzero++; inonzero = i; @@ -395,8 +395,8 @@ static void vcsUtil_mlequ_preprocess(double* c, int idem, int n, double* b, int for (j = 0; j < n; j++) { if (c[j + j * idem] == 0.0) { int numNonzero = 0; - int inonzero = -1; - for (int i = 0; i < n; i++) { + size_t inonzero = npos; + for (size_t i = 0; i < n; i++) { if (! irowUsed[i]) { if (c[i + j * idem] != 0.0) { if ((c[i + i * idem] == 0.0) || (c[j + i * idem] != 0.0)) { @@ -423,8 +423,8 @@ static void vcsUtil_mlequ_preprocess(double* c, int idem, int n, double* b, int for (j = 0; j < n; j++) { if (c[j + j * idem] == 0.0) { int numNonzero = 0; - int inonzero = -1; - for (int i = 0; i < n; i++) { + size_t inonzero = npos; + for (size_t i = 0; i < n; i++) { if (! irowUsed[i]) { if (c[i + j * idem] != 0.0) { if ((c[i + i * idem] == 0.0) || (c[j + i * idem] != 0.0)) { @@ -434,7 +434,7 @@ static void vcsUtil_mlequ_preprocess(double* c, int idem, int n, double* b, int } } } - if (inonzero != -1) { + if (inonzero != npos) { if (inonzero != j) { if (irowUsed[inonzero] == 0) { vcsUtil_swapRows(c, idem, n, b, m, j, inonzero); @@ -618,12 +618,12 @@ FOUND_PIVOT: * (each column is a new rhs) * @param m number of rhs's */ -int vcsUtil_gaussj(double* c, int idem, int n, double* b, int m) +int vcsUtil_gaussj(double* c, size_t idem, size_t n, double* b, size_t m) { - int i, j, k, l, ll; - int irow = -1; - int icol = -1; + size_t i, j, k, l, ll; + size_t irow = npos; + size_t icol = npos; bool needInverse = false; double pivinv, dum; #ifdef DEBUG_HKM @@ -642,8 +642,8 @@ int vcsUtil_gaussj(double* c, int idem, int n, double* b, int m) // mlequ_matrixDump(c, idem, n); #endif - std::vector indxc(n); - std::vector indxr(n); + std::vector indxc(n); + std::vector indxr(n); std::vector ipiv(n, 0); doublereal big = 0.0; /* diff --git a/src/kinetics/InterfaceKinetics.cpp b/src/kinetics/InterfaceKinetics.cpp index 4bd9f9320..65fcfd030 100644 --- a/src/kinetics/InterfaceKinetics.cpp +++ b/src/kinetics/InterfaceKinetics.cpp @@ -877,9 +877,8 @@ void InterfaceKinetics::getDeltaElectrochemPotentials(doublereal* deltaM) * Get the chemical potentials of the species in the * ideal gas solution. */ - int np = nPhases(); - int n; - for (n = 0; n < np; n++) { + size_t np = nPhases(); + for (size_t n = 0; n < np; n++) { thermo(n).getElectrochemPotentials(DATA_PTR(m_grt) + m_start[n]); } /* diff --git a/src/numerics/BandMatrix.cpp b/src/numerics/BandMatrix.cpp index eac5659a7..f789be5b7 100644 --- a/src/numerics/BandMatrix.cpp +++ b/src/numerics/BandMatrix.cpp @@ -174,7 +174,7 @@ size_t BandMatrix::nRows() const } //==================================================================================================================== // Number of rows -size_t BandMatrix::nRowsAndStruct(int* const iStruct) const +size_t BandMatrix::nRowsAndStruct(size_t* const iStruct) const { if (iStruct) { iStruct[0] = m_kl; @@ -214,7 +214,7 @@ vector_int& BandMatrix::ipiv() /* * Multiply A*b and write result to \c prod. */ -void BandMatrix::mult(const doublereal* const b, doublereal* const prod) const +void BandMatrix::mult(const doublereal* b, doublereal* prod) const { size_t nr = nRows(); doublereal sum = 0.0; @@ -385,7 +385,7 @@ doublereal BandMatrix::rcond(doublereal a1norm) } // doublereal anorm = oneNorm(); - int ldab = (2 *m_kl + m_ku + 1); + size_t ldab = (2 *m_kl + m_ku + 1); int rinfo; rcond = ct_dgbcon('1', m_n, m_kl, m_ku, DATA_PTR(ludata), ldab, DATA_PTR(m_ipiv), a1norm, DATA_PTR(work_), DATA_PTR(iwork_), rinfo); diff --git a/src/numerics/DenseMatrix.cpp b/src/numerics/DenseMatrix.cpp index 160736097..a06904d7e 100644 --- a/src/numerics/DenseMatrix.cpp +++ b/src/numerics/DenseMatrix.cpp @@ -27,7 +27,7 @@ DenseMatrix::DenseMatrix() : * Constructor. Create an \c n by \c m matrix, and initialize * all elements to \c v. */ -DenseMatrix::DenseMatrix(int n, int m, doublereal v) : +DenseMatrix::DenseMatrix(size_t n, size_t m, doublereal v) : Array2D(n, m, v), m_ipiv(0), m_useReturnErrorCode(0), @@ -35,7 +35,7 @@ DenseMatrix::DenseMatrix(int n, int m, doublereal v) : { m_ipiv.resize(max(n, m)); m_colPts.resize(m); - for (int j = 0; j < m; j++) { + for (size_t j = 0; j < m; j++) { m_colPts[j] = &(m_data[m_nrows*j]); } } @@ -79,7 +79,7 @@ DenseMatrix::~DenseMatrix() { } //==================================================================================================================== -void DenseMatrix::resize(int n, int m, doublereal v) +void DenseMatrix::resize(size_t n, size_t m, doublereal v) { Array2D::resize(n,m,v); m_ipiv.resize(max(n,m)); @@ -109,13 +109,12 @@ void DenseMatrix::mult(const double* b, double* prod) const //==================================================================================================================== void DenseMatrix::leftMult(const double* const b, double* const prod) const { - int nc = static_cast(nColumns()); - int nr = static_cast(nRows()); - int n, i; + size_t nc = nColumns(); + size_t nr = nRows(); double sum = 0.0; - for (n = 0; n < nc; n++) { + for (size_t n = 0; n < nc; n++) { sum = 0.0; - for (i = 0; i < nr; i++) { + for (size_t i = 0; i < nr; i++) { sum += value(i,n)*b[i]; } prod[n] = sum; @@ -139,9 +138,8 @@ int solve(DenseMatrix& A, double* b) } return -1; } - ct_dgetrf(static_cast(A.nRows()), - static_cast(A.nColumns()), A.ptrColumn(0), //begin(), - static_cast(A.nRows()), &A.ipiv()[0], info); + ct_dgetrf(A.nRows(), A.nColumns(), A.ptrColumn(0), + A.nRows(), &A.ipiv()[0], info); if (info != 0) { if (info > 0) { if (A.m_printLevel) { @@ -166,11 +164,8 @@ int solve(DenseMatrix& A, double* b) } return info; } - ct_dgetrs(ctlapack::NoTranspose, - static_cast(A.nRows()), 1, A.ptrColumn(0), //begin(), - static_cast(A.nRows()), - &A.ipiv()[0], b, - static_cast(A.nColumns()), info); + ct_dgetrs(ctlapack::NoTranspose, A.nRows(), 1, A.ptrColumn(0), + A.nRows(), &A.ipiv()[0], b, A.nColumns(), info); if (info != 0) { if (A.m_printLevel) { writelogf("solve(DenseMatrix& A, double* b): DGETRS returned INFO = %d\n", info); @@ -194,9 +189,8 @@ int solve(DenseMatrix& A, DenseMatrix& b) } return -1; } - ct_dgetrf(static_cast(A.nRows()), - static_cast(A.nColumns()), A.ptrColumn(0), - static_cast(A.nRows()), &A.ipiv()[0], info); + ct_dgetrf(A.nRows(), A.nColumns(), A.ptrColumn(0), + A.nRows(), &A.ipiv()[0], info); if (info != 0) { if (info > 0) { if (A.m_printLevel) { @@ -222,11 +216,8 @@ int solve(DenseMatrix& A, DenseMatrix& b) return info; } - ct_dgetrs(ctlapack::NoTranspose, static_cast(A.nRows()), - static_cast(b.nColumns()), - A.ptrColumn(0), static_cast(A.nRows()), - &A.ipiv()[0], b.ptrColumn(0), - static_cast(b.nRows()), info); + ct_dgetrs(ctlapack::NoTranspose, A.nRows(), b.nColumns(), A.ptrColumn(0), + A.nRows(), &A.ipiv()[0], b.ptrColumn(0), b.nRows(), info); if (info != 0) { if (A.m_printLevel) { writelogf("solve(DenseMatrix& A, DenseMatrix& b): DGETRS returned INFO = %d\n", info); @@ -283,9 +274,9 @@ void increment(const DenseMatrix& A, const double* b, double* prod) A.ptrColumn(0), static_cast(A.nRows()), b, 1, 1.0, prod, 1); } //==================================================================================================================== -int invert(DenseMatrix& A, int nn) +int invert(DenseMatrix& A, size_t nn) { - integer n = (nn > 0 ? nn : static_cast(A.nRows())); + integer n = static_cast(nn != npos ? nn : A.nRows()); int info=0; ct_dgetrf(n, n, A.ptrColumn(0), static_cast(A.nRows()), &A.ipiv()[0], info); diff --git a/src/numerics/NonlinearSolver.cpp b/src/numerics/NonlinearSolver.cpp index c82ab7823..29ede8fd3 100644 --- a/src/numerics/NonlinearSolver.cpp +++ b/src/numerics/NonlinearSolver.cpp @@ -762,9 +762,9 @@ int NonlinearSolver::doResidualCalc(const doublereal time_curr, const int typeCa void NonlinearSolver::scaleMatrix(GeneralMatrix& jac, doublereal* const y_comm, doublereal* const ydot_comm, doublereal time_curr, int num_newt_its) { - int irow, jcol; - int ku, kl; - int ivec[2]; + size_t irow, jcol; + size_t ku, kl; + size_t ivec[2]; jac.nRowsAndStruct(ivec); double* colP_j; @@ -1185,7 +1185,7 @@ int NonlinearSolver::doAffineNewtonSolve(const doublereal* const y_curr, const if (doHessian) { // Store the old value for later comparison - delyNewton = mdp::mdp_alloc_dbl_1(neq_, MDP_DBL_NOINIT); + delyNewton = mdp::mdp_alloc_dbl_1((int) neq_, MDP_DBL_NOINIT); for (irow = 0; irow < neq_; irow++) { delyNewton[irow] = delta_y[irow]; } @@ -1285,7 +1285,7 @@ int NonlinearSolver::doAffineNewtonSolve(const doublereal* const y_curr, const } // doublereal *JTF = delta_y; - doublereal* delyH = mdp::mdp_alloc_dbl_1(neq_, MDP_DBL_NOINIT); + doublereal* delyH = mdp::mdp_alloc_dbl_1((int) neq_, MDP_DBL_NOINIT); // First recalculate the scaled residual. It got wiped out doing the newton solve if (m_rowScaling) { for (int n = 0; n < neq_; n++) { @@ -1368,7 +1368,7 @@ int NonlinearSolver::doAffineNewtonSolve(const doublereal* const y_curr, const * Choose the delta_y to use */ if (newtonGood || s_alwaysAssumeNewtonGood) { - mdp::mdp_copy_dbl_1(DATA_PTR(delta_y), CONSTD_DATA_PTR(delyNewton), neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(delta_y), CONSTD_DATA_PTR(delyNewton), (int) neq_); } mdp::mdp_safe_free((void**) &delyH); mdp::mdp_safe_free((void**) &delyNewton); @@ -2794,7 +2794,7 @@ int NonlinearSolver::dampDogLeg(const doublereal time_curr, const doublereal* y_ haveASuccess = true; // Store the good results in stepLastGood - mdp::mdp_copy_dbl_1(DATA_PTR(stepLastGood), CONSTD_DATA_PTR(step_1), neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(stepLastGood), CONSTD_DATA_PTR(step_1), (int) neq_); // Within the program decideStep(), we have already increased the value of trustDelta_. We store the // value of step0 in step1, recalculate a larger step0 in the next fillDogLegStep(), // and then attempt to see if the larger step works in the next iteration @@ -2805,7 +2805,7 @@ int NonlinearSolver::dampDogLeg(const doublereal time_curr, const doublereal* y_ // already been decreased in the decideStep() routine. We go back and try another iteration with // a smaller trust region. if (haveASuccess) { - mdp::mdp_copy_dbl_1(DATA_PTR(step_1), CONSTD_DATA_PTR(stepLastGood), neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(step_1), CONSTD_DATA_PTR(stepLastGood), (int) neq_); for (j = 0; j < neq_; j++) { y_n_1[j] = y_n_curr[j] + step_1[j]; } @@ -3082,11 +3082,11 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c bool trInit = false; - mdp::mdp_copy_dbl_1(DATA_PTR(m_y_n_curr), DATA_PTR(y_comm), neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(m_y_n_curr), DATA_PTR(y_comm), (int) neq_); if (SolnType != NSOLN_TYPE_STEADY_STATE || ydot_comm) { - mdp::mdp_copy_dbl_1(DATA_PTR(m_ydot_n_curr), ydot_comm, neq_); - mdp::mdp_copy_dbl_1(DATA_PTR(m_ydot_n_1), ydot_comm, neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(m_ydot_n_curr), ydot_comm, (int) neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(m_ydot_n_1), ydot_comm, (int) neq_); } // Redo the solution weights every time we enter the function createSolnWeights(DATA_PTR(m_y_n_curr)); @@ -3103,7 +3103,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c trInit = true; initializeTrustRegion(); } else { - mdp::mdp_init_dbl_1(DATA_PTR(deltaX_trust_), 1.0, neq_); + mdp::mdp_init_dbl_1(DATA_PTR(deltaX_trust_), 1.0, (int) neq_); trustDelta_ = 1.0; } @@ -3277,7 +3277,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c } goto done; } - mdp::mdp_copy_dbl_1(DATA_PTR(m_step_1), CONSTD_DATA_PTR(deltaX_Newton_), neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(m_step_1), CONSTD_DATA_PTR(deltaX_Newton_), (int) neq_); if (m_print_flag >= 6) { m_normDeltaSoln_Newton = solnErrorNorm(DATA_PTR(deltaX_Newton_), "Initial Undamped Newton Step of the iteration", 10); @@ -3452,7 +3452,7 @@ int NonlinearSolver::solve_nonlinear_problem(int SolnType, doublereal* const y_c // Exchange new for curr solutions if (retnDamp >= NSOLN_RETN_CONTINUE) { - mdp::mdp_copy_dbl_1(DATA_PTR(m_y_n_curr), CONSTD_DATA_PTR(m_y_n_1), neq_); + mdp::mdp_copy_dbl_1(DATA_PTR(m_y_n_curr), CONSTD_DATA_PTR(m_y_n_1), (int) neq_); if (solnType_ != NSOLN_TYPE_STEADY_STATE) { calc_ydot(m_order, DATA_PTR(m_y_n_curr), DATA_PTR(m_ydot_n_curr)); @@ -3566,9 +3566,9 @@ done: } - mdp::mdp_copy_dbl_1(y_comm, CONSTD_DATA_PTR(m_y_n_curr), neq_); + mdp::mdp_copy_dbl_1(y_comm, CONSTD_DATA_PTR(m_y_n_curr), (int) neq_); if (solnType_ != NSOLN_TYPE_STEADY_STATE) { - mdp::mdp_copy_dbl_1(ydot_comm, CONSTD_DATA_PTR(m_ydot_n_curr), neq_); + mdp::mdp_copy_dbl_1(ydot_comm, CONSTD_DATA_PTR(m_ydot_n_curr), (int) neq_); } num_linear_solves += m_numTotalLinearSolves; @@ -3761,7 +3761,7 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, * deltaY's that are appropriate for calculating the numerical * derivative. */ - doublereal* dyVector = mdp::mdp_alloc_dbl_1(neq_, MDP_DBL_NOINIT); + doublereal* dyVector = mdp::mdp_alloc_dbl_1((int) neq_, MDP_DBL_NOINIT); retn = m_func->calcDeltaSolnVariables(time_curr, y, ydot, dyVector, DATA_PTR(m_ewt)); @@ -3837,9 +3837,9 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, */ mdp::mdp_safe_free((void**) &dyVector); } else if (J.matrixType_ == 1) { - int ku, kl; - int ivec[2]; - int n = J.nRowsAndStruct(ivec); + size_t ku, kl; + size_t ivec[2]; + size_t n = J.nRowsAndStruct(ivec); kl = ivec[0]; ku = ivec[1]; if (n != neq_) { @@ -3856,7 +3856,7 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, m_nJacEval++; - doublereal* dyVector = mdp::mdp_alloc_dbl_1(neq_, MDP_DBL_NOINIT); + doublereal* dyVector = mdp::mdp_alloc_dbl_1((int) neq_, MDP_DBL_NOINIT); retn = m_func->calcDeltaSolnVariables(time_curr, y, ydot, dyVector, DATA_PTR(m_ewt)); if (s_print_NumJac) { if (m_print_flag >= 7) { @@ -3897,7 +3897,7 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, - for (int i = j - ku; i <= j + kl; i++) { + for (size_t i = j - ku; i <= j + kl; i++) { if (i >= 0 && i < neq_) { diff = subtractRD(m_wksp[i], f[i]); col_j[kl + ku + i - j] = diff / dy; @@ -3912,7 +3912,7 @@ int NonlinearSolver::beuler_jac(GeneralMatrix& J, doublereal* const f, mdp::mdp_safe_free((void**) &dyVector); double vSmall; - int ismall = J.checkRows(vSmall); + size_t ismall = J.checkRows(vSmall); if (vSmall < 1.0E-100) { printf("WE have a zero row, %d\n", ismall); exit(-1); diff --git a/src/numerics/SquareMatrix.cpp b/src/numerics/SquareMatrix.cpp index 4a57ac083..a08978a6a 100644 --- a/src/numerics/SquareMatrix.cpp +++ b/src/numerics/SquareMatrix.cpp @@ -156,7 +156,7 @@ void SquareMatrix::resize(size_t n, size_t m, doublereal v) * @param b Vector to do the rh multiplcation * @param prod OUTPUT vector to receive the result */ -void SquareMatrix::mult(const doublereal* const b, doublereal* const prod) const +void SquareMatrix::mult(const doublereal* b, doublereal* prod) const { DenseMatrix::mult(b, prod); } @@ -220,7 +220,7 @@ int SquareMatrix::factorQR() a1norm_ = ct_dlange('1', m_nrows, m_nrows, &(*(begin())), m_nrows, DATA_PTR(work)); int info; m_factored = 2; - int lwork = work.size(); + size_t lwork = work.size(); ct_dgeqrf(m_nrows, m_nrows, &(*(begin())), m_nrows, DATA_PTR(tau), DATA_PTR(work), lwork, info); if (info != 0) { if (m_printLevel) { @@ -230,7 +230,7 @@ int SquareMatrix::factorQR() throw CELapackError("SquareMatrix::factorQR()", "DGEQRF returned INFO = " + int2str(info)); } } - int lworkOpt = work[0]; + size_t lworkOpt = static_cast(work[0]); if (lworkOpt > lwork) { work.resize(lworkOpt); } @@ -371,7 +371,7 @@ int SquareMatrix::factorAlgorithm() const //===================================================================================================================== bool SquareMatrix::factored() const { - return m_factored; + return (m_factored != 0); } //===================================================================================================================== // Return a pointer to the top of column j, columns are contiguous in memory @@ -401,7 +401,7 @@ size_t SquareMatrix::nRows() const return m_nrows; } //===================================================================================================================== -size_t SquareMatrix::nRowsAndStruct(int* const iStruct) const +size_t SquareMatrix::nRowsAndStruct(size_t* const iStruct) const { return m_nrows; } diff --git a/src/numerics/solveProb.cpp b/src/numerics/solveProb.cpp index 844fe4c80..0a48b7a8e 100644 --- a/src/numerics/solveProb.cpp +++ b/src/numerics/solveProb.cpp @@ -31,7 +31,7 @@ namespace Cantera * STATIC ROUTINES DEFINED IN THIS FILE ***************************************************************************/ -static doublereal calcWeightedNorm(const doublereal [], const doublereal dx[], int); +static doublereal calcWeightedNorm(const doublereal [], const doublereal dx[], size_t); /*************************************************************************** * LAPACK PROTOTYPES @@ -66,7 +66,7 @@ solveProb::solveProb(ResidEval* resid) : m_neq = m_residFunc->nEquations(); // Dimension solution vector - int dim1 = MAX(1, m_neq); + size_t dim1 = MAX(1, m_neq); m_atol.resize(dim1, 1.0E-9); m_netProductionRatesSave.resize(dim1, 0.0); @@ -85,7 +85,7 @@ solveProb::solveProb(ResidEval* resid) : m_Jac.resize(dim1, dim1, 0.0); m_JacCol.resize(dim1, 0); - for (int k = 0; k < dim1; k++) { + for (size_t k = 0; k < dim1; k++) { m_JacCol[k] = m_Jac.ptrColumn(k); } @@ -111,9 +111,9 @@ int solveProb::solve(int ifunc, doublereal time_scale, EXTRA_ACCURACY *= 0.001; } int info = 0; - int label_t=-1; /* Species IDs for time control */ + size_t label_t = npos; /* Species IDs for time control */ int label_d; /* Species IDs for damping control */ - int label_t_old = -1; + size_t label_t_old = npos; doublereal label_factor = 1.0; int iter=0; // iteration number on numlinear solver int iter_max=1000; // maximum number of nonlinear iterations @@ -504,7 +504,7 @@ void solveProb::resjac_eval(std::vector &JacCol, * @param dim Size of the solution vector * @param label return int, stating which solution component caused the most damping. */ -doublereal solveProb::calc_damping(doublereal x[], doublereal dxneg[], int dim, int* label) +doublereal solveProb::calc_damping(doublereal x[], doublereal dxneg[], size_t dim, int* label) { doublereal damp = 1.0, xnew, xtop, xbot; static doublereal damp_old = 1.0; @@ -582,7 +582,7 @@ doublereal solveProb::calc_damping(doublereal x[], doublereal dxneg[], int dim, * This function calculates the norm of an update, dx[], * based on the weighted values of x. */ -static doublereal calcWeightedNorm(const doublereal wtX[], const doublereal dx[], int dim) +static doublereal calcWeightedNorm(const doublereal wtX[], const doublereal dx[], size_t dim) { doublereal norm = 0.0; doublereal tmp; @@ -638,7 +638,7 @@ void solveProb::calcWeights(doublereal wtSpecies[], doublereal wtResid[], */ doublereal solveProb:: calc_t(doublereal netProdRateSolnSP[], doublereal Csoln[], - int* label, int* label_old, doublereal* label_factor, int ioflag) + size_t* label, size_t* label_old, doublereal* label_factor, int ioflag) { doublereal tmp, inv_timeScale=0.0; for (size_t k = 0; k < m_neq; k++) { @@ -818,14 +818,14 @@ void solveProb::print_header(int ioflag, int ifunc, doublereal time_scale, } //================================================================================================ void solveProb::printIteration(int ioflag, doublereal damp, int label_d, - int label_t, + size_t label_t, doublereal inv_t, doublereal t_real, int iter, doublereal update_norm, doublereal resid_norm, doublereal netProdRate[], doublereal CSolnSP[], doublereal resid[], - doublereal wtSpecies[], int dim, bool do_time) + doublereal wtSpecies[], size_t dim, bool do_time) { - int i, k; + size_t i, k; string nm; if (ioflag == 1) { @@ -907,15 +907,15 @@ void solveProb::printIteration(int ioflag, doublereal damp, int label_d, } /* printIteration */ //================================================================================================ -void solveProb::printFinal(int ioflag, doublereal damp, int label_d, int label_t, +void solveProb::printFinal(int ioflag, doublereal damp, int label_d, size_t label_t, doublereal inv_t, doublereal t_real, int iter, doublereal update_norm, doublereal resid_norm, doublereal netProdRateKinSpecies[], const doublereal CSolnSP[], const doublereal resid[], const doublereal wtSpecies[], const doublereal wtRes[], - int dim, bool do_time) + size_t dim, bool do_time) { - int i, k; + size_t i, k; string nm; if (ioflag == 1) { diff --git a/src/thermo/Constituents.cpp b/src/thermo/Constituents.cpp index dd3db686d..1d6109876 100644 --- a/src/thermo/Constituents.cpp +++ b/src/thermo/Constituents.cpp @@ -114,7 +114,7 @@ int Constituents::atomicNumber(size_t m) const return m_Elements->atomicNumber(m); } -int Constituents::elementType(int m) const +int Constituents::elementType(size_t m) const { return m_Elements->elementType(m); } @@ -495,18 +495,18 @@ void Constituents::getAtoms(size_t k, double* atomArray) const //==================================================================================================================== -int Constituents::addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, +size_t Constituents::addUniqueElementAfterFreeze(const std::string& symbol, doublereal weight, int atomicNumber, doublereal entropy298, int elem_type) { - int ii = elementIndex(symbol); - if (ii != -1) { + size_t ii = elementIndex(symbol); + if (ii != npos) { return ii; } // Check to see that the element isn't really in the list m_Elements->m_elementsFrozen = false; addUniqueElement(symbol, weight, atomicNumber, entropy298, elem_type); m_Elements->m_elementsFrozen = true; - int m_mm = m_Elements->nElements(); + size_t m_mm = m_Elements->nElements(); ii = elementIndex(symbol); if (ii != m_mm-1) { throw CanteraError("Constituents::addElementAfterFreeze()", "confused"); @@ -515,8 +515,8 @@ int Constituents::addUniqueElementAfterFreeze(const std::string& symbol, doubler vector_fp old(m_speciesComp); m_speciesComp.resize(m_kk*m_mm, 0.0); for (size_t k = 0; k < m_kk; k++) { - int m_old = m_mm - 1; - for (int m = 0; m < m_old; m++) { + size_t m_old = m_mm - 1; + for (size_t m = 0; m < m_old; m++) { m_speciesComp[k * m_mm + m] = old[k * (m_old) + m]; } m_speciesComp[k * (m_mm) + (m_mm-1)] = 0.0; diff --git a/src/thermo/Elements.cpp b/src/thermo/Elements.cpp index 054192935..7c021266b 100644 --- a/src/thermo/Elements.cpp +++ b/src/thermo/Elements.cpp @@ -353,7 +353,7 @@ doublereal Elements::entropyElement298(size_t m) const * * The default is CT_ELEM_TYPE_ABSPOS */ -int Elements::elementType(int m) const +int Elements::elementType(size_t m) const { return m_elem_type[m]; } diff --git a/src/thermo/FixedChemPotSSTP.cpp b/src/thermo/FixedChemPotSSTP.cpp index 7e8501b12..f9e112cf4 100644 --- a/src/thermo/FixedChemPotSSTP.cpp +++ b/src/thermo/FixedChemPotSSTP.cpp @@ -112,8 +112,7 @@ FixedChemPotSSTP::FixedChemPotSSTP(std::string Ename, doublereal val) : setNDim(3); addUniqueElement(Ename, -12345.); freezeElements(); - int nel = nElements(); - vector_fp ecomp(nel, 0.0); + vector_fp ecomp(nElements(), 0.0); ecomp[0] = 1.0; double chrg = 0.0; SpeciesThermo* spth = new SimpleThermo(); diff --git a/src/thermo/IonsFromNeutralVPSSTP.cpp b/src/thermo/IonsFromNeutralVPSSTP.cpp index c179d3db8..c4fcfefe2 100644 --- a/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -588,7 +588,7 @@ void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_ } } //==================================================================================================================== -void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoeffdlnN) +void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN) { s_update_lnActCoeff(); s_update_dlnActCoeff_dlnN(); @@ -1679,7 +1679,7 @@ void IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN() const if (!geThermo) { throw CanteraError("IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN()", "dynamic cast failed"); } - int nsp_ge = geThermo->nSpecies(); + size_t nsp_ge = geThermo->nSpecies(); geThermo->getdlnActCoeffdlnN(nsp_ge, &(dlnActCoeffdlnN_NeutralMolecule_(0,0))); switch (ionSolnType_) { diff --git a/src/thermo/LatticeSolidPhase.cpp b/src/thermo/LatticeSolidPhase.cpp index 6dcc83743..6bd31bdc6 100644 --- a/src/thermo/LatticeSolidPhase.cpp +++ b/src/thermo/LatticeSolidPhase.cpp @@ -122,9 +122,9 @@ ThermoPhase* LatticeSolidPhase::duplMyselfAsThermoPhase() const * @param k index of the species. Default is -1, which will return the max of the min value * over all species. */ -doublereal LatticeSolidPhase::minTemp(int k) const +doublereal LatticeSolidPhase::minTemp(size_t k) const { - if (k >= 0) { + if (k != npos) { for (size_t n = 0; n < m_nlattice; n++) { if (lkstart_[n+1] < k) { double ml = (m_lattice[n])->minTemp(k-lkstart_[n]); @@ -152,9 +152,9 @@ doublereal LatticeSolidPhase::minTemp(int k) const * @param k index of the species. Default is -1, which will return the max of the min value * over all species. */ -doublereal LatticeSolidPhase::maxTemp(int k) const +doublereal LatticeSolidPhase::maxTemp(size_t k) const { - if (k >= 0) { + if (k != npos) { for (size_t n = 0; n < m_nlattice; n++) { if (lkstart_[n+1] < k) { double ml = (m_lattice[n])->maxTemp(k - lkstart_[n]); @@ -512,8 +512,8 @@ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) for (size_t m = 0; m < lp->nElements(); m++) { if (constArr[m] != 0.0) { std::string oldEname = lp->elementName(m); - int newIndex = elementIndex(oldEname); - if (newIndex < 0) { + size_t newIndex = elementIndex(oldEname); + if (newIndex == npos) { throw CanteraError("LatticeSolidPhase::installSlavePhases", "confused"); } ecomp[newIndex] = constArr[m]; @@ -534,7 +534,7 @@ void LatticeSolidPhase::installSlavePhases(Cantera::XML_Node* phaseNode) string econ = "LC_"; econ += int2str(n); econ += "_" + id(); - int m = addUniqueElementAfterFreeze(econ, 0.0, 0, 0.0, CT_ELEM_TYPE_LATTICERATIO); + size_t m = addUniqueElementAfterFreeze(econ, 0.0, 0, 0.0, CT_ELEM_TYPE_LATTICERATIO); m_mm = nElements(); LatticePhase* lp0 = m_lattice[0]; size_t nsp0 = lp0->nSpecies(); @@ -574,7 +574,6 @@ void LatticeSolidPhase::initThermo() for (size_t n = 0; n < m_nlattice; n++) { nsp = m_lattice[n]->nSpecies(); lkstart_[n] = loc; - nspLattice_[n] = nsp; for (size_t k = 0; k < nsp; k++) { m_x[loc] =m_lattice[n]->moleFraction(k) / (double) m_nlattice; loc++; @@ -592,7 +591,6 @@ void LatticeSolidPhase::initThermo() void LatticeSolidPhase::initLengths() { theta_.resize(m_nlattice,0); - nspLattice_.resize(m_nlattice); lkstart_.resize(m_nlattice+1); m_x.resize(m_kk, 0.0); tmpV_.resize(m_kk, 0.0); diff --git a/src/thermo/MargulesVPSSTP.cpp b/src/thermo/MargulesVPSSTP.cpp index b1f841b59..dcb7de82d 100644 --- a/src/thermo/MargulesVPSSTP.cpp +++ b/src/thermo/MargulesVPSSTP.cpp @@ -403,11 +403,11 @@ void MargulesVPSSTP::getChemPotentials(doublereal* mu) const /// Molar enthalpy. Units: J/kmol. doublereal MargulesVPSSTP::enthalpy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double h = 0; vector_fp hbar(kk); getPartialMolarEnthalpies(&hbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { h += moleFractions_[i]*hbar[i]; } return h; @@ -416,11 +416,11 @@ doublereal MargulesVPSSTP::enthalpy_mole() const /// Molar entropy. Units: J/kmol. doublereal MargulesVPSSTP::entropy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double s = 0; vector_fp sbar(kk); getPartialMolarEntropies(&sbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { s += moleFractions_[i]*sbar[i]; } return s; @@ -429,11 +429,11 @@ doublereal MargulesVPSSTP::entropy_mole() const /// Molar heat capacity at constant pressure. Units: J/kmol/K. doublereal MargulesVPSSTP::cp_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double cp = 0; vector_fp cpbar(kk); getPartialMolarCp(&cpbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { cp += moleFractions_[i]*cpbar[i]; } return cp; @@ -1050,7 +1050,7 @@ void MargulesVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_diag) c } } //==================================================================================================================== -void MargulesVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoeffdlnN) +void MargulesVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN) { s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); diff --git a/src/thermo/MixedSolventElectrolyte.cpp b/src/thermo/MixedSolventElectrolyte.cpp index f40f5c64d..890d97139 100644 --- a/src/thermo/MixedSolventElectrolyte.cpp +++ b/src/thermo/MixedSolventElectrolyte.cpp @@ -187,16 +187,16 @@ MixedSolventElectrolyte::MixedSolventElectrolyte(int testProb) : m_SE_d_ij[0] = 0.0; - int iLiCl = speciesIndex("LiCl(L)"); - if (iLiCl < 0) { + size_t iLiCl = speciesIndex("LiCl(L)"); + if (iLiCl == npos) { throw CanteraError("MixedSolventElectrolyte test1 constructor", "Unable to find LiCl(L)"); } m_pSpecies_B_ij[0] = iLiCl; - int iKCl = speciesIndex("KCl(L)"); - if (iKCl < 0) { + size_t iKCl = speciesIndex("KCl(L)"); + if (iKCl == npos) { throw CanteraError("MixedSolventElectrolyte test1 constructor", "Unable to find KCl(L)"); } @@ -707,8 +707,8 @@ void MixedSolventElectrolyte::initThermoXML(XML_Node& phaseNode, std::string id) throw CanteraError(subname.c_str(), "Unknown activity coefficient model: " + mStringa); } - int n = acNodePtr->nChildren(); - for (int i = 0; i < n; i++) { + size_t n = acNodePtr->nChildren(); + for (size_t i = 0; i < n; i++) { XML_Node& xmlACChild = acNodePtr->child(i); stemp = xmlACChild.name(); string nodeName = lowercase(stemp); @@ -1052,7 +1052,7 @@ void MixedSolventElectrolyte::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdln } } //==================================================================================================================== -void MixedSolventElectrolyte::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoeffdlnN) +void MixedSolventElectrolyte::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN) { s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); @@ -1063,7 +1063,7 @@ void MixedSolventElectrolyte::getdlnActCoeffdlnN(const int ld, doublereal* dlnAc } } //==================================================================================================================== -void MixedSolventElectrolyte::resizeNumInteractions(const int num) +void MixedSolventElectrolyte::resizeNumInteractions(const size_t num) { numBinaryInteractions_ = num; m_HE_b_ij.resize(num, 0.0); @@ -1101,7 +1101,7 @@ void MixedSolventElectrolyte::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) } double* charge = DATA_PTR(m_speciesCharge); string stemp; - int nParamsFound; + size_t nParamsFound; vector_fp vParams; string iName = xmLBinarySpecies.attrib("speciesA"); if (iName == "") { @@ -1115,16 +1115,16 @@ void MixedSolventElectrolyte::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) * Find the index of the species in the current phase. It's not * an error to not find the species */ - int iSpecies = speciesIndex(iName); - if (iSpecies < 0) { + size_t iSpecies = speciesIndex(iName); + if (iSpecies == npos) { return; } string ispName = speciesName(iSpecies); if (charge[iSpecies] != 0) { throw CanteraError("MixedSolventElectrolyte::readXMLBinarySpecies", "speciesA charge problem"); } - int jSpecies = speciesIndex(jName); - if (jSpecies < 0) { + size_t jSpecies = speciesIndex(jName); + if (jSpecies == npos) { return; } string jspName = speciesName(jSpecies); @@ -1133,12 +1133,12 @@ void MixedSolventElectrolyte::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) } resizeNumInteractions(numBinaryInteractions_ + 1); - int iSpot = numBinaryInteractions_ - 1; + size_t iSpot = numBinaryInteractions_ - 1; m_pSpecies_A_ij[iSpot] = iSpecies; m_pSpecies_B_ij[iSpot] = jSpecies; - int num = xmLBinarySpecies.nChildren(); - for (int iChild = 0; iChild < num; iChild++) { + size_t num = xmLBinarySpecies.nChildren(); + for (size_t iChild = 0; iChild < num; iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); stemp = xmlChild.name(); string nodeName = lowercase(stemp); diff --git a/src/thermo/MolarityIonicVPSSTP.cpp b/src/thermo/MolarityIonicVPSSTP.cpp index 443b6eb9f..8f99b0a28 100644 --- a/src/thermo/MolarityIonicVPSSTP.cpp +++ b/src/thermo/MolarityIonicVPSSTP.cpp @@ -635,7 +635,7 @@ void MolarityIonicVPSSTP::initThermo() * Go find the list of cations and anions */ double ch; - numCationSpecies_ = 0.0; + numCationSpecies_ = 0; cationList_.clear(); anionList_.clear(); passThroughList_.clear(); @@ -721,8 +721,8 @@ void MolarityIonicVPSSTP::initThermoXML(XML_Node& phaseNode, std::string id) // throw CanteraError(subname.c_str(), // "Unknown activity coefficient model: " + mStringa); //} - int n = acNodePtr->nChildren(); - for (int i = 0; i < n; i++) { + size_t n = acNodePtr->nChildren(); + for (size_t i = 0; i < n; i++) { XML_Node& xmlACChild = acNodePtr->child(i); stemp = xmlACChild.name(); std::string nodeName = lowercase(stemp); @@ -779,7 +779,7 @@ std::string MolarityIonicVPSSTP::report(bool show_thermo) const sprintf(p, " potential %12.6g V\n", phi); s += p; - int kk = nSpecies(); + size_t kk = nSpecies(); array_fp x(kk); array_fp molal(kk); array_fp mu(kk); diff --git a/src/thermo/PhaseCombo_Interaction.cpp b/src/thermo/PhaseCombo_Interaction.cpp index 7f9bf3984..784493d1d 100644 --- a/src/thermo/PhaseCombo_Interaction.cpp +++ b/src/thermo/PhaseCombo_Interaction.cpp @@ -197,16 +197,16 @@ PhaseCombo_Interaction::PhaseCombo_Interaction(int testProb) : m_SE_d_ij[0] = 0.0; - int iLiT = speciesIndex("LiTFe1S2(S)"); - if (iLiT < 0) { + size_t iLiT = speciesIndex("LiTFe1S2(S)"); + if (iLiT == npos) { throw CanteraError("PhaseCombo_Interaction test1 constructor", "Unable to find LiTFe1S2(S)"); } m_pSpecies_A_ij[0] = iLiT; - int iLi2 = speciesIndex("Li2Fe1S2(S)"); - if (iLi2 < 0) { + size_t iLi2 = speciesIndex("Li2Fe1S2(S)"); + if (iLi2 == npos) { throw CanteraError("PhaseCombo_Interaction test1 constructor", "Unable to find Li2Fe1S2(S)"); } @@ -717,8 +717,8 @@ void PhaseCombo_Interaction::initThermoXML(XML_Node& phaseNode, std::string id) throw CanteraError(subname.c_str(), "Unknown activity coefficient model: " + mStringa); } - int n = acNodePtr->nChildren(); - for (int i = 0; i < n; i++) { + size_t n = acNodePtr->nChildren(); + for (size_t i = 0; i < n; i++) { XML_Node& xmlACChild = acNodePtr->child(i); stemp = xmlACChild.name(); string nodeName = lowercase(stemp); @@ -1061,20 +1061,15 @@ void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnN() const //==================================================================================================================== void PhaseCombo_Interaction::s_update_dlnActCoeff_dlnX_diag() const { - - int iA, iB; doublereal XA, XB, g0 , g1; doublereal T = temperature(); dlnActCoeffdlnX_diag_.assign(m_kk, 0.0); - doublereal RT = GasConstant * T; - for (size_t i = 0; i < numBinaryInteractions_; i++) { - - iA = m_pSpecies_A_ij[i]; - iB = m_pSpecies_B_ij[i]; + size_t iA = m_pSpecies_A_ij[i]; + size_t iB = m_pSpecies_B_ij[i]; XA = moleFractions_[iA]; XB = moleFractions_[iB]; @@ -1117,7 +1112,7 @@ void PhaseCombo_Interaction::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX /* * HKM - Checked for Transition */ -void PhaseCombo_Interaction::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoeffdlnN) +void PhaseCombo_Interaction::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN) { s_update_dlnActCoeff_dlnN(); double* data = & dlnActCoeffdlnN_(0,0); @@ -1132,7 +1127,7 @@ void PhaseCombo_Interaction::getdlnActCoeffdlnN(const int ld, doublereal* dlnAct /* * HKM - Checked for Transition */ -void PhaseCombo_Interaction::resizeNumInteractions(const int num) +void PhaseCombo_Interaction::resizeNumInteractions(const size_t num) { numBinaryInteractions_ = num; m_HE_b_ij.resize(num, 0.0); @@ -1169,7 +1164,7 @@ void PhaseCombo_Interaction::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) } double* charge = DATA_PTR(m_speciesCharge); string stemp; - int nParamsFound; + size_t nParamsFound; vector_fp vParams; string iName = xmLBinarySpecies.attrib("speciesA"); if (iName == "") { @@ -1183,16 +1178,16 @@ void PhaseCombo_Interaction::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) * Find the index of the species in the current phase. It's not * an error to not find the species */ - int iSpecies = speciesIndex(iName); - if (iSpecies < 0) { + size_t iSpecies = speciesIndex(iName); + if (iSpecies == npos) { return; } string ispName = speciesName(iSpecies); if (charge[iSpecies] != 0) { throw CanteraError("PhaseCombo_Interaction::readXMLBinarySpecies", "speciesA charge problem"); } - int jSpecies = speciesIndex(jName); - if (jSpecies < 0) { + size_t jSpecies = speciesIndex(jName); + if (jSpecies == npos) { return; } string jspName = speciesName(jSpecies); @@ -1201,12 +1196,12 @@ void PhaseCombo_Interaction::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) } resizeNumInteractions(numBinaryInteractions_ + 1); - int iSpot = numBinaryInteractions_ - 1; + size_t iSpot = numBinaryInteractions_ - 1; m_pSpecies_A_ij[iSpot] = iSpecies; m_pSpecies_B_ij[iSpot] = jSpecies; - int num = xmLBinarySpecies.nChildren(); - for (int iChild = 0; iChild < num; iChild++) { + size_t num = xmLBinarySpecies.nChildren(); + for (size_t iChild = 0; iChild < num; iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); stemp = xmlChild.name(); string nodeName = lowercase(stemp); diff --git a/src/thermo/RedlichKisterVPSSTP.cpp b/src/thermo/RedlichKisterVPSSTP.cpp index 7353775df..4cd7afc2a 100644 --- a/src/thermo/RedlichKisterVPSSTP.cpp +++ b/src/thermo/RedlichKisterVPSSTP.cpp @@ -123,16 +123,16 @@ RedlichKisterVPSSTP::RedlichKisterVPSSTP(int testProb) : m_pSpecies_A_ij.resize(1); m_pSpecies_B_ij.resize(1); - int iLiLi = speciesIndex("LiLi"); - if (iLiLi < 0) { + size_t iLiLi = speciesIndex("LiLi"); + if (iLiLi == npos) { throw CanteraError("RedlichKisterVPSSTP test1 constructor", "Unable to find LiLi"); } m_pSpecies_A_ij[0] = iLiLi; - int iVLi = speciesIndex("VLi"); - if (iVLi < 0) { + size_t iVLi = speciesIndex("VLi"); + if (iVLi == npos) { throw CanteraError("RedlichKisterVPSSTP test1 constructor", "Unable to find VLi"); } @@ -409,11 +409,11 @@ void RedlichKisterVPSSTP::getChemPotentials(doublereal* mu) const //Molar enthalpy. Units: J/kmol. doublereal RedlichKisterVPSSTP::enthalpy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double h = 0; vector_fp hbar(kk); getPartialMolarEnthalpies(&hbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { h += moleFractions_[i]*hbar[i]; } return h; @@ -422,11 +422,11 @@ doublereal RedlichKisterVPSSTP::enthalpy_mole() const /// Molar entropy. Units: J/kmol. doublereal RedlichKisterVPSSTP::entropy_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double s = 0; vector_fp sbar(kk); getPartialMolarEntropies(&sbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { s += moleFractions_[i]*sbar[i]; } return s; @@ -435,11 +435,11 @@ doublereal RedlichKisterVPSSTP::entropy_mole() const /// Molar heat capacity at constant pressure. Units: J/kmol/K. doublereal RedlichKisterVPSSTP::cp_mole() const { - int kk = nSpecies(); + size_t kk = nSpecies(); double cp = 0; vector_fp cpbar(kk); getPartialMolarCp(&cpbar[0]); - for (int i = 0; i < kk; i++) { + for (size_t i = 0; i < kk; i++) { cp += moleFractions_[i]*cpbar[i]; } return cp; @@ -678,8 +678,8 @@ void RedlichKisterVPSSTP::initThermoXML(XML_Node& phaseNode, std::string id) throw CanteraError(subname.c_str(), "Unknown activity coefficient model: " + mStringa); } - int n = acNodePtr->nChildren(); - for (int i = 0; i < n; i++) { + size_t n = acNodePtr->nChildren(); + for (size_t i = 0; i < n; i++) { XML_Node& xmlACChild = acNodePtr->child(i); stemp = xmlACChild.name(); std::string nodeName = lowercase(stemp); @@ -960,7 +960,7 @@ void RedlichKisterVPSSTP::getdlnActCoeffdlnX_diag(doublereal* dlnActCoeffdlnX_di } } //==================================================================================================================== -void RedlichKisterVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoeffdlnN) +void RedlichKisterVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnActCoeffdlnN) { s_update_dlnActCoeff_dX_(); double* data = & dlnActCoeffdlnN_(0,0); @@ -971,7 +971,7 @@ void RedlichKisterVPSSTP::getdlnActCoeffdlnN(const int ld, doublereal* dlnActCoe } } //==================================================================================================================== -void RedlichKisterVPSSTP::resizeNumInteractions(const int num) +void RedlichKisterVPSSTP::resizeNumInteractions(const size_t num) { numBinaryInteractions_ = num; m_pSpecies_A_ij.resize(num, -1); @@ -1013,16 +1013,16 @@ void RedlichKisterVPSSTP::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) * an error to not find the species. This means that the interaction doesn't occur for the current * implementation of the phase. */ - int iSpecies = speciesIndex(iName); - if (iSpecies < 0) { + size_t iSpecies = speciesIndex(iName); + if (iSpecies == npos) { return; } string ispName = speciesName(iSpecies); if (charge[iSpecies] != 0) { throw CanteraError("RedlichKisterVPSSTP::readXMLBinarySpecies", "speciesA charge problem"); } - int jSpecies = speciesIndex(jName); - if (jSpecies < 0) { + size_t jSpecies = speciesIndex(jName); + if (jSpecies == npos) { return; } std::string jspName = speciesName(jSpecies); @@ -1033,14 +1033,14 @@ void RedlichKisterVPSSTP::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) * Ok we have found a valid interaction */ numBinaryInteractions_++; - int iSpot = numBinaryInteractions_ - 1; + size_t iSpot = numBinaryInteractions_ - 1; m_pSpecies_A_ij.resize(numBinaryInteractions_); m_pSpecies_B_ij.resize(numBinaryInteractions_); m_pSpecies_A_ij[iSpot] = iSpecies; m_pSpecies_B_ij[iSpot] = jSpecies; - int num = xmLBinarySpecies.nChildren(); - for (int iChild = 0; iChild < num; iChild++) { + size_t num = xmLBinarySpecies.nChildren(); + for (size_t iChild = 0; iChild < num; iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); stemp = xmlChild.name(); string nodeName = lowercase(stemp); diff --git a/src/thermo/RedlichKisterVPSSTP.h b/src/thermo/RedlichKisterVPSSTP.h index a06ffb996..ea098111d 100644 --- a/src/thermo/RedlichKisterVPSSTP.h +++ b/src/thermo/RedlichKisterVPSSTP.h @@ -800,7 +800,7 @@ public: * @param dlnActCoeffdlnN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ - virtual void getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) ; + virtual void getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) ; //@} @@ -823,7 +823,7 @@ private: /*! * @param num Number of binary Redlich-Kister interaction terms */ - void resizeNumInteractions(const int num); + void resizeNumInteractions(const size_t num); //! Initialize lengths of local variables after all species have @@ -885,14 +885,14 @@ protected: * Each Redlich-Kister excess Gibbs free energy term involves two species, A and B. * This vector identifies species A. */ - vector_int m_pSpecies_A_ij; + std::vector m_pSpecies_A_ij; //! vector of species indices representing species B in the interaction /*! * Each Redlich-Kisterexcess Gibbs free energy term involves two species, A and B. * This vector identifies species B. */ - vector_int m_pSpecies_B_ij; + std::vector m_pSpecies_B_ij; //! Vector of the length of the polynomial for the interaction. diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index 18b06d570..37ec5f027 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -169,7 +169,7 @@ void ThermoPhase::getActivities(doublereal* a) const } } //================================================================================================================= -void ThermoPhase::getLnActivityCoefficients(doublereal* const lnac) const +void ThermoPhase::getLnActivityCoefficients(doublereal* lnac) const { getActivityCoefficients(lnac); for (size_t k = 0; k < m_kk; k++) { @@ -1159,7 +1159,7 @@ bool ThermoPhase::getElementPotentials(doublereal* lambda) const * @param dlnActCoeffdN Output vector of derivatives of the * log Activity Coefficients. length = m_kk * m_kk */ -void ThermoPhase::getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeffdlnN) +void ThermoPhase::getdlnActCoeffdlnN(const size_t ld, doublereal* const dlnActCoeffdlnN) { for (size_t m = 0; m < m_kk; m++) { for (size_t k = 0; k < m_kk; k++) { @@ -1169,7 +1169,7 @@ void ThermoPhase::getdlnActCoeffdlnN(const int ld, doublereal* const dlnActCoeff return; } //==================================================================================================================== -void ThermoPhase::getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dlnActCoeffdlnN) +void ThermoPhase::getdlnActCoeffdlnN_numderiv(const size_t ld, doublereal* const dlnActCoeffdlnN) { double deltaMoles_j = 0.0; double pres = pressure(); @@ -1230,7 +1230,7 @@ void ThermoPhase::getdlnActCoeffdlnN_numderiv(const int ld, doublereal* const dl * Revert to the base case Xmol_, v_totalMoles */ v_totalMoles = TMoles_base; - mdp::mdp_copy_dbl_1(DATA_PTR(Xmol), DATA_PTR(Xmol_Base), m_kk); + mdp::mdp_copy_dbl_1(DATA_PTR(Xmol), DATA_PTR(Xmol_Base), (int) m_kk); } /* * Go get base values for the activity coefficients. diff --git a/src/transport/LiquidTranInteraction.cpp b/src/transport/LiquidTranInteraction.cpp index 6b424b2b1..bae634f09 100644 --- a/src/transport/LiquidTranInteraction.cpp +++ b/src/transport/LiquidTranInteraction.cpp @@ -59,26 +59,26 @@ LiquidTranInteraction::LiquidTranInteraction(TransportPropertyType tp_ind) : LiquidTranInteraction::~LiquidTranInteraction() { - int kmax = m_Aij.size(); - for (int k = 0; k < kmax; k++) { + size_t kmax = m_Aij.size(); + for (size_t k = 0; k < kmax; k++) { if (m_Aij[k]) { delete m_Aij[k]; } } kmax = m_Bij.size(); - for (int k = 0; k < kmax; k++) { + for (size_t k = 0; k < kmax; k++) { if (m_Bij[k]) { delete m_Bij[k]; } } kmax = m_Hij.size(); - for (int k = 0; k < kmax; k++) { + for (size_t k = 0; k < kmax; k++) { if (m_Hij[k]) { delete m_Hij[k]; } } kmax = m_Sij.size(); - for (int k = 0; k < kmax; k++) { + for (size_t k = 0; k < kmax; k++) { if (m_Sij[k]) { delete m_Sij[k]; } @@ -93,7 +93,7 @@ void LiquidTranInteraction::init(const XML_Node& compModelNode, m_thermo = thermo; - int nsp = thermo->nSpecies(); + size_t nsp = thermo->nSpecies(); m_Dij.resize(nsp, nsp, 0.0); m_Eij.resize(nsp, nsp, 0.0); /* @@ -112,8 +112,8 @@ void LiquidTranInteraction::init(const XML_Node& compModelNode, std::string speciesA; std::string speciesB; - int num = compModelNode.nChildren(); - for (int iChild = 0; iChild < num; iChild++) { + size_t num = compModelNode.nChildren(); + for (size_t iChild = 0; iChild < num; iChild++) { XML_Node& xmlChild = compModelNode.child(iChild); std::string nodeName = lowercase(xmlChild.name()); if (nodeName != "interaction") { @@ -122,12 +122,12 @@ void LiquidTranInteraction::init(const XML_Node& compModelNode, } speciesA = xmlChild.attrib("speciesA"); speciesB = xmlChild.attrib("speciesB"); - int iSpecies = m_thermo->speciesIndex(speciesA); + size_t iSpecies = m_thermo->speciesIndex(speciesA); if (iSpecies < 0) { throw CanteraError("TransportFactory::getLiquidInteractionsTransportData", "Unknown species " + speciesA); } - int jSpecies = m_thermo->speciesIndex(speciesB); + size_t jSpecies = m_thermo->speciesIndex(speciesB); if (jSpecies < 0) { throw CanteraError("TransportFactory::getLiquidInteractionsTransportData", "Unknown species " + speciesB); @@ -168,7 +168,7 @@ void LiquidTranInteraction::init(const XML_Node& compModelNode, bTemp->resize(nsp, nsp, 0.0); m_Bij.push_back(bTemp); } - for (int i=0; i<(int)poly.size(); i++) { + for (size_t i=0; iresize(nsp, nsp, 0.0); m_Hij.push_back(hTemp); } - for (int i=0; i<(int)poly.size(); i++) { + for (size_t i=0; iresize(nsp, nsp, 0.0); m_Sij.push_back(sTemp); } - for (int i=0; i<(int)poly.size(); i++) { + for (size_t i=0; inSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -266,7 +266,7 @@ doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* s //if weightings are specified, use those if (speciesWeight) { - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]; // should be: molefracs[k] = molefracs[k]*speciesWeight[k]; for consistency, but weight(solvent)=1? } @@ -281,7 +281,7 @@ doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* s }*/ } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { //presume that the weighting is set to 1.0 for solvent and 0.0 for everything else. value += speciesValues[i] * speciesWeight[i]; if (i == 0) { @@ -289,12 +289,12 @@ doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* s } else { AssertTrace(speciesWeight[i] == 0.0); } - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (int) k); } - for (int k = 0; k < (int)m_Bij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i],k); + for (size_t k = 0; k < m_Bij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (int) k); } } } @@ -305,27 +305,27 @@ doublereal LTI_Solvent::getMixTransProp(doublereal* speciesValues, doublereal* s doublereal LTI_Solvent::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); doublereal value = 0.0; - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]; // should be: molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight(); for consistency, but weight(solvent)=1? } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { //presume that the weighting is set to 1.0 for solvent and 0.0 for everything else. value += LTPptrs[i]->getSpeciesTransProp() * LTPptrs[i]->getMixWeight(); - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (int) k); } - for (int k = 0; k < (int)m_Bij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i],k); + for (size_t k = 0; k < m_Bij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (int) k); } } } @@ -343,7 +343,7 @@ void LTI_Solvent::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues doublereal LTI_MoleFracs::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -359,14 +359,14 @@ doublereal LTI_MoleFracs::getMixTransProp(doublereal* speciesValues, doublereal* throw CanteraError("LTI_MoleFracs::getMixTransProp","You should be specifying the speciesWeight"); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += speciesValues[i] * molefracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (int) k); } - for (int k = 0; k < (int)m_Bij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i],k); + for (size_t k = 0; k < m_Bij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (int) k); } } } @@ -378,25 +378,25 @@ doublereal LTI_MoleFracs::getMixTransProp(doublereal* speciesValues, doublereal* doublereal LTI_MoleFracs::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); doublereal value = 0; - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight(); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (int) k); } - for (int k = 0; k < (int)m_Bij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i],k); + for (size_t k = 0; k < m_Bij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Bij[k])(i,j)*temp*pow(molefracs[i], (int) k); } } } @@ -407,7 +407,7 @@ doublereal LTI_MoleFracs::getMixTransProp(std::vector LTPptrs) doublereal LTI_MassFracs::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp massfracs(nsp); m_thermo->getMassFractions(&massfracs[0]); @@ -416,21 +416,21 @@ doublereal LTI_MassFracs::getMixTransProp(doublereal* speciesValues, doublereal* //if weightings are specified, use those if (speciesWeight) { - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { massfracs[k] = massfracs[k]*speciesWeight[k]; } } else { throw CanteraError("LTI_MassFracs::getMixTransProp","You should be specifying the speciesWeight"); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += speciesValues[i] * massfracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += massfracs[i]*massfracs[j]*(*m_Aij[k])(i,j)*pow(massfracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += massfracs[i]*massfracs[j]*(*m_Aij[k])(i,j)*pow(massfracs[i], (int) k); } - for (int k = 0; k < (int)m_Bij.size(); k++) { - value += massfracs[i]*massfracs[j]*(*m_Bij[k])(i,j)*temp*pow(massfracs[i],k); + for (size_t k = 0; k < m_Bij.size(); k++) { + value += massfracs[i]*massfracs[j]*(*m_Bij[k])(i,j)*temp*pow(massfracs[i], (int) k); } } } @@ -442,25 +442,25 @@ doublereal LTI_MassFracs::getMixTransProp(doublereal* speciesValues, doublereal* doublereal LTI_MassFracs::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp massfracs(nsp); m_thermo->getMassFractions(&massfracs[0]); doublereal value = 0; - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { massfracs[k] = massfracs[k]*LTPptrs[k]->getMixWeight(); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += LTPptrs[i]->getSpeciesTransProp() * massfracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += massfracs[i]*massfracs[j]*(*m_Aij[k])(i,j)*pow(massfracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += massfracs[i]*massfracs[j]*(*m_Aij[k])(i,j)*pow(massfracs[i], (int) k); } - for (int k = 0; k < (int)m_Bij.size(); k++) { - value += massfracs[i]*massfracs[j]*(*m_Bij[k])(i,j)*temp*pow(massfracs[i],k); + for (size_t k = 0; k < m_Bij.size(); k++) { + value += massfracs[i]*massfracs[j]*(*m_Bij[k])(i,j)*temp*pow(massfracs[i], (int) k); } } } @@ -474,7 +474,7 @@ doublereal LTI_MassFracs::getMixTransProp(std::vector LTPptrs) doublereal LTI_Log_MoleFracs::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -485,22 +485,22 @@ doublereal LTI_Log_MoleFracs::getMixTransProp(doublereal* speciesValues, doubler //if weightings are specified, use those if (speciesWeight) { - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]*speciesWeight[k]; } } else { throw CanteraError("LTI_Log_MoleFracs::getMixTransProp","You probably should have a speciesWeight when you call getMixTransProp to convert ion mole fractions to molecular mole fractions"); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += log(speciesValues[i]) * molefracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Hij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Hij[k])(i,j)/temp*pow(molefracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Hij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Hij[k])(i,j)/temp*pow(molefracs[i], (int) k); //cout << "value = " << value << ", m_Sij = " << (*m_Sij[k])(i,j) << ", m_Hij = " << (*m_Hij[k])(i,j) << endl; } - for (int k = 0; k < (int)m_Sij.size(); k++) { - value -= molefracs[i]*molefracs[j]*(*m_Sij[k])(i,j)*pow(molefracs[i],k); + for (size_t k = 0; k < m_Sij.size(); k++) { + value -= molefracs[i]*molefracs[j]*(*m_Sij[k])(i,j)*pow(molefracs[i], (int) k); //cout << "value = " << value << ", m_Sij = " << (*m_Sij[k])(i,j) << ", m_Hij = " << (*m_Hij[k])(i,j) << endl; } } @@ -514,7 +514,7 @@ doublereal LTI_Log_MoleFracs::getMixTransProp(doublereal* speciesValues, doubler doublereal LTI_Log_MoleFracs::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -524,20 +524,20 @@ doublereal LTI_Log_MoleFracs::getMixTransProp(std::vector LTPptrs) //if weightings are specified, use those - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight(); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += log(LTPptrs[i]->getSpeciesTransProp()) * molefracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Hij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Hij[k])(i,j)/temp*pow(molefracs[i],k); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Hij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Hij[k])(i,j)/temp*pow(molefracs[i], (int) k); //cout << "1 = " << molefracs[i]+molefracs[j] << endl; //cout << "value = " << value << ", m_Sij = " << (*m_Sij[k])(i,j) << ", m_Hij = " << (*m_Hij[k])(i,j) << endl; } - for (int k = 0; k < (int)m_Sij.size(); k++) { - value -= molefracs[i]*molefracs[j]*(*m_Sij[k])(i,j)*pow(molefracs[i],k); + for (size_t k = 0; k < m_Sij.size(); k++) { + value -= molefracs[i]*molefracs[j]*(*m_Sij[k])(i,j)*pow(molefracs[i], (int) k); //cout << "1 = " << molefracs[i]+molefracs[j] << endl; //cout << "value = " << value << ", m_Sij = " << (*m_Sij[k])(i,j) << ", m_Hij = " << (*m_Hij[k])(i,j) << endl; } @@ -557,10 +557,10 @@ doublereal LTI_Log_MoleFracs::getMixTransProp(std::vector LTPptrs) void LTI_Pairwise_Interaction::setParameters(LiquidTransportParams& trParam) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); m_diagonals.resize(nsp, 0); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { Cantera::LiquidTransportData& ltd = trParam.LTData[k]; if (ltd.speciesDiffusivity) { m_diagonals[k] = ltd.speciesDiffusivity; @@ -571,7 +571,7 @@ void LTI_Pairwise_Interaction::setParameters(LiquidTransportParams& trParam) doublereal LTI_Pairwise_Interaction::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -586,7 +586,7 @@ doublereal LTI_Pairwise_Interaction::getMixTransProp(doublereal* speciesValues, doublereal LTI_Pairwise_Interaction::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -600,18 +600,18 @@ doublereal LTI_Pairwise_Interaction::getMixTransProp(std::vector LT void LTI_Pairwise_Interaction::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); mat.resize(nsp, nsp, 0.0); - for (int i = 0; i < nsp; i++) - for (int j = 0; j < i; j++) { + for (size_t i = 0; i < nsp; i++) + for (size_t j = 0; j < i; j++) { mat(i,j) = mat(j,i) = exp(m_Eij(i,j) / temp) / m_Dij(i,j); } - for (int i = 0; i < nsp; i++) + for (size_t i = 0; i < nsp; i++) if (mat(i,i) == 0.0 && m_diagonals[i]) { mat(i,i) = 1.0 / m_diagonals[i]->getSpeciesTransProp() ; } @@ -620,8 +620,8 @@ void LTI_Pairwise_Interaction::getMatrixTransProp(DenseMatrix& mat, doublereal* void LTI_StefanMaxwell_PPN::setParameters(LiquidTransportParams& trParam) { - int nsp = m_thermo->nSpecies(); - int nsp2 = nsp*nsp; + size_t nsp = m_thermo->nSpecies(); + size_t nsp2 = nsp*nsp; //vectornSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -679,7 +679,7 @@ doublereal LTI_StefanMaxwell_PPN::getMixTransProp(doublereal* speciesValues, dou doublereal LTI_StefanMaxwell_PPN::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -695,8 +695,7 @@ void LTI_StefanMaxwell_PPN::getMatrixTransProp(DenseMatrix& mat, doublereal* spe //CAL IonsFromNeutralVPSSTP* ions_thermo = dynamic_cast(m_thermo); - int i, j, k; - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); if (nsp != 3) { throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Function may only be called with a 3-ion system"); } @@ -716,10 +715,10 @@ void LTI_StefanMaxwell_PPN::getMatrixTransProp(DenseMatrix& mat, doublereal* spe std::vector neutMolIndex(3); ions_thermo->getDissociationCoeffs(viS,charges,neutMolIndex); - if ((int)anion.size() != 1) { + if (anion.size() != 1) { throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Must have one anion only for StefanMaxwell_PPN"); } - if ((int)cation.size() != 2) { + if (cation.size() != 2) { throw CanteraError("LTI_StefanMaxwell_PPN::getMatrixTransProp","Must have two cations of equal charge for StefanMaxwell_PPN"); } if (charges[cation[0]] != charges[cation[1]]) { @@ -731,9 +730,9 @@ void LTI_StefanMaxwell_PPN::getMatrixTransProp(DenseMatrix& mat, doublereal* spe MargulesVPSSTP* marg_thermo = dynamic_cast(ions_thermo->neutralMoleculePhase_); doublereal vol = m_thermo->molarVolume(); - k = 0; - for (j = 0; j < nsp; j++) { - for (i = 0; i < nsp; i++) { + size_t k = 0; + for (size_t j = 0; j < nsp; j++) { + for (size_t i = 0; i < nsp; i++) { if (m_mobRatMixModel[k]) { m_mobRatMix(i,j) = m_mobRatMixModel[k]->getMixTransProp(m_mobRatSpecies[k]); if (m_mobRatMix(i,j) > 0.0) { @@ -749,6 +748,7 @@ void LTI_StefanMaxwell_PPN::getMatrixTransProp(DenseMatrix& mat, doublereal* spe m_selfDiffMix[k] = m_selfDiffMixModel[k]->getMixTransProp(m_selfDiffSpecies[k]); } + //! @todo Suspicious implicit conversion from double to int. int vP = max(viS[cation[0]],viS[cation[1]]); int vM = viS[anion[0]]; int zP = charges[cation[0]]; @@ -775,7 +775,7 @@ void LTI_StefanMaxwell_PPN::getMatrixTransProp(DenseMatrix& mat, doublereal* spe doublereal LTI_StokesEinstein::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -790,7 +790,7 @@ doublereal LTI_StokesEinstein::getMixTransProp(doublereal* speciesValues, double doublereal LTI_StokesEinstein::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -805,10 +805,10 @@ doublereal LTI_StokesEinstein::getMixTransProp(std::vector LTPptrs) void LTI_StokesEinstein::setParameters(LiquidTransportParams& trParam) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); m_viscosity.resize(nsp, 0); m_hydroRadius.resize(nsp, 0); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { Cantera::LiquidTransportData& ltd = trParam.LTData[k]; m_viscosity[k] = ltd.viscosity; m_hydroRadius[k] = ltd.hydroRadius; @@ -817,21 +817,20 @@ void LTI_StokesEinstein::setParameters(LiquidTransportParams& trParam) void LTI_StokesEinstein::getMatrixTransProp(DenseMatrix& mat, doublereal* speciesValues) { - - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); array_fp viscSpec(nsp); array_fp radiusSpec(nsp); - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { viscSpec[k] = m_viscosity[k]->getSpeciesTransProp() ; radiusSpec[k] = m_hydroRadius[k]->getSpeciesTransProp() ; } mat.resize(nsp,nsp, 0.0); - for (int i = 0; i < nsp; i++) - for (int j = 0; j < nsp; j++) { + for (size_t i = 0; i < nsp; i++) + for (size_t j = 0; j < nsp; j++) { mat(i,j) = (6.0 * Pi * radiusSpec[i] * viscSpec[j]) / GasConstant / temp; } } @@ -839,7 +838,7 @@ void LTI_StokesEinstein::getMatrixTransProp(DenseMatrix& mat, doublereal* specie doublereal LTI_MoleFracs_ExpT::getMixTransProp(doublereal* speciesValues, doublereal* speciesWeight) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); @@ -848,18 +847,18 @@ doublereal LTI_MoleFracs_ExpT::getMixTransProp(doublereal* speciesValues, double //if weightings are specified, use those if (speciesWeight) { - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]*speciesWeight[k]; } } else { throw CanteraError("LTI_MoleFracs_ExpT::getMixTransProp","You should be specifying the speciesWeight"); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += speciesValues[i] * molefracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i],k)*exp((*m_Bij[k])(i,j)*temp); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (int) k)*exp((*m_Bij[k])(i,j)*temp); } } } @@ -871,22 +870,22 @@ doublereal LTI_MoleFracs_ExpT::getMixTransProp(doublereal* speciesValues, double doublereal LTI_MoleFracs_ExpT::getMixTransProp(std::vector LTPptrs) { - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal temp = m_thermo->temperature(); vector_fp molefracs(nsp); m_thermo->getMoleFractions(&molefracs[0]); doublereal value = 0; - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { molefracs[k] = molefracs[k]*LTPptrs[k]->getMixWeight(); } - for (int i = 0; i < nsp; i++) { + for (size_t i = 0; i < nsp; i++) { value += LTPptrs[i]->getSpeciesTransProp() * molefracs[i]; - for (int j = 0; j < nsp; j++) { - for (int k = 0; k < (int)m_Aij.size(); k++) { - value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i],k)*exp((*m_Bij[k])(i,j)*temp); + for (size_t j = 0; j < nsp; j++) { + for (size_t k = 0; k < m_Aij.size(); k++) { + value += molefracs[i]*molefracs[j]*(*m_Aij[k])(i,j)*pow(molefracs[i], (int) k)*exp((*m_Bij[k])(i,j)*temp); } } } diff --git a/src/transport/LiquidTransport.cpp b/src/transport/LiquidTransport.cpp index 50483a101..9a71f2a5a 100644 --- a/src/transport/LiquidTransport.cpp +++ b/src/transport/LiquidTransport.cpp @@ -500,7 +500,7 @@ doublereal LiquidTransport::viscosity() * @param visc array of length "number of species" * to hold returned viscosities. */ -void LiquidTransport::getSpeciesViscosities(doublereal* visc) +void LiquidTransport::getSpeciesViscosities(doublereal* const visc) { update_T(); if (!m_visc_temp_ok) { @@ -1097,7 +1097,7 @@ void LiquidTransport::getSpeciesVdiffES(size_t ndim, * Flat vector with the m_nsp in the inner loop. * length = ldx * ndim */ -void LiquidTransport::getSpeciesFluxes(int ndim, +void LiquidTransport::getSpeciesFluxes(size_t ndim, const doublereal* grad_T, int ldx, const doublereal* grad_X, int ldf, doublereal* fluxes) diff --git a/src/transport/SimpleTransport.cpp b/src/transport/SimpleTransport.cpp index 1471f00e4..69dde68cd 100644 --- a/src/transport/SimpleTransport.cpp +++ b/src/transport/SimpleTransport.cpp @@ -250,10 +250,10 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr) tempDepType_ = 1; } else if (vm0 == LTR_MODEL_NOTSET) { throw CanteraError("SimpleTransport::initLiquid", - "Viscosity Model is not set for species " + spName0 + " in the input file"); + "Viscosity Model is not set for species " + spName0 + " in the input file"); } else { throw CanteraError("SimpleTransport::initLiquid", - "Viscosity Model for species " + spName0 + " is not handled by this object"); + "Viscosity Model for species " + spName0 + " is not handled by this object"); } */ @@ -266,7 +266,7 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr) if (vm != vm0) { if (compositionDepType_ != 0) { throw CanteraError(" SimpleTransport::initLiquid", - "different viscosity models for species " + spName + " and " + spName0 ); + "different viscosity models for species " + spName + " and " + spName0 ); } else { kentry = m_coeffVisc_Ns[0]; } @@ -297,7 +297,7 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr) if (cm != cm0) { if (compositionDepType_ != 0) { throw CanteraError(" SimpleTransport::initLiquid", - "different thermal conductivity models for species " + spName + " and " + spName0); + "different thermal conductivity models for species " + spName + " and " + spName0); } else { kentry = m_coeffLambda_Ns[0]; } @@ -322,7 +322,7 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr) LiquidTR_Model rm0 = ltd0.model_hydroradius; if (rm0 != vm0) { throw CanteraError("SimpleTransport::initLiquid", - "hydroradius model is not the same as the viscosity model for species " + spName0); + "hydroradius model is not the same as the viscosity model for species " + spName0); } else { useHydroRadius_ = true; } @@ -339,22 +339,22 @@ bool SimpleTransport::initLiquid(LiquidTransportParams& tr) LiquidTR_Model rm = ltd.model_hydroradius; if (rm == LTR_MODEL_NOTSET) { throw CanteraError("SimpleTransport::initLiquid", - "Neither diffusivity nor hydroradius is set for species " + spName); + "Neither diffusivity nor hydroradius is set for species " + spName); } if (rm != vm0) { throw CanteraError("SimpleTransport::initLiquid", - "hydroradius model is not the same as the viscosity model for species " + spName); + "hydroradius model is not the same as the viscosity model for species " + spName); } if (rm != LTR_MODEL_CONSTANT) { throw CanteraError("SimpleTransport::initLiquid", - "hydroradius model is not constant for species " + spName0); + "hydroradius model is not constant for species " + spName0); } vector_fp &kentry = m_coeffHydroRadius_Ns[k]; kentry = ltd.hydroradius; } else { if (dm != dm0) { throw CanteraError(" SimpleTransport::initLiquid", - "different diffusivity models for species " + spName + " and " + spName0 ); + "different diffusivity models for species " + spName + " and " + spName0 ); } vector_fp &kentry = m_coeffDiff_Ns[k]; kentry = ltd.speciesDiffusivity; @@ -452,7 +452,7 @@ doublereal SimpleTransport::viscosity() return m_viscmix; } //================================================================================================ -void SimpleTransport::getSpeciesViscosities(doublereal* visc) +void SimpleTransport::getSpeciesViscosities(doublereal* const visc) { update_T(); if (!m_visc_temp_ok) { diff --git a/src/transport/SolidTransport.cpp b/src/transport/SolidTransport.cpp index e81d0dd36..c2ea1763a 100644 --- a/src/transport/SolidTransport.cpp +++ b/src/transport/SolidTransport.cpp @@ -159,9 +159,9 @@ void SolidTransport::getMixDiffCoeffs(doublereal* const d) doublereal SolidTransport::electricalConductivity() { getMobilities(&m_work[0]); - int nsp = m_thermo->nSpecies(); + size_t nsp = m_thermo->nSpecies(); doublereal sum = 0.0; - for (int k = 0; k < nsp; k++) { + for (size_t k = 0; k < nsp; k++) { sum += m_thermo->charge(k) * m_thermo->moleFraction(k) * m_work[k]; } return sum * m_thermo->molarDensity(); diff --git a/src/transport/TransportBase.cpp b/src/transport/TransportBase.cpp index 0d3569a44..d6857110a 100644 --- a/src/transport/TransportBase.cpp +++ b/src/transport/TransportBase.cpp @@ -29,7 +29,7 @@ namespace Cantera //////////////////// class LiquidTransport methods ////////////// -Transport::Transport(thermo_t* thermo, int ndim) : +Transport::Transport(thermo_t* thermo, size_t ndim) : m_thermo(thermo), m_ready(false), m_nmin(0), @@ -148,7 +148,7 @@ void Transport::finalize() } //==================================================================================================================== -void Transport::getSpeciesFluxes(int ndim, const doublereal* const grad_T, +void Transport::getSpeciesFluxes(size_t ndim, const doublereal* const grad_T, int ldx, const doublereal* const grad_X, int ldf, doublereal* const fluxes) { diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index 436fb343a..f9bfa0d26 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -1013,8 +1013,8 @@ void TransportFactory::getLiquidSpeciesTransportData(const std::vectorspeciesIndex(specName.c_str()); + size_t index = temp_thermo->speciesIndex(specName.c_str()); data.selfDiffusion[index] = newLTP(propSpecNode, name, m_tranPropMap[nodeName], temp_thermo); }; }; @@ -1119,11 +1119,11 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp { try { - int nsp = trParam.nsp_; - int nBinInt = nsp*(nsp-1)/2; + size_t nsp = trParam.nsp_; + size_t nBinInt = nsp*(nsp-1)/2; - int num = transportNode.nChildren(); - for (int iChild = 0; iChild < num; iChild++) { + size_t num = transportNode.nChildren(); + for (size_t iChild = 0; iChild < num; iChild++) { //tranTypeNode is a type of transport property like viscosity XML_Node& tranTypeNode = transportNode.child(iChild); std::string nodeName = tranTypeNode.name(); @@ -1146,7 +1146,7 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp trParam); break; case TP_MOBILITYRATIO: { - for (int iSpec = 0; iSpec< nBinInt; iSpec++) { + for (size_t iSpec = 0; iSpec< nBinInt; iSpec++) { XML_Node& propSpecNode = compDepNode.child(iSpec); string specName = propSpecNode.name(); size_t loc = specName.find(":"); @@ -1160,10 +1160,10 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp }; break; case TP_SELFDIFFUSION: { - for (int iSpec = 0; iSpec< nsp; iSpec++) { + for (size_t iSpec = 0; iSpec< nsp; iSpec++) { XML_Node& propSpecNode = compDepNode.child(iSpec); string specName = propSpecNode.name(); - int index = temp_thermo->speciesIndex(specName.c_str()); + size_t index = temp_thermo->speciesIndex(specName.c_str()); trParam.selfDiffusion[index] = newLTI(propSpecNode, m_tranPropMap[nodeName], trParam); @@ -1211,7 +1211,7 @@ void TransportFactory::getLiquidInteractionsTransportData(const XML_Node& transp } else if (velocityBasis == "mole") { trParam.velocityBasis_ = VB_MOLEAVG; } else if (trParam.thermo->speciesIndex(velocityBasis) > 0) { - trParam.velocityBasis_ = trParam.thermo->speciesIndex(velocityBasis) ; + trParam.velocityBasis_ = static_cast(trParam.thermo->speciesIndex(velocityBasis)); } else { int linenum = __LINE__; throw TransportDBError(linenum, "Unknown attribute \"" + velocityBasis + "\" for node. ");