Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER > Class Template Reference

A GPU-compatible three-dimensional array. More...

#include <AMReX_Array.H>

Public Member Functions

__host__ __device__ const T * begin () const noexcept
 
__host__ __device__ const T * end () const noexcept
 
__host__ __device__ T * begin () noexcept
 
__host__ __device__ T * end () noexcept
 
__host__ __device__ const T & operator() (int i, int j, int k) const noexcept
 
__host__ __device__ T & operator() (int i, int j, int k) noexcept
 
__host__ __device__ constexpr T sum () const noexcept
 
__host__ __device__ constexpr T sum (int axis, int loc0, int loc1) const noexcept
 
__host__ __device__ constexpr T product () const noexcept
 
__host__ __device__ constexpr T product (const int axis, const int loc0, const int loc1) const noexcept
 

Static Public Member Functions

__host__ static __device__ constexpr unsigned int size () noexcept
 
__host__ static __device__ constexpr int xlo () noexcept
 
__host__ static __device__ constexpr int xhi () noexcept
 
__host__ static __device__ constexpr unsigned int xlen () noexcept
 
__host__ static __device__ constexpr int ylo () noexcept
 
__host__ static __device__ constexpr int yhi () noexcept
 
__host__ static __device__ constexpr unsigned int ylen () noexcept
 
__host__ static __device__ constexpr int zlo () noexcept
 
__host__ static __device__ constexpr int zhi () noexcept
 
__host__ static __device__ constexpr unsigned int zlen () noexcept
 

Detailed Description

template<class T, int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
class amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >

A GPU-compatible three-dimensional array.

Array3D objects can be indexed according to Fortran column-major order (first index moving fastest) or C/C++ row-major order (last index moving fastest). If not specified, Fortran order is assumed.

Template Parameters
TValue data type.
XLOIndex for inclusive lower bound in x dimension. Can be other than 0.
XHIIndex for inclusive upper bound in x dimension.
YLOIndex for inclusive lower bound in y dimension. Can be other than 0.
YHIIndex for inclusive upper bound in y dimension.
ZLOIndex for inclusive lower bound in z dimension. Can be other than 0.
ZHIIndex for inclusive upper bound in z dimension.
ORDEREither Order::C (C/C++ row-major order) or Order::F (Fortran column-major order, which is the default if not given)

Member Function Documentation

