Fixed more signed/unsigned/size_t warnings

These were warnings that showed up when compiling with the Microsoft
Platform SDK.
This commit is contained in:
Ray Speth 2012-01-20 23:13:54 +00:00
parent ea2c3b977c
commit f23bb0365a
28 changed files with 80 additions and 99 deletions

View file

@ -2,6 +2,7 @@
* @file ctonedim.cpp
*/
#define CANTERA_USE_INTERNAL
#include "ctonedim.h"
// Cantera includes
@ -560,7 +561,7 @@ extern "C" {
int DLL_EXPORT sim1D_domainIndex(int i, char* name) {
try {
return _sim1D(i)->domainIndex(string(name));
return (int) _sim1D(i)->domainIndex(string(name));
}
catch (CanteraError) { return -1; }
}

View file

@ -204,7 +204,7 @@ extern "C" {
int DLL_EXPORT xml_nChildren(int i) {
try {
XML_Node& node = *_xml(i);
return node.nChildren();
return (int) node.nChildren();
}
catch (CanteraError) { return -1; }
}

View file

@ -805,7 +805,7 @@ namespace Cantera {
/*
* @param n Number of the child to return
*/
XML_Node& XML_Node::child(const int n) const {
XML_Node& XML_Node::child(const size_t n) const {
return *m_children[n];
}
@ -919,8 +919,7 @@ namespace Cantera {
}
if (depth > 0) {
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < nChildren(); i++) {
r = m_children[i]->findID(id, depth-1);
if (r != 0) return r;
}
@ -951,8 +950,7 @@ namespace Cantera {
}
}
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < nChildren(); i++) {
r = m_children[i]->findByAttr(attr, val);
if (r != 0) return r;
}
@ -975,8 +973,7 @@ namespace Cantera {
return this;
}
XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < nChildren(); i++) {
r = m_children[i]->findByName(nm);
if (r != 0) return r;
}
@ -999,8 +996,7 @@ namespace Cantera {
return const_cast<XML_Node*>(this);
}
const XML_Node* r = 0;
int n = nChildren();
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < nChildren(); i++) {
r = m_children[i]->findByName(nm);
if (r != 0) return r;
}
@ -1080,7 +1076,6 @@ namespace Cantera {
*/
void XML_Node::copyUnion(XML_Node * const node_dest) const {
XML_Node *sc, *dc;
int ndc, idc;
node_dest->addValue(m_value);
if (m_name == "") return;
map<string,string>::const_iterator b = m_attribs.begin();
@ -1092,10 +1087,10 @@ namespace Cantera {
const vector<XML_Node*> &vsc = node_dest->children();
for (size_t n = 0; n < m_nchildren; n++) {
sc = m_children[n];
ndc = node_dest->nChildren();
size_t ndc = node_dest->nChildren();
dc = 0;
if (! sc->m_iscomment) {
for (idc = 0; idc < ndc; idc++) {
for (size_t idc = 0; idc < ndc; idc++) {
XML_Node *dcc = vsc[idc];
if (dcc->name() == sc->name()) {
if (sc->hasAttrib("id")) {
@ -1133,7 +1128,6 @@ namespace Cantera {
*/
void XML_Node::copy(XML_Node * const node_dest) const {
XML_Node *sc, *dc;
int ndc;
node_dest->addValue(m_value);
node_dest->setName(m_name);
if (m_name == "") return;
@ -1145,7 +1139,7 @@ namespace Cantera {
for (size_t n = 0; n < m_nchildren; n++) {
sc = m_children[n];
ndc = node_dest->nChildren();
size_t ndc = node_dest->nChildren();
(void) node_dest->addChild(sc->name());
dc = vsc[ndc];
sc->copy(dc);
@ -1178,8 +1172,7 @@ namespace Cantera {
*/
void XML_Node::getChildren(const std::string &nm,
std::vector<XML_Node*>& children) const {
int i, n = nChildren();
for (i = 0; i < n; i++) {
for (size_t i = 0; i < nChildren(); i++) {
if (child(i).name() == nm) {
children.push_back(&child(i));
}

View file

@ -456,7 +456,7 @@ namespace Cantera {
/*!
* @param n Number of the child to return
*/
XML_Node& child(const int n) const ;
XML_Node& child(const size_t n) const ;
//! Return an unchangeable reference to the vector of children of the current node
/*!

View file

@ -26,7 +26,7 @@ namespace VCSnonideal {
* @return Returns true if the phase can come into existence
* and false otherwise.
*/
bool VCS_SOLVE::vcs_popPhasePossible(const int iphasePop) const {
bool VCS_SOLVE::vcs_popPhasePossible(const size_t iphasePop) const {
vcs_VolPhase *Vphase = m_VolPhaseList[iphasePop];
@ -404,7 +404,7 @@ namespace VCSnonideal {
}
double VCS_SOLVE::vcs_phaseStabilityTest(const int iph) {
double VCS_SOLVE::vcs_phaseStabilityTest(const size_t iph) {
/*
* We will use the _new state calc here

View file

@ -509,7 +509,7 @@ public:
* @return Returns true if the phase can come into existence
* and false otherwise.
*/
bool vcs_popPhasePossible(const int iphasePop) const;
bool vcs_popPhasePossible(const size_t iphasePop) const;
//! Decision as to whether a phase pops back into existence
/*!
@ -670,7 +670,7 @@ public:
*
* @param iph Phase id of the deleted phase
*/
double vcs_phaseStabilityTest(const int iph);
double vcs_phaseStabilityTest(const size_t iph);
//! Solve an equilibrium problem at a particular fixed temperature
//! and pressure

View file

@ -850,14 +850,14 @@ namespace Cantera {
/*!
* @param i index of the reaction
*/
doublereal multiplier(int i) const {return m_perturb[i];}
doublereal multiplier(size_t i) const {return m_perturb[i];}
/// Set the multiplier for reaction i to f.
/*!
* @param i index of the reaction
* @param f value of the multiplier.
*/
void setMultiplier(int i, doublereal f) {m_perturb[i] = f;}
void setMultiplier(size_t i, doublereal f) {m_perturb[i] = f;}
//@}

View file

@ -517,11 +517,9 @@ namespace Cantera {
"Unknown type: " + type);
}
int nc = kf.nChildren();
nodeset_t& kf_children = kf.children();
vector_fp clow(3,0.0), chigh(3,0.0);
// int nr = nReacMolecules(rdata);
for (int m = 0; m < nc; m++) {
for (size_t m = 0; m < kf.nChildren(); m++) {
const node_t& c = *kf_children[m];
string nm = c.name();
int highlow=0;
@ -845,7 +843,7 @@ namespace Cantera {
|| (c < 0.0 && m_rev[nn])) {
if ((!dup || !m_dup[nn])) {
string msg = string("Undeclared duplicate reactions detected: \n")
+"Reaction "+int2str(nn+1)+": "+m_eqn[nn]
+"Reaction "+int2str(int(nn)+1)+": "+m_eqn[nn]
+"\nReaction "+int2str(i+1)+": "+eqn+"\n";
throw CanteraError("installReaction", msg);
}

View file

@ -57,7 +57,7 @@ namespace Cantera {
virtual void setMoleFractions(doublereal* xin){err("setMoleFractions");}
/// Mass fraction of species k.
virtual doublereal massFraction(int k) {err("massFraction"); return 0.0;}
virtual doublereal massFraction(size_t k) {err("massFraction"); return 0.0;}
/// Set the total mass flow rate.
virtual void setMdot(doublereal mdot){m_mdot = mdot;}
@ -151,8 +151,8 @@ namespace Cantera {
virtual void setMoleFractions(std::string xin);
virtual void setMoleFractions(doublereal* xin);
virtual doublereal massFraction(int k) {return m_yin[k];}
virtual std::string componentName(int n) const;
virtual doublereal massFraction(size_t k) {return m_yin[k];}
virtual std::string componentName(size_t n) const;
virtual void init();
virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
integer* diagg, doublereal rdt);
@ -182,7 +182,7 @@ namespace Cantera {
}
virtual ~Empty1D(){}
virtual std::string componentName(int n) const;
virtual std::string componentName(size_t n) const;
virtual void showSolution(const doublereal* x) {}
virtual void init();
@ -214,7 +214,7 @@ namespace Cantera {
}
virtual ~Symm1D(){}
virtual std::string componentName(int n) const;
virtual std::string componentName(size_t n) const;
virtual void init();
@ -246,7 +246,7 @@ namespace Cantera {
}
virtual ~Outlet1D(){}
virtual std::string componentName(int n) const;
virtual std::string componentName(size_t n) const;
virtual void init();
@ -295,8 +295,8 @@ namespace Cantera {
virtual void setMoleFractions(std::string xin);
virtual void setMoleFractions(doublereal* xin);
virtual doublereal massFraction(int k) {return m_yres[k];}
virtual std::string componentName(int n) const;
virtual doublereal massFraction(size_t k) {return m_yres[k];}
virtual std::string componentName(size_t n) const;
virtual void init();
virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
integer* diagg, doublereal rdt);
@ -327,7 +327,7 @@ namespace Cantera {
}
virtual ~Surf1D(){}
virtual std::string componentName(int n) const;
virtual std::string componentName(size_t n) const;
virtual void init();

View file

@ -134,7 +134,8 @@ namespace Cantera {
"Jacobian is singular for domain "+
dom.id() + ", component "
+dom.componentName(comp)+" at point "
+int2str(int(pt))+"\n(Matrix row "+int2str(iok)+") \nsee file bandmatrix.csv\n");
+int2str(int(pt))+"\n(Matrix row "
+int2str(int(iok))+") \nsee file bandmatrix.csv\n");
}
else if (int(iok) < 0)
throw CanteraError("MultiNewton::step",

View file

@ -53,12 +53,12 @@ namespace Cantera {
}
int OneDim::domainIndex(string name) {
size_t OneDim::domainIndex(string name) {
for (size_t n = 0; n < m_nd; n++) {
if (domain(n).id() == name) return n;
}
throw CanteraError("OneDim::domainIndex","no domain named >>"+name+"<<");
return -1;
return npos;
}

View file

@ -52,7 +52,7 @@ namespace Cantera {
/// Return a reference to domain i.
Domain1D& domain(size_t i) const { return *m_dom[i]; }
int domainIndex(std::string name);
size_t domainIndex(std::string name);
/// The index of the start of domain i in the solution vector.
size_t start(size_t i) const { return m_dom[i]->loc(); }

View file

@ -970,7 +970,7 @@ namespace Cantera {
case 2: return "T";
case 3: return "lambda";
default:
if (n >= (int) c_offset_Y && n < (int) (c_offset_Y + m_nsp)) {
if (n >= c_offset_Y && n < (c_offset_Y + m_nsp)) {
return m_thermo->speciesName(n - c_offset_Y);
}
else

View file

@ -28,11 +28,11 @@ namespace Cantera {
//------------------------------------------
// Offsets of solution components in the solution array.
const unsigned int c_offset_U = 0; // axial velocity
const unsigned int c_offset_V = 1; // strain rate
const unsigned int c_offset_T = 2; // temperature
const unsigned int c_offset_L = 3; // (1/r)dP/dr
const unsigned int c_offset_Y = 4; // mass fractions
const size_t c_offset_U = 0; // axial velocity
const size_t c_offset_V = 1; // strain rate
const size_t c_offset_T = 2; // temperature
const size_t c_offset_L = 3; // (1/r)dP/dr
const size_t c_offset_Y = 4; // mass fractions
// Transport option flags
const int c_Mixav_Transport = 0;

View file

@ -102,7 +102,7 @@ namespace Cantera {
}
string Inlet1D::
componentName(int n) const {
componentName(size_t n) const {
switch (n) {
case 0:
return "mdot";
@ -259,7 +259,7 @@ namespace Cantera {
// Empty1D
//--------------------------------------------------
string Empty1D::componentName(int n) const {
string Empty1D::componentName(size_t n) const {
switch (n) {
case 0:
return "dummy";
@ -317,7 +317,7 @@ namespace Cantera {
// Symm1D
//--------------------------------------------------
string Symm1D::componentName(int n) const {
string Symm1D::componentName(size_t n) const {
switch (n) {
case 0:
return "dummy";
@ -399,7 +399,7 @@ namespace Cantera {
// Outlet1D
//--------------------------------------------------
string Outlet1D::componentName(int n) const {
string Outlet1D::componentName(size_t n) const {
switch (n) {
case 0:
return "outlet dummy";
@ -519,7 +519,7 @@ namespace Cantera {
}
}
string OutletRes1D::componentName(int n) const {
string OutletRes1D::componentName(size_t n) const {
switch (n) {
case 0:
return "dummy";
@ -641,7 +641,7 @@ namespace Cantera {
string Surf1D::componentName(int n) const {
string Surf1D::componentName(size_t n) const {
switch (n) {
case 0:
return "temperature";

View file

@ -345,7 +345,7 @@ namespace Cantera {
}
SpeciesThermoInterpType * GeneralSpeciesThermo::provideSTIT(int k) {
SpeciesThermoInterpType * GeneralSpeciesThermo::provideSTIT(size_t k) {
return (m_sp[k]);
}

View file

@ -229,7 +229,7 @@ namespace Cantera {
*
* @return pointer to the SpeciesThermoInterpType object.
*/
SpeciesThermoInterpType * provideSTIT(int k);
SpeciesThermoInterpType * provideSTIT(size_t k);
protected:

View file

@ -653,9 +653,9 @@ namespace Cantera {
double L = relative_enthalpy();
getMoleFractions(DATA_PTR(m_tmpV));
double xanion = 0.0;
int kcation = -1;
size_t kcation = npos;
double xcation = 0.0;
int kanion = -1;
size_t kanion = npos;
const double *charge = DATA_PTR(m_speciesCharge);
for (size_t k = 0; k < m_kk; k++) {
if (charge[k] > 0.0) {
@ -670,7 +670,7 @@ namespace Cantera {
}
}
}
if (kcation < 0 || kanion < 0) {
if (kcation == npos || kanion == npos) {
return L;
}
double xuse = xcation;
@ -1949,9 +1949,9 @@ namespace Cantera {
for (int times = 0; times< 10; times++) {
double anion_charge = 0.0;
double cation_charge = 0.0;
int anion_contrib_max_i = -1;
size_t anion_contrib_max_i = npos;
double anion_contrib_max = -1.0;
int cation_contrib_max_i = -1;
size_t cation_contrib_max_i = npos;
double cation_contrib_max = -1.0;
for (size_t i = 0; i < m_kk; i++) {
double charge_i = m_speciesCharge[i];

View file

@ -101,8 +101,7 @@ namespace Cantera {
size_t n = iSpecies * m_kk + jSpecies;
int counter = m_CounterIJ[n];
int num = BinSalt.nChildren();
for (int iChild = 0; iChild < num; iChild++) {
for (size_t iChild = 0; iChild < BinSalt.nChildren(); iChild++) {
XML_Node &xmlChild = BinSalt.child(iChild);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -305,8 +304,7 @@ namespace Cantera {
size_t n = iSpecies * m_kk + jSpecies;
int counter = m_CounterIJ[n];
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (size_t i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -392,8 +390,7 @@ namespace Cantera {
size_t n = iSpecies * m_kk + jSpecies;
int counter = m_CounterIJ[n];
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (size_t i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -493,8 +490,7 @@ namespace Cantera {
size_t n = iSpecies * m_kk + jSpecies;
int counter = m_CounterIJ[n];
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (size_t i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -638,8 +634,7 @@ namespace Cantera {
size_t n = iSpecies * m_kk + jSpecies;
int counter = m_CounterIJ[n];
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (size_t i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -771,8 +766,7 @@ namespace Cantera {
return;
}
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (size_t i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -850,9 +844,7 @@ namespace Cantera {
"neutral charge problem");
}
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (int i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -951,8 +943,7 @@ namespace Cantera {
throw CanteraError("HMWSoln::readXMLZetaCation", "anion1 charge problem");
}
int num = BinSalt.nChildren();
for (int i = 0; i < num; i++) {
for (size_t i = 0; i < BinSalt.nChildren(); i++) {
XML_Node &xmlChild = BinSalt.child(i);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);
@ -1539,8 +1530,7 @@ namespace Cantera {
* parameters
*/
if (acNodePtr) {
int n = acNodePtr->nChildren();
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < acNodePtr->nChildren(); i++) {
XML_Node &xmlACChild = acNodePtr->child(i);
stemp = xmlACChild.name();
string nodeName = lowercase(stemp);

View file

@ -613,8 +613,7 @@ namespace Cantera {
throw CanteraError(subname.c_str(),
"Unknown activity coefficient model: " + mStringa);
}
int n = acNodePtr->nChildren();
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < acNodePtr->nChildren(); i++) {
XML_Node &xmlACChild = acNodePtr->child(i);
stemp = xmlACChild.name();
string nodeName = lowercase(stemp);
@ -988,12 +987,11 @@ namespace Cantera {
}
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++) {
for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) {
XML_Node &xmlChild = xmLBinarySpecies.child(iChild);
stemp = xmlChild.name();
string nodeName = lowercase(stemp);

View file

@ -170,7 +170,7 @@ namespace Cantera {
/*
* return the solvent id index number.
*/
int MolalityVPSSTP::solventIndex() const {
size_t MolalityVPSSTP::solventIndex() const {
return m_indexSolvent;
}

View file

@ -303,7 +303,7 @@ namespace Cantera {
void setMoleFSolventMin(doublereal xmolSolventMIN);
//! Returns the solvent index.
int solventIndex() const;
size_t solventIndex() const;
/**
* Returns the minimum mole fraction in the molality

View file

@ -256,7 +256,7 @@ namespace Cantera {
vector_fp c(2 + 2 * numPoints);
c[0] = numPoints;
c[0] = static_cast<double>(numPoints);
c[1] = h298;
for (size_t i = 0; i < numPoints; i++) {
c[2+i*2] = cTemperatures[i];

View file

@ -129,8 +129,8 @@ namespace Cantera {
*
* @note This method is not used currently.
*/
void TransportFactory::getBinDiffCorrection(doublereal t,
const GasTransportParams& tr, int k, int j, doublereal xk, doublereal xj,
void TransportFactory::getBinDiffCorrection(doublereal t, const GasTransportParams& tr,
size_t k, size_t j, doublereal xk, doublereal xj,
doublereal& fkj, doublereal& fjk) {
doublereal w1, w2, wsum, sig1, sig2, sig12, sigratio, sigratio2,
@ -200,7 +200,7 @@ namespace Cantera {
* of polar-nonpolar pairs. For more information about this
* correction, see Dixon-Lewis, Proc. Royal Society (1968).
*/
void TransportFactory::makePolarCorrections(int i, int j,
void TransportFactory::makePolarCorrections(size_t i, size_t j,
const GasTransportParams& tr, doublereal& f_eps, doublereal& f_sigma) {
// no correction if both are nonpolar, or both are polar
@ -211,8 +211,8 @@ namespace Cantera {
// corrections to the effective diameter and well depth
// if one is polar and one is non-polar
int kp = (tr.polar[i] ? i : j); // the polar one
int knp = (i == kp ? j : i); // the nonpolar one
size_t kp = (tr.polar[i] ? i : j); // the polar one
size_t knp = (i == kp ? j : i); // the nonpolar one
doublereal d3np, d3p, alpha_star, mu_p_star, xi;
d3np = pow(tr.sigma[knp],3);

View file

@ -195,13 +195,13 @@ namespace Cantera {
/// Second-order correction to the binary diffusion coefficients
void getBinDiffCorrection(doublereal t,
const GasTransportParams& tr, int k, int j,
void getBinDiffCorrection(doublereal t, const GasTransportParams& tr,
size_t k, size_t j,
doublereal xk, doublereal xj,
doublereal& fkj, doublereal& fjk);
/// Corrections for polar-nonpolar binary diffusion coefficients
void makePolarCorrections(int i, int j,
void makePolarCorrections(size_t i, size_t j,
const GasTransportParams& tr, doublereal& f_eps,
doublereal& f_sigma);

View file

@ -126,7 +126,7 @@ namespace CanteraZeroD {
size_t m_nv;
size_t m_nsens;
vector_int m_pnum;
std::vector<size_t> m_pnum;
std::vector<std::string> m_pname;
std::vector<size_t> m_nsens_wall;
vector_fp m_mult_save;

View file

@ -123,7 +123,7 @@ namespace CanteraZeroD {
void Wall::addSensitivityReaction(int leftright, size_t rxn) {
if (rxn >= m_chem[leftright]->nReactions())
throw CanteraError("Wall::addSensitivityReaction",
"Reaction number out of range ("+int2str(rxn)+")");
"Reaction number out of range ("+int2str(int(rxn))+")");
if (leftright == 0) {
m_pleft.push_back(rxn);
m_leftmult_save.push_back(1.0);

View file

@ -157,7 +157,7 @@ namespace CanteraZeroD {
Cantera::Func1 *m_qf;
Cantera::vector_fp m_leftcov, m_rightcov;
Cantera::vector_int m_pleft, m_pright;
std::vector<size_t> m_pleft, m_pright;
Cantera::vector_fp m_leftmult_save, m_rightmult_save;
std::vector<std::string> m_pname_left, m_pname_right;