From 78947a6d481fcdf921792463ddbf2b2c4bd6ab0a Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Fri, 2 Jul 2004 17:28:09 +0000 Subject: [PATCH] static_cast to eliminate VC++ warnings. --- Cantera/src/converters/CKReader.cpp | 35 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Cantera/src/converters/CKReader.cpp b/Cantera/src/converters/CKReader.cpp index a5bdb0860..63fbad173 100755 --- a/Cantera/src/converters/CKReader.cpp +++ b/Cantera/src/converters/CKReader.cpp @@ -81,7 +81,7 @@ bool CKReader::read(const string& inputFile, const string& thermoDatabase, //----------- process ELEMENT section ---------------------- bool elok = parser.readElementSection(elements); - int nel = elements.size(); + int nel = static_cast(elements.size()); vector elementSymbols; for (int j = 0; j < nel; j++) elementSymbols.push_back(elements[j].name); @@ -119,7 +119,7 @@ bool CKReader::read(const string& inputFile, const string& thermoDatabase, vector speciesSymbols; bool spok = parser.readSpeciesSection(species); - int nsp = species.size(); + int nsp = static_cast(species.size()); if (verbose) log << newTask("reading species") << endl; @@ -161,14 +161,14 @@ bool CKReader::read(const string& inputFile, const string& thermoDatabase, bool hasthermo = parser.advanceToKeyword("THERM","REAC"); int k, optionFlag = 0; - int undefined = species.size(); + int undefined = static_cast(species.size()); string nm; vector undef; bool allsp = (speciesSymbols[0] == ""); if (hasthermo && parser.readThermoSection(speciesSymbols, speciesData, temp, optionFlag, log)) { if (allsp) { - nsp = speciesData.size(); + nsp = static_cast(speciesData.size()); for (k = 0; k < nsp; k++) { Species s; s.name = speciesSymbols[k]; @@ -213,7 +213,7 @@ bool CKReader::read(const string& inputFile, const string& thermoDatabase, undefined = 0; if (allsp) { species.clear(); - nsp = speciesData.size(); + nsp = static_cast(speciesData.size()); for (k = 0; k < nsp; k++) { Species s; s.name = undef[k]; @@ -251,7 +251,8 @@ bool CKReader::read(const string& inputFile, const string& thermoDatabase, parser2.verbose = verbose; parser2.readReactionSection(speciesSymbols, elementSymbols, reactions, units); - log << "\nread " << reactions.size() << " reactions." << endl; + log << "\nread " << static_cast(reactions.size()) + << " reactions." << endl; bool rxnok = true; if (validate) rxnok = rxnok && validateReactions(log); @@ -287,7 +288,7 @@ bool CKReader::writeReactions(ostream& log) { bool ok = true; // int ns = species.size(); - int nrxns = reactions.size(); + int nrxns = static_cast(reactions.size()); log.flags(ios::unitbuf); log.precision(6); @@ -320,7 +321,7 @@ bool CKReader::writeReactions(ostream& log) { log << " reverse rate coeff: "; ok = ok && writeRateCoeff(r.krev, log); } - int ne = r.e3b.size(); + int ne = static_cast(r.e3b.size()); if (ne > 0) { vector enhSpecies; @@ -346,8 +347,8 @@ bool CKReader::writeReactions(ostream& log) { /// validate the species bool CKReader::validateSpecies(ostream& log) { - int nel = elements.size(); - int nsp = species.size(); + int nel = static_cast(elements.size()); + int nsp = static_cast(species.size()); double nm, tol; int j, k, m; @@ -413,7 +414,7 @@ bool CKReader::validateReactions(ostream& log) { bool ok = true; // int ns = species.size(); - int nrxns = reactions.size(); + int nrxns = static_cast(reactions.size()); vector unbal; log << "checking that all reactions balance..."; @@ -421,7 +422,7 @@ bool CKReader::validateReactions(ostream& log) { log << " OK" << endl; } else { - int nu = unbal.size(); + int nu = static_cast(unbal.size()); for (int iu = 0; iu < nu; iu++) { log << " error... reaction " << unbal[iu] << " does not balance" << endl; @@ -471,7 +472,7 @@ bool CKReader::validateReactions(ostream& log) { bool checkThermo(ostream& log, speciesList& sp, double tol) { const double dt = 0.0001; double t, cp0, h0, s0, cp1, h1, s1; - int nsp = sp.size(); + int nsp = static_cast(sp.size()); const int n_points = 20; int k; @@ -585,7 +586,7 @@ bool checkThermo(ostream& log, speciesList& sp, double tol) { // This does not include any possible electronic contribution cp0 = cp(s.thigh, s); - int nel = s.elements.size(); + int nel = static_cast(s.elements.size()); int i; double na = 0.0; for (i = 0; i < nel; i++) @@ -627,7 +628,7 @@ bool checkThermo(ostream& log, speciesList& sp, double tol) { bool checkBalance(ostream& f, speciesTable& speciesData, reactionList& r, vector& unbalanced) { - int nrxn = r.size(); + int nrxn = static_cast(r.size()); string rname, pname; vector elementSyms; unsigned int m; @@ -638,8 +639,8 @@ bool checkThermo(ostream& log, speciesList& sp, double tol) { for (int i = 0; i < nrxn; i++) { atoms.clear(); - int nr = r[i].reactants.size(); - int np = r[i].products.size(); + int nr = static_cast(r[i].reactants.size()); + int np = static_cast(r[i].products.size()); int j; double stoichCoeff; for (j = 0; j < nr; j++)