Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::ArrayND< T, N, last_dim_component > Class Template Reference

A multidimensional array accessor. More...

#include <AMReX_Array4.H>

Inheritance diagram for amrex::ArrayND< T, N, last_dim_component >:
amrex::PolymorphicArray4< T >

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).
 

Detailed Description

template<typename T, int N, bool last_dim_component = false>
class amrex::ArrayND< T, N, last_dim_component >

A multidimensional array accessor.

Template Parameters
TThe type of data (e.g., Real, int). May be const-qualified.
NThe dimension of the array (rank).
last_dim_componentIf 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.

Note
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.

Constructor & Destructor Documentation

◆ ArrayND() [1/9]

template<typename T , int N, bool last_dim_component = false>
__host__ __device__ constexpr amrex::ArrayND< T, N, last_dim_component >::ArrayND ( )
inlineconstexprnoexcept

Default-construct an empty accessor.

The resulting accessor is invalid (operator bool() returns false).

◆ ArrayND() [2/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t< std::is_const_v< U >, int > = 0>
__host__ __device__ constexpr amrex::ArrayND< T, N, last_dim_component >::ArrayND ( ArrayND< std::remove_const_t< T >, N, last_dim_component > const &  rhs)
inlineconstexprnoexcept

Construct a const accessor from a non-const accessor.

This enables implicit conversion from ArrayND<T,...> to ArrayND<const T,...>.

Parameters
rhsSource accessor.

◆ ArrayND() [3/9]

template<typename T , int N, bool last_dim_component = false>
template<bool C = last_dim_component, std::enable_if_t<!C, int > = 0>
__host__ __device__ amrex::ArrayND< T, N, last_dim_component >::ArrayND ( T *  a_p,
BoxND< N > const &  box 
)
inlinenoexcept

Constructor using a BoxND.

Parameters
a_pPointer to data.
boxThe domain covered by this array.

◆ ArrayND() [4/9]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t<((M+1==N)||(N==4 &&M==3)) &&last_dim_component, int > = 0>
__host__ __device__ amrex::ArrayND< T, N, last_dim_component >::ArrayND ( T *  a_p,
BoxND< M > const &  box,
int  ncomp 
)
inlinenoexcept

Constructor using a BoxND and the number of components.

Parameters
a_pPointer to data.
boxBoxND<M> with M <= N-1 defining the spatial dimensions.
ncompNumber of components (size of last dimension).

◆ ArrayND() [5/9]

template<typename T , int N, bool last_dim_component = false>
template<bool C = last_dim_component, std::enable_if_t<!C, int > = 0>
__host__ __device__ constexpr amrex::ArrayND< T, N, last_dim_component >::ArrayND ( T *  a_p,
IntVectND< N > const &  a_begin,
IntVectND< N > const &  a_end 
)
inlineconstexprnoexcept

IntVectND<N> constructor.

This constructor specifies begin and end indices using IntVectND<N> for all N dimensions.

Parameters
a_pPointer to data.
a_beginStart index (inclusive).
a_endEnd index (exclusive).

◆ ArrayND() [6/9]

template<typename T , int N, bool last_dim_component = false>
template<bool B = IsArray4_v, std::enable_if_t< B, int > = 0>
__host__ __device__ constexpr amrex::ArrayND< T, N, last_dim_component >::ArrayND ( T *  a_p,
Dim3 const &  a_begin,
Dim3 const &  a_end,
int  a_ncomp 
)
inlineconstexprnoexcept

Constructor for N=4 using Dim3.

Typically used for standard (i, j, k, n) access in 3D simulations.

Parameters
a_pPointer to data.
a_beginStart index.
a_endEnd index exclusive.
a_ncompNumber of components (4th dimension).

◆ ArrayND() [7/9]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t<((M+1==N)||(N==4 &&M==3)) &&last_dim_component, int > = 0>
__host__ __device__ constexpr amrex::ArrayND< T, N, last_dim_component >::ArrayND ( T *  a_p,
IntVectND< M > const &  a_begin,
IntVectND< M > const &  a_end,
int  ncomp 
)
inlineconstexprnoexcept

Reduced dimension constructor with component count.

Pads intermediate dimensions with [0,1) and sets the last dimension to [0, ncomp).

Parameters
a_pPointer to data.
a_beginStart index (inclusive).
a_endEnd index (exclusive).
ncompNumber of components (size of last dimension).

◆ ArrayND() [8/9]

template<typename T , int N, bool last_dim_component = false>
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 amrex::ArrayND< T, N, last_dim_component >::ArrayND ( ArrayND< U, N, last_dim_component > const &  rhs,
int  start_comp 
)
inlineconstexprnoexcept

Slicing constructor (Component subset).

Creates a new ArrayND that is a slice of the input ArrayND along the last dimension (components).

Parameters
rhsThe source ArrayND to slice from.
start_compThe starting component index for the slice.

◆ ArrayND() [9/9]

template<typename T , int N, bool last_dim_component = false>
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 amrex::ArrayND< T, N, last_dim_component >::ArrayND ( ArrayND< U, N, last_dim_component > const &  rhs,
int  start_comp,
int  num_comp 
)
inlineconstexprnoexcept

Slicing constructor (Component subset with count).

Creates a new ArrayND that is a slice of the input ArrayND along the last dimension (components).

Parameters
rhsThe source ArrayND to slice from.
start_compThe starting component index for the slice.
num_compThe number of components to include in the slice.

Member Function Documentation

◆ cellData()

template<typename T , int N, bool last_dim_component = false>
template<int M = N, bool B = IsArray4_v, std::enable_if_t< B, int > = 0>
__host__ __device__ CellData< T > amrex::ArrayND< T, N, last_dim_component >::cellData ( int  i,
int  j,
int  k 
) const
inlinenoexcept

Create a single-cell component accessor.

Returns a CellData<T> view for the cell $(i,j,k)$ in an Array4. The returned object provides access to all components without recomputing full (i,j,k,n) indexing.

Parameters
iCell index in x.
jCell index in y.
kCell index in z.
Returns
A CellData<T> accessor for cell $(i,j,k)$.
Note
This overload is enabled only for Array4.
See also
CellData

◆ contains() [1/6]

template<typename T , int N, bool last_dim_component = false>
template<bool B = IsArray4_v, std::enable_if_t< B, int > = 0>
__host__ __device__ bool amrex::ArrayND< T, N, last_dim_component >::contains ( Dim3 const &  cell) const
inlinenoexcept

Test whether the spatial indices are inside the Array4 bounds.

Parameters
cellSpatial indices.
Returns
true if all indices are within bounds.

◆ contains() [2/6]

template<typename T , int N, bool last_dim_component = false>
template<typename... idx, std::enable_if_t<!IsArray4_v &&detail::ArrayNDIndexCheck_impl_v< N, last_dim_component, idx... >, int > = 0>
__host__ __device__ constexpr bool amrex::ArrayND< T, N, last_dim_component >::contains ( idx...  i) const
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.

Template Parameters
idxIndex argument types.
Parameters
iIndices to test.
Returns
true if all indices are within bounds.

◆ contains() [3/6]

template<typename T , int N, bool last_dim_component = false>
template<bool B = IsArray4_v, std::enable_if_t< B, int > = 0>
__host__ __device__ bool amrex::ArrayND< T, N, last_dim_component >::contains ( int  i,
int  j,
int  k 
) const
inlinenoexcept

Test whether the spatial indices are inside the Array4 bounds.

Parameters
iCell index in x.
jCell index in y.
kCell index in z.
Returns
true if all indices are within bounds.

◆ contains() [4/6]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t<(M==N)||(!IsArray4_v &&last_dim_component &&(M+1==N)), int > = 0>
__host__ __device__ constexpr bool amrex::ArrayND< T, N, last_dim_component >::contains ( IntVectND< M > const &  iv) const
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).
Template Parameters
MDimension of the input IntVectND.
Parameters
[in]ivIntVectND to test.
Returns
true if iv is inside the bounds, otherwise false.

