Adapt for a more general octTree
This commit is contained in:
parent
bab3c3b111
commit
bdb9825213
@ -19,6 +19,19 @@ OctTree::OctTree(const FCoordinates *particles, octPtr numParticles,
|
|||||||
//#ifdef VERBOSE
|
//#ifdef VERBOSE
|
||||||
cerr << "Allocating " << numCells << " octtree cells" << endl;
|
cerr << "Allocating " << numCells << " octtree cells" << endl;
|
||||||
//#endif
|
//#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];
|
cells = new OctCell[numCells];
|
||||||
Lbox = (float)(octCoordTypeNorm+1);
|
Lbox = (float)(octCoordTypeNorm+1);
|
||||||
|
@ -62,6 +62,8 @@ namespace CosmoTool
|
|||||||
float Lbox;
|
float Lbox;
|
||||||
octPtr lastNode;
|
octPtr lastNode;
|
||||||
octPtr numCells;
|
octPtr numCells;
|
||||||
|
float lenNorm;
|
||||||
|
float xMin[3];
|
||||||
|
|
||||||
|
|
||||||
template<typename FunT>
|
template<typename FunT>
|
||||||
@ -70,10 +72,13 @@ namespace CosmoTool
|
|||||||
octCoordType halfNodeLength)
|
octCoordType halfNodeLength)
|
||||||
{
|
{
|
||||||
OctCoords newCoord;
|
OctCoords newCoord;
|
||||||
FCoordinates realCenter;
|
FCoordinates center, realCenter;
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++)
|
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,
|
f(realCenter, cells[node].numberLeaves, halfNodeLength/(float)octCoordCenter,
|
||||||
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
||||||
@ -93,7 +98,10 @@ namespace CosmoTool
|
|||||||
if (newNode & octParticleMarker)
|
if (newNode & octParticleMarker)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 3; j++)
|
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,
|
f(realCenter,
|
||||||
1, halfNodeLength/(2.*octCoordCenter),
|
1, halfNodeLength/(2.*octCoordCenter),
|
||||||
|
Loading…
Reference in New Issue
Block a user