dune-fem  2.4.1-rc
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 
96 
97  protected:
98  using Base::quadImp;
99 
100  public:
101  using Base::localPoint;
102 
105  CachingPointList( const GeometryType &geometry, int order )
106  : Base( geometry, order )
107  {
109  }
110 
111  const QuadraturePointWrapperType operator[] ( const size_t i ) const
112  {
113  return QuadraturePointWrapperType( *this, i );
114  }
115 
117  const CoordinateType &point ( const size_t i ) const
118  {
119  return localPoint( i );
120  }
121 
123  inline size_t cachingPoint( const size_t quadraturePoint ) const
124  {
125  return quadraturePoint;
126  }
127  };
128 
129 
130 
132  template< typename GridPartImp, class IntegrationTraits >
133  class CachingPointList< GridPartImp, 1, IntegrationTraits >
134  : public ElementPointListBase< GridPartImp, 1, IntegrationTraits >,
135  public CachingInterface
136  {
139 
140  public:
142  typedef GridPartImp GridPartType;
143 
144  typedef typename Base::RealType RealType;
145  static const int dimension = Base::dimension;
146  static const int codimension = Base::codimension;
147 
150 
152  typedef typename GridPartType::IntersectionIteratorType IntersectionIteratorType;
153  typedef typename IntersectionIteratorType::Intersection IntersectionType;
154 
156 
160 
161 
162  // for compatibility
163  typedef typename GridPartType::TwistUtilityType TwistUtilityType;
164  typedef IntersectionIteratorType IntersectionIterator;
165 
166 
167  protected:
170 
173 
174  using Base::localFaceIndex;
175  using Base::quadImp;
176 
177  public:
178  using Base::elementGeometry;
179  using Base::nop;
180 
193  CachingPointList ( const GridPartType &gridPart,
194  const IntersectionType &intersection,
195  int order, const typename Base :: Side side )
196  : Base( getPointList( gridPart, intersection, order, side ) ),
197  mapper_( CacheProviderType::getMapper( quadImp(), elementGeometry(), localFaceIndex(), twist_ ) ),
198  points_( PointProviderType::getPoints( quadImp().ipList().id(), elementGeometry() ) )
199  {
200  }
201 
202  const QuadraturePointWrapperType operator[] ( const size_t i ) const
203  {
204  return QuadraturePointWrapperType( *this, i );
205  }
206 
209  const CoordinateType &point ( const size_t i ) const
210  {
211  return points_[ cachingPoint( i ) ];
212  }
213 
215  inline size_t cachingPoint( const size_t quadraturePoint ) const
216  {
217  assert( quadraturePoint < (size_t)nop() );
218  return mapper_[ quadraturePoint ];
219  }
220 
221  // return local caching point
222  // for debugging issues only
223  size_t localCachingPoint ( const size_t i ) const
224  {
225  assert( i < (size_t)nop() );
226 
227  assert( mapper_[ i ] >= 0 );
228  int faceIndex = localFaceIndex();
229  int point = mapper_[ i ] - faceIndex * mapper_.size();
230  assert( point < nop() );
231 
232  return point;
233  }
234 
235  protected:
236  Base getPointList ( const GridPartType &gridPart,
237  const IntersectionType &intersection,
238  const int order,
239  const typename Base :: Side side )
240  {
241  switch( side )
242  {
243  case Base :: INSIDE:
244  twist_ = TwistUtilityType::twistInSelf( gridPart.grid(), intersection );
245  return Base( TwistUtilityType::elementGeometry( intersection, true ),
246  intersection.indexInInside(), order );
247 
248  case Base :: OUTSIDE:
249  twist_ = TwistUtilityType::twistInNeighbor( gridPart.grid(), intersection );
250  return Base( TwistUtilityType::elementGeometry( intersection, false ),
251  intersection.indexInOutside(), order );
252 
253  default:
254  DUNE_THROW( InvalidStateException, "ElementIntegrationPointList: side must either be INSIDE or OUTSIDE." );
255  }
256  }
257 
258  private:
259  int twist_;
260  const MapperType &mapper_;
261  const PointVectorType &points_;
262  };
263 
264  } //namespace Fem
265 
266 } //namespace Dune
267 
268 #endif // #ifndef DUNE_FEM_CACHINGPOINTLIST_HH
CachingTraits< RealType, dimension >::PointVectorType PointVectorType
Definition: cachingpointlist.hh:169
Base getPointList(const GridPartType &gridPart, const IntersectionType &intersection, const int order, const typename Base::Side side)
Definition: cachingpointlist.hh:236
std::vector< size_t > MapperType
Definition: pointmapper.hh:58
Side
inside and outside flags
Definition: elementpointlistbase.hh:163
integration point list supporting base function caching
Definition: cachingpointlist.hh:74
CachingPointList(const GeometryType &geometry, int order)
constructor
Definition: cachingpointlist.hh:105
GridPartType::IntersectionIteratorType IntersectionIteratorType
Type of the intersection iterator.
Definition: cachingpointlist.hh:152
GridPartType::TwistUtilityType TwistUtilityType
Definition: cachingpointlist.hh:163
GridPartImp GridPartType
type of the grid partition
Definition: cachingpointlist.hh:142
wrapper for a (Quadrature,int) pair
Definition: quadrature.hh:40
ElementPointListBase.
Definition: elementpointlistbase.hh:16
CacheProvider< GridPartType, codimension > CacheProviderType
Definition: cachingpointlist.hh:171
ElementIntegrationPointList< GridPartType, codimension, IntegrationTraits > NonConformingQuadratureType
type of quadrature used for non-conforming intersections
Definition: cachingpointlist.hh:159
QuadraturePointWrapper< This > QuadraturePointWrapperType
Definition: cachingpointlist.hh:155
GridPartImp GridPartType
type of the grid partition
Definition: elementpointlistbase.hh:26
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:41
QuadraturePointWrapper< This > QuadraturePointWrapperType
the type of the quadrature point
Definition: cachingpointlist.hh:95
IntegrationTraits::CoordinateType CoordinateType
Definition: elementpointlistbase.hh:177
Definition: coordinate.hh:4
constructor
Definition: cachingpointlist.hh:133
CachingTraits< RealType, dimension >::MapperType MapperType
Definition: cachingpointlist.hh:168
Base::CoordinateType CoordinateType
Type of coordinates in codim-0 reference element.
Definition: cachingpointlist.hh:149
Definition: cacheprovider.hh:136
integration point list on the codim-0 reference element
Definition: elementpointlist.hh:49
Base::CoordinateType CoordinateType
The type of the coordinates in the codim-0 reference element.
Definition: cachingpointlist.hh:92
GridPartType::ctype RealType
coordinate type
Definition: elementpointlistbase.hh:169
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:123
IntersectionIteratorType IntersectionIterator
Definition: cachingpointlist.hh:164
PointProvider< RealType, dimension, codimension > PointProviderType
Definition: cachingpointlist.hh:172
interface a cachable quadrature has to implement
Definition: cachingpointlist.hh:22
CachingInterface()
Definition: cachingpointlist.hh:26
IntersectionIteratorType::Intersection IntersectionType
Definition: cachingpointlist.hh:153
std::vector< PointType > PointVectorType
Definition: pointmapper.hh:57
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:117
Definition: pointprovider.hh:21
size_t localCachingPoint(const size_t i) const
Definition: cachingpointlist.hh:223
size_t cachingPoint(const size_t quadraturePoint) const
map quadrature points to caching points
Definition: cachingpointlist.hh:215
const CoordinateType & point(const size_t i) const
obtain coordinates of i-th integration point
Definition: cachingpointlist.hh:209
CachingPointList(const GridPartType &gridPart, const IntersectionType &intersection, int order, const typename Base::Side side)
constructor
Definition: cachingpointlist.hh:193
constructor
Definition: cachingpointlist.hh:80
Base::GridPartType GridPartType
Definition: cachingpointlist.hh:88
IntegrationTraits::CoordinateType CoordinateType
Definition: elementpointlistbase.hh:43
Base::RealType RealType
Definition: cachingpointlist.hh:144