]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add Quadrature::initialize() function taking ArrayView
authorMartin Kronbichler <martin.kronbichler@rub.de>
Fri, 5 Apr 2024 08:30:17 +0000 (10:30 +0200)
committerMartin Kronbichler <martin.kronbichler@rub.de>
Fri, 5 Apr 2024 08:30:17 +0000 (10:30 +0200)
include/deal.II/base/quadrature.h
source/base/quadrature.cc

index 075ff4218cf7cfce0c6cd806356eb5892f3489d6..8827c895fac5cfff4677caec5919522f3cecc277 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <deal.II/base/config.h>
 
+#include <deal.II/base/array_view.h>
 #include <deal.II/base/point.h>
 #include <deal.II/base/subscriptor.h>
 
@@ -243,6 +244,18 @@ public:
   initialize(const std::vector<Point<dim>> &points,
              const std::vector<double>     &weights);
 
+  /**
+   * Set the quadrature points and weights to the values provided in the
+   * arguments. The weights array is allowed to be empty, in which case the
+   * weights are set to infinity. The resulting object is therefore not meant
+   * to actually perform integrations, but rather to be used with FEValues
+   * objects in order to find the position of some points (the quadrature
+   * points in this object) on the transformed cell in real space.
+   */
+  void
+  initialize(const ArrayView<const Point<dim>> &points,
+             const ArrayView<const double>     &weights = {});
+
   /**
    * Number of quadrature points.
    */
index c1f535198e8a4a44cafe5d6aeaa4b2e9ca4f2be9..376d12c93aa5b5fa3ec43c86df296e586f51d6ae 100644 (file)
@@ -59,6 +59,31 @@ Quadrature<dim>::initialize(const std::vector<Point<dim>> &p,
 
 
 
+template <int dim>
+void
+Quadrature<dim>::initialize(const ArrayView<const Point<dim>> &points,
+                            const ArrayView<const double>     &weights)
+{
+  this->weights.clear();
+  if (!weights.empty())
+    {
+      AssertDimension(weights.size(), points.size());
+      this->weights.insert(this->weights.end(), weights.begin(), weights.end());
+    }
+  else
+    this->weights.resize(points.size(),
+                         std::numeric_limits<double>::infinity());
+
+  quadrature_points.clear();
+  quadrature_points.insert(quadrature_points.end(),
+                           points.begin(),
+                           points.end());
+
+  is_tensor_product_flag = dim == 1;
+}
+
+
+
 template <int dim>
 Quadrature<dim>::Quadrature(const std::vector<Point<dim>> &points,
                             const std::vector<double>     &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.