diff --git a/bh_tree_mpi/datastructures/Box.cpp b/bh_tree_mpi/datastructures/Box.cpp index f779a111d364ee68d5d245a7e17f35a9d75484d7..2e71f44114d677d06e918a467bbd294d9733769e 100644 --- a/bh_tree_mpi/datastructures/Box.cpp +++ b/bh_tree_mpi/datastructures/Box.cpp @@ -279,4 +279,15 @@ namespace nbody { } } } + + void Box::extend(Body extender) { + for (int i = 0; i < 3; i++) { + if (this->min[i] > extender.position[i]) { + this->min[i] = extender.position[i]; + } + if (this->max[i] < extender.position[i]) { + this->max[i] = extender.position[i]; + } + } + } } diff --git a/bh_tree_mpi/datastructures/Box.hpp b/bh_tree_mpi/datastructures/Box.hpp index 0c176b5ab123976ed21ffb5205e22762b7e72095..95a2459827dd06258cf1c3b2666a063944216882 100644 --- a/bh_tree_mpi/datastructures/Box.hpp +++ b/bh_tree_mpi/datastructures/Box.hpp @@ -37,6 +37,7 @@ namespace nbody { virtual vector splitLongestSide(); virtual bool contained(double* position); virtual void extend(Box extender); + virtual void extend(Body extender); }; } diff --git a/bh_tree_mpi/datastructures/Node.hpp b/bh_tree_mpi/datastructures/Node.hpp index ce22df9d5187fc482ba9720745d3d904e80da0cc..642932787df86c55f0042299edeae23c329bbae2 100644 --- a/bh_tree_mpi/datastructures/Node.hpp +++ b/bh_tree_mpi/datastructures/Node.hpp @@ -17,7 +17,6 @@ namespace nbody { protected: Box bb; vector bodies; - vector refinements; Node* prev; Node* next; Node* nextSibling; diff --git a/bh_tree_mpi/datastructures/Tree.cpp b/bh_tree_mpi/datastructures/Tree.cpp index f0bde3e238ed690ab972ba4cee6790bdb9c8b729..ce494b16c53cbdde59fe49e00aa9009485e2f386 100644 --- a/bh_tree_mpi/datastructures/Tree.cpp +++ b/bh_tree_mpi/datastructures/Tree.cpp @@ -149,6 +149,33 @@ namespace nbody { this->build(this->extractLocalBodies(), domain); } + void Tree::advance() { + for (Node* n = this->nodes->next; n != this->nodes; n = n->next) { + if (n->leaf) { + for (vector::iterator it = n->bodies.begin(); it != n->bodies.end(); it++) { + if (!it->refinement) { + it->integrate(); + } + } + } + } + } + + Box Tree::getLocalBB() { + Box result; + + for (Node* n = this->nodes->next; n != this->nodes; n = n->next) { + if (n->leaf) { + for (vector::iterator it = n->bodies.begin(); it != n->bodies.end(); it++) { + if (!it->refinement) { + result.extend(*it); + } + } + } + } + return result; + } + void Tree::print() { this->nodes->next->bb.print(); } diff --git a/bh_tree_mpi/datastructures/Tree.hpp b/bh_tree_mpi/datastructures/Tree.hpp index acd6efe345bc925b5b4a7a62f98e1e5b9786e0f3..4a73122e993078ca330446604a6eebe086eb679f 100644 --- a/bh_tree_mpi/datastructures/Tree.hpp +++ b/bh_tree_mpi/datastructures/Tree.hpp @@ -35,6 +35,8 @@ namespace nbody { virtual Box getRootBB(); virtual void print(); virtual bool isCorrect(); + virtual void advance(); + virtual Box getLocalBB(); }; diff --git a/bh_tree_mpi/parallelization/MpiSimulation.cpp b/bh_tree_mpi/parallelization/MpiSimulation.cpp index c2189ab4a8b542a09b3f62e0bdb46743e09d9c2a..69862fe8fdff455080b48fe90ac08b684720e424 100644 --- a/bh_tree_mpi/parallelization/MpiSimulation.cpp +++ b/bh_tree_mpi/parallelization/MpiSimulation.cpp @@ -143,11 +143,11 @@ namespace nbody { this->comms[0].recvBlocking(0, this->bodies); } this->tree.build(this->bodies); + this->domains[this->mpiRank] = this->tree.getRootBB(); //this->tree.isCorrect(); } void MpiSimulation::distributeDomains() { - this->domains[this->mpiRank] = this->tree.getRootBB(); MPI::COMM_WORLD.Allgather(&this->domains[this->mpiRank], 1, this->boxType, &this->domains[0], 1, this->boxType); } @@ -183,13 +183,16 @@ namespace nbody { Box overallDomain; this->distributeDomains(); - this->domains[this->mpiRank].print(); + //this->domains[this->mpiRank].print(); for (unsigned int i = 0; i < this->mpiSize; i++) { overallDomain.extend(this->domains[i]); } - overallDomain.print(); + //overallDomain.print(); this->tree.rebuild(overallDomain); this->distributeLETs(); + this->tree.computeForces(); + this->tree.advance(); + this->domains[this->mpiRank] = this->tree.getLocalBB(); } }