Commit 0ff18472 authored by jclamber's avatar jclamber

first ramses working

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@108 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent b5b9e373
......@@ -112,7 +112,9 @@ int CSnapshotRamsesIn::nextFrame(uns::UserSelection &user_select)
std::cerr << "ngas = "<< particles->ngas <<"\n";
std::cerr << "ndm = "<< particles->ndm <<"\n";
std::cerr << "nstars = "<< particles->nstars <<"\n";
std::cerr << "Start reordering...\n";
reorderParticles(user_select);
std::cerr << "Stop reordering...\n";
status = 1;
}
}
......@@ -357,7 +359,7 @@ bool CSnapshotRamsesIn::getData(const std::string comp, std::string name, int *n
// return requested array according 'name' selection
bool CSnapshotRamsesIn::getData(const std::string name,int *n,float **data)
{
bool ok=false;
bool ok=true;
*data = NULL;
*n = 0;
int first=0;
......@@ -370,6 +372,7 @@ bool CSnapshotRamsesIn::getData(const std::string name,int *n,float **data)
} else {
ok=false;
}
break;
case uns::Pos :
if (particles->pos.size()>0) {
*data = &particles->pos[first*3];
......@@ -394,7 +397,6 @@ bool CSnapshotRamsesIn::getData(const std::string name,int *n,float **data)
ok=false;
}
break;
case uns::Rho :
if (particles->rho.size()>0) {
*data = &particles->rho[0];
......@@ -450,7 +452,22 @@ bool CSnapshotRamsesIn::getData(const std::string name,int *n,float **data)
// return requested float according 'name' selection
bool CSnapshotRamsesIn::getData(const std::string name,float *data)
{
bool ok=false;
bool ok=true;
*data=0.0;
switch(CunsOut::s_mapStringValues[name]) {
case uns::Time :
*data = 0.0; // find time
break;
default: ok=false;
}
if (verbose) {
if (ok) {
std::cerr << "CSnapshotGadgetIn::getData name["<<name<<"]=" << CunsOut::s_mapStringValues[name] << "\n";
} else {
std::cerr << "**WARNING** CSnapshotGadgetIn::getData Value ["<<name<<"] does not exist...\n";
}
}
return ok;
}
// ============================================================================
......@@ -458,7 +475,35 @@ bool CSnapshotRamsesIn::getData(const std::string name,float *data)
// return requested array according 'name' selection
bool CSnapshotRamsesIn::getData(const std::string comp,const std::string name,int *n, int **data)
{
bool ok=false;
bool ok=true;
*data=NULL;
*n = 0;
int nbody,first,last;
bool status=getRangeSelect(comp.c_str(),&nbody,&first,&last,false); // find components ranges
if (!status && comp=="all") { // retreive all particles selected by the user
status=1;
first=0;
nbody=particles->ntot;
}
switch(CunsOut::s_mapStringValues[name]) {
case uns::Nbody :
if (status) {
*data = NULL;
*n = nbody;
} else {
ok = false;
}
break;
default: ok=false;
}
if (verbose) {
if (ok) {
std::cerr << "CSnapshotGadgetIn::getData name["<<name<<"]=" << CunsOut::s_mapStringValues[name] << "\n";
} else {
std::cerr << "**WARNING** CSnapshotGadgetIn::getData Value ["<<name<<"] for component <"<<comp<<"> does not exist...\n";
}
}
return ok;
}
// ============================================================================
......@@ -474,7 +519,31 @@ bool CSnapshotRamsesIn::getData(const std::string name,int *n, int **data)
// return requested int according 'name' selection
bool CSnapshotRamsesIn::getData(const std::string name,int *data)
{
bool ok=false;
bool ok=true;
*data=0;
switch(CunsOut::s_mapStringValues[name]) {
case uns::Nsel :
*data = particles->ntot;
break;
case uns::Ngas :
*data = particles->ngas;
break;
case uns::Nhalo :
*data = particles->ndm;
break;
case uns::Nstars :
*data = particles->nstars;
break;
default: ok=false;
}
if (ok && !*data) ok = false; // not ok because array is NULL
if (verbose) {
if (ok) {
std::cerr << "CSnapshotGadgetIn::getData name["<<name<<"]=" << CunsOut::s_mapStringValues[name] << "\n";
} else {
std::cerr << "**WARNING** CSnapshotGadgetIn::getData Value ["<<name<<"] does not exist or empty\n";
}
}
return ok;
}
// ============================================================================
......
......@@ -42,15 +42,6 @@ namespace uns {
CunsIn::CunsIn(const char * _name ,const char * _comp, const char * _time,
const bool verb)
{
CunsIn::s_mapCompInt["gas" ] = 0;
CunsIn::s_mapCompInt["halo" ] = 1;
CunsIn::s_mapCompInt["dm" ] = 1;
CunsIn::s_mapCompInt["disk" ] = 2;
CunsIn::s_mapCompInt["bulge" ] = 3;
CunsIn::s_mapCompInt["stars" ] = 4;
CunsIn::s_mapCompInt["bndry" ] = 5;
CunsIn::s_mapCompInt["all" ] =-1;
init(_name,_comp,_time,verb);
}
// ----------------------------------------------------------------------------
......@@ -62,6 +53,16 @@ namespace uns {
sel_comp = tools::Ctools::fixFortran(_comp.c_str(),false);
sel_time = tools::Ctools::fixFortran(_time.c_str(),false);
// initialise some maps
CunsIn::s_mapCompInt["gas" ] = 0;
CunsIn::s_mapCompInt["halo" ] = 1;
CunsIn::s_mapCompInt["dm" ] = 1;
CunsIn::s_mapCompInt["disk" ] = 2;
CunsIn::s_mapCompInt["bulge" ] = 3;
CunsIn::s_mapCompInt["stars" ] = 4;
CunsIn::s_mapCompInt["bndry" ] = 5;
CunsIn::s_mapCompInt["all" ] =-1;
// to lower
//simname = tools::Ctools::tolower(simname);
//sel_comp = tools::Ctools::tolower(sel_comp);
......
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