Commit 8d89293f authored by jclamber's avatar jclamber

add ramses metallicity

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@145 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 95a63fea
# #
nemocvs: nemocvs:
rsync -CRav --exclude-from=exclude.txt build/CMakeLists.txt build/FindNEMO.cmake . ${NEMO}/usr/jcl/unsio rsync -CRav --exclude-from=exclude.txt CMakeLists.txt INSTALL LICENSE 3rdparty cmake man src template test_src ${NEMO}/usr/jcl/unsio
tar : tar :
cd ..;tar czhvf unsio/unsio-`date "+%d%b-%Y-%H.%M"`.tar.gz `ls unsio/src/*.{f,F,cc,h} unsio/test_src/*.{f,F,cc,h} unsio/CMakeLists.txt unsio/cmake/*.cmake unsio/doc/*.{odp,pdf,txt} unsio/INSTALL unsio/mmakefile unsio/man/man3/* unsio/3rdparty/nemolight/build/CMakeLists.txt unsio/3rdparty/nemolight/src/*.{c,h} unsio/3rdparty/nemolight/src/inc/*.{c,h} unsio/3rdparty/nemolight/src/inc/snapshot/*.{c,h} unsio/3rdparty/nemolight/src/fortran_old_gcc/*.{c,h} unsio/template/uns_devel/cmake/*.cmake unsio/template/uns_devel/README unsio/template/uns_devel/CMakeLists.txt unsio/template/uns_devel/src/*.{c,cc,F} unsio/template/uns_devel/lib/src/*.{c,cc,F} 2> /dev/null` cd ..;tar czhvf unsio/unsio-`date "+%d%b-%Y-%H.%M"`.tar.gz `ls unsio/src/*.{f,F,cc,h} unsio/test_src/*.{f,F,cc,h} unsio/CMakeLists.txt unsio/cmake/*.cmake unsio/doc/*.{odp,pdf,txt} unsio/INSTALL unsio/mmakefile unsio/man/man3/* unsio/3rdparty/nemolight/build/CMakeLists.txt unsio/3rdparty/nemolight/src/*.{c,h} unsio/3rdparty/nemolight/src/inc/*.{c,h} unsio/3rdparty/nemolight/src/inc/snapshot/*.{c,h} unsio/3rdparty/nemolight/src/fortran_old_gcc/*.{c,h} unsio/template/uns_devel/cmake/*.cmake unsio/template/uns_devel/README unsio/template/uns_devel/CMakeLists.txt unsio/template/uns_devel/src/*.{c,cc,F} unsio/template/uns_devel/lib/src/*.{c,cc,F} 2> /dev/null`
......
...@@ -354,11 +354,16 @@ int CAmr::loadData(uns::CParticles * particles, ...@@ -354,11 +354,16 @@ int CAmr::loadData(uns::CParticles * particles,
particles->rho.push_back(rho); // rho var(i,ind,1) * scale_nH particles->rho.push_back(rho); // rho var(i,ind,1) * scale_nH
particles->load_bits |= RHO_BIT; particles->load_bits |= RHO_BIT;
} }
if (req_bits&TEMP_BIT) { if (req_bits&TEMP_BIT && nvarh>4) {
float temp= std::max(0.0,var[4*ngrida*twotondim+ind*ngrida+i]/rho); float temp= std::max(0.0,var[4*ngrida*twotondim+ind*ngrida+i]/rho);
particles->temp.push_back(temp); particles->temp.push_back(temp);
particles->load_bits |= TEMP_BIT; particles->load_bits |= TEMP_BIT;
} }
if (req_bits&METAL_BIT && nvarh>5) {
float metal= var[5*ngrida*twotondim+ind*ngrida+i];
particles->metal.push_back(metal);
particles->load_bits |= METAL_BIT;
}
if (take) { if (take) {
particles->indexes.push_back(0); // GAS particles particles->indexes.push_back(0); // GAS particles
particles->ngas++; // One more gas particles particles->ngas++; // One more gas particles
......
...@@ -31,13 +31,14 @@ public: ...@@ -31,13 +31,14 @@ public:
bool good() { bool good() {
if (!fake_reading) return in.good(); if (!fake_reading) return in.good();
else return true;} else return true;}
inline int readDataBlock(char * ptr) { inline int readDataBlock(char * ptr, bool abort=true) {
if (!fake_reading) { if (!fake_reading) {
int len1=readFRecord(); int len1=readFRecord(abort);
readData(ptr,1,len1); readData(ptr,1,len1);
int len2=readFRecord(); int len2=readFRecord(abort);
if (len2==len1) ; // remove warning.... if (len2==len1) ; // remove warning....
assert(good() && len1==len2); if (abort)
assert(good() && len1==len2);
return len1; return len1;
} else return 1; } else return 1;
} }
...@@ -60,14 +61,18 @@ public: ...@@ -60,14 +61,18 @@ public:
} }
// read fortran record // read fortran record
inline int readFRecord() { inline int readFRecord(bool abort=true) {
if (!fake_reading) { if (!fake_reading) {
int len; in.read((char *) &len,sizeof(int)); int len; in.read((char *) &len,sizeof(int));
// We SWAP data // We SWAP data
if (swap) { // swapping requested if (swap) { // swapping requested
swapBytes(&len,sizeof(int)); swapBytes(&len,sizeof(int));
} }
assert(in.good()); if (abort)
assert(in.good());
else {
if (! in.good()) len=0;
}
return len; return len;
} }
else return 1; else return 1;
......
...@@ -115,12 +115,21 @@ int CPart::loadData(uns::CParticles * particles, ...@@ -115,12 +115,21 @@ int CPart::loadData(uns::CParticles * particles,
// read masses // read masses
tmp[6] = new double[npart]; // alloc tmp[6] = new double[npart]; // alloc
part.readDataBlock((char *) tmp[6]); part.readDataBlock((char *) tmp[6]);
double * agetmp; double * agetmp, * metaltmp;
if (nstar>0) { // || 1) { // there are stars if (nstar>0) { // || 1) { // there are stars
part.skipBlock(); // skip identity part.skipBlock(); // skip identity
part.skipBlock(); // skip level part.skipBlock(); // skip level
agetmp = new double[npart]; agetmp = new double[npart];
part.readDataBlock((char *) agetmp); part.readDataBlock((char *) agetmp);
bool found_metal=false;
if (req_bits&METAL_BIT) {
metaltmp = new double[npart];
int status=part.readDataBlock((char *) metaltmp, false);
if (status) found_metal=true;
std::cerr << "Metalicity status =" << status << "\n";
}
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 if ((agetmp[k]==0.&& (comp_bits&HALO_BIT)) || // it's DM
(agetmp[k]!=0.&& (comp_bits&STARS_BIT))) { // its' stars (agetmp[k]!=0.&& (comp_bits&STARS_BIT))) { // its' stars
...@@ -146,10 +155,14 @@ int CPart::loadData(uns::CParticles * particles, ...@@ -146,10 +155,14 @@ int CPart::loadData(uns::CParticles * 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 if (agetmp[k]!=0 && 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)
particles->metal.push_back(metaltmp[k]);
particles->load_bits |= METAL_BIT;
}
if (take && agetmp[k]!=0) { if (take && agetmp[k]!=0) {
particles->indexes.push_back(4); // save star positions particles->indexes.push_back(4); // save star positions
particles->nstars++; particles->nstars++;
...@@ -167,6 +180,9 @@ int CPart::loadData(uns::CParticles * particles, ...@@ -167,6 +180,9 @@ int CPart::loadData(uns::CParticles * particles,
} }
// garbage // garbage
delete [] agetmp; delete [] agetmp;
if (req_bits&METAL_BIT) {
delete [] metaltmp;
}
} }
else { // there are no stars else { // there are no stars
if (comp_bits&HALO_BIT) { // DM sel if (comp_bits&HALO_BIT) { // DM sel
......
...@@ -210,13 +210,15 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select) ...@@ -210,13 +210,15 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
// particles reordering // particles reordering
if (particles->ntot) { // exist particles to reorder if (particles->ntot) { // exist particles to reorder
std::vector <float> pos,vel,mass; std::vector <float> pos,vel,mass,metal;
if (particles->pos.size()>0) if (particles->pos.size()>0)
pos.resize(particles->pos.size()); // resize new pos vector pos.resize(particles->pos.size()); // resize new pos vector
if (particles->vel.size()>0) if (particles->vel.size()>0)
vel.resize(particles->vel.size()); // resize new pos vector vel.resize(particles->vel.size()); // resize new pos vector
if (particles->mass.size()>0) if (particles->mass.size()>0)
mass.resize(particles->mass.size()); // resize new mass vector mass.resize(particles->mass.size()); // resize new mass vector
if (particles->metal.size()>0)
metal.resize(particles->metal.size()); // resize new metal vector
for (int i=0; i<particles->ntot; i++) { for (int i=0; i<particles->ntot; i++) {
...@@ -251,6 +253,13 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select) ...@@ -251,6 +253,13 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
mass[istart] = particles->mass[i]; mass[istart] = particles->mass[i];
} }
// metal
if (particles->metal.size()>0 && (icomp==0 || icomp==4)) { // metal for gas or stars
assert(istart<(int)particles->metal.size());
found=true;
metal[istart] = particles->metal[i];
}
if (found) { // found particles if (found) { // found particles
offset_comp[icomp]++; // update offset offset_comp[icomp]++; // update offset
} }
...@@ -259,6 +268,7 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select) ...@@ -259,6 +268,7 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
particles->pos=pos; particles->pos=pos;
particles->vel=vel; particles->vel=vel;
particles->mass=mass; particles->mass=mass;
particles->metal=metal;
} }
return 1; return 1;
} }
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
ntot=ngas=ndm,nstars=0; ntot=ngas=ndm,nstars=0;
load_bits=0; load_bits=0;
} }
std::vector <float> pos,vel,mass,hsml,rho,temp,age; std::vector <float> pos,vel,mass,hsml,rho,temp,age,metal;
std::vector <int> indexes; std::vector <int> indexes;
int ntot, ngas, ndm, nstars; int ntot, ngas, ndm, nstars;
unsigned int load_bits; unsigned int load_bits;
......
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