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 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.");
53 template <
int N,
int Dim,
typename T,
typename... Args>
58 static inline int result(
int* sizes, T first, Args... args)
61 return first *
Init < N + 1, Dim, Args... >
::result(sizes, args...);
66 template <
int Dim,
typename T,
typename... Args>
67 class Init<Dim, Dim, T, 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");
107 for (
int i = 0; i < Dim; ++i)
115 MFEM_HOST_DEVICE
inline operator Scalar *()
const {
return data; }
118 template <
typename... Args> MFEM_HOST_DEVICE
inline
121 static_assert(
sizeof...(args) == Dim,
"Wrong number of arguments");
135 template <
typename T,
typename... Dims>
156 #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 DeviceTensor(const DeviceTensor &t)
Copy constructor.
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< sizeof...(Dims), T > Reshape(T *ptr, Dims...dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
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.
MFEM_HOST_DEVICE Scalar & operator[](int i) const
Subscript operator where the tensor is viewed as a 1D array.
DeviceTensor< 3, const double > ConstDeviceCube