]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Switch to setting the combined orientation.
authorDavid Wells <drwells@email.unc.edu>
Wed, 18 Jan 2023 02:42:10 +0000 (21:42 -0500)
committerDavid Wells <drwells@email.unc.edu>
Sun, 22 Jan 2023 02:42:45 +0000 (21:42 -0500)
include/deal.II/grid/reference_cell.h
include/deal.II/grid/tria_accessor.h
include/deal.II/grid/tria_accessor.templates.h
source/grid/tria.cc

index 5ff5140e4d54b0220a64624222fddffe391ac50f..c6392025a16fe789941b040d8284dde38f450a1e 100644 (file)
@@ -349,6 +349,13 @@ public:
    * @{
    */
 
+  /**
+   * Return the default combined face orientation flag (i.e., the default set of
+   * orientations, defined by orientation, rotate, and flip for a face in 3D).
+   */
+  static constexpr unsigned char
+  default_combined_face_orientation();
+
   /**
    * Return which child cells are adjacent to a certain face of the
    * mother cell.
@@ -1389,6 +1396,14 @@ ReferenceCell::face_reference_cell(const unsigned int face_no) const
 
 
 
+inline constexpr unsigned char
+ReferenceCell::default_combined_face_orientation()
+{
+  return 1u;
+}
+
+
+
 inline unsigned int
 ReferenceCell::child_cell_on_face(
   const unsigned int  face,
index c3ea1f39f5050a8335d8acd1c38d6b764ecf56b5..e8cf2d7c1d117f576974bb86d57f41749c395fc6 100644 (file)
@@ -1799,6 +1799,17 @@ private:
   void
   set_face_rotation(const unsigned int face, const bool rotation) const;
 
+  /**
+   * Set the combined face orientation (i.e., the integer that uniquely encodes
+   * the orientation, flip, and rotation).
+   *
+   * It is only possible to set the face_orientation of cells in 3d (i.e.
+   * <code>structdim==3 && dim==3</code>).
+   */
+  void
+  set_combined_face_orientation(const unsigned int  face,
+                                const unsigned char combined_orientation) const;
+
   /**
    * Set the @p used flag. Only for internal use in the library.
    */
index f27a9ef59253ff7170903079b3e36e4d05bc3419..faad143516ba8791ef950af28c4eab5951ef9ea0 100644 (file)
@@ -926,6 +926,33 @@ namespace internal
                                            value);
       }
 
+      /**
+       * Implementation of the function of some name in the mother class.
+       */
+      template <int structdim, int dim, int spacedim>
+      inline static void
+      set_combined_face_orientation(
+        const TriaAccessor<structdim, dim, spacedim> &,
+        const unsigned int,
+        const unsigned char)
+      {
+        Assert(false, ExcInternalError());
+      }
+
+
+
+      inline static void
+      set_combined_face_orientation(const TriaAccessor<3, 3, 3> &accessor,
+                                    const unsigned int           face,
+                                    const unsigned char combined_orientation)
+      {
+        AssertIndexRange(face, accessor.n_faces());
+        accessor.tria->levels[accessor.present_level]
+          ->face_orientations.set_raw_orientation(
+            accessor.present_index * GeometryInfo<3>::faces_per_cell + face,
+            combined_orientation);
+      }
+
       /**
        * Implementation of the function of some name in the mother class.
        */
@@ -1543,6 +1570,21 @@ TriaAccessor<structdim, dim, spacedim>::set_line_orientation(
 
 
 
+template <int structdim, int dim, int spacedim>
+inline void
+TriaAccessor<structdim, dim, spacedim>::set_combined_face_orientation(
+  const unsigned int  face,
+  const unsigned char combined_orientation) const
+{
+  Assert(used(), TriaAccessorExceptions::ExcCellNotUsed());
+  AssertIndexRange(face, this->n_faces());
+
+  dealii::internal::TriaAccessorImplementation::Implementation::
+    set_combined_face_orientation(*this, face, combined_orientation);
+}
+
+
+
 template <int structdim, int dim, int spacedim>
 void
 TriaAccessor<structdim, dim, spacedim>::set_used_flag() const
index 2b5ee8ac438f44363e0cbed40fca631390031a12..b3a09641f3901ec460d57763d3f4c0f9565d0e08 100644 (file)
@@ -3099,14 +3099,10 @@ namespace internal
             cell->child(child)->clear_user_flag();
 
             for (auto f : GeometryInfo<dim>::face_indices())
-              {
-                // set flags denoting deviations from
-                // standard orientation of faces back
-                // to initialization values
-                cell->child(child)->set_face_orientation(f, true);
-                cell->child(child)->set_face_flip(f, false);
-                cell->child(child)->set_face_rotation(f, false);
-              }
+              // set flags denoting deviations from standard orientation of
+              // faces back to initialization values
+              cell->child(child)->set_combined_face_orientation(
+                f, ReferenceCell::default_combined_face_orientation());
 
             cell->child(child)->clear_used_flag();
           }
