From 055c403dbb746b972cf8e29d536eea39a192697a Mon Sep 17 00:00:00 2001 From: David Wells Date: Tue, 6 May 2025 17:23:58 -0400 Subject: [PATCH] GridGenerator: make some 3d arrays 2d arrays. This will make it easier to add some alternative subdivision strategies. --- source/grid/grid_generator.cc | 104 ++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index 624ea2c35b..7864fc1ca0 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -8043,24 +8043,32 @@ namespace GridGenerator // After converting, each of the 4 quadrilateral faces is defined by faces // of 2 different triangles, i.e., lines. Note that lines are defined by 2 // vertices. - static const ndarray - vertex_ids_for_boundary_faces_2d = {{{{{{0, 4}}, {{4, 2}}}}, - {{{{1, 5}}, {{5, 3}}}}, - {{{{0, 6}}, {{6, 1}}}}, - {{{{2, 7}}, {{7, 3}}}}}}; + static const std:: + array>, 8> + vertex_ids_for_boundary_faces_2d = {{{0, {{0, 4}}}, + {0, {{4, 2}}}, + {1, {{1, 5}}}, + {1, {{5, 3}}}, + {2, {{0, 6}}}, + {2, {{6, 1}}}, + {3, {{2, 7}}}, + {3, {{7, 3}}}}}; // Boundary-faces 3d: // After converting, each of the 6 hexahedron faces corresponds to faces of // 4 different tetrahedron faces, i.e., triangles. Note that a triangle is // defined by 3 vertices. - static const ndarray - vertex_ids_for_boundary_faces_3d = { - {{{{{0, 4, 8}}, {{4, 8, 6}}, {{8, 6, 2}}, {{0, 2, 8}}}}, - {{{{1, 3, 9}}, {{3, 9, 7}}, {{9, 7, 5}}, {{1, 9, 5}}}}, - {{{{0, 1, 10}}, {{1, 10, 5}}, {{10, 5, 4}}, {{0, 10, 4}}}}, - {{{{2, 3, 11}}, {{3, 11, 7}}, {{11, 7, 6}}, {{2, 11, 6}}}}, - {{{{0, 1, 12}}, {{1, 12, 3}}, {{12, 3, 2}}, {{0, 12, 2}}}}, - {{{{4, 5, 13}}, {{5, 13, 7}}, {{13, 7, 6}}, {{4, 13, 6}}}}}}; + static const std:: + array>, 24> + vertex_ids_for_boundary_faces_3d = { + {{0, {{0, 4, 8}}}, {0, {{4, 8, 6}}}, {0, {{8, 6, 2}}}, + {0, {{0, 2, 8}}}, {1, {{1, 3, 9}}}, {1, {{3, 9, 7}}}, + {1, {{9, 7, 5}}}, {1, {{1, 9, 5}}}, {2, {{0, 1, 10}}}, + {2, {{1, 10, 5}}}, {2, {{10, 5, 4}}}, {2, {{0, 10, 4}}}, + {3, {{2, 3, 11}}}, {3, {{3, 11, 7}}}, {3, {{11, 7, 6}}}, + {3, {{2, 11, 6}}}, {4, {{0, 1, 12}}}, {4, {{1, 12, 3}}}, + {4, {{12, 3, 2}}}, {4, {{0, 12, 2}}}, {5, {{4, 5, 13}}}, + {5, {{5, 13, 7}}}, {5, {{13, 7, 6}}}, {5, {{4, 13, 6}}}}}; // Inner-faces 2d: // The converted triangulation based on simplices has 8 faces that do not @@ -8122,14 +8130,16 @@ namespace GridGenerator // triangulation. The new 4 edges inherit the manifold id of the relevant // face, but the other 4 need to be copied from the input and thus do not // require a lookup table. - static const ndarray - vertex_ids_for_new_boundary_edges_3d = { - {{{{{4, 8}}, {{6, 8}}, {{0, 8}}, {{2, 8}}}}, - {{{{5, 9}}, {{7, 9}}, {{1, 9}}, {{3, 9}}}}, - {{{{4, 10}}, {{5, 10}}, {{0, 10}}, {{1, 10}}}}, - {{{{6, 11}}, {{7, 11}}, {{2, 11}}, {{3, 11}}}}, - {{{{2, 12}}, {{3, 12}}, {{0, 12}}, {{1, 12}}}}, - {{{{6, 13}}, {{7, 13}}, {{4, 13}}, {{5, 13}}}}}}; + static const std:: + array>, 24> + vertex_ids_for_new_boundary_edges_3d = {{ + {0, {{4, 8}}}, {0, {{6, 8}}}, {0, {{0, 8}}}, {0, {{2, 8}}}, + {1, {{5, 9}}}, {1, {{7, 9}}}, {1, {{1, 9}}}, {1, {{3, 9}}}, + {2, {{4, 10}}}, {2, {{5, 10}}}, {2, {{0, 10}}}, {2, {{1, 10}}}, + {3, {{6, 11}}}, {3, {{7, 11}}}, {3, {{2, 11}}}, {3, {{3, 11}}}, + {4, {{2, 12}}}, {4, {{3, 12}}}, {4, {{0, 12}}}, {4, {{1, 12}}}, + {5, {{6, 13}}}, {5, {{7, 13}}}, {5, {{4, 13}}}, {5, {{5, 13}}}, + }}; std::vector> vertices; std::vector> cells; @@ -8329,34 +8339,42 @@ namespace GridGenerator DEAL_II_NOT_IMPLEMENTED(); // Set up sub-cell data. - for (const auto f : cell->face_indices()) + if (dim == 2) { - const auto bid = cell->face(f)->boundary_id(); - const auto mid = cell->face(f)->manifold_id(); - - // process boundary-faces: set boundary and manifold ids - if (dim == 2) // 2d boundary-faces + for (const auto &[quad_face_no, tri_face_vertices] : + vertex_ids_for_boundary_faces_2d) { - for (const auto &face_vertices : - vertex_ids_for_boundary_faces_2d[f]) - add_cell(1, face_vertices, bid, mid); + const auto face = cell->face(quad_face_no); + add_cell(1, + tri_face_vertices, + face->boundary_id(), + face->manifold_id()); } - else if (dim == 3) // 3d boundary-faces + } + else if (dim == 3) + { + for (const auto &[hex_face_no, tet_face_vertices] : + vertex_ids_for_boundary_faces_3d) { - // set manifold ids of tet-boundary-faces according to - // hex-boundary-faces - for (const auto &face_vertices : - vertex_ids_for_boundary_faces_3d[f]) - add_cell(2, face_vertices, bid, mid); - // set manifold ids of new tet-boundary-edges according to - // hex-boundary-faces - for (const auto &edge_vertices : - vertex_ids_for_new_boundary_edges_3d[f]) - add_cell(1, edge_vertices, bid, mid); + const auto face = cell->face(hex_face_no); + add_cell(2, + tet_face_vertices, + face->boundary_id(), + face->manifold_id()); + } + + for (const auto &[hex_face_no, tet_edge_vertices] : + vertex_ids_for_new_boundary_edges_3d) + { + const auto face = cell->face(hex_face_no); + add_cell(1, + tet_edge_vertices, + face->boundary_id(), + face->manifold_id()); } - else - DEAL_II_NOT_IMPLEMENTED(); } + else + DEAL_II_NOT_IMPLEMENTED(); // set manifold ids of edges that were already present in the // triangulation. -- 2.39.5