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

* debugging force computation

parent c134ca62
Branches
No related merge requests found
......@@ -118,6 +118,7 @@ namespace nbody {
*/
BarnesHutTree::splitTree(this->nodes->next);
this->update();
}
void BarnesHutTree::build(vector<Body> bodies) {
......
......@@ -119,7 +119,11 @@ namespace nbody {
dvdt[i] = 1.0 / 6.0 * (a.dv[i] + 2.0f * (b.dv[i] + c.dv[i]) + d.dv[i]);
this->position[i] = this->position[i] + dxdt[i] * timestep;
this->velocity[i] = this->velocity[i] + dvdt[i] * timestep;
if (fabs(dxdt[i] * timestep) > FLT_EPSILON) {
cout << "M: " << dxdt[i] * timestep << endl;
}
}
//this->print();
}
......
......@@ -128,6 +128,10 @@ namespace nbody {
cout << "non-empty inner node" << endl;
return false;
}
if (this->leaf && this->nextSibling != NULL && this->next != this->nextSibling) {
cout << "wrong next sibling" << endl;
return false;
}
return true;
}
......
......@@ -57,15 +57,20 @@ namespace nbody {
body.resetAcceleration();
while (n != this->nodes) {
//cout << "n" << endl;
if (n->sufficientForBody(body)) {
n->representative.accumulateForceOnto(body);
//cout << "rb" << endl;
} else if (n->leaf) {
//cout << "l" << endl;
for (vector<Body>::iterator it = n->bodies.begin(); it != n->bodies.end(); it++) {
//cout << "lb" << endl;
it->accumulateForceOnto(body);
}
}
n = n->afterSubtree;
}
//body.print();
}
void Tree::computeForces() {
......@@ -140,6 +145,10 @@ namespace nbody {
this->build(this->extractLocalBodies(), domain);
}
void Tree::rebuild() {
this->build(this->extractLocalBodies());
}
void Tree::advance() {
for (Node* n = this->nodes->next; n != this->nodes; n = n->next) {
if (n->leaf) {
......
......@@ -34,6 +34,7 @@ namespace nbody {
virtual vector<Body> extractLocalBodies();
virtual vector<Body> copyRefinements(Box domain);
virtual void rebuild(Box domain);
virtual void rebuild();
virtual Box getRootBB();
virtual void print();
virtual bool isCorrect();
......
......@@ -179,6 +179,9 @@ namespace nbody {
//this->tree.getRootBB().print();
received++;
}
if (!this->tree.isCorrect()) {
cout << "WRONG" << endl;
}
}
void MpiSimulation::runStep() {
......@@ -195,6 +198,7 @@ namespace nbody {
}
*/
this->tree.rebuild(overallDomain);
this->distributeLETs();
this->tree.computeForces();
this->tree.advance();
......
......@@ -42,10 +42,10 @@ namespace nbody {
}
void PthreadSimulation::runStep() {
Box domain = this->tree.getRootBB();
//Box domain = this->tree.getRootBB();
//cout << this->tree.getRootBB().volume() << endl;
this->tree.rebuild(domain);
this->tree.rebuild();
this->tree.computeForces();
this->tree.advance();
......
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