Reference documentation for deal.II version GIT relicensing-43-g3fc2fae7c3 2024-03-03 21:10:02+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 - 2023 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
21#include <deal.II/base/point.h>
23
24#include <array>
25#include <memory>
26#include <vector>
27
29
120template <int dim>
122{
123public:
129 using SubQuadrature = Quadrature<dim == 0 ? 0 : dim - 1>;
130
139 explicit Quadrature(const unsigned int n_quadrature_points = 0);
140
149 Quadrature(const SubQuadrature &, const Quadrature<1> &);
150
170 explicit Quadrature(const Quadrature<dim != 1 ? 1 : 0> &quadrature_1d);
171
175 Quadrature(const Quadrature<dim> &q);
176
181 Quadrature(Quadrature<dim> &&) noexcept = default;
182
188 Quadrature(const std::vector<Point<dim>> &points,
189 const std::vector<double> &weights);
190
196 Quadrature(std::vector<Point<dim>> &&points, std::vector<double> &&weights);
197
205 Quadrature(const std::vector<Point<dim>> &points);
206
211 Quadrature(const Point<dim> &point);
212
216 virtual ~Quadrature() override = default;
217
222 Quadrature &
223 operator=(const Quadrature<dim> &);
224
229 Quadrature &
230 operator=(Quadrature<dim> &&) = default; // NOLINT
231
235 bool
236 operator==(const Quadrature<dim> &p) const;
237
242 void
243 initialize(const std::vector<Point<dim>> &points,
244 const std::vector<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:
338 std::vector<Point<dim>> quadrature_points;
339
344 std::vector<double> weights;
345
354
359 std::unique_ptr<std::array<Quadrature<1>, dim>> tensor_basis;
360};
361
362
371template <int dim>
372class QAnisotropic : public Quadrature<dim>
373{
374public:
379 QAnisotropic(const Quadrature<1> &qx);
380
384 QAnisotropic(const Quadrature<1> &qx, const Quadrature<1> &qy);
385
389 QAnisotropic(const Quadrature<1> &qx,
390 const Quadrature<1> &qy,
391 const Quadrature<1> &qz);
392};
393
394
418template <int dim>
419class QIterated : public Quadrature<dim>
420{
421public:
428 QIterated(const Quadrature<1> &base_quadrature, const unsigned int n_copies);
429
441 QIterated(const Quadrature<1> &base_quadrature,
442 const std::vector<Point<1>> &intervals);
443
448 "The quadrature formula you provided cannot be used "
449 "as the basis for iteration.");
450};
451
452
453
456#ifndef DOXYGEN
457
458// ------------------- inline and template functions ----------------
459
460
461template <int dim>
462inline unsigned int
464{
465 return weights.size();
466}
467
468
469
470template <int dim>
471inline bool
473{
474 return weights.empty();
475}
476
477
478
479template <int dim>
480inline const Point<dim> &
481Quadrature<dim>::point(const unsigned int i) const
482{
483 AssertIndexRange(i, size());
484 return quadrature_points[i];
485}
486
487
488
489template <int dim>
490double
491Quadrature<dim>::weight(const unsigned int i) const
492{
493 AssertIndexRange(i, size());
494 return weights[i];
495}
496
497
498
499template <int dim>
500inline const std::vector<Point<dim>> &
502{
503 return quadrature_points;
504}
505
506
507
508template <int dim>
509inline const std::vector<double> &
511{
512 return weights;
513}
514
515
516
517template <int dim>
518inline bool
520{
521 return is_tensor_product_flag;
522}
523
524
525
526template <int dim>
527template <class Archive>
528inline void
529Quadrature<dim>::serialize(Archive &ar, const unsigned int)
530{
531 // forward to serialization
532 // function in the base class.
533 ar &static_cast<Subscriptor &>(*this);
534
535 ar &quadrature_points &weights;
536}
537
538
539
540/* -------------- declaration of explicit specializations ------------- */
541
542template <>
543Quadrature<0>::Quadrature(const unsigned int);
544template <>
546 const Quadrature<1> &);
547template <>
549template <>
551
552template <>
554
555template <>
557
558template <>
559QIterated<1>::QIterated(const Quadrature<1> &base_quadrature,
560 const unsigned int n_copies);
561
562#endif // DOXYGEN
564
565#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:338
std::unique_ptr< std::array< Quadrature< 1 >, dim > > tensor_basis
Definition quadrature.h:359
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:353
Quadrature(const unsigned int n_quadrature_points=0)
Definition quadrature.cc:41
double weight(const unsigned int i) const
const std::vector< double > & get_weights() const
void initialize(const std::vector< Point< dim > > &points, const std::vector< double > &weights)
Definition quadrature.cc:51
const std::array< Quadrature< 1 >, dim > & get_tensor_basis() const
Quadrature(Quadrature< dim > &&) noexcept=default
std::vector< double > weights
Definition quadrature.h:344
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:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
static ::ExceptionBase & ExcInvalidQuadratureFormula()
#define AssertIndexRange(index, range)
#define DeclExceptionMsg(Exception, defaulttext)
Definition exceptions.h:494
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.