]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Consolidate face_orientation() functions.
authorDavid Wells <drwells@email.unc.edu>
Sat, 4 May 2024 16:00:05 +0000 (12:00 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 6 May 2024 14:54:27 +0000 (10:54 -0400)
include/deal.II/grid/tria_accessor.templates.h

index d4f5c4722da925b6b64185829fb4ad1c1b56a75d..3c737dadec7a8ee41d90c658d5b75422e8b5b1f6 100644 (file)
@@ -651,44 +651,6 @@ namespace internal
 
 
 
-      /**
-       * Implementation of the function of some name in the mother class
-       */
-      template <int structdim, int dim, int spacedim>
-      inline static bool
-      face_orientation(const TriaAccessor<structdim, dim, spacedim> &,
-                       const unsigned int)
-      {
-        /*
-         * Default implementation used in 1d
-         *
-         * In 1d, face_orientation is always true
-         */
-
-        return true;
-      }
-
-
-      template <int spacedim>
-      inline static bool
-      face_orientation(const TriaAccessor<2, 2, spacedim> &accessor,
-                       const unsigned int                  face)
-      {
-        return line_orientation(accessor, face);
-      }
-
-
-      inline static bool
-      face_orientation(const TriaAccessor<3, 3, 3> &accessor,
-                       const unsigned int           face)
-      {
-        return accessor.tria->levels[accessor.present_level]
-          ->face_orientations.get_orientation(
-            accessor.present_index * GeometryInfo<3>::faces_per_cell + face);
-      }
-
-
-
       template <int dim, int spacedim>
       inline static unsigned char
       combined_face_orientation(
@@ -1369,9 +1331,23 @@ TriaAccessor<structdim, dim, spacedim>::face_orientation(
   const unsigned int face) const
 {
   Assert(used(), TriaAccessorExceptions::ExcCellNotUsed());
+  AssertIndexRange(face, n_faces());
+  Assert(structdim == dim,
+         ExcMessage("This function can only be used on objects "
+                    "that are cells, but not on faces or edges "
+                    "that bound cells."));
+  // work around a bogus GCC-9 warning which considers face unused in 1d
+  (void)face;
 
-  return dealii::internal::TriaAccessorImplementation::Implementation::
-    face_orientation(*this, face);
+  if constexpr (structdim == 1)
+    // in 1d 'faces' are vertices and those are always consistently oriented
+    return true;
+  else if constexpr (structdim == 2)
+    return this->line_orientation(face);
+  else
+    return this->tria->levels[this->present_level]
+      ->face_orientations.get_orientation(
+        this->present_index * GeometryInfo<structdim>::faces_per_cell + face);
 }
 
 

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.