◆ contains() [5/6]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t< IsArray4_v &&(M==3||M==3), int > = 0>
__host__ __device__ bool amrex::ArrayND< T, N, last_dim_component >::contains ( IntVectND< M > const &  iv) const
inlinenoexcept

Test whether the spatial indices are inside the Array4 bounds.

Parameters
ivSpatial indices.
Returns
true if all indices are within bounds.

◆ contains() [6/6]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t< last_dim_component &&!IsArray4_v &&(M+1==N), int > = 0>
__host__ __device__ constexpr bool amrex::ArrayND< T, N, last_dim_component >::contains ( IntVectND< M > const &  iv,
int  n 
) const
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.

Template Parameters
MSpatial dimension of the input IntVectND.
Parameters
[in]ivSpatial IntVectND to test.
[in]nComponent index to test.
Returns
true if both the spatial index and component are inside, otherwise false.

◆ dataPtr()

template<typename T , int N, bool last_dim_component = false>
__host__ __device__ constexpr T * amrex::ArrayND< T, N, last_dim_component >::dataPtr ( ) const
inlineconstexprnoexcept

Get raw data pointer.

Returns
Raw data pointer.

◆ get_offset() [1/2]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t<(M==N)||(last_dim_component &&(M+1==N||M==3)), int > = 0>
__host__ __device__ constexpr Long amrex::ArrayND< T, N, last_dim_component >::get_offset ( IntVectND< M > const &  iv) const
inlineconstexprnoexcept

