https://mooseframework.inl.gov
Public Member Functions | Protected Attributes | List of all members
Moose::Kokkos::JaggedArrayInnerData< T, inner, layout > Class Template Reference

The inner array wrapper class. More...

#include <KokkosJaggedArray.h>

Public Member Functions

KOKKOS_FUNCTION JaggedArrayInnerData (T *data, JaggedArrayInnerDim< inner > dim)
 Constructor. More...
 
KOKKOS_FUNCTION unsigned int size () const
 Get the total inner array size. More...
 
KOKKOS_FUNCTION unsigned int n (unsigned int dim) const
 Get the size of a dimension of the inner array. More...
 
KOKKOS_FUNCTION T & operator[] (unsigned int i) const
 Get an array entry. More...
 
template<typename... indices>
KOKKOS_FUNCTION T & operator() (indices... i) const
 Get an array entry. More...
 

Protected Attributes

T * _data
 Pointer to the inner array data. More...
 
JaggedArrayInnerDim< inner > _dim
 Inner array dimension information. More...
 

Detailed Description

template<typename T, unsigned int inner, LayoutType layout>
class Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >

The inner array wrapper class.

This object provides access to an inner array with local multi-dimensional indexing and is created as a temporary object by the jagged array class.

Template Parameters
TThe data type
innerThe inner array dimension size
layoutThe memory layout type

Definition at line 52 of file KokkosJaggedArray.h.

Constructor & Destructor Documentation

◆ JaggedArrayInnerData()

template<typename T, unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::JaggedArrayInnerData ( T *  data,
JaggedArrayInnerDim< inner >  dim 
)
inline

Constructor.

Parameters
dataThe pointer to the inner array data
dimThe inner array dimension information

Definition at line 60 of file KokkosJaggedArray.h.

61  : _data(data), _dim(dim)
62  {
63  }
JaggedArrayInnerDim< inner > _dim
Inner array dimension information.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163
T * _data
Pointer to the inner array data.

Member Function Documentation

◆ n()

template<typename T, unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION unsigned int Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::n ( unsigned int  dim) const
inline

Get the size of a dimension of the inner array.

Parameters
dimThe dimension index
Returns
The size of the dimension of the inner array

Definition at line 75 of file KokkosJaggedArray.h.

75 { return _dim[dim]; }
JaggedArrayInnerDim< inner > _dim
Inner array dimension information.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163

◆ operator()()

template<typename T , unsigned int inner, LayoutType layout>
template<typename... indices>
KOKKOS_FUNCTION T & Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::operator() ( indices...  i) const

Get an array entry.

Parameters
iThe inner array index of each dimension

Definition at line 107 of file KokkosJaggedArray.h.

108 {
109  static_assert((std::is_convertible<indices, unsigned int>::value && ...),
110  "All arguments must be convertible to unsigned int");
111  static_assert(sizeof...(i) == inner, "Number of arguments should match array dimension");
112 
113 #ifndef NDEBUG
114  {
115  unsigned int idx[inner] = {static_cast<unsigned int>(i)...};
116 
117  for (unsigned int d = 0; d < sizeof...(i); ++d)
118  KOKKOS_ASSERT(idx[d] < _dim[d]);
119  }
120 #endif
121 
122  unsigned int idx = 0;
123  unsigned int d = 0;
124 
125  if constexpr (layout == LayoutType::LEFT)
126  (((idx +=
127  (d == 0 ? static_cast<unsigned int>(i) : static_cast<unsigned int>(i) * _dim.stride[d])),
128  ++d),
129  ...);
130  else
131  (((idx += (d == inner - 1 ? static_cast<unsigned int>(i)
132  : static_cast<unsigned int>(i) * _dim.stride[d])),
133  ++d),
134  ...);
135 
136  return _data[idx];
137 }
JaggedArrayInnerDim< inner > _dim
Inner array dimension information.
T * _data
Pointer to the inner array data.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)

◆ operator[]()

template<typename T, unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION T& Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::operator[] ( unsigned int  i) const
inline

Get an array entry.

Parameters
iThe dimensionless inner array index

Definition at line 80 of file KokkosJaggedArray.h.

81  {
82  KOKKOS_ASSERT(i < _dim.stride[inner]);
83 
84  return _data[i];
85  }
JaggedArrayInnerDim< inner > _dim
Inner array dimension information.
T * _data
Pointer to the inner array data.

◆ size()

template<typename T, unsigned int inner, LayoutType layout>
KOKKOS_FUNCTION unsigned int Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::size ( ) const
inline

Get the total inner array size.

Returns
The total inner array size

Definition at line 69 of file KokkosJaggedArray.h.

69 { return _dim.stride[inner]; }
JaggedArrayInnerDim< inner > _dim
Inner array dimension information.

Member Data Documentation

◆ _data

template<typename T, unsigned int inner, LayoutType layout>
T* Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::_data
protected

Pointer to the inner array data.

Definition at line 97 of file KokkosJaggedArray.h.

Referenced by Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::operator[]().

◆ _dim

template<typename T, unsigned int inner, LayoutType layout>
JaggedArrayInnerDim<inner> Moose::Kokkos::JaggedArrayInnerData< T, inner, layout >::_dim
protected

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