DUNE-FEM (unstable)

femquadratures_inline.hh
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>
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 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
40 typedef FieldVector< ct, dim > CoordinateType;
41
42 // point quadrature
43 if constexpr ( dim == 0 )
44 {
45 typedef FieldVector< double, 0 > CoordinateType;
46
47 order_ = 20;
48
49 // fill in all the gauss points
50 // compute coordinates and weight
51 double weight = 1.0;
52 CoordinateType local( 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;
84 CoordinateType local;
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
125 FieldVector<ct, 3> local;
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>
142 PyramidQuadrature<ct>::PyramidQuadrature(const GeometryType&, int order, size_t id) :
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>
167 PolyhedronQuadrature<ct, dim>::PolyhedronQuadrature(const GeometryType& geomType, int order, size_t id) :
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
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)