DUNE-FEM (unstable)

interpolationquadrature.hh
1#ifndef DUNE_FEM_INTERPOLATIONQUADRATURE_HH
2#define DUNE_FEM_INTERPOLATIONQUADRATURE_HH
3
4//- Dune includes
7
8#include <dune/fem/quadrature/quadratureimp.hh>
9#include <dune/fem/space/localfiniteelement/quadratureinterpolation.hh>
10
11namespace Dune
12{
13
14 namespace Fem
15 {
16
17 namespace detail
18 {
24 template< typename FieldImp, int dim, template <class,unsigned int> class PointSet >
25 class InterpolationQuadratureFactory
26 : public Dune::Fem::QuadratureImp< FieldImp, dim >
27 {
28 public:
29 typedef FieldImp FieldType;
30 typedef PointSet< FieldType, dim > PointSetType;
31
32 enum { dimension = dim };
33
34 private:
35 typedef InterpolationQuadratureFactory< FieldType, dimension, PointSet > ThisType;
37
38 protected:
39 typedef typename BaseType :: ElementCoordinateType ElementCoordinateType;
40 using BaseType :: addQuadraturePoint;
41
42 public:
43 typedef typename BaseType :: CoordinateType CoordinateType;
44
45 protected:
46 const GeometryType elementGeometry_;
47 mutable size_t numElementInterpolPoints_;
48 int order_;
49
50 public:
57 InterpolationQuadratureFactory( const GeometryType &geometry,
58 const int order,
59 const size_t id )
60 : BaseType( id ),
61 elementGeometry_( geometry ),
62 numElementInterpolPoints_( 0 ) // this is only set when interpolationPoints are requested
63 {
64 // revert quadrature order to polynomial order
65 if( geometry.isCube() )
66 {
67 auto points = PointSetType::buildCubeQuadrature( order );
68 order_ = points.quadOrder();
69
70 assert(order_ >= order);
71
72 for( unsigned int i=0; i<points.size(); ++i )
73 {
74 addQuadraturePoint( points[ i ].point(), points[ i ].weight() );
75 }
76 }
77 else
78 {
79 DUNE_THROW(InvalidStateException,"InterpolationQuadratureFactory: Unsupported geometry type " << geometry);
80 }
81 }
82
85 int order () const
86 {
87 return order_;
88 }
89
92 virtual std::vector< ElementCoordinateType > interpolationPoints(const int reqDim ) const
93 {
94 // if requested dimension matches potential element dimension
95 if( reqDim == (dim+1) && dim < 3 )
96 {
97 typedef PointSet< FieldType, dim+1 > ElementPointSet;
98 auto points = ElementPointSet::buildCubeQuadrature( order_ );
99 numElementInterpolPoints_ = points.size();
100 std::vector< ElementCoordinateType > pts( numElementInterpolPoints_ );
101 for( size_t i=0; i<numElementInterpolPoints_; ++i )
102 pts[ i ] = points[ i ].point();
103 return pts;
104 }
105 else
106 return std::vector< ElementCoordinateType >();
107 }
108
110 virtual bool isFaceInterpolationQuadrature( const size_t numShapeFunctions ) const
111 {
112 // when numElementInterpolPoints_ is set this means we have a face
113 // quadrature and then this is an interpolation quadrature if the
114 // number of shape functions matches the number of element
115 // interpolation points
116 return numShapeFunctions == numElementInterpolPoints_;
117 }
118
122 {
123 return elementGeometry_;
124 }
125
128 static unsigned int maxOrder ()
129 {
130 // if the quadrature is from dune-geometry use the info from there
131 if constexpr( PointSetType::pointSetId < Dune::QuadratureType::size )
132 {
134 maxOrder( Dune::GeometryTypes::cube(dim), Dune::QuadratureType::Enum(PointSetType::pointSetId) );
135 }
136 else
137 {
138 return 20;
139 }
140 }
141 };
142
143 template< class FieldType, int dim, template <class,unsigned int> class PointSet >
144 struct InterpolationQuadratureTraitsImpl
145 {
146 static const int pointSetId = PointSet<FieldType,dim>::pointSetId;
147
148 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > SimplexQuadratureType;
149 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > CubeQuadratureType;
150
151 typedef Dune::Fem::QuadratureImp< FieldType, dim > IntegrationPointListType;
152
153 typedef int QuadratureKeyType ;
154 };
155
156 template< class FieldType, template <class,unsigned int> class PointSet >
157 struct InterpolationQuadratureTraitsImpl< FieldType, 0, PointSet >
158 {
159 static const int dim = 0;
160
161 static const int pointSetId = PointSet<FieldType,dim>::pointSetId;
162
163 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > PointQuadratureType;
164
165 typedef Dune::Fem::QuadratureImp< FieldType, dim > IntegrationPointListType;
166
167 typedef int QuadratureKeyType ;
168 };
169
170 template< class FieldType, template <class,unsigned int> class PointSet >
171 struct InterpolationQuadratureTraitsImpl< FieldType, 1, PointSet >
172 {
173 static const int dim = 1;
174
175 static const int pointSetId = PointSet<FieldType,dim>::pointSetId;
176
177 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > LineQuadratureType;
178
179 typedef Dune::Fem::QuadratureImp< FieldType, dim > IntegrationPointListType;
180
181 typedef int QuadratureKeyType ;
182 };
183
184 template< class FieldType, template <class,unsigned int> class PointSet >
185 struct InterpolationQuadratureTraitsImpl< FieldType, 3, PointSet >
186 {
187 static const int dim = 3;
188
189 static const int pointSetId = PointSet<FieldType,dim>::pointSetId;
190
191 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > SimplexQuadratureType;
192 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > CubeQuadratureType;
193
194 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > PrismQuadratureType;
195 typedef InterpolationQuadratureFactory< FieldType, dim, PointSet > PyramidQuadratureType;
196
197 typedef Dune::Fem::QuadratureImp< FieldType, dim > IntegrationPointListType;
198
199 typedef int QuadratureKeyType ;
200 };
201 } // end namespace detail
202
203#if HAVE_DUNE_LOCALFUNCTIONS
205 //
206 // Equidistant point set
207 //
209 template <class FieldType, int dim >
210 using EquidistantQuadratureTraits = detail::InterpolationQuadratureTraitsImpl< FieldType, dim, EquidistantPointSetDerived >;
211
213 //
214 // GaussLobatto point set (same quadrature as in dune-geometry
215 // but different point ordering)
216 //
218 template <class FieldType, int dim >
219 using GaussLobattoQuadratureTraits = detail::InterpolationQuadratureTraitsImpl< FieldType, dim, GaussLobattoPointSet >;
220
222 //
223 // GaussLegendre point set (same quadrature as in dune-geometry
224 // but different point ordering)
225 //
227 template <class FieldType, int dim >
228 using GaussLegendreQuadratureTraits = detail::InterpolationQuadratureTraitsImpl< FieldType, dim, GaussLegendrePointSet >;
229
231 //
232 // Cell centers point set
233 //
235 template <class FieldType, int dim >
236 using CellCentersQuadratureTraits = detail::InterpolationQuadratureTraitsImpl< FieldType, dim, CellCentersPointSet >;
237
238#endif
239
240 } // namespace Fem
241
242} // namespace Dune
243
244#endif // #ifndef DUNE_FEM_LAGRANGEPOINTS_HH
const CoordinateType & point(size_t i) const
obtain coordinates of i-th integration point
Definition: quadratureimp.hh:96
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
BaseType::CoordinateType CoordinateType
type of local coordinates
Definition: quadratureimp.hh:207
const FieldType & weight(size_t i) const
obtain weight of i-th integration point
Definition: quadratureimp.hh:251
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
maximum quadrature order for given geometry type and quadrature type
Definition: quadraturerules.hh:319
GeometryType geometryType(const Dune::GeometryType &t)
mapping from GeometryType to VTKGeometryType
Definition: common.hh:151
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
Enum
Definition: quadraturerules.hh:131
Dune namespace.
Definition: alignedallocator.hh:13
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)