diff --git a/lib/node.cpp b/lib/node.cpp index ce11458b4ffe0f84738fab7d28445e3e7eaae0e3..c08f6292980d51a25a8a2298ccefb3d6fc0d81db 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -57,16 +57,6 @@ void Node::update(List localParticles, unsigned nLocalParticles) { updateMassAndCOM(); isLeaf_ = true; - if (depth_ >= maxDepth_) { - // if the node contains less than minNParticles, it is a leaf - // std::cout << "max depth reached, nLocalParticles = " << nLocalParticles << std::endl; - for (unsigned i=0; i<8; ++i) { - delete children_[i]; - children_[i] = nullptr; - } - return; - } - for (unsigned i=0; i<8; ++i) { if (children_[i] != nullptr) { // if child is not a nullptr and particleDivision[i] contains too few particles, delete the child @@ -86,7 +76,7 @@ void Node::update(List localParticles, unsigned nLocalParticles) { double childSize = size_/2; Vector childCenter(3); for (unsigned j=0; j<3; ++j) { - childCenter[j] = center_[j] + (i & (1 << (2-j)) ? childSize : -childSize); + childCenter[j] = center_[j] + (i & (1 << j) ? childSize : -childSize); } children_[i] = new Node(mass_, positions_, nParticles_, softening_, depth_+1, childSize, childCenter, childParticles_[i], childParticles_[i].size()); @@ -225,15 +215,15 @@ unsigned Node::getOctant(unsigned particle) { double px = positions_[3*particle + 0]; double py = positions_[3*particle + 1]; double pz = positions_[3*particle + 2]; - if (px < center_[0]) { + if (px < center_[2]) { if (py < center_[1]) { - if (pz < center_[2]) { + if (pz < center_[0]) { return 0; } else { return 1; } } else { - if (pz < center_[2]) { + if (pz < center_[0]) { return 2; } else { return 3; @@ -241,13 +231,13 @@ unsigned Node::getOctant(unsigned particle) { } } else { if (py < center_[1]) { - if (pz < center_[2]) { + if (pz < center_[0]) { return 4; } else { return 5; } } else { - if (pz < center_[2]) { + if (pz < center_[0]) { return 6; } else { return 7; diff --git a/lib/node.hpp b/lib/node.hpp index 0102ac4609adfcde214a861006e54e03a49819cc..36b3bd9781b97b31e2f5137ab46ca2b7bbfa2f09 100644 --- a/lib/node.hpp +++ b/lib/node.hpp @@ -60,8 +60,7 @@ private: double totalMass_; const double theta0_ = 0.0; - const double minNParticles_ = 32; - const double maxDepth_ = 24; + const double minNParticles_ = 8; bool isLeaf_; };