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:
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 :
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,
particles->rho.push_back(rho); // rho var(i,ind,1) * scale_nH
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);
particles->temp.push_back(temp);
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) {
particles->indexes.push_back(0); // GAS particles
particles->ngas++; // One more gas particles
......
......@@ -31,12 +31,13 @@ public:
bool good() {
if (!fake_reading) return in.good();
else return true;}
inline int readDataBlock(char * ptr) {
inline int readDataBlock(char * ptr, bool abort=true) {
if (!fake_reading) {
int len1=readFRecord();
int len1=readFRecord(abort);
readData(ptr,1,len1);
int len2=readFRecord();
int len2=readFRecord(abort);
if (len2==len1) ; // remove warning....
if (abort)
assert(good() && len1==len2);
return len1;
} else return 1;
......@@ -60,14 +61,18 @@ public:
}
// read fortran record
inline int readFRecord() {
inline int readFRecord(bool abort=true) {
if (!fake_reading) {
int len; in.read((char *) &len,sizeof(int));
// We SWAP data
if (swap) { // swapping requested
swapBytes(&len,sizeof(int));
}
if (abort)
assert(in.good());
else {
if (! in.good()) len=0;
}
return len;
}
else return 1;
......
......@@ -115,12 +115,21 @@ int CPart::loadData(uns::CParticles * particles,
// read masses
tmp[6] = new double[npart]; // alloc
part.readDataBlock((char *) tmp[6]);
double * agetmp;
double * agetmp, * metaltmp;
if (nstar>0) { // || 1) { // there are stars
part.skipBlock(); // skip identity
part.skipBlock(); // skip level
agetmp = new double[npart];
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++) {
if ((agetmp[k]==0.&& (comp_bits&HALO_BIT)) || // it's DM
(agetmp[k]!=0.&& (comp_bits&STARS_BIT))) { // its' stars
......@@ -146,10 +155,14 @@ int CPart::loadData(uns::CParticles * particles,
particles->load_bits |= MASS_BIT;
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->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) {
particles->indexes.push_back(4); // save star positions
particles->nstars++;
......@@ -167,6 +180,9 @@ int CPart::loadData(uns::CParticles * particles,
}
// garbage
delete [] agetmp;
if (req_bits&METAL_BIT) {
delete [] metaltmp;
}
}
else { // there are no stars
if (comp_bits&HALO_BIT) { // DM sel
......
......@@ -210,13 +210,15 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
// particles reordering
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)
pos.resize(particles->pos.size()); // resize new pos vector
if (particles->vel.size()>0)
vel.resize(particles->vel.size()); // resize new pos vector
if (particles->mass.size()>0)
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++) {
......@@ -251,6 +253,13 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
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
offset_comp[icomp]++; // update offset
}
......@@ -259,6 +268,7 @@ int CSnapshotRamsesIn::reorderParticles(uns::UserSelection &user_select)
particles->pos=pos;
particles->vel=vel;
particles->mass=mass;
particles->metal=metal;
}
return 1;
}
......
......@@ -31,7 +31,7 @@ public:
ntot=ngas=ndm,nstars=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;
int ntot, ngas, ndm, nstars;
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