Fixed position scaling in SDF

This commit is contained in:
Guilhem Lavaux 2013-03-06 00:59:28 +01:00
parent 1c1c8b778e
commit b8fa109008

View file

@ -84,8 +84,10 @@ public:
double rescale_position, double rescale_position,
double rescale_velocity) double rescale_velocity)
{ {
#define INFINITY std::numeric_limits<float>::max()
float shift = 0.5*d->BoxSize; float shift = 0.5*d->BoxSize;
rescale_position /= d->time; rescale_position /= d->time;
float min_pos[3] = {INFINITY,INFINITY, INFINITY}, max_pos[3] = {-INFINITY,-INFINITY,-INFINITY};
if (d->Pos[0] != 0) if (d->Pos[0] != 0)
{ {
@ -94,7 +96,10 @@ public:
for (int64_t i = 0; i < d->NumPart; i++) for (int64_t i = 0; i < d->NumPart; i++)
{ {
d->Pos[k][i] = (d->Pos[k][i]*rescale_position + shift); d->Pos[k][i] = (d->Pos[k][i]*rescale_position + shift);
min_pos[k] = std::min(min_pos[k], d->Pos[k][i]);
max_pos[k] = std::max(max_pos[k], d->Pos[k][i]);
} }
cout << boost::format("min[%d] = %g, max[%d] = %g") % k % min_pos[k] % k %max_pos[k] << endl;
} }
} }
if (d->Vel[0] != 0) if (d->Vel[0] != 0)
@ -170,7 +175,7 @@ public:
} }
if (load_flags & (NEED_POSITION | NEED_VELOCITY)) if (load_flags & (NEED_POSITION | NEED_VELOCITY))
rescaleParticles(d, 0.001*d->Hubble, one_kpc/one_Gyr); rescaleParticles(d, d->Hubble*1e-5, one_kpc/one_Gyr);
applyTransformations(d); applyTransformations(d);
basicPreprocessing(d, preproc); basicPreprocessing(d, preproc);
@ -194,6 +199,7 @@ SimulationLoader *sdfLoader(const std::string& snapshot, int flags,
return 0; return 0;
} }
cout << "Loading SDF with artificial splitting " << num_splitting << endl; cout << "Loading SDF with artificial splitting " << num_splitting << endl;
hdr = new SimuData;
SDFgetintOrDefault(sdfp, "version", &fileversion, 1); SDFgetintOrDefault(sdfp, "version", &fileversion, 1);
if (fileversion == 1) if (fileversion == 1)
@ -216,8 +222,8 @@ SimulationLoader *sdfLoader(const std::string& snapshot, int flags,
} }
double h0; double h0;
hdr->Hubble *= 10.0; hdr->Hubble *= 1000.0;
h0 = hdr->Hubble*(one_kpc/one_Gyr); h0 = hdr->Hubble/100.*(one_kpc/one_Gyr);
if (SDFhasname("R0", sdfp)) if (SDFhasname("R0", sdfp))
{ {