From: David Wells Date: Sat, 6 Apr 2024 15:42:29 +0000 (-0400) Subject: execute_refinement_isotropic(): Generalize 2d child line assignment. X-Git-Tag: v9.6.0-rc1~382^2~7 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1939bd308a67d3ab78d3c5ac9c9871d72fe1e2a6;p=dealii.git execute_refinement_isotropic(): Generalize 2d child line assignment. Quadrilateral cells in mixed meshes may have lines with reversed orientations. We can make that case work correctly by simply generalizing the code we already have for triangles. --- diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 5d37de13fa..6d7185c8d1 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -5184,34 +5184,33 @@ namespace internal AssertIsNotUsed(new_lines[l]); } - if (cell->reference_cell() == ReferenceCells::Triangle) + // set up lines which have parents: + for (const unsigned int face_no : cell->face_indices()) { - // add lines in the order implied by their orientation. Here, - // face_no is the cell (not subcell) face number and vertex_no is - // the first vertex on that face in the standard orientation. - const auto ref = [&](const unsigned int face_no, - const unsigned int vertex_no) { - auto l = cell->line(face_no); - // if the vertex is on the first child then add the first child - // first - if (l->child(0)->vertex_index(0) == new_vertices[vertex_no] || - l->child(0)->vertex_index(1) == new_vertices[vertex_no]) - { - new_lines[2 * face_no + 0] = l->child(0); - new_lines[2 * face_no + 1] = l->child(1); - } - else - { - new_lines[2 * face_no + 0] = l->child(1); - new_lines[2 * face_no + 1] = l->child(0); - } - }; - - ref(0, 0); - ref(1, 1); - ref(2, 2); + // Check the face (line) orientation to ensure that the (six or + // eight) outer lines in new_lines are indexed in the default + // orientation. This way we can index into this array in the + // without special casing orientations (e.g., quadrilateral child + // 3 will always have lines 9, 3, 11, 7) when setting child lines. + const unsigned char combined_orientation = + cell->combined_face_orientation(face_no); + Assert(combined_orientation == + ReferenceCell::default_combined_face_orientation() || + combined_orientation == + ReferenceCell::reversed_combined_line_orientation(), + ExcInternalError()); + for (unsigned int c = 0; c < 2; ++c) + { + new_lines[2 * face_no + c] = cell->line(face_no)->child(c); + } + if (combined_orientation == + ReferenceCell::reversed_combined_line_orientation()) + std::swap(new_lines[2 * face_no], new_lines[2 * face_no + 1]); + } - // set up lines which do not have parents: + // set up lines which do not have parents: + if (cell->reference_cell() == ReferenceCells::Triangle) + { new_lines[6]->set_bounding_object_indices( {new_vertices[3], new_vertices[4]}); new_lines[7]->set_bounding_object_indices( @@ -5221,11 +5220,6 @@ namespace internal } else if (cell->reference_cell() == ReferenceCells::Quadrilateral) { - unsigned int l = 0; - for (const unsigned int face_no : cell->face_indices()) - for (unsigned int c = 0; c < 2; ++c, ++l) - new_lines[l] = cell->line(face_no)->child(c); - new_lines[8]->set_bounding_object_indices( {new_vertices[6], new_vertices[8]}); new_lines[9]->set_bounding_object_indices(