00001 #ifndef DUNE_QUADRATURERULES_HH
00002 #define DUNE_QUADRATURERULES_HH
00003
00004 #include<iostream>
00005 #include<vector>
00006 #include<map>
00007
00008 #include<dune/common/fvector.hh>
00009 #include<dune/common/exceptions.hh>
00010 #include<dune/common/stdstreams.hh>
00011 #include<dune/common/geometrytype.hh>
00012 #include<dune/grid/common/referenceelements.hh>
00013
00019 namespace Dune {
00020
00025 class QuadratureOrderOutOfRange : public NotImplemented {};
00026
00030 template<typename ct, int dim>
00031 class QuadraturePoint {
00032 public:
00033
00034 enum { d=dim };
00035 typedef ct CoordType;
00036
00038 QuadraturePoint (const FieldVector<ct, dim>& x, double w) : local(x)
00039 {
00040 wght = w;
00041 }
00042
00044 const FieldVector<ct, dim>& position () const
00045 {
00046 return local;
00047 }
00048
00050 double weight () const
00051 {
00052 return wght;
00053 }
00054 virtual ~QuadraturePoint(){}
00055
00056 protected:
00057 FieldVector<ct, dim> local;
00058 double wght;
00059 };
00060
00064 namespace QuadratureType {
00065 enum Enum {
00066 Gauss = 0,
00067
00068 Jacobian_1_0 = 1,
00069 Jacobian_2_0 = 2,
00070
00071 Simpson = 3,
00072 Trap = 4,
00073 Grid = 5,
00074
00075 Clough = 21,
00076
00077 Invalid_Rule = 127
00078 };
00079 }
00080
00084 template<typename ct, int dim>
00085 class QuadratureRule : public std::vector<QuadraturePoint<ct,dim> >
00086 {
00087 public:
00088
00090 QuadratureRule() : delivered_order(-1) {}
00091
00093 QuadratureRule(GeometryType t) : geometry_type(t), delivered_order(-1) {}
00094
00096 QuadratureRule(GeometryType t, int order) : geometry_type(t), delivered_order(order) {}
00097
00099 enum { d=dim };
00100
00102 typedef ct CoordType;
00103
00105 virtual int order () const { return delivered_order; }
00106
00108 virtual GeometryType type () const { return geometry_type; }
00109 virtual ~QuadratureRule(){}
00110
00113 typedef typename std::vector<QuadraturePoint<ct,dim> >::const_iterator iterator;
00114
00115 protected:
00116 GeometryType geometry_type;
00117 int delivered_order;
00118
00119 void tensor_product (const QuadratureRule<ct,1> & q1d)
00120 {
00121
00122 int m = q1d.size();
00123 int n = power(m,dim);
00124 for (int i=0; i<n; i++)
00125 {
00126
00127 int x[dim];
00128 int z = i;
00129 for (int k=0; k<dim; ++k)
00130 {
00131 x[k] = z%m;
00132 z = z/m;
00133 }
00134
00135
00136 double weight = 1.0;
00137 FieldVector<ct, dim> local;
00138 for (int k=0; k<dim; k++)
00139 {
00140 local[k] = q1d[x[k]].position()[0];
00141 weight *= q1d[x[k]].weight();
00142 }
00143
00144
00145 push_back(QuadraturePoint<ct,dim>(local,weight));
00146 }
00147 }
00148
00149 int power (int y, int d)
00150 {
00151 int m=1;
00152 for (int i=0; i<d; i++) m *= y;
00153 return m;
00154 }
00155 };
00156
00157
00158
00159 template<typename ctype, int dim> struct QuadratureRuleFactory;
00160
00164 template<typename ctype, int dim>
00165 class QuadratureRules {
00166
00168 typedef std::pair<GeometryType,int> QuadratureRuleKey;
00169
00171 typedef Dune::QuadratureRule<ctype, dim> QuadratureRule;
00172
00174 const QuadratureRule& _rule(const GeometryType& t, int p, QuadratureType::Enum qt=QuadratureType::Gauss)
00175 {
00176 static std::map<QuadratureRuleKey, QuadratureRule> _quadratureMap;
00177 QuadratureRuleKey key(t,p);
00178 if (_quadratureMap.find(key) == _quadratureMap.end()) {
00179
00180
00181
00182
00183
00184 QuadratureRule rule =
00185 QuadratureRuleFactory<ctype,dim>::rule(t,p,qt);
00186 _quadratureMap[key] = rule;
00187 }
00188 return _quadratureMap[key];
00189 }
00191 static QuadratureRules& instance()
00192 {
00193 static QuadratureRules instance;
00194 return instance;
00195 }
00197 QuadratureRules () {};
00198 public:
00200 static const QuadratureRule& rule(const GeometryType& t, int p, QuadratureType::Enum qt=QuadratureType::Gauss)
00201 {
00202 return instance()._rule(t,p,qt);
00203 }
00205 static const QuadratureRule& rule(const GeometryType::BasicType t, int p, QuadratureType::Enum qt=QuadratureType::Gauss)
00206 {
00207 GeometryType gt(t,dim);
00208 return instance()._rule(gt,p,qt);
00209 }
00210 };
00211
00212
00213
00217 template<typename ct, int dim>
00218 class CubeQuadratureRule :
00219 public QuadratureRule<ct,dim>
00220 {
00221 public:
00223 enum { d=dim };
00224
00226 enum { highest_order=CubeQuadratureRule<ct,1>::highest_order };
00227
00229 typedef ct CoordType;
00230
00232 typedef CubeQuadratureRule value_type;
00233
00234 ~CubeQuadratureRule(){}
00235 private:
00236 friend class QuadratureRuleFactory<ct,dim>;
00238 CubeQuadratureRule (int p) : QuadratureRule<ct,dim>(GeometryType(GeometryType::cube, d))
00239 {
00240 QuadratureRule<ct,1> q1D = QuadratureRules<ct,1>::rule(GeometryType::cube, p);
00241 tensor_product( q1D );
00242 this->delivered_order = q1D.order();
00243 }
00244
00245 };
00246
00249 template<typename ct>
00250 class CubeQuadratureRule<ct,0> :
00251 public QuadratureRule<ct,0>
00252 {
00253 public:
00254
00255 enum { d=0 };
00256 enum { dim=0 };
00257 enum { highest_order=61 };
00258 typedef ct CoordType;
00259 typedef CubeQuadratureRule value_type;
00260
00261 ~CubeQuadratureRule(){}
00262 private:
00263 friend class QuadratureRuleFactory<ct,dim>;
00264 CubeQuadratureRule (int p):
00265 QuadratureRule<ct,0>(GeometryType(GeometryType::cube, 0))
00266 {
00267 FieldVector<ct, dim> point(0.0);
00268
00269 if (p > highest_order)
00270 DUNE_THROW(QuadratureOrderOutOfRange, "Quadrature rule " << p << " not supported!");
00271
00272 this->delivered_order = highest_order;
00273 this->push_back(QuadraturePoint<ct,dim>(point, 1.0));
00274 }
00275 };
00276
00279 template<typename ct>
00280 class CubeQuadratureRule<ct,1> :
00281 public QuadratureRule<ct,1>
00282 {
00283 public:
00284
00285 enum { d=1 };
00286 enum { dim=1 };
00287 enum { highest_order=61 };
00288 typedef ct CoordType;
00289 typedef CubeQuadratureRule value_type;
00290
00291 ~CubeQuadratureRule(){}
00292 private:
00293 void init(int p,
00294 std::vector< FieldVector<ct, dim> > & _points,
00295 std::vector< double > & _weight,
00296 int & delivered_order);
00297 friend class QuadratureRuleFactory<ct,dim>;
00298 CubeQuadratureRule (int p)
00299 : QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
00300 {
00302 std::vector< FieldVector<ct, dim> > _points;
00303 std::vector< double > _weight;
00304
00305 init(p, _points, _weight, this->delivered_order);
00306
00307 assert(_points.size() == _weight.size());
00308 for (size_t i = 0; i < _points.size(); i++)
00309 this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
00310 }
00311 };
00312
00316 template<typename ct, int dim>
00317 class Jacobi1QuadratureRule;
00318
00322 template<typename ct>
00323 class Jacobi1QuadratureRule<ct,1> :
00324 public QuadratureRule<ct,1>
00325 {
00326 public:
00328 enum { d=1 };
00331 enum { dim=1 };
00332
00334 enum { highest_order=61 };
00335
00337 typedef ct CoordType;
00338
00340 typedef Jacobi1QuadratureRule value_type;
00341
00342 ~Jacobi1QuadratureRule(){}
00343 private:
00344 void init(int p,
00345 std::vector< FieldVector<ct, dim> > & _points,
00346 std::vector< double > & _weight,
00347 int & delivered_order);
00348 friend class QuadratureRuleFactory<ct,dim>;
00349 Jacobi1QuadratureRule (int p)
00350 : QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
00351 {
00353 std::vector< FieldVector<ct, dim> > _points;
00354 std::vector< double > _weight;
00355
00356 int delivered_order;
00357
00358 init(p, _points, _weight, delivered_order);
00359 this->delivered_order = delivered_order;
00360 assert(_points.size() == _weight.size());
00361 for (size_t i = 0; i < _points.size(); i++)
00362 this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
00363 }
00364 };
00365
00369 template<typename ct, int dim>
00370 class Jacobi2QuadratureRule;
00371
00375 template<typename ct>
00376 class Jacobi2QuadratureRule<ct,1> :
00377 public QuadratureRule<ct,1>
00378 {
00379 public:
00381 enum { d=1 };
00382
00385 enum { dim=1 };
00386
00388 enum { highest_order=61 };
00389
00391 typedef ct CoordType;
00392
00394 typedef Jacobi2QuadratureRule value_type;
00395
00396 ~Jacobi2QuadratureRule(){}
00397 private:
00398 void init(int p,
00399 std::vector< FieldVector<ct, dim> > & _points,
00400 std::vector< double > & _weight,
00401 int & delivered_order);
00402 friend class QuadratureRuleFactory<ct,dim>;
00403 Jacobi2QuadratureRule (int p)
00404 : QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
00405 {
00407 std::vector< FieldVector<ct, dim> > _points;
00408 std::vector< double > _weight;
00409
00410 int delivered_order;
00411
00412 init(p, _points, _weight, delivered_order);
00413
00414 this->delivered_order = delivered_order;
00415 assert(_points.size() == _weight.size());
00416 for (size_t i = 0; i < _points.size(); i++)
00417 this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
00418 }
00419 };
00420
00421
00422
00423
00424
00428 template<typename ct, int dim>
00429 class SimplexQuadratureRule;
00430
00434 template<typename ct>
00435 class SimplexQuadratureRule<ct,2> : public QuadratureRule<ct,2>
00436 {
00437 public:
00438
00440 enum{d=2};
00441
00443 enum { highest_order=CubeQuadratureRule<ct,1>::highest_order -1 };
00444
00446 typedef ct CoordType;
00447
00449 typedef SimplexQuadratureRule value_type;
00450 ~SimplexQuadratureRule(){}
00451 private:
00452 friend class QuadratureRuleFactory<ct,d>;
00453 SimplexQuadratureRule (int p);
00454 };
00455
00459 template<typename ct>
00460 class SimplexQuadratureRule<ct,3> : public QuadratureRule<ct,3>
00461 {
00462 public:
00463
00465 enum{d=3};
00466
00468 enum { highest_order=CubeQuadratureRule<ct,1>::highest_order -2 };
00469
00471 typedef ct CoordType;
00472
00474 typedef SimplexQuadratureRule<ct,3> value_type;
00475 ~SimplexQuadratureRule(){}
00476 private:
00477 friend class QuadratureRuleFactory<ct,d>;
00478 SimplexQuadratureRule (int p);
00479 };
00480
00481
00482
00483
00484
00486 template<int dim>
00487 class PrismQuadraturePoints;
00488
00490 template<>
00491 class PrismQuadraturePoints<3>
00492 {
00493 public:
00494 enum { MAXP=6};
00495 enum { highest_order=2 };
00496
00498 PrismQuadraturePoints ()
00499 {
00500 int m = 0;
00501 O[m] = 0;
00502
00503
00504 m = 6;
00505 G[m][0][0] = 0.0;
00506 G[m][0][1] = 0.0;
00507 G[m][0][2] = 0.0;
00508
00509 G[m][1][0] = 1.0;
00510 G[m][1][1] = 0.0;
00511 G[m][1][2] = 0.0;
00512
00513 G[m][2][0] = 0.0;
00514 G[m][2][1] = 1.0;
00515 G[m][2][2] = 0.0;
00516
00517 G[m][3][0] = 0.0;
00518 G[m][3][1] = 0.0;
00519 G[m][3][2] = 1.0;
00520
00521 G[m][4][0] = 1.0;
00522 G[m][4][1] = 0.0;
00523 G[m][4][2] = 1.0;
00524
00525 G[m][5][0] = 0.0;
00526 G[m][5][1] = 0.1;
00527 G[m][5][2] = 1.0;
00528
00529 W[m][0] = 0.16666666666666666 / 2.0;
00530 W[m][1] = 0.16666666666666666 / 2.0;
00531 W[m][2] = 0.16666666666666666 / 2.0;
00532 W[m][3] = 0.16666666666666666 / 2.0;
00533 W[m][4] = 0.16666666666666666 / 2.0;
00534 W[m][5] = 0.16666666666666666 / 2.0;
00535
00536 O[m] = 0;
00537
00538
00539
00540 m = 6;
00541 G[m][0][0] =0.66666666666666666 ;
00542 G[m][0][1] =0.16666666666666666 ;
00543 G[m][0][2] =0.211324865405187 ;
00544
00545 G[m][1][0] = 0.16666666666666666;
00546 G[m][1][1] =0.66666666666666666 ;
00547 G[m][1][2] = 0.211324865405187;
00548
00549 G[m][2][0] = 0.16666666666666666;
00550 G[m][2][1] = 0.16666666666666666;
00551 G[m][2][2] = 0.211324865405187;
00552
00553 G[m][3][0] = 0.66666666666666666;
00554 G[m][3][1] = 0.16666666666666666;
00555 G[m][3][2] = 0.788675134594813;
00556
00557 G[m][4][0] = 0.16666666666666666;
00558 G[m][4][1] = 0.66666666666666666;
00559 G[m][4][2] = 0.788675134594813;
00560
00561 G[m][5][0] = 0.16666666666666666;
00562 G[m][5][1] = 0.16666666666666666;
00563 G[m][5][2] = 0.788675134594813;
00564
00565 W[m][0] = 0.16666666666666666 / 2.0;
00566 W[m][1] = 0.16666666666666666 / 2.0;
00567 W[m][2] = 0.16666666666666666 / 2.0;
00568 W[m][3] = 0.16666666666666666 / 2.0;
00569 W[m][4] = 0.16666666666666666 / 2.0;
00570 W[m][5] = 0.16666666666666666 / 2.0;
00571
00572 O[m] = 2;
00573
00574 }
00575
00577 FieldVector<double, 3> point(int m, int i)
00578 {
00579 return G[m][i];
00580 }
00581
00583 double weight (int m, int i)
00584 {
00585 return W[m][i];
00586 }
00587
00589 int order (int m)
00590 {
00591 return O[m];
00592 }
00593
00594 private:
00595 FieldVector<double, 3> G[MAXP+1][MAXP];
00596
00597 double W[MAXP+1][MAXP];
00598 int O[MAXP+1];
00599 };
00600
00601
00605 template<int dim>
00606 struct PrismQuadraturePointsSingleton {
00607 static PrismQuadraturePoints<3> prqp;
00608 };
00609
00613 template<>
00614 struct PrismQuadraturePointsSingleton<3> {
00615 static PrismQuadraturePoints<3> prqp;
00616 };
00617
00621 template<typename ct, int dim>
00622 class PrismQuadratureRule;
00623
00627 template<typename ct>
00628 class PrismQuadratureRule<ct,3> : public QuadratureRule<ct,3>
00629 {
00630 public:
00631
00633 enum{ d=3 };
00634
00636 enum{
00637
00638 highest_order =
00639 (int)CubeQuadratureRule<ct,1>::highest_order
00640 < (int)SimplexQuadratureRule<ct,2>::highest_order
00641 ? (int)CubeQuadratureRule<ct,1>::highest_order
00642 : (int)SimplexQuadratureRule<ct,2>::highest_order
00643 };
00644
00646 typedef ct CoordType;
00647
00649 typedef PrismQuadratureRule<ct,3> value_type;
00650
00651 ~PrismQuadratureRule(){}
00652 private:
00653 friend class QuadratureRuleFactory<ct,d>;
00654 PrismQuadratureRule(int p) : QuadratureRule<ct,3>(GeometryType(GeometryType::prism, d))
00655 {
00656 if (p>highest_order)
00657 DUNE_THROW(QuadratureOrderOutOfRange,
00658 "QuadratureRule for order " << p << " and GeometryType "
00659 << this->type() << " not available");
00660
00661 if (p<=2) {
00662 int m=6;
00663 this->delivered_order = PrismQuadraturePointsSingleton<3>::prqp.order(m);
00664 for(int i=0;i<m;++i)
00665 {
00666 FieldVector<ct,3> local;
00667 for (int k=0; k<d; k++)
00668 local[k] = PrismQuadraturePointsSingleton<3>::prqp.point(m,i)[k];
00669 double weight =
00670 PrismQuadraturePointsSingleton<3>::prqp.weight(m,i);
00671
00672 push_back(QuadraturePoint<ct,d>(local,weight));
00673 }
00674 }
00675 else {
00676 const QuadratureRule<ct,2> & triangle = QuadratureRules<ct,2>::rule(GeometryType::simplex, p);
00677 const QuadratureRule<ct,1> & line = QuadratureRules<ct,1>::rule(GeometryType::cube, p);
00678
00679 this->delivered_order = std::min(triangle.order(),line.order());
00680
00681 for (typename QuadratureRule<ct,1>::const_iterator
00682 lit = line.begin(); lit != line.end(); ++lit)
00683 {
00684 for (typename QuadratureRule<ct,2>::const_iterator
00685 tit = triangle.begin(); tit != triangle.end(); ++tit)
00686 {
00687 FieldVector<ct, d> local;
00688 local[0] = tit->position()[0];
00689 local[1] = tit->position()[1];
00690 local[2] = lit->position()[0];
00691
00692 double weight = tit->weight() * lit->weight();
00693
00694
00695 push_back(QuadraturePoint<ct,d>(local,weight));
00696 }
00697 }
00698 }
00699 }
00700 };
00701
00703 class PyramidQuadraturePoints
00704 {
00705 public:
00706 enum { MAXP=8};
00707 enum { highest_order=2 };
00708
00710 PyramidQuadraturePoints()
00711 {
00712 int m = 0;
00713 O[m] = 0;
00714
00715
00716
00717 m = 8;
00718 G[m][0][0] =0.58541020;
00719 G[m][0][1] =0.72819660;
00720 G[m][0][2] =0.13819660;
00721
00722 G[m][1][0] =0.13819660;
00723 G[m][1][1] =0.72819660;
00724 G[m][1][2] =0.13819660;
00725
00726 G[m][2][0] =0.13819660;
00727 G[m][2][1] =0.27630920;
00728 G[m][2][2] =0.58541020;
00729
00730 G[m][3][0] =0.13819660;
00731 G[m][3][1] =0.27630920;
00732 G[m][3][2] =0.13819660;
00733
00734 G[m][4][0] =0.72819660;
00735 G[m][4][1] =0.13819660;
00736 G[m][4][2] =0.13819660;
00737
00738 G[m][5][0] =0.72819660;
00739 G[m][5][1] =0.58541020;
00740 G[m][5][2] =0.13819660;
00741
00742 G[m][6][0] =0.27630920;
00743 G[m][6][1] =0.13819660;
00744 G[m][6][2] =0.58541020;
00745
00746 G[m][7][0] =0.27630920;
00747 G[m][7][1] =0.13819660;
00748 G[m][7][2] =0.13819660;
00749
00750 W[m][0] = 0.125 / 3.0;
00751 W[m][1] = 0.125 / 3.0;
00752 W[m][2] = 0.125 / 3.0;
00753 W[m][3] = 0.125 / 3.0;
00754 W[m][4] = 0.125 / 3.0;
00755 W[m][5] = 0.125 / 3.0;
00756 W[m][6] = 0.125 / 3.0;
00757 W[m][7] = 0.125 / 3.0;
00758
00759 O[m] = 2;
00760
00761 }
00762
00764 FieldVector<double, 3> point(int m, int i)
00765 {
00766 return G[m][i];
00767 }
00768
00770 double weight (int m, int i)
00771 {
00772 return W[m][i];
00773 }
00774
00776 int order (int m)
00777 {
00778 return O[m];
00779 }
00780
00781 private:
00782 FieldVector<double, 3> G[MAXP+1][MAXP];
00783 double W[MAXP+1][MAXP];
00784 int O[MAXP+1];
00785 };
00786
00790 template<int dim>
00791 struct PyramidQuadraturePointsSingleton {};
00792
00796 template<>
00797 struct PyramidQuadraturePointsSingleton<3> {
00798 static PyramidQuadraturePoints pyqp;
00799 };
00800
00804 template<typename ct, int dim>
00805 class PyramidQuadratureRule;
00806
00810 template<typename ct>
00811 class PyramidQuadratureRule<ct,3> : public QuadratureRule<ct,3>
00812 {
00813 public:
00814
00816 enum{d=3};
00817
00819 enum{highest_order=CubeQuadratureRule<ct,1>::highest_order};
00820
00822 typedef ct CoordType;
00823
00825 typedef PyramidQuadratureRule<ct,3> value_type;
00826
00827 ~PyramidQuadratureRule(){}
00828 private:
00829 friend class QuadratureRuleFactory<ct,d>;
00830 PyramidQuadratureRule(int p) : QuadratureRule<ct,3>(GeometryType(GeometryType::pyramid, d))
00831 {
00832 int m;
00833
00834 if (p>highest_order)
00835 DUNE_THROW(QuadratureOrderOutOfRange,
00836 "QuadratureRule for order " << p << " and GeometryType "
00837 << this->type() << " not available");
00838
00839 if(false) {
00840
00841 m=8;
00842 this->delivered_order = PyramidQuadraturePointsSingleton<3>::pyqp.order(m);
00843 FieldVector<ct, d> local;
00844 double weight;
00845 for(int i=0;i<m;++i)
00846 {
00847 for(int k=0;k<d;++k)
00848 local[k]=PyramidQuadraturePointsSingleton<3>::pyqp.point(m,i)[k];
00849 weight=PyramidQuadraturePointsSingleton<3>::pyqp.weight(m,i);
00850
00851 push_back(QuadraturePoint<ct,d>(local,weight));
00852 }
00853 }
00854 else
00855 {
00856
00857 QuadratureRule<ct,3> simplex =
00858 QuadratureRules<ct,3>::rule(GeometryType::simplex,p);
00859
00860 for (typename QuadratureRule<ct,3>::const_iterator
00861 it=simplex.begin(); it != simplex.end(); ++it)
00862 {
00863 FieldVector<ct,3> local = it->position();
00864 ct weight = it->weight();
00865
00866
00867 local[0] = local[0]+local[1];
00868 push_back(QuadraturePoint<ct,d>(local,weight));
00869
00870
00871 local[0] = it->position()[0];
00872 local[1] = local[0]+local[1];
00873 push_back(QuadraturePoint<ct,d>(local,weight));
00874 }
00875
00876 this->delivered_order = simplex.order();
00877 }
00878 }
00879 };
00880
00887 template<typename ctype, int dim>
00888 class QuadratureRuleFactory {
00889 private:
00890 friend class QuadratureRules<ctype, dim>;
00891 static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
00892 {
00893 if (t.isCube())
00894 {
00895 return CubeQuadratureRule<ctype,dim>(p);
00896 }
00897 if (t.isSimplex())
00898 {
00899 return SimplexQuadratureRule<ctype,dim>(p);
00900 }
00901 DUNE_THROW(Exception, "Unknown GeometryType");
00902 }
00903 };
00904
00905 template<typename ctype>
00906 class QuadratureRuleFactory<ctype, 0> {
00907 private:
00908 enum { dim = 0 };
00909 friend class QuadratureRules<ctype, dim>;
00910 static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
00911 {
00912 if (t.isVertex())
00913 {
00914 return CubeQuadratureRule<ctype,dim>(p);
00915 }
00916 DUNE_THROW(Exception, "Unknown GeometryType");
00917 }
00918 };
00919
00920 template<typename ctype>
00921 class QuadratureRuleFactory<ctype, 1> {
00922 private:
00923 enum { dim = 1 };
00924 friend class QuadratureRules<ctype, dim>;
00925 static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
00926 {
00927 if (t.isLine())
00928 {
00929 switch (qt) {
00930 case QuadratureType::Gauss:
00931 return CubeQuadratureRule<ctype,dim>(p);
00932 case QuadratureType::Jacobian_1_0:
00933 return Jacobi1QuadratureRule<ctype,dim>(p);
00934 case QuadratureType::Jacobian_2_0:
00935 return Jacobi2QuadratureRule<ctype,dim>(p);
00936 default:
00937 DUNE_THROW(Exception, "Unknown QuadratureType");
00938 }
00939 }
00940 DUNE_THROW(Exception, "Unknown GeometryType");
00941 }
00942 };
00943
00944 template<typename ctype>
00945 class QuadratureRuleFactory<ctype, 3> {
00946 private:
00947 enum { dim = 3 };
00948 friend class QuadratureRules<ctype, dim>;
00949 static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
00950 {
00951 if (t.isCube())
00952 {
00953 return CubeQuadratureRule<ctype,dim>(p);
00954 }
00955 if (t.isSimplex())
00956 {
00957 return SimplexQuadratureRule<ctype,dim>(p);
00958 }
00959 if (t.isPrism())
00960 {
00961 return PrismQuadratureRule<ctype,dim>(p);
00962 }
00963 if (t.isPyramid())
00964 {
00965 return PyramidQuadratureRule<ctype,dim>(p);
00966 }
00967 DUNE_THROW(Exception, "Unknown GeometryType");
00968 }
00969 };
00970
00971 }
00972
00973 #endif