]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Switch to using the combined orientation internally. 16281/head
authorDavid Wells <drwells@email.unc.edu>
Sun, 19 Nov 2023 02:33:35 +0000 (21:33 -0500)
committerDavid Wells <drwells@email.unc.edu>
Sun, 19 Nov 2023 02:33:35 +0000 (21:33 -0500)
source/dofs/dof_tools_constraints.cc

index f8db073bafafafaf906d81f398a6f80a5c0986b8..9b0066cfc405c75c8497ec3736cb078691c9740d 100644 (file)
@@ -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<dim>::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<dim>();
+            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),

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.