]> https://gitweb.dealii.org/ - dealii.git/commitdiff
ReferenceCell: Introduce an alias for std::equal().
authorDavid Wells <drwells@email.unc.edu>
Sat, 21 Jan 2023 18:24:04 +0000 (13:24 -0500)
committerDavid Wells <drwells@email.unc.edu>
Sun, 22 Jan 2023 20:23:57 +0000 (15:23 -0500)
This makes this a lot easier to read.

include/deal.II/grid/reference_cell.h

index a633d5910ca8ff0457d0d78bcf8028befda66c5d..d8a6e4e7d89e8701e4b4334ca84c6a1090771deb 100644 (file)
@@ -2689,127 +2689,86 @@ ReferenceCell::get_orientation_index(const ArrayView<const T> &vertices_0,
                     "the number of vertices of the cell "
                     "referenced by this object."));
 
+  const auto v0_equals = [&](const std::initializer_list<const T> &list) {
+    Assert(list.size() == n_vertices(), ExcInternalError());
+    return std::equal(vertices_0.begin(), vertices_0.end(), std::begin(list));
+  };
+
   switch (this->kind)
     {
       case ReferenceCells::Line:
         // line_orientation=true
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin({vertices_1[0], vertices_1[1]})))
+        if (v0_equals({vertices_1[0], vertices_1[1]}))
           return 1;
 
         // line_orientation=false
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin({vertices_1[1], vertices_1[0]})))
+        if (v0_equals({vertices_1[1], vertices_1[0]}))
           return 0;
         break;
       case ReferenceCells::Triangle:
         // face_orientation=true, face_rotation=false, face_flip=false
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin(
-                         {vertices_1[0], vertices_1[1], vertices_1[2]})))
+        if (v0_equals({vertices_1[0], vertices_1[1], vertices_1[2]}))
           return 1;
 
         // face_orientation=true, face_rotation=true, face_flip=false
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin(
-                         {vertices_1[1], vertices_1[2], vertices_1[0]})))
+        if (v0_equals({vertices_1[1], vertices_1[2], vertices_1[0]}))
           return 3;
 
         // face_orientation=true, face_rotation=false, face_flip=true
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin(
-                         {vertices_1[2], vertices_1[0], vertices_1[1]})))
+        if (v0_equals({vertices_1[2], vertices_1[0], vertices_1[1]}))
           return 5;
 
         // face_orientation=false, face_rotation=false, face_flip=false
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin(
-                         {vertices_1[0], vertices_1[2], vertices_1[1]})))
+        if (v0_equals({vertices_1[0], vertices_1[2], vertices_1[1]}))
           return 0;
 
         // face_orientation=false, face_rotation=true, face_flip=false
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin(
-                         {vertices_1[2], vertices_1[1], vertices_1[0]})))
+        if (v0_equals({vertices_1[2], vertices_1[1], vertices_1[0]}))
           return 2;
 
         // face_orientation=false, face_rotation=false, face_flip=true
-        if (std::equal(vertices_0.begin(),
-                       vertices_0.end(),
-                       std::begin(
-                         {vertices_1[1], vertices_1[0], vertices_1[2]})))
+        if (v0_equals({vertices_1[1], vertices_1[0], vertices_1[2]}))
           return 4;
         break;
       case ReferenceCells::Quadrilateral:
         // face_orientation=true, face_rotation=false, face_flip=false
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[0], vertices_1[1], vertices_1[2], vertices_1[3]})))
+        if (v0_equals(
+              {vertices_1[0], vertices_1[1], vertices_1[2], vertices_1[3]}))
           return 1;
 
         // face_orientation=true, face_rotation=true, face_flip=false
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[2], vertices_1[0], vertices_1[3], vertices_1[1]})))
+        if (v0_equals(
+              {vertices_1[2], vertices_1[0], vertices_1[3], vertices_1[1]}))
           return 3;
 
         // face_orientation=true, face_rotation=false, face_flip=true
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[3], vertices_1[2], vertices_1[1], vertices_1[0]})))
+        if (v0_equals(
+              {vertices_1[3], vertices_1[2], vertices_1[1], vertices_1[0]}))
           return 5;
 
         // face_orientation=true, face_rotation=true, face_flip=true
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[1], vertices_1[3], vertices_1[0], vertices_1[2]})))
+        if (v0_equals(
+              {vertices_1[1], vertices_1[3], vertices_1[0], vertices_1[2]}))
           return 7;
 
         // face_orientation=false, face_rotation=false, face_flip=false
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[0], vertices_1[2], vertices_1[1], vertices_1[3]})))
+        if (v0_equals(
+              {vertices_1[0], vertices_1[2], vertices_1[1], vertices_1[3]}))
           return 0;
 
         // face_orientation=false, face_rotation=true, face_flip=false
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[2], vertices_1[3], vertices_1[0], vertices_1[1]})))
+        if (v0_equals(
+              {vertices_1[2], vertices_1[3], vertices_1[0], vertices_1[1]}))
           return 2;
 
         // face_orientation=false, face_rotation=false, face_flip=true
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[3], vertices_1[1], vertices_1[2], vertices_1[0]})))
+        if (v0_equals(
+              {vertices_1[3], vertices_1[1], vertices_1[2], vertices_1[0]}))
           return 4;
 
         // face_orientation=false, face_rotation=true, face_flip=true
-        if (std::equal(
-              vertices_0.begin(),
-              vertices_0.end(),
-              std::begin(
-                {vertices_1[1], vertices_1[0], vertices_1[3], vertices_1[2]})))
+        if (v0_equals(
+              {vertices_1[1], vertices_1[0], vertices_1[3], vertices_1[2]}))
           return 6;
         break;
       default:

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.