Fixed some signed/unsigned comparison warnings

This commit is contained in:
Ray Speth 2012-01-17 04:13:04 +00:00
parent c2372197de
commit aeb16e0bc9
10 changed files with 40 additions and 47 deletions

View file

@ -619,7 +619,7 @@ py_sim1D_new(PyObject *self, PyObject *args)
size_t domains_len = domains_array->dimensions[0];
int * domains_data = (int *) malloc(sizeof(int) * domains_len);
for (int i = 0; i < domains_len; i++) {
for (size_t i = 0; i < domains_len; i++) {
domains_data[i] = (int) dd_data[i];
}

View file

@ -514,7 +514,7 @@ namespace Cantera {
*/
XML_Node& XML_Node::addChild(XML_Node& node) {
m_children.push_back(&node);
m_nchildren = static_cast<int>(m_children.size());
m_nchildren = m_children.size();
m_childindex[node.name()] = m_children.back();
node.setRoot(root());
node.setParent(this);
@ -533,7 +533,7 @@ namespace Cantera {
XML_Node& XML_Node::addChild(const std::string &sname) {
XML_Node *xxx = new XML_Node(sname, this);
m_children.push_back(xxx);
m_nchildren = static_cast<int>(m_children.size());
m_nchildren = m_children.size();
m_childindex[sname] = m_children.back();
xxx->setRoot(root());
xxx->setParent(this);
@ -589,7 +589,7 @@ namespace Cantera {
vector<XML_Node*>::iterator i;
i = find(m_children.begin(), m_children.end(), node);
m_children.erase(i);
m_nchildren = static_cast<int>(m_children.size());
m_nchildren = m_children.size();
m_childindex.erase(node->name());
}
@ -824,7 +824,7 @@ namespace Cantera {
/*
*
*/
int XML_Node::nChildren() const {
size_t XML_Node::nChildren() const {
return m_nchildren;
}
@ -873,13 +873,12 @@ namespace Cantera {
XML_Node *scResult = 0;
XML_Node *sc;
std::string idattrib = id();
int n;
if (name() == nameTarget) {
if (idTarget == "" || idTarget == idattrib) {
return const_cast<XML_Node*>(this);
}
}
for (n = 0; n < m_nchildren; n++) {
for (size_t n = 0; n < m_nchildren; n++) {
sc = m_children[n];
if (sc->name() == nameTarget) {
if (idTarget == "") return sc;
@ -887,7 +886,7 @@ namespace Cantera {
if (idTarget == idattrib) return sc;
}
}
for (n = 0; n < m_nchildren; n++) {
for (size_t n = 0; n < m_nchildren; n++) {
sc = m_children[n];
scResult = sc->findNameID(nameTarget, idTarget);
if (scResult) return scResult;
@ -1094,7 +1093,7 @@ namespace Cantera {
}
}
const vector<XML_Node*> &vsc = node_dest->children();
for (int n = 0; n < m_nchildren; n++) {
for (size_t n = 0; n < m_nchildren; n++) {
sc = m_children[n];
ndc = node_dest->nChildren();
dc = 0;
@ -1147,7 +1146,7 @@ namespace Cantera {
}
const vector<XML_Node*> &vsc = node_dest->children();
for (int n = 0; n < m_nchildren; n++) {
for (size_t n = 0; n < m_nchildren; n++) {
sc = m_children[n];
ndc = node_dest->nChildren();
(void) node_dest->addChild(sc->name());
@ -1159,7 +1158,7 @@ namespace Cantera {
// Set the lock for this node
void XML_Node::lock() {
m_locked = true;
for (int i = 0; i < m_nchildren; i++) {
for (size_t i = 0; i < m_nchildren; i++) {
m_children[i]->lock();
}
}
@ -1167,7 +1166,7 @@ namespace Cantera {
// Unset the lock for this node
void XML_Node::unlock() {
m_locked = false;
for (int i = 0; i < m_nchildren; i++) {
for (size_t i = 0; i < m_nchildren; i++) {
m_children[i]->unlock();
}
}
@ -1336,8 +1335,7 @@ namespace Cantera {
}
}
}
int i;
for (i = 0; i < m_nchildren; i++) {
for (size_t i = 0; i < m_nchildren; i++) {
s << endl;
m_children[i]->write_int(s,level + 2);
}
@ -1358,7 +1356,7 @@ namespace Cantera {
*/
void XML_Node::write(std::ostream& s, const int level) const {
if (m_name == "--" && m_root == this) {
for (int i = 0; i < m_nchildren; i++) {
for (size_t i = 0; i < m_nchildren; i++) {
m_children[i]->write_int(s,level);
s << endl;
}
@ -1391,8 +1389,7 @@ namespace Cantera {
}
const vector<XML_Node*> &vsc = root->children();
int n;
for (n = 0; n < root->nChildren(); n++) {
for (size_t n = 0; n < root->nChildren(); n++) {
sc = vsc[n];
if (sc->name() == "phase") {
if (idtarget == "") return sc;
@ -1400,7 +1397,7 @@ namespace Cantera {
if (idtarget == idattrib) return sc;
}
}
for (n = 0; n < root->nChildren(); n++) {
for (size_t n = 0; n < root->nChildren(); n++) {
sc = vsc[n];
if (sc->name() != "phase") {
scResult = findXMLPhase(sc, idtarget);

View file

@ -470,7 +470,7 @@ namespace Cantera {
/*!
*
*/
int nChildren() const;
size_t nChildren() const;
//! Require that the current xml node have an attribute named
//! by the first argument, a, and that this attribute have the
@ -746,7 +746,7 @@ namespace Cantera {
std::vector<XML_Node*> m_children;
//! Number of children of this node
int m_nchildren;
size_t m_nchildren;
//! True if the current node is a comment node
bool m_iscomment;

View file

@ -648,7 +648,7 @@ next:
log << endl << " Default # of temperature regions: "
<< nreg << endl;
log << " ";
for (int i = 0; i <= nreg; i++) {
for (size_t i = 0; i <= nreg; i++) {
log << temp[i] << " ";
}
log << endl;

View file

@ -352,10 +352,9 @@ bool CKReader::writeReactions(std::ostream& log) {
/// validate the species
bool CKReader::validateSpecies(std::ostream& log) {
int nel = static_cast<int>(elements.size());
int nsp = static_cast<int>(species.size());
size_t nel = elements.size();
size_t nsp = species.size();
double tol;
int j, k, m;
log << newTask("validating species");
@ -363,7 +362,7 @@ bool CKReader::validateSpecies(std::ostream& log) {
vector<string> esyms;
log << " checking that all species have been defined... ";
for (k = 0; k < nsp; k++) {
for (size_t k = 0; k < nsp; k++) {
Species& s = species[k];
if (s.valid == 0) {
log << endl << " species " << s.name << " undefined ";
@ -377,14 +376,14 @@ bool CKReader::validateSpecies(std::ostream& log) {
}
log << " checking that all species elements have been declared... ";
for (k = 0; k < nsp; k++) {
for (size_t k = 0; k < nsp; k++) {
Species& s = species[k];
getMapKeys(s.comp, esyms);
size_t nm = esyms.size();
for (m = 0; m < nm; m++) {
for (size_t m = 0; m < nm; m++) {
size_t j;
for (j = 0; j < nel; j++) {
if (esyms[m] == elements[j].name) break;
}

View file

@ -127,7 +127,7 @@ namespace Cantera {
if (m_abstol) N_VFree(nv(m_abstol));
m_abstol = reinterpret_cast<void*>(N_VNew(m_nabs, 0));
}
for (int i=0; i<n; i++) {
for (int i=0; i<m_nabs; i++) {
N_VIth(nv(m_abstol), i) = abstol[i];
}
m_reltol = reltol;

View file

@ -270,7 +270,7 @@ namespace Cantera {
N_VDestroy_Serial(nv(m_y)); // free solution vector if already allocated
}
m_y = reinterpret_cast<void*>(N_VNew_Serial(m_neq)); // allocate solution vector
for (int i=0; i<m_neq; i++) {
for (size_t i = 0; i < m_neq; i++) {
NV_Ith_S(nv(m_y), i) = 0.0;
}
// check abs tolerance array size

View file

@ -824,7 +824,7 @@ namespace Cantera {
*/
class Poly1 : public Func1 {
public:
Poly1(int n, doublereal* c) :
Poly1(size_t n, doublereal* c) :
Func1()
{
m_n = n+1;
@ -857,9 +857,8 @@ namespace Cantera {
}
virtual doublereal eval(doublereal t) const {
int n;
doublereal r = m_cpoly[m_n-1];
for (n = 1; n < m_n; n++) {
for (size_t n = 1; n < m_n; n++) {
r *= t;
r += m_cpoly[m_n - n - 1];
}
@ -867,7 +866,7 @@ namespace Cantera {
}
protected:
int m_n;
size_t m_n;
vector_fp m_cpoly;
};
@ -882,7 +881,7 @@ namespace Cantera {
*/
class Fourier1 : public Func1 {
public:
Fourier1(int n, doublereal omega, doublereal a0,
Fourier1(size_t n, doublereal omega, doublereal a0,
doublereal* a, doublereal* b) :
Func1()
{
@ -921,7 +920,7 @@ namespace Cantera {
}
virtual doublereal eval(doublereal t) const {
int n, nn;
size_t n, nn;
doublereal sum = m_a0_2;
for (n = 0; n < m_n; n++) {
nn = n + 1;
@ -932,7 +931,7 @@ namespace Cantera {
}
protected:
int m_n;
size_t m_n;
doublereal m_omega, m_a0_2;
vector_fp m_ccos, m_csin;
};
@ -946,16 +945,15 @@ namespace Cantera {
*/
class Arrhenius1 : public Func1 {
public:
Arrhenius1(int n, doublereal* c) :
Arrhenius1(size_t n, doublereal* c) :
Func1()
{
m_n = n;
m_A.resize(n);
m_b.resize(n);
m_E.resize(n);
int loc;
for (int i = 0; i < n; i++) {
loc = 3*i;
for (size_t i = 0; i < n; i++) {
size_t loc = 3*i;
m_A[i] = c[loc];
m_b[i] = c[loc+1];
m_E[i] = c[loc+2];
@ -988,16 +986,15 @@ namespace Cantera {
}
virtual doublereal eval(doublereal t) const {
int n;
doublereal sum = 0.0;
for (n = 0; n < m_n; n++) {
for (size_t n = 0; n < m_n; n++) {
sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
}
return sum;
}
protected:
int m_n;
size_t m_n;
vector_fp m_A, m_b, m_E;
};

View file

@ -94,7 +94,7 @@ void StFlow::setGasAtMidpoint(const doublereal* x,int j) {
m_thermo->setTemperature(0.5*(T(x,j)+T(x,j+1)));
const doublereal* yyj = x + m_nv*j + 4;
const doublereal* yyjp = x + m_nv*(j+1) + 4;
for (int k = 0; k < m_nsp; k++)
for (size_t k = 0; k < m_nsp; k++)
m_ybar[k] = 0.5*(yyj[k] + yyjp[k]);
m_thermo->setMassFractions_NoNorm(DATA_PTR(m_ybar));
m_thermo->setPressure(m_press);

View file

@ -116,7 +116,7 @@ AxiStagnBVP::AxiStagnBVP(igthermo_t* ph, int nsp, int points) :
m_refiner->setActive(3, false);
vector_fp gr;
for (int ng = 0; ng < m_points; ng++) gr.push_back(1.0*ng/m_points);
for (size_t ng = 0; ng < m_points; ng++) gr.push_back(1.0*ng/m_points);
setupGrid(m_points, DATA_PTR(gr));
setID("stagnation flow");
}
@ -221,7 +221,7 @@ AxiStagnBVP::AxiStagnBVP(igthermo_t* ph, int nsp, int points) :
m_thermo->setTemperature(0.5*(T(x,j)+T(x,j+1)));
const doublereal* yyj = x + m_nv*j + c_offset_Y;
const doublereal* yyjp = x + m_nv*(j+1) + c_offset_Y;
for (int k = 0; k < m_nsp; k++)
for (size_t k = 0; k < m_nsp; k++)
m_ybar[k] = 0.5*(yyj[k] + yyjp[k]);
m_thermo->setMassFractions_NoNorm(DATA_PTR(m_ybar));
m_thermo->setPressure(m_press);