diff --git a/src/mesh/Connectivity3D.hpp b/src/mesh/Connectivity3D.hpp index 5b65c12e81d52f3a8a573eb71997523648ff3dc8..94e65508b3927f35cec03a8bf384d8b40f1c4d31 100644 --- a/src/mesh/Connectivity3D.hpp +++ b/src/mesh/Connectivity3D.hpp @@ -47,14 +47,15 @@ private: Kokkos::View<unsigned int**> m_face_nodes; Kokkos::View<unsigned short**> m_face_node_local_face; - size_t m_max_nb_node_per_cell; + size_t m_max_nb_node_per_cell; + size_t m_max_nb_face_per_cell; struct Face { KOKKOS_INLINE_FUNCTION std::vector<unsigned int> _sort(const std::vector<unsigned int>& node_list) const { - auto min_id = std::min_element(node_list.begin(), node_list.end()); + const auto min_id = std::min_element(node_list.begin(), node_list.end()); const size_t shift = std::distance(min_id, node_list.begin()); std::vector<unsigned int> rotated_node_list(node_list.size()); @@ -110,13 +111,15 @@ private: void _computeFaceCellConnectivities() { - // In 2D faces are simply define + Kokkos::View<unsigned short*> cell_nb_faces("cell_nb_faces", m_number_of_cells); + typedef std::pair<unsigned int, unsigned short> CellFaceId; std::map<Face, std::vector<CellFaceId>> face_cells_map; for (unsigned int j=0; j<m_number_of_cells; ++j) { const unsigned short cell_nb_nodes = m_cell_nb_nodes[j]; switch (cell_nb_nodes) { case 4: { // tetrahedron + cell_nb_faces[j] = 4; std::cerr << "tetrahedron cell type NIY!\n"; std::exit(0); break; @@ -147,11 +150,13 @@ private: m_cell_nodes(j,1), m_cell_nodes(j,5), m_cell_nodes(j,4)})].push_back(std::make_pair(j,4)); - // face 1 + // face 5 face_cells_map[Face({m_cell_nodes(j,3), m_cell_nodes(j,2), m_cell_nodes(j,6), m_cell_nodes(j,7)})].push_back(std::make_pair(j,5)); + + cell_nb_faces[j] = 6; break; } default: { @@ -159,15 +164,11 @@ private: std::exit(0); } } - for (unsigned short r=0; r<cell_nb_nodes; ++r) { - unsigned int node0_id = m_cell_nodes(j,r); - unsigned int node1_id = m_cell_nodes(j,(r+1)%cell_nb_nodes); - if (node1_id<node0_id) { - std::swap(node0_id, node1_id); - } - // face_cells_map[Face(node0_id, node1_id)].push_back(std::make_pair(j, r)); - } } + 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(); Kokkos::View<unsigned short*> face_nb_nodes("face_nb_nodes", m_number_of_faces); @@ -177,9 +178,9 @@ private: m_face_nb_nodes = face_nb_nodes; std::cerr << __FILE__ << ':' << __LINE__ << ':' - << rang::fg::red << "m_max_nb_node_per_face forced to 8" << rang::fg::reset; - unsigned int m_max_nb_node_per_face = 8; - Kokkos::View<unsigned int**> face_nodes("face_nodes", m_number_of_faces, m_max_nb_node_per_face); + << rang::fg::red << " max_nb_node_per_face forced to 4" << rang::fg::reset << '\n'; + const size_t max_nb_node_per_face = 4; + Kokkos::View<unsigned int**> face_nodes("face_nodes", m_number_of_faces, max_nb_node_per_face); { int l=0; for (const auto& face_cells_vector : face_cells_map) { @@ -203,6 +204,8 @@ private: } m_face_nb_cells = face_nb_cells; +#warning check that the number of cell per faces is <=2 + Kokkos::View<unsigned int**> face_cells("face_cells", face_cells_map.size(), 2); { int l=0; @@ -217,9 +220,10 @@ private: } m_face_cells = face_cells; - // In 2d cell_nb_faces = cell_nb_node - m_cell_nb_faces = m_cell_nb_nodes; - Kokkos::View<unsigned int**> cell_faces("cell_faces", m_number_of_faces, m_max_nb_node_per_cell); + 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_faces, m_max_nb_face_per_cell); { int l=0; for (const auto& face_cells_vector : face_cells_map) {