| 1 | /* |
| 2 | * VerletNNIterator.hpp |
| 3 | * |
| 4 | * Created on: Aug 16, 2016 |
| 5 | * Author: i-bird |
| 6 | */ |
| 7 | |
| 8 | #ifndef OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETNNITERATOR_HPP_ |
| 9 | #define OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETNNITERATOR_HPP_ |
| 10 | |
| 11 | #define VL_NON_SYMMETRIC 0 |
| 12 | #define VL_SYMMETRIC 1 |
| 13 | #define VL_CRS_SYMMETRIC 2 |
| 14 | |
| 15 | /*! \brief Iterator for the neighborhood of the cell structures |
| 16 | * |
| 17 | * In general you never create it directly but you get it from the CellList structures |
| 18 | * |
| 19 | * It iterate across all the element of the selected cell and the near cells |
| 20 | * |
| 21 | * \tparam dim dimensionality of the space where the cell live |
| 22 | * \tparam Cell cell type on which the iterator is working |
| 23 | * \tparam NNc_size neighborhood size |
| 24 | * \tparam impl implementation specific options NO_CHECK do not do check on access, SAFE do check on access |
| 25 | * |
| 26 | */ |
| 27 | template<unsigned int dim, typename Ver> class VerletNNIterator |
| 28 | { |
| 29 | //! start index for the neighborhood |
| 30 | const typename Ver::Mem_type_type::local_index_type * start; |
| 31 | |
| 32 | //! stop index for the neighborhood |
| 33 | const typename Ver::Mem_type_type::local_index_type * stop; |
| 34 | |
| 35 | //! actual neighborhood |
| 36 | const typename Ver::Mem_type_type::local_index_type * ele_id; |
| 37 | |
| 38 | //! verlet list |
| 39 | Ver & ver; |
| 40 | |
| 41 | public: |
| 42 | |
| 43 | /*! \brief |
| 44 | * |
| 45 | * Cell NN iterator |
| 46 | * |
| 47 | * \param part_id Particle id |
| 48 | * \param ver Verlet-list |
| 49 | * |
| 50 | */ |
| 51 | inline VerletNNIterator(size_t part_id, Ver & ver) |
| 52 | :start(&ver.getStart(part_id)),stop(&ver.getStop(part_id)),ver(ver) |
| 53 | {ele_id = start;} |
| 54 | |
| 55 | /*! \brief |
| 56 | * |
| 57 | * Check if there is the next element |
| 58 | * |
| 59 | * \return true if there is the next element |
| 60 | * |
| 61 | */ |
| 62 | inline bool isNext() |
| 63 | { |
| 64 | if (ele_id < stop) |
| 65 | return true; |
| 66 | return false; |
| 67 | } |
| 68 | |
| 69 | /*! \brief take the next element |
| 70 | * |
| 71 | * \return itself |
| 72 | * |
| 73 | */ |
| 74 | inline VerletNNIterator & operator++() |
| 75 | { |
| 76 | ele_id++; |
| 77 | |
| 78 | return *this; |
| 79 | } |
| 80 | |
| 81 | /*! \brief Get the value of the cell |
| 82 | * |
| 83 | * \return the next element object |
| 84 | * |
| 85 | */ |
| 86 | inline typename Ver::Mem_type_type::local_index_type get() |
| 87 | { |
| 88 | return ver.get_lin(ele_id); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | |
| 93 | #endif /* OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETNNITERATOR_HPP_ */ |
| 94 | |