◆ begin() [1/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ const T * amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::begin ( ) const
inlinenoexcept

Returns a const pointer address to the first element of the Array3D object, as if the object is treated as one-dimensional.

◆ begin() [2/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ T * amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::begin ( )
inlinenoexcept

Returns a pointer address to the first element of the Array3D object, as if the object is treated as one-dimensional.

◆ end() [1/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ const T * amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::end ( ) const
inlinenoexcept

Returns a const pointer address right after the last element of the Array3D object, as if the object is treated as one-dimensional.

◆ end() [2/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ T * amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::end ( )
inlinenoexcept

Returns a pointer address right after the last element of the Array3D object, as if the object is treated as one-dimensional.

◆ operator()() [1/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ const T & amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::operator() ( int  i,
int  j,
int  k 
) const
inlinenoexcept

The elements of an Array3D object are accessed using parentheses, e.g. array(i,j,k), instead of using square brackets.

Parameters
iIndex in x dimension.
jIndex in y dimension.
kIndex in z dimension.

◆ operator()() [2/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ T & amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::operator() ( int  i,
int  j,
int  k 
)
inlinenoexcept

The elements of an Array3D object are accessed using parentheses, e.g. array(i,j,k), instead of using square brackets.

Parameters
iIndex in x dimension.
jIndex in y dimension.
kIndex in z dimension.

◆ product() [1/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ constexpr T amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::product ( ) const
inlineconstexprnoexcept

When called without any arguments, returns the product of all elements in the Array3D object.

◆ product() [2/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ constexpr T amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::product ( const int  axis,
const int  loc0,
const int  loc1 
) const
inlineconstexprnoexcept

When called with three arguments, performs a product reduction over the specified axis, for a particular set of location indices loc0 and loc1.

Parameters
axisThe dimension to reduce (0 for x dimension, 1 for y dimension, 2 for z dimension)
loc0The appropriate location index (either i or j)
loc1The appropriate location index (either j or k)

This can be used, for instance, to calculate the sum over the z dimension of an Array3D object that was instantiated as

A GPU-compatible three-dimensional array.
Definition AMReX_Array.H:652

One could instantiate an Array2D object to hold the results,

A GPU-compatible two-dimensional array.
Definition AMReX_Array.H:357

and then perform the summation for each element of the resulting matrix.

for (int j = 1; j <= N; ++j) {
for (int i = 1; i <= M; ++i) {
mat(i,j) = array.sum(2,i,j)
}
}
__host__ __device__ constexpr T sum() const noexcept
Definition AMReX_Array.H:804

In this example, the axis is 2 and the location indices are loc0 = i and loc1 = j. For axis = 0, the location indices are treated as loc0 = j and loc1 = k; for axis = 1, loc0 = i and loc1 = k.

◆ size()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr unsigned int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::size ( )
inlinestaticconstexprnoexcept

Returns the total number of elements in the Array3D object as an unsigned integer.

◆ sum() [1/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ constexpr T amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::sum ( ) const
inlineconstexprnoexcept

When called without any arguments, returns the sum of all elements in the Array3D object.

◆ sum() [2/2]

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ __device__ constexpr T amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::sum ( int  axis,
int  loc0,
int  loc1 
) const
inlineconstexprnoexcept

When called with three arguments, performs a sum reduction over the specified axis, for a particular set of location indices loc0 and loc1.

Parameters
axisThe dimension to reduce (0 for x dimension, 1 for y dimension, 2 for z dimension)
loc0The appropriate location index (either i or j)
loc1The appropriate location index (either j or k)

This can be used, for instance, to calculate the sum over the x dimension of an Array3D object that was instantiated as

One could instantiate an Array2D object to hold the results,

and then perform the summation for each element of the resulting matrix.

for (int j = 1; j <= N; ++j) {
for (int k = 1; k <= K; ++k) {
mat(j,k) = array.sum(0,j,k)
}
}

In this example, the axis is 0 and the location indices are loc0 = j and loc1 = k. For axis = 1, the location indices are treated as loc0 = i and loc1 = k; for axis = 2, loc0 = j and loc1 = k.

◆ xhi()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::xhi ( )
inlinestaticconstexprnoexcept

Returns the inclusive upper bound of the Array3D object in the x direction.

◆ xlen()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr unsigned int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::xlen ( )
inlinestaticconstexprnoexcept

Returns the number of elements of the Array3D object in the x direction as an unsigned integer.

◆ xlo()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::xlo ( )
inlinestaticconstexprnoexcept

Returns the inclusive lower bound of the Array3D object in the x direction. Can be other than 0.

◆ yhi()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::yhi ( )
inlinestaticconstexprnoexcept

Returns the inclusive upper bound of the Array3D object in the y direction.

◆ ylen()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr unsigned int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::ylen ( )
inlinestaticconstexprnoexcept

Returns the number of elements of the Array3D object in the y direction as an unsigned integer.

◆ ylo()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::ylo ( )
inlinestaticconstexprnoexcept

Returns the inclusive lower bound of the Array3D object in the y direction. Can be other than 0.

◆ zhi()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::zhi ( )
inlinestaticconstexprnoexcept

Returns the inclusive upper bound of the Array3D object in the z direction.

◆ zlen()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr unsigned int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::zlen ( )
inlinestaticconstexprnoexcept

Returns the number of elements of the Array3D object in the z direction as an unsigned integer.

◆ zlo()

template<class T , int XLO, int XHI, int YLO, int YHI, int ZLO, int ZHI, Order ORDER = Order::F>
__host__ static __device__ constexpr int amrex::Array3D< T, XLO, XHI, YLO, YHI, ZLO, ZHI, ORDER >::zlo ( )
inlinestaticconstexprnoexcept

Returns the inclusive lower bound of the Array3D object in the z direction. Can be other than 0.


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