From 7aa02175466538cf1a0f1ea1df6cb4cd0c034199 Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Wed, 11 Jul 2018 18:17:06 +0200 Subject: [PATCH] Continue use of crs representation of connectivity - cell->face is reversed - face->local face number in cell --- src/mesh/Connectivity2D.hpp | 16 ++++----- src/mesh/Connectivity3D.hpp | 68 +++++++++++++++++-------------------- src/mesh/MeshData.hpp | 6 ++-- 3 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/mesh/Connectivity2D.hpp b/src/mesh/Connectivity2D.hpp index 0384c53b9..4eecf7485 100644 --- a/src/mesh/Connectivity2D.hpp +++ b/src/mesh/Connectivity2D.hpp @@ -215,10 +215,10 @@ class Connectivity2D return m_cell_nodes; } - const Kokkos::View<const unsigned int**> cellFaces() const - { - return m_cell_faces; - } + // const Kokkos::View<const unsigned int**> cellFaces() const + // { + // return m_cell_faces; + // } const Kokkos::View<const unsigned short*> cellNbNodes() const { @@ -230,10 +230,10 @@ class Connectivity2D 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*> cellNbFaces() const + // { + // return m_cell_nb_faces; + // } const Kokkos::View<const unsigned short**> faceCellLocalFace() const { diff --git a/src/mesh/Connectivity3D.hpp b/src/mesh/Connectivity3D.hpp index 4b317a5cc..c509e8e5b 100644 --- a/src/mesh/Connectivity3D.hpp +++ b/src/mesh/Connectivity3D.hpp @@ -23,8 +23,12 @@ public: static constexpr size_t dimension = 3; ConnectivityMatrix m_cell_to_face_matrix; + ConnectivityMatrixShort m_cell_to_face_is_reversed_matrix; + ConnectivityMatrix m_face_to_cell_matrix; + ConnectivityMatrixShort m_face_to_cell_local_face_matrix; ConnectivityMatrix m_face_to_node_matrix; + ConnectivityMatrix m_node_to_cell_matrix; ConnectivityMatrixShort m_node_to_cell_local_node_matrix; @@ -32,18 +36,13 @@ private: std::vector<RefFaceList> m_ref_face_list; std::vector<RefNodeList> m_ref_node_list; - const size_t m_number_of_cells; + const size_t m_number_of_cells; size_t m_number_of_faces; const Kokkos::View<const unsigned short*> m_cell_nb_nodes; const Kokkos::View<const unsigned int**> m_cell_nodes; Kokkos::View<double*> m_inv_cell_nb_nodes; - Kokkos::View<const unsigned short*> m_cell_nb_faces; - Kokkos::View<const bool**> m_cell_faces_is_reversed; - - Kokkos::View<const unsigned short**> m_face_cell_local_face; - Kokkos::View<const unsigned short*> m_node_nb_faces; Kokkos::View<const unsigned int**> m_node_faces; @@ -255,8 +254,6 @@ private: std::cerr << __FILE__ << ':' << __LINE__ << ':' << rang::fg::red << " only works for hexa" << rang::fg::reset << '\n'; - m_cell_nb_faces = cell_nb_faces; - m_number_of_faces = face_cells_map.size(); std::cerr << __FILE__ << ':' << __LINE__ << ':' @@ -301,6 +298,24 @@ private: = Kokkos::create_staticcrsgraph<ConnectivityMatrix>("face_to_cell_matrix", face_to_cell_vector); } + { + std::vector<std::vector<unsigned short>> face_to_cell_local_face_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; + std::vector<unsigned short>& cells_vector = face_to_cell_local_face_vector[l]; + cells_vector.resize(cells_info_vector.size()); + for (size_t j=0; j<cells_info_vector.size(); ++j) { + const auto& [cell_number, local_face_in_cell, reversed] = cells_info_vector[j]; + cells_vector[j] = local_face_in_cell; + } + ++l; + } + m_face_to_cell_local_face_matrix + = Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("face_to_cell_local_face_matrix", + face_to_cell_local_face_vector); + } + #warning check that the number of cell per faces is <=2 { @@ -325,34 +340,25 @@ private: << 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); { + std::vector<std::vector<unsigned short>> cell_to_face_is_reversed_vector(m_number_of_cells); + for (size_t j=0; j<cell_to_face_is_reversed_vector.size(); ++j) { + cell_to_face_is_reversed_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_is_reversed(cell_number,cell_local_face) = reversed; + cell_to_face_is_reversed_vector[cell_number][cell_local_face] = reversed; } ++l; } - } - m_cell_faces_is_reversed = cell_faces_is_reversed; - Kokkos::View<unsigned short**> face_cell_local_face("face_cell_local_face", - m_number_of_faces, m_max_nb_node_per_cell); - { - 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) { - unsigned short cell_local_face = std::get<1>(cells_vector[lj]); - face_cell_local_face(l,lj) = cell_local_face; - } - ++l; - } + m_cell_to_face_is_reversed_matrix + = Kokkos::create_staticcrsgraph<ConnectivityMatrixShort>("cell_to_face_is_reversed_matrix", + cell_to_face_is_reversed_vector); } - m_face_cell_local_face = face_cell_local_face; std::unordered_map<unsigned int, std::vector<unsigned int>> node_faces_map; for (size_t l=0; l<m_face_to_node_matrix.numRows(); ++l) { @@ -448,11 +454,6 @@ private: return m_cell_nodes; } - const Kokkos::View<const bool**> cellFacesIsReversed() const - { - return m_cell_faces_is_reversed; - } - const Kokkos::View<const unsigned short*> cellNbNodes() const { return m_cell_nb_nodes; @@ -463,11 +464,6 @@ private: return m_inv_cell_nb_nodes; } - const Kokkos::View<const unsigned short**> faceCellLocalFace() const - { - return m_face_cell_local_face; - } - unsigned int getFaceNumber(const std::vector<unsigned int>& face_nodes) const { const Face face(face_nodes); @@ -489,7 +485,7 @@ private: { { Kokkos::View<double*> inv_cell_nb_nodes("inv_cell_nb_nodes", m_number_of_cells); - Kokkos::parallel_for(m_number_of_cells, KOKKOS_LAMBDA(const int&j){ + Kokkos::parallel_for(m_number_of_cells, KOKKOS_LAMBDA(const int& j){ inv_cell_nb_nodes[j] = 1./m_cell_nb_nodes[j]; }); m_inv_cell_nb_nodes = inv_cell_nb_nodes; diff --git a/src/mesh/MeshData.hpp b/src/mesh/MeshData.hpp index 5e30cb4d8..e2c0e0ac6 100644 --- a/src/mesh/MeshData.hpp +++ b/src/mesh/MeshData.hpp @@ -140,9 +140,6 @@ private: } }); - const Kokkos::View<const bool**> cell_faces_is_reversed - = m_mesh.connectivity().cellFacesIsReversed(); - 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; @@ -152,10 +149,11 @@ private: node_id_to_local[cell_nodes(j,R)] = R; } const auto& cell_faces = m_mesh.connectivity().m_cell_to_face_matrix.rowConst(j); + const auto& cell_faces_is_reversed = m_mesh.connectivity().m_cell_to_face_is_reversed_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)) { + if (cell_faces_is_reversed(L)) { for (size_t rl = 0; rl<face_nodes.length; ++rl) { m_Cjr(j, node_id_to_local[face_nodes(rl)]) -= Nlr(l,rl); } -- GitLab