Commit 30d18914 authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

hdf5 writing working so far...

parent 64da40ef
......@@ -201,8 +201,10 @@ def process(args):
ok,insnap=readSnap(args.simname,args.component,args.float)
ok,svsnap=saveSnap(insnap,args.component,"gadget2",args.float)
ok,hdf5snap=saveSnap(insnap,args.component,"gadget3",args.float)
ok,nemosnap=saveSnap(insnap,args.component,"nemo",args.float)
compare(insnap,svsnap)
compare(insnap,hdf5snap)
compare(insnap,nemosnap)
# -----------------------------------------------------
......
......@@ -1748,13 +1748,8 @@ int CSnapshotGadgetOut<T>::setData(std::string name,std::string array, const in
bool ok=true;
int status=0;
switch(CunsOut2<T>::s_mapStringValues[name]) {
case uns::Gas :
case uns::Halo :
case uns::Disk :
case uns::Bulge :
case uns::Stars :
case uns::Bndry :
switch(CunsOut2<T>::s_mapStringValues[array]) {
case uns::Id :
status = setId(name, n, data, _addr);
break;
default: ok=false;
......
This diff is collapsed.
......@@ -55,27 +55,37 @@ typedef struct h5_header {
//
template <class T> class GH5 {
public:
GH5(const std::string _f_name, int mode, const bool verb=false);
GH5(const std::string _f_name,unsigned int mode, const bool verb=false);
~GH5();
t_h5_header getHeader() { return header; }
// reading
template <class U> std::vector<U> getDataset(std::string dset_name, U );
template <class U> std::vector<U> getAttribute(std::string attr_name);
int getNpartTotal() { return npart_total; }
// writing
template <class U>
bool setDataset(std::string dset_name, U * data, const unsigned int n, const unsigned int second_dim);
template <class U> bool setAttribute(std::string attr_name, U *, const int );
private:
std::map<std::string, bool> histo_group;
bool verbose;
void readHeaderAttributes();
int npart_total;
template <class U>
DataType guessType(U);
std::string f_name;
H5File * myfile;
Group header_group;
t_h5_header header;
};
//
// ---------------------------------------------------
// class CSnapshotGadgetH5In
//
// READING class
// ---------------------------------------------------
template <class T> class CSnapshotGadgetH5In : public CSnapshotInterfaceIn<T> {
public:
......@@ -116,8 +126,41 @@ private:
bool loadDataset(std::string tag, std::vector<U> &data);
void storeComponents();
}; // End of class snapshotgadgeth5
}; // End of class snapshotgadgetH5In
// ---------------------------------------------------
// class CSnapshotGadgetH5Out
// WRITING class
// ---------------------------------------------------
template <class T> class CSnapshotGadgetH5Out : public CSnapshotInterfaceOut<T> {
public:
CSnapshotGadgetH5Out(const std::string, const std::string, const bool);
~CSnapshotGadgetH5Out();
int setHeader(void * );
int setNbody(const int _n);
int setData(std::string, T);
int setData(std::string, const int , T *,const bool _addr=false);
// array by double keys
int setData(std::string, std::string, const int , T *,const bool _addr=false);
int setData(std::string, std::string, const int , int *,const bool _addr=false);
int setData(std::string, const int , int *,const bool _addr=false);
int setData(std::string, const int ,
T *, T *, T *, const bool _addr=false);
int save();
private:
// methods
template <class U>
bool saveCommonDataset(std::string name,std::string dataset, const int n ,U * data, const unsigned int);
template <class U>
bool checkMasses(const int n ,U * data, const int comp_id);
// HDF5 gadget object
GH5<T> * myH5;
t_h5_header header;
}; // End of class snapshotgadgetH5Out
} // namespace
#endif // SNAPSHOTGADGETH5_H
......@@ -221,7 +221,7 @@ namespace uns {
T *, T *, T *,const bool _addr=false)=0;
virtual int setData(std::string, const int, int *,const bool _addr=false)=0;
virtual int save()=0;
virtual std::vector<double> moveToCom()=0;
//virtual std::vector<double> moveToCom()=0;
std::string getInterfaceType() { return interface_type;}
std::string getFileStructure() { return file_structure;}
virtual int close() {
......
......@@ -286,9 +286,14 @@ template <class T> CunsOut2<T>::CunsOut2(const std::string _name, const std::str
snapshot = new CSnapshotNemoOut<T>(simname,simtype,verbose);
}
else {
std::cerr << "Unkonwn UNS output file format => ["<<simtype<<"]"
if (simtype == "gadget3") {
snapshot = new CSnapshotGadgetH5Out<T>(simname,simtype,verbose);
}
else {
std::cerr << "Unkonwn UNS output file format => ["<<simtype<<"]"
<< " aborting program...... \n\n";
std::exit(1);
std::exit(1);
}
}
}
}
......
......@@ -58,7 +58,7 @@
namespace uns {
const std::string VERSION="2.0.0.pre-march-10-2016"; // UNSIO version
const std::string VERSION="1.2.0.pre-march-16-2016"; // UNSIO version
inline std::string getVersion() { return uns::VERSION; }
......
......@@ -131,10 +131,10 @@ int main(int argc, char ** argv )
// according to user's input request ("select" parameter)
// check if gas component exist from input snapshot
if ((uns->snapshot->getRangeSelect("gas",&cnbody,&cfirst,&clast) && // gas exist
type == "gadget2") || // AND outype is gadget2
if (((uns->snapshot->getRangeSelect("gas",&cnbody,&cfirst,&clast) && // gas exist
(type == "gadget2" || type == "gadget3")) || // AND outype is gadget2
(select_c == "gas" && type=="nemo" && // OR only gas/nemo selected
uns->snapshot->getRangeSelect("gas",&cnbody,&cfirst,&clast))) {// AND gas exist
uns->snapshot->getRangeSelect("gas",&cnbody,&cfirst,&clast)))) {// AND gas exist
fprintf(stderr,"Gas :nbody %d first = %d last = %d\n",cnbody,cfirst,clast);
unsout->snapshot->setData("gas",cnbody,mass+cfirst,pos+cfirst*3,vel+cfirst*3,false);
......
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