mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Factored out the basic preprocessing code (partially inline subsampling)
This commit is contained in:
parent
c50876d994
commit
d291651ff1
3 changed files with 35 additions and 26 deletions
|
@ -71,32 +71,7 @@ public:
|
||||||
d->BoxSize *= unitMpc;
|
d->BoxSize *= unitMpc;
|
||||||
|
|
||||||
applyTransformations(d);
|
applyTransformations(d);
|
||||||
|
basicPreprocessing(d, preproc);
|
||||||
long numAccepted = 0;
|
|
||||||
bool *accepted = new bool[d->NumPart];
|
|
||||||
for (long i = 0; i < d->NumPart; i++)
|
|
||||||
{
|
|
||||||
SingleParticle p;
|
|
||||||
|
|
||||||
for (int k = 0; k < 3; k++)
|
|
||||||
{
|
|
||||||
p.Pos[k] = (d->Pos[k]) ? 0 : d->Pos[k][i];
|
|
||||||
p.Vel[k] = (d->Vel[k]) ? 0 : d->Vel[k][i];
|
|
||||||
}
|
|
||||||
p.ID = (d->Id) ? 0 : d->Id[i];
|
|
||||||
|
|
||||||
accepted[i] = preproc->accept(p);
|
|
||||||
numAccepted += accepted[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int k = 0; k < 3; k++)
|
|
||||||
{
|
|
||||||
filteredCopy(d->Pos[k], accepted, d->NumPart);
|
|
||||||
filteredCopy(d->Vel[k], accepted, d->NumPart);
|
|
||||||
}
|
|
||||||
filteredCopy(d->Id, accepted, d->NumPart);
|
|
||||||
filteredCopy(d->type, accepted, d->NumPart);
|
|
||||||
delete[] accepted;
|
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,3 +39,35 @@ void SimulationLoader::applyTransformations(SimuData *s)
|
||||||
redshift_gravity*s->Vel[redshift_axis][i]/100.;
|
redshift_gravity*s->Vel[redshift_axis][i]/100.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SimulationLoader::basicPreprocessing(SimuData *d,
|
||||||
|
SimulationPreprocessor *preproc)
|
||||||
|
{
|
||||||
|
long numAccepted = 0;
|
||||||
|
bool *accepted = new bool[d->NumPart];
|
||||||
|
for (long i = 0; i < d->NumPart; i++)
|
||||||
|
{
|
||||||
|
SingleParticle p;
|
||||||
|
|
||||||
|
for (int k = 0; k < 3; k++)
|
||||||
|
{
|
||||||
|
p.Pos[k] = (d->Pos[k]) ? 0 : d->Pos[k][i];
|
||||||
|
p.Vel[k] = (d->Vel[k]) ? 0 : d->Vel[k][i];
|
||||||
|
}
|
||||||
|
p.ID = (d->Id) ? 0 : d->Id[i];
|
||||||
|
|
||||||
|
accepted[i] = preproc->accept(p);
|
||||||
|
numAccepted += accepted[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int k = 0; k < 3; k++)
|
||||||
|
{
|
||||||
|
filteredCopy(d->Pos[k], accepted, d->NumPart);
|
||||||
|
filteredCopy(d->Vel[k], accepted, d->NumPart);
|
||||||
|
}
|
||||||
|
filteredCopy(d->Id, accepted, d->NumPart);
|
||||||
|
filteredCopy(d->type, accepted, d->NumPart);
|
||||||
|
delete[] accepted;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ protected:
|
||||||
|
|
||||||
void reallocSimu(CosmoTool::SimuData *s, long newNumPart);
|
void reallocSimu(CosmoTool::SimuData *s, long newNumPart);
|
||||||
|
|
||||||
|
|
||||||
|
void basicPreprocessor(SimuData *d, SimulationPreprocessor *preproc);
|
||||||
void applyTransformations(CosmoTool::SimuData *s);
|
void applyTransformations(CosmoTool::SimuData *s);
|
||||||
|
|
||||||
void copyParticleToSimu(const SingleParticle& p, CosmoTool::SimuData *s, long index)
|
void copyParticleToSimu(const SingleParticle& p, CosmoTool::SimuData *s, long index)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue