dune-fem  2.8-git
cachingpointlist.hh
Go to the documentation of this file.
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
12 
13 namespace 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  inline bool twisted () const { return false; }
33 
35  inline int twistId () const { return 0; }
36 
47  inline size_t cachingPoint( const size_t quadraturePoint ) const
48  {
49  DUNE_THROW( NotImplemented,
50  "CachingInterface :: cachingPoint must be overloaded!" );
51  }
52 
58  inline size_t interpolationPoint( const size_t quadraturePoint ) const
59  {
60  DUNE_THROW( NotImplemented,
61  "CachingInterface :: interpolationPoint must be overloaded!" );
62  }
63 
70  inline bool isInterpolationQuadrature( const size_t numShapeFunctions ) const
71  {
72  DUNE_THROW( NotImplemented,
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:
118  static const int codimension = Base::codimension;
119 
122 
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  {
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 
208 
211 
213  typedef typename GridPartType::IntersectionIteratorType IntersectionIteratorType;
214  typedef typename IntersectionIteratorType::Intersection IntersectionType;
215 
219 
223 
224 
225  // for compatibility
226  typedef typename GridPartType::TwistUtilityType TwistUtilityType;
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:
242 
245 
246  using Base::quadImp;
247 
248  public:
249  using Base::localFaceIndex;
250  using Base::elementGeometry;
251  using Base::nop;
252 
265  CachingPointList ( const GridPartType &gridPart,
266  const IntersectionType &intersection,
267  const QuadratureKeyType& quadKey, const typename Base :: Side side )
268  : Base( getPointList( intersection, quadKey, side ) ),
269  twist_( getTwist( gridPart, intersection, side ) ),
270  mapper_( CacheProviderType::getMapper( quadImp(), elementGeometry(), localFaceIndex(), twist_) ),
271  points_( PointProviderType::getPoints( quadImp().ipList().id(), elementGeometry() ) )
272  {
273  }
274 
275  const QuadraturePointWrapperType operator[] ( const size_t i ) const
276  {
277  return QuadraturePointWrapperType( *this, i );
278  }
279 
280  IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
281  IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
282 
285  const CoordinateType &point ( const size_t i ) const
286  {
287  return points_[ cachingPoint( i ) ];
288  }
289 
291  inline bool twisted() const { return true; }
292 
294  inline int twistId () const { return twist_ + 4; }
295 
297  inline size_t cachingPoint( const size_t quadraturePoint ) const
298  {
299  assert( quadraturePoint < (size_t)nop() );
300  return mapper_.first[ quadraturePoint ];
301  }
302 
304  inline size_t interpolationPoint( const size_t quadraturePoint ) const
305  {
306  assert( quadraturePoint < mapper_.second.size() );
307  return mapper_.second[ quadraturePoint ];
308  }
309 
311  inline bool isInterpolationQuadrature( const size_t numShapeFunctions ) const
312  {
313  // if pointSetId is not negative then we have an interpolation
314  // quadrature if the number of point are equal to number of shape functions
315  return (pointSetId < 0) ? false :
316  quadImp().ipList().isFaceInterpolationQuadrature( numShapeFunctions );
317  }
318 
319  // return local caching point
320  // for debugging issues only
321  size_t localCachingPoint ( const size_t i ) const
322  {
323  const auto& mapper = mapper_.first;
324 
325  assert( i < (size_t)nop() );
326 
327  assert( mapper[ i ] >= 0 );
328  int faceIndex = localFaceIndex();
329  unsigned int point = mapper[ i ] - faceIndex * mapper.size();
330  assert( point < nop() );
331 
332  return point;
333  }
334 
335  protected:
336  Base getPointList ( const IntersectionType &intersection,
337  const QuadratureKeyType& key,
338  const typename Base :: Side side )
339  {
340  switch( side )
341  {
342  case Base :: INSIDE:
343  return Base( TwistUtilityType::elementGeometry( intersection, true ),
344  intersection.indexInInside(), key );
345 
346  case Base :: OUTSIDE:
347  return Base( TwistUtilityType::elementGeometry( intersection, false ),
348  intersection.indexInOutside(), key );
349 
350  default:
351  DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
352  }
353  }
354 
355  int getTwist ( const GridPartType &gridPart,
356  const IntersectionType &intersection,
357  const typename Base :: Side side )
358  {
359  switch( side )
360  {
361  case Base :: INSIDE:
362  return TwistUtilityType::twistInSelf( gridPart.grid(), intersection );
363 
364  case Base :: OUTSIDE:
365  return TwistUtilityType::twistInNeighbor( gridPart.grid(), intersection );
366 
367  default:
368  DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
369  }
370  }
371 
372  private:
373  const int twist_;
374  const MapperPairType &mapper_;
375  const PointVectorType &points_;
376  };
377 
378  } //namespace Fem
379 
380 } //namespace Dune
381 
382 #endif // #ifndef DUNE_FEM_CACHINGPOINTLIST_HH
Definition: bindguard.hh:11
detail::SelectPointSetId< Quadrature, -Dune::QuadratureType::size > SelectQuadraturePointSetId
Definition: quadrature.hh:541
Definition: cacheprovider.hh:157
std::pair< MapperType, MapperType > MapperPairType
Definition: pointmapper.hh:59
std::vector< PointType > PointVectorType
Definition: pointmapper.hh:57
Definition: pointprovider.hh:24
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
CachingInterface()
Definition: cachingpointlist.hh:26
bool isInterpolationQuadrature(const size_t numShapeFunctions) const
check if quadrature is interpolation quadrature
Definition: cachingpointlist.hh:70
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
bool twisted() const
returns true if cachingPoint is not the identity mapping
Definition: cachingpointlist.hh:32
integration point list supporting base function caching
Definition: cachingpointlist.hh:103
constructor
Definition: cachingpointlist.hh:112
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
Base::GridPartType GridPartType
Definition: cachingpointlist.hh:117
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
IteratorType end() const noexcept
Definition: cachingpointlist.hh:158
IteratorType begin() const noexcept
Definition: cachingpointlist.hh:157
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:161
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:285
IteratorType begin() const noexcept
Definition: cachingpointlist.hh:280
PointProvider< RealType, dimension, codimension > PointProviderType
Definition: cachingpointlist.hh:244
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
IteratorType end() const noexcept
Definition: cachingpointlist.hh:281
Base getPointList(const IntersectionType &intersection, const QuadratureKeyType &key, const typename Base ::Side side)
Definition: cachingpointlist.hh:336
Base::RealType RealType
Definition: cachingpointlist.hh:202
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
IntersectionIteratorType IntersectionIterator
Definition: cachingpointlist.hh:227
QuadraturePointWrapper< This > QuadraturePointWrapperType
Definition: cachingpointlist.hh:216
CachingTraits< RealType, dimension >::MapperPairType MapperPairType
Definition: cachingpointlist.hh:240
CacheProvider< GridPartType, codimension > CacheProviderType
Definition: cachingpointlist.hh:243
IntersectionIteratorType::Intersection IntersectionType
Definition: cachingpointlist.hh:214
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:311
int getTwist(const GridPartType &gridPart, const IntersectionType &intersection, const typename Base ::Side side)
Definition: cachingpointlist.hh:355
int twistId() const
returns the twistId, i.e. [0,...,7]
Definition: cachingpointlist.hh:294
bool twisted() const
returns true if cachingPoint is not the identity mapping
Definition: cachingpointlist.hh:291
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:297
CachingTraits< RealType, dimension >::PointVectorType PointVectorType
Definition: cachingpointlist.hh:241
size_t localCachingPoint(const size_t i) const
Definition: cachingpointlist.hh:321
size_t interpolationPoint(const size_t quadraturePoint) const
map quadrature points to interpolation points
Definition: cachingpointlist.hh:304
GridPartType::IntersectionIteratorType IntersectionIteratorType
Type of the intersection iterator.
Definition: cachingpointlist.hh:213
GridPartType::TwistUtilityType TwistUtilityType
Definition: cachingpointlist.hh:226
integration point list on the codim-0 reference element
Definition: elementpointlist.hh:49
ElementPointListBase.
Definition: elementpointlistbase.hh:189
IntegrationTraits::CoordinateType CoordinateType
Definition: elementpointlistbase.hh:211
IntegrationPointListType ::QuadratureKeyType QuadratureKeyType
Definition: elementpointlistbase.hh:214
GridPartType::ctype RealType
coordinate type
Definition: elementpointlistbase.hh:203
IntegrationPointListType ::QuadratureKeyType QuadratureKeyType
Definition: elementpointlistbase.hh:48
GridPartImp GridPartType
type of the grid partition
Definition: elementpointlistbase.hh:28
IntegrationTraits::CoordinateType CoordinateType
Definition: elementpointlistbase.hh:45
wrapper for a (Quadrature,int) pair
Definition: quadrature.hh:43
iterator over quadrature points
Definition: quadrature.hh:106