dune-fem  2.6-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:
41  inline size_t cachingPoint( const size_t quadraturePoint ) const
42  {
43  DUNE_THROW( NotImplemented,
44  "CachingInterface :: cachingPoint must be overloaded!" );
45  }
46  };
47 
48 
49 
73  template< class GridPartImp, int codim, class IntegrationTraits >
75 
76 
77 
79  template< class GridPartImp, class IntegrationTraits >
80  class CachingPointList< GridPartImp, 0, IntegrationTraits >
81  : public ElementPointListBase< GridPartImp, 0, IntegrationTraits >,
82  public CachingInterface
83  {
86 
87  public:
88  typedef typename Base::GridPartType GridPartType;
89  static const int codimension = Base::codimension;
90 
93 
98 
99  protected:
100  using Base::quadImp;
101 
102  public:
103  using Base::localPoint;
104  using Base::nop;
105 
108  CachingPointList( const GeometryType &geometry, int order )
109  : Base( geometry, order )
110  {
112  }
113 
114  const QuadraturePointWrapperType operator[] ( const size_t i ) const
115  {
116  return QuadraturePointWrapperType( *this, i );
117  }
118 
119  IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
120  IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
121 
123  const CoordinateType &point ( const size_t i ) const
124  {
125  return localPoint( i );
126  }
127 
129  inline size_t cachingPoint( const size_t quadraturePoint ) const
130  {
131  return quadraturePoint;
132  }
133  };
134 
135 
136 
138  template< typename GridPartImp, class IntegrationTraits >
139  class CachingPointList< GridPartImp, 1, IntegrationTraits >
140  : public ElementPointListBase< GridPartImp, 1, IntegrationTraits >,
141  public CachingInterface
142  {
145 
146  public:
148  typedef GridPartImp GridPartType;
149 
150  typedef typename Base::RealType RealType;
151  static const int dimension = Base::dimension;
152  static const int codimension = Base::codimension;
153 
156 
158  typedef typename GridPartType::IntersectionIteratorType IntersectionIteratorType;
159  typedef typename IntersectionIteratorType::Intersection IntersectionType;
160 
164 
168 
169 
170  // for compatibility
171  typedef typename GridPartType::TwistUtilityType TwistUtilityType;
173 
174 
175  protected:
178 
181 
182  using Base::localFaceIndex;
183  using Base::quadImp;
184 
185  public:
186  using Base::elementGeometry;
187  using Base::nop;
188 
201  CachingPointList ( const GridPartType &gridPart,
202  const IntersectionType &intersection,
203  int order, const typename Base :: Side side )
204  : Base( getPointList( intersection, order, side ) ),
205  mapper_( CacheProviderType::getMapper( quadImp(), elementGeometry(), localFaceIndex(), getTwist( gridPart, intersection, side ) ) ),
206  points_( PointProviderType::getPoints( quadImp().ipList().id(), elementGeometry() ) )
207  {
208  }
209 
210  const QuadraturePointWrapperType operator[] ( const size_t i ) const
211  {
212  return QuadraturePointWrapperType( *this, i );
213  }
214 
215  IteratorType begin () const noexcept { return IteratorType( *this, 0 ); }
216  IteratorType end () const noexcept { return IteratorType( *this, nop() ); }
217 
220  const CoordinateType &point ( const size_t i ) const
221  {
222  return points_[ cachingPoint( i ) ];
223  }
224 
226  inline size_t cachingPoint( const size_t quadraturePoint ) const
227  {
228  assert( quadraturePoint < (size_t)nop() );
229  return mapper_[ quadraturePoint ];
230  }
231 
232  // return local caching point
233  // for debugging issues only
234  size_t localCachingPoint ( const size_t i ) const
235  {
236  assert( i < (size_t)nop() );
237 
238  assert( mapper_[ i ] >= 0 );
239  int faceIndex = localFaceIndex();
240  int point = mapper_[ i ] - faceIndex * mapper_.size();
241  assert( point < nop() );
242 
243  return point;
244  }
245 
246  protected:
247  Base getPointList ( const IntersectionType &intersection,
248  const int order,
249  const typename Base :: Side side )
250  {
251  switch( side )
252  {
253  case Base :: INSIDE:
254  return Base( TwistUtilityType::elementGeometry( intersection, true ),
255  intersection.indexInInside(), order );
256 
257  case Base :: OUTSIDE:
258  return Base( TwistUtilityType::elementGeometry( intersection, false ),
259  intersection.indexInOutside(), order );
260 
261  default:
262  DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
263  }
264  }
265 
266  int getTwist ( const GridPartType &gridPart,
267  const IntersectionType &intersection,
268  const typename Base :: Side side )
269  {
270  switch( side )
271  {
272  case Base :: INSIDE:
273  return TwistUtilityType::twistInSelf( gridPart.grid(), intersection );
274 
275  case Base :: OUTSIDE:
276  return TwistUtilityType::twistInNeighbor( gridPart.grid(), intersection );
277 
278  default:
279  DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
280  }
281  }
282 
283  private:
284  const MapperType &mapper_;
285  const PointVectorType &points_;
286  };
287 
288  } //namespace Fem
289 
290 } //namespace Dune
291 
292 #endif // #ifndef DUNE_FEM_CACHINGPOINTLIST_HH
Definition: bindguard.hh:11
Definition: cacheprovider.hh:136
std::vector< size_t > MapperType
Definition: pointmapper.hh:58
std::vector< PointType > PointVectorType
Definition: pointmapper.hh:57
Definition: pointprovider.hh:23
interface a cachable quadrature has to implement
Definition: cachingpointlist.hh:23
CachingInterface()
Definition: cachingpointlist.hh:26
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:41
integration point list supporting base function caching
Definition: cachingpointlist.hh:74
constructor
Definition: cachingpointlist.hh:83
QuadraturePointWrapper< This > QuadraturePointWrapperType
the type of the quadrature point
Definition: cachingpointlist.hh:95
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:129
Base::GridPartType GridPartType
Definition: cachingpointlist.hh:88
CachingPointList(const GeometryType &geometry, int order)
constructor
Definition: cachingpointlist.hh:108
Base::CoordinateType CoordinateType
The type of the coordinates in the codim-0 reference element.
Definition: cachingpointlist.hh:92
IteratorType end() const noexcept
Definition: cachingpointlist.hh:120
IteratorType begin() const noexcept
Definition: cachingpointlist.hh:119
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:123
QuadraturePointIterator< This > IteratorType
type of iterator
Definition: cachingpointlist.hh:97
constructor
Definition: cachingpointlist.hh:142
Base getPointList(const IntersectionType &intersection, const int order, const typename Base ::Side side)
Definition: cachingpointlist.hh:247
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:220
IteratorType begin() const noexcept
Definition: cachingpointlist.hh:215
PointProvider< RealType, dimension, codimension > PointProviderType
Definition: cachingpointlist.hh:180
QuadraturePointIterator< This > IteratorType
type of iterator
Definition: cachingpointlist.hh:163
GridPartImp GridPartType
type of the grid partition
Definition: cachingpointlist.hh:148
Base::CoordinateType CoordinateType
Type of coordinates in codim-0 reference element.
Definition: cachingpointlist.hh:155
IteratorType end() const noexcept
Definition: cachingpointlist.hh:216
Base::RealType RealType
Definition: cachingpointlist.hh:150
ElementIntegrationPointList< GridPartType, codimension, IntegrationTraits > NonConformingQuadratureType
type of quadrature used for non-conforming intersections
Definition: cachingpointlist.hh:167
IntersectionIteratorType IntersectionIterator
Definition: cachingpointlist.hh:172
QuadraturePointWrapper< This > QuadraturePointWrapperType
Definition: cachingpointlist.hh:161
CacheProvider< GridPartType, codimension > CacheProviderType
Definition: cachingpointlist.hh:179
IntersectionIteratorType::Intersection IntersectionType
Definition: cachingpointlist.hh:159
CachingPointList(const GridPartType &gridPart, const IntersectionType &intersection, int order, const typename Base ::Side side)
constructor
Definition: cachingpointlist.hh:201
int getTwist(const GridPartType &gridPart, const IntersectionType &intersection, const typename Base ::Side side)
Definition: cachingpointlist.hh:266
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:226
CachingTraits< RealType, dimension >::MapperType MapperType
Definition: cachingpointlist.hh:176
CachingTraits< RealType, dimension >::PointVectorType PointVectorType
Definition: cachingpointlist.hh:177
size_t localCachingPoint(const size_t i) const
Definition: cachingpointlist.hh:234
GridPartType::IntersectionIteratorType IntersectionIteratorType
Type of the intersection iterator.
Definition: cachingpointlist.hh:158
GridPartType::TwistUtilityType TwistUtilityType
Definition: cachingpointlist.hh:171
integration point list on the codim-0 reference element
Definition: elementpointlist.hh:49
ElementPointListBase.
Definition: elementpointlistbase.hh:155
IntegrationTraits::CoordinateType CoordinateType
Definition: elementpointlistbase.hh:177
GridPartType::ctype RealType
coordinate type
Definition: elementpointlistbase.hh:169
GridPartImp GridPartType
type of the grid partition
Definition: elementpointlistbase.hh:26
IntegrationTraits::CoordinateType CoordinateType
Definition: elementpointlistbase.hh:43
wrapper for a (Quadrature,int) pair
Definition: quadrature/quadrature.hh:41
iterator over quadrature points
Definition: quadrature/quadrature.hh:108