deal.II version GIT relicensing-2287-g6548a49e0a 2024-12-20 18:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
quadrature.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1998 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_quadrature_h
16#define dealii_quadrature_h
17
18
19#include <deal.II/base/config.h>
20
23#include <deal.II/base/point.h>
24
25#include <array>
26#include <memory>
27#include <vector>
28
30
121template <int dim>
123{
124public:
130 using SubQuadrature = Quadrature<dim == 0 ? 0 : dim - 1>;
131
135 Quadrature();
136
145 Quadrature(const SubQuadrature &, const Quadrature<1> &);
146
166 explicit Quadrature(const Quadrature<dim != 1 ? 1 : 0> &quadrature_1d);
167
171 Quadrature(const Quadrature<dim> &q);
172
177 Quadrature(Quadrature<dim> &&) noexcept = default;
178
184 Quadrature(const std::vector<Point<dim>> &points,
185 const std::vector<double> &weights);
186
192 Quadrature(std::vector<Point<dim>> &&points, std::vector<double> &&weights);
193
201 Quadrature(const std::vector<Point<dim>> &points);
202
207 Quadrature(const Point<dim> &point);
208
212 virtual ~Quadrature() override = default;
213
218 Quadrature &
219 operator=(const Quadrature<dim> &);
220
225 Quadrature &
226 operator=(Quadrature<dim> &&) = default; // NOLINT
227
231 bool
232 operator==(const Quadrature<dim> &p) const;
233
242 void
243 initialize(const ArrayView<const Point<dim>> &points,
244 const ArrayView<const double> &weights = {});
245
249 unsigned int
250 size() const;
251
255 bool
256 empty() const;
257
261 const Point<dim> &
262 point(const unsigned int i) const;
263
267 const std::vector<Point<dim>> &
268 get_points() const;
269
273 double
274 weight(const unsigned int i) const;
275
279 const std::vector<double> &
280 get_weights() const;
281
286 std::size_t
287 memory_consumption() const;
288
294 template <class Archive>
295 void
296 serialize(Archive &ar, const unsigned int version);
297
303 bool
305
324#ifndef DOXYGEN
325 std::conditional_t<dim == 1,
326 std::array<Quadrature<1>, dim>,
327 const std::array<Quadrature<1>, dim> &>
328#else
329 const std::array<Quadrature<1>, dim> &
330#endif
331 get_tensor_basis() const;
332
333protected:
347 explicit Quadrature(const unsigned int n_quadrature_points);
348
353 std::vector<Point<dim>> quadrature_points;
354
359 std::vector<double> weights;
360
369
374 std::unique_ptr<std::array<Quadrature<1>, dim>> tensor_basis;
375};
376
377
386template <int dim>
387class QAnisotropic : public Quadrature<dim>
388{
389public:
394 QAnisotropic(const Quadrature<1> &qx);
395
399 QAnisotropic(const Quadrature<1> &qx, const Quadrature<1> &qy);
400
404 QAnisotropic(const Quadrature<1> &qx,
405 const Quadrature<1> &qy,
406 const Quadrature<1> &qz);
407};
408
409
433template <int dim>
434class QIterated : public Quadrature<dim>
435{
436public:
443 QIterated(const Quadrature<1> &base_quadrature, const unsigned int n_copies);
444
456 QIterated(const Quadrature<1> &base_quadrature,
457 const std::vector<Point<1>> &intervals);
458
463 "The quadrature formula you provided cannot be used "
464 "as the basis for iteration.");
465};
466
467
468
471#ifndef DOXYGEN
472
473// ------------------- inline and template functions ----------------
474
475
476template <int dim>
477inline unsigned int
479{
480 return weights.size();
481}
482
483
484
485template <int dim>
486inline bool
488{
489 return weights.empty();
490}
491
492
493
494template <int dim>
495inline const Point<dim> &
496Quadrature<dim>::point(const unsigned int i) const
497{
499 return quadrature_points[i];
500}
501
502
503
504template <int dim>
505double
506Quadrature<dim>::weight(const unsigned int i) const
507{
509 return weights[i];
510}
511
512
513
514template <int dim>
515inline const std::vector<Point<dim>> &
517{
518 return quadrature_points;
519}
520
521
522
523template <int dim>
524inline const std::vector<double> &
526{
527 return weights;
528}
529
530
531
532template <int dim>
533inline bool
535{
536 return is_tensor_product_flag;
537}
538
539
540
541template <int dim>
542template <class Archive>
543inline void
544Quadrature<dim>::serialize(Archive &ar, const unsigned int)
545{
546 // forward to serialization
547 // function in the base class.
548 ar &static_cast<EnableObserverPointer &>(*this);
549
550 ar &quadrature_points &weights;
551}
552
553
554
555/* -------------- declaration of explicit specializations ------------- */
556
557template <>
558Quadrature<0>::Quadrature(const unsigned int);
559template <>
561 const Quadrature<1> &);
562template <>
564template <>
566
567template <>
569
570template <>
572
573template <>
574QIterated<1>::QIterated(const Quadrature<1> &base_quadrature,
575 const unsigned int n_copies);
576
577#endif // DOXYGEN
579
580#endif
Definition point.h:111
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
std::vector< Point< dim > > quadrature_points
Definition quadrature.h:353
void initialize(const ArrayView< const Point< dim > > &points, const ArrayView< const double > &weights={})
Definition quadrature.cc:63
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
Definition quadrature.h:374
bool is_tensor_product() const
std::size_t memory_consumption() const
const Point< dim > & point(const unsigned int i) const
bool is_tensor_product_flag
Definition quadrature.h:368
double weight(const unsigned int i) const
const std::vector< double > & get_weights() const
const std::array< Quadrature< 1 >, dim > & get_tensor_basis() const
Quadrature(Quadrature< dim > &&) noexcept=default
std::vector< double > weights
Definition quadrature.h:359
const std::vector< Point< dim > > & get_points() const
bool empty() const
unsigned int size() const
void serialize(Archive &ar, const unsigned int version)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
static ::ExceptionBase & ExcInvalidQuadratureFormula()
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
Definition exceptions.h:489
std::size_t size
Definition mpi.cc:734
void quadrature_points(const Triangulation< dim, spacedim > &triangulation, const Quadrature< dim > &quadrature, const std::vector< std::vector< BoundingBox< spacedim > > > &global_bounding_boxes, ParticleHandler< dim, spacedim > &particle_handler, const Mapping< dim, spacedim > &mapping=(ReferenceCells::get_hypercube< dim >() .template get_default_linear_mapping< dim, spacedim >()), const std::vector< std::vector< double > > &properties={})
STL namespace.