From 01f952865c39a3d7b01598176ed4e6b9e0b43037 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Thu, 7 Mar 2013 09:45:52 -0600 Subject: [PATCH] Allow replication to be different along different dimensions --- src/mykdtree.hpp | 10 ++++++++-- src/replicateGenerator.hpp | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/mykdtree.hpp b/src/mykdtree.hpp index 27d66ae..bf1eaa0 100644 --- a/src/mykdtree.hpp +++ b/src/mykdtree.hpp @@ -136,7 +136,13 @@ namespace CosmoTool { void setPeriodic(bool on, CoordType replicate) { periodic = on; - this->replicate = replicate; + std::fill(this->replicate, this->replicate+N, replicate); + } + + void setPeriodic(bool on, const coords& replicate) + { + periodic = on; + std::copy(replicate, replicate+N, this->replicate); } uint32_t getIntersection(const coords& x, CoordType r, @@ -193,7 +199,7 @@ namespace CosmoTool { Cell *base_cell; bool periodic; - CoordType replicate; + coords replicate; Node *buildTree(Cell **cell0, uint32_t NumCells, diff --git a/src/replicateGenerator.hpp b/src/replicateGenerator.hpp index fd7035f..4d89050 100644 --- a/src/replicateGenerator.hpp +++ b/src/replicateGenerator.hpp @@ -46,18 +46,29 @@ namespace CosmoTool { public: typedef Coord Coords[N]; - Coord replicate; + Coords replicate; ReplicateGenerator(const Coords& x, Coord shift) { face = 0; - replicate = shift; + std::fill(replicate, replicate+N, shift); numFaces = spower(3); std::copy(x, x+N, x_base); if (!next()) abort(); } + ReplicateGenerator(const Coords& x, Coords& shift) + { + face = 0; + std::copy(shift, shift+N, replicate); + numFaces = spower(3); + std::copy(x, x+N, x_base); + if (!next()) + abort(); + } + + bool next() { if (face == numFaces) @@ -72,7 +83,7 @@ namespace CosmoTool int c_face; c_face = q_face % 3; q_face /= 3; - x_shifted[i] = x_base[i] + (c_face-1)*replicate; + x_shifted[i] = x_base[i] + (c_face-1)*replicate[i]; no_move = no_move && (c_face == 1); } if (no_move)