dune-fem 2.12-git
Loading...
Searching...
No Matches
femquadratures_inline.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_FEMQUADRATURES_INLINE_HH
2#define DUNE_FEM_FEMQUADRATURES_INLINE_HH
3
4#include "femquadratures.hh"
5
6namespace Dune
7{
8
9 namespace Fem
10 {
11
12#define SimplexPointsAdapter ParDGSimplexQuadrature::Quadrature
13
14 // only if we use dune-fem quadratures
15 template <class ct, int dim>
17 QuadratureImp<ct, dim>(id),
18 order_((order <= 0) ? 1 : order)
19 {
20 // make sure that we only use orders that are available
21 assert( order_ <= SimplexMaxOrder :: maxOrder( dim ) );
22
23 SimplexPointsAdapter<dim> points(order);
24
25 order_ = points.order();
26
27 for (int i = 0; i < points.numPoints(); ++i) {
28 this->addQuadraturePoint(points.point(i), points.weight(i));
29 }
30 }
31
32 template <class ct, int dim>
33 template <class QuadPoints>
34 CubeQuadratureBase<ct, dim>::CubeQuadratureBase(const GeometryType&, int order, size_t id, const QuadPoints& gp) :
35 QuadratureImp<ct, dim>(id),
36 order_((order <= 0) ? 1 : order)
37 {
38 assert( order_ <= QuadPoints::highestOrder );
39
41
42 // point quadrature
43 if constexpr ( dim == 0 )
44 {
46
47 order_ = 20;
48
49 // fill in all the gauss points
50 // compute coordinates and weight
51 double weight = 1.0;
53
54 // put in container
55 this->addQuadraturePoint(local, weight);
56 }
57 else
58 {
59 // find the right Gauss Rule from given order
60 int m = 0;
61 for (int i = 0; i <= GaussPts::MAXP; i++) {
62 if (gp.order(i)>=order_) {
63 m = i;
64 break;
65 }
66 }
67
68 if (m==0) DUNE_THROW(NotImplemented, "order " << order_ << " not implemented");
69 order_ = gp.order(m);
70
71 // fill in all the gauss points
72 int n = gp.power(m,dim);
73 for (int i = 0; i < n; i++) {
74 // compute multidimensional coordinates of Gauss point
75 int x[dim];
76 int z = i;
77 for (int k=0; k<dim; ++k) {
78 x[k] = z%m;
79 z = z/m;
80 }
81
82 // compute coordinates and weight
83 double weight = 1.0;
85 for (int k = 0; k < dim; k++)
86 {
87 local[k] = gp.point(m,x[k]);
88 weight *= gp.weight(m,x[k]);
89 }
90
91 // put in container
92 this->addQuadraturePoint(local, weight);
93 }
94 }
95 }
96
97
98 template <class ct>
99 PrismQuadrature<ct>::PrismQuadrature(const GeometryType&, int order, size_t id) :
100 QuadratureImp<ct, 3>(id),
101 order_((order <= 0) ? 1 : order)
102 {
103 SimplexPointsAdapter<2> simplexPoints(order);
104 int simplexOrder = simplexPoints.order();
105
106 const GaussPts gp;
107
108 // find the right Gauss Rule from given order
109 int m = 0;
110 for (int i = 0; i <= GaussPts::MAXP; i++) {
111 if (gp.order(i)>=order_) {
112 m = i;
113 break;
114 }
115 }
116 if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
117
118 int gaussOrder = gp.order(m);
119 int minOrder = ((simplexOrder < gaussOrder) ? simplexOrder : gaussOrder);
120 order_ = minOrder;
121
122 int numSimplexPoints = simplexPoints.numPoints();
123 int numGaussPoints = gp.power(m,1);
124
126 double weight, simplexWeight;
127
128 for (int i = 0; i < numSimplexPoints; ++i) {
129 local[0] = simplexPoints.point(i)[0];
130 local[1] = simplexPoints.point(i)[1];
131 simplexWeight = simplexPoints.weight(i);
132 for (int j = 0; j < numGaussPoints; ++j) {
133 local[2] = gp.point(m,j);
134 weight = simplexWeight;
135 weight *= gp.weight(m,j);
136 this->addQuadraturePoint(local, weight);
137 }
138 }
139 }
140
141 template <class ct>
143 QuadratureImp<ct, 3>(id),
144 order_((order <= 0) ? 1 : order)
145 {
146 const PyramidPoints points;
147
148 int m = 0;
149 for (int i = 0; i < PyramidPoints::numQuads; ++i) {
150 if (points.order(i) >= order_) {
151 m = i;
152 break;
153 }
154 }
155
156 if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
157 order_ = points.order(m);
158
159 // fill in the points
160 for (int i = 0; i < points.numPoints(m); ++i) {
161 this->addQuadraturePoint(points.point(m, i), points.weight(m, i));
162 }
163 }
164
165
166 template <class ct, int dim>
168 QuadratureImp<ct, dim>(id),
169 geometryType_( geomType ),
170 order_((order <= 0) ? 1 : order)
171 {
172 }
173
174
175 } // namespace Fem
176
177} // namespace Dune
178
179#endif // #ifndef DUNE_FEM_FEMQUADRATURES_INLINE_HH
int id()
size_type dim() const
#define DUNE_THROW(E,...)
LocalIndex & local()
int order_
Definition femquadratures.hh:66
virtual int order() const
obtain order of the integration point list
Definition femquadratures.hh:86
SimplexQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition femquadratures_inline.hh:16
CubeQuadratureBase(const GeometryType &geometry, int order, size_t id, const QuadPoints &pts)
constructor filling the list of points and weights
Definition femquadratures_inline.hh:34
int order_
Definition femquadratures.hh:132
BaseType::CoordinateType CoordinateType
type of local coordinates
Definition femquadratures.hh:129
PrismQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition femquadratures_inline.hh:99
virtual int order() const
obtain order of the integration point list
Definition femquadratures.hh:288
PyramidQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition femquadratures_inline.hh:142
PolyhedronQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition femquadratures_inline.hh:167
int power(int y, int d) const
a simple power method
Definition gausspoints.hh:87
double point(int m, int i) const
obtain the i-th point of the m-th quadrature
Definition gausspoints.hh:48
double weight(int m, int i) const
obtain the i-th weight of the m-th quadrature
Definition gausspoints.hh:61
int order(int m) const
obtain the order of the m-th quadrature
Definition gausspoints.hh:73
one-dimensional Gauss points and their weights
Definition gausspoints.hh:108
static const int MAXP
number of available quadratures
Definition gausspoints.hh:111
Definition pyramidpoints.hh:17
const FieldVector< double, 3 > & point(int m, int i) const
Access to the ith point of quadrature rule m.
Definition pyramidpoints.hh:24
int numPoints(int m) const
Number of points in the quadrature rule m.
Definition pyramidpoints.hh:42
@ numQuads
Definition pyramidpoints.hh:19
int order(int m) const
Actual order of quadrature rule m.
Definition pyramidpoints.hh:36
double weight(int m, int i) const
Access to the ith weight of quadrature rule m.
Definition pyramidpoints.hh:30
Generic implementation of a Dune quadrature.
Definition quadratureimp.hh:196
void addQuadraturePoint(const CoordinateType &point, const FieldType weight)
Adds a point-weight pair to the quadrature.
Definition quadratureimp.hh:270
const FieldType & weight(size_t i) const
obtain weight of i-th integration point
Definition quadratureimp.hh:251