Commit af0285d2 authored by jclamber's avatar jclamber

add new chemical stuffs for gadget files

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@127 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent b3796d41
......@@ -40,6 +40,7 @@ namespace tools {
#define ZS_BIT (1 << 18)
#define ZSMT_BIT (1 << 19)
#define IM_BIT (1 << 20)
#define CM_BIT (1 << 21)
// Component BITS
#define ALL_BIT (1 << 1)
......
......@@ -62,6 +62,7 @@ namespace uns {
zs = NULL;
zsmt = NULL;
im = NULL;
cm = NULL;
bits = 0;
load_bits = 0;
tframe = 0.;
......@@ -105,6 +106,7 @@ CSnapshotGadgetIn::~CSnapshotGadgetIn()
if (zs) delete [] zs;
if (zsmt) delete [] zsmt;
if (im) delete [] im;
if (cm) delete [] cm;
}
crv.clear();
}
......@@ -494,6 +496,16 @@ int CSnapshotGadgetIn::read(uns::UserSelection &user_select)
ok=true;
readOneArray(&im,4,compOffset);
}
// --> CM block
if (block_name=="cM" && req_bits&CM_BIT && (comp_bits&GAS_BIT || comp_bits&STARS_BIT)) {
assert((load_bits&CM_BIT)==0); // if failed means that multiple file not supported for this block
load_bits |= CM_BIT;
assert((header.npart[0]+header.npart[4])>0); // gas+stars
ok=true;
int ccm;
readGasStarsUnknownArray(&cm,&ccm,compOffset);
assert(ccm==1); // there is only one value per particle
}
// --> Zs block
if (block_name=="Zs" && req_bits&ZS_BIT && (comp_bits&GAS_BIT || comp_bits&STARS_BIT)) {
assert((load_bits&ZS_BIT)==0); // if failed means that multiple file not supported for this block
......@@ -573,6 +585,8 @@ int CSnapshotGadgetIn::read(uns::UserSelection &user_select)
freeNotLoadedData(&hsml ,HSML_BIT);
freeNotLoadedData(&zs ,ZS_BIT);
freeNotLoadedData(&zsmt ,ZSMT_BIT);
freeNotLoadedData(&im ,IM_BIT);
freeNotLoadedData(&cm ,CM_BIT);
}
return 1;
}
......@@ -931,6 +945,19 @@ bool CSnapshotGadgetIn::getData(const std::string comp, std::string name, int *n
ok=false;
}
break;
case uns::Cm :
if (status && comp=="gas") {
*data = getCmGas(*n);
} else
if (status && comp=="stars") {
*data = getCmStars(*n);
} else
if (status && comp=="all") {
*data = getCm(*n);
} else {
ok=false;
}
break;
case uns::Zs :
if (status && comp=="gas") {
*data = getZsGas(*n);
......@@ -1043,6 +1070,16 @@ bool CSnapshotGadgetIn::getData(const std::string name,int *n,float **data)
if (comp_bits&GAS_BIT) // only gas requested
*data = getZsGas(*n);
break;
case uns::Cm :
if (comp_bits&STARS_BIT && comp_bits&GAS_BIT) // gas and stars requested
*data = getCm(*n);
else
if (comp_bits&STARS_BIT) // only stars requested
*data = getCmStars(*n);
else
if (comp_bits&GAS_BIT) // only gas requested
*data = getCmGas(*n);
break;
case uns::ZSMT :
if (comp_bits&STARS_BIT && comp_bits&GAS_BIT) // gas and stars requested
*data = getZsmt(*n);
......
......@@ -143,7 +143,7 @@ typedef struct particle_data_lite
float * mass, * pos, * vel, * acc, *pot, * rho, * hsml, * age, * metal, * intenerg, * temp;
int * id;
// new data for Sergey
float * zs, * zsmt, * im;
float * zs, * zsmt, * im, * cm;
int czs, czsmt; // constant for zs and zsmt
int bits; // to store the bits components
float tframe,redshift;
......@@ -196,6 +196,9 @@ typedef struct particle_data_lite
float * getZsmtGas(int & n) { n=czsmt*(header.npartTotal[0]); return zsmt;}
float * getZsmtStars(int & n) { n=czsmt*(header.npartTotal[4]); return zsmt+header.npartTotal[0]*czsmt;}
float * getIm(int & n) { n=header.npartTotal[4]; return im;}
float * getCm(int & n) { n=1*(header.npartTotal[0]+header.npartTotal[4]); return cm;}
float * getCmGas(int & n) { n=1*(header.npartTotal[0]); return cm;}
float * getCmStars(int & n) { n=1*(header.npartTotal[4]); return cm+header.npartTotal[0]*1;}
//fortran offset record length
int frecord_offset;
......
......@@ -91,6 +91,8 @@ namespace uns {
case 'z': req_bits |= ZS_BIT ; break; //
case 'Z': req_bits |= ZSMT_BIT ; break; //
case 'i': req_bits |= IM_BIT ; break; //
case 'c': req_bits |= CM_BIT ; break; //
case 'C': req_bits |= (CM_BIT|IM_BIT|ZSMT_BIT|ZS_BIT) ; break; //
default:
std::cerr << "!!!!WARNING unknown requested bit : <"<<bits.at(i)<<">\n";
break;
......
......@@ -236,6 +236,7 @@ namespace uns {
CunsOut::s_mapStringValues["zs" ] = uns::Zs;
CunsOut::s_mapStringValues["zsmt" ] = uns::ZSMT;
CunsOut::s_mapStringValues["im" ] = uns::Im;
CunsOut::s_mapStringValues["cm" ] = uns::Cm;
CunsOut::s_mapStringValues["czs" ] = uns::Czs;
CunsOut::s_mapStringValues["czsmt" ] = uns::Czsmt;
if (verbose) {
......
......@@ -43,6 +43,7 @@ namespace uns {
Zs ,
ZSMT ,
Im ,
Cm ,
Czs ,
Czsmt ,
......
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