diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index b02da8ac7b3af0f46b63b9bdb0e577f592bb3f80..62710a7619c83cd1778ee62e21cdb5bd4a084f47 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -403,6 +403,14 @@ Connectivity<3>::itemToItemMatrix<TypeOfItem::face, { return m_face_to_cell_matrix; } +template <> +template <> +inline const ConnectivityMatrix& +Connectivity<3>::itemToItemMatrix<TypeOfItem::face, + TypeOfItem::node>() const +{ + return m_face_to_node_matrix; +} template <> template <> @@ -443,6 +451,15 @@ Connectivity<2>::itemToItemMatrix<TypeOfItem::face, return m_face_to_cell_matrix; } +template <> +template <> +inline const ConnectivityMatrix& +Connectivity<2>::itemToItemMatrix<TypeOfItem::face, + TypeOfItem::node>() const +{ + return m_face_to_node_matrix; +} + template <> template <> inline const ConnectivityMatrix& @@ -483,6 +500,16 @@ Connectivity<1>::itemToItemMatrix<TypeOfItem::face, return m_face_to_cell_matrix; } +template <> +template <> +inline const ConnectivityMatrix& +Connectivity<1>::itemToItemMatrix<TypeOfItem::face, + TypeOfItem::node>() const +{ +#warning in 1d, faces and node are the same + return m_face_to_node_matrix; +} + template <> template <> inline const ConnectivityMatrix& @@ -519,6 +546,9 @@ itemToItemMatrix(const TypeOfItem& item_type_0, case TypeOfItem::cell: { return itemToItemMatrix<TypeOfItem::face, TypeOfItem::cell>(); } + case TypeOfItem::node: { + return itemToItemMatrix<TypeOfItem::face, TypeOfItem::node>(); + } default: { std::cerr << __FILE__ << ":" << __LINE__ << ": NIY " << int(item_type_1) << "\n"; std::exit(1); diff --git a/src/mesh/ConnectivityComputer.hpp b/src/mesh/ConnectivityComputer.hpp index d10a5652c5da137a7c1b2bb4ffe332eda8077727..f8e2e31bbf5d66664aff95d21499a9d33fef40b9 100644 --- a/src/mesh/ConnectivityComputer.hpp +++ b/src/mesh/ConnectivityComputer.hpp @@ -13,9 +13,9 @@ struct ConnectivityComputer const ConnectivityMatrix& child_item_to_items_matrix, CellValuePerNode<unsigned short>& child_item_number_in_item_matrix) const; - void computeLocalChildItemNumberInItem(const ConnectivityMatrix& item_to_child_items_matrix, - const ConnectivityMatrix& child_item_to_items_matrix, - NodeValuePerCell<unsigned short>& child_item_number_in_item_matrix) const; + void computeLocalChildItemNumberInItem(const ConnectivityMatrix& item_to_child_items_matrix, + const ConnectivityMatrix& child_item_to_items_matrix, + NodeValuePerCell<unsigned short>& child_item_number_in_item_matrix) const; void computeLocalChildItemNumberInItem(const ConnectivityMatrix& item_to_child_items_matrix, const ConnectivityMatrix& child_item_to_items_matrix, diff --git a/src/mesh/SubItemValuePerItem.hpp b/src/mesh/SubItemValuePerItem.hpp index 3f0c9951e5e2daec9e4d6cd67b5f74a9235f0ec0..a8016d0a5ee327797f18494b485ea77e9e009cf9 100644 --- a/src/mesh/SubItemValuePerItem.hpp +++ b/src/mesh/SubItemValuePerItem.hpp @@ -61,42 +61,6 @@ class SubItemValuePerItem } }; - class SubViewConst - { - private: - KOKKOS_RESTRICT const DataType* const m_sub_values; - const size_t m_size; - public: - KOKKOS_FORCEINLINE_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)); - } - }; - SubItemValuePerItem& operator=(const SubItemValuePerItem&) = default; KOKKOS_FORCEINLINE_FUNCTION @@ -105,8 +69,10 @@ class SubItemValuePerItem return m_values[m_host_row_map(j)+r]; } + // Following Kokkos logic, these classes are view and const view does allow + // changes in data KOKKOS_FORCEINLINE_FUNCTION - const DataType& operator()(const size_t& j, const size_t& r) const + DataType& operator()(const size_t& j, const size_t& r) const { return m_values[m_host_row_map(j)+r]; } @@ -123,8 +89,10 @@ class SubItemValuePerItem return m_values[i]; } + // Following Kokkos logic, these classes are view and const view does allow + // changes in data KOKKOS_FORCEINLINE_FUNCTION - const DataType& operator[](const size_t & i) const + DataType& operator[](const size_t & i) const { return m_values[i]; } @@ -132,7 +100,7 @@ class SubItemValuePerItem KOKKOS_INLINE_FUNCTION size_t numberOfItems() const { - Assert(m_host_row_map.extent(0) != 0>0); + Assert(m_host_row_map.extent(0) != 0); return m_host_row_map.extent(0); } @@ -150,12 +118,14 @@ class SubItemValuePerItem return SubView(m_values, cell_begin, cell_end); } + // Following Kokkos logic, these classes are view and const view does allow + // changes in data KOKKOS_INLINE_FUNCTION - SubViewConst itemValues(const size_t& i_cell) const + SubView itemValues(const size_t& i_cell) const { const auto& cell_begin = m_host_row_map(i_cell); const auto& cell_end = m_host_row_map(i_cell+1); - return SubViewConst(m_values, cell_begin, cell_end); + return SubView(m_values, cell_begin, cell_end); } SubItemValuePerItem() = default; @@ -174,6 +144,9 @@ class SubItemValuePerItem template <typename DataType> using NodeValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::cell>; +template <typename DataType> +using NodeValuePerFace = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::face>; + template <typename DataType> using FaceValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::face, TypeOfItem::cell>;