4#ifndef DUNE_GEOMETRY_QUADRATURERULES_HH
5#define DUNE_GEOMETRY_QUADRATURERULES_HH
17#include <dune/common/stdthread.hh>
20#include <dune/geometry/quadraturerules/nocopyvector.hh>
42 template<
typename ct,
int dim>
46 enum { dimension = dim };
80 namespace QuadratureType {
95 template<
typename ct,
int dim>
120 virtual int order ()
const {
return delivered_order; }
128 typedef typename std::vector<QuadraturePoint<ct,dim> >::const_iterator
iterator;
142 template<
typename ctype,
int dim>
149 static void initQuadratureRule(
QuadratureRule *qr, QuadratureType::Enum qt,
155 typedef NoCopyVector<std::pair<std::once_flag, QuadratureRule> >
156 QuadratureOrderVector;
159 static void initQuadratureOrderVector(QuadratureOrderVector *qov,
160 QuadratureType::Enum qt,
170 typedef NoCopyVector<std::pair<std::once_flag, QuadratureOrderVector> >
174 static void initGeometryTypeVector(GeometryTypeVector *gtv)
182 assert(t.dim()==dim);
184 DUNE_ASSERT_CALL_ONCE();
186 static NoCopyVector<std::pair<
189 > > quadratureCache(QuadratureType::size);
191 auto & quadratureTypeLevel = quadratureCache[qt];
192 std::call_once(quadratureTypeLevel.first, initGeometryTypeVector,
193 &quadratureTypeLevel.second);
195 auto & geometryTypeLevel =
197 std::call_once(geometryTypeLevel.first, initQuadratureOrderVector,
198 &geometryTypeLevel.second, qt, t);
201 auto & quadratureOrderLevel = geometryTypeLevel.second[dim == 0 ? 0 : p];
202 std::call_once(quadratureOrderLevel.first, initQuadratureRule,
203 &quadratureOrderLevel.second, qt, t, p);
205 return quadratureOrderLevel.second;
219 QuadratureType::Enum qt=QuadratureType::GaussLegendre)
227 return instance()._rule(t,p,qt);
233 return instance()._rule(
gt,p,qt);
239#include "quadraturerules/pointquadrature.hh"
244 template<typename ct, bool fundamental = std::numeric_limits<ct>::is_specialized>
246 template<
typename ct>
248 static void init(
int p,
250 std::vector< ct > & _weight,
251 int & delivered_order);
253 template<
typename ct>
255 static void init(
int p,
257 std::vector< ct > & _weight,
258 int & delivered_order);
262 template<
typename ct>
269 enum { highest_order=61 };
278 std::vector< FieldVector<ct, dim> > _points;
279 std::vector< ct > _weight;
282 (p, _points, _weight, this->delivered_order);
284 assert(_points.size() == _weight.size());
285 for (
size_t i = 0; i < _points.size(); i++)
295#define DUNE_INCLUDING_IMPLEMENTATION
296#include "quadraturerules/gauss_imp.hh"
301 template<
typename ct,
302 bool fundamental = std::numeric_limits<ct>::is_specialized>
304 template<
typename ct>
306 static void init(
int p,
308 std::vector< ct > & _weight,
309 int & delivered_order);
311 template<
typename ct>
313 static void init(
int p,
315 std::vector< ct > & _weight,
316 int & delivered_order);
322 template<
typename ct>
331 enum { highest_order=61 };
340 std::vector< FieldVector<ct, dim> > _points;
341 std::vector< ct > _weight;
346 (p, _points, _weight, delivered_order);
347 this->delivered_order = delivered_order;
348 assert(_points.size() == _weight.size());
349 for (
size_t i = 0; i < _points.size(); i++)
361#define DUNE_INCLUDING_IMPLEMENTATION
362#include "quadraturerules/jacobi_1_0_imp.hh"
367 template<
typename ct,
368 bool fundamental = std::numeric_limits<ct>::is_specialized>
370 template<
typename ct>
372 static void init(
int p,
374 std::vector< ct > & _weight,
375 int & delivered_order);
377 template<
typename ct>
379 static void init(
int p,
381 std::vector< ct > & _weight,
382 int & delivered_order);
388 template<
typename ct>
397 enum { highest_order=61 };
406 std::vector< FieldVector<ct, dim> > _points;
407 std::vector< ct > _weight;
412 (p, _points, _weight, delivered_order);
414 this->delivered_order = delivered_order;
415 assert(_points.size() == _weight.size());
416 for (
size_t i = 0; i < _points.size(); i++)
428#define DUNE_INCLUDING_IMPLEMENTATION
429#include "quadraturerules/jacobi_2_0_imp.hh"
434 template<
typename ct,
435 bool fundamental = std::numeric_limits<ct>::is_specialized>
437 template<
typename ct>
439 static void init(
int p,
441 std::vector< ct > & _weight,
442 int & delivered_order);
444 template<
typename ct>
446 static void init(
int p,
448 std::vector< ct > & _weight,
449 int & delivered_order);
455 template<
typename ct>
464 enum { highest_order=31 };
473 std::vector< FieldVector<ct, dim> > _points;
474 std::vector< ct > _weight;
479 (p, _points, _weight, delivered_order);
481 this->delivered_order = delivered_order;
482 assert(_points.size() == _weight.size());
483 for (
size_t i = 0; i < _points.size(); i++)
495#define DUNE_INCLUDING_IMPLEMENTATION
496#include "quadraturerules/gausslobatto_imp.hh"
498#include "quadraturerules/tensorproductquadrature.hh"
500#include "quadraturerules/simplexquadrature.hh"
518 enum { highest_order=2 };
552 W[m][0] = 0.16666666666666666 / 2.0;
553 W[m][1] = 0.16666666666666666 / 2.0;
554 W[m][2] = 0.16666666666666666 / 2.0;
555 W[m][3] = 0.16666666666666666 / 2.0;
556 W[m][4] = 0.16666666666666666 / 2.0;
557 W[m][5] = 0.16666666666666666 / 2.0;
564 G[m][0][0] =0.66666666666666666 ;
565 G[m][0][1] =0.16666666666666666 ;
566 G[m][0][2] =0.211324865405187 ;
568 G[m][1][0] = 0.16666666666666666;
569 G[m][1][1] =0.66666666666666666 ;
570 G[m][1][2] = 0.211324865405187;
572 G[m][2][0] = 0.16666666666666666;
573 G[m][2][1] = 0.16666666666666666;
574 G[m][2][2] = 0.211324865405187;
576 G[m][3][0] = 0.66666666666666666;
577 G[m][3][1] = 0.16666666666666666;
578 G[m][3][2] = 0.788675134594813;
580 G[m][4][0] = 0.16666666666666666;
581 G[m][4][1] = 0.66666666666666666;
582 G[m][4][2] = 0.788675134594813;
584 G[m][5][0] = 0.16666666666666666;
585 G[m][5][1] = 0.16666666666666666;
586 G[m][5][2] = 0.788675134594813;
588 W[m][0] = 0.16666666666666666 / 2.0;
589 W[m][1] = 0.16666666666666666 / 2.0;
590 W[m][2] = 0.16666666666666666 / 2.0;
591 W[m][3] = 0.16666666666666666 / 2.0;
592 W[m][4] = 0.16666666666666666 / 2.0;
593 W[m][5] = 0.16666666666666666 / 2.0;
620 double W[MAXP+1][MAXP];
644 template<
typename ct,
int dim>
650 template<
typename ct>
659 enum { highest_order = 2 };
668 for(
int i=0; i<m; ++i)
671 for (
int k=0; k<d; k++)
687 template<
typename ctype,
int dim>
691 static unsigned maxOrder(
const GeometryType &t, QuadratureType::Enum qt)
693 return TensorProductQuadratureRule<ctype,dim>::maxOrder(t.id(), qt);
697 return TensorProductQuadratureRule<ctype,dim>(t.id(), p, qt);
701 template<
typename ctype>
705 friend class QuadratureRules<ctype, dim>;
706 static unsigned maxOrder(
const GeometryType &t, QuadratureType::Enum qt)
710 return std::numeric_limits<int>::max();
712 DUNE_THROW(Exception,
"Unknown GeometryType");
714 static QuadratureRule<ctype, dim> rule(
const GeometryType& t,
int p, QuadratureType::Enum qt)
718 return PointQuadratureRule<ctype>();
720 DUNE_THROW(Exception,
"Unknown GeometryType");
724 template<
typename ctype>
725 class QuadratureRuleFactory<ctype, 1> {
728 friend class QuadratureRules<ctype, dim>;
729 static unsigned maxOrder(
const GeometryType &t, QuadratureType::Enum qt)
734 case QuadratureType::GaussLegendre :
735 return GaussQuadratureRule1D<ctype>::highest_order;
736 case QuadratureType::GaussJacobi_1_0 :
737 return Jacobi1QuadratureRule1D<ctype>::highest_order;
738 case QuadratureType::GaussJacobi_2_0 :
739 return Jacobi2QuadratureRule1D<ctype>::highest_order;
740 case QuadratureType::GaussLobatto :
741 return GaussLobattoQuadratureRule1D<ctype>::highest_order;
743 DUNE_THROW(Exception,
"Unknown QuadratureType");
746 DUNE_THROW(Exception,
"Unknown GeometryType");
748 static QuadratureRule<ctype, dim> rule(
const GeometryType& t,
int p, QuadratureType::Enum qt)
753 case QuadratureType::GaussLegendre :
754 return GaussQuadratureRule1D<ctype>(p);
755 case QuadratureType::GaussJacobi_1_0 :
756 return Jacobi1QuadratureRule1D<ctype>(p);
757 case QuadratureType::GaussJacobi_2_0 :
758 return Jacobi2QuadratureRule1D<ctype>(p);
759 case QuadratureType::GaussLobatto :
760 return GaussLobattoQuadratureRule1D<ctype>(p);
762 DUNE_THROW(Exception,
"Unknown QuadratureType");
765 DUNE_THROW(Exception,
"Unknown GeometryType");
769 template<
typename ctype>
770 class QuadratureRuleFactory<ctype, 2> {
773 friend class QuadratureRules<ctype, dim>;
774 static unsigned maxOrder(
const GeometryType &t, QuadratureType::Enum qt)
777 TensorProductQuadratureRule<ctype,dim>::maxOrder(t.id(), qt);
780 (order,
unsigned(SimplexQuadratureRule<ctype,dim>::highest_order));
783 static QuadratureRule<ctype, dim> rule(
const GeometryType& t,
int p, QuadratureType::Enum qt)
786 && qt == QuadratureType::GaussLegendre
787 && p <= SimplexQuadratureRule<ctype,dim>::highest_order)
789 return SimplexQuadratureRule<ctype,dim>(p);
791 return TensorProductQuadratureRule<ctype,dim>(t.id(), p, qt);
795 template<
typename ctype>
796 class QuadratureRuleFactory<ctype, 3> {
799 friend class QuadratureRules<ctype, dim>;
800 static unsigned maxOrder(
const GeometryType &t, QuadratureType::Enum qt)
803 TensorProductQuadratureRule<ctype,dim>::maxOrder(t.id(), qt);
806 (order,
unsigned(SimplexQuadratureRule<ctype,dim>::highest_order));
809 (order,
unsigned(PrismQuadratureRule<ctype,dim>::highest_order));
812 static QuadratureRule<ctype, dim> rule(
const GeometryType& t,
int p, QuadratureType::Enum qt)
815 && qt == QuadratureType::GaussLegendre
816 && p <= SimplexQuadratureRule<ctype,dim>::highest_order)
818 return SimplexQuadratureRule<ctype,dim>(p);
821 && qt == QuadratureType::GaussLegendre
822 && p <= PrismQuadratureRule<ctype,dim>::highest_order)
824 return PrismQuadratureRule<ctype,dim>(p);
826 return TensorProductQuadratureRule<ctype,dim>(t.id(), p, qt);
Jacobi-Gauss quadrature for alpha=2, beta=0.
Definition: quadraturerules.hh:458
Gauss quadrature rule in 1D.
Definition: quadraturerules.hh:265
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
BasicType
Each entity can be tagged by one of these basic types plus its space dimension.
Definition: type.hh:29
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:31
Jacobi-Gauss quadrature for alpha=1, beta=0.
Definition: quadraturerules.hh:325
Jacobi-Gauss quadrature for alpha=2, beta=0.
Definition: quadraturerules.hh:391
static DUNE_CONSTEXPR std::size_t size(std::size_t dim)
Compute total number of geometry types for the given dimension.
Definition: typeindex.hh:58
static std::size_t index(const GeometryType >)
Compute the index for the given geometry type within its dimension.
Definition: typeindex.hh:70
Default exception for dummy implementations.
Definition: exceptions.hh:288
Definition: quadraturerules.hh:515
double weight(int m, int i)
Definition: quadraturerules.hh:606
int order(int m)
Definition: quadraturerules.hh:612
PrismQuadraturePoints()
initialize quadrature points on the interval for all orders
Definition: quadraturerules.hh:521
FieldVector< double, 3 > point(int m, int i)
Definition: quadraturerules.hh:600
Definition: quadraturerules.hh:510
Quadrature rules for prisms.
Definition: quadraturerules.hh:652
Quadrature rules for prisms.
Definition: quadraturerules.hh:645
Exception thrown if a desired QuadratureRule is not available, because the requested order is to high...
Definition: quadraturerules.hh:35
Single evaluation point in a quadrature rule.
Definition: quadraturerules.hh:43
const Vector & position() const
return local coordinates of integration point i
Definition: quadraturerules.hh:61
Dune::FieldVector< ct, dim > Vector
Type used for the position of a quadrature point.
Definition: quadraturerules.hh:52
ct Field
Number type used for coordinates and quadrature weights.
Definition: quadraturerules.hh:49
const ct & weight() const
return weight associated with integration point i
Definition: quadraturerules.hh:67
QuadraturePoint(const Vector &x, ct w)
set up quadrature of given order in d dimensions
Definition: quadraturerules.hh:55
Factory class for creation of quadrature rules, depending on GeometryType, order and QuadratureType.
Definition: quadraturerules.hh:688
Abstract base class for quadrature rules.
Definition: quadraturerules.hh:97
virtual GeometryType type() const
return type of element
Definition: quadraturerules.hh:123
QuadratureRule(GeometryType t, int order)
Constructor for a given geometry type and a given quadrature order.
Definition: quadraturerules.hh:111
ct CoordType
The type used for coordinates.
Definition: quadraturerules.hh:117
QuadratureRule()
Default constructor.
Definition: quadraturerules.hh:104
virtual int order() const
return order
Definition: quadraturerules.hh:120
QuadratureRule(GeometryType t)
Constructor for a given geometry type. Leaves the quadrature order invalid
Definition: quadraturerules.hh:108
std::vector< QuadraturePoint< ct, dim > >::const_iterator iterator
Definition: quadraturerules.hh:128
A container for all quadrature rules of dimension dim
Definition: quadraturerules.hh:143
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
maximum quadrature order for given geometry type and quadrature type
Definition: quadraturerules.hh:218
static const QuadratureRule & rule(const GeometryType::BasicType t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
select the appropriate QuadratureRule for GeometryType t and order p
Definition: quadraturerules.hh:230
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
select the appropriate QuadratureRule for GeometryType t and order p
Definition: quadraturerules.hh:225
A few common exception classes.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:132
Dune namespace.
Definition: alignment.hh:10
Standard Dune debug streams.
Definition: quadraturerules.hh:436
Definition: quadraturerules.hh:245
Definition: quadraturerules.hh:303
Definition: quadraturerules.hh:369
Singleton holding the Prism Quadrature points.
Definition: quadraturerules.hh:637
Singleton holding the Prism Quadrature points.
Definition: quadraturerules.hh:629
A unique label for each type of element that can occur in a grid.
Helper classes to provide indices for geometrytypes for use in a vector.
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18