Commit a071a86e authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

fix gadget writing crash when saving gas properties before gas positions

parent 30d18914
......@@ -2014,7 +2014,9 @@ int CSnapshotGadgetOut<T>::setAcc(std::string name, const int _n, T * _acc, cons
template <class T>
int CSnapshotGadgetOut<T>::setRho(const int _n, T * _rho, const bool addr)
{
assert(_n==header.npart[0]);; // #rho particles = #gas particles
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #rho particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
rho = _rho;
}
......@@ -2032,8 +2034,8 @@ int CSnapshotGadgetOut<T>::setRho(const int _n, T * _rho, const bool addr)
template <class T>
int CSnapshotGadgetOut<T>::setHsml(const int _n, T * _hsml, const bool addr)
{
assert(_n==header.npart[0]);; // #hsml particles = #gas particles
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #hsml particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
hsml = _hsml;
}
......@@ -2050,9 +2052,9 @@ int CSnapshotGadgetOut<T>::setHsml(const int _n, T * _hsml, const bool addr)
// setU:
template <class T>
int CSnapshotGadgetOut<T>::setU(const int _n, T * _U, const bool addr)
{
assert(_n==header.npart[0]);; // #U particles = #gas particles
{
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #U particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
intenerg = _U;
}
......@@ -2071,7 +2073,8 @@ template <class T>
int CSnapshotGadgetOut<T>::setTemp(const int _n, T * _temp, const bool addr)
{
assert(_n==header.npart[0]);; // #U particles = #gas particles
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #U particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
temp = _temp;
}
......@@ -2090,7 +2093,8 @@ template <class T>
int CSnapshotGadgetOut<T>::setMetalGas(const int _n, T * _mg, const bool addr)
{
assert(_n==header.npart[0]);; // #U particles = #gas particles
if (header.npart[0]>0) assert(_n==header.npart[0]);; // #U particles = #gas particles
header.npart[0]=_n;
if (addr) { // map address
metal[0] = _mg;
}
......@@ -2109,7 +2113,8 @@ template <class T>
int CSnapshotGadgetOut<T>::setMetalStars(const int _n, T * _ms, const bool addr)
{
assert(_n==header.npart[4]);; // #metal stars particles
if (header.npart[4]>0) assert(_n==header.npart[4]);; // #metal stars particles
header.npart[4]=_n;
if (addr) { // map address
metal[4] = _ms;
}
......@@ -2128,7 +2133,8 @@ template <class T>
int CSnapshotGadgetOut<T>::setAge(const int _n, T * _age, const bool addr)
{
assert(_n==header.npart[4]);; // #age stars particles
if (header.npart[4]>0) assert(_n==header.npart[4]);; // #age stars particles
header.npart[4]=_n;
if (addr) { // map address
age = _age;
}
......
......@@ -248,29 +248,6 @@ template <class T> bool CSnapshotInterfaceIn<T>::checkRangeTime(const float curr
}
return false;
}
// ============================================================================
// shift
// shift Positions or Velocities
template <class T> bool CSnapshotInterfaceIn<T>::shift(std::string name,const float x, const float y, const float z)
{
T * data;
if (name!="pos" && name!="vel") {
std::cerr << "Error CSnapshotInterfaceIn::shift, name=["<<name<<"] sould be \"pos\" or \"vel\" \n"
<< "aborting....\n";
std::exit(1);
}
int nbody;
bool ok=getData("all",name,&nbody,&data);
if (ok) {
for (int i=0; i<nbody; i++) {
data[i*3+0] += x;
data[i*3+1] += y;
data[i*3+2] += z;
}
}
return ok;
}
// ============================================================================
// getRangeSelect
// ============================================================================
......
......@@ -124,8 +124,7 @@ namespace uns {
virtual void setNsel(const int _nsel) { nsel = _nsel;}
virtual bool isNewFrame() { return true;}
virtual int nextFrame(std::string bits="");//mxvpaekXRMAHIU");
virtual ComponentRangeVector * getCrvFromSelection() { return user_select.getCrvFromSelection();}
virtual bool shift(std::string,const float x, const float y, const float z);
virtual ComponentRangeVector * getCrvFromSelection() { return user_select.getCrvFromSelection();}
virtual T getEps(const std::string) { return -1.;}
virtual int getCod(const std::string select, const float time,
float * tcod, const std::string base="ANALYSIS/cod",
......
......@@ -51,9 +51,6 @@ namespace uns {
else return CSnapshotInterfaceIn<T>::getFileName();
}
bool isNewFrame();
bool shift(std::string name, const float x, const float y, const float z) {
return snapshot->shift(name,x,y,z);
}
virtual ComponentRangeVector * getCrvFromSelection() { return snapshot->user_select.getCrvFromSelection();}
//bool isNewFrame();
......
......@@ -54,9 +54,6 @@ namespace uns {
assert(0);
return "";
}
bool shift(std::string name, const float x, const float y, const float z) {
return snapshot->shift(name,x,y,z);
}
bool isNewFrame();
virtual ComponentRangeVector * getCrvFromSelection() { return snapshot->user_select.getCrvFromSelection();}
virtual int getCod(const std::string select, const float time,
......
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