diff --git a/bhtree_mpi/src/datastructures/BarnesHutTree.hpp b/bhtree_mpi/src/datastructures/BarnesHutTree.hpp index ff5a4e6210760bb4a9965530def896ce3953edeb..a765067bd8e65561400b965b7f513cf5f364eaa3 100644 --- a/bhtree_mpi/src/datastructures/BarnesHutTree.hpp +++ b/bhtree_mpi/src/datastructures/BarnesHutTree.hpp @@ -12,7 +12,7 @@ namespace nbody { static std::vector splitBB(const Node* node); static bool splitNode(Node* current); virtual void update(); - virtual void init(const std::vector& bodies, const Box& domain); //TODO(steinret): ctor + virtual void init(const std::vector& bodies, const Box& domain); static void split(Node* current); public: BarnesHutTree(int parallelId); diff --git a/bhtree_mpi/src/datastructures/Body.cpp b/bhtree_mpi/src/datastructures/Body.cpp index ca095a6d8849a13bf1c7422731e28284f3ff2fea..f458d587ad90f1d421e378ec1cc918e1b9b0d71b 100644 --- a/bhtree_mpi/src/datastructures/Body.cpp +++ b/bhtree_mpi/src/datastructures/Body.cpp @@ -75,7 +75,7 @@ namespace nbody { return mass >= 0.0; } - void Body::print(int parallelId) const { //TODO(steinret): do printing via put + void Body::print(int parallelId) const { std::cout << parallelId << " " << id << " Position: " << position[0] << " " << position[1] << " " << position[2] << '\n'; std::cout << parallelId << " " << id << " Velocity: " << velocity[0] << " " << velocity[1] << " " << velocity[2] << '\n'; std::cout << parallelId << " " << id << " Acceleration: " << acceleration[0] << " " << acceleration[1] << " " << acceleration[2] << '\n'; diff --git a/bhtree_mpi/src/datastructures/Box.cpp b/bhtree_mpi/src/datastructures/Box.cpp index b3609ef4ec838698f525e830602b075e5a2000f4..c16a2577ce77c5628a148200c63b842044b32f71 100644 --- a/bhtree_mpi/src/datastructures/Box.cpp +++ b/bhtree_mpi/src/datastructures/Box.cpp @@ -148,26 +148,6 @@ namespace nbody { std::cout << '\n'; } - //check for box/sphere overlap - bool Box::overlapsSphere(const double* sphereCenter, double sphereRadius) const { - double dmin = 0.0; - - if (!isValid()) { - return false; - } - for (int i = 0; i < 3; i++) { - if (sphereCenter[i] < min[i]) { - double dist = sphereCenter[i] - min[i]; - - dmin += dist * dist; - } else if (sphereCenter[i] > max[i]) { - double dist = sphereCenter[i] - max[i]; - - dmin += dist * dist; - } - } - return dmin <= sphereRadius * sphereRadius; - } //distance from nearest box order to position double Box::distanceToPosition(const double* position) const { diff --git a/bhtree_mpi/src/datastructures/Box.hpp b/bhtree_mpi/src/datastructures/Box.hpp index 8a4da435b124e4653755fca7abd9f99492288151..1bff6e8f0461674274cabc0033d7041e3e49296a 100644 --- a/bhtree_mpi/src/datastructures/Box.hpp +++ b/bhtree_mpi/src/datastructures/Box.hpp @@ -20,7 +20,6 @@ namespace nbody { bool isCorrectBox() const; bool isValid() const; void printBB(int parallelId) const; - bool overlapsSphere(const double* sphereCenter, double sphereRadius) const; //TODO(steinret): double* srsly? double distanceToPosition(const double* position) const; double distanceToBox(const Box& box2) const; std::vector octreeSplit() const; diff --git a/bhtree_mpi/src/datastructures/Node.cpp b/bhtree_mpi/src/datastructures/Node.cpp index 2cf627949912051235083aebe66e6b5cb4a7b452..f42853f6d5e4ce9855a069a867d0f08a645d3e82 100644 --- a/bhtree_mpi/src/datastructures/Node.cpp +++ b/bhtree_mpi/src/datastructures/Node.cpp @@ -177,6 +177,9 @@ namespace nbody { void Node::setBodies(const std::vector& bodies) { this->bodies = bodies; } + void Node::setBodies(std::vector&& bodies) { + this->bodies = std::move(bodies); + } //get local bodies void Node::extractLocalBodiesTo(std::vector& result) { diff --git a/bhtree_mpi/src/datastructures/Node.hpp b/bhtree_mpi/src/datastructures/Node.hpp index 96332903fbf925b264898fbcd0cd067839783130..279104a7fa7f37f376e805deec42da9fe7e8fa7b 100644 --- a/bhtree_mpi/src/datastructures/Node.hpp +++ b/bhtree_mpi/src/datastructures/Node.hpp @@ -42,7 +42,8 @@ namespace nbody { virtual void print(int parallelId) const; virtual bool sufficientForBody(const Body& body) const; virtual bool sufficientForBox(const Box& box) const; - virtual void setBodies(const std::vector& bodies); //TODO(steinret): && optimization + virtual void setBodies(const std::vector& bodies); + virtual void setBodies(std::vector&& bodies); virtual void extractLocalBodiesTo(std::vector& bodies); }; } diff --git a/bhtree_mpi/src/datastructures/Tree.hpp b/bhtree_mpi/src/datastructures/Tree.hpp index d7599e4b034b393df8c5e7e5421d16b7c9001de3..91289f3f4ba19a2a9ac2e219fc4437deb9a994fd 100644 --- a/bhtree_mpi/src/datastructures/Tree.hpp +++ b/bhtree_mpi/src/datastructures/Tree.hpp @@ -29,7 +29,7 @@ namespace nbody { virtual void setSimulation(Simulation* simulation); virtual void clean(); virtual void build(const std::vector& bodies) = 0; - virtual void build(const std::vector& bodies, const Box& domain) = 0; //TODO(steinret) dead? + virtual void build(const std::vector& bodies, const Box& domain) = 0; virtual int numberOfChildren() const = 0; virtual size_t numberOfNodes() const; virtual bool isCorrect() const;