Skip to content
Snippets Groups Projects
Commit 23710af4 authored by Paul Heinzlreiter's avatar Paul Heinzlreiter
Browse files

* working on threading

parent c871b2d0
Branches
No related merge requests found
......@@ -58,7 +58,7 @@ namespace nbody {
}
void BarnesHutTree::splitNode(Node* current) {
if (current->isSplitable(this->control.maxLeafBodies)) {
if (current->isSplitable(&this->control)) {
vector<Box> subboxes = this->splitBB(current);
current->leaf = false;
Node* after = current->next;
......
......@@ -34,14 +34,18 @@ namespace nbody {
this->bb = bb;
}
bool Node::isSplitable(unsigned int maxBodies) {
if (this->bodies.size() < maxBodies + 1) {
return false;
bool Node::isSplitable(Control* control) {
bool result = true;
pthread_rwlock_rdlock(&control->lock);
if (this->bodies.size() < control->maxLeafBodies + 1) {
result = false;
}
if (this->bb.volume() <= FLT_EPSILON) {
return false;
result = false;
}
return true;
pthread_rwlock_unlock(&control->lock);
return result;
}
void Node::extendBBforBodies() {
......
......@@ -29,7 +29,7 @@ namespace nbody {
public:
Node(Tree* tree);
virtual ~Node();
virtual bool isSplitable(unsigned int maxBodies);
virtual bool isSplitable(Control* control);
virtual void extendBBforBodies();
virtual void extendBBtoCube();
virtual Box getBB();
......
......@@ -209,6 +209,9 @@ namespace nbody {
this->tree.computeForces();
this->tree.advance();
this->domains[this->mpiRank] = this->tree.getLocalBB();
if (!this->tree.isCorrect()) {
cout << "tree not correct" << endl;
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment