Upgraded ramses format-on-disk. DInterpolate assertion check

This commit is contained in:
Guilhem Lavaux 2012-06-28 09:36:28 -04:00
parent 17f3f74dd2
commit dc03871f37
3 changed files with 56 additions and 11 deletions

View File

@ -19,7 +19,10 @@ namespace CosmoTool {
for (uint32_t i = 0; i < numPoints; i++)
index_by_point[i] = numSimplex_by_point[i] = 0;
for (uint32_t i = 0; i < (N+1)*numSimplex; i++)
numSimplex_by_point[simplex_list[i]]++;
{
assert(simplex_list[i] < numPoints);
numSimplex_by_point[simplex_list[i]]++;
}
// Compute the total number and the index for accessing lists.
for (uint32_t i = 0; i < numPoints; i++)
@ -35,6 +38,7 @@ namespace CosmoTool {
for (int j = 0; j <= N; j++)
{
uint32_t p = simplex_list[(N+1)*i+j];
assert(index_by_point[p] < point_to_simplex_size);
point_to_simplex_list_base[index_by_point[p]] = i;
++index_by_point[p];
}
@ -45,6 +49,7 @@ namespace CosmoTool {
{
// check assertion
assert((i==0 && index_by_point[0]==numSimplex_by_point[0]) || ((index_by_point[i]-index_by_point[i-1]) == (numSimplex_by_point[i]+1)));
assert(index_by_point[i] < point_to_simplex_size);
point_to_simplex_list_base[index_by_point[i]] = -1;
}

View File

@ -258,7 +258,7 @@ int readInfoFile(const char *basename, int outputId, InfoData& info)
return 1;
}
CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputId, int cpuid, int flags)
CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputId, int cpuid, bool dp, int flags)
{
CosmoTool::SimuData *data = new CosmoTool::SimuData();
@ -347,6 +347,26 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
data->NumPart = nPar = infile.readInt32();
infile.endCheckpoint();
infile.beginCheckpoint();
for (int i = 0; i < 4; i++) infile.readInt32();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readInt32();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readReal64();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readReal64();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readInt32();
infile.endCheckpoint();
if (flags & NEED_POSITION)
{
data->Pos[0] = new float[nPar];
@ -371,7 +391,7 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
{
for (uint32_t i = 0; i < nPar; i++)
{
data->Pos[k][i] = infile.readReal32();
data->Pos[k][i] = dp ? infile.readReal64() : infile.readReal32();
data->Pos[k][i] *= data->BoxSize;
}
infile.endCheckpoint();
@ -386,7 +406,7 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
{
for (uint32_t i = 0; i < nPar; i++)
{
data->Vel[k][i] = infile.readReal32();
data->Vel[k][i] = dp ? infile.readReal64() : infile.readReal32();
data->Vel[k][i] *= unit_vel;
}
infile.endCheckpoint();
@ -399,7 +419,7 @@ CosmoTool::SimuData *CosmoTool::loadRamsesSimu(const char *basename, int outputI
infile.beginCheckpoint();
for (uint32_t i = nPar; i > 0; i--)
{
float dummyF = infile.readReal32();
float dummyF = dp ? infile.readReal64() : infile.readReal32();
if (dummyF < minMass) minMass = dummyF;
}
infile.endCheckpoint();
@ -797,7 +817,7 @@ CosmoTool::PhaseSpaceData *CosmoTool::loadRamsesPhase(const char *basename, int
}
CosmoTool::PhaseSpaceDataID *CosmoTool::loadRamsesPhase1(const char *basename, int outputId, int cpuid, bool quiet)
CosmoTool::PhaseSpaceDataID *CosmoTool::loadRamsesPhase1(const char *basename, int outputId, int cpuid, bool dp, bool quiet)
{
PhaseSpaceDataID *gd = (PhaseSpaceDataID *)malloc(sizeof(PhaseSpaceDataID));
int id = 1;
@ -905,6 +925,26 @@ CosmoTool::PhaseSpaceDataID *CosmoTool::loadRamsesPhase1(const char *basename, i
nPar = infile.readInt32();
infile.endCheckpoint();
infile.beginCheckpoint();
for (int i = 0; i < 4; i++) infile.readInt32();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readInt32();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readReal64();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readReal64();
infile.endCheckpoint();
infile.beginCheckpoint();
infile.readInt32();
infile.endCheckpoint();
gd->pos = new FCoordinates[nPar];
gd->vel = new FCoordinates[nPar];
@ -913,7 +953,7 @@ CosmoTool::PhaseSpaceDataID *CosmoTool::loadRamsesPhase1(const char *basename, i
infile.beginCheckpoint();
for (uint32_t i = 0; i < nPar; i++)
{
gd->pos[i][k] = infile.readReal32()*gd->BoxSize;
gd->pos[i][k] = (dp ? infile.readReal64() : infile.readReal32())*gd->BoxSize;
}
infile.endCheckpoint();
}
@ -923,7 +963,7 @@ CosmoTool::PhaseSpaceDataID *CosmoTool::loadRamsesPhase1(const char *basename, i
infile.beginCheckpoint();
for (uint32_t i = 0; i < nPar; i++)
{
gd->vel[i][k] = infile.readReal32()*unit_vel;
gd->vel[i][k] = (dp ? infile.readReal64() : infile.readReal32())*unit_vel;
}
infile.endCheckpoint();
}
@ -932,7 +972,7 @@ CosmoTool::PhaseSpaceDataID *CosmoTool::loadRamsesPhase1(const char *basename, i
infile.beginCheckpoint();
for (uint32_t i = nPar; i > 0; i--)
{
float dummyF = infile.readReal32();
float dummyF = (dp ? infile.readReal64() : infile.readReal32());
if (dummyF < minMass) minMass = dummyF;
}
infile.endCheckpoint();

View File

@ -10,9 +10,9 @@ namespace CosmoTool {
PurePositionData *loadRamsesPosition(const char *fname, int id, bool quiet = false, bool dp = true);
PhaseSpaceData *loadRamsesPhase(const char *fname, int id, bool quiet = false);
PhaseSpaceDataID *loadRamsesPhase1(const char *fname, int id, int cpuid, bool quiet = false);
PhaseSpaceDataID *loadRamsesPhase1(const char *fname, int id, int cpuid, bool dp = true, bool quiet = false);
SimuData *loadRamsesSimu(const char *basename, int id, int cpuid, int flags);
SimuData *loadRamsesSimu(const char *basename, int id, int cpuid, bool dp, int flags);
};
#endif