DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
ArrayEigenVector_DeviceView.hpp
Go to the documentation of this file.
1#pragma once
2/// @file ArrayEigenVector_DeviceView.hpp
3/// @brief Device-callable view type for @ref DNDS::ArrayEigenVector "ArrayEigenVector"; `operator[]` returns
4/// an `Eigen::Map<Vector>` suitable for use inside CUDA kernels.
5
6#include "../DeviceView.hpp"
7#include "DNDS/Defines.hpp"
9#include "Eigen/src/Core/util/Constants.h"
10
11namespace DNDS
12{
13 /**
14 * @brief Device-callable view onto @ref DNDS::ArrayEigenVector "ArrayEigenVector" rows.
15 *
16 * @details Extends the generic @ref DNDS::ArrayDeviceView "ArrayDeviceView" to yield an
17 * `Eigen::Map<Vector>` on `operator[]`. The Eigen maps use
18 * `Eigen::DontAlign` to avoid assumptions about the backing pointer's
19 * alignment (which is device-allocator specific).
20 *
21 * @tparam real_T `DNDS::real` or `const DNDS::real` for a const view.
22 * @tparam _vec_size / _row_max / _align Same meaning as in the host class.
23 */
24 template <DeviceBackend B, class real_T, rowsize _vec_size = 1, rowsize _row_max = _vec_size, rowsize _align = NoAlign>
25 class ArrayEigenVectorDeviceView : public ArrayDeviceView<B, real_T, _vec_size, _row_max, _align>
26 {
27 public:
29 using t_base::t_base;
30
32
34
36
37 using t_EigenVector = Eigen::Matrix<std::remove_cv_t<real_T>, RowSize_To_EigenSize(_vec_size), 1,
38 Eigen::DontAlign | Eigen::ColMajor, RowSize_To_EigenSize(_row_max), 1>;
39 using t_EigenMap_Const = Eigen::Map<const t_EigenVector, Eigen::Unaligned>; // default no buffer align and stride
40 using t_EigenMap =
41 std::conditional_t<std::is_const_v<real_T>,
43 Eigen::Map<t_EigenVector, Eigen::Unaligned>>; // default no buffer align and stride
44
49
51 {
52 return {static_cast<const t_base &>(*this).operator[](i), t_base::RowSize(i)};
53 }
54 };
55}
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE(T, T_Self)
Definition Defines.hpp:83
#define DNDS_DEVICE_CALLABLE
Definition Defines.hpp:76
Device memory abstraction layer with backend-specific storage and factory creation.
Non-owning device-callable view of an Array, specialised per DeviceBackend.
Device-callable view onto ArrayEigenVector rows.
Eigen::Matrix< std::remove_cv_t< real_T >, RowSize_To_EigenSize(_vec_size), 1, Eigen::DontAlign|Eigen::ColMajor, RowSize_To_EigenSize(_row_max), 1 > t_EigenVector
std::conditional_t< std::is_const_v< real_T >, t_EigenMap_Const, Eigen::Map< t_EigenVector, Eigen::Unaligned > > t_EigenMap
DNDS_DEVICE_CALLABLE t_EigenMap operator[](index i)
DNDS_DEVICE_CALLABLE t_EigenMap_Const operator[](index i) const
Eigen::Map< const t_EigenVector, Eigen::Unaligned > t_EigenMap_Const
T * operator[](index iRow)
Raw row pointer. iRow == Size() is allowed for past-the-end queries (useful for computing buffer end ...
DNDS_DEVICE_CALLABLE rowsize RowSize() const
Uniform row width for fixed layouts (asserts otherwise).
the host side operators are provided as implemented
constexpr int RowSize_To_EigenSize(rowsize rs)
Convert a rowsize constant to the corresponding Eigen compile-time size. Fixed >= 0 -> the value; Dyn...
Definition Defines.hpp:286
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Definition Defines.hpp:107