4#include <AMReX_Config.H>
20#define AMREX_ARRAY4_INDEX_ASSERT(i,j,k,n) \
21 if ((i)<begin.vect[0] || (i)>=end.vect[0] || \
22 (j)<begin.vect[1] || (j)>=end.vect[1] || \
23 (k)<begin.vect[2] || (k)>=end.vect[2] || \
24 (n)<0 || (n)>=end.vect[3]) \
26 index_assert_print_error_message(i,j,k,n); \
65 : p(a_p), stride(a_stride), ncomp(a_ncomp)
77 requires (std::is_const_v<U>)
80 : p(rhs.p), stride(rhs.stride), ncomp(rhs.ncomp)
89 explicit operator bool() const noexcept {
return p !=
nullptr; }
93 int nComp() const noexcept {
return ncomp; }
107 requires (!std::is_void_v<T>)
110#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
111 if (n < 0 || n >= ncomp) {
116 std::stringstream ss;
117 ss <<
" " << n <<
" is out of bound: (0:" << ncomp-1 <<
")";
129 template <
int N>
struct Stride { Long a[N] = {}; };
130 template <>
struct Stride<0> {};
137 template <
typename T>
138 struct IsValidIndexType {
139 static constexpr bool value = std::is_integral_v<T> && IsNonNarrowingConversion_v<T, int>;
148 template <
int N,
bool last_dim_component,
typename... idx>
149 struct ArrayNDIndexCheck_impl {
151 static constexpr int num_indices =
sizeof...(idx);
153 template <
typename... Ts>
154 struct AllExceptLastEnum;
156 template <
typename first,
typename... Ts>
157 struct AllExceptLastEnum<first, Ts...> {
158 static constexpr bool value =
159 IsValidIndexType<std::decay_t<first>>::value
160 && AllExceptLastEnum<Ts...>::value;
165 template <
typename last>
166 struct AllExceptLastEnum<last> {
167 static constexpr bool value = IsValidIndexType<std::decay_t<last>>::value
168 || (std::is_enum_v<std::decay_t<last>>);
171 static constexpr bool index_with_maybe_enum = AllExceptLastEnum<idx...>::value;
173 static constexpr bool index_all_values = Conjunction<
174 IsValidIndexType<std::decay_t<idx>>...>::value;
177 static constexpr bool value = ((num_indices == N) && index_all_values)
178 || ((num_indices == N - 1) && index_all_values && last_dim_component)
179 || ((num_indices == N) && index_with_maybe_enum && last_dim_component);
182 template <
int N,
bool last_dim_component,
class... idx>
183 inline constexpr bool ArrayNDIndexCheck_impl_v = ArrayNDIndexCheck_impl<N, last_dim_component, idx...>::value;
185 template<std::size_t... idx>
186 constexpr auto make_oob_message_impl (std::index_sequence<idx...>) {
187 constexpr std::size_t N =
sizeof...(idx);
188 constexpr char prefix[] =
" (";
189 constexpr char middle[] =
") is out of bound (";
190 constexpr char suffix[] =
")\n";
192 constexpr std::size_t size =
199 std::array<char, size> buf{};
204 for (
char c : prefix) {
210 ((buf[pos++] =
'%', buf[pos++] =
'd', idx + 1 < N ? buf[pos++] =
',' : 0), ...);
213 for (
char c : middle) {
220 ((buf[pos++] =
'%', buf[pos++] =
'd', buf[pos++] =
':', buf[pos++] =
'%', buf[pos++] =
'd',
221 idx + 1 < N ? buf[pos++] =
',' : 0), ...);
224 for (
char c : suffix) {
230 template <std::size_t... idx, std::size_t... idx2x>
232 void device_print_impl2 (std::index_sequence<idx...>,
233 std::index_sequence<idx2x...>,
234 IntVectND<
sizeof...(idx)>
const& iv,
235 IntVectND<
sizeof...(idx)>
const&
begin,
236 IntVectND<
sizeof...(idx)>
const&
end)
238 constexpr auto msg = make_oob_message_impl(std::index_sequence<idx...>{});
242 ((idx2x % 2 == 0) ?
begin.vect[idx2x / 2] :
end.vect[idx2x / 2])...
249 void device_printf_impl (
const IntVectND<N>& iv,
250 const IntVectND<N>&
begin,
251 const IntVectND<N>&
end)
254 std::make_index_sequence<N>{},
255 std::make_index_sequence<N*2>{},
286 template<
typename T,
int N,
bool last_dim_component = false>
289 static_assert(N >= 1,
"ArrayND must have at least one dimension");
290 static_assert(N > 1 || !last_dim_component,
"ArrayND with N=1 cannot have last_dim_component=true");
295 static constexpr bool IsArray4_v = (N==4 && last_dim_component);
321 requires (std::is_const_v<U>)
323 constexpr ArrayND (
ArrayND<std::remove_const_t<T>, N, last_dim_component>
const& rhs) noexcept
324 :
p(rhs.p), stride(rhs.stride),
begin(rhs.begin),
end(rhs.end) {}
334 requires (!last_dim_component)
335 :
ArrayND(a_p, box.smallEnd(), box.bigEnd() + 1)
345 requires (((M+1==N) || (N == 4 && M == AMREX_SPACEDIM))
346 && last_dim_component)
350 :
ArrayND(a_p, box.smallEnd(), box.bigEnd() + 1, ncomp)
364 requires (!last_dim_component)
381 constexpr ArrayND (T* a_p,
Dim3 const& a_begin,
Dim3 const& a_end,
int a_ncomp)
noexcept
383 :
p(a_p),
begin(a_begin.
x, a_begin.
y, a_begin.
z, 0),
end(a_end.
x, a_end.
y, a_end.
z, a_ncomp)
399 requires (((M+1 == N) || (N == 4 && M == AMREX_SPACEDIM)) && last_dim_component)
404 constexpr_for<0, M>([&](
int d) {
408 constexpr_for<M, N>([&](
int d) {
426 requires (std::is_same_v<std::remove_const_t<T>, std::remove_const_t<U>>
427 && (N >= 2) && last_dim_component)
430 :
p((T*)(rhs.p + start_comp*rhs.stride.a[N-2])),
436 end.
vect[N-1] = rhs.end.vect[N-1] - start_comp;
449 requires (std::is_same_v<std::remove_const_t<T>, std::remove_const_t<U>>
450 && (N >= 2) && last_dim_component)
453 :
p((T*)(rhs.p + start_comp*rhs.stride.a[N-2])),
467 constexpr explicit operator bool() const noexcept {
return p !=
nullptr; }
493 template <
typename... idx>
495 && detail::ArrayNDIndexCheck_impl_v<N, last_dim_component, idx...>)
497 T&
operator() (idx... i)
const noexcept {
498 constexpr auto nidx =
sizeof...(i);
499#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
518 requires (!std::is_void_v<T> &&
519 ((M == N) || (!
IsArray4_v && last_dim_component && (M + 1 == N))))
522#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
540 requires (!std::is_void_v<T> && last_dim_component && !
IsArray4_v
544#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
556 template <
typename... idx>
558 && detail::ArrayNDIndexCheck_impl_v<N, last_dim_component, idx...>)
560 T*
ptr (idx... i)
const noexcept {
561 constexpr auto nidx =
sizeof...(i);
562#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
581 requires ((M == N) || (!
IsArray4_v && last_dim_component && (M + 1 == N)))
584#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
602 requires (last_dim_component && !
IsArray4_v && (M + 1 == N))
605#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
625 constexpr int nComp () const noexcept {
626 if constexpr (last_dim_component) {
642 constexpr std::size_t
size () const noexcept {
645 constexpr_for<0, N>([&](
int d) {
665 requires ((d < N) && (d >= 0))
668 if constexpr (N > 1 && d > 0) {
669 return stride.a[d-1];
686 template <
typename... idx>
688 detail::ArrayNDIndexCheck_impl_v<N, last_dim_component, idx...>)
690 constexpr bool contains (idx... i)
const noexcept {
691 constexpr auto nidx =
sizeof...(i);
712 requires ((M == N) || (!
IsArray4_v && last_dim_component && (M + 1 == N)))
716 constexpr_for<0, M>([&](
int d) {
717 inside = inside && (iv.vect[d] >=
begin.
vect[d]) && (iv.vect[d] <
end.
vect[d]);
739 requires (last_dim_component && !
IsArray4_v && (M + 1 == N))
743 constexpr_for<0, M>([&](
int d) {
744 inside = inside && (iv.vect[d] >=
begin.
vect[d]) && (iv.vect[d] <
end.
vect[d]);
746 inside = inside && (n >= 0) && (n <
end.
vect[N-1]);
783 requires ((M == N) || (last_dim_component && (M + 1 == N || M == AMREX_SPACEDIM)))
790 constexpr int idx = (last_dim_component && M == N) ? N - 1 : M;
791 if constexpr (N > 1) {
792 constexpr_for<1, idx>([&](
int d) {
799 if constexpr (last_dim_component && M == N) {
800 offset += iv.vect[N-1] * stride.a[N-2];
815 requires (last_dim_component
816 && ((M + 1 == N) || (N == 4 && M == AMREX_SPACEDIM)))
821 constexpr_for<1, M>([&](
int d) {
824 offset += n * stride.a[N-2];
828#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
829#if defined(AMREX_USE_HIP)
836 bool out_of_bounds =
false;
837 for (
int d = 0; d < N; ++d) {
839 out_of_bounds =
true;
844 detail::device_printf_impl(iv,
begin,
end);
848 std::stringstream ss;
850 for (
int d = 0; d < N; ++d) {
852 if (d + 1 < N) ss <<
",";
854 ss <<
") is out of bound (";
855 for (
int d = 0; d < N; ++d) {
857 if (d + 1 < N) ss <<
",";
868 requires (((M+1 == N) || (M == AMREX_SPACEDIM)) && last_dim_component)
869#if defined(AMREX_USE_HIP)
874 void index_assert (IntVectND<M>
const& iv)
const
876 IntVectND<N> iv_full = iv.template expand<N>(0);
877 for (
int d = M; d < N; ++d) {
880 index_assert(iv_full);
886 requires (((M+1 == N) || (M == AMREX_SPACEDIM)) && last_dim_component)
887#if defined(AMREX_USE_HIP)
892 void index_assert (IntVectND<M>
const& iv,
int n)
const
894 IntVectND<N> iv_full = iv.template expand<N>(0);
895 for (
int d = M; d < N-1; ++d) {
898 iv_full.vect[N-1] = n;
899 index_assert(iv_full);
929#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
930 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,0);
932#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
937 Long idx1 = i + j*stride.a[0] + k*stride.a[1];
965#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
966 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,n);
968#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
974 Long idx1 = i + j*stride.a[0] + k*stride.a[1] + n*stride.a[2];
992 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
995#if (AMREX_SPACEDIM == 1)
996 if constexpr (M == 1) {
999#elif (AMREX_SPACEDIM == 2)
1000 if constexpr (M == 2) {
1001 return this->
operator()(iv.vect[0],iv.vect[1],0);
1005 return this->
operator()(iv.vect[0],iv.vect[1],iv.vect[2]);
1020 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1023#if (AMREX_SPACEDIM == 1)
1024 if constexpr (M == 1) {
1027#elif (AMREX_SPACEDIM == 2)
1028 if constexpr (M == 2) {
1029 return this->
operator()(iv.vect[0],iv.vect[1],0,n);
1033 return this->
operator()(iv.vect[0],iv.vect[1],iv.vect[2],n);
1049 return this->
operator()(cell.x,cell.y,cell.z);
1064 return this->
operator()(cell.x,cell.y,cell.z,n);
1076 T*
ptr (
int i,
int j,
int k)
const noexcept
1080#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
1081 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,0);
1083#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
1088 Long idx1 = i + j*stride.a[0] + k*stride.a[1];
1092 return p + (idx1-idx0);
1106 T*
ptr (
int i,
int j,
int k,
int n)
const noexcept
1110#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
1111 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,n);
1113#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
1119 Long idx1 = i + j*stride.a[0] + k*stride.a[1] + n*stride.a[2];
1123 return p + (idx1-idx0);
1134 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1137#if (AMREX_SPACEDIM == 1)
1138 if constexpr (M == 1) {
1139 return this->
ptr(iv.vect[0],0,0);
1141#elif (AMREX_SPACEDIM == 2)
1142 if constexpr (M == 2) {
1143 return this->
ptr(iv.vect[0],iv.vect[1],0);
1147 return this->
ptr(iv.vect[0],iv.vect[1],iv.vect[2]);
1159 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1162#if (AMREX_SPACEDIM == 1)
1163 if constexpr (M == 1) {
1164 return this->
ptr(iv.vect[0],0,0,n);
1166#elif (AMREX_SPACEDIM == 2)
1167 if constexpr (M == 2) {
1168 return this->
ptr(iv.vect[0],iv.vect[1],0,n);
1172 return this->
ptr(iv.vect[0],iv.vect[1],iv.vect[2],n);
1187 return this->
ptr(cell.x,cell.y,cell.z);
1202 return this->
ptr(cell.x,cell.y,cell.z,n);
1230 requires (
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1233#if (AMREX_SPACEDIM < 3)
1234 if constexpr (M == AMREX_SPACEDIM) {
1263#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
1264#if defined(AMREX_USE_HIP)
1269 void index_assert_print_error_message (
int i,
int j,
int k,
int n)
const
1283 std::stringstream ss;
1284 ss << " (" << i << "," << j << "," << k << "," << n
1285 << ") is out of bound ("
1286 <<
begin.vect[0] << ":" <<
end.vect[0]-1 << ","
1287 <<
begin.vect[1] << ":" <<
end.vect[1]-1 << ","
1288 <<
begin.vect[2] << ":" <<
end.vect[2]-1 << ","
1289 << "0:" <<
end.vect[3]-1 << ")";
1297 constexpr void set_stride () noexcept {
1298 if constexpr (N > 1) {
1299 Long current_stride = 1;
1302 current_stride *= len;
1303 stride.a[d] = current_stride;
1312 template <
typename T,
int N>
1313 ArrayND (T*, BoxND<N>
const&) -> ArrayND<T, N, false>;
1317 template <
typename T,
int N>
1318 ArrayND (T*, BoxND<N>
const&,
int) -> ArrayND<T, N+1, true>;
1321 template <
typename T,
int N>
1322 ArrayND (T*, IntVectND<N>
const&, IntVectND<N>
const&) -> ArrayND<T, N, false>;
1325 template <
typename T,
int N>
1326 ArrayND (T*, IntVectND<N>
const&, IntVectND<N>
const&,
int) -> ArrayND<T, N+1, true>;
1329 template <
typename T>
1330 ArrayND (T*, Dim3
const&, Dim3
const&,
int) -> ArrayND<T, 4, true>;
1338 template<
typename T>
1352 return Dim3{.
x = a.begin.vect[0], .y = a.begin.vect[1], .z = a.begin.vect[2]};
1366 return Dim3{.
x = a.end.vect[0]-1, .y = a.end.vect[1]-1, .z = a.end.vect[2]-1};
1380 return Dim3{.
x = a.end.vect[0]-a.begin.vect[0],
1381 .y = a.end.vect[1]-a.begin.vect[1],
1382 .z = a.end.vect[2]-a.begin.vect[2]};
1396 template <
typename T,
int N,
bool C>
1398 os <<
"(" << a.
begin <<
',' << a.
end-1 <<
")";
1406 template <
class A>
struct HasMultiComp : std::false_type {};
1409 requires (B().size() >= 1)
1410 struct HasMultiComp<B> : std::true_type {};
1425 template <
typename T>
1434 T& operator() (
int i,
int j,
int k)
const noexcept {
1439 typename T::reference_type
1440 operator() (
int i,
int j,
int k,
int n)
const noexcept
1441 requires (amrex::HasMultiComp<T>::value)
1448 T& operator() (
int i,
int j,
int k,
int n)
const noexcept
1449 requires (!amrex::HasMultiComp<T>::value)
1458 template <
typename T>
1459 [[nodiscard]] PolymorphicArray4<T>
Runtime initialization/finalization helpers and global diagnostics.
Compile-time unrolled loop utility.
#define AMREX_NO_UNIQUE_ADDRESS
Definition AMReX_Extension.H:269
#define AMREX_NO_INLINE
Definition AMReX_Extension.H:141
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_RESTRICT
Definition AMReX_Extension.H:37
#define AMREX_DEVICE_PRINTF(...)
Definition AMReX_GpuPrint.H:21
#define AMREX_IF_ON_DEVICE(CODE)
Definition AMReX_GpuQualifiers.H:56
#define AMREX_IF_ON_HOST(CODE)
Definition AMReX_GpuQualifiers.H:58
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1129
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
A Rectangular Domain on an Integer Lattice.
Definition AMReX_Box.H:54
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:149
__host__ __device__ constexpr bool allGT(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than argument for all components. NOTE: This is NOT a strict weak ord...
Definition AMReX_IntVect.H:517
int vect[dim]
Definition AMReX_IntVect.H:885
amrex_long Long
Definition AMReX_INT.H:30
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Return the inclusive upper bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1364
__host__ __device__ Dim3 length(Array4< T > const &a) noexcept
Return the spatial extents of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1378
PolymorphicArray4< T > makePolymorphic(Array4< T > const &a)
Definition AMReX_Array4.H:1460
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Return the inclusive lower bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1350
__host__ __device__ constexpr void constexpr_for(F const &f)
Compile-time unrolled loop from I (inclusive) to N (exclusive).
Definition AMReX_ConstexprFor.H:38
Definition AMReX_Amr.cpp:50
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Stream helper; forwards to the friend declared inside AmrMesh.
Definition AMReX_AmrMesh.cpp:1306
__host__ __device__ Dim3 begin(BoxND< dim > const &box) noexcept
Return the iterator begin coordinate of box as Dim3.
Definition AMReX_Box.H:2239
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:241
__host__ __device__ Dim3 end(BoxND< dim > const &box) noexcept
Return the iterator end coordinate of box as Dim3.
Definition AMReX_Box.H:2257
A multidimensional array accessor.
Definition AMReX_Array4.H:288
__host__ __device__ T * ptr(int i, int j, int k) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1076
__host__ __device__ constexpr bool contains(IntVectND< M > const &iv, int n) const noexcept
Test whether a spatial index and component lie inside the bounds.
Definition AMReX_Array4.H:741
static constexpr bool IsArray4_v
True if this is an Array4 (N==4 and last dim is component).
Definition AMReX_Array4.H:295
__host__ __device__ ArrayND(T *a_p, BoxND< M > const &box, int ncomp) noexcept
Constructor using a BoxND and the number of components.
Definition AMReX_Array4.H:349
__host__ __device__ constexpr bool ok() const noexcept
Check if the ArrayND pointer is valid and bounds are valid.
Definition AMReX_Array4.H:475
__host__ __device__ T & operator()(idx... i) const noexcept
Multi-index operator() for accessing elements.
Definition AMReX_Array4.H:497
__host__ __device__ ArrayND(T *a_p, BoxND< N > const &box) noexcept
Constructor using a BoxND.
Definition AMReX_Array4.H:333
__host__ __device__ constexpr std::size_t size() const noexcept
Total number of elements in the ArrayND's index region.
Definition AMReX_Array4.H:642
__host__ __device__ constexpr bool contains(IntVectND< M > const &iv) const noexcept
Test whether an IntVectND lies inside the ArrayND bounds.
Definition AMReX_Array4.H:714
__host__ __device__ bool contains(IntVectND< M > const &iv) const noexcept
Test whether the spatial indices are inside the Array4 bounds.
Definition AMReX_Array4.H:1232
__host__ __device__ T * ptr(IntVectND< M > const &iv) const noexcept
Access pointer by IntVectND.
Definition AMReX_Array4.H:583
T *__restrict__ p
Definition AMReX_Array4.H:297
__host__ __device__ constexpr ArrayND(T *a_p, IntVectND< N > const &a_begin, IntVectND< N > const &a_end) noexcept
IntVectND<N> constructor.
Definition AMReX_Array4.H:363
__host__ __device__ constexpr bool contains(idx... i) const noexcept
Test whether an index tuple lies inside the ArrayND bounds.
Definition AMReX_Array4.H:690
__host__ __device__ T * ptr(Dim3 const &cell, int n) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1198
static constexpr bool IsLastDimComponent_v
True if the last dimension is treated as components.
Definition AMReX_Array4.H:293
__host__ __device__ constexpr int nComp() const noexcept
Get number of components.
Definition AMReX_Array4.H:625
__host__ __device__ constexpr T * dataPtr() const noexcept
Get raw data pointer.
Definition AMReX_Array4.H:616
__host__ __device__ T * ptr(idx... i) const noexcept
Multi-index ptr() for accessing pointer to element.
Definition AMReX_Array4.H:560
__host__ __device__ T * ptr(int i, int j, int k, int n) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1106
IntVectND< N > end
Exclusive upper bounds.
Definition AMReX_Array4.H:302
__host__ __device__ constexpr Long get_offset(IntVectND< M > const &iv, int n) const noexcept
Compute the linear offset (in elements) for an IntVectND and component index.
Definition AMReX_Array4.H:818
IntVectND< N > begin
Inclusive lower bounds.
Definition AMReX_Array4.H:301
__host__ __device__ CellData< T > cellData(int i, int j, int k) const noexcept
Create a single-cell component accessor.
Definition AMReX_Array4.H:767
__host__ __device__ T * ptr(IntVectND< M > const &iv, int n) const noexcept
Access pointer by spatial IntVectND and component index.
Definition AMReX_Array4.H:604
__host__ __device__ T * ptr(IntVectND< M > const &iv) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1136
__host__ __device__ constexpr ArrayND(ArrayND< U, N, last_dim_component > const &rhs, int start_comp, int num_comp) noexcept
Slicing constructor (Component subset with count).
Definition AMReX_Array4.H:452
__host__ __device__ constexpr Long get_offset(IntVectND< M > const &iv) const noexcept
Compute the linear offset (in elements) for an IntVectND.
Definition AMReX_Array4.H:785
__host__ __device__ T * ptr(Dim3 const &cell) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1183
__host__ __device__ constexpr Long get_stride() const noexcept
Return the stride (in elements) for dimension d.
Definition AMReX_Array4.H:667
__host__ __device__ constexpr ArrayND() noexcept
Default-construct an empty accessor.
Definition AMReX_Array4.H:310
__host__ __device__ constexpr ArrayND(ArrayND< U, N, last_dim_component > const &rhs, int start_comp) noexcept
Slicing constructor (Component subset).
Definition AMReX_Array4.H:429
__host__ __device__ constexpr ArrayND(T *a_p, Dim3 const &a_begin, Dim3 const &a_end, int a_ncomp) noexcept
Constructor for N=4 using Dim3.
Definition AMReX_Array4.H:381
__host__ __device__ T * ptr(IntVectND< M > const &iv, int n) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1161
__host__ __device__ bool contains(Dim3 const &cell) const noexcept
Test whether the spatial indices are inside the Array4 bounds.
Definition AMReX_Array4.H:1254
__host__ __device__ bool contains(int i, int j, int k) const noexcept
Test whether the spatial indices are inside the Array4 bounds.
Definition AMReX_Array4.H:1214
__host__ __device__ constexpr ArrayND(T *a_p, IntVectND< M > const &a_begin, IntVectND< M > const &a_end, int ncomp) noexcept
Reduced dimension constructor with component count.
Definition AMReX_Array4.H:401
Lightweight accessor for data associated with a single cell.
Definition AMReX_Array4.H:47
__host__ __device__ constexpr CellData(T *a_p, Long a_stride, int a_ncomp)
Construct a CellData.
Definition AMReX_Array4.H:64
__host__ __device__ T & operator[](int n) const
Access the n-th component of the cell.
Definition AMReX_Array4.H:106
__host__ __device__ int nComp() const noexcept
Return the number of components referenced by this accessor.
Definition AMReX_Array4.H:93
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
Array4 subclass that provides uniform (i,j,k,n) access for both AoS and SoA data.
Definition AMReX_Array4.H:1428
__host__ __device__ PolymorphicArray4(Array4< T > const &a)
Definition AMReX_Array4.H:1430