From 9a6ef414852019e8d1ca0f2d1303ef727269864f Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 18 Nov 2023 21:33:35 -0500 Subject: [PATCH] Switch to using the combined orientation internally. --- source/dofs/dof_tools_constraints.cc | 64 ++++++++-------------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index f8db073baf..9b0066cfc4 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2376,6 +2376,11 @@ namespace DoFTools ExcMessage("first_vector_components is nonempty, so matrix must " "be a rotation matrix exactly of size spacedim")); + const unsigned char combined_orientation = + ::dealii::internal::combined_face_orientation(face_orientation, + face_rotation, + face_flip); + #ifdef DEBUG if (!face_1->has_children()) { @@ -2426,39 +2431,6 @@ namespace DoFTools } #endif - // A lookup table on how to go through the child faces depending on the - // orientation: - - static const int lookup_table_2d[2][2] = { - // flip: - {0, 1}, // false - {1, 0}, // true - }; - - static const int lookup_table_3d[2][2][2][4] = { - // orientation flip rotation - { - { - {0, 2, 1, 3}, // false false false - {2, 3, 0, 1}, // false false true - }, - { - {3, 1, 2, 0}, // false true false - {1, 0, 3, 2}, // false true true - }, - }, - { - { - {0, 1, 2, 3}, // true false false - {1, 3, 0, 2}, // true false true - }, - { - {3, 2, 1, 0}, // true true false - {2, 0, 3, 1}, // true true true - }, - }, - }; - if (face_1->has_children() && face_2->has_children()) { // In the case that both faces have children, we loop over all children @@ -2473,20 +2445,18 @@ namespace DoFTools for (unsigned int i = 0; i < GeometryInfo::max_children_per_face; ++i) { - // Lookup the index for the second face - unsigned int j = numbers::invalid_unsigned_int; - switch (dim) - { - case 2: - j = lookup_table_2d[face_flip][i]; - break; - case 3: - j = lookup_table_3d[face_orientation][face_flip] - [face_rotation][i]; - break; - default: - AssertThrow(false, ExcNotImplemented()); - } + // We need to access the subface indices without knowing the face + // number. Hence, we pick the lowest-value face: i.e., face 2 in 2D + // has subfaces {0, 1} and face 4 in 3D has subfaces {0, 1, 2, 3}. + const unsigned int face_no = dim == 2 ? 2 : 4; + + // Lookup the index for the second face. Like the assertions above, + // this is only presently valid for hypercube meshes. + const auto reference_cell = ReferenceCells::get_hypercube(); + const unsigned int j = + reference_cell.child_cell_on_face(face_no, + i, + combined_orientation); make_periodicity_constraints(face_1->child(i), face_2->child(j), -- 2.39.5