Line data Source code
1 : //
2 : // Class NDRegion
3 : // NDRegion is a simple container of N PRegion objects. It is templated
4 : // on the type of data (T) and the number of PRegions (Dim).
5 : //
6 : #ifndef IPPL_NDREGION_H
7 : #define IPPL_NDREGION_H
8 :
9 : #include <initializer_list>
10 :
11 : #include "Region/PRegion.h"
12 :
13 : namespace ippl {
14 : template <typename T, unsigned Dim>
15 : /*!
16 : * @file NDRegion.h
17 : * @tparam T data type
18 : * @tparam Dim number of PRegions
19 : */
20 : class NDRegion {
21 : public:
22 : /*!
23 : * Create an empty NDregion
24 : */
25 : KOKKOS_FUNCTION
26 734 : NDRegion() {}
27 :
28 : KOKKOS_FUNCTION
29 226 : ~NDRegion() {}
30 :
31 : /*!
32 : * Create a NDregion from PRegions
33 : * @param ...args list of PRegions
34 : *
35 : * \remark See also (November 21, 2020)
36 : * https://stackoverflow.com/questions/16478089/converting-variadic-template-pack-into-stdinitializer-list
37 : */
38 : template <class... Args>
39 : KOKKOS_FUNCTION NDRegion(const Args&... args);
40 :
41 : KOKKOS_INLINE_FUNCTION NDRegion(const NDRegion<T, Dim>& nr);
42 :
43 : KOKKOS_INLINE_FUNCTION NDRegion<T, Dim>& operator=(const NDRegion<T, Dim>& nr);
44 :
45 : KOKKOS_INLINE_FUNCTION const PRegion<T>& operator[](unsigned d) const;
46 :
47 : KOKKOS_INLINE_FUNCTION PRegion<T>& operator[](unsigned d);
48 :
49 : KOKKOS_INLINE_FUNCTION NDRegion<T, Dim>& operator+=(const T t);
50 :
51 : KOKKOS_INLINE_FUNCTION NDRegion<T, Dim>& operator-=(const T t);
52 :
53 : KOKKOS_INLINE_FUNCTION NDRegion<T, Dim>& operator*=(const T t);
54 :
55 : KOKKOS_INLINE_FUNCTION NDRegion<T, Dim>& operator/=(const T t);
56 :
57 : KOKKOS_INLINE_FUNCTION bool empty() const;
58 :
59 : private:
60 : KOKKOS_FUNCTION
61 : NDRegion(std::initializer_list<PRegion<T>> regions);
62 :
63 : //! Array of PRegions
64 : PRegion<T> regions_m[Dim];
65 : };
66 : } // namespace ippl
67 :
68 : #include "Region/NDRegion.hpp"
69 :
70 : #endif
|