Skip to content
Snippets Groups Projects
Commit 81a92aa5 authored by Thomas Steinreiter's avatar Thomas Steinreiter
Browse files

* removed dead code

  * added move optimizations
parent f296df28
Branches
No related merge requests found
......@@ -12,7 +12,7 @@ namespace nbody {
static std::vector<Box> splitBB(const Node* node);
static bool splitNode(Node* current);
virtual void update();
virtual void init(const std::vector<Body>& bodies, const Box& domain); //TODO(steinret): ctor
virtual void init(const std::vector<Body>& bodies, const Box& domain);
static void split(Node* current);
public:
BarnesHutTree(int parallelId);
......
......@@ -75,7 +75,7 @@ namespace nbody {
return mass >= 0.0;
}
void Body::print(int parallelId) const { //TODO(steinret): do printing via put
void Body::print(int parallelId) const {
std::cout << parallelId << " " << id << " Position: " << position[0] << " " << position[1] << " " << position[2] << '\n';
std::cout << parallelId << " " << id << " Velocity: " << velocity[0] << " " << velocity[1] << " " << velocity[2] << '\n';
std::cout << parallelId << " " << id << " Acceleration: " << acceleration[0] << " " << acceleration[1] << " " << acceleration[2] << '\n';
......
......@@ -148,26 +148,6 @@ namespace nbody {
std::cout << '\n';
}
//check for box/sphere overlap
bool Box::overlapsSphere(const double* sphereCenter, double sphereRadius) const {
double dmin = 0.0;
if (!isValid()) {
return false;
}
for (int i = 0; i < 3; i++) {
if (sphereCenter[i] < min[i]) {
double dist = sphereCenter[i] - min[i];
dmin += dist * dist;
} else if (sphereCenter[i] > max[i]) {
double dist = sphereCenter[i] - max[i];
dmin += dist * dist;
}
}
return dmin <= sphereRadius * sphereRadius;
}
//distance from nearest box order to position
double Box::distanceToPosition(const double* position) const {
......
......@@ -20,7 +20,6 @@ namespace nbody {
bool isCorrectBox() const;
bool isValid() const;
void printBB(int parallelId) const;
bool overlapsSphere(const double* sphereCenter, double sphereRadius) const; //TODO(steinret): double* srsly?
double distanceToPosition(const double* position) const;
double distanceToBox(const Box& box2) const;
std::vector<Box> octreeSplit() const;
......
......@@ -177,6 +177,9 @@ namespace nbody {
void Node::setBodies(const std::vector<Body>& bodies) {
this->bodies = bodies;
}
void Node::setBodies(std::vector<Body>&& bodies) {
this->bodies = std::move(bodies);
}
//get local bodies
void Node::extractLocalBodiesTo(std::vector<Body>& result) {
......
......@@ -42,7 +42,8 @@ namespace nbody {
virtual void print(int parallelId) const;
virtual bool sufficientForBody(const Body& body) const;
virtual bool sufficientForBox(const Box& box) const;
virtual void setBodies(const std::vector<Body>& bodies); //TODO(steinret): && optimization
virtual void setBodies(const std::vector<Body>& bodies);
virtual void setBodies(std::vector<Body>&& bodies);
virtual void extractLocalBodiesTo(std::vector<Body>& bodies);
};
}
......
......@@ -29,7 +29,7 @@ namespace nbody {
virtual void setSimulation(Simulation* simulation);
virtual void clean();
virtual void build(const std::vector<Body>& bodies) = 0;
virtual void build(const std::vector<Body>& bodies, const Box& domain) = 0; //TODO(steinret) dead?
virtual void build(const std::vector<Body>& bodies, const Box& domain) = 0;
virtual int numberOfChildren() const = 0;
virtual size_t numberOfNodes() const;
virtual bool isCorrect() const;
......
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