Commit 63cd7e4b authored by jclamber's avatar jclamber

Fix a lot of bugs on Ramses reader

Now py_unsio is abble to read ramses data, it was because :
SWIG forbid multiple variable affectation
like ntto=ngas=ndm=0 !!!!!!!!!
This affectation was in snapshotramses.h
Really crazy bug....


git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@206 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 4a47c67d
......@@ -374,7 +374,7 @@ int CAmr::loadData(uns::CParticles * particles,
particles->id.push_back(-1.); // no id for gas, use "-1"
particles->load_bits |= ID_BIT;
}
if (take) {
if (take|| !req_bits) { // !req_bits for uns_info and siplay=f
particles->indexes.push_back(0); // GAS particles
particles->ngas++; // One more gas particles
......
......@@ -189,11 +189,11 @@ int CPart::loadData(uns::CParticles * particles,
particles->id.push_back(id[k]); // save real id for dm or stars
particles->load_bits |= ID_BIT;
}
if (take && agetmp[k]!=0) {
if ( (take && agetmp[k]!=0) || (!req_bits && agetmp[k]!=0)) { // !req_bits for uns_info and siplay=f
particles->indexes.push_back(4); // save star positions
particles->nstars++;
}
if (take && agetmp[k]==0) {
if ((take && agetmp[k]==0) || (!req_bits && agetmp[k]==0)) {
particles->indexes.push_back(1); // save DM positions
particles->ndm++;
}
......@@ -240,10 +240,10 @@ int CPart::loadData(uns::CParticles * particles,
particles->load_bits |= ID_BIT;
}
if (req_bits&METAL_BIT) {
particles->metal.push_back(-1.0); // we put -1.0 when no metellicity
particles->metal.push_back(-1.0); // !!!! we put -1.0 when no metallicity
particles->load_bits |= METAL_BIT;
}
if (take) {
if (take || !req_bits) { // !req_bits for uns_info and siplay=f
particles->indexes.push_back(1); // save DM positions
particles->ndm++;
}
......
......@@ -116,9 +116,11 @@ int CSnapshotRamsesIn::nextFrame(uns::UserSelection &user_select)
std::cerr << "ndm = "<< particles->ndm <<"\n";
std::cerr << "nstars = "<< particles->nstars <<"\n";
std::cerr << "Box len=" << amr->getHeader()->boxlen << "\n";
std::cerr << "Start reordering...\n";
reorderParticles(user_select);
std::cerr << "Stop reordering...\n";
//if (req_bits) {
std::cerr << "Start reordering...\n";
reorderParticles(user_select);
std::cerr << "Stop reordering...\n";
//}
status = 1;
}
}
......@@ -153,6 +155,7 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
npart_comp[1] = particles->ndm;
npart_comp[4] = particles->nstars;
assert(particles->indexes.size()>0);
assert(select_order.size()<7);
bool first=true;
// according to user selection
......@@ -210,7 +213,7 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
uns::ComponentRange::list(&crv);
// particles reordering
if (particles->ntot) { // exist particles to reorder
if (particles->ntot && req_bits) { // exist particles to reorder
std::vector <float> pos,vel,mass,metal;
std::vector <int> id;
if (particles->pos.size()>0)
......@@ -229,6 +232,9 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
bool found=false;
int icomp=particles->indexes[i]; // integer component
if (! (icomp==0 ||icomp==1 || icomp==4)) {
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
......
......@@ -28,8 +28,12 @@ namespace uns {
class CParticles {
public:
CParticles() {
ntot=ngas=ndm,nstars=0;
CParticles() {
ntot =0; // SWIG forbid multiple variable affectation
ngas =0; // like ntto=ngas=ndm=0 !!!!!!!!!
ndm =0; // it was a bug in py_unsio wrapper for ramses files,
nstars=0; // really really damn crazy !!!!!
load_bits=0;
}
std::vector <float> pos,vel,mass,hsml,rho,temp,age,metal;
......
......@@ -37,9 +37,6 @@ std::map<std::string, int> CunsIn::s_mapCompInt;
CunsIn::CunsIn(const std::string _name ,const std::string _comp ,const std::string _time, const bool verb)
{
init(_name,_comp,_time,verb);
if (verbose) {
std::cerr << "CunsIn::CunsIn -- UNSIO version = "<<uns::getVersion()<< "\n";
}
}
// ----------------------------------------------------------------------------
......@@ -53,6 +50,9 @@ CunsIn::CunsIn(const char * _name ,const char * _comp, const char * _time,
//
void CunsIn::init(const std::string _name ,const std::string _comp ,const std::string _time, const bool verb )
{
if (verb) {
std::cerr << "CunsIn::CunsIn -- UNSIO version = "<<uns::getVersion()<< "\n";
}
valid = false;
simname = tools::Ctools::fixFortran(_name.c_str(),false);
sel_comp = tools::Ctools::fixFortran(_comp.c_str(),false);
......
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