diff --git a/bh_tree_mpi/datastructures/BarnesHutTree.cpp b/bh_tree_mpi/datastructures/BarnesHutTree.cpp index 4f95c269e1853cf9e99df3ffc573406faf18d9c2..acdfade7f66c91c670e7a84a8028633353043313 100644 --- a/bh_tree_mpi/datastructures/BarnesHutTree.cpp +++ b/bh_tree_mpi/datastructures/BarnesHutTree.cpp @@ -47,14 +47,39 @@ namespace nbody { child->bb = *it; child->bodies = it->copyBodies(current->bodies); current->insertAfter(child); - child->nextSibling = current->next; - current->next->prevSibling = child; + if (it + 1 != subboxes.end()) { + child->nextSibling = current->next; + } + if (it != subboxes.begin()) { + current->next->prevSibling = child; + } if (it != subboxes.begin()) { child->afterSubtree = child->next; } else { child->afterSubtree = current->afterSubtree; } } + + //// + Node* child = current->next; + for (int i = 0; i < 8; i++) { + if (i == 0) { + if (child->prevSibling != NULL || child->nextSibling == NULL) { + cout << "WRONG BEG" << endl; + } + } else if (i == 7) { + if (child->prevSibling == NULL || child->nextSibling != NULL) { + cout << "WRONG END" << endl; + } + } else { + if (child->prevSibling == NULL || child->nextSibling == NULL) { + cout << "WRONG MID" << endl; + } + } + child = child->next; + } + //// + current->bodies.clear(); } current = current->next; diff --git a/bh_tree_mpi/datastructures/Tree.cpp b/bh_tree_mpi/datastructures/Tree.cpp index 883f68a75b435ff204767a81e04bf54f554971e5..aa104ae2d9087291c3a8a9d3edf2a9c670ce7ae7 100644 --- a/bh_tree_mpi/datastructures/Tree.cpp +++ b/bh_tree_mpi/datastructures/Tree.cpp @@ -125,7 +125,6 @@ namespace nbody { bool sufficient = current->sufficientForBox(domain); if (sufficient) { - //TODO: check for setting representative in build process result.push_back(current->representative); current = current->afterSubtree; } else if (current->leaf) { diff --git a/bh_tree_mpi/parallelization/MpiSimulation.cpp b/bh_tree_mpi/parallelization/MpiSimulation.cpp index b34b20609d3e53a477f212f7ba927c94209a8c2e..ba81e9ded93cd2b53549cd39ebd9cf81f1d9502e 100644 --- a/bh_tree_mpi/parallelization/MpiSimulation.cpp +++ b/bh_tree_mpi/parallelization/MpiSimulation.cpp @@ -143,6 +143,7 @@ namespace nbody { this->comms[0].recvBlocking(0, this->bodies); } this->tree.build(this->bodies); + this->tree.isCorrect(); } void MpiSimulation::distributeDomains() {