3 #include <AMReX_Config.H>
19 #include <type_traits>
23 template <
class T, std::
size_t N>
32 template <
class T,
unsigned int N>
56 const T*
data () const noexcept {
return arr; }
69 static constexpr
unsigned int size () noexcept {
return N; }
76 const T*
begin () const noexcept {
return arr; }
83 const T*
end () const noexcept {
return arr + N; }
97 T*
end () noexcept {
return arr + N; }
106 void fill (
const T& value ) noexcept
107 {
for (
unsigned int i = 0; i < N; ++i) {
arr[i] = value; } }
113 constexpr T
sum () const noexcept
116 for (
unsigned int i = 0; i < N; ++i) { s +=
arr[i]; }
127 for (
unsigned int i = 0; i < N; ++i) { p *=
arr[i]; }
134 for (
unsigned int i = 0; i < N; ++i) {
159 template <
class T,
int XLO,
int XHI>
167 static constexpr
unsigned int size () noexcept {
return (XHI-XLO+1); }
174 static constexpr
int lo () noexcept {
return XLO; }
180 static constexpr
int hi () noexcept {
return XHI; }
187 static constexpr
unsigned int len () noexcept {
return (XHI-XLO+1); }
201 const T*
end () const noexcept {
return arr + XHI-XLO+1; }
215 T*
end () noexcept {
return arr + XHI-XLO+1; }
241 constexpr T
sum () const noexcept
244 for (
int i = XLO; i <= XHI; ++i) { s +=
arr[i-XLO]; }
255 for (
int i = 0; i < (XHI-XLO+1); ++i) {
279 template <
class T,
int XLO,
int XHI,
int YLO,
int YHI,
288 static constexpr
unsigned int size() noexcept {
return (XHI-XLO+1)*(YHI-YLO+1); }
296 static constexpr
int xlo () noexcept {
return XLO; }
303 static constexpr
int xhi () noexcept {
return XHI; }
311 static constexpr
unsigned int xlen () noexcept {
return (XHI-XLO+1); }
319 static constexpr
int ylo () noexcept {
return YLO; }
326 static constexpr
int yhi () noexcept {
return YHI; }
334 static constexpr
unsigned int ylen () noexcept {
return (YHI-YLO+1); }
348 const T*
end () const noexcept {
return arr + (XHI-XLO+1)*(YHI-YLO+1); }
362 T*
end () noexcept {
return arr + (XHI-XLO+1)*(YHI-YLO+1); }
370 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::F,
int> = 0>
373 AMREX_ASSERT(i >= XLO && i <= XHI && j >= YLO && j <= YHI);
374 return arr[i+j*(XHI-XLO+1)-(YLO*(XHI-XLO+1)+XLO)];
383 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::F,
int> = 0>
386 AMREX_ASSERT(i >= XLO && i <= XHI && j >= YLO && j <= YHI);
387 return arr[i+j*(XHI-XLO+1)-(YLO*(XHI-XLO+1)+XLO)];
396 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::C,
int> = 0>
399 AMREX_ASSERT(i >= XLO && i <= XHI && j >= YLO && j <= YHI);
400 return arr[j+i*(YHI-YLO+1)-(XLO*(YHI-YLO+1)+YLO)];
409 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::C,
int> = 0>
412 AMREX_ASSERT(i >= XLO && i <= XHI && j >= YLO && j <= YHI);
413 return arr[j+i*(YHI-YLO+1)-(XLO*(YHI-YLO+1)+YLO)];
421 constexpr T
sum () const noexcept
424 for (
int i = 0; i < (XHI-XLO+1)*(YHI-YLO+1); ++i) {
455 constexpr T
sum (
int axis,
int loc)
const noexcept
460 for (
int i = XLO; i <= XHI; ++i) {
463 }
else if (axis == 1) {
465 for (
int j = YLO; j <= YHI; ++j) {
480 for (
int i = 0; i < (XHI-XLO+1)*(YHI-YLO+1); ++i) {
512 constexpr T
product (
int axis,
int loc)
const noexcept
517 for (
int i = XLO; i <= XHI; ++i) {
520 }
else if (axis == 1) {
522 for (
int j = YLO; j <= YHI; ++j) {
529 T
arr[(XHI-XLO+1)*(YHI-YLO+1)];
546 template <
class T,
int XLO,
int XHI,
int YLO,
int YHI,
int ZLO,
int ZHI,
555 static constexpr
unsigned int size () noexcept {
return (XHI-XLO+1)*(YHI-YLO+1)*(ZHI-ZLO+1); }
563 static constexpr
int xlo () noexcept {
return XLO; }
570 static constexpr
int xhi () noexcept {
return XHI; }
577 static constexpr
unsigned int xlen () noexcept {
return (XHI-XLO+1); }
585 static constexpr
int ylo () noexcept {
return YLO; }
592 static constexpr
int yhi () noexcept {
return YHI; }
600 static constexpr
unsigned int ylen () noexcept {
return (YHI-YLO+1); }
608 static constexpr
int zlo () noexcept {
return ZLO; }
615 static constexpr
int zhi () noexcept {
return ZHI; }
622 static constexpr
unsigned int zlen () noexcept {
return (ZHI-ZLO+1); }
636 const T*
end () const noexcept {
return arr + (XHI-XLO+1)*(YHI-YLO+1)*(ZHI-ZLO+1); }
650 T*
end () noexcept {
return arr + (XHI-XLO+1)*(YHI-YLO+1)*(ZHI-ZLO+1); }
658 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::F,
int> = 0>
661 return arr[i+j*(XHI-XLO+1)+k*((XHI-XLO+1)*(YHI-YLO+1))
662 -(ZLO*((XHI-XLO+1)*(YHI-YLO+1))+YLO*(XHI-XLO+1)+XLO)];
671 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::F,
int> = 0>
674 return arr[i+j*(XHI-XLO+1)+k*((XHI-XLO+1)*(YHI-YLO+1))
675 -(ZLO*((XHI-XLO+1)*(YHI-YLO+1))+YLO*(XHI-XLO+1)+XLO)];
684 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::C,
int> = 0>
687 return arr[k+j*(ZHI-ZLO+1)+i*((ZHI-ZLO+1)*(YHI-YLO+1))
688 -(XLO*((ZHI-ZLO+1)*(YHI-YLO+1))+YLO*(ZHI-ZLO+1)+ZLO)];
697 template <Order Ord=ORDER, std::enable_if_t<Ord==Order::C,
int> = 0>
700 return arr[k+j*(ZHI-ZLO+1)+i*((ZHI-ZLO+1)*(YHI-YLO+1))
701 -(XLO*((ZHI-ZLO+1)*(YHI-YLO+1))+YLO*(ZHI-ZLO+1)+ZLO)];
709 constexpr T
sum () const noexcept
712 for (
int i = 0; i < (XHI-XLO+1)*(YHI-YLO+1)*(ZHI-ZLO+1); ++i) {
749 constexpr T
sum (
int axis,
int loc0,
int loc1)
const noexcept
755 for (
int i = XLO; i <= XHI; ++i) {
758 }
else if (axis == 1) {
761 for (
int j = YLO; j <= YHI; ++j) {
764 }
else if (axis == 2) {
767 for (
int k = ZLO; k <= ZHI; ++k) {
782 for (
int i = 0; i < (XHI-XLO+1)*(YHI-YLO+1)*(ZHI-ZLO+1); ++i) {
820 constexpr T
product (
const int axis,
const int loc0,
const int loc1)
const noexcept
826 for (
int i = XLO; i <= XHI; ++i) {
829 }
else if (axis == 1) {
832 for (
int j = YLO; j <= YHI; ++j) {
835 }
else if (axis == 2) {
838 for (
int k = ZLO; k <= ZHI; ++k) {
845 T
arr[(XHI-XLO+1)*(YHI-YLO+1)*(ZHI-ZLO+1)];
851 template <
class T,
typename =
typename T::FABType>
852 std::array<T*,AMREX_SPACEDIM>
GetArrOfPtrs (std::array<T,AMREX_SPACEDIM>& a) noexcept
854 return {{
AMREX_D_DECL(a.data(), a.data()+1, a.data()+2)}};
858 std::array<T*,AMREX_SPACEDIM>
GetArrOfPtrs (
const std::array<std::unique_ptr<T>,AMREX_SPACEDIM>& a) noexcept
864 std::array<T const*,AMREX_SPACEDIM>
GetArrOfConstPtrs (
const std::array<T,AMREX_SPACEDIM>& a) noexcept
866 return {{
AMREX_D_DECL(a.data(), a.data()+1, a.data()+2)}};
870 std::array<T const*,AMREX_SPACEDIM>
GetArrOfConstPtrs (
const std::array<T*,AMREX_SPACEDIM>& a) noexcept
876 std::array<T const*,AMREX_SPACEDIM>
GetArrOfConstPtrs (
const std::array<std::unique_ptr<T>,AMREX_SPACEDIM>& a) noexcept
887 #if (AMREX_SPACEDIM == 1)
888 return XDim3{a[0], 0., 0.};
889 #elif (AMREX_SPACEDIM == 2)
890 return XDim3{a[0], a[1], 0.};
892 return XDim3{a[0], a[1], a[2]};
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
Definition: AMReX_Amr.cpp:49
std::array< T const *, AMREX_SPACEDIM > GetArrOfConstPtrs(const std::array< T, AMREX_SPACEDIM > &a) noexcept
Definition: AMReX_Array.H:864
Order
Definition: AMReX_SmallMatrix.H:19
Array< int, AMREX_SPACEDIM > IntArray
Definition: AMReX_Array.H:27
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
std::array< T *, AMREX_SPACEDIM > GetArrOfPtrs(std::array< T, AMREX_SPACEDIM > &a) noexcept
Definition: AMReX_Array.H:852
constexpr AMREX_GPU_HOST_DEVICE GpuTupleElement< I, GpuTuple< Ts... > >::type & get(GpuTuple< Ts... > &tup) noexcept
Definition: AMReX_Tuple.H:179
XDim3 makeXDim3(const Array< Real, AMREX_SPACEDIM > &a) noexcept
Definition: AMReX_Array.H:885
Array< Real, AMREX_SPACEDIM > RealArray
Definition: AMReX_Array.H:26
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_Array.H:161
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * end() noexcept
Definition: AMReX_Array.H:215
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T & operator()(int i) const noexcept
Definition: AMReX_Array.H:222
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int lo() noexcept
Definition: AMReX_Array.H:174
T arr[(XHI-XLO+1)]
Definition: AMReX_Array.H:265
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * begin() noexcept
Definition: AMReX_Array.H:208
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * begin() const noexcept
Definition: AMReX_Array.H:194
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int hi() noexcept
Definition: AMReX_Array.H:180
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T sum() const noexcept
Definition: AMReX_Array.H:241
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int len() noexcept
Definition: AMReX_Array.H:187
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int size() noexcept
Definition: AMReX_Array.H:167
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * end() const noexcept
Definition: AMReX_Array.H:201
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T product() const noexcept
Definition: AMReX_Array.H:252
Definition: AMReX_Array.H:282
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int xhi() noexcept
Definition: AMReX_Array.H:303
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * begin() const noexcept
Definition: AMReX_Array.H:341
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T sum() const noexcept
Definition: AMReX_Array.H:421
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T product() const noexcept
Definition: AMReX_Array.H:477
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * begin() noexcept
Definition: AMReX_Array.H:355
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int yhi() noexcept
Definition: AMReX_Array.H:326
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int ylen() noexcept
Definition: AMReX_Array.H:334
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int xlo() noexcept
Definition: AMReX_Array.H:296
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * end() noexcept
Definition: AMReX_Array.H:362
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int xlen() noexcept
Definition: AMReX_Array.H:311
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T sum(int axis, int loc) const noexcept
Definition: AMReX_Array.H:455
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int ylo() noexcept
Definition: AMReX_Array.H:319
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int size() noexcept
Definition: AMReX_Array.H:288
T arr[(XHI-XLO+1) *(YHI-YLO+1)]
Definition: AMReX_Array.H:529
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * end() const noexcept
Definition: AMReX_Array.H:348
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T & operator()(int i, int j) const noexcept
Definition: AMReX_Array.H:372
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T product(int axis, int loc) const noexcept
Definition: AMReX_Array.H:512
Definition: AMReX_Array.H:549
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int yhi() noexcept
Definition: AMReX_Array.H:592
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * end() noexcept
Definition: AMReX_Array.H:650
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T sum(int axis, int loc0, int loc1) const noexcept
Definition: AMReX_Array.H:749
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * begin() const noexcept
Definition: AMReX_Array.H:629
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * end() const noexcept
Definition: AMReX_Array.H:636
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int xlen() noexcept
Definition: AMReX_Array.H:577
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int zlen() noexcept
Definition: AMReX_Array.H:622
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int zhi() noexcept
Definition: AMReX_Array.H:615
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int size() noexcept
Definition: AMReX_Array.H:555
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int xhi() noexcept
Definition: AMReX_Array.H:570
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int ylen() noexcept
Definition: AMReX_Array.H:600
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T product(const int axis, const int loc0, const int loc1) const noexcept
Definition: AMReX_Array.H:820
T arr[(XHI-XLO+1) *(YHI-YLO+1) *(ZHI-ZLO+1)]
Definition: AMReX_Array.H:845
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * begin() noexcept
Definition: AMReX_Array.H:643
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T product() const noexcept
Definition: AMReX_Array.H:779
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int ylo() noexcept
Definition: AMReX_Array.H:585
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int zlo() noexcept
Definition: AMReX_Array.H:608
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T sum() const noexcept
Definition: AMReX_Array.H:709
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T & operator()(int i, int j, int k) const noexcept
Definition: AMReX_Array.H:660
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int xlo() noexcept
Definition: AMReX_Array.H:563
Definition: AMReX_Array.H:34
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T product() const noexcept
Definition: AMReX_Array.H:124
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T sum() const noexcept
Definition: AMReX_Array.H:113
T & reference_type
Definition: AMReX_Array.H:36
T value_type
Definition: AMReX_Array.H:35
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * data() const noexcept
Definition: AMReX_Array.H:56
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * data() noexcept
Definition: AMReX_Array.H:62
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE unsigned int size() noexcept
Definition: AMReX_Array.H:69
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * end() noexcept
Definition: AMReX_Array.H:97
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T & operator[](int i) const noexcept
Definition: AMReX_Array.H:43
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * begin() noexcept
Definition: AMReX_Array.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void fill(const T &value) noexcept
Definition: AMReX_Array.H:106
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * begin() const noexcept
Definition: AMReX_Array.H:76
T arr[amrex::max(N, 1U)]
Definition: AMReX_Array.H:140
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const T * end() const noexcept
Definition: AMReX_Array.H:83
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuArray< T, N > & operator+=(GpuArray< T, N > const &a) noexcept
Definition: AMReX_Array.H:132
Definition: AMReX_Dim3.H:13