diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index 27d5e248970fc46d63267f35a08fd4b41165dcde..bd80214032c8b0de69c00527f76feee13f432618 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -7,6 +7,8 @@ #include <PastisOStream.hpp> #include <PastisUtils.hpp> +#include <PastisTraits.hpp> + #include <TinyVector.hpp> #include <ItemValue.hpp> @@ -50,6 +52,20 @@ class ConnectivityDescriptor // std::vector<std::vector<unsigned int>> face_to_cell_vector; std::vector<std::vector<unsigned int>> face_to_node_vector; + template <typename ItemOfItemT> + auto& itemOfItemVector() + { + if constexpr (std::is_same_v<ItemOfItemT,NodeOfCell>) { + return cell_by_node_vector; + } else if constexpr (std::is_same_v<ItemOfItemT,FaceOfCell>) { + return cell_to_face_vector; + } else if constexpr (std::is_same_v<ItemOfItemT,NodeOfCell>) { + return face_to_node_vector; + } else { + static_assert(is_false_v<ItemOfItemT>, "Unexpected item of item type"); + } + } + std::vector<Array<bool>> cell_face_is_reversed_vector; std::vector<CellType> cell_type_vector; @@ -228,8 +244,7 @@ class Connectivity final } else if constexpr(item_type == ItemType::node) { return m_node_number; } else { - static_assert(item_type == ItemType::cell, "unknown ItemType"); - return m_cell_number; + static_assert(is_false_item_type_v<item_type>, "unknown ItemType"); } } @@ -272,8 +287,7 @@ class Connectivity final } else if constexpr(item_type == ItemType::node) { return m_node_owner; } else { - static_assert(item_type == ItemType::cell, "unknown ItemType"); - return m_cell_owner; + static_assert(is_false_item_type_v<item_type>, "unknown ItemType"); } } @@ -316,8 +330,7 @@ class Connectivity final } else if constexpr(item_type == ItemType::node) { return m_node_is_owned; } else { - static_assert(item_type == ItemType::cell, "unknown ItemType"); - return m_cell_is_owned; + static_assert(is_false_item_type_v<item_type>, "unknown ItemType"); } } diff --git a/src/mesh/ConnectivityDispatcher.cpp b/src/mesh/ConnectivityDispatcher.cpp index f31fd9e6a645f09fc2c03fbfb29e3bac606e9c5e..b16f6bd7d7eb2a0809c6b62089974e35db0763fe 100644 --- a/src/mesh/ConnectivityDispatcher.cpp +++ b/src/mesh/ConnectivityDispatcher.cpp @@ -226,7 +226,7 @@ void ConnectivityDispatcher<Dimension>:: _buildSubItemNumberToIdMap(const std::vector<Array<const int>>& recv_cell_sub_item_number_by_proc) { - static_assert(ItemOfItemT::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 built using cell as master entities"); 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) { @@ -408,13 +408,13 @@ 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<NodeOfFace>(); + { + std::vector<Array<const int>> recv_number_of_node_per_face_by_proc = + _getRecvNumberOfSubItemPerItemByProc<NodeOfFace>(); - std::vector<Array<const int>> recv_face_node_numbering_by_proc - = this->_getRecvItemSubItemNumberingByProc<NodeOfFace>(recv_number_of_node_per_face_by_proc); + std::vector<Array<const int>> recv_face_node_numbering_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; for (size_t i_rank=0; i_rank < parallel::size(); ++i_rank) { int l=0; diff --git a/src/mesh/ConnectivityDispatcher.hpp b/src/mesh/ConnectivityDispatcher.hpp index b4becdf236266b5eb9887d8f6af9dad0768c4762..43dd2e75f023d5dad74226ab0b38a1fcf49dbb06 100644 --- a/src/mesh/ConnectivityDispatcher.hpp +++ b/src/mesh/ConnectivityDispatcher.hpp @@ -116,8 +116,7 @@ class ConnectivityDispatcher } else if constexpr (std::is_same_v<CellOfNode, ItemOfItem>) { return m_dispatched_cell_of_node_info; } else { - static_assert(std::is_same_v<NodeOfCell, ItemOfItem>, - "Unexpected ItemOfItem type"); + static_assert(is_false_v<ItemOfItem>, "Unexpected ItemOfItem type"); } } @@ -150,8 +149,7 @@ class ConnectivityDispatcher } else if constexpr (std::is_same_v<CellOfNode, ItemOfItem>) { return m_dispatched_cell_of_node_info; } else { - static_assert(std::is_same_v<NodeOfCell, ItemOfItem>, - "Unexpected ItemOfItem type"); + static_assert(is_false_v<ItemOfItem>, "Unexpected ItemOfItem type"); } } diff --git a/src/mesh/ItemToItemMatrix.hpp b/src/mesh/ItemToItemMatrix.hpp index d10aa5ac11e33c95aa54012828944c45a34024c1..bf62537d33b805aee07fddd9e886aa2ed48a922c 100644 --- a/src/mesh/ItemToItemMatrix.hpp +++ b/src/mesh/ItemToItemMatrix.hpp @@ -83,7 +83,7 @@ class ItemToItemMatrix PASTIS_INLINE const auto& operator[](const IndexType& source_id) const { - static_assert(std::is_same<IndexType, SourceItemId>(), + static_assert(std::is_same_v<IndexType, SourceItemId>, "ItemToItemMatrix must be indexed using correct ItemId"); using RowType = decltype(m_connectivity_matrix.rowConst(source_id)); return SubItemList<RowType>(m_connectivity_matrix.rowConst(source_id)); diff --git a/src/mesh/ItemType.hpp b/src/mesh/ItemType.hpp index 1b5f3cb452e898dc957ff7f96fb07c4955312f16..e9de6153098342eeaa0306e3754fd8b03e45644c 100644 --- a/src/mesh/ItemType.hpp +++ b/src/mesh/ItemType.hpp @@ -118,4 +118,8 @@ struct ItemTypeId<3> } }; +template <ItemType item_type> +PASTIS_INLINE +constexpr bool is_false_item_type_v = false; + #endif // ITEM_TYPE_HPP diff --git a/src/utils/Messenger.hpp b/src/utils/Messenger.hpp index 1e32874a7c0e2302aeffac02c9ee2855516bae59..163489cc5ec9118c2c63dbafdb01cfc09030ce35 100644 --- a/src/utils/Messenger.hpp +++ b/src/utils/Messenger.hpp @@ -37,7 +37,7 @@ class Messenger } else { static_assert(std::is_arithmetic_v<DataType>, "Unexpected arithmetic type! Should not occur!"); - static_assert(not std::is_arithmetic_v<DataType>, + static_assert(is_false_v<DataType>, "MPI_Datatype are only defined for arithmetic types!"); return MPI_Datatype(); } @@ -379,7 +379,7 @@ class Messenger _allGather(cast_value_array, cast_gather_array); } else { - static_assert(is_trivially_castable<DataType>, "unexpected type of data"); + static_assert(is_false_v<DataType>, "unexpected type of data"); } return gather_array; } @@ -403,7 +403,7 @@ class Messenger _allGather(cast_array, cast_gather_array); } else { - static_assert(is_trivially_castable<DataType>, "unexpected type of data"); + static_assert(is_false_v<DataType>, "unexpected type of data"); } return gather_array; } @@ -432,7 +432,7 @@ class Messenger auto recv_cast_array = cast_array_to<CastType>::from(recv_array); _allToAll(send_cast_array, recv_cast_array); } else { - static_assert(is_trivially_castable<DataType>, "unexpected type of data"); + static_assert(is_false_v<DataType>, "unexpected type of data"); } return recv_array; } @@ -455,8 +455,7 @@ class Messenger _broadcast_array(cast_array, root_rank); } } else { - static_assert(is_trivially_castable<DataType>, - "unexpected non trivial type of data"); + static_assert(is_false_v<DataType>, "unexpected type of data"); } } @@ -485,8 +484,7 @@ class Messenger auto cast_array = cast_array_to<CastType>::from(array); _broadcast_array(cast_array, root_rank); } else{ - static_assert(is_trivially_castable<DataType>, - "unexpected non trivial type of data"); + static_assert(is_false_v<DataType>, "unexpected type of data"); } } @@ -523,8 +521,7 @@ class Messenger using CastType = helper::split_cast_t<DataType>; _exchange_through_cast<SendDataType, CastType>(send_array_list, recv_array_list); } else { - static_assert(is_trivially_castable<RecvDataType>, - "unexpected non trivial type of data"); + static_assert(is_false_v<RecvDataType>, "unexpected type of data"); } } diff --git a/src/utils/Partitioner.cpp b/src/utils/Partitioner.cpp index 77839a25c4d2fd91110bcb286dfb17c228024e9a..c1da28a49e5b477870a0e0cb32fb15a4b4500770 100644 --- a/src/utils/Partitioner.cpp +++ b/src/utils/Partitioner.cpp @@ -60,8 +60,6 @@ Array<int> Partitioner::partition(const CSRGraph& graph) part = Array<int>(local_number_of_nodes); std::vector<int> vtxdist{0,local_number_of_nodes}; - static_assert(std::is_same<int, int>()); - const Array<int>& entries = graph.entries(); const Array<int>& neighbors = graph.neighbors(); diff --git a/src/utils/PastisTraits.hpp b/src/utils/PastisTraits.hpp index 4f7877ac9716662363c7b0e1d8051fd78eaec2ac..871e30fd1c471ec67841b156ab89a624a41194b6 100644 --- a/src/utils/PastisTraits.hpp +++ b/src/utils/PastisTraits.hpp @@ -19,4 +19,7 @@ inline constexpr bool is_trivially_castable<TinyMatrix<N,T>> = is_trivially_cast template <size_t N, typename T> inline constexpr bool is_trivially_castable<const TinyMatrix<N,T>> = is_trivially_castable<T>; +template <typename T> +inline constexpr bool is_false_v = false; + #endif // PASTIS_TRAITS_HPP