DUNE-FEM (unstable)

cachingpointlist.hh
1#ifndef DUNE_FEM_CACHINGPOINTLIST_HH
2#define DUNE_FEM_CACHINGPOINTLIST_HH
3
4//- Dune includes
5#include <dune/common/math.hh>
6
7//- Local includes
8#include <dune/fem/quadrature/elementpointlist.hh>
9#include <dune/fem/quadrature/caching/twistutility.hh>
10#include <dune/fem/quadrature/caching/pointmapper.hh>
11#include <dune/fem/quadrature/caching/cacheprovider.hh>
12
13namespace Dune
14{
15
16 namespace Fem
17 {
18
23 {
24 protected:
25 // do not create instances of this class
27 {
28 }
29
30 public:
32 static constexpr bool twisted () { return false; }
33
35 inline int twistId () const { return 0; }
36
47 inline size_t cachingPoint( const size_t quadraturePoint ) const
48 {
50 "CachingInterface :: cachingPoint must be overloaded!" );
51 }
52
58 inline size_t interpolationPoint( const size_t quadraturePoint ) const
59 {
61 "CachingInterface :: interpolationPoint must be overloaded!" );
62 }
63
70 inline bool isInterpolationQuadrature( const size_t numShapeFunctions ) const
71 {
73 "CachingInterface :: isInterpolationQuadrature must be overloaded!" );
74 }
75 };
76
77
78
102 template< class GridPartImp, int codim, class IntegrationTraits >
104
105
106
108 template< class GridPartImp, class IntegrationTraits >
109 class CachingPointList< GridPartImp, 0, IntegrationTraits >
110 : public ElementPointListBase< GridPartImp, 0, IntegrationTraits >,
111 public CachingInterface
112 {
115
116 public:
117 typedef typename Base::GridPartType GridPartType;
118 static const int codimension = Base::codimension;
119
121 typedef typename Base::CoordinateType CoordinateType;
122
124 typedef typename Base::QuadratureKeyType QuadratureKeyType;
125
130
132 static const int pointSetId = SelectQuadraturePointSetId<
133 typename IntegrationTraits::IntegrationPointListType::Traits > :: value;
134
135 protected:
136 using Base::quadImp;
137
138 public:
141 using Base::localPoint;
142 using Base::nop;
143
146 CachingPointList( const GeometryType &geometry, const QuadratureKeyType& quadKey )
147 : Base( geometry, quadKey )
148 {
149 CacheProvider< GridPartType, codimension >::registerQuadrature( quadImp() );
150 }
151
152 const QuadraturePointWrapperType operator[] ( const size_t i ) const
153 {
154 return QuadraturePointWrapperType( *this, i );
155 }
156
157 IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
158 IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
159
161 const CoordinateType &point ( const size_t i ) const
162 {
163 return localPoint( i );
164 }
165
167 inline size_t cachingPoint( const size_t quadraturePoint ) const
168 {
169 return quadraturePoint;
170 }
171
173 inline size_t interpolationPoint( const size_t quadraturePoint ) const
174 {
175 return quadraturePoint;
176 }
177
179 inline bool isInterpolationQuadrature( const size_t numShapeFunctions ) const
180 {
181 // if pointSetId is not negative then we have an interpolation
182 // quadrature if the number of point are equal to number of shape functions
183 return (pointSetId >= 0) ? (nop() == numShapeFunctions) : false;
184 }
185 };
186
187
188
190 template< typename GridPartImp, class IntegrationTraits >
191 class CachingPointList< GridPartImp, 1, IntegrationTraits >
192 : public ElementPointListBase< GridPartImp, 1, IntegrationTraits >,
193 public CachingInterface
194 {
197
198 public:
200 typedef GridPartImp GridPartType;
201
202 typedef typename Base::RealType RealType;
203 static const int dimension = Base::dimension;
204 static const int codimension = Base::codimension;
205
207 typedef typename Base::CoordinateType CoordinateType;
208
210 typedef typename Base::QuadratureKeyType QuadratureKeyType;
211
214 typedef typename IntersectionIteratorType::Intersection IntersectionType;
215
219
223
224
225 // for compatibility
227 typedef IntersectionIteratorType IntersectionIterator;
228
229 private:
230 static const int quadPointSetId =
232
233 public:
234 // Note: we also exclude GaussLegendre(0) here, because on faces it is not
235 // an interpolation rule
236 static const int pointSetId = (quadPointSetId > 0) ? quadPointSetId :
238
239 protected:
240 typedef typename CachingTraits< RealType, dimension >::MapperPairType MapperPairType;
241 typedef typename CachingTraits< RealType, dimension >::PointVectorType PointVectorType;
242
243 typedef CacheProvider< GridPartType, codimension > CacheProviderType;
244 typedef PointProvider< RealType, dimension, codimension> PointProviderType;
245
246 using Base::quadImp;
247
248 public:
249 using Base::localFaceIndex;
250 using Base::elementGeometry;
251 using Base::nop;
252
266 const IntersectionType &intersection,
267 const QuadratureKeyType& quadKey, const typename Base :: Side side )
268 : Base( getPointList( intersection, quadKey, side ) ),
269 side_(side),
270 twist_( getTwist( gridPart, intersection, side ) ),
271 mapper_( CacheProviderType::getMapper( quadImp(), elementGeometry(), localFaceIndex(), twist_) ),
272 points_( PointProviderType::getPoints( quadImp().ipList().id(), elementGeometry() ) ),
273 intersection_(intersection)
274 {
275 }
276
277 const QuadraturePointWrapperType operator[] ( const size_t i ) const
278 {
279 return QuadraturePointWrapperType( *this, i );
280 }
281
282 IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
283 IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
284
285 typename Base :: Side side() const { return side_; }
286 bool isInside() const { return side_ == Base::INSIDE; }
287
290 const CoordinateType &point ( const size_t i ) const
291 {
292 return points_[ cachingPoint( i ) ];
293 }
294
295 const IntersectionType &intersection() const
296 {
297 return intersection_;
298 }
299
301 static constexpr bool twisted() { return true; }
302
304 inline int twistId () const { return twist_ + 4; }
305
307 inline size_t cachingPoint( const size_t quadraturePoint ) const
308 {
309 assert( quadraturePoint < (size_t)nop() );
310 return mapper_.first[ quadraturePoint ];
311 }
312
314 inline size_t interpolationPoint( const size_t quadraturePoint ) const
315 {
316 assert( quadraturePoint < mapper_.second.size() );
317 return mapper_.second[ quadraturePoint ];
318 }
319
321 inline bool isInterpolationQuadrature( const size_t numShapeFunctions ) const
322 {
323 // if pointSetId is not negative then we have an interpolation
324 // quadrature if the number of point are equal to number of shape functions
325 return (pointSetId < 0) ? false :
326 quadImp().ipList().isFaceInterpolationQuadrature( numShapeFunctions );
327 }
328
329 // return local caching point
330 // for debugging issues only
331 size_t localCachingPoint ( const size_t i ) const
332 {
333 const auto& mapper = mapper_.first;
334
335 assert( i < (size_t)nop() );
336
337 assert( mapper[ i ] >= 0 );
338 int faceIndex = localFaceIndex();
339 unsigned int point = mapper[ i ] - faceIndex * mapper.size();
340 assert( point < nop() );
341
342 return point;
343 }
344
345 protected:
346 Base getPointList ( const IntersectionType &intersection,
347 const QuadratureKeyType& key,
348 const typename Base :: Side side )
349 {
350 switch( side )
351 {
352 case Base :: INSIDE:
353 return Base( TwistUtilityType::elementGeometry( intersection, true ),
354 intersection.indexInInside(), key );
355
356 case Base :: OUTSIDE:
357 return Base( TwistUtilityType::elementGeometry( intersection, false ),
358 intersection.indexInOutside(), key );
359
360 default:
361 DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
362 }
363 }
364
365 int getTwist ( const GridPartType &gridPart,
366 const IntersectionType &intersection,
367 const typename Base :: Side side )
368 {
369 switch( side )
370 {
371 case Base :: INSIDE:
372 return TwistUtilityType::twistInSelf( gridPart.grid(), intersection );
373
374 case Base :: OUTSIDE:
375 return TwistUtilityType::twistInNeighbor( gridPart.grid(), intersection );
376
377 default:
378 DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
379 }
380 }
381
382 private:
383 const typename Base :: Side side_;
384 const int twist_;
385 const MapperPairType &mapper_;
386 const PointVectorType &points_;
387 const IntersectionType &intersection_;
388 };
389
390 } //namespace Fem
391
392} //namespace Dune
393
394#endif // #ifndef DUNE_FEM_CACHINGPOINTLIST_HH
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: adaptiveleafgridpart.hh:92
interface a cachable quadrature has to implement
Definition: cachingpointlist.hh:23
size_t interpolationPoint(const size_t quadraturePoint) const
map quadrature points to interpolation points
Definition: cachingpointlist.hh:58
bool isInterpolationQuadrature(const size_t numShapeFunctions) const
check if quadrature is interpolation quadrature
Definition: cachingpointlist.hh:70
static constexpr bool twisted()
returns true if cachingPoint is not the identity mapping
Definition: cachingpointlist.hh:32
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:47
int twistId() const
returns the twistId, i.e. [0,...,7]
Definition: cachingpointlist.hh:35
constructor
Definition: cachingpointlist.hh:112
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:161
QuadraturePointWrapper< This > QuadraturePointWrapperType
the type of the quadrature point
Definition: cachingpointlist.hh:127
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:167
size_t interpolationPoint(const size_t quadraturePoint) const
map quadrature points to interpolation points
Definition: cachingpointlist.hh:173
bool isInterpolationQuadrature(const size_t numShapeFunctions) const
check if quadrature is interpolation quadrature
Definition: cachingpointlist.hh:179
Base::CoordinateType CoordinateType
The type of the coordinates in the codim-0 reference element.
Definition: cachingpointlist.hh:121
QuadraturePointIterator< This > IteratorType
type of iterator
Definition: cachingpointlist.hh:129
CachingPointList(const GeometryType &geometry, const QuadratureKeyType &quadKey)
constructor
Definition: cachingpointlist.hh:146
Base::QuadratureKeyType QuadratureKeyType
type of quadrature identifier on user side (default is the order of quadrature)
Definition: cachingpointlist.hh:124
constructor
Definition: cachingpointlist.hh:194
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:290
QuadraturePointIterator< This > IteratorType
type of iterator
Definition: cachingpointlist.hh:218
GridPartImp GridPartType
type of the grid partition
Definition: cachingpointlist.hh:200
Base::CoordinateType CoordinateType
Type of coordinates in codim-0 reference element.
Definition: cachingpointlist.hh:207
ElementIntegrationPointList< GridPartType, codimension, IntegrationTraits > NonConformingQuadratureType
type of quadrature used for non-conforming intersections
Definition: cachingpointlist.hh:222
Base::QuadratureKeyType QuadratureKeyType
type of quadrature identifier on user side (default is the order of quadrature)
Definition: cachingpointlist.hh:210
static constexpr bool twisted()
returns true if cachingPoint is not the identity mapping
Definition: cachingpointlist.hh:301
CachingPointList(const GridPartType &gridPart, const IntersectionType &intersection, const QuadratureKeyType &quadKey, const typename Base ::Side side)
constructor
Definition: cachingpointlist.hh:265
bool isInterpolationQuadrature(const size_t numShapeFunctions) const
check if quadrature is interpolation quadrature
Definition: cachingpointlist.hh:321
int twistId() const
returns the twistId, i.e. [0,...,7]
Definition: cachingpointlist.hh:304
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:307
size_t interpolationPoint(const size_t quadraturePoint) const
map quadrature points to interpolation points
Definition: cachingpointlist.hh:314
GridPartType::IntersectionIteratorType IntersectionIteratorType
Type of the intersection iterator.
Definition: cachingpointlist.hh:213
integration point list supporting base function caching
Definition: cachingpointlist.hh:103
integration point list on the codim-0 reference element
Definition: elementpointlist.hh:49
ElementPointListBase.
Definition: elementpointlistbase.hh:189
GridPartType::ctype RealType
coordinate type
Definition: elementpointlistbase.hh:203
iterator over quadrature points
Definition: quadrature.hh:103
wrapper for a (Quadrature,int) pair
Definition: quadrature.hh:42
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
Default exception for dummy implementations.
Definition: exceptions.hh:263
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:13
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition: twistutility.hh:107
selects Obj::pointSetId if available, otherwise defaultValue (default is -1)
Definition: utility.hh:174
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)