Reference documentation for deal.II version 8.5.1
quadrature.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2016 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__quadrature_h
17 #define dealii__quadrature_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/point.h>
22 #include <deal.II/base/subscriptor.h>
23 #include <vector>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
29 
80 template <int dim>
81 class Quadrature : public Subscriptor
82 {
83 public:
88  typedef Quadrature<dim-1> SubQuadrature;
89 
98  explicit Quadrature (const unsigned int n_quadrature_points = 0);
99 
106  Quadrature (const SubQuadrature &,
107  const Quadrature<1> &);
108 
121  explicit Quadrature (const Quadrature<dim != 1 ? 1 : 0> &quadrature_1d);
122 
126  Quadrature (const Quadrature<dim> &q);
127 
128 #ifdef DEAL_II_WITH_CXX11
129 
136  Quadrature (Quadrature<dim> &&) = default;
137 #endif
138 
144  Quadrature (const std::vector<Point<dim> > &points,
145  const std::vector<double> &weights);
146 
154  Quadrature (const std::vector<Point<dim> > &points);
155 
160  Quadrature (const Point<dim> &point);
161 
165  virtual ~Quadrature ();
166 
172 
176  bool operator == (const Quadrature<dim> &p) const;
177 
182  void initialize(const std::vector<Point<dim> > &points,
183  const std::vector<double> &weights);
184 
188  unsigned int size () const;
189 
193  const Point<dim> &point (const unsigned int i) const;
194 
198  const std::vector<Point<dim> > &get_points () const;
199 
203  double weight (const unsigned int i) const;
204 
208  const std::vector<double> &get_weights () const;
209 
214  std::size_t memory_consumption () const;
215 
220  template <class Archive>
221  void serialize (Archive &ar, const unsigned int version);
222 
223 protected:
228  std::vector<Point<dim> > quadrature_points;
229 
234  std::vector<double> weights;
235 };
236 
237 
248 template <int dim>
249 class QAnisotropic : public Quadrature<dim>
250 {
251 public:
256  QAnisotropic(const Quadrature<1> &qx);
257 
261  QAnisotropic(const Quadrature<1> &qx,
262  const Quadrature<1> &qy);
263 
267  QAnisotropic(const Quadrature<1> &qx,
268  const Quadrature<1> &qy,
269  const Quadrature<1> &qz);
270 };
271 
272 
298 template <int dim>
299 class QIterated : public Quadrature<dim>
300 {
301 public:
306  QIterated (const Quadrature<1> &base_quadrature,
307  const unsigned int n_copies);
308 
313  "The quadrature formula you provided cannot be used "
314  "as the basis for iteration.");
315 private:
320  static bool
321  uses_both_endpoints (const Quadrature<1> &base_quadrature);
322 };
323 
324 
325 
328 #ifndef DOXYGEN
329 
330 // ------------------- inline and template functions ----------------
331 
332 
333 template<int dim>
334 inline
335 unsigned int
336 Quadrature<dim>::size () const
337 {
338  return weights.size();
339 }
340 
341 
342 template <int dim>
343 inline
344 const Point<dim> &
345 Quadrature<dim>::point (const unsigned int i) const
346 {
347  AssertIndexRange(i, size());
348  return quadrature_points[i];
349 }
350 
351 
352 
353 template <int dim>
354 double
355 Quadrature<dim>::weight (const unsigned int i) const
356 {
357  AssertIndexRange(i, size());
358  return weights[i];
359 }
360 
361 
362 
363 template <int dim>
364 inline
365 const std::vector<Point<dim> > &
367 {
368  return quadrature_points;
369 }
370 
371 
372 
373 template <int dim>
374 inline
375 const std::vector<double> &
377 {
378  return weights;
379 }
380 
381 
382 
383 template <int dim>
384 template <class Archive>
385 inline
386 void
387 Quadrature<dim>::serialize (Archive &ar, const unsigned int)
388 {
389  // forward to serialization
390  // function in the base class.
391  ar &static_cast<Subscriptor &>(*this);
392 
393  ar &quadrature_points &weights;
394 }
395 
396 
397 
398 /* -------------- declaration of explicit specializations ------------- */
399 
400 template <>
401 Quadrature<0>::Quadrature (const unsigned int);
402 template <>
404  const Quadrature<1> &);
405 template <>
407 template <>
409 
410 template <>
412  const Quadrature<1> &);
413 
414 template <>
416 
417 #endif // DOXYGEN
418 DEAL_II_NAMESPACE_CLOSE
419 
420 #endif
std::vector< double > weights
Definition: quadrature.h:234
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:45
#define AssertIndexRange(index, range)
Definition: exceptions.h:1170
const Point< dim > & point(const unsigned int i) const
static bool uses_both_endpoints(const Quadrature< 1 > &base_quadrature)
Quadrature & operator=(const Quadrature< dim > &)
Definition: quadrature.cc:252
QAnisotropic(const Quadrature< 1 > &qx)
Definition: quadrature.cc:289
void initialize(const std::vector< Point< dim > > &points, const std::vector< double > &weights)
Definition: quadrature.cc:55
virtual ~Quadrature()
Definition: quadrature.cc:273
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:553
std::size_t memory_consumption() const
Definition: quadrature.cc:280
static ::ExceptionBase & ExcInvalidQuadratureFormula()
Quadrature< dim-1 > SubQuadrature
Definition: quadrature.h:88
std::vector< Point< dim > > quadrature_points
Definition: quadrature.h:228
unsigned int size() const
bool operator==(const Quadrature< dim > &p) const
Definition: quadrature.cc:263
QIterated(const Quadrature< 1 > &base_quadrature, const unsigned int n_copies)
Definition: quadrature.cc:1758
void serialize(Archive &ar, const unsigned int version)
double weight(const unsigned int i) const