15 #include "../general/backends.hpp"
21 template <
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... >
37 template <
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);
53 template <
int N,
int Dim,
typename T,
typename...
Args>
58 static inline int result(
int* sizes, T first,
Args... args)
66 template <
int Dim,
typename T,
typename...
Args>
71 static inline int result(
int* sizes, T first,
Args... args)
73 sizes[Dim - 1] = first;
80 template<
int Dim,
typename Scalar =
double>
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");
130 template <
typename T,
typename... Dims> MFEM_HOST_DEVICE
151 #endif // MFEM_DTENSOR
DeviceTensor< 2, const double > ConstDeviceMatrix
static MFEM_HOST_DEVICE int result(const int *sizes, T first, Args...args)
DeviceTensor()=delete
Default constructor.
static MFEM_HOST_DEVICE int result(int *sizes, T first, Args...args)
MFEM_HOST_DEVICE Scalar & operator()(Args...args) const
Const accessor for the data.
DeviceTensor< 2, double > DeviceMatrix
MFEM_HOST_DEVICE DeviceTensor(Scalar *data_, Args...args)
Constructor to initialize a tensor from the Scalar array data_.
DeviceTensor< 1, const int > ConstDeviceArray
DeviceTensor< 1, int > DeviceArray
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 basic generic Tensor class, appropriate for use on the GPU.
DeviceTensor< 1, const double > ConstDeviceVector
DeviceTensor< 3, double > DeviceCube
A class to initialize the size of a Tensor.
DeviceTensor< 1, double > DeviceVector
A Class to compute the real index from the multi-indices of a tensor.
kernels::InvariantsEvaluator2D::Buffers Args
DeviceTensor & operator=(const DeviceTensor &)=default
Copy assignment (default)
MFEM_HOST_DEVICE Scalar & operator[](int i) const
Subscript operator where the tensor is viewed as a 1D array.
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims...dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
DeviceTensor< 3, const double > ConstDeviceCube