From 8dec2e8312250cea7426476328dcce1c3c141e19 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Sat, 6 Aug 2016 06:04:54 +0100 Subject: [PATCH] started to convert BucketSearchSerial to new format --- doc/neighbourhood.qbk | 2 +- src/BucketSearchSerial.h | 82 ++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 46 deletions(-) diff --git a/doc/neighbourhood.qbk b/doc/neighbourhood.qbk index 630f7f91..f0a7198c 100644 --- a/doc/neighbourhood.qbk +++ b/doc/neighbourhood.qbk @@ -43,7 +43,7 @@ containing 1. The found particle object 2. $dx$, a vector pointing to the query point from the found point. I.e. if -$x_a$ is the query point and $x_b$ is the found point, then $dx = x_a - x_b$. +$x_a$ is the query point and $x_b$ is the found point, then $dx = x_b - x_a$. The latter is useful for periodic domains, the returned vector $dx$ takes periodic domains into account and returns the $dx$ with the smallest length. diff --git a/src/BucketSearchSerial.h b/src/BucketSearchSerial.h index cb0a2201..7e322414 100644 --- a/src/BucketSearchSerial.h +++ b/src/BucketSearchSerial.h @@ -38,8 +38,8 @@ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define BUCKETSEARCH_H_ #include +#include "Traits.h" #include "Vector.h" -#include "Constants.h" #include "Log.h" #include #include @@ -64,8 +64,9 @@ const int CELL_EMPTY = -1; /// a given point can be performed using find_broadphase_neighbours(), which returns a const /// iterator to all the points in the same bucket or surrounding buckets of the given point. /// -template +template class BucketSearch { + UNPACK_TRAITS(traits) public: /// A const iterator to a set of neighbouring points. This iterator implements @@ -73,10 +74,10 @@ class BucketSearch { class const_iterator { public: - typedef const std::tuple* pointer; + typedef const std::tuple* pointer; typedef std::forward_iterator_tag iterator_category; - typedef const std::tuple value_type; - typedef const std::tuple reference; + typedef const std::tuple value_type; + typedef const std::tuple reference; typedef std::ptrdiff_t difference_type; @@ -133,7 +134,7 @@ class BucketSearch { /// all point pairs within a single container and so don't return /// each point pair twice (i.e. only 1/2 the normal neighbour checking required) explicit const_iterator(const BucketSearch* bucket_sort, - const Vect3d centre, + const double_d centre, const int my_index = -1, const bool self = false) : bucket_sort(bucket_sort), my_index(my_index),self(self), @@ -200,7 +201,7 @@ class BucketSearch { //std::cout <<" increment "<return_vect3d(bucket_sort->begin_iterator[*m_node]); + const double_d p = bucket_sort->return_vect3d(bucket_sort->begin_iterator[*m_node]); dx = centre-bucket_sort->correct_position_for_periodicity(centre, p); //std::cout << "testing candidate with position "< 0) && (celli[1] < num_cells_along_axes[1]-1), "position is outside of y-range "< linked_list,linked_list_reverse; std::vector neighbr_list; - Vect3d low,high,domain_size; + double_d low,high,domain_size; Vect3b periodic; - Vect3d cell_size,inv_cell_size; + double_d cell_size,inv_cell_size; Vect3i num_cells_along_axes; int num_cells_along_yz; double max_interaction_radius; @@ -618,7 +610,7 @@ void BucketSearch::copy_points(const T copy_to_iterator, const T copy_from_ } template -void BucketSearch::reset(const Vect3d& _low, const Vect3d& _high, double _max_interaction_radius, const Vect3b& _periodic) { +void BucketSearch::reset(const double_d& _low, const double_d& _high, double _max_interaction_radius, const Vect3b& _periodic) { LOG(2,"Resetting bucketsort data structure:"); LOG(2,"\tMax interaction radius = "<<_max_interaction_radius); high = _high; @@ -635,7 +627,7 @@ void BucketSearch::reset(const Vect3d& _low, const Vect3d& _high, double _m LOG(2,"\tNote: Dimension "<::reset(const Vect3d& _low, const Vect3d& _high, double _m LOG(2,"\tNumber of cells along each axis = "<