From 398b4f56ebf93b92f2a170c1eb6fade0591429f0 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 5 Apr 2024 10:30:17 +0200 Subject: [PATCH] Add Quadrature::initialize() function taking ArrayView --- include/deal.II/base/quadrature.h | 13 +++++++++++++ source/base/quadrature.cc | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/deal.II/base/quadrature.h b/include/deal.II/base/quadrature.h index 075ff4218c..8827c895fa 100644 --- a/include/deal.II/base/quadrature.h +++ b/include/deal.II/base/quadrature.h @@ -18,6 +18,7 @@ #include +#include #include #include @@ -243,6 +244,18 @@ public: initialize(const std::vector> &points, const std::vector &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> &points, + const ArrayView &weights = {}); + /** * Number of quadrature points. */ diff --git a/source/base/quadrature.cc b/source/base/quadrature.cc index c1f535198e..376d12c93a 100644 --- a/source/base/quadrature.cc +++ b/source/base/quadrature.cc @@ -59,6 +59,31 @@ Quadrature::initialize(const std::vector> &p, +template +void +Quadrature::initialize(const ArrayView> &points, + const ArrayView &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::infinity()); + + quadrature_points.clear(); + quadrature_points.insert(quadrature_points.end(), + points.begin(), + points.end()); + + is_tensor_product_flag = dim == 1; +} + + + template Quadrature::Quadrature(const std::vector> &points, const std::vector &weights) -- 2.39.5