![]() |
Block-Structured AMR Software Framework
|
A multidimensional array accessor. More...
#include <AMReX_Array4.H>
Public Member Functions | |
| __host__ __device__ constexpr | ArrayND () noexcept |
| Default-construct an empty accessor. | |
| template<class U = T, std::enable_if_t< std::is_const_v< U >, int > = 0> | |
| __host__ __device__ constexpr | ArrayND (ArrayND< std::remove_const_t< T >, N, last_dim_component > const &rhs) noexcept |
| Construct a const accessor from a non-const accessor. | |
| template<bool C = last_dim_component, std::enable_if_t<!C, int > = 0> | |
| __host__ __device__ | ArrayND (T *a_p, BoxND< N > const &box) noexcept |
| Constructor using a BoxND. | |
| template<int M, std::enable_if_t<((M+1==N)||(N==4 &&M==3)) &&last_dim_component, int > = 0> | |
| __host__ __device__ | ArrayND (T *a_p, BoxND< M > const &box, int ncomp) noexcept |
| Constructor using a BoxND and the number of components. | |
| template<bool C = last_dim_component, std::enable_if_t<!C, int > = 0> | |
| __host__ __device__ constexpr | ArrayND (T *a_p, IntVectND< N > const &a_begin, IntVectND< N > const &a_end) noexcept |
| IntVectND<N> constructor. | |
| template<bool B = IsArray4_v, std::enable_if_t< B, int > = 0> | |
| __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. | |
| template<int M, std::enable_if_t<((M+1==N)||(N==4 &&M==3)) &&last_dim_component, int > = 0> | |
| __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. | |
| template<class U , std::enable_if_t< std::is_same_v< std::remove_const_t< T >, std::remove_const_t< U > > &&(N >=2) &&last_dim_component, int > = 0> | |
| __host__ __device__ constexpr | ArrayND (ArrayND< U, N, last_dim_component > const &rhs, int start_comp) noexcept |
| Slicing constructor (Component subset). | |
| template<class U , std::enable_if_t< std::is_same_v< std::remove_const_t< T >, std::remove_const_t< U > > &&(N >=2) &&last_dim_component, int > = 0> | |
| __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). | |
| __host__ __device__ constexpr | operator bool () const noexcept |
| Check if the ArrayND pointer is valid. | |
| __host__ __device__ constexpr bool | ok () const noexcept |
| Check if the ArrayND pointer is valid and bounds are valid. | |
| template<typename... idx, class U = T, std::enable_if_t<!std::is_void_v< U > &&!IsArray4_v &&detail::ArrayNDIndexCheck_impl_v< N, last_dim_component, idx... >, int > = 0> | |
| __host__ __device__ U & | operator() (idx... i) const noexcept |
| Multi-index operator() for accessing elements. | |
| template<int M, class U = T, std::enable_if_t< !std::is_void_v< U > &&((M==N)||(!IsArray4_v &&last_dim_component &&(M+1==N))), int > = 0> | |
| __host__ __device__ U & | operator() (IntVectND< M > const &iv) const noexcept |
| Access element by IntVectND. | |
| template<int M, class U = T, std::enable_if_t< !std::is_void_v< U > &&last_dim_component &&!IsArray4_v &&(M+1==N), int > = 0> | |
| __host__ __device__ U & | operator() (IntVectND< M > const &iv, int n) const noexcept |
| Access element by spatial IntVectND and component index. | |
| template<typename... idx, class U = T, std::enable_if_t<!std::is_void_v< U > &&!IsArray4_v &&detail::ArrayNDIndexCheck_impl_v< N, last_dim_component, idx... >, int > = 0> | |
| __host__ __device__ T * | ptr (idx... i) const noexcept |
| Multi-index ptr() for accessing pointer to element. | |
| template<int M, std::enable_if_t<(M==N)||(!IsArray4_v &&last_dim_component &&(M+1==N)), int > = 0> | |
| __host__ __device__ T * | ptr (IntVectND< M > const &iv) const noexcept |
| Access pointer by IntVectND. | |
| template<int M, std::enable_if_t< last_dim_component &&!IsArray4_v &&(M+1==N), int > = 0> | |
| __host__ __device__ T * | ptr (IntVectND< M > const &iv, int n) const noexcept |
| Access pointer by spatial IntVectND and component index. | |
| __host__ __device__ constexpr T * | dataPtr () const noexcept |
| Get raw data pointer. | |
| __host__ __device__ constexpr int | nComp () const noexcept |
| Get number of components. | |
| __host__ __device__ constexpr std::size_t | size () const noexcept |
| Total number of elements in the ArrayND's index region. | |
| template<int d, std::enable_if_t<(d< N) &&(d >=0), int > = 0> | |
| __host__ __device__ constexpr Long | get_stride () const noexcept |
Return the stride (in elements) for dimension d. | |
| template<typename... idx, std::enable_if_t<!IsArray4_v &&detail::ArrayNDIndexCheck_impl_v< N, last_dim_component, idx... >, int > = 0> | |
| __host__ __device__ constexpr bool | contains (idx... i) const noexcept |
| Test whether an index tuple lies inside the ArrayND bounds. | |
| template<int M, std::enable_if_t<(M==N)||(!IsArray4_v &&last_dim_component &&(M+1==N)), int > = 0> | |
| __host__ __device__ constexpr bool | contains (IntVectND< M > const &iv) const noexcept |
| Test whether an IntVectND lies inside the ArrayND bounds. | |
| template<int M, std::enable_if_t< last_dim_component &&!IsArray4_v &&(M+1==N), int > = 0> | |
| __host__ __device__ constexpr bool | contains (IntVectND< M > const &iv, int n) const noexcept |
| Test whether a spatial index and component lie inside the bounds. | |
| template<int M = N, bool B = IsArray4_v, std::enable_if_t< B, int > = 0> | |
| __host__ __device__ CellData< T > | cellData (int i, int j, int k) const noexcept |
| Create a single-cell component accessor. | |
| template<int M, std::enable_if_t<(M==N)||(last_dim_component &&(M+1==N||M==3)), int > = 0> | |
| __host__ __device__ constexpr Long | get_offset (IntVectND< M > const &iv) const noexcept |
| Compute the linear offset (in elements) for an IntVectND. | |
| template<int M, std::enable_if_t< last_dim_component &&((M+1==N)||(N==4 &&M==3)), int > = 0> | |
| __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. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U & | operator() (int i, int j, int k) const noexcept |
| Access Array4 element using three integer spatial indices. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U & | operator() (int i, int j, int k, int n) const noexcept |
| Access Array4 element using three integer spatial indices and component index. | |
| template<int M, class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v &&(M==3||M==3), int > = 0> | |
| __host__ __device__ U & | operator() (IntVectND< M > const &iv) const noexcept |
| Access Array4 element by spatial indices in IntVectND. | |
| template<int M, class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v &&(M==3||M==3), int > = 0> | |
| __host__ __device__ U & | operator() (IntVectND< M > const &iv, int n) const noexcept |
| Access Array4 element by spatial indices in IntVectND and component index. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U & | operator() (Dim3 const &cell) const noexcept |
Access Array4 element by spatial indices in Dim3. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U & | operator() (Dim3 const &cell, int n) const noexcept |
Access Array4 element by spatial indices in Dim3 and component index. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U * | ptr (int i, int j, int k) const noexcept |
| Return the pointer to an element. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U * | ptr (int i, int j, int k, int n) const noexcept |
| Return the pointer to an element. | |
| template<int M, class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v &&(M==3||M==3), int > = 0> | |
| __host__ __device__ U * | ptr (IntVectND< M > const &iv) const noexcept |
| Return the pointer to an element. | |
| template<int M, class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v &&(M==3||M==3), int > = 0> | |
| __host__ __device__ U * | ptr (IntVectND< M > const &iv, int n) const noexcept |
| Return the pointer to an element. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U * | ptr (Dim3 const &cell) const noexcept |
| Return the pointer to an element. | |
| template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0> | |
| __host__ __device__ U * | ptr (Dim3 const &cell, int n) const noexcept |
| Return the pointer to an element. | |
| template<bool B = IsArray4_v, std::enable_if_t< B, int > = 0> | |
| __host__ __device__ bool | contains (int i, int j, int k) const noexcept |
| Test whether the spatial indices are inside the Array4 bounds. | |
| template<int M, std::enable_if_t< IsArray4_v &&(M==3||M==3), int > = 0> | |
| __host__ __device__ bool | contains (IntVectND< M > const &iv) const noexcept |
| Test whether the spatial indices are inside the Array4 bounds. | |
| template<bool B = IsArray4_v, std::enable_if_t< B, int > = 0> | |
| __host__ __device__ bool | contains (Dim3 const &cell) const noexcept |
| Test whether the spatial indices are inside the Array4 bounds. | |
Public Attributes | |
| T *__restrict__ | p = nullptr |
| IntVectND< N > | begin {1} |
| Inclusive lower bounds. | |
| IntVectND< N > | end {0} |
| Exclusive upper bounds. | |
Static Public Attributes | |
| static constexpr bool | IsLastDimComponent_v = last_dim_component |
| True if the last dimension is treated as components. | |
| static constexpr bool | IsArray4_v = (N==4 && last_dim_component) |
True if this is an Array4 (N==4 and last dim is component). | |
A multidimensional array accessor.
| T | The type of data (e.g., Real, int). May be const-qualified. |
| N | The dimension of the array (rank). |
| last_dim_component | If true, the last dimension represents components rather than a spatial index. In this case, the component index always starts at zero. |
ArrayND is a lightweight, non-owning wrapper around a pointer that provides multidimensional indexing into a contiguous memory block. It is trivially copyable and designed to be passed by value into GPU kernels. Note, ArrayND follows fortran-style column-major ordering.
It stores the pointer, stride information, and the bounds (begin and end) of the array.
Array4 is an alias of ArrayND with N=4 and last_dim_component=true. It represents three spatial dimensions plus one component dimension. When AMREX_SPACEDIM is less than 3, the extra spatial dimensions typically have bounds [0,1), and the correspding indices are zero.
|
inlineconstexprnoexcept |
Default-construct an empty accessor.
The resulting accessor is invalid (operator bool() returns false).
|
inlineconstexprnoexcept |
Construct a const accessor from a non-const accessor.
This enables implicit conversion from ArrayND<T,...> to ArrayND<const T,...>.
| rhs | Source accessor. |
|
inlinenoexcept |
Constructor using a BoxND.
| a_p | Pointer to data. |
| box | The domain covered by this array. |
|
inlinenoexcept |
Constructor using a BoxND and the number of components.
| a_p | Pointer to data. |
| box | BoxND<M> with M <= N-1 defining the spatial dimensions. |
| ncomp | Number of components (size of last dimension). |
|
inlineconstexprnoexcept |
IntVectND<N> constructor.
This constructor specifies begin and end indices using IntVectND<N> for all N dimensions.
| a_p | Pointer to data. |
| a_begin | Start index (inclusive). |
| a_end | End index (exclusive). |
|
inlineconstexprnoexcept |
Constructor for N=4 using Dim3.
Typically used for standard (i, j, k, n) access in 3D simulations.
| a_p | Pointer to data. |
| a_begin | Start index. |
| a_end | End index exclusive. |
| a_ncomp | Number of components (4th dimension). |
|
inlineconstexprnoexcept |
Reduced dimension constructor with component count.
Pads intermediate dimensions with [0,1) and sets the last dimension to [0, ncomp).
| a_p | Pointer to data. |
| a_begin | Start index (inclusive). |
| a_end | End index (exclusive). |
| ncomp | Number of components (size of last dimension). |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Slicing constructor (Component subset with count).
Creates a new ArrayND that is a slice of the input ArrayND along the last dimension (components).
| rhs | The source ArrayND to slice from. |
| start_comp | The starting component index for the slice. |
| num_comp | The number of components to include in the slice. |
|
inlinenoexcept |
Create a single-cell component accessor.
Returns a CellData<T> view for the cell 
(i,j,k,n) indexing.
| i | Cell index in x. |
| j | Cell index in y. |
| k | Cell index in z. |
CellData<T> accessor for cell 
|
inlinenoexcept |
Test whether the spatial indices are inside the Array4 bounds.
| cell | Spatial indices. |
true if all indices are within bounds.
|
inlineconstexprnoexcept |
Test whether an index tuple lies inside the ArrayND bounds.
This overload accepts a pack of integer indices and it is disabled for Array4, which has its own overload of contains that takes three integer indices for spatial dimensions.
| idx | Index argument types. |
| i | Indices to test. |
true if all indices are within bounds.
|
inlinenoexcept |
Test whether the spatial indices are inside the Array4 bounds.
| i | Cell index in x. |
| j | Cell index in y. |
| k | Cell index in z. |
true if all indices are within bounds.
|
inlineconstexprnoexcept |
Test whether an IntVectND lies inside the ArrayND bounds.
Checks whether each component of iv is within the half-open bounds [begin, end) for the corresponding dimensions.
This overload supports two cases:
M==N : the full index space is checked; if the last dimension is a component dimension, it is checked as well. This can be used Array4.(M+1==N) with last_dim_component=true : only the spatial dimensions are checked (component handled separately).| M | Dimension of the input IntVectND. |
| [in] | iv | IntVectND to test. |
true if iv is inside the bounds, otherwise false.
|
inlinenoexcept |
Test whether the spatial indices are inside the Array4 bounds.
| iv | Spatial indices. |
true if all indices are within bounds.
|
inlineconstexprnoexcept |
Test whether a spatial index and component lie inside the bounds.
Checks that the spatial index iv is within [begin, end) for the spatial dimensions and that the component index n satisfies 0 <= n < end[N-1].
This overload is enabled only when the last dimension is a component dimension.
| M | Spatial dimension of the input IntVectND. |
| [in] | iv | Spatial IntVectND to test. |
| [in] | n | Component index to test. |
true if both the spatial index and component are inside, otherwise false.
|
inlineconstexprnoexcept |
Get raw data pointer.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Return the stride (in elements) for dimension d.
This returns the multiplier used to advance the linear address when incrementing index d by one. For d==0, the stride is 1.
| d | Dimension index in the range [0, N). |
d, in number of elements.
|
inlineconstexprnoexcept |
Get number of components.
|
inlineconstexprnoexcept |
Check if the ArrayND pointer is valid and bounds are valid.
|
inlineexplicitconstexprnoexcept |
Check if the ArrayND pointer is valid.
|
inlinenoexcept |
Access Array4 element by spatial indices in Dim3.
The component index is implicitly assumed to be zero.
| cell | Spatial indices. |
|
inlinenoexcept |
Access Array4 element by spatial indices in Dim3 and component index.
| cell | Spatial indices. |
| n | Component index. |
|
inlinenoexcept |
Multi-index operator() for accessing elements.
This operator is only enabled when the number of indices provided matches the dimension N or N-1 if last_dim_component is true, where in the latter case the last dimension is assumed to be 0. The passed indices must be of integral types that can be converted to int without narrowing. The last index can also be an enum type.
operator() that takes three integer indices for spatial dimensions and an optional integer component index.| idx | Variadic template for indices. |
| i | Variadic list of indices. |
|
inlinenoexcept |
Access Array4 element using three integer spatial indices.
The component index is implicitly assumed to be zero. When AMREX_SPACEDIM is less than 3, the bounds for extra spatial dimensions are typically [0,1). In particular, when launching a kernel with amrex::ParallelFor(Box, f), where f is a lambda function with the signature of void(int i,int j,int k), AMReX supplies zero for the extra dimensions. Thus this operator is safe under the usual AMReX execution model.
| i | Cell index in x. |
| j | Cell index in y. |
| k | Cell index in z. |
|
inlinenoexcept |
Access Array4 element using three integer spatial indices and component index.
When AMREX_SPACEDIM is less than 3, the bounds for extra spatial dimensions are typically [0,1). For example, when AMREX_SPADIM is 2, k should typically be zero.
| i | Cell index in x. |
| j | Cell index in y. |
| k | Cell index in z. |
| n | Component index. |
|
inlinenoexcept |
Access element by IntVectND.
This function handles access via:
| M | The dimension of the index vector. |
| iv | The index vector. |
|
inlinenoexcept |
Access Array4 element by spatial indices in IntVectND.
The component index is implicitly assumed to be zero. The dimension of iv is either 3 or AMREX_SPACEDIM. If it's less than 3, zero is used in the extra dimensions.
| iv | Spatial indices. |
|
inlinenoexcept |
Access element by spatial IntVectND and component index.
This overload is enabled only when last_dim_component is true and M represents the spatial dimensions (either N-1 or AMREX_SPACEDIM).
| M | The dimension of the spatial index vector (typically N-1 or AMREX_SPACEDIM). |
| iv | The spatial index vector. |
| n | Component index (last dimension). |
|
inlinenoexcept |
Access Array4 element by spatial indices in IntVectND and component index.
The dimension of iv is either 3 or AMREX_SPACEDIM. If it's less than 3, zero is used in the extra dimensions.
| iv | Spatial indices. |
| n | Component index. |
|
inlinenoexcept |
Return the pointer to an element.
| cell | Spatial indices |
(cell).
|
inlinenoexcept |
Return the pointer to an element.
| cell | Spatial indices. |
| n | Component index. |
(cell,n).
|
inlinenoexcept |
Multi-index ptr() for accessing pointer to element.
| idx | Variadic template for indices. |
| i | Variadic list of indices. |
|
inlinenoexcept |
Return the pointer to an element.
| i | Cell index in x. |
| j | Cell index in y. |
| k | Cell index in z. |
(i,j,k).
|
inlinenoexcept |
Return the pointer to an element.
| i | Cell index in x. |
| j | Cell index in y. |
| k | Cell index in z. |
| n | Component index. |
(i,j,k,n).
|
inlinenoexcept |
Access pointer by IntVectND.
This function handles access via:
| M | The dimension of the index vector. |
| iv | The index vector. |
|
inlinenoexcept |
Return the pointer to an element.
| iv | Spatial indices |
(iv).
|
inlinenoexcept |
Access pointer by spatial IntVectND and component index.
This overload is enabled only when last_dim_component is true and M represents the spatial dimensions (either N-1 or AMREX_SPACEDIM).
| M | The dimension of the spatial index vector (typically N-1 or AMREX_SPACEDIM). |
| iv | The spatial index vector. |
| n | Component index (last dimension). |
|
inlinenoexcept |
Return the pointer to an element.
| iv | Spatial indices. |
| n | Component index. |
(iv,n).
|
inlineconstexprnoexcept |
| IntVectND<N> amrex::ArrayND< T, N, last_dim_component >::begin {1} |
Inclusive lower bounds.
| IntVectND<N> amrex::ArrayND< T, N, last_dim_component >::end {0} |
Exclusive upper bounds.
|
staticconstexpr |
True if this is an Array4 (N==4 and last dim is component).
|
staticconstexpr |
True if the last dimension is treated as components.
| T* __restrict__ amrex::ArrayND< T, N, last_dim_component >::p = nullptr |
Base pointer to the first element