Fixed representation and walking of arbitrary sized OctTree

This commit is contained in:
Guilhem Lavaux 2009-11-02 07:27:00 -06:00
parent bdb9825213
commit a4ffa66b8d
2 changed files with 22 additions and 8 deletions

View File

@ -32,6 +32,17 @@ OctTree::OctTree(const FCoordinates *particles, octPtr numParticles,
}
}
lenNorm = 0;
for (octPtr i = 0; i < numParticles; i++)
{
for (int j = 0; j < 3; j++)
{
float delta = particles[i][j]-xMin[j];
if (delta > lenNorm)
lenNorm = delta;
}
}
cout << xMin[0] << " " << xMin[1] << " " << xMin[2] << " lNorm=" << lenNorm << endl;
cells = new OctCell[numCells];
Lbox = (float)(octCoordTypeNorm+1);
@ -94,11 +105,14 @@ void OctTree::insertParticle(octPtr node,
}
for (int j = 0; j < 3; j++)
if ((octPtr)(particles[particleId][j]*Lbox) > icoord[j])
{
octPos |= (1 << j);
ipos[j] = 1;
}
{
float treePos = (particles[particleId][j]-xMin[j])*Lbox/lenNorm;
if ((octPtr)(treePos) > icoord[j])
{
octPos |= (1 << j);
ipos[j] = 1;
}
}
if (cells[node].children[octPos] == emptyOctCell)
{

View File

@ -77,10 +77,10 @@ namespace CosmoTool
for (int j = 0; j < 3; j++)
{
center[j] = icoord[j]/(2.*octCoordCenter);
realCenter[j] = center[j]*lenNorm+xMin[j];
realCenter[j] = xMin[j] + center[j]*lenNorm;
}
f(realCenter, cells[node].numberLeaves, halfNodeLength/(float)octCoordCenter,
f(realCenter, cells[node].numberLeaves, lenNorm*halfNodeLength/(float)octCoordCenter,
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
false);
@ -104,7 +104,7 @@ namespace CosmoTool
}
f(realCenter,
1, halfNodeLength/(2.*octCoordCenter),
1, lenNorm*halfNodeLength/(2.*octCoordCenter),
false, true);
continue;
}