Compute the linear offset (in elements) for an IntVectND.

Template Parameters
MDimension of IntVectND.
Parameters
[in]ivIntVectND.
Returns
Linear offset in number of elements from base pointer p.

◆ get_offset() [2/2]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t< last_dim_component &&((M+1==N)||(N==4 &&M==3)), int > = 0>
__host__ __device__ constexpr Long amrex::ArrayND< T, N, last_dim_component >::get_offset ( IntVectND< M > const &  iv,
int  n 
) const
inlineconstexprnoexcept

Compute the linear offset (in elements) for an IntVectND and component index.

Template Parameters
MDimension of IntVectND.
Parameters
ivIntVectND for spatial part.
nComponent index.
Returns
Linear offset in number of elements from base pointer p.

◆ get_stride()

template<typename T , int N, bool last_dim_component = false>
template<int d, std::enable_if_t<(d< N) &&(d >=0), int > = 0>
__host__ __device__ constexpr Long amrex::ArrayND< T, N, last_dim_component >::get_stride ( ) const
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.

Template Parameters
dDimension index in the range [0, N).
Returns
Stride for dimension d, in number of elements.

◆ nComp()

template<typename T , int N, bool last_dim_component = false>
__host__ __device__ constexpr int amrex::ArrayND< T, N, last_dim_component >::nComp ( ) const
inlineconstexprnoexcept

Get number of components.

Returns
Number of components.

◆ ok()

template<typename T , int N, bool last_dim_component = false>
__host__ __device__ constexpr bool amrex::ArrayND< T, N, last_dim_component >::ok ( ) const
inlineconstexprnoexcept

Check if the ArrayND pointer is valid and bounds are valid.

Returns
true if pointer and bounds are valid, false otherwise.

◆ operator bool()

template<typename T , int N, bool last_dim_component = false>
__host__ __device__ constexpr amrex::ArrayND< T, N, last_dim_component >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Check if the ArrayND pointer is valid.

Returns
true if pointer is valid, false otherwise.

