Commit 0602c9bb authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

fix bug when too big number of particles (int) vs (unsigned int)

parent cce9606e
......@@ -243,11 +243,12 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
std::cerr << "ASSERT fails i="<<i<<" icomp="<<icomp<<"\n";
}
assert(icomp==0 ||icomp==1 || icomp==4); // gas || halo || stars only
int istart=offset_comp[icomp]; // index start in the new pos array
assert(offset_comp[icomp]>=0);
unsigned int istart=offset_comp[icomp]; // index start in the new pos array
// positions
if (particles->pos.size()>0) {
assert((istart*3)+2<(int)particles->pos.size());
assert((istart*3)+2<(unsigned int)particles->pos.size());
found=true;
pos[istart*3+0] = particles->pos[i*3+0]; // x
pos[istart*3+1] = particles->pos[i*3+1]; // y
......@@ -256,7 +257,7 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
// velocities
if (particles->vel.size()>0) {
assert((istart*3)+2<(int)particles->vel.size());
assert((istart*3)+2<(unsigned int)particles->vel.size());
found=true;
vel[istart*3+0] = particles->vel[i*3+0]; // x
vel[istart*3+1] = particles->vel[i*3+1]; // y
......@@ -265,23 +266,23 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
// masses
if (particles->mass.size()>0) {
assert(istart<(int)particles->mass.size());
assert(istart<(unsigned int)particles->mass.size());
found=true;
mass[istart] = particles->mass[i];
}
// id
if (particles->id.size()>0) {
assert(istart<(int)particles->id.size());
assert(istart<(unsigned int)particles->id.size());
found=true;
id[istart] = particles->id[i];
}
// metal
if (particles->metal.size()>0) { // && (icomp==0 || icomp==4)) { // metal for gas or stars
if (!(istart<(int)particles->metal.size())) {
if (!(istart<(unsigned int)particles->metal.size())) {
std::cerr << " istart ="<<istart<< " metal.size ="<< particles->metal.size() << "\n";
}
assert(istart<(int)particles->metal.size());
assert(istart<(unsigned int)particles->metal.size());
found=true;
metal[istart] = particles->metal[i];
}
......
......@@ -651,7 +651,7 @@ void uns_get_interface_type_(const int * id, char * dest, int lenstring)
// return the Component Range Vector belonging to the UNS's object "index"
void getCrv(int index)
{
assert(index<(int)unsv.size());
assert(index<(unsigned int)unsv.size());
crv = ((CunsIn2<float>*)unsv[index].obj)->snapshot->getSnapshotRange();
//ComponentRange::list(crv);
}
......
......@@ -232,7 +232,7 @@ int UserSelection::isComponent(const std::string comp)
int offset;
int icrv=ComponentRange::getIndexMatchType(crv,type,offset);
if (icrv != -1 && !nodata) {
assert(icrv<(int)crv->size());
assert((unsigned int) icrv<crv->size());
comp_bits |= tools::Ctools::compBits(type);
first=(*crv)[icrv].first;
last =(*crv)[icrv].last;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment