dune-fem  2.8-git
dgspace.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_LOCALFINITEELEMENT_DGSPACE_HH
2 #define DUNE_FEM_SPACE_LOCALFINITEELEMENT_DGSPACE_HH
3 
4 #include <cassert>
5 
6 #include <memory>
7 #include <utility>
8 #include <vector>
9 
10 #include <dune/geometry/type.hh>
11 
24 
28 
29 namespace Dune
30 {
31 
32  namespace Fem
33  {
34 
35  // DiscontinuousLocalFiniteElementSpaceTraits
36  // ------------------------------------------
37  template< class LFEMap, class FunctionSpace, class Storage,
38  unsigned int scalarBlockSize >
40  {
42 
43  typedef LFEMap LFEMapType;
44 
45  typedef typename LFEMapType::GridPartType GridPartType;
46  typedef typename LFEMapType::LocalFiniteElementType LocalFiniteElementType;
47 
49 
50  static constexpr int codimension = 0;
51  static constexpr bool isScalar = LocalFiniteElementType::Traits::LocalBasisType::Traits::dimRange==1;
52  static constexpr bool fullBlocking = isScalar && scalarBlockSize>1;
53 
54  typedef std::conditional_t<isScalar,
58 
59  private:
60  typedef typename GridPartType::template Codim< codimension >::EntityType EntityType;
61 
62  public:
63  using BlockMapperType = std::conditional_t<!fullBlocking,
66 
67  // TODO: need SFINAE since not all LFEMap have a pointSetId
70 
72  // only extend to vector valued in case that the original space is scalar
73  typedef std::conditional_t<isScalar,
77 
78  private:
79  template< class LFEM >
81 
83 
84  public:
85  typedef decltype( basisFunctionSet( std::declval< const LFEMapType & >() ) ) BasisFunctionSetType;
86 
87  template< class DiscreteFunction, class Operation = DFCommunicationOperation::Copy >
89  {
91  typedef Operation OperationType;
92  };
93  };
94 
95 
96 
97  // DiscontinuousLocalFiniteElementSpace
98  // ------------------------------------
99 
109  template <class LFEMap,class Enabler>
111  {
112  static const unsigned int scalarBlockSize = 1;
113  };
114  template <class LFEMap>
115  struct FixedPolyOrder_<LFEMap,
116  std::enable_if_t<LFEMap::numBasisFunctions>=0, std::true_type> >
117  {
118  static const unsigned int scalarBlockSize = LFEMap::numBasisFunctions;
119  static const unsigned int polynomialOrder = LFEMap::polynomialOrder;
120  };
121  template <class LFEMap>
123 
124  template< class LFEMap, class FunctionSpace, class Storage >
127  DiscontinuousLocalFiniteElementSpaceTraits< LFEMap,
128  FunctionSpace, Storage, FixedPolyOrder<LFEMap>::scalarBlockSize > >,
129  public FixedPolyOrder<LFEMap>
130  {
135 
136  typedef typename BaseType::Traits Traits;
137 
138  public:
140 
144 
147 
149 
151  // typedef L2LocalFiniteElement< typename Traits::LocalFiniteElementType > LocalFiniteElementType;
152 
153  typedef typename Traits::LFEMapType LFEMapType;
154 
155  typedef typename LFEMapType::KeyType KeyType;
156 
157  private:
158  typedef typename LocalFiniteElementType::Traits::LocalBasisType LocalBasisType;
159  typedef typename LocalFiniteElementType::Traits::LocalInterpolationType LocalInterpolationType;
160  typedef typename LocalFiniteElementType::Traits::LocalCoefficientsType LocalCoefficientsType;
161 
163 
164  struct LFEMapFactory
165  {
166  static LFEMapType *createObject ( std::pair< GridPartType *, KeyType > key ) { return new LFEMapType( *key.first, key.second ); }
167  static void deleteObject ( LFEMapType *object ) { delete object; }
168  };
169 
170  typedef SingletonList< std::pair< GridPartType *, KeyType >, LFEMapType, LFEMapFactory > LFEMapProviderType;
171 
172  typedef typename Traits::StoredShapeFunctionSetType StoredShapeFunctionSetType;
173  typedef std::vector< std::unique_ptr< StoredShapeFunctionSetType > > StoredShapeFunctionSetVectorType;
174 
175  struct StoredShapeFunctionSetVectorFactory
176  {
177  static StoredShapeFunctionSetVectorType *createObject ( LFEMapType *lfeMap ) { return new StoredShapeFunctionSetVectorType( lfeMap->size() ); }
178  static void deleteObject ( StoredShapeFunctionSetVectorType *object ) { delete object; }
179  };
180 
181  typedef SingletonList< LFEMapType *, StoredShapeFunctionSetVectorType, StoredShapeFunctionSetVectorFactory > StoredShapeFunctionSetVectorProviderType;
182 
183  struct BlockMapperSingletonFactory
184  {
185  static BlockMapperType *createObject ( LFEMapType *lfeMap )
186  {
187  if constexpr (!Traits::fullBlocking)
188  return new BlockMapperType( lfeMap->gridPart(),
189  [ lfeMap ] ( const auto &refElement ) {
190  if( lfeMap->hasCoefficients( refElement.type() ) )
191  return Dune::Fem::generateCodimensionCode( refElement, 0, lfeMap->localCoefficients( refElement.type() ).size() );
192  else
193  return Dune::Fem::DofMapperCode();
194  } );
195  else
196  return new BlockMapperType( lfeMap->gridPart() );
197  }
198 
199  static void deleteObject ( BlockMapperType *object ) { delete object; }
200  };
201 
202  typedef SingletonList< LFEMapType *, BlockMapperType, BlockMapperSingletonFactory > BlockMapperProviderType;
203 
204  public:
205  //- internal implementation
207 
210 
211  using BaseType::order;
212 
213  template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value &&std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
215  const InterfaceType commInterface = InteriorBorder_All_Interface,
216  const CommunicationDirection commDirection = ForwardCommunication )
217  : BaseType( gridPart, commInterface, commDirection ),
218  lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, KeyType() ) ) ),
219  storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
220  blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get()))
221  {}
222 
223  template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value && !std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
224  explicit DiscontinuousLocalFiniteElementSpace ( GridPart &gridPart, const KeyType &key,
225  const InterfaceType commInterface = InteriorBorder_All_Interface,
226  const CommunicationDirection commDirection = ForwardCommunication )
227  : BaseType( gridPart, commInterface, commDirection ),
228  lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, key ) ) ),
229  storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
230  blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get()) )
231  {}
232 
235 
236  ThisType &operator= ( const ThisType & ) = delete;
237  ThisType &operator= ( ThisType && ) = delete;
238 
240  DFSpaceIdentifier type () const { return DGSpace_id; }
241 
244  {
245  return BasisFunctionSetType( entity, shapeFunctionSet( entity ) );
246  }
247 
256  {
257  return getShapeFunctionSet( (*lfeMap_)( entity ), entity.type() );
258  }
259 
261  bool continuous () const { return false; }
262 
264  bool continuous ( const IntersectionType &intersection ) const { return false; }
265 
267  int order () const { return lfeMap_->order(); }
268 
270  bool multipleGeometryTypes () const { return true; }
271 
273  BlockMapperType &blockMapper () const { assert( blockMapper_ ); return *blockMapper_; }
274 
280  {
281  return InterpolationType( *this );
282  }
283 
289  [[deprecated("Use LocalInterpolation( space ) instead!")]]
291  {
292  return localInterpolation( entity );
293  }
294 
301  {
302  auto lfe = (*lfeMap_)( entity );
303  return InterpolationImplType( BasisFunctionSetType( entity, getShapeFunctionSet( lfe, entity.type() ) ), std::get< 2 >( lfe ) );
304  }
305 
306  typedef typename LFEMapType::LocalCoefficientsType QuadratureType;
307  const QuadratureType& quadrature ( const GeometryType &type ) const
308  {
309  return (*lfeMap_).localCoefficients(type);
310  }
311  private:
312  ShapeFunctionSetType getShapeFunctionSet ( std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & > lfe, const GeometryType &type ) const
313  {
314  auto &storedShapeFunctionSet = (*storedShapeFunctionSetVector_)[ std::get< 0 >( lfe ) ];
315  if( !storedShapeFunctionSet )
316  storedShapeFunctionSet.reset( new StoredShapeFunctionSetType( type, LocalFunctionsShapeFunctionSetType( std::get< 1 >( lfe ) ) ) );
317  return ShapeFunctionSetType( storedShapeFunctionSet.get() );
318  }
319 
320  std::unique_ptr< LFEMapType, typename LFEMapProviderType::Deleter > lfeMap_;
321  std::unique_ptr< StoredShapeFunctionSetVectorType, typename StoredShapeFunctionSetVectorProviderType::Deleter > storedShapeFunctionSetVector_;
322  std::unique_ptr< BlockMapperType, typename BlockMapperProviderType::Deleter > blockMapper_;
323  };
324 
325  template< class LFEMap, class FunctionSpace, class Storage, int newRange >
327  DiscontinuousLocalFiniteElementSpace<LFEMap, FunctionSpace, Storage>, newRange>
328  {
330  };
331  template <class LFEMap, class FunctionSpace, class Storage,
332  class NewFunctionSpace>
334  DiscontinuousLocalFiniteElementSpace<LFEMap,FunctionSpace,Storage>, NewFunctionSpace>
335  {
337  };
338 
339  } // namespace Fem
340 
341 } // namespace Dune
342 
343 #endif // #ifndef DUNE_FEM_SPACE_LOCALFINITEELEMENT_DGSPACE_HH
Provides a proxy class for pointers to a shape function set.
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:94
@ DGSpace_id
id for Discontinuous Galerkin Space
Definition: discretefunctionspace.hh:97
Definition: bindguard.hh:11
std::tuple_element< i, Tuple >::type & get(Dune::TypeIndexedTuple< Tuple, Types > &tuple)
Definition: typeindexedtuple.hh:122
typename Impl::GridFunctionSpace< GridPart, T >::Type GridFunctionSpace
Definition: functionspace.hh:317
Definition: hybrid.hh:86
Definition: space/basisfunctionset/default.hh:52
implementation of a basis function set for given entity
Definition: transformed.hh:44
Mathematical operation apply during communication to data that is communicated enum of all avialable ...
Definition: commoperations.hh:122
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:29
Definition: discretefunctionspace.hh:133
Traits ::BasisFunctionSetType BasisFunctionSetType
type of basis function set of this space
Definition: discretefunctionspace.hh:200
This is the class with default implementations for discrete function. The methods not marked with hav...
Definition: discretefunctionspace.hh:628
A vector valued function space.
Definition: functionspace.hh:60
convert functions space to space with new dim range
Definition: functionspace.hh:250
Rannacher-Turek Space.
Definition: dgspace.hh:130
bool multipleGeometryTypes() const
returns true if the grid has more than one geometry type
Definition: dgspace.hh:270
Traits::LFEMapType LFEMapType
Definition: dgspace.hh:153
BaseType::EntityType EntityType
Definition: dgspace.hh:142
InterpolationImplType localInterpolation(const EntityType &entity) const
return local interpolation
Definition: dgspace.hh:300
BaseType::GridPartType GridPartType
Definition: dgspace.hh:141
LFEMapType::KeyType KeyType
Definition: dgspace.hh:155
BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType
Definition: dgspace.hh:145
LFEMapType::LocalCoefficientsType QuadratureType
Definition: dgspace.hh:306
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: dgspace.hh:264
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: dgspace.hh:273
BaseType::IntersectionType IntersectionType
Definition: dgspace.hh:143
DiscontinuousLocalFiniteElementSpace(GridPart &gridPart, const KeyType &key, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
Definition: dgspace.hh:224
ThisType & operator=(const ThisType &)=delete
Traits::LocalFiniteElementType LocalFiniteElementType
Definition: dgspace.hh:150
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: dgspace.hh:240
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: dgspace.hh:261
BaseType::BasisFunctionSetType BasisFunctionSetType
Definition: dgspace.hh:146
BaseType::BlockMapperType BlockMapperType
Definition: dgspace.hh:148
LocalFEInterpolationWrapper< ThisType > InterpolationType
Interpolation object.
Definition: dgspace.hh:209
BaseType::FunctionSpaceType FunctionSpaceType
Definition: dgspace.hh:139
BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: dgspace.hh:243
DiscontinuousLocalFiniteElementSpace(GridPart &gridPart, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
Definition: dgspace.hh:214
ShapeFunctionSetType shapeFunctionSet(const EntityType &entity) const
return shape function set for given entity
Definition: dgspace.hh:255
int order() const
get global order of space
Definition: dgspace.hh:267
LocalFiniteElementInterpolation< ThisType, LocalInterpolationType, LocalBasisType::dimRange==1 > InterpolationImplType
Definition: dgspace.hh:206
DiscontinuousLocalFiniteElementSpace(const ThisType &)=delete
InterpolationType interpolation() const
return local interpolation object (uninitialized)
Definition: dgspace.hh:279
const QuadratureType & quadrature(const GeometryType &type) const
Definition: dgspace.hh:307
InterpolationImplType interpolation(const EntityType &entity) const
return local interpolation
Definition: dgspace.hh:290
SelectCachingShapeFunctionSet< LocalFunctionsShapeFunctionSetType, Storage > StoredShapeFunctionSetType
Definition: dgspace.hh:69
LFEMapType::GridPartType GridPartType
Definition: dgspace.hh:45
static constexpr bool isScalar
Definition: dgspace.hh:51
DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > DiscreteFunctionSpaceType
Definition: dgspace.hh:41
LocalFunctionsShapeFunctionSet< typename LocalFiniteElementType::Traits::LocalBasisType, LFEMap::pointSetId > LocalFunctionsShapeFunctionSetType
Definition: dgspace.hh:68
ShapeFunctionSetProxy< StoredShapeFunctionSetType > ShapeFunctionSetProxyType
Definition: dgspace.hh:71
static constexpr int codimension
Definition: dgspace.hh:50
LFEMapType::LocalFiniteElementType LocalFiniteElementType
Definition: dgspace.hh:46
std::conditional_t<!fullBlocking, IndexSetDofMapper< GridPartType >, CodimensionMapper< GridPartType, codimension > > BlockMapperType
Definition: dgspace.hh:65
static constexpr bool fullBlocking
Definition: dgspace.hh:52
std::conditional_t< isScalar, Hybrid::IndexRange< int, FunctionSpace::dimRange *scalarBlockSize >, Hybrid::IndexRange< int, 1 > > LocalBlockIndices
Definition: dgspace.hh:57
std::conditional_t< isScalar, VectorialShapeFunctionSet< ShapeFunctionSetProxyType, typename FunctionSpaceType::RangeType >, ShapeFunctionSetProxyType > ShapeFunctionSetType
Definition: dgspace.hh:76
GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType
Definition: dgspace.hh:48
decltype(basisFunctionSet(std::declval< const LFEMapType & >())) typedef BasisFunctionSetType
Definition: dgspace.hh:85
DefaultCommunicationHandler< DiscreteFunction, Operation > Type
Definition: dgspace.hh:90
Definition: dgspace.hh:111
static const unsigned int scalarBlockSize
Definition: dgspace.hh:112
DiscontinuousLocalFiniteElementSpace< LFEMap, typename ToNewDimRangeFunctionSpace< FunctionSpace, newRange >::Type, Storage > Type
Definition: dgspace.hh:329
DiscontinuousLocalFiniteElementSpace< LFEMap, NewFunctionSpace, Storage > Type
Definition: dgspace.hh:336
Definition: localfiniteelement/interpolation.hh:105
Definition: localfiniteelement/interpolation.hh:346
Definition: localfiniteelement/shapefunctionset.hh:49
mapper allocating one DoF per subentity of a given codimension
Definition: codimensionmapper.hh:330
Definition: indexsetdofmapper.hh:655
Definition: proxy.hh:35
Definition: selectcaching.hh:26
Definition: shapefunctionset/vectorial.hh:447
Singleton list for key/object pairs.
Definition: singletonlist.hh:53