DUNE-FEM (unstable)

quadrature.hh
1#ifndef DUNE_FEM_QUADRATURE_HH
2#define DUNE_FEM_QUADRATURE_HH
3
4#include <cassert>
5#include <memory>
6
9
11
13
14#include <dune/fem/common/coordinate.hh>
15#include <dune/fem/common/utility.hh>
16#include <dune/fem/storage/envelope.hh>
17#include <dune/fem/version.hh>
18#include <dune/fem/quadrature/quadprovider.hh>
19#include <dune/fem/quadrature/defaultquadratures.hh>
20
21namespace Dune
22{
23 namespace Fem
24 {
40 template< class Quadrature >
42 {
43 public:
45
46 typedef typename QuadratureType::CoordinateType CoordinateType;
47 typedef typename QuadratureType::RealType RealType;
48 typedef typename QuadratureType::LocalCoordinateType LocalCoordinateType;
49
50 private:
52
53 protected:
54 const QuadratureType &quadrature_;
55 const unsigned int index_;
56
57 public:
58 QuadraturePointWrapper ( const QuadratureType &quadrature, unsigned int index )
59 : quadrature_( quadrature ), index_( index )
60 {}
61
62 ThisType &operator= ( const ThisType & ) = delete;
63
64 inline const QuadratureType &quadrature () const
65 {
66 return quadrature_;
67 }
68
69 unsigned int index () const { return index_; }
70 const CoordinateType &position () const { return quadrature().point( index() ); }
71 auto weight () const { return quadrature().weight( index() ); }
72 const LocalCoordinateType &localPosition () const { return quadrature().localPoint( index() ); }
73 };
74
75
76
89 template< class Quadrature >
90 static inline typename Quadrature::CoordinateType
92 {
93 return x.position();
94 }
95
101 template< class Quadrature >
103 {
105
106 public:
107 typedef std::forward_iterator_tag iterator_category;
109 typedef std::ptrdiff_t difference_type;
110 typedef Envelope< QuadraturePointWrapper< Quadrature > > pointer;
112
113 QuadraturePointIterator () noexcept = default;
114
115 QuadraturePointIterator ( const Quadrature &quadrature, std::size_t point ) noexcept
116 : quadrature_( &quadrature ), point_( point )
117 {}
118
119 reference operator* () const noexcept { return value_type( quadrature(), point_ ); }
120 pointer operator-> () const noexcept { return pointer( value_type( quadrature(), point_ ) ); }
121
122 bool operator== ( const ThisType &other ) const noexcept { return (point_ == other.point_); }
123 bool operator!= ( const ThisType &other ) const noexcept { return (point_ != other.point_); }
124
125 ThisType &operator++ () noexcept { ++point_; return *this; }
126 ThisType operator++ ( int ) noexcept { ThisType copy( *this ); ++(*this); return copy; }
127
128 const Quadrature &quadrature () const noexcept { assert( quadrature_ ); return *quadrature_; }
129
130 protected:
131 const Quadrature *quadrature_ = nullptr;
132 std::size_t point_ = 0;
133 };
134
135
136
154 template< typename FieldImp, int dim,
155 template< class, int > class IntegrationTraits,
156 bool isQuadrature = false >
158 {
159 public:
160 typedef FieldImp FieldType;
161
162 enum { dimension = dim };
163
164 typedef IntegrationTraits< FieldType, dimension > Traits;
165
166 private:
168
171
172 typedef typename std::conditional< isQuadrature,
173 const FieldType&,
174 FieldType > :: type WeightReturnType;
175 public:
177 typedef typename Traits :: IntegrationPointListType IntegrationPointListType;
178
180 typedef typename IntegrationPointListType :: CoordinateType CoordinateType;
181
183
184 typedef std::shared_ptr< const IntegrationPointListType > IntegrationPointListStorageType;
185
187 enum { codimension = 0 };
188
189 protected:
190 // when the integration point list is obtained from the
191 // QuadratureProvider then it should not be deleted
192 struct NoDelete
193 {
194 void operator()( const IntegrationPointListType* ) {}
195 };
196
197 IntegrationPointListStorageType ipListPtr_;
198
199 public:
210 template <class FactoryTraits>
211 inline IntegrationPointList ( const FactoryTraits traits,
213 const typename FactoryTraits::QuadratureKeyType& quadKey )
214 : ipListPtr_( &QuadratureProviderType :: getQuadrature( geometryType, quadKey ), NoDelete() )
215 //: ipListPtr_( &QuadratureProviderType :: getQuadrature( traits, geometryType, quadKey ), NoDelete() )
216 {
217 }
218
219 template <class QuadratureKeyType>
221 const QuadratureKeyType& quadKey )
222 : IntegrationPointList( DefaultQuadratureTraits< FieldType, dimension > (),
223 geometryType, quadKey )
224 {
225 }
226
239 template <class FactoryTraits>
240 inline IntegrationPointList ( const FactoryTraits traits,
242 const GeometryType &elementGeometry,
243 const typename FactoryTraits::QuadratureKeyType& quadKey )
244 //: ipListPtr_( &QuadratureProviderType :: getQuadrature( traits, geometryType, elementGeometry, quadKey ), NoDelete() )
245 : ipListPtr_( &QuadratureProviderType :: getQuadrature( geometryType, elementGeometry, quadKey ), NoDelete() )
246 {
247 }
248
249 template <class QuadratureKeyType>
251 const GeometryType &elementGeometry,
252 const QuadratureKeyType& quadKey )
253 : IntegrationPointList( DefaultQuadratureTraits< FieldType, dimension > (),
254 geometryType, elementGeometry, quadKey )
255 {
256 }
257
268 : ipListPtr_( &ipList, NoDelete() )
269 {
270 }
271
281 inline IntegrationPointList ( const IntegrationPointListStorageType& ipListPtr )
282 : ipListPtr_( ipListPtr )
283 {
284 }
285
290 inline IntegrationPointList ( const IntegrationPointList &org ) = default;
291
292 const QuadraturePointWrapperType operator[] ( unsigned int i ) const
293 {
294 return QuadraturePointWrapperType( *this, i );
295 }
296
303 {
304 assert( ipListPtr_ );
305 return *ipListPtr_;
306 }
307
312 int nop () const
313 {
314 return ipList().nop();
315 }
316
328 const CoordinateType &point ( size_t i ) const
329 {
330 return ipList().point( i );
331 }
332
344 size_t id () const
345 {
346 return ipList().id();
347 }
348
362 int order () const
363 {
364 return ipList().order();
365 }
366
380 {
381 return ipList().geometryType();
382 }
383
386 auto interpolationPoints( const int reqDim ) const
387 {
388 return ipList().interpolationPoints( reqDim );
389 }
390
393 bool isFaceInterpolationQuadrature( const size_t numShapeFunctions ) const
394 {
395 return ipList().isFaceInterpolationQuadrature( numShapeFunctions );
396 }
397
412 WeightReturnType weight( size_t i ) const
413 {
414 if constexpr ( isQuadrature )
415 {
416 return ipList().weight( i );
417 }
418 else
419 return 1.0;
420 }
421 };
422
423
441 template< class FieldImp, int dim,
442 template< class, int > class QuadratureTraits = DefaultQuadratureTraits >
443 using Quadrature = IntegrationPointList< FieldImp, dim, QuadratureTraits, true >;
444
445
446
453 template <class Quadrature>
454 using SelectQuadraturePointSetId = detail::SelectPointSetId< Quadrature, -Dune::QuadratureType::size >;
455
456 } //end namespace Fem
457
458} //end namespace Dune
459
460#endif
actual interface class for integration point lists
Definition: quadrature.hh:158
auto interpolationPoints(const int reqDim) const
returns list of element interpolation points for a given face quadrature
Definition: quadrature.hh:386
IntegrationPointList(const IntegrationPointListType &ipList)
create an integration point list from an implementation
Definition: quadrature.hh:267
IntegrationPointList(const FactoryTraits traits, const GeometryType &geometryType, const typename FactoryTraits::QuadratureKeyType &quadKey)
create a quadrature for a given geometry type and order
Definition: quadrature.hh:211
size_t id() const
obtain the identifier of the integration point list
Definition: quadrature.hh:344
int order() const
obtain order of the integration point list
Definition: quadrature.hh:362
int nop() const
obtain the number of integration points
Definition: quadrature.hh:312
WeightReturnType weight(size_t i) const
obtain weight of i-th integration point (if quadrature, else 1.0)
Definition: quadrature.hh:412
Traits::IntegrationPointListType IntegrationPointListType
type of integration point list implementation
Definition: quadrature.hh:177
IntegrationPointList(const FactoryTraits traits, const GeometryType &geometryType, const GeometryType &elementGeometry, const typename FactoryTraits::QuadratureKeyType &quadKey)
create a quadrature for a given geometry type and order
Definition: quadrature.hh:240
const IntegrationPointListType & ipList() const
obtain a reference the actual implementation
Definition: quadrature.hh:302
GeometryType geometryType() const
obtain GeometryType for this integration point list
Definition: quadrature.hh:379
IntegrationPointList(const IntegrationPointListStorageType &ipListPtr)
create an integration point list from an implementation
Definition: quadrature.hh:281
bool isFaceInterpolationQuadrature(const size_t numShapeFunctions) const
return true if quadrature is also a set of interpolation points for the given shape functions
Definition: quadrature.hh:393
IntegrationPointList(const IntegrationPointList &org)=default
copy constructor
IntegrationPointListType::CoordinateType CoordinateType
type of coordinate
Definition: quadrature.hh:180
const CoordinateType & point(size_t i) const
obtain coordinates of i-th integration point
Definition: quadrature.hh:328
iterator over quadrature points
Definition: quadrature.hh:103
wrapper for a (Quadrature,int) pair
Definition: quadrature.hh:42
static Quadrature::CoordinateType coordinate(const QuadraturePointWrapper< Quadrature > &x)
extract the real coordinate from a point
Definition: quadrature.hh:91
provide a single instance pool of quadratures
Definition: quadprovider.hh:304
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
actual interface class for quadratures
Different resources needed by all grid implementations.
A few common exception classes.
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)