Commit 46b6b552 authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

load new ramses with families

parent 1a184803
...@@ -29,6 +29,7 @@ CPart::CPart(const std::string _indir, const bool _v) ...@@ -29,6 +29,7 @@ CPart::CPart(const std::string _indir, const bool _v)
verbose=_v; verbose=_v;
indir = _indir; indir = _indir;
infile=""; infile="";
exist_family=false;
// keep filename untill last / // keep filename untill last /
int found=indir.find_last_of("/"); int found=indir.find_last_of("/");
...@@ -50,6 +51,15 @@ CPart::CPart(const std::string _indir, const bool _v) ...@@ -50,6 +51,15 @@ CPart::CPart(const std::string _indir, const bool _v)
infile = indir + "/part_" + s_run_index + ".out00001"; infile = indir + "/part_" + s_run_index + ".out00001";
if (verbose) if (verbose)
std::cerr << "infile =[" << infile <<"]\n"; std::cerr << "infile =[" << infile <<"]\n";
// check if new ramses format with family
std::ifstream fi;
fi.open(std::string(indir+"/part_file_descriptor.txt").c_str());
if (fi.is_open()) {
exist_family=true;
fi.close();
} else {
exist_family=false;
}
} }
} }
...@@ -125,6 +135,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -125,6 +135,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
part.readDataBlock((char *) tmp[6]); part.readDataBlock((char *) tmp[6]);
double * agetmp, * metaltmp; double * agetmp, * metaltmp;
int * id=NULL; int * id=NULL;
char * family=NULL;
if (req_bits&ID_BIT) { if (req_bits&ID_BIT) {
id = new int[npart]; id = new int[npart];
...@@ -136,6 +147,11 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -136,6 +147,11 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
if (nstar>0) { // || 1) { // there are stars if (nstar>0) { // || 1) { // there are stars
part.skipBlock(); // skip level part.skipBlock(); // skip level
if (exist_family) {
family = new char[npart];
part.readDataBlock((char *) family); // read family
part.skipBlock(); // skip tag
}
agetmp = new double[npart]; agetmp = new double[npart];
part.readDataBlock((char *) agetmp); part.readDataBlock((char *) agetmp);
...@@ -151,8 +167,23 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -151,8 +167,23 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
} }
for (int k=0; k<npart; k++) { for (int k=0; k<npart; k++) {
if ((agetmp[k]==0.&& (comp_bits&HALO_BIT)) || // it's DM bool ok_stars=false, ok_dm=false;
(agetmp[k]!=0.&& (comp_bits&STARS_BIT))) { // its' stars if (exist_family) {
if (family[k]==2) { // stars
ok_stars=true;
}
if (family[k]==1) { // stars
ok_dm=true;
}
} else {
if (agetmp[k]!=0.) { // stars
ok_stars=true;
} else { // dm
ok_dm=true;
}
}
if ((ok_dm && (comp_bits&HALO_BIT)) || // it's DM
(ok_stars&& (comp_bits&STARS_BIT))) { // its' stars
if ((tmp[0][k]>=xmin && tmp[0][k]<=xmax) && if ((tmp[0][k]>=xmin && tmp[0][k]<=xmax) &&
(tmp[1][k]>=ymin && tmp[1][k]<=ymax) && (tmp[1][k]>=ymin && tmp[1][k]<=ymax) &&
((ndim<3)||(tmp[2][k]>=zmin && tmp[2][k]<=zmax)) ((ndim<3)||(tmp[2][k]>=zmin && tmp[2][k]<=zmax))
...@@ -184,16 +215,19 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -184,16 +215,19 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
particles->load_bits |= MASS_BIT; particles->load_bits |= MASS_BIT;
take=true; take=true;
} }
if (agetmp[k]!=0 && req_bits&AGE_BIT) { // stars only (age) //if (agetmp[k]!=0 && req_bits&AGE_BIT) { // stars only (age)
if (ok_stars && req_bits&AGE_BIT) { // stars only (age)
particles->age.push_back(agetmp[k]); particles->age.push_back(agetmp[k]);
particles->load_bits |= AGE_BIT; particles->load_bits |= AGE_BIT;
} }
if (agetmp[k]!=0 && req_bits&METAL_BIT && found_metal) { // stars only (metallicity) //if (agetmp[k]!=0 && req_bits&METAL_BIT && found_metal) { // stars only (metallicity)
if (ok_stars && req_bits&METAL_BIT && found_metal) { // stars only (metallicity)
//std::cerr << "Stars => "<<metaltmp[k]<<"\n"; //std::cerr << "Stars => "<<metaltmp[k]<<"\n";
particles->metal.push_back(metaltmp[k]); particles->metal.push_back(metaltmp[k]);
particles->load_bits |= METAL_BIT; particles->load_bits |= METAL_BIT;
} }
if (agetmp[k]==0 && req_bits&METAL_BIT && found_metal) { // stars only (metallicity) //if (agetmp[k]==0 && req_bits&METAL_BIT && found_metal) { // stars only (metallicity)
if (ok_dm && req_bits&METAL_BIT && found_metal) { // stars only (metallicity)
//if ( tmp[6][k] == 0.0 ) //if ( tmp[6][k] == 0.0 )
//std::cerr << "DM => "<<metaltmp[k]<<" mass=" << tmp[6][k] << "\n"; //std::cerr << "DM => "<<metaltmp[k]<<" mass=" << tmp[6][k] << "\n";
//particles->metal.push_back(tmp[6][k]); // put mass for dark matter //particles->metal.push_back(tmp[6][k]); // put mass for dark matter
...@@ -205,11 +239,11 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -205,11 +239,11 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
particles->id.push_back(id[k]); // save real id for dm or stars particles->id.push_back(id[k]); // save real id for dm or stars
particles->load_bits |= ID_BIT; particles->load_bits |= ID_BIT;
} }
if ( (take && agetmp[k]!=0) || (!req_bits && agetmp[k]!=0)) { // !req_bits for uns_info and siplay=f if ( (take && ok_stars) || (!req_bits && ok_stars)) { // !req_bits for uns_info and siplay=f
particles->indexes.push_back(4); // save star positions particles->indexes.push_back(4); // save star positions
particles->nstars++; particles->nstars++;
} }
if ((take && agetmp[k]==0) || (!req_bits && agetmp[k]==0)) { if ((take && ok_dm) || (!req_bits && ok_dm)) {
particles->indexes.push_back(1); // save DM positions particles->indexes.push_back(1); // save DM positions
particles->ndm++; particles->ndm++;
} }
...@@ -223,6 +257,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles, ...@@ -223,6 +257,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
} }
// garbage // garbage
delete [] agetmp; delete [] agetmp;
delete [] family;
if (req_bits&ID_BIT) { if (req_bits&ID_BIT) {
delete [] id; delete [] id;
} }
......
...@@ -60,7 +60,7 @@ private: ...@@ -60,7 +60,7 @@ private:
int npart,nstar,ncpu,ndim,nbody,ndm; int npart,nstar,ncpu,ndim,nbody,ndm;
int ndm_box, nstar_box; int ndm_box, nstar_box;
std::string s_run_index; std::string s_run_index;
bool exist_family;
double xmin,xmax,ymin,ymax,zmin,zmax; double xmin,xmax,ymin,ymax,zmin,zmax;
CFortIO part; CFortIO part;
......
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