diff --git a/src/mesh/Connectivity1D.hpp b/src/mesh/Connectivity1D.hpp index 3bb13bab1b03191344ceca3570eea785f11e31b8..d0422f7b25a7b1df91e444f9bea0b9e8ab04a602 100644 --- a/src/mesh/Connectivity1D.hpp +++ b/src/mesh/Connectivity1D.hpp @@ -29,14 +29,14 @@ private: Kokkos::View<double*> m_inv_cell_nb_nodes; const Kokkos::View<const unsigned short*>& m_cell_nb_faces = m_cell_nb_nodes; - Kokkos::View<unsigned short*> m_node_nb_cells; - const Kokkos::View<unsigned short*>& m_face_nb_cells = m_node_nb_cells; + Kokkos::View<const unsigned short*> m_node_nb_cells; + const Kokkos::View<const unsigned short*>& m_face_nb_cells = m_node_nb_cells; - Kokkos::View<unsigned int**> m_node_cells; - const Kokkos::View<unsigned int**>& m_face_cells = m_node_cells; + Kokkos::View<const unsigned int**> m_node_cells; + const Kokkos::View<const unsigned int**>& m_face_cells = m_node_cells; - Kokkos::View<unsigned short**> m_node_cell_local_node; - const Kokkos::View<unsigned short**>& m_face_cell_local_face = m_node_cell_local_node; + Kokkos::View<const unsigned short**> m_node_cell_local_node; + const Kokkos::View<const unsigned short**>& m_face_cell_local_face = m_node_cell_local_node; size_t m_max_nb_node_per_cell; diff --git a/src/mesh/Connectivity2D.hpp b/src/mesh/Connectivity2D.hpp index e4d8c9c0c8bcf5c12dce93e497e4158d07be480b..bf87b5b9ab2f69306ec4dbc68958927f7df6df6f 100644 --- a/src/mesh/Connectivity2D.hpp +++ b/src/mesh/Connectivity2D.hpp @@ -34,9 +34,9 @@ class Connectivity2D Kokkos::View<const unsigned short*> m_cell_nb_faces; Kokkos::View<unsigned int**> m_cell_faces; - Kokkos::View<unsigned short*> m_node_nb_cells; - Kokkos::View<unsigned int**> m_node_cells; - Kokkos::View<unsigned short**> m_node_cell_local_node; + Kokkos::View<const unsigned short*> m_node_nb_cells; + Kokkos::View<const unsigned int**> m_node_cells; + Kokkos::View<const unsigned short**> m_node_cell_local_node; Kokkos::View<unsigned short*> m_face_nb_cells; Kokkos::View<unsigned int**> m_face_cells; diff --git a/src/mesh/Connectivity3D.hpp b/src/mesh/Connectivity3D.hpp index 64f1c22ded5c60e19956834f8210eab540a4dc0f..ce982d2765dd82736c3211238017529ce997d92f 100644 --- a/src/mesh/Connectivity3D.hpp +++ b/src/mesh/Connectivity3D.hpp @@ -38,9 +38,9 @@ private: Kokkos::View<const unsigned int**> m_cell_faces; Kokkos::View<const bool**> m_cell_faces_is_reversed; - Kokkos::View<unsigned short*> m_node_nb_cells; - Kokkos::View<unsigned int**> m_node_cells; - Kokkos::View<unsigned short**> m_node_cell_local_node; + Kokkos::View<const unsigned short*> m_node_nb_cells; + Kokkos::View<const unsigned int**> m_node_cells; + Kokkos::View<const unsigned short**> m_node_cell_local_node; Kokkos::View<const unsigned short*> m_face_nb_cells; Kokkos::View<const unsigned int**> m_face_cells; diff --git a/src/mesh/ConnectivityUtils.hpp b/src/mesh/ConnectivityUtils.hpp index a6482b3dfbebc2560e67b270eebbc2bd5bef021f..3fe9e6f6a11032e752ce5bdcd9d76e7a9c46e1b0 100644 --- a/src/mesh/ConnectivityUtils.hpp +++ b/src/mesh/ConnectivityUtils.hpp @@ -12,9 +12,9 @@ class ConnectivityUtils const size_t& number_of_cells, size_t& max_nb_node_per_cell, size_t& number_of_nodes, - Kokkos::View<unsigned short*>& node_nb_cells, - Kokkos::View<unsigned int**>& node_cells, - Kokkos::View<unsigned short**>& node_cell_local_node) + Kokkos::View<const unsigned short*>& node_nb_cells, + Kokkos::View<const unsigned int**>& node_cells, + Kokkos::View<const unsigned short**>& node_cell_local_node) { std::map<unsigned int, std::vector<unsigned int>> node_cells_map; using namespace Kokkos::Experimental; @@ -43,38 +43,41 @@ class ConnectivityUtils number_of_nodes = node_cells_map.size(); - node_nb_cells = Kokkos::View<unsigned short*>("node_nb_cells", node_cells_map.size()); + Kokkos::View<unsigned short*> built_node_nb_cells("node_nb_cells", node_cells_map.size()); size_t max_node_cells = 0; for (const auto& i_cell_vector : node_cells_map) { const auto& [i, cells_vector] = i_cell_vector; const size_t nb_cells = cells_vector.size(); - node_nb_cells[i] = nb_cells; + built_node_nb_cells[i] = nb_cells; if (nb_cells > max_node_cells) { max_node_cells = nb_cells; } } + node_nb_cells = built_node_nb_cells; - node_cells = Kokkos::View<unsigned int**>("node_cells", node_cells_map.size(), max_node_cells); + Kokkos::View<unsigned int**> built_node_cells("node_cells", node_cells_map.size(), max_node_cells); for (const auto& i_cell_vector : node_cells_map) { const auto& [i, cells_vector] = i_cell_vector; for (size_t j=0; j<cells_vector.size(); ++j) { - node_cells(i,j) = cells_vector[j]; + built_node_cells(i,j) = cells_vector[j]; } } + node_cells = built_node_cells; - node_cell_local_node = Kokkos::View<unsigned short**>("node_cell_local_node", - node_cells_map.size(), max_node_cells); + Kokkos::View<unsigned short**> built_node_cell_local_node("node_cell_local_node", + node_cells_map.size(), max_node_cells); Kokkos::parallel_for(number_of_nodes, KOKKOS_LAMBDA(const unsigned int& r){ for (unsigned short J=0; J<node_nb_cells[r]; ++J) { const unsigned int j = node_cells(r,J); for (unsigned int R=0; R<cell_nb_nodes[j]; ++R) { if (cell_nodes(j,R) == r) { - node_cell_local_node(r,J)=R; + built_node_cell_local_node(r,J)=R; break; } } } }); + node_cell_local_node = built_node_cell_local_node; } };