diff --git a/src/mesh/SubItemValuePerItem.hpp b/src/mesh/SubItemValuePerItem.hpp index 63bff8a35848746535df9d05c7df0a12c899c3a6..b86b075ecbb44ff0f95a1a28b1f8f2468d98b2e3 100644 --- a/src/mesh/SubItemValuePerItem.hpp +++ b/src/mesh/SubItemValuePerItem.hpp @@ -50,55 +50,6 @@ class SubItemValuePerItem public: using ToShared = SubItemValuePerItem<DataType, ItemOfItem, ConnectivitySharedPtr>; - class SubView - { - public: - using data_type = DataType; - - private: - PUGS_RESTRICT DataType* const m_sub_values; - const size_t m_size; - - public: - template <typename IndexType> - PUGS_FORCEINLINE DataType& - operator[](IndexType i) const noexcept(NO_ASSERT) - { - static_assert(std::is_integral_v<IndexType>, "SubView is indexed by integral values"); - Assert(i < m_size); - return m_sub_values[i]; - } - - template <typename IndexType> - PUGS_FORCEINLINE DataType& - operator[](IndexType i) noexcept(NO_ASSERT) - { - static_assert(std::is_integral_v<IndexType>, "SubView is indexed by integral values"); - Assert(i < m_size); - return m_sub_values[i]; - } - - PUGS_INLINE - size_t - size() const noexcept - { - return m_size; - } - - SubView(const SubView&) = delete; - SubView(SubView&&) noexcept = delete; - - PUGS_INLINE - SubView(const Array<DataType>& values, size_t begin, size_t end) noexcept(NO_ASSERT) - : m_sub_values(&(values[begin])), m_size(end - begin) - { - Assert(begin <= end); - Assert(end <= values.size()); - } - - ~SubView() = default; - }; - friend PUGS_INLINE SubItemValuePerItem<std::remove_const_t<DataType>, ItemOfItem, ConnectivityPtr> copy(SubItemValuePerItem<DataType, ItemOfItem, ConnectivityPtr>& source) { @@ -178,8 +129,16 @@ class SubItemValuePerItem return m_host_row_map(size_t{item_id} + 1) - m_host_row_map(size_t{item_id}); } + PUGS_INLINE + void + fill(const DataType& data) const noexcept + { + static_assert(not std::is_const_v<DataType>, "Cannot modify ItemValue of const"); + m_values.fill(data); + } + template <typename IndexType> - PUGS_INLINE SubView + PUGS_INLINE Array<DataType> itemValues(IndexType item_id) noexcept(NO_ASSERT) { static_assert(std::is_same_v<IndexType, ItemId>, "index must be an ItemId"); @@ -187,13 +146,13 @@ class SubItemValuePerItem Assert(item_id < this->numberOfItems()); const auto& item_begin = m_host_row_map(size_t{item_id}); const auto& item_end = m_host_row_map(size_t{item_id} + 1); - return SubView(m_values, item_begin, item_end); + return subArray(m_values, item_begin, item_end - item_begin); } // Following Kokkos logic, these classes are view and const view does allow // changes in data template <typename IndexType> - PUGS_INLINE SubView + PUGS_INLINE Array<DataType> itemValues(IndexType item_id) const noexcept(NO_ASSERT) { static_assert(std::is_same_v<IndexType, ItemId>, "index must be an ItemId"); @@ -201,7 +160,7 @@ class SubItemValuePerItem Assert(item_id < this->numberOfItems()); const auto& item_begin = m_host_row_map(size_t{item_id}); const auto& item_end = m_host_row_map(size_t{item_id} + 1); - return SubView(m_values, item_begin, item_end); + return subArray(m_values, item_begin, item_end - item_begin); } template <typename DataType2, typename ConnectivityPtr2>