21template <
int N,
int Dim,
typename T,
typename...
Args>
26 static inline int result(
const int* sizes, T first,
Args... args)
28#if !(defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP))
29 MFEM_ASSERT(first<sizes[N-1],
"Trying to access out of boundary.");
31 return static_cast<int>(first + sizes[N - 1] *
TensorInd < N + 1, Dim,
Args... >
37template <
int Dim,
typename T,
typename...
Args>
42 static inline int result(
const int* sizes, T first,
Args... args)
44#if !(defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP))
45 MFEM_ASSERT(first<sizes[Dim-1],
"Trying to access out of boundary.");
47 return static_cast<int>(first);
53template <
int N,
int Dim,
typename T,
typename...
Args>
58 static inline int result(
int* sizes, T first,
Args... args)
66template <
int Dim,
typename T,
typename...
Args>
71 static inline int result(
int* sizes, T first,
Args... args)
73 sizes[Dim - 1] = first;
80template<
int Dim,
typename Scalar = real_t>
93 template <
typename...
Args> MFEM_HOST_DEVICE
96 static_assert(
sizeof...(args) == Dim,
"Wrong number of arguments");
110 MFEM_HOST_DEVICE
inline operator Scalar *()
const {
return data; }
113 template <
typename...
Args> MFEM_HOST_DEVICE
inline
116 static_assert(
sizeof...(args) == Dim,
"Wrong number of arguments");
130template <
typename T,
typename... Dims> MFEM_HOST_DEVICE
A basic generic Tensor class, appropriate for use on the GPU.
DeviceTensor(const DeviceTensor &)=default
Copy constructor (default)
MFEM_HOST_DEVICE Scalar & operator[](int i) const
Subscript operator where the tensor is viewed as a 1D array.
MFEM_HOST_DEVICE DeviceTensor(Scalar *data_, Args... args)
Constructor to initialize a tensor from the Scalar array data_.
DeviceTensor()=delete
Default constructor.
DeviceTensor & operator=(const DeviceTensor &)=default
Copy assignment (default)
MFEM_HOST_DEVICE Scalar & operator()(Args... args) const
Const accessor for the data.
static MFEM_HOST_DEVICE int result(int *sizes, T first, Args... args)
A class to initialize the size of a Tensor.
static MFEM_HOST_DEVICE int result(int *sizes, T first, Args... args)
static MFEM_HOST_DEVICE int result(const int *sizes, T first, Args... args)
A Class to compute the real index from the multi-indices of a tensor.
static MFEM_HOST_DEVICE int result(const int *sizes, T first, Args... args)
DeviceTensor< 2, real_t > DeviceMatrix
DeviceTensor< 1, const int > ConstDeviceArray
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
DeviceTensor< 2, const real_t > ConstDeviceMatrix
DeviceTensor< 3, const real_t > ConstDeviceCube
DeviceTensor< 1, real_t > DeviceVector
kernels::InvariantsEvaluator2D::Buffers Args
DeviceTensor< 1, int > DeviceArray
DeviceTensor< 1, const real_t > ConstDeviceVector
DeviceTensor< 3, real_t > DeviceCube