From 7b626f9907c1bdec4743b016c96184558323d20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Wed, 9 Mar 2022 14:46:31 +0100 Subject: [PATCH] Change a few function names to conform more to pugs nomenclatures --- src/mesh/Connectivity.hpp | 2 +- src/mesh/ConnectivityComputer.cpp | 2 +- src/mesh/ConnectivityMatrix.hpp | 9 +++---- src/mesh/ItemId.hpp | 2 +- src/mesh/ItemToItemMatrix.hpp | 39 +++++++++++++------------------ src/mesh/SubItemArrayPerItem.hpp | 2 +- src/mesh/SubItemValuePerItem.hpp | 2 +- src/output/VTKWriter.cpp | 2 +- 8 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index 4411e728d..dc2e0e890 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -80,9 +80,9 @@ class Connectivity final : public IConnectivity WeakFaceValuePerCell<const bool> m_cell_face_is_reversed; WeakEdgeValuePerFace<const bool> m_face_edge_is_reversed; - WeakNodeValuePerCell<const unsigned short> m_cell_local_numbers_in_their_nodes; WeakFaceValuePerCell<const unsigned short> m_cell_local_numbers_in_their_faces; WeakEdgeValuePerCell<const unsigned short> m_cell_local_numbers_in_their_edges; + WeakNodeValuePerCell<const unsigned short> m_cell_local_numbers_in_their_nodes; WeakCellValuePerFace<const unsigned short> m_face_local_numbers_in_their_cells; WeakEdgeValuePerFace<const unsigned short> m_face_local_numbers_in_their_edges; diff --git a/src/mesh/ConnectivityComputer.cpp b/src/mesh/ConnectivityComputer.cpp index e08a638d7..3c4d1714f 100644 --- a/src/mesh/ConnectivityComputer.cpp +++ b/src/mesh/ConnectivityComputer.cpp @@ -45,7 +45,7 @@ ConnectivityMatrix ConnectivityComputer::_computeInverse(const ConnectivityMatrix& item_to_child_matrix) const { std::map<unsigned int, std::vector<unsigned int>> child_to_item_vector_map; - const size_t& number_of_items = item_to_child_matrix.numRows(); + const size_t& number_of_items = item_to_child_matrix.numberOfRows(); for (unsigned int j = 0; j < number_of_items; ++j) { const auto& item_to_child = item_to_child_matrix[j]; diff --git a/src/mesh/ConnectivityMatrix.hpp b/src/mesh/ConnectivityMatrix.hpp index 11df5978b..e51ba1892 100644 --- a/src/mesh/ConnectivityMatrix.hpp +++ b/src/mesh/ConnectivityMatrix.hpp @@ -6,9 +6,10 @@ class ConnectivityMatrix { - private: + public: using IndexType = uint32_t; + private: Array<const IndexType> m_row_map; Array<const IndexType> m_column_indices; @@ -22,7 +23,7 @@ class ConnectivityMatrix } const Array<const IndexType>& - entries() const + values() const { return m_column_indices; } @@ -35,14 +36,14 @@ class ConnectivityMatrix PUGS_INLINE size_t - numEntries() const + numberOfValues() const { return m_column_indices.size(); } PUGS_INLINE size_t - numRows() const + numberOfRows() const { return m_row_map.size() - 1; } diff --git a/src/mesh/ItemId.hpp b/src/mesh/ItemId.hpp index e62fe7bae..4d7d67143 100644 --- a/src/mesh/ItemId.hpp +++ b/src/mesh/ItemId.hpp @@ -9,7 +9,7 @@ template <ItemType item_type> class ItemIdT { public: - using base_type = unsigned int; + using base_type = uint32_t; private: base_type m_id; diff --git a/src/mesh/ItemToItemMatrix.hpp b/src/mesh/ItemToItemMatrix.hpp index acee8ecd8..8ee4e9d74 100644 --- a/src/mesh/ItemToItemMatrix.hpp +++ b/src/mesh/ItemToItemMatrix.hpp @@ -15,12 +15,13 @@ class ItemToItemMatrix using SourceItemId = ItemIdT<SourceItemType>; using TargetItemId = ItemIdT<TargetItemType>; - class SubItemList + class UnsafeSubItemArray { private: - const ConnectivityMatrix& m_connectivity_matrix; - SourceItemId m_source_item_id; - size_t m_size; + using IndexType = typename ConnectivityMatrix::IndexType; + + const IndexType* const m_values; + const size_t m_size; public: PUGS_INLINE @@ -34,31 +35,23 @@ class ItemToItemMatrix operator[](size_t j) const { Assert(j < m_size); - return m_connectivity_matrix.entries()[m_connectivity_matrix.rowsMap()[m_source_item_id] + j]; + return m_values[j]; } PUGS_INLINE - SubItemList(const ConnectivityMatrix& connectivity_matrix, SourceItemId source_item_id) - : m_connectivity_matrix{connectivity_matrix}, - m_source_item_id(source_item_id), - m_size(m_connectivity_matrix.rowsMap()[m_source_item_id + 1] - - m_connectivity_matrix.rowsMap()[m_source_item_id]) + UnsafeSubItemArray(const ConnectivityMatrix& connectivity_matrix, SourceItemId source_item_id) + : m_values{&(connectivity_matrix.values()[connectivity_matrix.rowsMap()[source_item_id]])}, + m_size(connectivity_matrix.rowsMap()[source_item_id + 1] - connectivity_matrix.rowsMap()[source_item_id]) {} PUGS_INLINE - SubItemList& operator=(const SubItemList&) = default; - - PUGS_INLINE - SubItemList& operator=(SubItemList&&) = default; - - PUGS_INLINE - SubItemList(const SubItemList&) = default; + UnsafeSubItemArray& operator=(const UnsafeSubItemArray&) = delete; PUGS_INLINE - SubItemList(SubItemList&&) = default; + UnsafeSubItemArray(const UnsafeSubItemArray&) = delete; PUGS_INLINE - ~SubItemList() = default; + ~UnsafeSubItemArray() = default; }; private: @@ -66,17 +59,17 @@ class ItemToItemMatrix public: auto - entries() const + values() const { - return m_connectivity_matrix.entries(); + return m_connectivity_matrix.values(); } PUGS_INLINE auto operator[](const SourceItemId& source_id) const { - Assert(source_id < m_connectivity_matrix.numRows()); - return SubItemList(m_connectivity_matrix, source_id); + Assert(source_id < m_connectivity_matrix.numberOfRows()); + return UnsafeSubItemArray(m_connectivity_matrix, source_id); } template <typename IndexType> diff --git a/src/mesh/SubItemArrayPerItem.hpp b/src/mesh/SubItemArrayPerItem.hpp index cb88e85d7..96a8edb56 100644 --- a/src/mesh/SubItemArrayPerItem.hpp +++ b/src/mesh/SubItemArrayPerItem.hpp @@ -200,7 +200,7 @@ class SubItemArrayPerItem ConnectivityMatrix connectivity_matrix = connectivity._getMatrix(item_type, sub_item_type); m_row_map = connectivity_matrix.rowsMap(); - m_values = Table<std::remove_const_t<DataType>>(connectivity_matrix.numEntries(), size_of_arrays); + m_values = Table<std::remove_const_t<DataType>>(connectivity_matrix.numberOfValues(), size_of_arrays); } ~SubItemArrayPerItem() = default; diff --git a/src/mesh/SubItemValuePerItem.hpp b/src/mesh/SubItemValuePerItem.hpp index 2b6ad9460..820117656 100644 --- a/src/mesh/SubItemValuePerItem.hpp +++ b/src/mesh/SubItemValuePerItem.hpp @@ -195,7 +195,7 @@ class SubItemValuePerItem ConnectivityMatrix connectivity_matrix = connectivity._getMatrix(item_type, sub_item_type); m_row_map = connectivity_matrix.rowsMap(); - m_values = Array<std::remove_const_t<DataType>>(connectivity_matrix.numEntries()); + m_values = Array<std::remove_const_t<DataType>>(connectivity_matrix.numberOfValues()); } ~SubItemValuePerItem() = default; diff --git a/src/output/VTKWriter.cpp b/src/output/VTKWriter.cpp index 5e8b84f95..98173a140 100644 --- a/src/output/VTKWriter.cpp +++ b/src/output/VTKWriter.cpp @@ -456,7 +456,7 @@ VTKWriter::_write(const std::shared_ptr<const MeshType>& mesh, { const auto& cell_to_node_matrix = mesh->connectivity().cellToNodeMatrix(); - _write_array(fout, "connectivity", cell_to_node_matrix.entries(), serialize_data_list); + _write_array(fout, "connectivity", cell_to_node_matrix.values(), serialize_data_list); } { -- GitLab