From 8ba96371b94d5101c412ca01a2baf0a9d49811af Mon Sep 17 00:00:00 2001 From: Pietro Incardona <incardon@mpi-cbg.de> Date: Mon, 12 Mar 2018 16:44:42 +0100 Subject: [PATCH] Fixing grid_key_dx private member --- src/Grid/grid_key.hpp | 23 +++++++++++++----- src/Grid/grid_sm.hpp | 24 +++++++++---------- .../iterators/grid_key_dx_iterator_sub.hpp | 2 +- src/NN/CellList/CellList.hpp | 4 +++- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/Grid/grid_key.hpp b/src/Grid/grid_key.hpp index f7de564e..2fa4573e 100644 --- a/src/Grid/grid_key.hpp +++ b/src/Grid/grid_key.hpp @@ -301,7 +301,8 @@ public: * \param t list of number * */ - template<typename a, typename ...T>void set(a v, T...t) + template<typename a, typename ...T> + inline void set(a v, T...t) { #ifdef SE_CLASS1 if (sizeof...(t) != dim -1) @@ -311,6 +312,16 @@ public: invert_assign(t...); } + /*! \brief Return the internal k structure + * + * \return k + * + */ + const long int(& get_k() const)[dim] + { + return k; + } + /*! \brief Convert to a point the grid_key_dx * * \see toPoint @@ -367,7 +378,7 @@ public: * \return the index value * */ - mem_id value(size_t i) const + inline mem_id value(size_t i) const { return k[i]; } @@ -380,7 +391,7 @@ public: * \return the index value * */ - mem_id get(size_t i) const + inline mem_id get(size_t i) const { return k[i]; } @@ -393,7 +404,7 @@ public: * \param id value to set * */ - void set_d(size_t i, mem_id id) + inline void set_d(size_t i, mem_id id) { #ifdef SE_CLASS1 @@ -404,11 +415,11 @@ public: k[i] = id; } +private: + //! structure that store all the index mem_id k[dim]; -private: - /*! \brief Recursively invert the assignment * * Recursively invert the assignment at compile-time (hopefully) diff --git a/src/Grid/grid_sm.hpp b/src/Grid/grid_sm.hpp index 8dd4cae0..896b6afc 100755 --- a/src/Grid/grid_sm.hpp +++ b/src/Grid/grid_sm.hpp @@ -340,20 +340,20 @@ public: // Check the sum produce a valid key - if (check::valid(gk.k[0] + sum_id[0],sz[0]) == false) + if (check::valid(gk.get(0) + sum_id[0],sz[0]) == false) return -1; - lid = gk.k[0] + sum_id[0]; + lid = gk.get(0) + sum_id[0]; for (mem_id i = 1 ; i < N ; i++) { // Check the sum produce a valid key - if (check::valid(gk.k[i] + sum_id[i],sz[i]) == false) + if (check::valid(gk.get(i) + sum_id[i],sz[i]) == false) return -1; - lid += (gk.k[i] + sum_id[i]) * sz_s[i-1]; + lid += (gk.get(i) + sum_id[i]) * sz_s[i-1]; } return lid; @@ -377,14 +377,14 @@ public: if (bc[0] == NON_PERIODIC) { - if (check::valid(gk.k[0] + sum_id[0],sz[0]) == false) + if (check::valid(gk.get(0) + sum_id[0],sz[0]) == false) return -1; - lid = gk.k[0] + sum_id[0]; + lid = gk.get(0) + sum_id[0]; } else { - lid = openfpm::math::positive_modulo(gk.k[0] + sum_id[0],sz[0]); + lid = openfpm::math::positive_modulo(gk.get(0) + sum_id[0],sz[0]); } for (mem_id i = 1 ; i < N ; i++) @@ -394,14 +394,14 @@ public: /* coverity[dead_error_line] */ if (bc[i] == NON_PERIODIC) { - if (check::valid(gk.k[i] + sum_id[i],sz[i]) == false) + if (check::valid(gk.get(i) + sum_id[i],sz[i]) == false) return -1; - lid += (gk.k[i] + sum_id[i]) * sz_s[i-1]; + lid += (gk.get(i) + sum_id[i]) * sz_s[i-1]; } else { - lid += (openfpm::math::positive_modulo(gk.k[i] + sum_id[i],sz[i])) * sz_s[i-1]; + lid += (openfpm::math::positive_modulo(gk.get(i) + sum_id[i],sz[i])) * sz_s[i-1]; } } @@ -459,11 +459,11 @@ public: inline mem_id LinId(const grid_key_dx<N> & gk) const { - mem_id lid = gk.k[0]; + mem_id lid = gk.get(0); for (mem_id i = 1 ; i < N ; i++) { /* coverity[dead_error_begin */ - lid += gk.k[i] * sz_s[i-1]; + lid += gk.get(i) * sz_s[i-1]; } return lid; diff --git a/src/Grid/iterators/grid_key_dx_iterator_sub.hpp b/src/Grid/iterators/grid_key_dx_iterator_sub.hpp index c9d52c4c..660bd811 100644 --- a/src/Grid/iterators/grid_key_dx_iterator_sub.hpp +++ b/src/Grid/iterators/grid_key_dx_iterator_sub.hpp @@ -578,7 +578,7 @@ public: */ inline size_t getVolume() { - return Box<dim,long int>::getVolumeKey(gk_start.k, gk_stop.k); + return Box<dim,long int>::getVolumeKey(gk_start.get_k(), gk_stop.get_k()); } /*! \brief Reset the iterator (it restart from the beginning) diff --git a/src/NN/CellList/CellList.hpp b/src/NN/CellList/CellList.hpp index 61ba218b..be6c4609 100644 --- a/src/NN/CellList/CellList.hpp +++ b/src/NN/CellList/CellList.hpp @@ -601,6 +601,7 @@ public: static_cast<CellDecomposer_sm<dim,T,transform> &>(*this).swap(cell); n_dec = cell.n_dec; + from_cd = cell.from_cd; return *this; } @@ -622,6 +623,7 @@ public: static_cast<CellDecomposer_sm<dim,T,transform> &>(*this) = static_cast<const CellDecomposer_sm<dim,T,transform> &>(cell); n_dec = cell.n_dec; + from_cd = cell.from_cd; return *this; } @@ -913,7 +915,7 @@ public: { #ifdef SE_CLASS1 if (from_cd == false) - std::cerr << __FILE__ << ":" << __LINE__ << " Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl; + {std::cerr << __FILE__ << ":" << __LINE__ << " Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;} #endif CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,base>,SYM,impl> cln(cell,p,NNc_sym,*this,v); -- GitLab