From: Wolfgang Bangerth Date: Wed, 27 Jan 2021 16:27:44 +0000 (-0700) Subject: Minor simplification in QProjector. X-Git-Tag: v9.3.0-rc1~557^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5078e96a97be1a6fb097123a0a785b5e5536239e;p=dealii.git Minor simplification in QProjector. --- diff --git a/source/base/qprojector.cc b/source/base/qprojector.cc index 6d05bf719b..7387aba1f6 100644 --- a/source/base/qprojector.cc +++ b/source/base/qprojector.cc @@ -27,17 +27,12 @@ template Quadrature<2> QProjector::reflect(const Quadrature<2> &q) { - std::vector> q_points(q.size()); - std::vector 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> 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::rotate(const Quadrature<2> &q, const unsigned int n_times) { std::vector> q_points(q.size()); - std::vector 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::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()); }