]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Address comments 2989/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 19 Aug 2016 17:57:27 +0000 (11:57 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 19 Aug 2016 17:57:27 +0000 (11:57 -0600)
include/deal.II/base/quadrature_lib.h
source/base/quadrature_lib.cc

index e3e530ba635db34be22a98c6cecc7ac8d0e3ade9..eeb491d34726c4605f76feb667a5d9ebf81c3f59 100644 (file)
@@ -436,15 +436,19 @@ class QSorted : public Quadrature<dim>
 {
 public:
   /**
-   * The constructor takes an arbitrary quadrature formula.
+   * The constructor takes an arbitrary quadrature formula @p quad and sorts
+   * its points and weights according to ascending weights.
    */
   QSorted (const Quadrature<dim> &quad);
 
+private:
   /**
-   * A rule to reorder pairs of points and weights.
+   * A rule for std::sort to reorder pairs of points and weights.
+   * @p a and @p b are indices into the weights array and the result will
+   * be determined by comparing the weights.
    */
-  bool operator()(const std::size_t &a,
-                  const std::size_t &b) const;
+  bool compare_weights(const unsigned int a,
+                       const unsigned int b) const;
 };
 
 /**
index e9c961c1b20daa6fe724eb66b9fff2c23e8314d0..107f851fbb6fc82e14163d3621dacbb897668170 100644 (file)
@@ -16,6 +16,7 @@
 #include <deal.II/base/quadrature_lib.h>
 #include <deal.II/base/geometry_info.h>
 
+#include <deal.II/base/std_cxx11/bind.h>
 
 #include <cmath>
 #include <limits>
@@ -935,9 +936,16 @@ template <int dim>
 QSorted<dim>::QSorted(const Quadrature<dim> &quad) :
   Quadrature<dim>(quad)
 {
-  std::vector<std::size_t> permutation(quad.size());
-  std::iota(permutation.begin(), permutation.end(), 0);
-  std::sort(permutation.begin(), permutation.end(), *this);
+  std::vector<unsigned int> permutation(quad.size());
+  for (unsigned int i=0; i<quad.size(); ++i)
+    permutation[i] = i;
+
+  std::sort(permutation.begin(),
+            permutation.end(),
+            std_cxx11::bind(&QSorted<dim>::compare_weights,
+                            std_cxx11::ref(*this),
+                            std_cxx11::_1,
+                            std_cxx11::_2));
 
   for (unsigned int i=0; i<quad.size(); ++i)
     {
@@ -948,8 +956,8 @@ QSorted<dim>::QSorted(const Quadrature<dim> &quad) :
 
 
 template <int dim>
-bool QSorted<dim>::operator()(const std::size_t &a,
-                              const std::size_t &b) const
+bool QSorted<dim>::compare_weights(const unsigned int a,
+                                   const unsigned int b) const
 {
   return (this->weights[a] < this->weights[b]);
 }

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.