Reference documentation for deal.II version Git 040c6ad7d4 2020-09-26 18:01:03 +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 - 2018 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 
128  explicit Quadrature(const Quadrature<dim != 1 ? 1 : 0> &quadrature_1d);
129 
133  Quadrature(const Quadrature<dim> &q);
134 
139  Quadrature(Quadrature<dim> &&) noexcept = default;
140 
146  Quadrature(const std::vector<Point<dim>> &points,
147  const std::vector<double> & weights);
148 
156  Quadrature(const std::vector<Point<dim>> &points);
157 
162  Quadrature(const Point<dim> &point);
163 
167  virtual ~Quadrature() override = default;
168 
173  Quadrature &
174  operator=(const Quadrature<dim> &);
175 
180  Quadrature &
181  operator=(Quadrature<dim> &&) = default; // NOLINT
182 
186  bool
187  operator==(const Quadrature<dim> &p) const;
188 
193  void
194  initialize(const std::vector<Point<dim>> &points,
195  const std::vector<double> & weights);
196 
200  unsigned int
201  size() const;
202 
206  const Point<dim> &
207  point(const unsigned int i) const;
208 
212  const std::vector<Point<dim>> &
213  get_points() const;
214 
218  double
219  weight(const unsigned int i) const;
220 
224  const std::vector<double> &
225  get_weights() const;
226 
231  std::size_t
232  memory_consumption() const;
233 
238  template <class Archive>
239  void
240  serialize(Archive &ar, const unsigned int version);
241 
247  bool
248  is_tensor_product() const;
249 
268 #ifndef DOXYGEN
269  typename std::conditional<dim == 1,
270  std::array<Quadrature<1>, dim>,
271  const std::array<Quadrature<1>, dim> &>::type
272 #else
273  const std::array<Quadrature<1>, dim> &
274 #endif
275  get_tensor_basis() const;
276 
277 protected:
282  std::vector<Point<dim>> quadrature_points;
283 
288  std::vector<double> weights;
289 
298 
303  std::unique_ptr<std::array<Quadrature<1>, dim>> tensor_basis;
304 };
305 
306 
315 template <int dim>
316 class QAnisotropic : public Quadrature<dim>
317 {
318 public:
323  QAnisotropic(const Quadrature<1> &qx);
324 
328  QAnisotropic(const Quadrature<1> &qx, const Quadrature<1> &qy);
329 
333  QAnisotropic(const Quadrature<1> &qx,
334  const Quadrature<1> &qy,
335  const Quadrature<1> &qz);
336 };
337 
338 
362 template <int dim>
363 class QIterated : public Quadrature<dim>
364 {
365 public:
370  QIterated(const Quadrature<1> &base_quadrature, const unsigned int n_copies);
371 
375  DeclExceptionMsg(ExcInvalidQuadratureFormula,
376  "The quadrature formula you provided cannot be used "
377  "as the basis for iteration.");
378 };
379 
380 
381 
384 #ifndef DOXYGEN
385 
386 // ------------------- inline and template functions ----------------
387 
388 
389 template <int dim>
390 inline unsigned int
391 Quadrature<dim>::size() const
392 {
393  return weights.size();
394 }
395 
396 
397 template <int dim>
398 inline const Point<dim> &
399 Quadrature<dim>::point(const unsigned int i) const
400 {
401  AssertIndexRange(i, size());
402  return quadrature_points[i];
403 }
404 
405 
406 
407 template <int dim>
408 double
409 Quadrature<dim>::weight(const unsigned int i) const
410 {
411  AssertIndexRange(i, size());
412  return weights[i];
413 }
414 
415 
416 
417 template <int dim>
418 inline const std::vector<Point<dim>> &
420 {
421  return quadrature_points;
422 }
423 
424 
425 
426 template <int dim>
427 inline const std::vector<double> &
429 {
430  return weights;
431 }
432 
433 
434 
435 template <int dim>
436 inline bool
438 {
439  return is_tensor_product_flag;
440 }
441 
442 
443 
444 template <int dim>
445 template <class Archive>
446 inline void
447 Quadrature<dim>::serialize(Archive &ar, const unsigned int)
448 {
449  // forward to serialization
450  // function in the base class.
451  ar &static_cast<Subscriptor &>(*this);
452 
454 }
455 
456 
457 
458 /* -------------- declaration of explicit specializations ------------- */
459 
460 template <>
461 Quadrature<0>::Quadrature(const unsigned int);
462 template <>
464 template <>
466 template <>
468 
469 template <>
471 
472 template <>
474 
475 template <>
476 QIterated<1>::QIterated(const Quadrature<1> &base_quadrature,
477  const unsigned int n_copies);
478 
479 #endif // DOXYGEN
481 
482 #endif
std::vector< double > weights
Definition: quadrature.h:288
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:1636
const Point< dim > & point(const unsigned int i) const
STL namespace.
const std::array< Quadrature< 1 >, dim > & get_tensor_basis() const
Definition: quadrature.cc:323
Definition: point.h:110
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:493
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
std::size_t memory_consumption() const
Definition: quadrature.cc:311
bool is_tensor_product_flag
Definition: quadrature.h:297
std::vector< Point< dim > > quadrature_points
Definition: quadrature.h:282
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
Definition: quadrature.cc:561
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
Definition: quadrature.h:303
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