dune-fem  2.4.1-rc
shapefunctionsets.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_SHAPEFUNCTIONSETS_HH
2 #define DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_SHAPEFUNCTIONSETS_HH
3 
4 #include <algorithm>
5 #include <utility>
6 #include <vector>
7 
8 #include <dune/common/documentation.hh>
9 
10 #include <dune/geometry/type.hh>
11 
18 
19 namespace Dune
20 {
21 
22  namespace Fem
23  {
24 
25  // ShapeFunctionSets
26  // -----------------
27 
33  {
34  public:
36  typedef ImplementationDefined ShapeFunctionSetType;
37 
44 
52  ShapeFunctionSets ( const ShapeFunctionSets & ) = delete;
53 
55  ShapeFunctionSets &operator= ( const ShapeFunctionSets & ) = delete;
56 
63  const std::vector< Dune::GeometryType > &types () const;
64 
66  int order () const;
67 
69  int order ( Dune::GeometryType type ) const;
70 
77  ShapeFunctionSetType shapeFunctionSet ( const Dune::GeometryType &type ) const;
78 
80  };
81 
82 
83 
84  // CachedShapeFunctionSets
85  // -----------------------
86 
87  template< class GridPart, class ShapeFunctionSet,
90  {
92 
93  public:
95  typedef GridPart GridPartType;
98 
99  private:
100  static const int dimension = GridPartType::dimension;
101  static const int mydimension = ShapeFunctionSet::FunctionSpaceType::dimDomain;
102  static const int codimension = dimension - mydimension;
103 
106 
107  public:
112  explicit CachedShapeFunctionSets ( const GridPartType &gridPart )
113  : types_( types( gridPart ) )
114  {
115  typedef typename std::vector< Dune::GeometryType >::const_iterator const_iterator;
116  const const_iterator end = types_.end();
117  for( const_iterator it = types_.begin(); it != end; ++it )
118  {
119  const Dune::GeometryType type = *it;
120  shapeFunctionSets_.template insert< SingletonProviderType >( type );
121  }
122  }
123 
130  CachedShapeFunctionSets ( const ThisType & ) = delete;
131 
132  CachedShapeFunctionSets ( ThisType &&other )
133  : types_( std::move( other.types_ ) ),
134  shapeFunctionSets_( std::move( other.shapeFunctionSets_ ) )
135  {}
136 
137  CachedShapeFunctionSets &operator= ( const ThisType & ) = delete;
138 
146  const std::vector< Dune::GeometryType > &types () const { return types_; }
147 
149  int order () const
150  {
151  int order = 0;
152 
153  typedef typename std::vector< Dune::GeometryType >::const_iterator const_iterator;
154  const const_iterator end = types_.end();
155  for( const_iterator it = types_.begin(); it != end; ++it )
156  {
157  const Dune::GeometryType type = *it;
158  order = std::max( this->order( type ), order );
159  }
160 
161  return order;
162  }
163 
165  int order ( Dune::GeometryType type ) const
166  {
167  return shapeFunctionSet( type ).order();
168  }
169 
171  ShapeFunctionSetType shapeFunctionSet ( const Dune::GeometryType &type ) const
172  {
173  return ShapeFunctionSetType( &shapeFunctionSets_[ type ] );
174  }
175 
178  private:
179  static std::vector< Dune::GeometryType > types ( const GridPartType &gridPart )
180  {
181  typedef typename GridPartType::GridType GridType;
182  typedef typename GridPartType::IndexSetType IndexSetType;
183  return Dune::Fem::AllGeomTypes< IndexSetType, GridType >( gridPart.indexSet() ).geomTypes( codimension );
184  }
185 
186  std::vector< Dune::GeometryType > types_;
187  ShapeFunctionSetStorageType shapeFunctionSets_;
188  };
189 
190 
191 
192  // SelectCachingShapeFunctionSets
193  // ------------------------------
194 
195  template< class GridPart, class ShapeFunctionSet, template< class > class Storage >
197  {
199 
201 
202  struct Factory
203  {
204  static CachedShapeFunctionSetType *createObject ( const Dune::GeometryType &type )
205  {
206  typedef typename CachedShapeFunctionSetType::ImplementationType ImplementationType;
207  return new CachedShapeFunctionSetType( type, ImplementationType( type ) );
208  }
209 
210  static void deleteObject ( CachedShapeFunctionSetType *object ) { delete object; }
211  };
212 
214 
215  public:
218 
223  explicit SelectCachingShapeFunctionSets ( const GridPart &gridPart )
224  : impl_( gridPart )
225  {}
226 
233  SelectCachingShapeFunctionSets ( const ThisType & ) = delete;
234 
235  SelectCachingShapeFunctionSets ( ThisType &&other )
236  : impl_( std::move( other.impl_ ) )
237  {}
238 
239  SelectCachingShapeFunctionSets &operator= ( const ThisType & ) = delete;
240 
244  const std::vector< Dune::GeometryType > &types () const { return impl_.types(); }
245 
247  int order () const { return impl_.order(); }
248 
250  int order ( Dune::GeometryType type ) const { return impl_.order( type ); }
251 
253  ShapeFunctionSetType shapeFunctionSet ( const Dune::GeometryType &type ) const
254  {
255  return impl_.shapeFunctionSet( type );
256  }
257 
258  private:
259  Implementation impl_;
260  };
261 
262 
263 
264  // VectorialShapeFunctionSets
265  // --------------------------
266 
267  template< class Implementation, class Range >
269  {
271 
272  public:
275 
280  explicit VectorialShapeFunctionSets ( Implementation &&impl )
281  : impl_( impl )
282  {}
283 
284  template< class... Args >
285  explicit VectorialShapeFunctionSets ( Args &&...args )
286  : impl_( std::forward< Args >( args )... )
287  {}
288 
295  VectorialShapeFunctionSets ( const ThisType & ) = delete;
296 
297  VectorialShapeFunctionSets ( ThisType & ) = delete;
298 
299  VectorialShapeFunctionSets ( ThisType &&other )
300  : impl_( std::move( other.impl_ ) )
301  {}
302 
303  VectorialShapeFunctionSets &operator= ( const ThisType & ) = delete;
304 
312  const std::vector< Dune::GeometryType > &types () const { return impl().types(); }
313 
315  int order () const { return impl().order(); }
316 
318  int order ( Dune::GeometryType type ) const { return impl().order( type ); }
319 
321  ShapeFunctionSetType shapeFunctionSet ( const Dune::GeometryType &type ) const
322  {
323  return ShapeFunctionSetType( impl().shapeFunctionSet( type ) );
324  }
325 
328  private:
329  const Implementation &impl () const { return impl_; }
330 
331  Implementation impl_;
332  };
333 
334  } // namespace Fem
335 
336 } // namespace Dune
337 
338 #endif // #ifndef DUNE_FEM_SPACE_DISCONTINUOUSGALERKIN_SHAPEFUNCTIONSETS_HH
Definition: shapefunctionsets.hh:268
Definition: selectcaching.hh:28
int order(Dune::GeometryType type) const
return maximum order
Definition: shapefunctionsets.hh:165
int order(Dune::GeometryType type) const
return maximum order
Definition: shapefunctionsets.hh:250
ShapeFunctionSetType shapeFunctionSet(const Dune::GeometryType &type) const
return shape function set
Definition: shapefunctionsets.hh:253
static constexpr T max(T a)
Definition: utility.hh:65
Definition: shapefunctionset/vectorial.hh:428
Singleton list for key/object pairs.
Definition: singletonlist.hh:49
interface class representing a family of shape function sets
Definition: shapefunctionsets.hh:32
VectorialShapeFunctionSet< typename Implementation::ShapeFunctionSetType, Range > ShapeFunctionSetType
shape function set type
Definition: shapefunctionsets.hh:274
Definition: shapefunctionset/shapefunctionset.hh:33
int order() const
return maximum order
Definition: shapefunctionsets.hh:247
dimension of domain vector space
Definition: functionspaceinterface.hh:45
Implementation::ShapeFunctionSetType ShapeFunctionSetType
shape function set type
Definition: shapefunctionsets.hh:217
CachedShapeFunctionSets(const GridPartType &gridPart)
Definition: shapefunctionsets.hh:112
const std::vector< Dune::GeometryType > & types() const
return vector of geometry types
Definition: shapefunctionsets.hh:312
int order(Dune::GeometryType type) const
return maximum order
Definition: shapefunctionsets.hh:318
ShapeFunctionSetType shapeFunctionSet(const Dune::GeometryType &type) const
return shape function set
Definition: shapefunctionsets.hh:321
GridPart GridPartType
grid part type
Definition: shapefunctionsets.hh:95
ShapeFunctionSetType shapeFunctionSet(const Dune::GeometryType &type) const
return shape function set
Definition: shapefunctionset/proxy.hh:35
Definition: coordinate.hh:4
const std::vector< Dune::GeometryType > & types() const
return vector of geometry types
Definition: shapefunctionsets.hh:244
const std::vector< Dune::GeometryType > & types() const
return vector of geometry types
SelectCachingShapeFunctionSets(ThisType &&other)
Definition: shapefunctionsets.hh:235
SelectCachingShapeFunctionSets(const GridPart &gridPart)
Definition: shapefunctionsets.hh:223
STL namespace.
int order() const
return maximum order
Definition: shapefunctionsets.hh:149
Provides a proxy class for pointers to a shape function set.
default implementation uses method geomTypes of given index set. Used in DiscreteFunctionSpaces.
Definition: allgeomtypes.hh:89
const std::vector< Dune::GeometryType > & types() const
return vector of geometry types
Definition: shapefunctionsets.hh:146
VectorialShapeFunctionSets(Implementation &&impl)
Definition: shapefunctionsets.hh:280
int order() const
return maximum order
ShapeFunctionSetType shapeFunctionSet(const Dune::GeometryType &type) const
return shape function set
Definition: shapefunctionsets.hh:171
void move(ArrayInterface< T > &array, const unsigned int oldOffset, const unsigned int newOffset, const unsigned int length)
Definition: array_inline.hh:38
ShapeFunctionSets & operator=(const ShapeFunctionSets &)=delete
assignment operator
Dune::Fem::ShapeFunctionSetProxy< ShapeFunctionSet > ShapeFunctionSetType
shape function set type
Definition: shapefunctionsets.hh:97
ImplementationDefined ShapeFunctionSetType
shape function set type
Definition: shapefunctionsets.hh:36
int order() const
return maximum order
Definition: shapefunctionsets.hh:315
ShapeFunctionSets(ShapeFunctionSets &&)
move constructor
CachedShapeFunctionSets(ThisType &&other)
Definition: shapefunctionsets.hh:132
Definition: shapefunctionsets.hh:89
Definition: shapefunctionsets.hh:196
VectorialShapeFunctionSets(ThisType &&other)
Definition: shapefunctionsets.hh:299
VectorialShapeFunctionSets(Args &&...args)
Definition: shapefunctionsets.hh:285
Definition: singletonlist.hh:21