Reference documentation for deal.II version Git 6d836ad036 2021-06-16 20:57:45 +0200
\(\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\}}\)
quadrature.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2021 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_quadrature_h
17 #define dealii_quadrature_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/point.h>
24 
25 #include <array>
26 #include <memory>
27 #include <vector>
28 
30 
33 
82 template <int dim>
83 class Quadrature : public Subscriptor
84 {
85 public:
90  using SubQuadrature = Quadrature<dim - 1>;
91 
100  explicit Quadrature(const unsigned int n_quadrature_points = 0);
101 
110  Quadrature(const SubQuadrature &, const Quadrature<1> &);
111 
131  explicit Quadrature(const Quadrature<dim != 1 ? 1 : 0> &quadrature_1d);
132 
136  Quadrature(const Quadrature<dim> &q);
137 
142  Quadrature(Quadrature<dim> &&) noexcept = default;
143 
149  Quadrature(const std::vector<Point<dim>> &points,
150  const std::vector<double> & weights);
151 
159  Quadrature(const std::vector<Point<dim>> &points);
160 
165  Quadrature(const Point<dim> &point);
166 
170  virtual ~Quadrature() override = default;
171 
176  Quadrature &
177  operator=(const Quadrature<dim> &);
178 
183  Quadrature &
184  operator=(Quadrature<dim> &&) = default; // NOLINT
185 
189  bool
190  operator==(const Quadrature<dim> &p) const;
191 
196  void
197  initialize(const std::vector<Point<dim>> &points,
198  const std::vector<double> & weights);
199 
203  unsigned int
204  size() const;
205 
209  const Point<dim> &
210  point(const unsigned int i) const;
211 
215  const std::vector<Point<dim>> &
216  get_points() const;
217 
221  double
222  weight(const unsigned int i) const;
223 
227  const std::vector<double> &
228  get_weights() const;
229 
234  std::size_t
235  memory_consumption() const;
236 
242  template <class Archive>
243  void
244  serialize(Archive &ar, const unsigned int version);
245 
251  bool
252  is_tensor_product() const;
253 
272 #ifndef DOXYGEN
273  typename std::conditional<dim == 1,
274  std::array<Quadrature<1>, dim>,
275  const std::array<Quadrature<1>, dim> &>::type
276 #else
277  const std::array<Quadrature<1>, dim> &
278 #endif
279  get_tensor_basis() const;
280 
281 protected:
286  std::vector<Point<dim>> quadrature_points;
287 
292  std::vector<double> weights;
293 
302 
307  std::unique_ptr<std::array<Quadrature<1>, dim>> tensor_basis;
308 };
309 
310 
319 template <int dim>
320 class QAnisotropic : public Quadrature<dim>
321 {
322 public:
327  QAnisotropic(const Quadrature<1> &qx);
328 
332  QAnisotropic(const Quadrature<1> &qx, const Quadrature<1> &qy);
333 
337  QAnisotropic(const Quadrature<1> &qx,
338  const Quadrature<1> &qy,
339  const Quadrature<1> &qz);
340 };
341 
342 
366 template <int dim>
367 class QIterated : public Quadrature<dim>
368 {
369 public:
374  QIterated(const Quadrature<1> &base_quadrature, const unsigned int n_copies);
375 
379  DeclExceptionMsg(ExcInvalidQuadratureFormula,
380  "The quadrature formula you provided cannot be used "
381  "as the basis for iteration.");
382 };
383 
384 
385 
388 #ifndef DOXYGEN
389 
390 // ------------------- inline and template functions ----------------
391 
392 
393 template <int dim>
394 inline unsigned int
395 Quadrature<dim>::size() const
396 {
397  return weights.size();
398 }
399 
400 
401 template <int dim>
402 inline const Point<dim> &
403 Quadrature<dim>::point(const unsigned int i) const
404 {
405  AssertIndexRange(i, size());
406  return quadrature_points[i];
407 }
408 
409 
410 
411 template <int dim>
412 double
413 Quadrature<dim>::weight(const unsigned int i) const
414 {
415  AssertIndexRange(i, size());
416  return weights[i];
417 }
418 
419 
420 
421 template <int dim>
422 inline const std::vector<Point<dim>> &
424 {
425  return quadrature_points;
426 }
427 
428 
429 
430 template <int dim>
431 inline const std::vector<double> &
433 {
434  return weights;
435 }
436 
437 
438 
439 template <int dim>
440 inline bool
442 {
443  return is_tensor_product_flag;
444 }
445 
446 
447 
448 template <int dim>
449 template <class Archive>
450 inline void
451 Quadrature<dim>::serialize(Archive &ar, const unsigned int)
452 {
453  // forward to serialization
454  // function in the base class.
455  ar &static_cast<Subscriptor &>(*this);
456 
458 }
459 
460 
461 
462 /* -------------- declaration of explicit specializations ------------- */
463 
464 template <>
465 Quadrature<0>::Quadrature(const unsigned int);
466 template <>
468 template <>
470 template <>
472 
473 template <>
475 
476 template <>
478 
479 template <>
480 QIterated<1>::QIterated(const Quadrature<1> &base_quadrature,
481  const unsigned int n_copies);
482 
483 #endif // DOXYGEN
485 
486 #endif
std::vector< double > weights
Definition: quadrature.h:292
const std::vector< Point< dim > > & get_points() const
const std::vector< double > & get_weights() const
Quadrature(const unsigned int n_quadrature_points=0)
Definition: quadrature.cc:40
#define AssertIndexRange(index, range)
Definition: exceptions.h:1721
const Point< dim > & point(const unsigned int i) const
STL namespace.
const std::array< Quadrature< 1 >, dim > & get_tensor_basis() const
Definition: quadrature.cc:322
Definition: point.h:110
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:493
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:399
std::size_t memory_consumption() const
Definition: quadrature.cc:310
bool is_tensor_product_flag
Definition: quadrature.h:301
std::vector< Point< dim > > quadrature_points
Definition: quadrature.h:286
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:398
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
Definition: quadrature.cc:560
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
Definition: quadrature.h:307
void initialize(const std::vector< Point< dim >> &points, const std::vector< double > &weights)
Definition: quadrature.cc:50
void serialize(Archive &ar, const unsigned int version)
bool is_tensor_product() const
double weight(const unsigned int i) const