From 0f4bd471a620584219a92219c2d7a9b5e7805f84 Mon Sep 17 00:00:00 2001 From: Paul Heinzlreiter Date: Tue, 21 Jun 2016 17:30:03 +0200 Subject: [PATCH] * node representation --- bh_tree_mpi/datastructures/Body.cpp | 13 +++++++++++++ bh_tree_mpi/datastructures/Body.hpp | 4 ++++ bh_tree_mpi/datastructures/TreeNode.cpp | 6 ++++++ bh_tree_mpi/datastructures/TreeNode.hpp | 2 ++ 4 files changed, 25 insertions(+) diff --git a/bh_tree_mpi/datastructures/Body.cpp b/bh_tree_mpi/datastructures/Body.cpp index 37dd95e..f0558c8 100644 --- a/bh_tree_mpi/datastructures/Body.cpp +++ b/bh_tree_mpi/datastructures/Body.cpp @@ -116,6 +116,19 @@ namespace nbody { return this->position[index]; } + double Body::getMass() { + return this->weight; + } + + void Body::setPosition(int index, double value) { + this->position[index] = value; + } + + void Body::setMass(double value) { + this->weight = value; + } + + void Body::print() { cout << this->position[0] << " " << this->position[1] << " " << this->position[2] << endl; } diff --git a/bh_tree_mpi/datastructures/Body.hpp b/bh_tree_mpi/datastructures/Body.hpp index 9e22e40..09b023e 100644 --- a/bh_tree_mpi/datastructures/Body.hpp +++ b/bh_tree_mpi/datastructures/Body.hpp @@ -1,6 +1,7 @@ #ifndef BODY_HPP #define BODY_HPP + namespace nbody { static const double timestep = 1.0; class Derivative; @@ -21,6 +22,9 @@ namespace nbody { Body(double positionX, double positionY, double positionZ, double velocityX, double velocityY, double velocityZ, double weight); virtual ~Body(); virtual double getPosition(int index); + virtual double getMass(); + virtual void setPosition(int index, double value); + virtual void setMass(double value); virtual void integrate(); virtual void print(); }; diff --git a/bh_tree_mpi/datastructures/TreeNode.cpp b/bh_tree_mpi/datastructures/TreeNode.cpp index 026230a..7af400e 100644 --- a/bh_tree_mpi/datastructures/TreeNode.cpp +++ b/bh_tree_mpi/datastructures/TreeNode.cpp @@ -133,6 +133,12 @@ namespace nbody { return true; } + void TreeNode::update() { + if (this->leaf) { + + } + } + void TreeNode::print() { this->bb.print(); for (vector::iterator it = this->bodies.begin(); it != this->bodies.end(); it++) { diff --git a/bh_tree_mpi/datastructures/TreeNode.hpp b/bh_tree_mpi/datastructures/TreeNode.hpp index 73d1124..ee48bf7 100644 --- a/bh_tree_mpi/datastructures/TreeNode.hpp +++ b/bh_tree_mpi/datastructures/TreeNode.hpp @@ -24,6 +24,7 @@ namespace nbody { TreeNode* afterSubtree; bool leaf; Tree* tree; + Body representative; public: TreeNode(Tree* tree); virtual ~TreeNode(); @@ -35,6 +36,7 @@ namespace nbody { virtual void insertBefore(TreeNode* node); virtual void insertAfter(TreeNode* node); virtual void unlink(); + virtual void update(); virtual bool isCorrect(); virtual void print(); }; -- GitLab