dune-fem  2.4.1-rc
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 
6 namespace Dune
7 {
8 
9  namespace Fem
10  {
11 
12 #define SimplexPointsAdapter ParDGSimplexPointsAdapter
13 
14  // only if we use dune-fem quadratures
15  template <class ct, int dim>
16  SimplexQuadrature<ct, dim>::SimplexQuadrature(const GeometryType&, int order, size_t id) :
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  CubeQuadrature<ct, dim>::CubeQuadrature(const GeometryType&, int order, size_t id) :
34  QuadratureImp<ct, dim>(id),
35  order_((order <= 0) ? 1 : order)
36  {
37  assert( order_ <= GaussPts::highestOrder );
38 
39  typedef FieldVector< ct, dim > CoordinateType;
40 
41  const GaussPts& gp = GaussPts::instance();
42 
43  // find the right Gauss Rule from given order
44  int m = 0;
45  for (int i = 0; i <= GaussPts::MAXP; i++) {
46  if (gp.order(i)>=order_) {
47  m = i;
48  break;
49  }
50  }
51 
52  if (m==0) DUNE_THROW(NotImplemented, "order " << order_ << " not implemented");
53  order_ = gp.order(m);
54 
55  // fill in all the gauss points
56  int n = gp.power(m,dim);
57  for (int i = 0; i < n; i++) {
58  // compute multidimensional coordinates of Gauss point
59  int x[dim];
60  int z = i;
61  for (int k=0; k<dim; ++k) {
62  x[k] = z%m;
63  z = z/m;
64  }
65 
66  // compute coordinates and weight
67  double weight = 1.0;
68  CoordinateType local;
69  for (int k = 0; k < dim; k++)
70  {
71  local[k] = gp.point(m,x[k]);
72  weight *= gp.weight(m,x[k]);
73  }
74 
75  // put in container
76  this->addQuadraturePoint(local, weight);
77  }
78 
79  }
80 
81  template <>
82  inline CubeQuadrature<double, 0>::CubeQuadrature(const GeometryType&, int order, size_t id) :
83  QuadratureImp<double, 0>(id),
84  order_((order <= 0) ? 1 : order)
85  {
86  typedef FieldVector< double, 0 > CoordinateType;
87 
88  order_ = 20;
89 
90  // fill in all the gauss points
91  // compute coordinates and weight
92  double weight = 1.0;
93  CoordinateType local( 0 );
94 
95  // put in container
96  this->addQuadraturePoint(local, weight);
97 
98  }
99 
100  template <class ct>
101  LineQuadrature<ct>::LineQuadrature(const GeometryType&, int order, size_t id) :
102  QuadratureImp<ct, 1>(id),
103  order_((order <= 0) ? 1 : order)
104  {
105  // make sure that we only use orders that are available
106  assert( order_ <= GaussPts::highestOrder );
107 
108  typedef FieldVector< ct, 1 > CoordinateType;
109 
110  const GaussPts& gp = GaussPts::instance();
111 
112  int m=0;
113  for (int i = 0; i <= GaussPts::MAXP; i++) {
114  if (gp.order(i)>=order_) {
115  m = i;
116  break;
117  }
118  }
119  if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
120  order_ = gp.order(m);
121 
122  // fill in all the gauss points
123  int n = gp.power(m,1);
124  for (int i = 0; i < n; ++i)
125  {
126  CoordinateType local( ct( 0 ) );
127 
128  local[0] = gp.point(m, i);
129  double weight = gp.weight(m, i);
130 
131  this->addQuadraturePoint(local, weight);
132  }
133  }
134 
135  template <class ct>
136  TriangleQuadrature<ct>::TriangleQuadrature(const GeometryType&, int order, size_t id) :
137  QuadratureImp<ct, 2>(id),
138  order_((order <= 0) ? 1 : order)
139  {
140  // make sure that we only use orders that are available
141  assert( order_ <= SimplexMaxOrder :: maxOrder( 2 ) );
142 
143  SimplexPointsAdapter<2> points(order);
144 
145  order_ = points.order();
146 
147  for (int i = 0; i < points.numPoints(); ++i) {
148  this->addQuadraturePoint(points.point(i), points.weight(i));
149  }
150  }
151 
152  template< class ct >
153  QuadrilateralQuadrature<ct>::QuadrilateralQuadrature(const GeometryType&, int order, size_t id) :
154  QuadratureImp<ct, 2>(id),
155  order_((order <= 0) ? 1 : order)
156  {
157  // make sure that we only use orders that are available
158  assert( order_ <= GaussPts::highestOrder );
159 
160  typedef FieldVector< ct, 2 > CoordinateType;
161 
162  const GaussPts& gp = GaussPts::instance();
163  const int dim = 2;
164 
165  // find the right Gauss Rule from given order
166  int m = 0;
167  for (int i = 0; i <= GaussPts::MAXP; i++)
168  {
169  if (gp.order(i)>=order_) {
170  m = i;
171  break;
172  }
173  }
174 
175  if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
176  order_ = gp.order(m);
177 
178  // fill in all the gauss points
179  int n = gp.power(m,dim);
180  for (int i = 0; i < n; i++) {
181  // compute multidimensional coordinates of Gauss point
182  int x[dim];
183  int z = i;
184  for (int k=0; k<dim; ++k) {
185  x[k] = z%m;
186  z = z/m;
187  }
188 
189  // compute coordinates and weight
190  double weight = 1.0;
191  CoordinateType local;
192  for (int k = 0; k < dim; k++)
193  {
194  local[k] = gp.point(m,x[k]);
195  weight *= gp.weight(m,x[k]);
196  }
197 
198  // put in container
199  this->addQuadraturePoint(local, weight);
200  }
201  }
202 
203  template <class ct>
204  TetraQuadrature<ct>::TetraQuadrature(const GeometryType&, int order, size_t id) :
205  QuadratureImp<ct, 3>(id),
206  order_((order <= 0) ? 1 : order)
207  {
208  // make sure that we only use orders that are available
209  assert( order_ <= SimplexMaxOrder :: maxOrder( 3 ) );
210 
211  SimplexPointsAdapter<3> points(order);
212 
213  order_ = points.order();
214 
215  for (int i = 0; i < points.numPoints(); ++i) {
216  this->addQuadraturePoint(points.point(i), points.weight(i));
217  }
218  }
219 
220  template< class ct >
221  HexaQuadrature<ct>::HexaQuadrature(const GeometryType&, int order, size_t id) :
222  QuadratureImp<ct, 3>(id),
223  order_((order <= 0) ? 1 : order)
224  {
225  // make sure that we only use orders that are available
226  assert( order_ <= GaussPts::highestOrder );
227 
228  typedef FieldVector< ct, 3 > CoordinateType;
229 
230  const GaussPts& gp = GaussPts::instance();
231  const int dim = 3;
232 
233  // find the right Gauss Rule from given order
234  int m = 0;
235  for (int i = 0; i <= GaussPts::MAXP; i++) {
236  if (gp.order(i)>=order_) {
237  m = i;
238  break;
239  }
240  }
241 
242  if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
243  order_ = gp.order(m);
244 
245  // fill in all the gauss points
246  int n = gp.power(m,dim);
247  for (int i = 0; i < n; i++) {
248  // compute multidimensional coordinates of Gauss point
249  int x[dim];
250  int z = i;
251  for (int k=0; k<dim; ++k) {
252  x[k] = z%m;
253  z = z/m;
254  }
255 
256  // compute coordinates and weight
257  double weight = 1.0;
258  CoordinateType local;
259  for (int k = 0; k < dim; k++)
260  {
261  local[k] = gp.point(m,x[k]);
262  weight *= gp.weight(m,x[k]);
263  }
264 
265  // put in container
266  this->addQuadraturePoint(local, weight);
267  }
268  }
269 
270  template <class ct>
271  PrismQuadrature<ct>::PrismQuadrature(const GeometryType&, int order, size_t id) :
272  QuadratureImp<ct, 3>(id),
273  order_((order <= 0) ? 1 : order)
274  {
275  SimplexPointsAdapter<2> simplexPoints(order);
276  int simplexOrder = simplexPoints.order();
277 
278  const GaussPts& gp = GaussPts::instance();
279  // find the right Gauss Rule from given order
280  int m = 0;
281  for (int i = 0; i <= GaussPts::MAXP; i++) {
282  if (gp.order(i)>=order_) {
283  m = i;
284  break;
285  }
286  }
287  if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
288 
289  int gaussOrder = gp.order(m);
290  int minOrder = ((simplexOrder < gaussOrder) ? simplexOrder : gaussOrder);
291  order_ = minOrder;
292 
293  int numSimplexPoints = simplexPoints.numPoints();
294  int numGaussPoints = gp.power(m,1);
295 
296  FieldVector<ct, 3> local;
297  double weight, simplexWeight;
298 
299  for (int i = 0; i < numSimplexPoints; ++i) {
300  local[0] = simplexPoints.point(i)[0];
301  local[1] = simplexPoints.point(i)[1];
302  simplexWeight = simplexPoints.weight(i);
303  for (int j = 0; j < numGaussPoints; ++j) {
304  local[2] = gp.point(m,j);
305  weight = simplexWeight;
306  weight *= gp.weight(m,j);
307  this->addQuadraturePoint(local, weight);
308  }
309  }
310  }
311 
312  template <class ct>
313  PyramidQuadrature<ct>::PyramidQuadrature(const GeometryType&, int order, size_t id) :
314  QuadratureImp<ct, 3>(id),
315  order_((order <= 0) ? 1 : order)
316  {
317  const PyramidPoints& points = PyramidPoints::instance();
318 
319  int m = 0;
320  for (int i = 0; i < PyramidPoints::numQuads; ++i) {
321  if (points.order(i) >= order_) {
322  m = i;
323  break;
324  }
325  }
326 
327  if (m==0) DUNE_THROW(NotImplemented, "order not implemented");
328  order_ = points.order(m);
329 
330  // fill in the points
331  for (int i = 0; i < points.numPoints(m); ++i) {
332  this->addQuadraturePoint(points.point(m, i), points.weight(m, i));
333  }
334  }
335 
336  } // namespace Fem
337 
338 } // namespace Dune
339 
340 #endif // #ifndef DUNE_FEM_FEMQUADRATURES_INLINE_HH
static int maxOrder(const int dim)
Definition: femquadratures.hh:25
CubeQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:33
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:337
LineQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:101
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:520
void addQuadraturePoint(const CoordinateType &point, const FieldType weight)
Adds a point-weight pair to the quadrature.
Definition: quadratureimp.hh:261
int order_
Definition: femquadratures.hh:135
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:460
PyramidQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:313
double weight(int m, int i) const
Access to the ith weight of quadrature rule m.
Definition: pyramidpoints.hh:35
int power(int y, int d) const
a simple power method
Definition: gausspoints.hh:98
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:89
const FieldType & weight(size_t i) const
obtain weight of i-th integration point
Definition: quadratureimp.hh:242
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:398
QuadrilateralQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:153
int order_
Definition: femquadratures.hh:67
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:155
BaseType::CoordinateType CoordinateType
type of local coordinates
Definition: femquadratures.hh:132
SimplexQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:16
double point(int m, int i) const
obtain the i-th point of the m-th quadratre
Definition: gausspoints.hh:59
PrismQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:271
TetraQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:204
int numPoints(int m) const
Number of points in the quadrature rule m.
Definition: pyramidpoints.hh:47
static const GaussPts & instance()
obtain the singleton object
Definition: gausspoints.hh:46
Definition: coordinate.hh:4
BaseType::CoordinateType CoordinateType
type of local coordinates
Definition: femquadratures.hh:314
Definition: pyramidpoints.hh:18
one-dimensional Gauss points and their weights
Definition: gausspoints.hh:22
const FieldVector< double, 3 > & point(int m, int i) const
Access to the ith point of quadrature rule m.
Definition: pyramidpoints.hh:29
int order(int m) const
obtain the order of the m-th quadratre
Definition: gausspoints.hh:84
BaseType::CoordinateType CoordinateType
type of local coordinates
Definition: femquadratures.hh:191
int order(int m) const
Actual order of quadrature rule m.
Definition: pyramidpoints.hh:41
TriangleQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:136
int order_
Definition: femquadratures.hh:194
double weight(int m, int i) const
obtain the i-th weight of the m-th quadratre
Definition: gausspoints.hh:72
Generic implementation of a Dune quadrature.
Definition: quadratureimp.hh:178
virtual int order() const
Definition: femquadratures.hh:214
BaseType::CoordinateType CoordinateType
type of local coordinates
Definition: femquadratures.hh:437
static const PyramidPoints & instance()
Access to the singleton object.
Definition: pyramidpoints.hh:23
virtual int order() const
obtain order of the integration point list
Definition: femquadratures.hh:275
Definition: pyramidpoints.hh:15
Definition: gausspoints.hh:26
HexaQuadrature(const GeometryType &geometry, int order, size_t id)
constructor filling the list of points and weights
Definition: femquadratures_inline.hh:221
Definition: gausspoints.hh:29