IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
NDIndex.h
Go to the documentation of this file.
1//
2// Class NDIndex
3// This is a simple wrapper around Index that just keeps track of
4// N of them and passes along requests for intersect, etc.
5//
6#ifndef IPPL_NDINDEX_H
7#define IPPL_NDINDEX_H
8
9#include <initializer_list>
10
11#include "Types/Vector.h"
12
13#include "Index/Index.h"
14
15namespace ippl {
20 template <unsigned Dim>
21 class NDIndex {
22 public:
23 KOKKOS_FUNCTION
25
26 template <class... Args>
27 KOKKOS_FUNCTION NDIndex(const Args&... args);
28
29 KOKKOS_FUNCTION NDIndex(const Vector<unsigned, Dim>& sizes);
30
34 KOKKOS_INLINE_FUNCTION const ippl::Index& operator[](unsigned d) const noexcept;
35
36 KOKKOS_INLINE_FUNCTION Index& operator[](unsigned d) noexcept;
37
41 KOKKOS_INLINE_FUNCTION unsigned size() const noexcept;
42
46 KOKKOS_INLINE_FUNCTION bool empty() const noexcept;
47
51 KOKKOS_INLINE_FUNCTION NDIndex<Dim> intersect(const NDIndex<Dim>&) const;
52
56 KOKKOS_INLINE_FUNCTION NDIndex<Dim> grow(int ncells) const;
57
58 KOKKOS_INLINE_FUNCTION NDIndex<Dim> grow(int ncells, unsigned int dim) const;
59
60 KOKKOS_INLINE_FUNCTION bool touches(const NDIndex<Dim>&) const;
61
62 KOKKOS_INLINE_FUNCTION bool contains(const NDIndex<Dim>& a) const;
63
64 // Split on dimension d with at position i
65 KOKKOS_INLINE_FUNCTION bool split(NDIndex<Dim>& l, NDIndex<Dim>& r, unsigned d,
66 int i) const;
67
68 // Split on dimension d with the given ratio 0<a<1.
69 KOKKOS_INLINE_FUNCTION bool split(NDIndex<Dim>& l, NDIndex<Dim>& r, unsigned d,
70 double a) const;
71
72 // Split on dimension d, or the longest dimension.
73 KOKKOS_INLINE_FUNCTION bool split(NDIndex<Dim>& l, NDIndex<Dim>& r, unsigned d) const;
74
75 KOKKOS_INLINE_FUNCTION bool split(NDIndex<Dim>& l, NDIndex<Dim>& r) const;
76
77 KOKKOS_INLINE_FUNCTION Vector<size_t, Dim> length() const;
78 KOKKOS_INLINE_FUNCTION Vector<int, Dim> first() const;
79 KOKKOS_INLINE_FUNCTION Vector<int, Dim> last() const;
80
81 using iterator = Index*;
82 using const_iterator = const Index*;
83 KOKKOS_INLINE_FUNCTION constexpr iterator begin();
84 KOKKOS_INLINE_FUNCTION constexpr iterator end();
85 KOKKOS_INLINE_FUNCTION constexpr const_iterator begin() const;
86 KOKKOS_INLINE_FUNCTION constexpr const_iterator end() const;
87
88 private:
89 KOKKOS_FUNCTION
90 NDIndex(std::initializer_list<Index> indices);
91
94 };
95} // namespace ippl
96
97#include "Index/NDIndex.hpp"
98
99#endif
constexpr unsigned Dim
constexpr KOKKOS_INLINE_FUNCTION auto first()
Definition AbsorbingBC.h:10
STL namespace.
Definition Archive.h:20
const Index * const_iterator
Definition NDIndex.h:82
KOKKOS_INLINE_FUNCTION constexpr iterator begin()
Definition NDIndex.hpp:186
Index * iterator
Definition NDIndex.h:81
KOKKOS_INLINE_FUNCTION bool touches(const NDIndex< Dim > &) const
Definition NDIndex.hpp:95
KOKKOS_INLINE_FUNCTION bool empty() const noexcept
Definition NDIndex.hpp:52
KOKKOS_INLINE_FUNCTION Vector< int, Dim > last() const
Definition NDIndex.hpp:178
KOKKOS_INLINE_FUNCTION unsigned size() const noexcept
Definition NDIndex.hpp:43
KOKKOS_FUNCTION NDIndex()
Definition NDIndex.h:24
KOKKOS_INLINE_FUNCTION const ippl::Index & operator[](unsigned d) const noexcept
Definition NDIndex.hpp:33
KOKKOS_INLINE_FUNCTION bool split(NDIndex< Dim > &l, NDIndex< Dim > &r, unsigned d, int i) const
Definition NDIndex.hpp:113
KOKKOS_INLINE_FUNCTION NDIndex< Dim > intersect(const NDIndex< Dim > &) const
Definition NDIndex.hpp:70
Index indices_m[Dim]
Array of indices.
Definition NDIndex.h:93
KOKKOS_INLINE_FUNCTION bool contains(const NDIndex< Dim > &a) const
Definition NDIndex.hpp:104
KOKKOS_INLINE_FUNCTION Vector< size_t, Dim > length() const
Definition NDIndex.hpp:162
KOKKOS_INLINE_FUNCTION constexpr iterator end()
Definition NDIndex.hpp:191
KOKKOS_INLINE_FUNCTION NDIndex< Dim > grow(int ncells) const
Definition NDIndex.hpp:79