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) {
117 std::stringstream ss;
118 ss <<
" " << n <<
" is out of bound: (0:" << ncomp-1 <<
")";
130 template <
int N>
struct Stride { Long a[N] = {}; };
131 template <>
struct Stride<0> {};
138 template <
typename T>
139 struct IsValidIndexType {
140 static constexpr bool value = std::is_integral_v<T> && IsNonNarrowingConversion_v<T, int>;
149 template <
int N,
bool last_dim_component,
typename... idx>
150 struct ArrayNDIndexCheck_impl {
152 static constexpr int num_indices =
sizeof...(idx);
154 template <
typename... Ts>
155 struct AllExceptLastEnum;
157 template <
typename first,
typename... Ts>
158 struct AllExceptLastEnum<first, Ts...> {
159 static constexpr bool value =
160 IsValidIndexType<std::decay_t<first>>::value
161 && AllExceptLastEnum<Ts...>::value;
166 template <
typename last>
167 struct AllExceptLastEnum<last> {
168 static constexpr bool value = IsValidIndexType<std::decay_t<last>>::value
169 || (std::is_enum_v<std::decay_t<last>>);
172 static constexpr bool index_with_maybe_enum = AllExceptLastEnum<idx...>::value;
174 static constexpr bool index_all_values = Conjunction<
175 IsValidIndexType<std::decay_t<idx>>...>::value;
178 static constexpr bool value = ((num_indices == N) && index_all_values)
179 || ((num_indices == N - 1) && index_all_values && last_dim_component)
180 || ((num_indices == N) && index_with_maybe_enum && last_dim_component);
183 template <
int N,
bool last_dim_component,
class... idx>
184 inline constexpr bool ArrayNDIndexCheck_impl_v = ArrayNDIndexCheck_impl<N, last_dim_component, idx...>::value;
186 template<std::size_t... idx>
187 constexpr auto make_oob_message_impl (std::index_sequence<idx...>) {
188 constexpr std::size_t N =
sizeof...(idx);
189 constexpr char prefix[] =
" (";
190 constexpr char middle[] =
") is out of bound (";
191 constexpr char suffix[] =
")\n";
193 constexpr std::size_t size =
200 std::array<char, size> buf{};
205 for (
char c : prefix) {
211 ((buf[pos++] =
'%', buf[pos++] =
'd', idx + 1 < N ? buf[pos++] =
',' : 0), ...);
214 for (
char c : middle) {
221 ((buf[pos++] =
'%', buf[pos++] =
'd', buf[pos++] =
':', buf[pos++] =
'%', buf[pos++] =
'd',
222 idx + 1 < N ? buf[pos++] =
',' : 0), ...);
225 for (
char c : suffix) {
231 template <std::size_t... idx, std::size_t... idx2x>
233 void device_print_impl2 (std::index_sequence<idx...>,
234 std::index_sequence<idx2x...>,
235 IntVectND<
sizeof...(idx)>
const& iv,
236 IntVectND<
sizeof...(idx)>
const&
begin,
237 IntVectND<
sizeof...(idx)>
const&
end)
239 constexpr auto msg = make_oob_message_impl(std::index_sequence<idx...>{});
243 ((idx2x % 2 == 0) ?
begin.vect[idx2x / 2] :
end.vect[idx2x / 2] - 1)...
250 void device_printf_impl (
const IntVectND<N>& iv,
251 const IntVectND<N>&
begin,
252 const IntVectND<N>&
end)
255 std::make_index_sequence<N>{},
256 std::make_index_sequence<N*2>{},
287 template<
typename T,
int N,
bool last_dim_component = false>
290 static_assert(N >= 1,
"ArrayND must have at least one dimension");
291 static_assert(N > 1 || !last_dim_component,
"ArrayND with N=1 cannot have last_dim_component=true");
296 static constexpr bool IsArray4_v = (N==4 && last_dim_component);
322 requires (std::is_const_v<U>)
324 constexpr ArrayND (
ArrayND<std::remove_const_t<T>, N, last_dim_component>
const& rhs) noexcept
325 :
p(rhs.p), stride(rhs.stride),
begin(rhs.begin),
end(rhs.end) {}
335 requires (!last_dim_component)
336 :
ArrayND(a_p, box.smallEnd(), box.bigEnd() + 1)
346 requires (((M+1==N) || (N == 4 && M == AMREX_SPACEDIM))
347 && last_dim_component)
351 :
ArrayND(a_p, box.smallEnd(), box.bigEnd() + 1, ncomp)
365 requires (!last_dim_component)
382 constexpr ArrayND (T* a_p,
Dim3 const& a_begin,
Dim3 const& a_end,
int a_ncomp)
noexcept
384 :
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)
400 requires (((M+1 == N) || (N == 4 && M == AMREX_SPACEDIM)) && last_dim_component)
405 constexpr_for<0, M>([&](
int d) {
409 constexpr_for<M, N>([&](
int d) {
427 requires (std::is_same_v<std::remove_const_t<T>, std::remove_const_t<U>>
428 && (N >= 2) && last_dim_component)
431 :
p((T*)(rhs.p + start_comp*rhs.stride.a[N-2])),
437 end.
vect[N-1] = rhs.end.vect[N-1] - start_comp;
450 requires (std::is_same_v<std::remove_const_t<T>, std::remove_const_t<U>>
451 && (N >= 2) && last_dim_component)
454 :
p((T*)(rhs.p + start_comp*rhs.stride.a[N-2])),
468 constexpr explicit operator bool() const noexcept {
return p !=
nullptr; }
494 template <
typename... idx>
496 && detail::ArrayNDIndexCheck_impl_v<N, last_dim_component, idx...>)
498 T&
operator() (idx... i)
const noexcept {
499 constexpr auto nidx =
sizeof...(i);
500#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
519 requires (!std::is_void_v<T> &&
520 ((M == N) || (!
IsArray4_v && last_dim_component && (M + 1 == N))))
523#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
541 requires (!std::is_void_v<T> && last_dim_component && !
IsArray4_v
545#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
557 template <
typename... idx>
559 && detail::ArrayNDIndexCheck_impl_v<N, last_dim_component, idx...>)
561 T*
ptr (idx... i)
const noexcept {
562 constexpr auto nidx =
sizeof...(i);
563#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
582 requires ((M == N) || (!
IsArray4_v && last_dim_component && (M + 1 == N)))
585#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
603 requires (last_dim_component && !
IsArray4_v && (M + 1 == N))
606#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
626 constexpr int nComp () const noexcept {
627 if constexpr (last_dim_component) {
643 constexpr std::size_t
size () const noexcept {
646 constexpr_for<0, N>([&](
int d) {
666 requires ((d < N) && (d >= 0))
669 if constexpr (N > 1 && d > 0) {
670 return stride.a[d-1];
687 template <
typename... idx>
689 detail::ArrayNDIndexCheck_impl_v<N, last_dim_component, idx...>)
691 constexpr bool contains (idx... i)
const noexcept {
692 constexpr auto nidx =
sizeof...(i);
713 requires ((M == N) || (!
IsArray4_v && last_dim_component && (M + 1 == N)))
717 constexpr_for<0, M>([&](
int d) {
718 inside = inside && (iv.vect[d] >=
begin.
vect[d]) && (iv.vect[d] <
end.
vect[d]);
740 requires (last_dim_component && !
IsArray4_v && (M + 1 == N))
744 constexpr_for<0, M>([&](
int d) {
745 inside = inside && (iv.vect[d] >=
begin.
vect[d]) && (iv.vect[d] <
end.
vect[d]);
747 inside = inside && (n >= 0) && (n <
end.
vect[N-1]);
784 requires ((M == N) || (last_dim_component && (M + 1 == N || M == AMREX_SPACEDIM)))
791 constexpr int idx = (last_dim_component && M == N) ? N - 1 : M;
792 if constexpr (N > 1) {
793 constexpr_for<1, idx>([&](
int d) {
800 if constexpr (last_dim_component && M == N) {
801 offset += iv.vect[N-1] * stride.a[N-2];
816 requires (last_dim_component
817 && ((M + 1 == N) || (N == 4 && M == AMREX_SPACEDIM)))
822 constexpr_for<1, M>([&](
int d) {
825 offset += n * stride.a[N-2];
829#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
830#if defined(AMREX_USE_HIP)
837 bool out_of_bounds =
false;
838 for (
int d = 0; d < N; ++d) {
840 out_of_bounds =
true;
845 detail::device_printf_impl(iv,
begin,
end);
849 std::stringstream ss;
851 for (
int d = 0; d < N; ++d) {
853 if (d + 1 < N) ss <<
",";
855 ss <<
") is out of bound (";
856 for (
int d = 0; d < N; ++d) {
858 if (d + 1 < N) ss <<
",";
869 requires (((M+1 == N) || (M == AMREX_SPACEDIM)) && last_dim_component)
870#if defined(AMREX_USE_HIP)
875 void index_assert (IntVectND<M>
const& iv)
const
877 IntVectND<N> iv_full = iv.template expand<N>(0);
878 for (
int d = M; d < N; ++d) {
881 index_assert(iv_full);
887 requires (((M+1 == N) || (M == AMREX_SPACEDIM)) && last_dim_component)
888#if defined(AMREX_USE_HIP)
893 void index_assert (IntVectND<M>
const& iv,
int n)
const
895 IntVectND<N> iv_full = iv.template expand<N>(0);
896 for (
int d = M; d < N-1; ++d) {
899 iv_full.vect[N-1] = n;
900 index_assert(iv_full);
930#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
931 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,0);
933#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
938 Long idx1 = i + j*stride.a[0] + k*stride.a[1];
966#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
967 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,n);
969#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
975 Long idx1 = i + j*stride.a[0] + k*stride.a[1] + n*stride.a[2];
993 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
996#if (AMREX_SPACEDIM == 1)
997 if constexpr (M == 1) {
1000#elif (AMREX_SPACEDIM == 2)
1001 if constexpr (M == 2) {
1002 return this->
operator()(iv.vect[0],iv.vect[1],0);
1006 return this->
operator()(iv.vect[0],iv.vect[1],iv.vect[2]);
1021 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1024#if (AMREX_SPACEDIM == 1)
1025 if constexpr (M == 1) {
1028#elif (AMREX_SPACEDIM == 2)
1029 if constexpr (M == 2) {
1030 return this->
operator()(iv.vect[0],iv.vect[1],0,n);
1034 return this->
operator()(iv.vect[0],iv.vect[1],iv.vect[2],n);
1050 return this->
operator()(cell.x,cell.y,cell.z);
1065 return this->
operator()(cell.x,cell.y,cell.z,n);
1077 T*
ptr (
int i,
int j,
int k)
const noexcept
1081#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
1082 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,0);
1084#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
1089 Long idx1 = i + j*stride.a[0] + k*stride.a[1];
1093 return p + (idx1-idx0);
1107 T*
ptr (
int i,
int j,
int k,
int n)
const noexcept
1111#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
1112 AMREX_ARRAY4_INDEX_ASSERT(i,j,k,n);
1114#if defined(AMREX_USE_GPU) || defined(AMREX_DEBUG)
1120 Long idx1 = i + j*stride.a[0] + k*stride.a[1] + n*stride.a[2];
1124 return p + (idx1-idx0);
1135 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1138#if (AMREX_SPACEDIM == 1)
1139 if constexpr (M == 1) {
1140 return this->
ptr(iv.vect[0],0,0);
1142#elif (AMREX_SPACEDIM == 2)
1143 if constexpr (M == 2) {
1144 return this->
ptr(iv.vect[0],iv.vect[1],0);
1148 return this->
ptr(iv.vect[0],iv.vect[1],iv.vect[2]);
1160 requires (!std::is_void_v<T> &&
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1163#if (AMREX_SPACEDIM == 1)
1164 if constexpr (M == 1) {
1165 return this->
ptr(iv.vect[0],0,0,n);
1167#elif (AMREX_SPACEDIM == 2)
1168 if constexpr (M == 2) {
1169 return this->
ptr(iv.vect[0],iv.vect[1],0,n);
1173 return this->
ptr(iv.vect[0],iv.vect[1],iv.vect[2],n);
1188 return this->
ptr(cell.x,cell.y,cell.z);
1203 return this->
ptr(cell.x,cell.y,cell.z,n);
1231 requires (
IsArray4_v && (M == 3 || M == AMREX_SPACEDIM))
1234#if (AMREX_SPACEDIM < 3)
1235 if constexpr (M == AMREX_SPACEDIM) {
1264#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
1265#if defined(AMREX_USE_HIP)
1270 void index_assert_print_error_message (
int i,
int j,
int k,
int n)
const
1284 std::stringstream ss;
1285 ss << " (" << i << "," << j << "," << k << "," << n
1286 << ") is out of bound ("
1287 <<
begin.vect[0] << ":" <<
end.vect[0]-1 << ","
1288 <<
begin.vect[1] << ":" <<
end.vect[1]-1 << ","
1289 <<
begin.vect[2] << ":" <<
end.vect[2]-1 << ","
1290 << "0:" <<
end.vect[3]-1 << ")";
1298 constexpr void set_stride () noexcept {
1299 if constexpr (N > 1) {
1300 Long current_stride = 1;
1303 current_stride *= len;
1304 stride.a[d] = current_stride;
1313 template <
typename T,
int N>
1314 ArrayND (T*, BoxND<N>
const&) -> ArrayND<T, N, false>;
1318 template <
typename T,
int N>
1319 ArrayND (T*, BoxND<N>
const&,
int) -> ArrayND<T, N+1, true>;
1322 template <
typename T,
int N>
1323 ArrayND (T*, IntVectND<N>
const&, IntVectND<N>
const&) -> ArrayND<T, N, false>;
1326 template <
typename T,
int N>
1327 ArrayND (T*, IntVectND<N>
const&, IntVectND<N>
const&,
int) -> ArrayND<T, N+1, true>;
1330 template <
typename T>
1331 ArrayND (T*, Dim3
const&, Dim3
const&,
int) -> ArrayND<T, 4, true>;
1339 template<
typename T>
1353 return Dim3{.
x = a.begin.vect[0], .y = a.begin.vect[1], .z = a.begin.vect[2]};
1367 return Dim3{.
x = a.end.vect[0]-1, .y = a.end.vect[1]-1, .z = a.end.vect[2]-1};
1381 return Dim3{.
x = a.end.vect[0]-a.begin.vect[0],
1382 .y = a.end.vect[1]-a.begin.vect[1],
1383 .z = a.end.vect[2]-a.begin.vect[2]};
1397 template <
typename T,
int N,
bool C>
1399 os <<
"(" << a.
begin <<
',' << a.
end-1 <<
")";
1407 template <
class A>
struct HasMultiComp : std::false_type {};
1410 requires (B().size() >= 1)
1411 struct HasMultiComp<B> : std::true_type {};
1426 template <
typename T>
1435 T& operator() (
int i,
int j,
int k)
const noexcept {
1440 typename T::reference_type
1441 operator() (
int i,
int j,
int k,
int n)
const noexcept
1442 requires (amrex::HasMultiComp<T>::value)
1449 T& operator() (
int i,
int j,
int k,
int n)
const noexcept
1450 requires (!amrex::HasMultiComp<T>::value)
1459 template <
typename T>
1460 [[nodiscard]] PolymorphicArray4<T>
Runtime initialization/finalization helpers and global diagnostics.
Compile-time unrolled loop utility.
#define AMREX_NO_UNIQUE_ADDRESS
Definition AMReX_Extension.H:307
#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:15
#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:1131
#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:1365
__host__ __device__ Dim3 length(Array4< T > const &a) noexcept
Return the spatial extents of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1379
PolymorphicArray4< T > makePolymorphic(Array4< T > const &a)
Definition AMReX_Array4.H:1461
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Return the inclusive lower bounds of an Array4 in Dim3 form.
Definition AMReX_Array4.H:1351
__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:1372
__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:242
__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:289
__host__ __device__ T * ptr(int i, int j, int k) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1077
__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:742
static constexpr bool IsArray4_v
True if this is an Array4 (N==4 and last dim is component).
Definition AMReX_Array4.H:296
__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:350
__host__ __device__ constexpr bool ok() const noexcept
Check if the ArrayND pointer is valid and bounds are valid.
Definition AMReX_Array4.H:476
__host__ __device__ T & operator()(idx... i) const noexcept
Multi-index operator() for accessing elements.
Definition AMReX_Array4.H:498
__host__ __device__ ArrayND(T *a_p, BoxND< N > const &box) noexcept
Constructor using a BoxND.
Definition AMReX_Array4.H:334
__host__ __device__ constexpr std::size_t size() const noexcept
Total number of elements in the ArrayND's index region.
Definition AMReX_Array4.H:643
__host__ __device__ constexpr bool contains(IntVectND< M > const &iv) const noexcept
Test whether an IntVectND lies inside the ArrayND bounds.
Definition AMReX_Array4.H:715
__host__ __device__ bool contains(IntVectND< M > const &iv) const noexcept
Test whether the spatial indices are inside the Array4 bounds.
Definition AMReX_Array4.H:1233
__host__ __device__ T * ptr(IntVectND< M > const &iv) const noexcept
Access pointer by IntVectND.
Definition AMReX_Array4.H:584
T *__restrict__ p
Definition AMReX_Array4.H:298
__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:364
__host__ __device__ constexpr bool contains(idx... i) const noexcept
Test whether an index tuple lies inside the ArrayND bounds.
Definition AMReX_Array4.H:691
__host__ __device__ T * ptr(Dim3 const &cell, int n) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1199
static constexpr bool IsLastDimComponent_v
True if the last dimension is treated as components.
Definition AMReX_Array4.H:294
__host__ __device__ constexpr int nComp() const noexcept
Get number of components.
Definition AMReX_Array4.H:626
__host__ __device__ constexpr T * dataPtr() const noexcept
Get raw data pointer.
Definition AMReX_Array4.H:617
__host__ __device__ T * ptr(idx... i) const noexcept
Multi-index ptr() for accessing pointer to element.
Definition AMReX_Array4.H:561
__host__ __device__ T * ptr(int i, int j, int k, int n) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1107
IntVectND< N > end
Exclusive upper bounds.
Definition AMReX_Array4.H:303
__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:819
IntVectND< N > begin
Inclusive lower bounds.
Definition AMReX_Array4.H:302
__host__ __device__ CellData< T > cellData(int i, int j, int k) const noexcept
Create a single-cell component accessor.
Definition AMReX_Array4.H:768
__host__ __device__ T * ptr(IntVectND< M > const &iv, int n) const noexcept
Access pointer by spatial IntVectND and component index.
Definition AMReX_Array4.H:605
__host__ __device__ T * ptr(IntVectND< M > const &iv) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1137
__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:453
__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:786
__host__ __device__ T * ptr(Dim3 const &cell) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1184
__host__ __device__ constexpr Long get_stride() const noexcept
Return the stride (in elements) for dimension d.
Definition AMReX_Array4.H:668
__host__ __device__ constexpr ArrayND() noexcept
Default-construct an empty accessor.
Definition AMReX_Array4.H:311
__host__ __device__ constexpr ArrayND(ArrayND< U, N, last_dim_component > const &rhs, int start_comp) noexcept
Slicing constructor (Component subset).
Definition AMReX_Array4.H:430
__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:382
__host__ __device__ T * ptr(IntVectND< M > const &iv, int n) const noexcept
Return the pointer to an element.
Definition AMReX_Array4.H:1162
__host__ __device__ bool contains(Dim3 const &cell) const noexcept
Test whether the spatial indices are inside the Array4 bounds.
Definition AMReX_Array4.H:1255
__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:1215
__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:402
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:1429
__host__ __device__ PolymorphicArray4(Array4< T > const &a)
Definition AMReX_Array4.H:1431