]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Un-hardcode some more face and line orientations.
authorDavid Wells <drwells@email.unc.edu>
Sat, 21 Jan 2023 18:16:40 +0000 (13:16 -0500)
committerDavid Wells <drwells@email.unc.edu>
Thu, 26 Jan 2023 21:49:21 +0000 (16:49 -0500)
include/deal.II/dofs/dof_accessor.templates.h
include/deal.II/grid/connectivity.h
include/deal.II/grid/reference_cell.h
include/deal.II/grid/tria_objects_orientations.h
source/grid/tria.cc

index f33d039e1814b9f5803ffc671ab2a35762f48421..c24adfda4cc2af64812cb1c3d65ad7dadb1f56b0 100644 (file)
@@ -1088,7 +1088,8 @@ namespace internal
               const unsigned int raw_orientation = TriaAccessorImplementation::
                 Implementation::face_orientation_raw(accessor, quad);
               const unsigned int quad_index = accessor.quad_index(quad);
-              if (raw_orientation == 1)
+              if (raw_orientation ==
+                  ReferenceCell::default_combined_face_orientation())
                 dof_operation.process_dofs(
                   accessor.get_dof_handler(),
                   0,
index 1319163c65319f32c2b3b886f9bff12e8ddf4544..882727b701491f676df559f2f751297abe36a6f4 100644 (file)
@@ -1317,7 +1317,8 @@ namespace internal
               const unsigned int f = con_cq.col[f_];
 
               // only faces with default orientation have to do something
-              if (ori_cq.get_raw_orientation(f_) != 1u)
+              if (ori_cq.get_raw_orientation(f_) !=
+                  ReferenceCell::default_combined_face_orientation())
                 continue;
 
               // determine entity type of face
@@ -1349,7 +1350,10 @@ namespace internal
                       }
 
                   // ... comparison gives orientation
-                  ori_ql.set_raw_orientation(con_ql.ptr[f] + l, same ? 1u : 0u);
+                  ori_ql.set_raw_orientation(
+                    con_ql.ptr[f] + l,
+                    same ? ReferenceCell::default_combined_face_orientation() :
+                           ReferenceCell::reversed_combined_line_orientation());
                 }
             }
         }
index 9dc0d5b27d78afea2984298c1fe359fcfb22b57f..d6c426337712dfb0e7653b02d6b4ef927bb37a1d 100644 (file)
@@ -356,6 +356,19 @@ public:
   static constexpr unsigned char
   default_combined_face_orientation();
 
+  /**
+   * Return the reversed (non-default orientation) line orientation flag. As
+   * lines only have two possible orientations, this function and
+   * ReferenceCell::default_combined_face_orientation() encode all of its
+   * possible orientation states.
+   *
+   * @note Line orientations are typically stored as booleans, but to better
+   * enable dimension-independent programming relevant functions typically
+   * present these values as unsigned chars.
+   */
+  static constexpr unsigned char
+  reversed_combined_line_orientation();
+
   /**
    * Return which child cells are adjacent to a certain face of the
    * mother cell.
@@ -400,7 +413,8 @@ public:
   unsigned int
   child_cell_on_face(const unsigned int  face,
                      const unsigned int  subface,
-                     const unsigned char face_orientation = 1) const;
+                     const unsigned char face_orientation =
+                       default_combined_face_orientation()) const;
 
   /**
    * For a given vertex in a cell, return a pair of a face index and a
@@ -1436,6 +1450,14 @@ ReferenceCell::default_combined_face_orientation()
 
 
 
+inline constexpr unsigned char
+ReferenceCell::reversed_combined_line_orientation()
+{
+  return 0u;
+}
+
+
+
 inline unsigned int
 ReferenceCell::child_cell_on_face(
   const unsigned int  face,
index 5ae0006bc162c4fa16e201ddb5efdbc71a1371e7..6916f63df66d8850a8e72ebb5e3288ec67c75684 100644 (file)
@@ -22,6 +22,8 @@
 #include <deal.II/base/memory_consumption.h>
 #include <deal.II/base/utilities.h>
 
+#include <deal.II/grid/reference_cell.h>
+
 #include <vector>
 
 DEAL_II_NAMESPACE_OPEN
@@ -195,7 +197,8 @@ namespace internal
     {
       n_stored_objects = n_objects;
       // Assign to the default orientation
-      flags.assign(n_objects, 1u);
+      flags.assign(n_objects,
+                   ReferenceCell::default_combined_face_orientation());
     }
 
 
@@ -203,7 +206,8 @@ namespace internal
     inline void
     TriaObjectsOrientations::resize(const unsigned int n_objects)
     {
-      flags.resize(n_objects, 1u);
+      flags.resize(n_objects,
+                   ReferenceCell::default_combined_face_orientation());
       n_stored_objects = n_objects;
     }
 
index d7e2e06b02c2bb4044636953ce73e88d0fe8494b..a5d70891d81e4a26bce155f56fc6dabafb38029c 100644 (file)
@@ -2354,11 +2354,16 @@ namespace internal
                         k);
                     // it doesn't make sense to set any flags except
                     // orientation for a line
-                    Assert(raw_orientation == 0u || raw_orientation == 1u,
-                           ExcInternalError());
+                    Assert(
+                      raw_orientation ==
+                          ReferenceCell::default_combined_face_orientation() ||
+                        raw_orientation ==
+                          ReferenceCell::reversed_combined_line_orientation(),
+                      ExcInternalError());
                     faces.quads_line_orientations
                       [q * GeometryInfo<3>::lines_per_face + j] =
-                      raw_orientation == 1u;
+                      raw_orientation ==
+                      ReferenceCell::default_combined_face_orientation();
                   }
               }
           }
@@ -2381,7 +2386,8 @@ namespace internal
             {
               const auto &orientations = connectivity.entity_orientations(1);
               for (unsigned int i = 0; i < orientations.n_objects(); ++i)
-                if (orientations.get_raw_orientation(i) != 1u)
+                if (orientations.get_raw_orientation(i) !=
+                    ReferenceCell::default_combined_face_orientation())
                   {
                     orientation_needed = true;
                     break;

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.