Fixing signed/unsigned comparison warnings in OneD

This commit is contained in:
Ray Speth 2012-01-17 04:12:45 +00:00
parent c0dfd33480
commit cfbd76ac02
11 changed files with 54 additions and 62 deletions

View file

@ -40,7 +40,7 @@ namespace Cantera {
void Domain1D::
setTolerances(doublereal rtol, doublereal atol,int ts) {
for (int n = 0; n < m_nv; n++){
for (size_t n = 0; n < m_nv; n++){
if(ts >= 0) {
m_rtol_ss[n] = rtol;
m_atol_ss[n] = atol;
@ -54,7 +54,7 @@ namespace Cantera {
void Domain1D::
setTolerancesTS(doublereal rtol, doublereal atol) {
for (int n = 0; n < m_nv; n++){
for (size_t n = 0; n < m_nv; n++){
m_rtol_ts[n] = rtol;
m_atol_ts[n] = atol;
}
@ -62,7 +62,7 @@ namespace Cantera {
void Domain1D::
setTolerancesSS(doublereal rtol, doublereal atol) {
for (int n = 0; n < m_nv; n++){
for (size_t n = 0; n < m_nv; n++){
m_rtol_ss[n] = rtol;
m_atol_ss[n] = atol;
}

View file

@ -422,10 +422,9 @@ namespace Cantera {
void setProfile(std::string name, doublereal* values, doublereal* soln) {
int n, j;
for (n = 0; n < m_nv; n++) {
for (size_t n = 0; n < m_nv; n++) {
if (name == componentName(n)) {
for (j = 0; j < m_points; j++) {
for (size_t j = 0; j < m_points; j++) {
soln[index(n, j) + m_iloc] = values[j];
}
return;

View file

@ -131,7 +131,7 @@ namespace Cantera {
writelog(buf);
if (m_flow) {
writelog(" Mass Fractions: \n");
for (int k = 0; k < m_flow->phase().nSpecies(); k++) {
for (size_t k = 0; k < m_flow->phase().nSpecies(); k++) {
if (m_yin[k] != 0.0) {
sprintf(buf, " %16s %10.4g \n",
m_flow->phase().speciesName(k).c_str(), m_yin[k]);
@ -387,7 +387,7 @@ namespace Cantera {
virtual ~ReactingSurf1D(){}
virtual std::string componentName(int n) const;
virtual std::string componentName(size_t n) const;
virtual void init();
@ -412,7 +412,7 @@ namespace Cantera {
sprintf(buf, " Temperature: %10.4g K \n", x[0]);
writelog(buf);
writelog(" Coverages: \n");
for (int k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
sprintf(buf, " %20s %10.4g \n", m_sphase->speciesName(k).c_str(),
x[k+1]);
writelog(buf);

View file

@ -34,8 +34,7 @@ namespace Cantera {
}
void MultiJac::updateTransient(doublereal rdt, integer* mask) {
int n;
for (n = 0; n < m_size; n++) {
for (size_t n = 0; n < m_size; n++) {
value(n,n) = m_ssdiag[n] - mask[n]*rdt;
}
}

View file

@ -101,7 +101,7 @@ namespace Cantera {
*/
void MultiNewton::step(doublereal* x, doublereal* step,
OneDim& r, MultiJac& jac, int loglevel) {
int iok;
size_t iok;
size_t sz = r.size();
r.eval(-1, x, step);
#undef DEBUG_STEP
@ -120,7 +120,7 @@ namespace Cantera {
iok = jac.solve(sz, step, step);
// if iok is non-zero, then solve failed
if (iok > 0) {
if (iok != 0) {
iok--;
size_t nd = r.nDomains();
size_t n;
@ -136,7 +136,7 @@ namespace Cantera {
+dom.componentName(comp)+" at point "
+int2str(int(pt))+"\n(Matrix row "+int2str(iok)+") \nsee file bandmatrix.csv\n");
}
else if (iok < 0)
else if (int(iok) < 0)
throw CanteraError("MultiNewton::step",
"iok = "+int2str(int(iok)));
@ -221,15 +221,15 @@ namespace Cantera {
// damping coefficient starts at 1.0
doublereal damp = 1.0;
int j, m;
doublereal ff;
size_t m;
for (m = 0; m < NDAMP; m++) {
ff = fbound*damp;
// step the solution by the damped step size
for (j = 0; j < m_n; j++) x1[j] = ff*step0[j] + x0[j];
for (size_t j = 0; j < m_n; j++) x1[j] = ff*step0[j] + x0[j];
// compute the next undamped step that would result if x1
// is accepted

View file

@ -54,7 +54,7 @@ namespace Cantera {
int OneDim::domainIndex(string name) {
for (int n = 0; n < m_nd; n++) {
for (size_t n = 0; n < m_nd; n++) {
if (domain(n).id() == name) return n;
}
throw CanteraError("OneDim::domainIndex","no domain named >>"+name+"<<");
@ -226,7 +226,7 @@ namespace Cantera {
* 8/26/02 changed '<' to '<=' DGG
*
*/
Domain1D* OneDim::pointDomain(int i) {
Domain1D* OneDim::pointDomain(size_t i) {
Domain1D* d = right();
while (d) {
if (d->loc() <= i) return d;
@ -274,7 +274,7 @@ namespace Cantera {
doublereal OneDim::ssnorm(doublereal* x, doublereal* r) {
eval(-1, x, r, 0.0, 0);
doublereal ss = 0.0;
for (int i = 0; i < m_size; i++) {
for (size_t i = 0; i < m_size; i++) {
ss = fmaxx(fabs(r[i]),ss);
}
return ss;

View file

@ -125,7 +125,7 @@ namespace Cantera {
int count = 1);
/// Pointer to the domain global point i belongs to.
Domain1D* pointDomain(int i);
Domain1D* pointDomain(size_t i);
void resize();

View file

@ -29,7 +29,7 @@ namespace Cantera {
m_x.resize(size(), 0.0);
m_xnew.resize(size(), 0.0);
for (int n = 0; n < m_nd; n++) {
for (size_t n = 0; n < m_nd; n++) {
domain(n)._getInitialSoln(DATA_PTR(m_x) + start(n));
domain(n).m_adiabatic=false;
}
@ -267,7 +267,7 @@ namespace Cantera {
if (loglevel > 0) {
writelog(" success.\n\n");
writelog("Problem solved on [");
for (int mm = 1; mm < nDomains(); mm+=2) {
for (size_t mm = 1; mm < nDomains(); mm+=2) {
writelog(int2str(int(domain(mm).nPoints())));
if (mm + 2 < nDomains()) writelog(", ");
}
@ -531,8 +531,7 @@ namespace Cantera {
//added by Karl Meredith
void Sim1D::setAdiabaticFlame(void){
int n;
for (n = 0; n < m_nd; n++) {
for (size_t n = 0; n < m_nd; n++) {
Domain1D& d = domain(n);
d.m_adiabatic=true;
}
@ -550,7 +549,7 @@ namespace Cantera {
r.setCriteria(ratio, slope, curve, prune);
}
else {
for (int n = 0; n < m_nd; n++) {
for (size_t n = 0; n < m_nd; n++) {
Refiner& r = domain(n).refiner();
r.setCriteria(ratio, slope, curve, prune);
}
@ -563,7 +562,7 @@ namespace Cantera {
r.setMaxPoints(npoints);
}
else {
for (int n = 0; n < m_nd; n++) {
for (size_t n = 0; n < m_nd; n++) {
Refiner& r = domain(n).refiner();
r.setMaxPoints(npoints);
}

View file

@ -27,9 +27,9 @@ namespace Cantera {
* not in the old one are set to zero. The new solution is created
* with the same number of grid points as in the old solution.
*/
void importSolution(int points,
void importSolution(size_t points,
doublereal* oldSoln, igthermo_t& oldmech,
int size_new, doublereal* newSoln, igthermo_t& newmech) {
size_t size_new, doublereal* newSoln, igthermo_t& newmech) {
// Number of components in old and new solutions
size_t nv_old = oldmech.nSpecies() + 4;
@ -157,8 +157,7 @@ namespace Cantera {
vmax[3] = 1.e20;
// mass fraction bounds
int k;
for (k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
vmin[4+k] = -1.0e-5;
vmax[4+k] = 1.0e5;
}
@ -178,7 +177,7 @@ namespace Cantera {
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");
}
@ -989,7 +988,7 @@ namespace Cantera {
else if (name=="T") {return 2;}
else if (name=="lambda") {return 3;}
else {
for (int n=4;n<m_nsp+4;n++){
for (size_t n=4;n<m_nsp+4;n++){
if(componentName(n)==name){
return n;
}
@ -1022,7 +1021,7 @@ namespace Cantera {
vector<XML_Node*> d;
dom.child("grid_data").getChildren("floatArray",d);
int nd = static_cast<int>(d.size());
size_t nd = d.size();
vector_fp x;
size_t n, np = 0, j, ks, k;
@ -1074,7 +1073,7 @@ namespace Cantera {
}
else if (nm == "T") {
writelog("temperature ");
if ((int) x.size() == np) {
if (x.size() == np) {
for (j = 0; j < np; j++)
soln[index(2,j)] = x[j];
@ -1084,7 +1083,7 @@ namespace Cantera {
// *after* restoring the solution.
vector_fp zz(np);
for (int jj = 0; jj < np; jj++)
for (size_t jj = 0; jj < np; jj++)
zz[jj] = (grid(jj) - zmin())/(zmax() - zmin());
setFixedTempProfile(zz, x);
}
@ -1092,7 +1091,7 @@ namespace Cantera {
}
else if (nm == "L") {
writelog("lambda ");
if ((int) x.size() == np) {
if (x.size() == np) {
for (j = 0; j < np; j++)
soln[index(3,j)] = x[j];
}
@ -1100,7 +1099,7 @@ namespace Cantera {
}
else if (m_thermo->speciesIndex(nm) >= 0) {
writelog(nm+" ");
if ((int) x.size() == np) {
if (x.size() == np) {
k = m_thermo->speciesIndex(nm);
did_species[k] = 1;
for (j = 0; j < np; j++)
@ -1114,8 +1113,8 @@ namespace Cantera {
if (ignored.size() != 0) {
writelog("\n\n");
writelog("Ignoring datasets:\n");
int nn = static_cast<int>(ignored.size());
for (int n = 0; n < nn; n++) {
size_t nn = ignored.size();
for (size_t n = 0; n < nn; n++) {
writelog(ignored[n]+" ");
}
}

View file

@ -115,10 +115,9 @@ namespace Cantera {
/// Write the initial solution estimate into
/// array x.
virtual void _getInitialSoln(doublereal* x) {
int k, j;
for (j = 0; j < m_points; j++) {
for (size_t j = 0; j < m_points; j++) {
x[index(2,j)] = T_fixed(j);
for (k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
x[index(4+k,j)] = Y_fixed(k,j);
}
}
@ -183,7 +182,7 @@ namespace Cantera {
void solveEnergyEqn(int j=-1) {
if (j < 0)
for (int i = 0; i < m_points; i++)
for (size_t i = 0; i < m_points; i++)
m_do_energy[i] = true;
else
m_do_energy[j] = true;
@ -195,7 +194,7 @@ namespace Cantera {
void fixTemperature(int j=-1) {
if (j < 0)
for (int i = 0; i < m_points; i++) {
for (size_t i = 0; i < m_points; i++) {
m_do_energy[i] = false;
}
else m_do_energy[j] = false;
@ -210,7 +209,7 @@ namespace Cantera {
void solveSpecies(int k=-1) {
if (k == -1) {
for (int i = 0; i < m_nsp; i++)
for (size_t i = 0; i < m_nsp; i++)
m_do_species[i] = true;
}
else m_do_species[k] = true;
@ -219,7 +218,7 @@ namespace Cantera {
void fixSpecies(int k=-1) {
if (k == -1) {
for (int i = 0; i < m_nsp; i++)
for (size_t i = 0; i < m_nsp; i++)
m_do_species[i] = false;
}
else m_do_species[k] = false;

View file

@ -158,7 +158,6 @@ namespace Cantera {
void Inlet1D::
eval(size_t jg, doublereal* xg, doublereal* rg,
integer* diagg, doublereal rdt) {
int k;
if (jg != -1 && (jg + 2 < firstPoint() || jg > lastPoint() + 2)) return;
// start of local part of global arrays
@ -203,7 +202,7 @@ namespace Cantera {
rb[3] += x[0];
// add the convective term to the species residual equations
for (k = 1; k < m_nsp; k++) {
for (size_t k = 1; k < m_nsp; k++) {
rb[4+k] += x[0]*m_yin[k];
}
@ -224,7 +223,7 @@ namespace Cantera {
rb[1] -= m_V0;
rb[2] -= x[1]; // T
rb[0] += x[0]; // u
for (k = 1; k < m_nsp; k++) {
for (size_t k = 1; k < m_nsp; k++) {
rb[4+k] += x[0]*(m_yin[k]);
}
}
@ -240,7 +239,7 @@ namespace Cantera {
inlt.addAttribute("points",1);
inlt.addAttribute("type","inlet");
inlt.addAttribute("components", double(nComponents()));
for (int k = 0; k < nComponents(); k++) {
for (size_t k = 0; k < nComponents(); k++) {
ctml::addFloat(inlt, componentName(k), s[k], "", "",lowerBound(k), upperBound(k));
}
}
@ -705,7 +704,7 @@ namespace Cantera {
inlt.addAttribute("points",1);
inlt.addAttribute("type","surface");
inlt.addAttribute("components", double(nComponents()));
for (int k = 0; k < nComponents(); k++) {
for (size_t k = 0; k < nComponents(); k++) {
ctml::addFloat(inlt, componentName(k), s[k], "", "",0.0, 1.0);
}
}
@ -729,7 +728,7 @@ namespace Cantera {
string ReactingSurf1D::componentName(int n) const {
string ReactingSurf1D::componentName(size_t n) const {
if (n == 0) return "temperature";
else if (n < m_nsp + 1)
return m_sphase->speciesName(n-1);
@ -749,14 +748,13 @@ namespace Cantera {
vector_fp lower(m_nv), upper(m_nv);
lower[0] = 200.0;
upper[0] = 1.e5;
int n;
for (n = 0; n < m_nsp; n++) {
for (size_t n = 0; n < m_nsp; n++) {
lower[n+1] = -1.0e-5;
upper[n+1] = 2.0;
}
setBounds(m_nv, DATA_PTR(lower), m_nv, DATA_PTR(upper));
vector_fp rtol(m_nv), atol(m_nv);
for (n = 0; n < m_nv; n++) {
for (size_t n = 0; n < m_nv; n++) {
rtol[n] = 1.0e-5;
atol[n] = 1.0e-9;
}
@ -781,8 +779,7 @@ namespace Cantera {
// set the coverages
doublereal sum = 0.0;
int k;
for (k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
m_work[k] = x[k+1];
sum += x[k+1];
}
@ -817,8 +814,8 @@ namespace Cantera {
if (m_enabled) {
doublereal maxx = -1.0;
int imx = -1;
for (k = 0; k < m_nsp; k++) {
size_t imx = -1;
for (size_t k = 0; k < m_nsp; k++) {
r[k+1] = m_work[k + ioffset] * m_sphase->size(k) * rs0;
r[k+1] -= rdt*(x[k+1] - prevSoln(k+1,0));
diag[k+1] = 1;
@ -831,7 +828,7 @@ namespace Cantera {
diag[1] = 0;
}
else {
for (k = 0; k < m_nsp; k++) {
for (size_t k = 0; k < m_nsp; k++) {
r[k+1] = x[k+1] - m_fixed_cov[k];
diag[k+1] = 0;
}
@ -849,7 +846,7 @@ namespace Cantera {
rb =r - nc;
xb = x - nc;
rb[2] = xb[2] - x[0]; // specified T
for (int nl = 1; nl < m_left_nsp; nl++) {
for (size_t nl = 1; nl < m_left_nsp; nl++) {
rb[4+nl] += m_work[nl]*mwleft[nl];
}
}
@ -864,7 +861,7 @@ namespace Cantera {
inlt.addAttribute("points",1);
inlt.addAttribute("type","surface");
inlt.addAttribute("components", double(nComponents()));
for (int k = 0; k < nComponents(); k++) {
for (size_t k = 0; k < nComponents(); k++) {
ctml::addFloat(inlt, componentName(k), s[k], "", "",0.0, 1.0);
}
}