Commit 7c4860bc authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

updates

parent 521c7171
......@@ -22,7 +22,7 @@ class CTestunsio:
__3D = [3,"pos","vel","acc"]
__1D = [1,"mass","pot"]
__1Dgas = [1,"rho","hsml","metal"]
__1Dgas = [1,"rho","hsml","metal","temp","nh","sfr"]
__1Dstars = [1,"metal","age"]
__1Dint = [1,"id"]
......@@ -30,9 +30,9 @@ class CTestunsio:
'disk':[__1D,__3D],'bndry':[__1D,__3D],'bulge':[__1D,__3D]}
__compNemo = { 'all':[__1D,__3D,__1Dgas] }
__fdout = None
__out = None
__singke = None
__fdout = None
__out = None
__single = None
# -----------------------------------------------------
#
def __init__(self,nbody=None,seed=666,single=True,verbose=None, uns2uns=False, out=None):
......@@ -89,7 +89,7 @@ class CTestunsio:
else:
# ok=self.__unso.setArrayI(comp,attr,np.arange(self.__nbody*dim,dtype=np.int32)) # save real arrays
ok = self.__unso.setData(np.arange(self.__nbody*dim,dtype=np.int32),comp,attr)
return ok
# -----------------------------------------------------
#
def saveModel(self,filename=None,unstype="gadget3",single=True):
......@@ -129,14 +129,15 @@ class CTestunsio:
for block_array in all_array:
dim=block_array[0]
for array in block_array[1:]:
print(" %s"%(array),file=self.__fdout, end="")
self.__saveArray(comp,array,dim,real=True) # save real
ok=self.__saveArray(comp,array,dim,real=True) # save real
print(" %s/%d"%(array,ok),file=self.__fdout, end="")
# save integer arrays
dim=self.__1Dint[0]
for array in self.__1Dint[1:]:
print(" %s"%(array),file=self.__fdout, end="")
self.__saveArray(comp,array,dim,real=False) # save integer
ok=self.__saveArray(comp,array,dim,real=False) # save integer
print(" %s/%d"%(array,ok),file=self.__fdout, end="")
print("\n",file=self.__fdout)
......@@ -185,7 +186,7 @@ class CTestunsio:
print("\n[ERROR !!!] Inconsitency: <%s> [%s]"%(comp,attr),data_ref.size,data.size,file=self.__fdout)
print(data_ref,data,file=self.__fdout)
sys.exit()
return ok
# -----------------------------------------------------
#
def __compareModel(self,unstype="gadget3",single=True):
......@@ -212,14 +213,14 @@ class CTestunsio:
for block_array in all_array:
dim=block_array[0]
for array in block_array[1:]:
print(" %s"%(array),file=self.__fdout, end="")
self.__compareArray(comp,array,dim,real=True)
ok=self.__compareArray(comp,array,dim,real=True)
print(" %s/%d"%(array,ok),file=self.__fdout, end="")
# compare integer arrays
dim=self.__1Dint[0]
for array in self.__1Dint[1:]:
print(" %s"%(array),file=self.__fdout, end="")
self.__compareArray(comp,array,dim,real=False)
ok=self.__compareArray(comp,array,dim,real=False)
print(" %s/%d"%(array,ok),file=self.__fdout, end="")
print("\n",file=self.__fdout)
......
......@@ -133,7 +133,7 @@ template <class T> int CPart::loadData(uns::CParticles<T> * particles,
// read masses
tmp[6] = new double[npart]; // alloc
part.readDataBlock((char *) tmp[6]);
double * agetmp, * metaltmp;
double * agetmp, * metaltmp=NULL;
int * id=NULL;
char * family=NULL;
......
......@@ -44,6 +44,8 @@ namespace tools {
#define CM_BIT (1 << 21)
#define SSL_BIT (1 << 22)
#define HYDRO_BIT (1 << 23)
#define NH_BIT (1 << 24)
#define SFR_BIT (1 << 25)
// Component BITS
#define ALL_BIT (1 << 1)
......
......@@ -53,6 +53,8 @@ CSnapshotGadgetIn<T>::CSnapshotGadgetIn(const std::string _name,
metal = NULL;
intenerg=NULL;
temp = NULL;
nh = NULL;
sfr = NULL;
rho = NULL;
hsml = NULL;
zs = NULL;
......@@ -100,6 +102,8 @@ CSnapshotGadgetIn<T>::~CSnapshotGadgetIn()
if (metal) delete [] metal;
if (intenerg) delete [] intenerg;
if (temp) delete [] temp;
if (nh) delete [] nh;
if (sfr) delete [] sfr;
if (rho) delete [] rho;
if (hsml) delete [] hsml;
if (zs) delete [] zs;
......@@ -525,13 +529,27 @@ int CSnapshotGadgetIn<T>::read(uns::UserSelection &user_select)
ok=true;
readOneArray(&intenerg,0,compOffset);
}
// --> Temperature block
// --> Temperature block (= Electron Abundance)
if (block_name=="NE" && this->req_bits&TEMP_BIT && this->comp_bits&GAS_BIT) {
this->load_bits |= TEMP_BIT;
assert(header.npart[0]>0); // (gas only)
ok=true;
readOneArray(&temp,0,compOffset);
}
// --> NH block (= Neutral Hydrogen Abundance)
if (block_name=="NH" && this->req_bits&NH_BIT && this->comp_bits&GAS_BIT) {
this->load_bits |= NH_BIT;
assert(header.npart[0]>0); // (gas only)
ok=true;
readOneArray(&nh,0,compOffset);
}
// --> SFR block (= Star Formation Rate)
if (block_name=="SFR" && this->req_bits&SFR_BIT && this->comp_bits&GAS_BIT) {
this->load_bits |= SFR_BIT;
assert(header.npart[0]>0); // (gas only)
ok=true;
readOneArray(&sfr,0,compOffset);
}
// --> RHO block (density)
if (block_name=="RHO" && this->req_bits&RHO_BIT && this->comp_bits&GAS_BIT) {
this->load_bits |= RHO_BIT;
......@@ -690,6 +708,8 @@ int CSnapshotGadgetIn<T>::read(uns::UserSelection &user_select)
this->freeNotLoadedData(&age ,AGE_BIT);
this->freeNotLoadedData(&metal ,METAL_BIT);
this->freeNotLoadedData(&temp ,TEMP_BIT);
this->freeNotLoadedData(&nh ,NH_BIT);
this->freeNotLoadedData(&sfr ,SFR_BIT);
this->freeNotLoadedData(&intenerg ,U_BIT);
this->freeNotLoadedData(&rho ,RHO_BIT);
this->freeNotLoadedData(&hsml ,HSML_BIT);
......@@ -1072,6 +1092,20 @@ bool CSnapshotGadgetIn<T>::getData(const std::string comp, std::string name, int
ok=false;
}
break;
case uns::Nh :
if (status && comp=="gas" && getNh(*n)) {
*data = getNh(*n);
} else {
ok=false;
}
break;
case uns::Sfr :
if (status && comp=="gas" && getSfr(*n)) {
*data = getSfr(*n);
} else {
ok=false;
}
break;
case uns::Age :
if (status && comp=="stars" && getAge(*n)) {
*data = getAge(*n);
......@@ -1207,6 +1241,12 @@ bool CSnapshotGadgetIn<T>::getData(const std::string name,int *n,T **data)
case uns::Temp :
*data = getTemp(*n);
break;
case uns::Nh :
*data = getNh(*n);
break;
case uns::Sfr :
*data = getSfr(*n);
break;
case uns::Age :
*data = getAge(*n);
break;
......@@ -1541,6 +1581,8 @@ CSnapshotGadgetOut<T>::CSnapshotGadgetOut(const std::string _n, const std::strin
//metal = NULL;
intenerg=NULL;
temp = NULL;
nh = NULL;
sfr = NULL;
rho = NULL;
hsml = NULL;
ntot_withmasses=0;
......@@ -1551,6 +1593,8 @@ CSnapshotGadgetOut<T>::CSnapshotGadgetOut(const std::string _n, const std::strin
ptrIsAlloc[0]["hsml" ]=false;
ptrIsAlloc[0]["metal"]=false;
ptrIsAlloc[0]["u" ]=false;
ptrIsAlloc[0]["nh" ]=false;
ptrIsAlloc[0]["sfr" ]=false;
// stars only
ptrIsAlloc[4]["age" ]=false;
ptrIsAlloc[4]["metal"]=false;
......@@ -1580,6 +1624,8 @@ CSnapshotGadgetOut<T>::~CSnapshotGadgetOut()
// metal=NULL;
// }
if (temp && ptrIsAlloc[0]["temp" ]) delete [] temp;
if (nh && ptrIsAlloc[0]["nh" ]) delete [] nh;
if (sfr && ptrIsAlloc[0]["sfr" ]) delete [] sfr;
if (intenerg && ptrIsAlloc[0]["u" ]) delete [] intenerg;
// stars only
// if (metal && ptrIsAlloc[4]["metal"]) {
......@@ -1682,6 +1728,12 @@ int CSnapshotGadgetOut<T>::setData(std::string name, const int n ,T * data,const
case uns::Temp :
status = setTemp(n, data, _addr);
break;
case uns::Nh :
status = setNh(n, data, _addr);
break;
case uns::Sfr :
status = setSfr(n, data, _addr);
break;
case uns::Age :
status = setAge(n, data, _addr);
break;
......@@ -1745,6 +1797,12 @@ int CSnapshotGadgetOut<T>::setData(std::string name,std::string array, const in
case uns::Temp :
status = setTemp(n, data, _addr);
break;
case uns::Nh :
status = setNh(n, data, _addr);
break;
case uns::Sfr :
status = setSfr(n, data, _addr);
break;
case uns::Age :
status = setAge(n, data, _addr);
break;
......@@ -2127,6 +2185,46 @@ int CSnapshotGadgetOut<T>::setTemp(const int _n, T * _temp, const bool addr)
bits |= TEMP_BIT;
return 1;
}
// ============================================================================
// setNh:
template <class T>
int CSnapshotGadgetOut<T>::setNh(const int _n, T * _nh, const bool addr)
{
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #U particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
nh = _nh;
}
else {
ptrIsAlloc[0]["nh"]=true;
if (! nh)
nh = new T[_n];
memcpy(nh,_nh,sizeof(T)*_n);
}
bits |= NH_BIT;
return 1;
}
// ============================================================================
// setSfr:
template <class T>
int CSnapshotGadgetOut<T>::setSfr(const int _n, T * _sfr, const bool addr)
{
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #U particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
sfr = _sfr;
}
else {
ptrIsAlloc[0]["sfr"]=true;
if (! sfr)
sfr = new T[_n];
memcpy(sfr,_sfr,sizeof(T)*_n);
}
bits |= SFR_BIT;
return 1;
}
// ============================================================================
// setMetalGas:
template <class T>
......@@ -2560,6 +2658,24 @@ int CSnapshotGadgetOut<T>::write()
writeData((char *) temp, sizeof(T), header.npart[0]);
writeFRecord(blk);
}
// Nh
if (bits & NH_BIT) {
assert(header.npart[0]>0);
blk=sizeof(T)*header.npart[0];
writeBlockName("NH ",blk);
writeFRecord(blk);
writeData((char *) nh, sizeof(T), header.npart[0]);
writeFRecord(blk);
}
// Sfr
if (bits & SFR_BIT) {
assert(header.npart[0]>0);
blk=sizeof(T)*header.npart[0];
writeBlockName("SFR ",blk);
writeFRecord(blk);
writeData((char *) sfr, sizeof(T), header.npart[0]);
writeFRecord(blk);
}
// Metal
if (bits & METAL_BIT) {
int nb=(header.npart[0]+header.npart[4]);
......
......@@ -131,7 +131,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
bool lonely_file;
//data
T * mass, * pos, * vel, * acc, *pot, * rho, * hsml, * age, * metal, * intenerg, * temp;
T * mass, * pos, * vel, * acc, *pot, * rho,
* hsml, * age, * metal, * intenerg, * temp, * nh, *sfr;
int * id;
// new data for Sergey
T * zs, * zsmt, * im, * cm, * ssl;
......@@ -190,6 +191,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
T * getMetalGas(int & n) { n=header.npartTotal[0]; return metal;}
T * getMetalStars(int & n) { n=header.npartTotal[4]; return metal+header.npartTotal[0];}
T * getTemp(int & n) { n=header.npartTotal[0]; return temp;}
T * getNh(int & n) { n=header.npartTotal[0]; return nh;}
T * getSfr(int & n) { n=header.npartTotal[0]; return sfr;}
T * getU(int & n) { n=header.npartTotal[0]; return intenerg;}
T * getRho(int & n) { n=header.npartTotal[0]; return rho;}
T * getHsml(int & n) { n=header.npartTotal[0]; return hsml;}
......@@ -296,7 +299,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
private:
//data
T * mass[6], * pos[6], *acc[6], * vel[6], * pot[6], * rho, * hsml, * age, * metal[6], * intenerg, * temp;
T * mass[6], * pos[6], *acc[6], * vel[6], * pot[6], * rho, * hsml,
* age, * metal[6], * intenerg, * temp, * nh, * sfr;
int * id[6];
int ntot_withmasses;
std::ofstream out;
......@@ -333,6 +337,8 @@ const t_data_type_header dth[NB_DATA_HEADER] = {
int setU (const int _n, T * _U , const bool addr);
int setAge (const int _n, T * _age , const bool addr);
int setTemp(const int _n, T * _temp, const bool addr);
int setNh (const int _n, T * _nh, const bool addr);
int setSfr (const int _n, T * _sfr, const bool addr);
int setMetalGas(const int _n, T * _mg , const bool addr);
int setMetalStars(const int _n, T * _ms , const bool addr);
// extra TAGS
......
......@@ -54,6 +54,8 @@ CSnapshotGadgetH5In<T>::CSnapshotGadgetH5In(const std::string _name,
rho.clear();
hsml.clear();
temp.clear();
nh.clear();
sfr.clear();
age.clear();
id.clear();
uenerg.clear();
......@@ -286,7 +288,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
ok=false;
}
case uns::Pos :
if (status && loadCommonDataset("Coordinates",pos,3)) {
if (status && this->req_bits&POS_BIT && loadCommonDataset("Coordinates",pos,3)) {
*data = &pos[first*3];// &getPos()[first*3];
*n = nbody;
} else {
......@@ -294,7 +296,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Vel :
if (status && loadCommonDataset("Velocities",vel,3)) {
if (status && this->req_bits&VEL_BIT && loadCommonDataset("Velocities",vel,3)) {
*data = &vel[first*3];// &getPos()[first*3];
*n = nbody;
} else {
......@@ -302,7 +304,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Mass :
if (status && loadCommonDataset("Masses",mass,1)) {
if (status && this->req_bits&MASS_BIT && loadCommonDataset("Masses",mass,1)) {
*data = &mass[first];// &getPos()[first*3];
*n = nbody;
} else {
......@@ -310,7 +312,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Acc :
if (status && loadCommonDataset("Acceleration",acc,3)) {
if (status && this->req_bits&ACC_BIT && loadCommonDataset("Acceleration",acc,3)) {
*data = &acc[first*3];// &getPos()[first*3];
*n = nbody;
} else {
......@@ -318,7 +320,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Pot :
if (status && loadCommonDataset("Potential",pot,1)) {
if (status && this->req_bits&POT_BIT && loadCommonDataset("Potential",pot,1)) {
*data = &pot[first];// &getPos()[first*3];
*n = nbody;
} else {
......@@ -326,7 +328,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Rho :
if (status && (comp=="gas" || comp=="all") && loadDataset("/PartType0/Density",rho)) {
if (status && this->req_bits&RHO_BIT && (comp=="gas" || comp=="all") && loadDataset("/PartType0/Density",rho)) {
*data = &rho[0];
*n = rho.size();
} else {
......@@ -334,15 +336,41 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::U :
if (status && (comp=="gas" || comp=="all") && loadDataset("/PartType0/InternalEnergy",uenerg)) {
if (status && this->req_bits&U_BIT && (comp=="gas" || comp=="all") && loadDataset("/PartType0/InternalEnergy",uenerg)) {
*data = &uenerg[0];
*n = uenerg.size();
} else {
ok=false;
}
break;
case uns::Ne:
{}
case uns::Temp :
if (status && this->req_bits&TEMP_BIT && (comp=="gas" || comp=="all") && loadDataset("/PartType0/ElectronAbundance",temp)) {
*data = &temp[0];
*n = temp.size();
} else {
ok=false;
}
break;
case uns::Nh :
if (status && this->req_bits&NH_BIT && (comp=="gas" || comp=="all") && loadDataset("/PartType0/NeutralHydrogenAbundance",nh)) {
*data = &nh[0];
*n = nh.size();
} else {
ok=false;
}
break;
case uns::Sfr :
if (status && this->req_bits&SFR_BIT && (comp=="gas" || comp=="all") && loadDataset("/PartType0/StarFormationRate",sfr)) {
*data = &sfr[0];
*n = sfr.size();
} else {
ok=false;
}
break;
case uns::Hsml :
if (status && (comp=="gas" || comp=="all") && loadDataset("/PartType0/SmoothingLength",hsml)) {
if (status && this->req_bits&HSML_BIT && (comp=="gas" || comp=="all") && loadDataset("/PartType0/SmoothingLength",hsml)) {
*data = &hsml[0];
*n = hsml.size();
} else {
......@@ -350,11 +378,11 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Metal :
if (status && comp=="gas" && loadDataset("/PartType0/Metallicity",g_metal)) {
if (status && this->req_bits&METAL_BIT && comp=="gas" && loadDataset("/PartType0/Metallicity",g_metal)) {
*data = &g_metal[0];
*n = g_metal.size();
} else {
if (status && comp=="stars" && loadDataset("/PartType4/Metallicity",s_metal)) {
if (status && this->req_bits&METAL_BIT && comp=="stars" && loadDataset("/PartType4/Metallicity",s_metal)) {
*data = &s_metal[0];
*n = s_metal.size();
}
......@@ -364,7 +392,7 @@ bool CSnapshotGadgetH5In<T>::getData(const std::string comp, const std::string n
}
break;
case uns::Age :
if (status && (comp=="stars" || comp=="all") && loadDataset("/PartType4/StellarFormationTime",age)) {
if (status && this->req_bits&AGE_BIT && (comp=="stars" || comp=="all") && loadDataset("/PartType4/StellarFormationTime",age)) {
*data = &age[0];
*n = age.size();
}
......@@ -672,6 +700,22 @@ int CSnapshotGadgetH5Out<T>::setData(std::string name,std::string array, const
status = saveCommonDataset(name,"InternalEnergy",n,data,1);
}
break;
case uns::Ne:
case uns::Temp :
if (name=="gas") {
status = saveCommonDataset(name,"ElectronAbundance",n,data,1);
}
break;
case uns::Nh :
if (name=="gas") {
status = saveCommonDataset(name,"NeutralHydrogenAbundance",n,data,1);
}
break;
case uns::Sfr :
if (name=="gas") {
status = saveCommonDataset(name,"StarFormationRate",n,data,1);
}
break;
case uns::Age :
if (name=="stars") {
status = saveCommonDataset(name,"StellarFormationTime",n,data,1);
......@@ -724,9 +768,16 @@ int CSnapshotGadgetH5Out<T>::setData(std::string name, const int n ,T * data,con
case uns::U:
status = setData("gas",name,n,data,_addr);
break;
case uns::Ne :
case uns::Temp :
status = setData("gas",name,n,data,_addr);
break;
case uns::Nh :
status = setData("gas",name,n,data,_addr);
break;
case uns::Sfr :
status = setData("gas",name,n,data,_addr);
break;
case uns::Age :
status = setData("stars",name,n,data,_addr);
break;
......
......@@ -123,7 +123,8 @@ private:
bool first_loc;
unsigned int comp_bits;
std::vector <T> pos,vel,mass, acc,pot, hsml,rho,temp,age,s_metal, g_metal,uenerg;
std::vector <T> pos,vel,mass, acc,pot, hsml,rho,temp,nh,sfr,
age,s_metal, g_metal,uenerg;
std::vector <int> indexes,id;
// HDF5 gadget object
......
......@@ -145,6 +145,8 @@ template <class T> void CSnapshotInterfaceIn<T>::computeBits(std::string bits)
case 'U': req_bits |= U_BIT ; break; // Internal energy
case 'M': req_bits |= METAL_BIT ; break; // metallicity
case 'A': req_bits |= AGE_BIT ; break; // stars's age
case 'S': req_bits |= SFR_BIT ; break; // Stars Formation Rate
case 'N': req_bits |= NH_BIT ; break; // Neutral Hydrogen Abundance
case 'H': req_bits |= HSML_BIT ; break; // hsml
case 'h': req_bits |= HYDRO_BIT ; break; // hydro extra
case 'T': req_bits |= TEMP_BIT ; break; // temperature
......
......@@ -148,6 +148,7 @@ namespace uns {
bool isFileExist() { return true; }
std::string getSelectPart() { return select_part; }
std::string getSelectTime() { return select_time; }
unsigned int getReqBits() { return req_bits;}
int nbody_first;
T time_first, time;
ComponentRangeVector crv_first;
......
......@@ -20,7 +20,7 @@
#include <limits>
#include "uns.h"
#include "ctools.h"
#include <iostream>
namespace uns {
// ============================================================================
......@@ -39,19 +39,21 @@ template <class T> CSnapshotRamsesIn<T>::CSnapshotRamsesIn(const std::string _na
// convert Header to template format
t_header = new ramses::T_Header<T>;
t_header->omega_m = (T) amr->getHeader()->omega_m;
t_header->omega_l = (T) amr->getHeader()->omega_l;
t_header->omega_k = (T) amr->getHeader()->omega_k;
t_header->omega_b = (T) amr->getHeader()->omega_b;
t_header->h0 = (T) amr->getHeader()->h0;
t_header->aexp_ini = (T) amr->getHeader()->aexp_ini;
t_header->boxlen_ini = (T) amr->getHeader()->boxlen_ini;
t_header->boxlen = (T) amr->getHeader()->boxlen;
t_header->aexp = (T) amr->getHeader()->aexp;
t_header->hexp = (T) amr->getHeader()->hexp;
t_header->aexp_old = (T) amr->getHeader()->aexp_old;
t_header->epot_tot_int = (T) amr->getHeader()->epot_tot_int;
t_header->epot_tot_old = (T) amr->getHeader()->epot_tot_old;
if (amr->isValid()) {
t_header->omega_m = (T) amr->getHeader()->omega_m;
t_header->omega_l = (T) amr->getHeader()->omega_l;
t_header->omega_k = (T) amr->getHeader()->omega_k;
t_header->omega_b = (T) amr->getHeader()->omega_b;
t_header->h0 = (T) amr->getHeader()->h0;
t_header->aexp_ini = (T) amr->getHeader()->aexp_ini;
t_header->boxlen_ini = (T) amr->getHeader()->boxlen_ini;
t_header->boxlen = (T) amr->getHeader()->boxlen;
t_header->aexp = (T) amr->getHeader()->aexp;
t_header->hexp = (T) amr->getHeader()->hexp;
t_header->aexp_old = (T) amr->getHeader()->aexp_old;
t_header->epot_tot_int = (T) amr->getHeader()->epot_tot_int;
t_header->epot_tot_old = (T) amr->getHeader()->epot_tot_old;
}
if (part->isValid() || amr->isValid()) {
this->valid=true;
......
......@@ -53,6 +53,7 @@ template <class T> void CunsIn2<T>::init(const std::string _name ,const std::st
if (verb) {
std::cerr << "CunsIn2::CunsIn2 -- UNSIO version = "<<uns::getVersion()<< "\n";
}
valid = false;
simname = tools::Ctools::fixFortran(_name.c_str(),false);
sel_comp = tools::Ctools::fixFortran(_comp.c_str(),false);
......@@ -76,33 +77,42 @@ template <class T> void CunsIn2<T>::init(const std::string _name ,const std::st
} else {
if (tools::Ctools::isFileExist(simname)) { // file exist
if ( tools::Ctools::isDirectory(simname)) {
PRINT("try RAMSES 1st\n");
tryRamses(); // try ramses
if (!valid) {
trySimDB(); // try DataBase
}
} else {
// ! ) { // not a directory
PRINT("try GADGET\n");
tryGadget(); // try gadget
if (!valid) {
PRINT("try RAMSES\n");
tryRamses(); // try ramses
}
if (!valid) { // gadget failed
PRINT("try NEMO\n");
tryNemo(); // try nemo
}
if (!valid) {
PRINT("try HDF5\n");
tryGadgetH5(); // try gadgetHDF5
}
if (!valid) { // nemo
PRINT("try LIST\n");
trySnapList(); // try snapshotlist
}
if (!valid) {
PRINT("try DATABASE\n");
trySimDB(); // try DataBase
}
}
}
else { // file does not exist
PRINT("try GADGET 2nd\n");
tryGadget(); // try gadget parallel output
if (!valid) {
PRINT("try DATABASE2\n");
trySimDB(); // try DataBase
}
}
......@@ -370,6 +380,9 @@ template <class T> void CunsOut2<T>::initializeStringMap(const bool verbose)
CunsOut2<T>::s_mapStringValues["keys" ] = uns::Keys;
CunsOut2<T>::s_mapStringValues["age" ] = uns::Age;
CunsOut2<T>::s_mapStringValues["temp" ] = uns::Temp;
CunsOut2<T>::s_mapStringValues["ne" ] = uns::Temp;
CunsOut2<T>::s_mapStringValues["nh" ] = uns::Nh;
CunsOut2<T>::s_mapStringValues["sfr" ] = uns::Sfr;
CunsOut2<T>::s_mapStringValues["metal" ] = uns::Metal;
CunsOut2<T>::s_mapStringValues["gas_metal" ] = uns::GasMetal;
CunsOut2<T>::s_mapStringValues["stars_metal"] = uns::StarsMetal;
......
......@@ -85,6 +85,9 @@ enum StringData {
Acc ,
Age ,
Temp , // temperature
Ne , // Temperature ElectronAbundance
Sfr , // Star formation rate
Nh , // NeutralHydrogenAbundance
Metal , // total metal : gas+stars
GasMetal , // metal for gas
StarsMetal, // metal for stars
......
......@@ -103,7 +103,7 @@ int uns_init_(const char * _name,const char * _comp, const char * _time, const i
std::string simname = tools::Ctools::fixFortran(_name,l1,false);
std::string sel_comp = tools::Ctools::fixFortran(_comp,l2,false);
std::string sel_time = tools::Ctools::fixFortran(_time,l3,false);
uns::CunsIn2<float> * uns = new uns::CunsIn2<float>(simname,sel_comp,sel_time,false);
uns::CunsIn2<float> * uns = new uns::CunsIn2<float>(simname,sel_comp,sel_time,true);
bool valid = uns->isValid();
if (valid) {
......
......@@ -17,9 +17,9 @@
#define UNS_VERSION_H
#define UNSIO_MAJOR "1"
#define UNSIO_MINOR "2"
#define UNSIO_MINOR "3"
#define UNSIO_PATCH "0"
#define UNSIO_EXTRA "-dev-May-09-2019"
#define UNSIO_EXTRA "-dev-May-29-2019"
#endif // UNS_VERSION_H
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2010-2016
// Copyright Jean-Charles LAMBERT - 2010-2019
// Centre de donneeS Astrophysiques de Marseille (CeSAM)
// e-mail: Jean-Charles.Lambert@lam.fr
// address: Aix Marseille Universite, CNRS, LAM
......@@ -35,7 +35,7 @@ const char * defv[] = {
"maxline=2\n max lines per components",
"times=all\n selected time",
"verbose=f\n verbose on/off",
"VERSION=2.1\n compiled on <"__DATE__"> JCL ",
"VERSION=2.2\n compiled on <"__DATE__"> JCL ",
NULL,
};
const char * usage="Print information about an UNS file";
......@@ -60,107 +60,156 @@ template <class T> void displayInfo(bool display,int maxlines, std::string comp,
std::cout<< setfill(' ');
std::cout<< left<< setw(8) << comp << ":" << setw(9) << right << nbody << "\n";
}
ok = uns->snapshot->getData(comp,"mass",&nbody,&mass);
if (ok && display) {
displayFormat(maxlines,"mass[1] = ",mass,1,nbody, 3);
}
ok = uns->snapshot->getData(comp,"pos" ,&nbody,&pos );
if (ok && display) {
displayFormat(maxlines,"pos [3] = ",pos ,3,nbody, 1);
if (uns->snapshot->getReqBits()&MASS_BIT) {