]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Minor simplification in QProjector. 11640/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 27 Jan 2021 16:27:44 +0000 (09:27 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 27 Jan 2021 16:28:25 +0000 (09:28 -0700)
source/base/qprojector.cc

index 6d05bf719b43ab4006d30820385bfcf616dfeef5..7387aba1f638e4139707eed909135bc7021396cc 100644 (file)
@@ -27,17 +27,12 @@ template <int dim>
 Quadrature<2>
 QProjector<dim>::reflect(const Quadrature<2> &q)
 {
-  std::vector<Point<2>> q_points(q.size());
-  std::vector<double>   weights(q.size());
-  for (unsigned int i = 0; i < q.size(); ++i)
-    {
-      q_points[i][0] = q.point(i)[1];
-      q_points[i][1] = q.point(i)[0];
+  // 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]);
 
-      weights[i] = q.weight(i);
-    }
-
-  return Quadrature<2>(q_points, weights);
+  return Quadrature<2>(q_points, q.get_weights());
 }
 
 
@@ -46,16 +41,15 @@ Quadrature<2>
 QProjector<dim>::rotate(const Quadrature<2> &q, const unsigned int n_times)
 {
   std::vector<Point<2>> q_points(q.size());
-  std::vector<double>   weights(q.size());
   for (unsigned int i = 0; i < q.size(); ++i)
     {
       switch (n_times % 4)
         {
           case 0:
-            // 0 degree
-            q_points[i][0] = q.point(i)[0];
-            q_points[i][1] = q.point(i)[1];
+            // 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];
@@ -72,11 +66,9 @@ QProjector<dim>::rotate(const Quadrature<2> &q, const unsigned int n_times)
             q_points[i][1] = 1.0 - q.point(i)[0];
             break;
         }
-
-      weights[i] = q.weight(i);
     }
 
-  return Quadrature<2>(q_points, weights);
+  return Quadrature<2>(q_points, q.get_weights());
 }
 
 

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.