From 87682f97767393c63315c9c71462aff5b759810f Mon Sep 17 00:00:00 2001 From: Paul Heinzlreiter Date: Tue, 12 Jul 2016 11:09:23 +0200 Subject: [PATCH] * debbugging tree build --- bh_tree_mpi/datastructures/BarnesHutTree.cpp | 29 +++++++++++++++++-- bh_tree_mpi/datastructures/Tree.cpp | 1 - bh_tree_mpi/parallelization/MpiSimulation.cpp | 1 + 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bh_tree_mpi/datastructures/BarnesHutTree.cpp b/bh_tree_mpi/datastructures/BarnesHutTree.cpp index 4f95c26..acdfade 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 883f68a..aa104ae 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 b34b206..ba81e9d 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() { -- GitLab