diff --git a/src/scheme/NodeByCellData.hpp b/src/scheme/NodeByCellData.hpp index 3ce0710d4fd67639f94dff4fac6f1060f79f3193..52f9b02cf3e7356ede2ebd84d9a3e41a2a53c203 100644 --- a/src/scheme/NodeByCellData.hpp +++ b/src/scheme/NodeByCellData.hpp @@ -58,6 +58,42 @@ class NodeByCellData } }; + class SubViewConst + { + private: + KOKKOS_RESTRICT const DataType* const m_sub_values; + const size_t m_size; + public: + KOKKOS_INLINE_FUNCTION + const DataType& operator[](const size_t& i) const + { + Assert(i<m_size); + return m_sub_values[i]; + } + + KOKKOS_INLINE_FUNCTION + const size_t& size() const + { + return m_size; + } + + SubViewConst(const SubViewConst&) = delete; + + KOKKOS_INLINE_FUNCTION + SubViewConst(SubViewConst&&) = default; + + KOKKOS_INLINE_FUNCTION + SubViewConst(const Kokkos::View<DataType*>& values, + const size_t& begin, + const size_t& end) + : m_sub_values(&(values[begin])), + m_size(end-begin) + { + Assert(begin<=end); + Assert(end<=values.extent(0)); + } + }; + KOKKOS_INLINE_FUNCTION DataType& operator()(const size_t& j, const size_t& r) { @@ -108,6 +144,14 @@ class NodeByCellData return SubView(m_values, cell_begin, cell_end); } + KOKKOS_INLINE_FUNCTION + SubViewConst cellValues(const size_t& i_cell) const + { + const ConnectivityMatrix::size_type& cell_begin = m_node_id_per_cell_matrix.row_map[i_cell]; + const ConnectivityMatrix::size_type& cell_end = m_node_id_per_cell_matrix.row_map[i_cell+1]; + return SubViewConst(m_values, cell_begin, cell_end); + } + NodeByCellData(const ConnectivityMatrix& node_id_per_cell_matrix) : m_node_id_per_cell_matrix(node_id_per_cell_matrix), m_values("values", m_node_id_per_cell_matrix.entries.extent(0))