Adapt for a more general octTree

This commit is contained in:
Guilhem Lavaux 2009-11-01 18:56:10 -06:00
parent bab3c3b111
commit bdb9825213
2 changed files with 24 additions and 3 deletions

View File

@ -19,6 +19,19 @@ OctTree::OctTree(const FCoordinates *particles, octPtr numParticles,
//#ifdef VERBOSE
cerr << "Allocating " << numCells << " octtree cells" << endl;
//#endif
for (int j = 0; j < 3; j++)
xMin[j] = particles[0][j];
for (octPtr i = 1; i < numParticles; i++)
{
for (int j = 0; j < 3; j++)
{
if (particles[i][j] < xMin[j])
xMin[j] = particles[i][j];
}
}
cells = new OctCell[numCells];
Lbox = (float)(octCoordTypeNorm+1);

View File

@ -62,6 +62,8 @@ namespace CosmoTool
float Lbox;
octPtr lastNode;
octPtr numCells;
float lenNorm;
float xMin[3];
template<typename FunT>
@ -70,10 +72,13 @@ namespace CosmoTool
octCoordType halfNodeLength)
{
OctCoords newCoord;
FCoordinates realCenter;
FCoordinates center, realCenter;
for (int j = 0; j < 3; j++)
realCenter[j] = icoord[j]/(2.*octCoordCenter);
{
center[j] = icoord[j]/(2.*octCoordCenter);
realCenter[j] = center[j]*lenNorm+xMin[j];
}
f(realCenter, cells[node].numberLeaves, halfNodeLength/(float)octCoordCenter,
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
@ -93,7 +98,10 @@ namespace CosmoTool
if (newNode & octParticleMarker)
{
for (int j = 0; j < 3; j++)
realCenter[j] = newCoord[j]/(2.*octCoordCenter);
{
center[j] = newCoord[j]/(2.*octCoordCenter);
realCenter[j] = xMin[j] + lenNorm*center[j];
}
f(realCenter,
1, halfNodeLength/(2.*octCoordCenter),