]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use the standardized orientation functions in a few more places. 16194/head
authorDavid Wells <drwells@email.unc.edu>
Wed, 25 Oct 2023 12:11:20 +0000 (08:11 -0400)
committerDavid Wells <drwells@email.unc.edu>
Thu, 26 Oct 2023 17:54:55 +0000 (13:54 -0400)
source/base/qprojector.cc
source/fe/fe.cc

index bdcb8bf7b2ecdd80df56a3fc6c9e3fabbdc236da..5203a7eb8509b7b7899d8994133dc4871e16f62f 100644 (file)
@@ -1323,21 +1323,29 @@ QProjector<dim>::DataSetDescriptor::face(const ReferenceCell &reference_cell,
                                          const bool           face_rotation,
                                          const unsigned int n_quadrature_points)
 {
+  const unsigned char combined_orientation =
+    internal::combined_face_orientation(face_orientation,
+                                        face_rotation,
+                                        face_flip);
+  // TODO: once we move to representing the default orientation as 0 (instead of
+  // 1) we can get rid of the dim = 1 check
+  Assert(dim == 1 ||
+           (combined_orientation < reference_cell.n_face_orientations(face_no)),
+         ExcInternalError());
   if (reference_cell == ReferenceCells::Triangle ||
       reference_cell == ReferenceCells::Tetrahedron)
     {
       if (dim == 2)
-        return {(2 * face_no + (face_orientation ? 1 : 0)) *
+        return {(2 * face_no +
+                 (combined_orientation ==
+                      ReferenceCell::default_combined_face_orientation() ?
+                    1 :
+                    0)) *
                 n_quadrature_points};
       else if (dim == 3)
         {
-          const unsigned char orientation =
-            internal::combined_face_orientation(face_orientation,
-                                                face_rotation,
-                                                face_flip);
-          Assert(orientation < 6, ExcInternalError());
           return {(reference_cell.n_face_orientations(face_no) * face_no +
-                   orientation) *
+                   combined_orientation) *
                   n_quadrature_points};
         }
     }
@@ -1424,6 +1432,13 @@ QProjector<dim>::DataSetDescriptor::face(
     {
       unsigned int offset = 0;
 
+      const unsigned char combined_orientation =
+        internal::combined_face_orientation(face_orientation,
+                                            face_rotation,
+                                            face_flip);
+      Assert(combined_orientation < reference_cell.n_face_orientations(face_no),
+             ExcInternalError());
+
       static const unsigned int X = numbers::invalid_unsigned_int;
       static const std::array<unsigned int, 5> scale_tri   = {{2, 2, 2, X, X}};
       static const std::array<unsigned int, 5> scale_tet   = {{6, 6, 6, 6, X}};
@@ -1447,14 +1462,13 @@ QProjector<dim>::DataSetDescriptor::face(
 
       if (dim == 2)
         return {offset +
-                face_orientation *
+                (combined_orientation ==
+                 ReferenceCell::default_combined_face_orientation()) *
                   quadrature[quadrature.size() == 1 ? 0 : face_no].size()};
       else if (dim == 3)
         {
           return {offset +
-                  internal::combined_face_orientation(face_orientation,
-                                                      face_rotation,
-                                                      face_flip) *
+                  combined_orientation *
                     quadrature[quadrature.size() == 1 ? 0 : face_no].size()};
         }
     }
index 9dd634495c1c295b7e303d50ebbc7f88040c72d0..749566788a13b94cd456701e2f538db229249373 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <deal.II/grid/tria.h>
 #include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_orientation.h>
 
 #include <algorithm>
 #include <functional>
@@ -608,8 +609,9 @@ FiniteElement<dim, spacedim>::face_to_cell_index(const unsigned int face_index,
       return (this->reference_cell().face_to_cell_vertices(
                 face,
                 face_vertex,
-                (face_orientation ? 1 : 0) + (face_rotation ? 2 : 0) +
-                  (face_flip ? 4 : 0)) *
+                internal::combined_face_orientation(face_orientation,
+                                                    face_rotation,
+                                                    face_flip)) *
                 this->n_dofs_per_vertex() +
               dof_index_on_vertex);
     }
@@ -624,15 +626,15 @@ FiniteElement<dim, spacedim>::face_to_cell_index(const unsigned int face_index,
       const unsigned int face_line         = index / this->n_dofs_per_line();
       const unsigned int dof_index_on_line = index % this->n_dofs_per_line();
 
-      return (
-        this->get_first_line_index() +
-        this->reference_cell().face_to_cell_lines(face,
-                                                  face_line,
-                                                  (face_orientation ? 1 : 0) +
-                                                    (face_rotation ? 2 : 0) +
-                                                    (face_flip ? 4 : 0)) *
-          this->n_dofs_per_line() +
-        dof_index_on_line);
+      return (this->get_first_line_index() +
+              this->reference_cell().face_to_cell_lines(
+                face,
+                face_line,
+                internal::combined_face_orientation(face_orientation,
+                                                    face_rotation,
+                                                    face_flip)) *
+                this->n_dofs_per_line() +
+              dof_index_on_line);
     }
   else
     // DoF is on a quad

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.