@@ -5684,23 +5680,13 @@ namespace internal
                       if (i % 2)
                         new_hex->set_parent(hex->index());
 
-                      // set the face_orientation flag to true for all
-                      // faces initially, as this is the default value
-                      // which is true for all faces interior to the
-                      // hex. later on go the other way round and
-                      // reset faces that are at the boundary of the
-                      // mother cube
-                      //
-                      // the same is true for the face_flip and
-                      // face_rotation flags. however, the latter two
-                      // are set to false by default as this is the
-                      // standard value
+                      // set the orientation flag to its default state for all
+                      // faces initially. later on go the other way round and
+                      // reset faces that are at the boundary of the mother cube
                       for (const auto f : new_hex->face_indices())
-                        {
-                          new_hex->set_face_orientation(f, true);
-                          new_hex->set_face_flip(f, false);
-                          new_hex->set_face_rotation(f, false);
-                        }
+                        new_hex->set_combined_face_orientation(
+                          f,
+                          ReferenceCell::default_combined_face_orientation());
                     }
                   for (unsigned int i = 0; i < n_new_hexes / 2; ++i)
                     hex->set_children(2 * i, new_hexes[2 * i]->index());
@@ -6152,17 +6138,11 @@ namespace internal
                                                                          [2]],
                                   }};
 
-                                const auto orientation =
+                                new_hex->set_combined_face_orientation(
+                                  f,
                                   face->reference_cell().get_orientation_index(
                                     make_array_view(vertices_1),
-                                    make_array_view(vertices_0));
-
-                                new_hex->set_face_orientation(
-                                  f, Utilities::get_bit(orientation, 0));
-                                new_hex->set_face_flip(
-                                  f, Utilities::get_bit(orientation, 2));
-                                new_hex->set_face_rotation(
-                                  f, Utilities::get_bit(orientation, 1));
+                                    make_array_view(vertices_0)));
                               }
                           }
                         else if (new_hex->n_faces() == 6)
@@ -6191,18 +6171,12 @@ namespace internal
                     if (hex->n_faces() == 6)
                       for (const auto f : hex->face_indices())
                         {
-                          const unsigned int orientation =
-                            hex->face_orientation(f);
-                          const unsigned int flip     = hex->face_flip(f);
-                          const unsigned int rotation = hex->face_rotation(f);
+                          const unsigned char combined_orientation =
+                            hex->combined_face_orientation(f);
                           for (unsigned int c = 0; c < 4; ++c)
-                            {
-                              auto &new_hex =
-                                new_hexes[face_to_child_indices_hex[f][c]];
-                              new_hex->set_face_orientation(f, orientation);
-                              new_hex->set_face_flip(f, flip);
-                              new_hex->set_face_rotation(f, rotation);
-                            }
+                            new_hexes[face_to_child_indices_hex[f][c]]
+                              ->set_combined_face_orientation(
+                                f, combined_orientation);
                         }
                   }
                 }
@@ -7709,11 +7683,9 @@ namespace internal
                       // standard value
                       for (const unsigned int f :
                            GeometryInfo<dim>::face_indices())
-                        {
-                          new_hexes[i]->set_face_orientation(f, true);
-                          new_hexes[i]->set_face_flip(f, false);
-                          new_hexes[i]->set_face_rotation(f, false);
-                        }
+                        new_hexes[i]->set_combined_face_orientation(
+                          f,
+                          ReferenceCell::default_combined_face_orientation());
                     }
                   // note these hexes as children to the present cell
                   for (unsigned int i = 0; i < n_new_hexes / 2; ++i)
@@ -7747,6 +7719,15 @@ namespace internal
                                         hex->face_rotation(4),
                                         hex->face_rotation(5)};
 
+                  // combined orientation
+                  const unsigned char f_co[6] = {
+                    hex->combined_face_orientation(0),
+                    hex->combined_face_orientation(1),
+                    hex->combined_face_orientation(2),
+                    hex->combined_face_orientation(3),
+                    hex->combined_face_orientation(4),
+                    hex->combined_face_orientation(5)};
+
                   // little helper table, indicating, whether the
                   // child with index 0 or with index 1 can be found
                   // at the standard origin of an anisotropically
@@ -10535,10 +10516,8 @@ namespace internal
                             f_ro[f],
                             GeometryInfo<dim>::face_refinement_case(
                               ref_case, f, f_or[f], f_fl[f], f_ro[f]));
-                        new_hexes[current_child]->set_face_orientation(f,
-                                                                       f_or[f]);
-                        new_hexes[current_child]->set_face_flip(f, f_fl[f]);
-                        new_hexes[current_child]->set_face_rotation(f, f_ro[f]);
+                        new_hexes[current_child]->set_combined_face_orientation(
+                          f, f_co[f]);
                       }
 
                   // now see if we have created cells that are

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.