diff --git a/src/mesh/Connectivity1D.hpp b/src/mesh/Connectivity1D.hpp index 4c56724d8dee5b9713d71afa70c0b3adcafec0eb..b78a8bf330eca6213ede9e20f1efd18d52bf50c2 100644 --- a/src/mesh/Connectivity1D.hpp +++ b/src/mesh/Connectivity1D.hpp @@ -15,7 +15,7 @@ class Connectivity1D public: static constexpr size_t dimension = 1; ConnectivityMatrix m_node_to_cell_matrix; - ConnectivityMatrix m_node_to_cell_local_node_matrix; + ConnectivityMatrixShort m_node_to_cell_local_node_matrix; private: std::vector<RefNodeList> m_ref_node_list; diff --git a/src/mesh/Connectivity2D.hpp b/src/mesh/Connectivity2D.hpp index b0555d9d290a26e2482f02dbebd98a865a564189..0384c53b954c70c29fb4984e40d16e28355558f6 100644 --- a/src/mesh/Connectivity2D.hpp +++ b/src/mesh/Connectivity2D.hpp @@ -20,7 +20,7 @@ class Connectivity2D static constexpr size_t dimension = 2; ConnectivityMatrix m_node_to_cell_matrix; - ConnectivityMatrix m_node_to_cell_local_node_matrix; + ConnectivityMatrixShort m_node_to_cell_local_node_matrix; ConnectivityMatrix m_face_to_cell_matrix; ConnectivityMatrix m_face_to_node_matrix; diff --git a/src/mesh/Connectivity3D.hpp b/src/mesh/Connectivity3D.hpp index fb04e5f968553b22e2e4fabbda94295a5f20bd12..4b317a5cc31c81423a8209b19d7a3420f92898f9 100644 --- a/src/mesh/Connectivity3D.hpp +++ b/src/mesh/Connectivity3D.hpp @@ -22,10 +22,11 @@ class Connectivity3D public: static constexpr size_t dimension = 3; - ConnectivityMatrix m_node_to_cell_matrix; - ConnectivityMatrix m_node_to_cell_local_node_matrix; + ConnectivityMatrix m_cell_to_face_matrix; ConnectivityMatrix m_face_to_cell_matrix; ConnectivityMatrix m_face_to_node_matrix; + ConnectivityMatrix m_node_to_cell_matrix; + ConnectivityMatrixShort m_node_to_cell_local_node_matrix; private: std::vector<RefFaceList> m_ref_face_list; @@ -39,7 +40,6 @@ private: Kokkos::View<double*> m_inv_cell_nb_nodes; Kokkos::View<const unsigned short*> m_cell_nb_faces; - Kokkos::View<const unsigned int**> m_cell_faces; Kokkos::View<const bool**> m_cell_faces_is_reversed; Kokkos::View<const unsigned short**> m_face_cell_local_face; @@ -284,8 +284,8 @@ private: } } - std::vector<std::vector<unsigned int>> face_to_cell_vector(m_number_of_faces); { + std::vector<std::vector<unsigned int>> face_to_cell_vector(m_number_of_faces); size_t l=0; for (const auto& face_cells_vector : face_cells_map) { const auto& cells_info_vector = face_cells_vector.second; @@ -297,28 +297,33 @@ private: } ++l; } + m_face_to_cell_matrix + = Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector); } - m_face_to_cell_matrix - = Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector); #warning check that the number of cell per faces is <=2 - std::cerr << __FILE__ << ':' << __LINE__ << ':' - << rang::fg::red << " m_max_nb_face_per_cell forced to 6" << rang::fg::reset << '\n'; - m_max_nb_face_per_cell = 6; - Kokkos::View<unsigned int**> cell_faces("cell_faces", m_number_of_cells, m_max_nb_face_per_cell); { + std::vector<std::vector<unsigned int>> cell_to_face_vector(m_number_of_cells); + for (size_t j=0; j<cell_to_face_vector.size(); ++j) { + cell_to_face_vector[j].resize(cell_nb_faces[j]); + } int l=0; for (const auto& face_cells_vector : face_cells_map) { const auto& cells_vector = face_cells_vector.second; for (unsigned short lj=0; lj<cells_vector.size(); ++lj) { const auto& [cell_number, cell_local_face, reversed] = cells_vector[lj]; - cell_faces(cell_number,cell_local_face) = l; + cell_to_face_vector[cell_number][cell_local_face] = l; } ++l; } + m_cell_to_face_matrix + = Kokkos::create_staticcrsgraph<ConnectivityMatrix>("cell_to_face_matrix", cell_to_face_vector); } - m_cell_faces = cell_faces; + + std::cerr << __FILE__ << ':' << __LINE__ << ':' + << rang::fg::red << " m_max_nb_face_per_cell forced to 6" << rang::fg::reset << '\n'; + m_max_nb_face_per_cell = 6; Kokkos::View<bool**> cell_faces_is_reversed("cell_faces_is_reversed", m_number_of_cells, m_max_nb_face_per_cell); { @@ -443,11 +448,6 @@ private: return m_cell_nodes; } - const Kokkos::View<const unsigned int**> cellFaces() const - { - return m_cell_faces; - } - const Kokkos::View<const bool**> cellFacesIsReversed() const { return m_cell_faces_is_reversed; @@ -463,21 +463,6 @@ private: return m_inv_cell_nb_nodes; } - const Kokkos::View<const unsigned short*> cellNbFaces() const - { - return m_cell_nb_faces; - } - - // const Kokkos::View<const unsigned short*> faceNbCells() const - // { - // return m_face_nb_cells; - // } - - // const Kokkos::View<const unsigned int**> faceCells() const - // { - // return m_face_cells; - // } - const Kokkos::View<const unsigned short**> faceCellLocalFace() const { return m_face_cell_local_face; diff --git a/src/mesh/ConnectivityUtils.hpp b/src/mesh/ConnectivityUtils.hpp index d9f1926931fb0e37dd61611bb98b2491309ca2ac..5ce1f4d370cdeff77b5855be7d8b9277aa86798f 100644 --- a/src/mesh/ConnectivityUtils.hpp +++ b/src/mesh/ConnectivityUtils.hpp @@ -6,6 +6,8 @@ #include <Kokkos_StaticCrsGraph.hpp> typedef Kokkos::StaticCrsGraph<unsigned int, Kokkos::HostSpace> ConnectivityMatrix; +#warning use right type (unsigned short) +typedef Kokkos::StaticCrsGraph<unsigned int, Kokkos::HostSpace> ConnectivityMatrixShort; class ConnectivityUtils { @@ -15,7 +17,7 @@ class ConnectivityUtils const size_t& number_of_cells, size_t& max_nb_node_per_cell, ConnectivityMatrix& node_to_cell_matrix, - ConnectivityMatrix& node_to_cell_local_node_matrix) + ConnectivityMatrixShort& node_to_cell_local_node_matrix) { std::map<unsigned int, std::vector<unsigned int>> node_cells_map; using namespace Kokkos::Experimental; @@ -65,7 +67,7 @@ class ConnectivityUtils } } node_to_cell_local_node_matrix - = Kokkos::create_staticcrsgraph<ConnectivityMatrix>("node_to_cell_local_node_matrix", node_to_cell_local_node_vector); + = Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("node_to_cell_local_node_matrix", node_to_cell_local_node_vector); } }; diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp index 32ad3ec8ab8626f812bb1b93e5c2d8d8b72cde11..5e30cb4d80005fe7fdf656290d409a0be920ed44 100644 --- a/src/mesh/MeshData.hpp +++ b/src/mesh/MeshData.hpp @@ -140,14 +140,9 @@ private: } }); - const Kokkos::View<const unsigned int**> cell_faces - = m_mesh.connectivity().cellFaces(); const Kokkos::View<const bool**> cell_faces_is_reversed = m_mesh.connectivity().cellFacesIsReversed(); - const Kokkos::View<const unsigned short*> cell_nb_faces - = m_mesh.connectivity().cellNbFaces(); - Kokkos::parallel_for(m_mesh.numberOfCells(), KOKKOS_LAMBDA(const int& j) { for (int R=0; R<cell_nb_nodes[j]; ++R) { m_Cjr(j,R) = zero; @@ -156,8 +151,9 @@ private: for (size_t R=0; R<cell_nb_nodes[j]; ++R) { node_id_to_local[cell_nodes(j,R)] = R; } - for (size_t L=0; L<cell_nb_faces[j]; ++L) { - const size_t l = cell_faces(j, L); + const auto& cell_faces = m_mesh.connectivity().m_cell_to_face_matrix.rowConst(j); + for (size_t L=0; L<cell_faces.length; ++L) { + const size_t l = cell_faces(L); const auto& face_nodes = m_mesh.connectivity().m_face_to_node_matrix.rowConst(l); if (cell_faces_is_reversed(j, L)) { for (size_t rl = 0; rl<face_nodes.length; ++rl) {