]> https://gitweb.dealii.org/ - dealii.git/commitdiff
TriaAccessor: permit calling set_combined_face_orientation() in 2d.
authorDavid Wells <drwells@email.unc.edu>
Sat, 6 Apr 2024 17:17:54 +0000 (13:17 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 8 Apr 2024 15:32:36 +0000 (11:32 -0400)
include/deal.II/grid/tria_accessor.h
include/deal.II/grid/tria_accessor.templates.h

index ebc3dbd05196ba3099cbed8d29d4353b5872e48a..1b783c7d26053bd9e3a4cc437f4f4a469d26f1ab 100644 (file)
@@ -1818,10 +1818,8 @@ private:
 
   /**
    * 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>).
+   * the orientation, flip, and rotation). This function is only implemented for
+   * objects which have faces, i.e., for structdim == dim.
    *
    * @ingroup reordering
    */
index 6538ea24ce5a6ae2f74c78bb410e21cfdb50ce8b..6fd99cee448fedbad57a40634ffe0837adc93d37 100644 (file)
@@ -862,25 +862,36 @@ namespace internal
       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)
-      {
-        DEAL_II_ASSERT_UNREACHABLE();
-      }
-
-
-
-      inline static void
-      set_combined_face_orientation(const TriaAccessor<3, 3, 3> &accessor,
-                                    const unsigned int           face,
-                                    const unsigned char combined_orientation)
+        const TriaAccessor<structdim, dim, spacedim> &accessor,
+        const unsigned int                            face,
+        const unsigned char                           combined_orientation)
       {
+        Assert(structdim == dim,
+               ExcMessage("This function can only be used on objects that are "
+                          "cells and not on objects which bound cells."));
         AssertIndexRange(face, accessor.n_faces());
-        accessor.tria->levels[accessor.present_level]
-          ->face_orientations.set_combined_orientation(
-            accessor.present_index * GeometryInfo<3>::faces_per_cell + face,
-            combined_orientation);
+
+        if (dim == 1)
+          Assert(combined_orientation ==
+                   ReferenceCell::default_combined_face_orientation(),
+                 ExcMessage("In 1d, faces do not have an orientation, so the "
+                            "only valid value is the default."));
+        else if (dim == 2)
+          Assert(combined_orientation ==
+                     ReferenceCell::default_combined_face_orientation() ||
+                   combined_orientation ==
+                     ReferenceCell::reversed_combined_line_orientation(),
+                 ExcMessage(
+                   "In 2d, the only valid values of the combined orientation "
+                   "are the standard orientation or the reversed line "
+                   "orientation."));
+
+        // face_orientations is not set up in 1d
+        if (dim != 1)
+          accessor.tria->levels[accessor.present_level]
+            ->face_orientations.set_combined_orientation(
+              accessor.present_index * GeometryInfo<dim>::faces_per_cell + face,
+              combined_orientation);
       }
 
       /**

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.