From 6a6b92d0ba592495ff9f85def5fbe0afecb417c2 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 8 Aug 2018 10:05:54 +0200 Subject: [PATCH] Rename TypeOfitem to ItemType --- src/mesh/Connectivity.cpp | 30 +++++----- src/mesh/Connectivity.hpp | 14 ++--- src/mesh/ConnectivityComputer.cpp | 58 +++++++++---------- src/mesh/ConnectivityComputer.hpp | 4 +- src/mesh/ConnectivityUtils.hpp | 6 +- src/mesh/IConnectivity.hpp | 6 +- src/mesh/ItemType.hpp | 92 +++++++++++++++++++++++++++++++ src/mesh/MeshData.hpp | 28 +++++----- src/mesh/MeshNodeBoundary.hpp | 32 +++++------ src/mesh/SubItemValuePerItem.hpp | 18 +++--- src/mesh/TypeOfItem.hpp | 76 ------------------------- src/output/VTKWriter.hpp | 4 +- src/scheme/AcousticSolver.hpp | 20 +++---- 13 files changed, 202 insertions(+), 186 deletions(-) create mode 100644 src/mesh/ItemType.hpp delete mode 100644 src/mesh/TypeOfItem.hpp diff --git a/src/mesh/Connectivity.cpp b/src/mesh/Connectivity.cpp index c52dab206..fedd33746 100644 --- a/src/mesh/Connectivity.cpp +++ b/src/mesh/Connectivity.cpp @@ -9,7 +9,7 @@ void Connectivity<3>::_computeFaceCellConnectivities() typedef std::tuple<unsigned int, unsigned short, bool> CellFaceInfo; const auto& cell_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::cell)][itemId(ItemType::node)]; std::map<Face, std::vector<CellFaceInfo>> face_cells_map; for (unsigned int j=0; j<this->numberOfCells(); ++j) { @@ -98,7 +98,7 @@ void Connectivity<3>::_computeFaceCellConnectivities() { auto& cell_to_face_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::face)]; + = m_item_to_item_matrix[itemId(ItemType::cell)][itemId(ItemType::face)]; std::vector<std::vector<unsigned int>> cell_to_face_vector(this->numberOfCells()); for (size_t j=0; j<cell_to_face_vector.size(); ++j) { cell_to_face_vector[j].resize(cell_nb_faces[j]); @@ -130,7 +130,7 @@ void Connectivity<3>::_computeFaceCellConnectivities() { auto& face_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::face)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::face)][itemId(ItemType::node)]; std::vector<std::vector<unsigned int>> face_to_node_vector(face_cells_map.size()); int l=0; @@ -152,18 +152,18 @@ void Connectivity<3>::_computeFaceCellConnectivities() } const auto& cell_to_face_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::face)]; + = m_item_to_item_matrix[itemId(ItemType::cell)][itemId(ItemType::face)]; auto& face_to_cell_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::face)][itemId(TypeOfItem::cell)]; + = m_item_to_item_matrix[itemId(ItemType::face)][itemId(ItemType::cell)]; m_connectivity_computer.computeInverseConnectivityMatrix(cell_to_face_matrix, face_to_cell_matrix); m_face_to_cell_local_face - = m_connectivity_computer.computeLocalItemNumberInChildItem<TypeOfItem::face, - TypeOfItem::cell>(*this); + = m_connectivity_computer.computeLocalItemNumberInChildItem<ItemType::face, + ItemType::cell>(*this); const auto& face_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::face)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::face)][itemId(ItemType::node)]; #warning check that the number of cell per faces is <=2 std::unordered_map<unsigned int, std::vector<unsigned int>> node_faces_map; @@ -197,7 +197,7 @@ template<> void Connectivity<2>::_computeFaceCellConnectivities() { const auto& cell_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::cell)][itemId(ItemType::node)]; // In 2D faces are simply define typedef std::pair<unsigned int, unsigned short> CellFaceId; @@ -232,7 +232,7 @@ void Connectivity<2>::_computeFaceCellConnectivities() ++l; } auto& face_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::face)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::face)][itemId(ItemType::node)]; face_to_node_matrix = face_to_node_vector; } @@ -247,7 +247,7 @@ void Connectivity<2>::_computeFaceCellConnectivities() ++l; } auto& face_to_cell_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::face)][itemId(TypeOfItem::cell)]; + = m_item_to_item_matrix[itemId(ItemType::face)][itemId(ItemType::cell)]; face_to_cell_matrix = face_to_cell_vector; } } @@ -258,7 +258,7 @@ Connectivity<Dimension>:: Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector) { auto& cell_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::cell)][itemId(ItemType::node)]; cell_to_node_matrix = cell_by_node_vector; Assert(this->numberOfCells()>0); @@ -273,16 +273,16 @@ Connectivity(const std::vector<std::vector<unsigned int>>& cell_by_node_vector) } auto& node_to_cell_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::node)][itemId(TypeOfItem::cell)]; + = m_item_to_item_matrix[itemId(ItemType::node)][itemId(ItemType::cell)]; m_connectivity_computer.computeInverseConnectivityMatrix(cell_to_node_matrix, node_to_cell_matrix); m_node_to_cell_local_node - = m_connectivity_computer.computeLocalItemNumberInChildItem<TypeOfItem::node, TypeOfItem::cell>(*this); + = m_connectivity_computer.computeLocalItemNumberInChildItem<ItemType::node, ItemType::cell>(*this); m_cell_to_node_local_cell - = m_connectivity_computer.computeLocalItemNumberInChildItem<TypeOfItem::cell, TypeOfItem::node>(*this); + = m_connectivity_computer.computeLocalItemNumberInChildItem<ItemType::cell, ItemType::node>(*this); if constexpr (Dimension>1) { this->_computeFaceCellConnectivities(); diff --git a/src/mesh/Connectivity.hpp b/src/mesh/Connectivity.hpp index dc30bf950..0bb4501ca 100644 --- a/src/mesh/Connectivity.hpp +++ b/src/mesh/Connectivity.hpp @@ -17,7 +17,7 @@ #include <algorithm> #include <RefId.hpp> -#include <TypeOfItem.hpp> +#include <ItemType.hpp> #include <RefNodeList.hpp> #include <RefFaceList.hpp> @@ -230,14 +230,14 @@ class Connectivity final public: static constexpr size_t dimension = Dimension; - template <TypeOfItem item_type_0, TypeOfItem item_type_1> + template <ItemType item_type_0, ItemType item_type_1> const ConnectivityMatrix& itemToItemMatrix() const { return m_item_to_item_matrix[itemId(item_type_0)][itemId(item_type_1)]; }; - const ConnectivityMatrix& getMatrix(const TypeOfItem& item_type_0, - const TypeOfItem& item_type_1) const + const ConnectivityMatrix& getMatrix(const ItemType& item_type_0, + const ItemType& item_type_1) const { return m_item_to_item_matrix[itemId(item_type_0)][itemId(item_type_1)]; } @@ -343,7 +343,7 @@ private: size_t numberOfNodes() const { const auto& node_to_cell_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::node)][itemId(TypeOfItem::cell)]; + = m_item_to_item_matrix[itemId(ItemType::node)][itemId(ItemType::cell)]; return node_to_cell_matrix.numRows(); } @@ -351,7 +351,7 @@ private: size_t numberOfFaces() const { const auto& face_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::face)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::face)][itemId(ItemType::node)]; return face_to_node_matrix.numRows(); } @@ -359,7 +359,7 @@ private: size_t numberOfCells() const { const auto& cell_to_node_matrix - = m_item_to_item_matrix[itemId(TypeOfItem::cell)][itemId(TypeOfItem::node)]; + = m_item_to_item_matrix[itemId(ItemType::cell)][itemId(ItemType::node)]; return cell_to_node_matrix.numRows(); } diff --git a/src/mesh/ConnectivityComputer.cpp b/src/mesh/ConnectivityComputer.cpp index fea44f9e4..91965f3f9 100644 --- a/src/mesh/ConnectivityComputer.cpp +++ b/src/mesh/ConnectivityComputer.cpp @@ -36,8 +36,8 @@ computeInverseConnectivityMatrix(const ConnectivityMatrix& item_to_child_item_ma child_item_to_item_matrix = child_item_to_items_vector; } -template <TypeOfItem child_item_type, - TypeOfItem item_type, +template <ItemType child_item_type, + ItemType item_type, typename ConnectivityType> SubItemValuePerItem<const unsigned short, item_type, child_item_type> ConnectivityComputer::computeLocalItemNumberInChildItem(const ConnectivityType& connectivity) const @@ -69,52 +69,52 @@ ConnectivityComputer::computeLocalItemNumberInChildItem(const ConnectivityType& // 1D -template SubItemValuePerItem<const unsigned short, TypeOfItem::cell, TypeOfItem::node> +template SubItemValuePerItem<const unsigned short, ItemType::cell, ItemType::node> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::node, - TypeOfItem::cell>(const Connectivity1D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::node, + ItemType::cell>(const Connectivity1D& connectivity) const; -template SubItemValuePerItem<const unsigned short, TypeOfItem::cell, TypeOfItem::face> +template SubItemValuePerItem<const unsigned short, ItemType::cell, ItemType::face> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::face, - TypeOfItem::cell>(const Connectivity1D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::face, + ItemType::cell>(const Connectivity1D& connectivity) const; -template SubItemValuePerItem<const unsigned short, TypeOfItem::node, TypeOfItem::cell> +template SubItemValuePerItem<const unsigned short, ItemType::node, ItemType::cell> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::cell, - TypeOfItem::node>(const Connectivity1D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::cell, + ItemType::node>(const Connectivity1D& connectivity) const; // 2D -template SubItemValuePerItem<const unsigned short, TypeOfItem::cell, TypeOfItem::node> +template SubItemValuePerItem<const unsigned short, ItemType::cell, ItemType::node> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::node, - TypeOfItem::cell>(const Connectivity2D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::node, + ItemType::cell>(const Connectivity2D& connectivity) const; -template SubItemValuePerItem<const unsigned short, TypeOfItem::cell, TypeOfItem::face> +template SubItemValuePerItem<const unsigned short, ItemType::cell, ItemType::face> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::face, - TypeOfItem::cell>(const Connectivity2D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::face, + ItemType::cell>(const Connectivity2D& connectivity) const; -template SubItemValuePerItem<const unsigned short, TypeOfItem::node, TypeOfItem::cell> +template SubItemValuePerItem<const unsigned short, ItemType::node, ItemType::cell> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::cell, - TypeOfItem::node>(const Connectivity2D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::cell, + ItemType::node>(const Connectivity2D& connectivity) const; // 3D -template SubItemValuePerItem<const unsigned short, TypeOfItem::cell, TypeOfItem::node> +template SubItemValuePerItem<const unsigned short, ItemType::cell, ItemType::node> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::node, - TypeOfItem::cell>(const Connectivity3D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::node, + ItemType::cell>(const Connectivity3D& connectivity) const; -template SubItemValuePerItem<const unsigned short, TypeOfItem::cell, TypeOfItem::face> +template SubItemValuePerItem<const unsigned short, ItemType::cell, ItemType::face> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::face, - TypeOfItem::cell>(const Connectivity3D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::face, + ItemType::cell>(const Connectivity3D& connectivity) const; -template SubItemValuePerItem<const unsigned short, TypeOfItem::node, TypeOfItem::cell> +template SubItemValuePerItem<const unsigned short, ItemType::node, ItemType::cell> ConnectivityComputer:: -computeLocalItemNumberInChildItem<TypeOfItem::cell, - TypeOfItem::node>(const Connectivity3D& connectivity) const; +computeLocalItemNumberInChildItem<ItemType::cell, + ItemType::node>(const Connectivity3D& connectivity) const; diff --git a/src/mesh/ConnectivityComputer.hpp b/src/mesh/ConnectivityComputer.hpp index 87dcc0672..cfdf12727 100644 --- a/src/mesh/ConnectivityComputer.hpp +++ b/src/mesh/ConnectivityComputer.hpp @@ -9,8 +9,8 @@ struct ConnectivityComputer void computeInverseConnectivityMatrix(const ConnectivityMatrix& item_to_child_item_matrix, ConnectivityMatrix& child_item_to_item_matrix) const; - template <TypeOfItem child_item_type, - TypeOfItem item_type, + template <ItemType child_item_type, + ItemType item_type, typename ConnectivityType> SubItemValuePerItem<const unsigned short, item_type, child_item_type> computeLocalItemNumberInChildItem(const ConnectivityType& c) const; diff --git a/src/mesh/ConnectivityUtils.hpp b/src/mesh/ConnectivityUtils.hpp index b5fcbb9ac..e073d5521 100644 --- a/src/mesh/ConnectivityUtils.hpp +++ b/src/mesh/ConnectivityUtils.hpp @@ -1,11 +1,11 @@ #ifndef CONNECTIVITY_UTILS_HPP #define CONNECTIVITY_UTILS_HPP -#include <TypeOfItem.hpp> +#include <ItemType.hpp> #include <ConnectivityMatrix.hpp> -template <TypeOfItem item_type_0, - TypeOfItem item_type_1, +template <ItemType item_type_0, + ItemType item_type_1, typename ConnectivityType> inline const ConnectivityMatrix& getConnectivityMatrix(const ConnectivityType& connectivity) diff --git a/src/mesh/IConnectivity.hpp b/src/mesh/IConnectivity.hpp index 40843d70a..49432fdea 100644 --- a/src/mesh/IConnectivity.hpp +++ b/src/mesh/IConnectivity.hpp @@ -1,14 +1,14 @@ #ifndef ICONNECTIVITY_HPP #define ICONNECTIVITY_HPP -#include <TypeOfItem.hpp> +#include <ItemType.hpp> #include <ConnectivityMatrix.hpp> struct IConnectivity { virtual const ConnectivityMatrix& - getMatrix(const TypeOfItem& item_type_0, - const TypeOfItem& item_type_1) const = 0; + getMatrix(const ItemType& item_type_0, + const ItemType& item_type_1) const = 0; IConnectivity() = default; IConnectivity(const IConnectivity&) = delete; diff --git a/src/mesh/ItemType.hpp b/src/mesh/ItemType.hpp new file mode 100644 index 000000000..56d35de3f --- /dev/null +++ b/src/mesh/ItemType.hpp @@ -0,0 +1,92 @@ +#ifndef ITEM_TYPE_HPP +#define ITEM_TYPE_HPP + +#include <utility> +#include <limits> + +enum class ItemType +{ + node = 0, + edge = 1, + face = 2, + cell = 3 +}; + +template <size_t Dimension> +struct ItemId {}; + +template <> +struct ItemId<1> +{ + inline static constexpr size_t itemId(const ItemType& item_type) { + size_t i = std::numeric_limits<size_t>::max(); + switch(item_type) { + case ItemType::cell: { + i=0; + break; + } + case ItemType::face: + case ItemType::edge: + case ItemType::node: { + // in 1d, faces, edges and nodes are the same + i=1; + break; + } + } + return i; + } +}; + +template <> +struct ItemId<2> +{ + inline static constexpr size_t itemId(const ItemType& item_type) { + size_t i = std::numeric_limits<size_t>::max(); + switch(item_type) { + case ItemType::cell: { + i=0; + break; + } + case ItemType::face: + case ItemType::edge: { + // in 2d, faces and edges are the same + i=1; + break; + } + case ItemType::node: { + i=2; + break; + } + } + return i; + } +}; + +template <> +struct ItemId<3> +{ + inline static constexpr size_t itemId(const ItemType& item_type) { + size_t i = std::numeric_limits<size_t>::max(); + switch(item_type) { + case ItemType::cell: { + i=0; + break; + } + case ItemType::face: { + i=1; + break; + } + case ItemType::edge: { + i=2; + break; + } + case ItemType::node: { + i=3; + break; + } + } + return i; + } +}; + +#endif // ITEM_TYPE_HPP diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp index fc7bcf66f..66ba3626a 100644 --- a/src/mesh/MeshData.hpp +++ b/src/mesh/MeshData.hpp @@ -36,8 +36,8 @@ class MeshData const Kokkos::View<const Rd*> xr = m_mesh.xr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ const auto& cell_nodes = cell_to_node_matrix.rowConst(j); @@ -49,8 +49,8 @@ class MeshData = m_mesh.connectivity().invCellNbNodes(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ Rd X = zero; @@ -68,8 +68,8 @@ class MeshData { const Kokkos::View<const Rd*> xr = m_mesh.xr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ double sum_cjr_xr = 0; @@ -90,8 +90,8 @@ class MeshData else if constexpr (dimension == 2) { const Kokkos::View<const Rd*> xr = m_mesh.xr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ const auto& cell_nodes = cell_to_node_matrix.rowConst(j); @@ -118,8 +118,8 @@ class MeshData NodeValuePerFace<Rd> Nlr(m_mesh.connectivity()); const auto& face_to_node_matrix - = getConnectivityMatrix<TypeOfItem::face, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::face, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfFaces(), KOKKOS_LAMBDA(const int& l) { const auto& face_nodes = face_to_node_matrix.rowConst(l); @@ -146,12 +146,12 @@ class MeshData }); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); const auto& cell_to_face_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::face>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::face>(m_mesh.connectivity()); const auto& cell_face_is_reversed = m_mesh.connectivity().cellFaceIsReversed(); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { diff --git a/src/mesh/MeshNodeBoundary.hpp b/src/mesh/MeshNodeBoundary.hpp index a1e3e9562..cf9df04f0 100644 --- a/src/mesh/MeshNodeBoundary.hpp +++ b/src/mesh/MeshNodeBoundary.hpp @@ -32,8 +32,8 @@ class MeshNodeBoundary { static_assert(dimension == MeshType::dimension); const auto& face_to_cell_matrix - = getConnectivityMatrix<TypeOfItem::face, - TypeOfItem::cell>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::face, + ItemType::cell>(mesh.connectivity()); const Kokkos::View<const unsigned int*>& face_list = ref_face_list.faceList(); Kokkos::parallel_for(face_list.extent(0), KOKKOS_LAMBDA(const int& l){ @@ -48,8 +48,8 @@ class MeshNodeBoundary // not enough but should reduce significantly the number of resizing node_ids.reserve(dimension*face_list.extent(0)); const auto& face_to_node_matrix - = getConnectivityMatrix<TypeOfItem::face, - TypeOfItem::node>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::face, + ItemType::node>(mesh.connectivity()); for (size_t l=0; l<face_list.extent(0); ++l) { const size_t face_number = face_list[l]; @@ -317,12 +317,12 @@ _getOutgoingNormal(const MeshType& mesh) const Kokkos::View<const R*>& xr = mesh.xr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(mesh.connectivity()); const auto& node_to_cell_matrix - = getConnectivityMatrix<TypeOfItem::node, - TypeOfItem::cell>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::node, + ItemType::cell>(mesh.connectivity()); const size_t r0 = m_node_list[0]; const size_t j0 = node_to_cell_matrix.rowConst(r0)(0); @@ -354,12 +354,12 @@ _getOutgoingNormal(const MeshType& mesh) const Kokkos::View<const R2*>& xr = mesh.xr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(mesh.connectivity()); const auto& node_to_cell_matrix - = getConnectivityMatrix<TypeOfItem::node, - TypeOfItem::cell>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::node, + ItemType::cell>(mesh.connectivity()); const size_t r0 = m_node_list[0]; const size_t j0 = node_to_cell_matrix.rowConst(r0)(0); @@ -391,12 +391,12 @@ _getOutgoingNormal(const MeshType& mesh) const Kokkos::View<const R3*>& xr = mesh.xr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(mesh.connectivity()); const auto& node_to_cell_matrix - = getConnectivityMatrix<TypeOfItem::node, - TypeOfItem::cell>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::node, + ItemType::cell>(mesh.connectivity()); const size_t r0 = m_node_list[0]; const size_t j0 = node_to_cell_matrix.rowConst(r0)(0); diff --git a/src/mesh/SubItemValuePerItem.hpp b/src/mesh/SubItemValuePerItem.hpp index c57830628..c2669e95b 100644 --- a/src/mesh/SubItemValuePerItem.hpp +++ b/src/mesh/SubItemValuePerItem.hpp @@ -2,7 +2,7 @@ #define SUBITEM_VALUE_PER_ITEM_HPP #include <Kokkos_StaticCrsGraph.hpp> -#include <TypeOfItem.hpp> +#include <ItemType.hpp> #include <PastisAssert.hpp> #include <ConnectivityMatrix.hpp> @@ -10,8 +10,8 @@ #include <ConnectivityUtils.hpp> template <typename DataType, - TypeOfItem SubItemType, - TypeOfItem ItemType> + ItemType SubItemType, + ItemType ItemType> class SubItemValuePerItem { private: @@ -168,21 +168,21 @@ class SubItemValuePerItem }; template <typename DataType> -using NodeValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::cell>; +using NodeValuePerCell = SubItemValuePerItem<DataType, ItemType::node, ItemType::cell>; template <typename DataType> -using NodeValuePerFace = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::face>; +using NodeValuePerFace = SubItemValuePerItem<DataType, ItemType::node, ItemType::face>; template <typename DataType> -using FaceValuePerNode = SubItemValuePerItem<DataType, TypeOfItem::face, TypeOfItem::node>; +using FaceValuePerNode = SubItemValuePerItem<DataType, ItemType::face, ItemType::node>; template <typename DataType> -using FaceValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::face, TypeOfItem::cell>; +using FaceValuePerCell = SubItemValuePerItem<DataType, ItemType::face, ItemType::cell>; template <typename DataType> -using CellValuePerNode = SubItemValuePerItem<DataType, TypeOfItem::cell, TypeOfItem::node>; +using CellValuePerNode = SubItemValuePerItem<DataType, ItemType::cell, ItemType::node>; template <typename DataType> -using CellValuePerFace = SubItemValuePerItem<DataType, TypeOfItem::cell, TypeOfItem::face>; +using CellValuePerFace = SubItemValuePerItem<DataType, ItemType::cell, ItemType::face>; #endif // SUBITEM_VALUE_PER_ITEM_HPP diff --git a/src/mesh/TypeOfItem.hpp b/src/mesh/TypeOfItem.hpp deleted file mode 100644 index 10ff8c168..000000000 --- a/src/mesh/TypeOfItem.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef TYPE_OF_ITEM_HPP -#define TYPE_OF_ITEM_HPP - -#include <utility> - -enum class TypeOfItem { - node = 0, - edge = 1, - face = 2, - cell = 3 -}; - -template <size_t Dimension> -struct ItemId {}; - -template <> -struct ItemId<1> -{ - inline static constexpr size_t itemId(const TypeOfItem& item_type) { - switch(item_type) { - case TypeOfItem::cell: { - return 0; - } - case TypeOfItem::face: - case TypeOfItem::edge: - case TypeOfItem::node: { - // in 1d, faces, edges and nodes are the same - return 1; - } - } - } -}; - -template <> -struct ItemId<2> -{ - inline static constexpr size_t itemId(const TypeOfItem& item_type) { - switch(item_type) { - case TypeOfItem::cell: { - return 0; - } - case TypeOfItem::face: - case TypeOfItem::edge: { - // in 2d, faces and edges are the same - return 1; - } - case TypeOfItem::node: { - return 2; - } - } - } -}; - -template <> -struct ItemId<3> -{ - inline static constexpr size_t itemId(const TypeOfItem& item_type) { - switch(item_type) { - case TypeOfItem::cell: { - return 0; - } - case TypeOfItem::face: { - return 1; - } - case TypeOfItem::edge: { - // in 2d, faces and edges are the same - return 2; - } - case TypeOfItem::node: { - return 3; - } - } - } -}; - -#endif // TYPE_OF_ITEM_HPP diff --git a/src/output/VTKWriter.hpp b/src/output/VTKWriter.hpp index 623576e67..a2454cb0f 100644 --- a/src/output/VTKWriter.hpp +++ b/src/output/VTKWriter.hpp @@ -72,8 +72,8 @@ class VTKWriter fout << "<DataArray type=\"Int32\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">\n"; const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(mesh.connectivity()); for (unsigned int j=0; j<mesh.numberOfCells(); ++j) { const auto& cell_nodes = cell_to_node_matrix.rowConst(j); diff --git a/src/scheme/AcousticSolver.hpp b/src/scheme/AcousticSolver.hpp index fc7baf549..52a3905c1 100644 --- a/src/scheme/AcousticSolver.hpp +++ b/src/scheme/AcousticSolver.hpp @@ -99,8 +99,8 @@ class AcousticSolver const Kokkos::View<const Rdd*> computeAr(const NodeValuePerCell<Rdd>& Ajr) { const auto& node_to_cell_matrix - = getConnectivityMatrix<TypeOfItem::node, - TypeOfItem::cell>(m_connectivity); + = getConnectivityMatrix<ItemType::node, + ItemType::cell>(m_connectivity); const auto& node_to_cell_local_node = m_connectivity.nodeToCellLocalNode(); Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const int& r) { Rdd sum = zero; @@ -124,8 +124,8 @@ class AcousticSolver const Kokkos::View<const Rd*>& uj, const Kokkos::View<const double*>& pj) { const auto& node_to_cell_matrix - = getConnectivityMatrix<TypeOfItem::node, - TypeOfItem::cell>(m_connectivity); + = getConnectivityMatrix<ItemType::node, + ItemType::cell>(m_connectivity); const auto& node_to_cell_local_node = m_connectivity.nodeToCellLocalNode(); Kokkos::parallel_for(m_mesh.numberOfNodes(), KOKKOS_LAMBDA(const int& r) { Rd& br = m_br(r); @@ -205,8 +205,8 @@ class AcousticSolver const Kokkos::View<const double*>& pj) { const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { const auto& cell_nodes = cell_to_node_matrix.rowConst(j); @@ -284,8 +284,8 @@ class AcousticSolver { const NodeValuePerCell<double>& ljr = m_mesh_data.ljr(); const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j){ const auto& cell_nodes = cell_to_node_matrix.rowConst(j); @@ -328,8 +328,8 @@ class AcousticSolver const NodeValuePerCell<Rd>& Fjr = m_Fjr; const Kokkos::View<const Rd*> ur = m_ur; const auto& cell_to_node_matrix - = getConnectivityMatrix<TypeOfItem::cell, - TypeOfItem::node>(m_mesh.connectivity()); + = getConnectivityMatrix<ItemType::cell, + ItemType::node>(m_mesh.connectivity()); const Kokkos::View<const double*> inv_mj = unknowns.invMj(); Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { -- GitLab