diff --git a/src/mesh/ConnectivityDispatcher.cpp b/src/mesh/ConnectivityDispatcher.cpp index d7fd7370785b7addef61ceeead352bcfeb9cf922..69d97399d5b0bb5533758f94593f2703ce8bfcb9 100644 --- a/src/mesh/ConnectivityDispatcher.cpp +++ b/src/mesh/ConnectivityDispatcher.cpp @@ -1,7 +1,7 @@ #include <ConnectivityDispatcher.hpp> #include <Partitioner.hpp> -#include <SubItemOfItemType.hpp> +#include <ItemOfItemType.hpp> #include <unordered_map> @@ -168,19 +168,19 @@ _buildCellNumberIdMap() } template <int Dimension> -template <typename SubItemOfItemT> +template <typename ItemOfItemT> void ConnectivityDispatcher<Dimension>:: -_buildSubItemNumberIdMapAs(const std::vector<Array<const int>>& recv_cell_sub_item_number_by_proc) +_buildSubItemNumberToIdMap(const std::vector<Array<const int>>& recv_cell_sub_item_number_by_proc) { - static_assert(SubItemOfItemT::item_type == ItemType::cell, "Dispatcher requires to be build using cell as master entities"); + static_assert(ItemOfItemT::item_type == ItemType::cell, "Dispatcher requires to be build using cell as master entities"); - auto& sub_item_number_id_map = this->_dispatchedInfo<SubItemOfItemT::sub_item_type>().m_number_to_id_map; + auto& sub_item_number_id_map = this->_dispatchedInfo<ItemOfItemT::sub_item_type>().m_number_to_id_map; for (size_t i_rank=0; i_rank<parallel::size(); ++i_rank) { int sub_item_id=0; for (size_t i=0; i<recv_cell_sub_item_number_by_proc[i_rank].size(); ++i) { - int node_number = recv_cell_sub_item_number_by_proc[i_rank][i]; - auto [iterator, inserted] = sub_item_number_id_map.insert(std::make_pair(node_number, sub_item_id)); + int sub_item_number = recv_cell_sub_item_number_by_proc[i_rank][i]; + auto [iterator, inserted] = sub_item_number_id_map.insert(std::make_pair(sub_item_number, sub_item_id)); if (inserted) sub_item_id++; } } @@ -305,12 +305,12 @@ ConnectivityDispatcher<Dimension>::_dispatchFaces() { if constexpr (Dimension>1) { std::vector<Array<const int>> recv_number_of_face_per_cell_by_proc = - _getRecvNumberOfSubItemPerItemByProc<SubFaceOfCell>(); + _getRecvNumberOfSubItemPerItemByProc<FaceOfCell>(); std::vector<Array<const int>> recv_cell_face_numbering_by_proc - = this->_getRecvItemSubItemNumberingByProc<SubFaceOfCell>(recv_number_of_face_per_cell_by_proc); + = this->_getRecvItemSubItemNumberingByProc<FaceOfCell>(recv_number_of_face_per_cell_by_proc); - this->_buildSubItemNumberIdMapAs<SubFaceOfCell>(recv_cell_face_numbering_by_proc); + this->_buildSubItemNumberToIdMap<FaceOfCell>(recv_cell_face_numbering_by_proc); const std::unordered_map<int, int>& face_number_id_map = this->_dispatchedInfo<ItemType::face>().m_number_to_id_map; @@ -328,7 +328,6 @@ ConnectivityDispatcher<Dimension>::_dispatchFaces() this->_buildRecvItemIdCorrespondanceByProc<ItemType::face>(); this->_gatherFrom(m_connectivity.template number<ItemType::face>(), m_new_descriptor.face_number_vector); - { const auto& cell_list_to_recv_size_by_proc = this->_dispatchedInfo<ItemType::cell>().m_list_to_recv_size_by_proc; @@ -392,10 +391,10 @@ ConnectivityDispatcher<Dimension>::_dispatchFaces() this->_gatherFrom(this->_dispatchedInfo<ItemType::face>().m_new_owner, m_new_descriptor.face_owner_vector); std::vector<Array<const int>> recv_number_of_node_per_face_by_proc = - _getRecvNumberOfSubItemPerItemByProc<SubNodeOfFace>(); + _getRecvNumberOfSubItemPerItemByProc<NodeOfFace>(); std::vector<Array<const int>> recv_face_node_numbering_by_proc - = this->_getRecvItemSubItemNumberingByProc<SubNodeOfFace>(recv_number_of_node_per_face_by_proc); + = this->_getRecvItemSubItemNumberingByProc<NodeOfFace>(recv_number_of_node_per_face_by_proc); { const auto& node_number_id_map = this->_dispatchedInfo<ItemType::node>().m_number_to_id_map; @@ -589,15 +588,15 @@ ConnectivityDispatcher<Dimension>::ConnectivityDispatcher(const ConnectivityType this->_buildCellNumberIdMap(); const std::vector<Array<const int>> recv_number_of_node_per_cell_by_proc - = this->_getRecvNumberOfSubItemPerItemByProc<SubNodeOfCell>(); + = this->_getRecvNumberOfSubItemPerItemByProc<NodeOfCell>(); const std::vector<Array<const int>> recv_cell_node_numbering_by_proc - = this->_getRecvItemSubItemNumberingByProc<SubNodeOfCell>(recv_number_of_node_per_cell_by_proc); + = this->_getRecvItemSubItemNumberingByProc<NodeOfCell>(recv_number_of_node_per_cell_by_proc); this->_buildRecvItemIdCorrespondanceByProc<ItemType::cell>(); this->_gatherFrom(m_connectivity.template number<ItemType::cell>(), m_new_descriptor.cell_number_vector); - this->_buildSubItemNumberIdMapAs<SubNodeOfCell>(recv_cell_node_numbering_by_proc); + this->_buildSubItemNumberToIdMap<NodeOfCell>(recv_cell_node_numbering_by_proc); this->_buildItemListToSend<ItemType::node>(); Array<unsigned int> nb_node_to_send_by_proc(parallel::size()); diff --git a/src/mesh/ConnectivityDispatcher.hpp b/src/mesh/ConnectivityDispatcher.hpp index 16a6b73ccd89bf15e70950e64d7ee8b72021e75a..947821f08c4f7c070d3919651567bb0c60210047 100644 --- a/src/mesh/ConnectivityDispatcher.hpp +++ b/src/mesh/ConnectivityDispatcher.hpp @@ -75,8 +75,8 @@ class ConnectivityDispatcher void _buildCellNumberIdMap(); - template <typename SubItemOfItemT> - void _buildSubItemNumberIdMapAs(const std::vector<Array<const int>>& recv_cell_node_number_by_proc); + template <typename ItemOfItemT> + void _buildSubItemNumberToIdMap(const std::vector<Array<const int>>& recv_cell_node_number_by_proc); void _dispatchFaces(); diff --git a/src/mesh/ItemOfItemType.hpp b/src/mesh/ItemOfItemType.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ce588bb9a786fd01344a569178c151693ba299d4 --- /dev/null +++ b/src/mesh/ItemOfItemType.hpp @@ -0,0 +1,33 @@ +#ifndef ITEM_OF_ITEM_TYPE_HPP +#define ITEM_OF_ITEM_TYPE_HPP + +#include <ItemType.hpp> + +#warning Should use this type in all sub item constructions +template <ItemType sub_item_t, + ItemType item_t> +struct ItemOfItemType +{ + static_assert(sub_item_t != item_t, "item and its sub-item cannot be of same type"); + + constexpr static ItemType sub_item_type = sub_item_t; + constexpr static ItemType item_type = item_t; +}; + +using FaceOfCell = ItemOfItemType<ItemType::face, ItemType::cell>; +using EdgeOfCell = ItemOfItemType<ItemType::edge, ItemType::cell>; +using NodeOfCell = ItemOfItemType<ItemType::node, ItemType::cell>; + +using CellofFace = ItemOfItemType<ItemType::cell, ItemType::face>; +using EdgeOfFace = ItemOfItemType<ItemType::edge, ItemType::face>; +using NodeOfFace = ItemOfItemType<ItemType::node, ItemType::face>; + +using CellofEdge = ItemOfItemType<ItemType::cell, ItemType::edge>; +using FaceOfEdge = ItemOfItemType<ItemType::face, ItemType::edge>; +using NodeOfEdge = ItemOfItemType<ItemType::node, ItemType::edge>; + +using CellofNode = ItemOfItemType<ItemType::cell, ItemType::node>; +using FaceOfNode = ItemOfItemType<ItemType::face, ItemType::node>; +using EdgeOfNode = ItemOfItemType<ItemType::edge, ItemType::node>; + +#endif // ITEM_OF_ITEM_TYPE_HPP diff --git a/src/mesh/SubItemOfItemType.hpp b/src/mesh/SubItemOfItemType.hpp deleted file mode 100644 index c2c8f267af4c9e782d6c15e3a28980936d7bb6b2..0000000000000000000000000000000000000000 --- a/src/mesh/SubItemOfItemType.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef SUB_ITEM_OF_ITEM_TYPE_HPP -#define SUB_ITEM_OF_ITEM_TYPE_HPP - -#include <ItemType.hpp> - -#warning Should use this type in all sub item constructions -template <ItemType sub_item_t, - ItemType item_t> -struct SubItemOfItemType -{ - static_assert(sub_item_t != item_t, "item and its sub-item cannot be of same type"); - - constexpr static ItemType sub_item_type = sub_item_t; - constexpr static ItemType item_type = item_t; -}; - -using SubFaceOfCell = SubItemOfItemType<ItemType::face, ItemType::cell>; -using SubEdgeOfCell = SubItemOfItemType<ItemType::edge, ItemType::cell>; -using SubNodeOfCell = SubItemOfItemType<ItemType::node, ItemType::cell>; - -using SubCellofFace = SubItemOfItemType<ItemType::cell, ItemType::face>; -using SubEdgeOfFace = SubItemOfItemType<ItemType::edge, ItemType::face>; -using SubNodeOfFace = SubItemOfItemType<ItemType::node, ItemType::face>; - -using SubCellofEdge = SubItemOfItemType<ItemType::cell, ItemType::edge>; -using SubFaceOfEdge = SubItemOfItemType<ItemType::face, ItemType::edge>; -using SubNodeOfEdge = SubItemOfItemType<ItemType::node, ItemType::edge>; - -using SubCellofNode = SubItemOfItemType<ItemType::cell, ItemType::node>; -using SubFaceOfNode = SubItemOfItemType<ItemType::face, ItemType::node>; -using SubEdgeOfNode = SubItemOfItemType<ItemType::edge, ItemType::node>; - -#endif // SUB_ITEM_OF_ITEM_TYPE_HPP