Commit 01b0e3de authored by jclamber's avatar jclamber

py/uns.h replaced by unsio/uns.h

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@169 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent a2b04c9b
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2008-2013
// e-mail: Jean-Charles.Lambert@oamp.fr
// address: Dynamique des galaxies
// Laboratoire d'Astrophysique de Marseille
// Pole de l'Etoile, site de Chateau-Gombert
// 38, rue Frederic Joliot-Curie
// 13388 Marseille cedex 13 France
// CNRS U.M.R 6110
// ============================================================================
#ifndef UNSENGINE_H
#define UNSENGINE_H
/**
@author Jean-Charles Lambert <jean-charles.lambert@oamp.fr>
*/
#include <cstring>
#include <string>
#include "snapshotinterface.h"
#include <map>
namespace uns {
enum StringData {
// data
Time ,
Redshift ,
Pos ,
Vel ,
Mass ,
Id ,
Rho ,
Hsml ,
U , // internal Energy
Keys ,
Aux ,
Eps ,
Pot ,
Acc ,
Age ,
Temp , // temperature
Metal , // total metal : gas+stars
GasMetal , // metal for gas
StarsMetal, // metal for stars
Zs ,
ZSMT ,
Im ,
Cm ,
Czs ,
Czsmt ,
Ssl ,
// Nbodies per component
Nsel ,
Nbody ,
Ngas ,
Nhalo ,
Ndisk ,
Nbulge ,
Nstars ,
Nbndry ,
// Components
Gas ,
Halo ,
Disk ,
Bulge ,
Stars ,
Bndry ,
All ,
GasMPV ,
HaloMPV ,
DiskMPV ,
BulgeMPV ,
StarsMPV ,
BndryMPV
};
// class Cuns
// manage Unified Nbody Snapshot Input operations
class CunsIn {
public:
// constructor for READING opertaions
CunsIn(const char * ,const char * , const char *, const bool verb=false );
CunsIn(const std::string ,const std::string,const std::string, const bool verb=false );
~CunsIn();
bool isValid() { return valid;}
uns::CSnapshotInterfaceIn * snapshot; // object to store data
// Map to associate component with a type
static std::map<std::string, int> s_mapCompInt;
//
// py wrapper
//
int nextFrame(const char * _bits) {
std::string bits(_bits);
int ok=snapshot->nextFrame(bits);
return ok;
}
bool getData(const char * _comp,const char * _prop,
int * size,float ** farray) {
float * data=NULL;
int nbody=0;
*size=0;
std::string comp(_comp);
std::string prop(_prop);
bool ok=snapshot->getData(comp,prop,&nbody,&data);
if (ok) {
int dim=1;
if (prop=="pos" || prop == "vel" || prop == "acc") dim=3;
std::cerr << "DIM="<<dim<<"\n";
*farray = data;
*size=nbody*dim;
}
return ok;
}
// py wrapper
private:
void init(const std::string ,const std::string,const std::string, const bool verb=false );
std::string simname, sel_comp, sel_time; // IN
void tryGadget();
void tryNemo();
void trySimDB();
void trySnapList();
void tryRamses();
//bool findSim();
bool valid;
bool verbose;
};
// class CunsOut
// manage Unified Nbody Snapshot Output operations
class CunsOut {
public:
// constructor for WRITING operations
CunsOut(const std::string, const std::string, const bool verb=false);
~CunsOut();
bool isValid() { return valid;};
uns::CSnapshotInterfaceOut * snapshot; // object to store data
// Map to associate the strings with the enum values
static std::map<std::string, StringData> s_mapStringValues;
static void initializeStringMap(const bool);
private:
std::string simname, simtype; // OUT
//bool findSim();
bool valid;
bool verbose;
};
}
#endif
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