◆ operator()() [1/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U & amrex::ArrayND< T, N, last_dim_component >::operator() ( Dim3 const &  cell) const
inlinenoexcept

Access Array4 element by spatial indices in Dim3.

The component index is implicitly assumed to be zero.

Parameters
cellSpatial indices.

◆ operator()() [2/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U & amrex::ArrayND< T, N, last_dim_component >::operator() ( Dim3 const &  cell,
int  n 
) const
inlinenoexcept

Access Array4 element by spatial indices in Dim3 and component index.

Parameters
cellSpatial indices.
nComponent index.

◆ operator()() [3/9]

template<typename T , int N, bool last_dim_component = false>
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 & amrex::ArrayND< T, N, last_dim_component >::operator() ( idx...  i) const
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.

Note
This overload is disabled for Array4, which has its own overload of operator() that takes three integer indices for spatial dimensions and an optional integer component index.
Template Parameters
idxVariadic template for indices.
Parameters
iVariadic list of indices.
Returns
Reference to the element.

◆ operator()() [4/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U & amrex::ArrayND< T, N, last_dim_component >::operator() ( int  i,
int  j,
int  k 
) const
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.

Parameters
iCell index in x.
jCell index in y.
kCell index in z.
Note
This overload is enabled only for Array4.

◆ operator()() [5/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U & amrex::ArrayND< T, N, last_dim_component >::operator() ( int  i,
int  j,
int  k,
int  n 
) const
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.

Parameters
iCell index in x.
jCell index in y.
kCell index in z.
nComponent index.
Note
This overload is enabled only for Array4.

◆ operator()() [6/9]

template<typename T , int N, bool last_dim_component = false>
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 & amrex::ArrayND< T, N, last_dim_component >::operator() ( IntVectND< M > const &  iv) const
inlinenoexcept

Access element by IntVectND.

This function handles access via:

  1. Full dimension vector (M == N).
  2. Spatial dimension vector (M == N-1) && !IsArray4_v (only enabled if last_dim_component is true).
Template Parameters
MThe dimension of the index vector.
Parameters
ivThe index vector.
Returns
Reference to the element.

◆ operator()() [7/9]

template<typename T , int N, bool last_dim_component = false>
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 & amrex::ArrayND< T, N, last_dim_component >::operator() ( IntVectND< M > const &  iv) const
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.

Parameters
ivSpatial indices.

◆ operator()() [8/9]

template<typename T , int N, bool last_dim_component = false>
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 & amrex::ArrayND< T, N, last_dim_component >::operator() ( IntVectND< M > const &  iv,
int  n 
) const
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).

Template Parameters
MThe dimension of the spatial index vector (typically N-1 or AMREX_SPACEDIM).
Parameters
ivThe spatial index vector.
nComponent index (last dimension).
Returns
Reference to the element.

◆ operator()() [9/9]

template<typename T , int N, bool last_dim_component = false>
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 & amrex::ArrayND< T, N, last_dim_component >::operator() ( IntVectND< M > const &  iv,
int  n 
) const
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.

Parameters
ivSpatial indices.
nComponent index.

◆ ptr() [1/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U * amrex::ArrayND< T, N, last_dim_component >::ptr ( Dim3 const &  cell) const
inlinenoexcept

Return the pointer to an element.

Parameters
cellSpatial indices
Returns
Pointer to element at (cell).

◆ ptr() [2/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U * amrex::ArrayND< T, N, last_dim_component >::ptr ( Dim3 const &  cell,
int  n 
) const
inlinenoexcept

Return the pointer to an element.

Parameters
cellSpatial indices.
nComponent index.
Returns
Pointer to element at (cell,n).

◆ ptr() [3/9]

template<typename T , int N, bool last_dim_component = false>
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 * amrex::ArrayND< T, N, last_dim_component >::ptr ( idx...  i) const
inlinenoexcept

Multi-index ptr() for accessing pointer to element.

Template Parameters
idxVariadic template for indices.
Parameters
iVariadic list of indices.
Returns
Pointer to the element.

◆ ptr() [4/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U * amrex::ArrayND< T, N, last_dim_component >::ptr ( int  i,
int  j,
int  k 
) const
inlinenoexcept

Return the pointer to an element.

Parameters
iCell index in x.
jCell index in y.
kCell index in z.
Returns
Pointer to element at (i,j,k).

◆ ptr() [5/9]

template<typename T , int N, bool last_dim_component = false>
template<class U = T, std::enable_if_t<!std::is_void_v< U > &&IsArray4_v, int > = 0>
__host__ __device__ U * amrex::ArrayND< T, N, last_dim_component >::ptr ( int  i,
int  j,
int  k,
int  n 
) const
inlinenoexcept

Return the pointer to an element.

Parameters
iCell index in x.
jCell index in y.
kCell index in z.
nComponent index.
Returns
Pointer to element at (i,j,k,n).

◆ ptr() [6/9]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t<(M==N)||(!IsArray4_v &&last_dim_component &&(M+1==N)), int > = 0>
__host__ __device__ T * amrex::ArrayND< T, N, last_dim_component >::ptr ( IntVectND< M > const &  iv) const
inlinenoexcept

Access pointer by IntVectND.

This function handles access via:

  1. Full dimension vector (M == N).
  2. Spatial dimension vector (M == N-1) && !IsArray4_v (only enabled if last_dim_component is true).
Template Parameters
MThe dimension of the index vector.
Parameters
ivThe index vector.
Returns
Pointer to the element.

◆ ptr() [7/9]

template<typename T , int N, bool last_dim_component = false>
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 * amrex::ArrayND< T, N, last_dim_component >::ptr ( IntVectND< M > const &  iv) const
inlinenoexcept

Return the pointer to an element.

Parameters
ivSpatial indices
Returns
Pointer to element at (iv).

◆ ptr() [8/9]

template<typename T , int N, bool last_dim_component = false>
template<int M, std::enable_if_t< last_dim_component &&!IsArray4_v &&(M+1==N), int > = 0>
__host__ __device__ T * amrex::ArrayND< T, N, last_dim_component >::ptr ( IntVectND< M > const &  iv,
int  n 
) const
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).

Template Parameters
MThe dimension of the spatial index vector (typically N-1 or AMREX_SPACEDIM).
Parameters
ivThe spatial index vector.
nComponent index (last dimension).
Returns
Pointer to the element.

◆ ptr() [9/9]

template<typename T , int N, bool last_dim_component = false>
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 * amrex::ArrayND< T, N, last_dim_component >::ptr ( IntVectND< M > const &  iv,
int  n 
) const
inlinenoexcept

Return the pointer to an element.

Parameters
ivSpatial indices.
nComponent index.
Returns
Pointer to element at (iv,n).

◆ size()

template<typename T , int N, bool last_dim_component = false>
__host__ __device__ constexpr std::size_t amrex::ArrayND< T, N, last_dim_component >::size ( ) const
inlineconstexprnoexcept

Total number of elements in the ArrayND's index region.

Returns the product of extents in each dimension. If the object is not valid (see ok()), this returns 0.

Returns
Number of elements in the ArrayND, or 0 if invalid.

Member Data Documentation

◆ begin

template<typename T , int N, bool last_dim_component = false>
IntVectND<N> amrex::ArrayND< T, N, last_dim_component >::begin {1}

Inclusive lower bounds.

◆ end

template<typename T , int N, bool last_dim_component = false>
IntVectND<N> amrex::ArrayND< T, N, last_dim_component >::end {0}

Exclusive upper bounds.

◆ IsArray4_v

template<typename T , int N, bool last_dim_component = false>
constexpr bool amrex::ArrayND< T, N, last_dim_component >::IsArray4_v = (N==4 && last_dim_component)
staticconstexpr

True if this is an Array4 (N==4 and last dim is component).

◆ IsLastDimComponent_v

template<typename T , int N, bool last_dim_component = false>
constexpr bool amrex::ArrayND< T, N, last_dim_component >::IsLastDimComponent_v = last_dim_component
staticconstexpr

True if the last dimension is treated as components.

◆ p

template<typename T , int N, bool last_dim_component = false>
T* __restrict__ amrex::ArrayND< T, N, last_dim_component >::p = nullptr

Base pointer to the first element


The documentation for this class was generated from the following file: