Reference documentation for deal.II version Git 500a7ed831 2022-01-17 20:04:17 -0700
\(\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 
85 template <int dim>
86 class Quadrature : public Subscriptor
87 {
88 public:
93  using SubQuadrature = Quadrature<dim - 1>;
94 
103  explicit Quadrature(const unsigned int n_quadrature_points = 0);
104 
113  Quadrature(const SubQuadrature &, const Quadrature<1> &);
114 
134  explicit Quadrature(const Quadrature<dim != 1 ? 1 : 0> &quadrature_1d);
135 
139  Quadrature(const Quadrature<dim> &q);
140 
145  Quadrature(Quadrature<dim> &&) noexcept = default;
146 
152  Quadrature(const std::vector<Point<dim>> &points,
153  const std::vector<double> & weights);
154 
162  Quadrature(const std::vector<Point<dim>> &points);
163 
168  Quadrature(const Point<dim> &point);
169 
173  virtual ~Quadrature() override = default;
174 
179  Quadrature &
180  operator=(const Quadrature<dim> &);
181 
186  Quadrature &
187  operator=(Quadrature<dim> &&) = default; // NOLINT
188 
192  bool
193  operator==(const Quadrature<dim> &p) const;
194 
199  void
200  initialize(const std::vector<Point<dim>> &points,
201  const std::vector<double> & weights);
202 
206  unsigned int
207  size() const;
208 
212  const Point<dim> &
213  point(const unsigned int i) const;
214 
218  const std::vector<Point<dim>> &
219  get_points() const;
220 
224  double
225  weight(const unsigned int i) const;
226 
230  const std::vector<double> &
231  get_weights() const;
232 
237  std::size_t
238  memory_consumption() const;
239 
245  template <class Archive>
246  void
247  serialize(Archive &ar, const unsigned int version);
248 
254  bool
255  is_tensor_product() const;
256 
275 #ifndef DOXYGEN
276  typename std::conditional<dim == 1,
277  std::array<Quadrature<1>, dim>,
278  const std::array<Quadrature<1>, dim> &>::type
279 #else
280  const std::array<Quadrature<1>, dim> &
281 #endif
282  get_tensor_basis() const;
283 
284 protected:
289  std::vector<Point<dim>> quadrature_points;
290 
295  std::vector<double> weights;
296 
305 
310  std::unique_ptr<std::array<Quadrature<1>, dim>> tensor_basis;
311 };
312 
313 
322 template <int dim>
323 class QAnisotropic : public Quadrature<dim>
324 {
325 public:
330  QAnisotropic(const Quadrature<1> &qx);
331 
335  QAnisotropic(const Quadrature<1> &qx, const Quadrature<1> &qy);
336 
340  QAnisotropic(const Quadrature<1> &qx,
341  const Quadrature<1> &qy,
342  const Quadrature<1> &qz);
343 };
344 
345 
369 template <int dim>
370 class QIterated : public Quadrature<dim>
371 {
372 public:
379  QIterated(const Quadrature<1> &base_quadrature, const unsigned int n_copies);
380 
392  QIterated(const Quadrature<1> & base_quadrature,
393  const std::vector<Point<1>> &intervals);
394 
398  DeclExceptionMsg(ExcInvalidQuadratureFormula,
399  "The quadrature formula you provided cannot be used "
400  "as the basis for iteration.");
401 };
402 
403 
404 
407 #ifndef DOXYGEN
408 
409 // ------------------- inline and template functions ----------------
410 
411 
412 template <int dim>
413 inline unsigned int
414 Quadrature<dim>::size() const
415 {
416  return weights.size();
417 }
418 
419 
420 template <int dim>
421 inline const Point<dim> &
422 Quadrature<dim>::point(const unsigned int i) const
423 {
424  AssertIndexRange(i, size());
425  return quadrature_points[i];
426 }
427 
428 
429 
430 template <int dim>
431 double
432 Quadrature<dim>::weight(const unsigned int i) const
433 {
434  AssertIndexRange(i, size());
435  return weights[i];
436 }
437 
438 
439 
440 template <int dim>
441 inline const std::vector<Point<dim>> &
443 {
444  return quadrature_points;
445 }
446 
447 
448 
449 template <int dim>
450 inline const std::vector<double> &
452 {
453  return weights;
454 }
455 
456 
457 
458 template <int dim>
459 inline bool
461 {
462  return is_tensor_product_flag;
463 }
464 
465 
466 
467 template <int dim>
468 template <class Archive>
469 inline void
470 Quadrature<dim>::serialize(Archive &ar, const unsigned int)
471 {
472  // forward to serialization
473  // function in the base class.
474  ar &static_cast<Subscriptor &>(*this);
475 
477 }
478 
479 
480 
481 /* -------------- declaration of explicit specializations ------------- */
482 
483 template <>
484 Quadrature<0>::Quadrature(const unsigned int);
485 template <>
487 template <>
489 template <>
491 
492 template <>
494 
495 template <>
497 
498 template <>
499 QIterated<1>::QIterated(const Quadrature<1> &base_quadrature,
500  const unsigned int n_copies);
501 
502 #endif // DOXYGEN
504 
505 #endif
std::vector< double > weights
Definition: quadrature.h:295
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:1720
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:487
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:407
std::size_t memory_consumption() const
Definition: quadrature.cc:310
bool is_tensor_product_flag
Definition: quadrature.h:304
std::vector< Point< dim > > quadrature_points
Definition: quadrature.h:289
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:406
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
Definition: quadrature.cc:627
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
Definition: quadrature.h:310
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