]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move two static private functions into an internal namespace.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Jan 2021 21:06:05 +0000 (14:06 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Jan 2021 21:26:36 +0000 (14:26 -0700)
include/deal.II/base/qprojector.h
source/base/qprojector.cc

index 501e6eeabb59f6d542cc468468ddc02540c34ba7..942e5894c798018648cfa2ca306b681ab6b3b291 100644 (file)
@@ -535,29 +535,6 @@ public:
      */
     DataSetDescriptor(const unsigned int dataset_offset);
   };
-
-private:
-  /**
-   * Given a quadrature object in 2d, reflect all quadrature points at the
-   * main diagonal and return them with their original weights.
-   *
-   * This function is necessary for projecting a 2d quadrature rule onto the
-   * faces of a 3d cube, since there we need both orientations.
-   */
-  static Quadrature<2>
-  reflect(const Quadrature<2> &q);
-
-  /**
-   * Given a quadrature object in 2d, rotate all quadrature points by @p
-   * n_times * 90 degrees counterclockwise and return them with their original
-   * weights.
-   *
-   * This function is necessary for projecting a 2d quadrature rule onto the
-   * faces of a 3d cube, since there we need all rotations to account for
-   * face_flip and face_rotation of non-standard faces.
-   */
-  static Quadrature<2>
-  rotate(const Quadrature<2> &q, const unsigned int n_times);
 };
 
 /*@}*/
index 7387aba1f638e4139707eed909135bc7021396cc..6a12d014d0b22a86131114360cfe3f9763a59bac 100644 (file)
 DEAL_II_NAMESPACE_OPEN
 
 
-template <int dim>
-Quadrature<2>
-QProjector<dim>::reflect(const Quadrature<2> &q)
+namespace internal
 {
-  // Take the points and reflect them by the diagonal
-  std::vector<Point<2>> q_points(q.get_points());
-  for (Point<2> &p : q_points)
-    std::swap(p[0], p[1]);
+  namespace QProjector
+  {
+    Quadrature<2>
+    reflect(const Quadrature<2> &q)
+    {
+      // Take the points and reflect them by the diagonal
+      std::vector<Point<2>> q_points(q.get_points());
+      for (Point<2> &p : q_points)
+        std::swap(p[0], p[1]);
 
-  return Quadrature<2>(q_points, q.get_weights());
-}
+      return Quadrature<2>(q_points, q.get_weights());
+    }
 
 
-template <int dim>
-Quadrature<2>
-QProjector<dim>::rotate(const Quadrature<2> &q, const unsigned int n_times)
-{
-  std::vector<Point<2>> q_points(q.size());
-  for (unsigned int i = 0; i < q.size(); ++i)
+    Quadrature<2>
+    rotate(const Quadrature<2> &q, const unsigned int n_times)
     {
-      switch (n_times % 4)
+      std::vector<Point<2>> q_points(q.size());
+      for (unsigned int i = 0; i < q.size(); ++i)
         {
-          case 0:
-            // 0 degree. the point remains as it is.
-            q_points[i] = q.point(i);
-            break;
-
-          case 1:
-            // 90 degree counterclockwise
-            q_points[i][0] = 1.0 - q.point(i)[1];
-            q_points[i][1] = q.point(i)[0];
-            break;
-          case 2:
-            // 180 degree counterclockwise
-            q_points[i][0] = 1.0 - q.point(i)[0];
-            q_points[i][1] = 1.0 - q.point(i)[1];
-            break;
-          case 3:
-            // 270 degree counterclockwise
-            q_points[i][0] = q.point(i)[1];
-            q_points[i][1] = 1.0 - q.point(i)[0];
-            break;
+          switch (n_times % 4)
+            {
+              case 0:
+                // 0 degree. the point remains as it is.
+                q_points[i] = q.point(i);
+                break;
+
+              case 1:
+                // 90 degree counterclockwise
+                q_points[i][0] = 1.0 - q.point(i)[1];
+                q_points[i][1] = q.point(i)[0];
+                break;
+              case 2:
+                // 180 degree counterclockwise
+                q_points[i][0] = 1.0 - q.point(i)[0];
+                q_points[i][1] = 1.0 - q.point(i)[1];
+                break;
+              case 3:
+                // 270 degree counterclockwise
+                q_points[i][0] = q.point(i)[1];
+                q_points[i][1] = 1.0 - q.point(i)[0];
+                break;
+            }
         }
+
+      return Quadrature<2>(q_points, q.get_weights());
     }
+  } // namespace QProjector
+} // namespace internal
 
-  return Quadrature<2>(q_points, q.get_weights());
-}
 
 
 template <>
@@ -891,25 +896,28 @@ QProjector<3>::project_to_all_faces(
                 mutation = quadrature_f;
                 break;
               case 1:
-                mutation = rotate(quadrature_f, 1);
+                mutation = internal::QProjector::rotate(quadrature_f, 1);
                 break;
               case 2:
-                mutation = rotate(quadrature_f, 2);
+                mutation = internal::QProjector::rotate(quadrature_f, 2);
                 break;
               case 3:
-                mutation = rotate(quadrature_f, 3);
+                mutation = internal::QProjector::rotate(quadrature_f, 3);
                 break;
               case 4:
-                mutation = reflect(quadrature_f);
+                mutation = internal::QProjector::reflect(quadrature_f);
                 break;
               case 5:
-                mutation = rotate(reflect(quadrature_f), 3);
+                mutation = internal::QProjector::rotate(
+                  internal::QProjector::reflect(quadrature_f), 3);
                 break;
               case 6:
-                mutation = rotate(reflect(quadrature_f), 2);
+                mutation = internal::QProjector::rotate(
+                  internal::QProjector::reflect(quadrature_f), 2);
                 break;
               case 7:
-                mutation = rotate(reflect(quadrature_f), 1);
+                mutation = internal::QProjector::rotate(
+                  internal::QProjector::reflect(quadrature_f), 1);
                 break;
               default:
                 Assert(false, ExcInternalError())
@@ -1065,15 +1073,15 @@ QProjector<3>::project_to_all_subfaces(
   Assert(reference_cell_type == ReferenceCell::Type::Hex, ExcNotImplemented());
 
   const unsigned int dim         = 3;
-  SubQuadrature      q_reflected = reflect(quadrature);
+  SubQuadrature      q_reflected = internal::QProjector::reflect(quadrature);
   SubQuadrature      q[8]        = {quadrature,
-                        rotate(quadrature, 1),
-                        rotate(quadrature, 2),
-                        rotate(quadrature, 3),
+                        internal::QProjector::rotate(quadrature, 1),
+                        internal::QProjector::rotate(quadrature, 2),
+                        internal::QProjector::rotate(quadrature, 3),
                         q_reflected,
-                        rotate(q_reflected, 3),
-                        rotate(q_reflected, 2),
-                        rotate(q_reflected, 1)};
+                        internal::QProjector::rotate(q_reflected, 3),
+                        internal::QProjector::rotate(q_reflected, 2),
+                        internal::QProjector::rotate(q_reflected, 1)};
 
   const unsigned int n_points = quadrature.size(),
                      n_faces  = GeometryInfo<dim>::faces_per_cell,

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.