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

removed useless forwarding references

parent 258ba060
Branches
Tags
No related merge requests found
...@@ -64,7 +64,7 @@ namespace nbody { ...@@ -64,7 +64,7 @@ namespace nbody {
} }
//initialize tree for build process //initialize tree for build process
void BarnesHutTree::init(const std::vector<Body>& bodies, const Box& domain) { void BarnesHutTree::init(std::vector<Body> bodies, const Box& domain) {
Node* current; Node* current;
clean(); clean();
...@@ -73,7 +73,7 @@ namespace nbody { ...@@ -73,7 +73,7 @@ namespace nbody {
nodes->insertAfter(new Node(this)); nodes->insertAfter(new Node(this));
current = nodes->next; current = nodes->next;
//assign bodies to root node //assign bodies to root node
current->bodies = bodies; current->bodies = std::move(bodies);
//setup proper bounding box //setup proper bounding box
current->bb = domain; current->bb = domain;
current->extendBBforBodies(); current->extendBBforBodies();
...@@ -92,18 +92,17 @@ namespace nbody { ...@@ -92,18 +92,17 @@ namespace nbody {
} }
//build tree with given domain //build tree with given domain
void BarnesHutTree::build(const std::vector<Body>& bodies, const Box& domain) { void BarnesHutTree::build(std::vector<Body> bodies, const Box& domain) {
init(bodies, domain); init(std::move(bodies), domain);
//iterate over existing boxes and split if it contains too much bodies //iterate over existing boxes and split if it contains too much bodies
BarnesHutTree::splitSubtree(nodes->next); BarnesHutTree::splitSubtree(nodes->next);
update(); update();
} }
//build tree //build tree
void BarnesHutTree::build(const std::vector<Body>& bodies) { void BarnesHutTree::build(std::vector<Body> bodies) {
Box bb; Box bb{ bodies };
bb.extendForBodies(bodies); build(std::move(bodies), bb);
build(bodies, bb);
} }
//merge remote refinement particles into local tree //merge remote refinement particles into local tree
......
...@@ -12,12 +12,12 @@ namespace nbody { ...@@ -12,12 +12,12 @@ namespace nbody {
static std::array<Box, 8> splitBB(const Node* node); static std::array<Box, 8> splitBB(const Node* node);
static bool splitNode(Node* current); static bool splitNode(Node* current);
void update(); void update();
void init(const std::vector<Body>& bodies, const Box& domain); void init(std::vector<Body> bodies, const Box& domain);
static void split(Node* current); static void split(Node* current);
public: public:
BarnesHutTree(std::size_t parallelId); BarnesHutTree(std::size_t parallelId);
void build(const std::vector<Body>& bodies) override; void build(std::vector<Body> bodies) override;
void build(const std::vector<Body>& bodies, const Box& domain) override; void build(std::vector<Body> bodies, const Box& domain) override;
void mergeLET(const std::vector<Body>& bodies); void mergeLET(const std::vector<Body>& bodies);
std::size_t numberOfChildren() const override; std::size_t numberOfChildren() const override;
static void splitSubtree(Node* root); static void splitSubtree(Node* root);
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
namespace nbody { namespace nbody {
Node::Node(Tree* tree_):tree(tree_) {} Node::Node(Tree* tree_):tree(tree_) {}
Node::Node(const Box& bb_, std::vector<Body>&& bodies_, Tree* tree_): bodies(std::move(bodies_)), bb(bb_), tree(tree_) {} Node::Node(const Box& bb_, std::vector<Body> bodies_, Tree* tree_): bodies(std::move(bodies_)), bb(bb_), tree(tree_) {}
Node::Node(std::vector<Body>&& bodies_, Tree* tree_) : bodies(std::move(bodies_)), bb(bodies), tree(tree_) {} Node::Node(std::vector<Body> bodies_, Tree* tree_) : bodies(std::move(bodies_)), bb(bodies), tree(tree_) {}
Box Node::getBB() const { Box Node::getBB() const {
return bb; return bb;
......
...@@ -41,8 +41,8 @@ namespace nbody { ...@@ -41,8 +41,8 @@ namespace nbody {
Body representative; Body representative;
public: public:
Node(Tree* _tree); Node(Tree* _tree);
Node(const Box& bb_, std::vector<Body>&& bodies_, Tree* tree_); Node(const Box& bb_, std::vector<Body> bodies_, Tree* tree_);
Node(std::vector<Body>&& bodies_, Tree* tree_); Node(std::vector<Body> bodies_, Tree* tree_);
~Node() = default; ~Node() = default;
bool isSplitable() const; bool isSplitable() const;
void extendBBforBodies(); void extendBBforBodies();
......
...@@ -24,8 +24,8 @@ namespace nbody { ...@@ -24,8 +24,8 @@ namespace nbody {
Tree(std::size_t parallelId_); Tree(std::size_t parallelId_);
virtual ~Tree(); virtual ~Tree();
virtual void clean(); virtual void clean();
virtual void build(const std::vector<Body>& bodies) = 0; virtual void build(std::vector<Body> bodies) = 0;
virtual void build(const std::vector<Body>& bodies, const Box& domain) = 0; virtual void build(std::vector<Body> bodies, const Box& domain) = 0;
virtual std::size_t numberOfChildren() const = 0; virtual std::size_t numberOfChildren() const = 0;
virtual std::size_t numberOfNodes() const; virtual std::size_t numberOfNodes() const;
virtual bool isCorrect() const; virtual bool isCorrect() const;
......
...@@ -96,7 +96,7 @@ namespace nbody { ...@@ -96,7 +96,7 @@ namespace nbody {
} }
//mpi send wrapper //mpi send wrapper
void MpiSimulation::send(std::vector<Body>&& bodies, int target) { void MpiSimulation::send(std::vector<Body> bodies, int target) {
const auto bodySize = bodies.size(); const auto bodySize = bodies.size();
SendStore store{ std::move(bodies) }; SendStore store{ std::move(bodies) };
MPI_Isend(store.bodies.data(), bodySize, bodyType, target, 0, MPI_COMM_WORLD, &store.request); MPI_Isend(store.bodies.data(), bodySize, bodyType, target, 0, MPI_COMM_WORLD, &store.request);
......
...@@ -13,7 +13,7 @@ namespace nbody { ...@@ -13,7 +13,7 @@ namespace nbody {
struct SendStore { struct SendStore {
std::vector<Body> bodies; std::vector<Body> bodies;
MPI_Request request{ MPI_REQUEST_NULL }; MPI_Request request{ MPI_REQUEST_NULL };
SendStore(std::vector<Body>&& b):bodies(std::move(b)) {}; SendStore(std::vector<Body> b):bodies(std::move(b)) {};
}; };
//MPI simulation //MPI simulation
...@@ -27,7 +27,7 @@ namespace nbody { ...@@ -27,7 +27,7 @@ namespace nbody {
std::vector<SendStore> sendStores; std::vector<SendStore> sendStores;
void flushSendStore(); void flushSendStore();
void send(std::vector<Body>&& bodies, int target); void send(std::vector<Body> bodies, int target);
int recv(std::vector<Body>& bodies, int source); int recv(std::vector<Body>& bodies, int source);
public: public:
MpiSimulation(const std::string& inputFile); MpiSimulation(const std::string& inputFile);
......
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