dune-fem  2.6-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 
23 
27 
28 namespace Dune
29 {
30 
31  namespace Fem
32  {
33 
34  // DiscontinuousLocalFiniteElementSpaceTraits
35  // ------------------------------------------
36 
37  template< class LFEMap, class FunctionSpace, template< class > class Storage >
39  {
41 
42  typedef LFEMap LFEMapType;
43 
44  typedef typename LFEMapType::GridPartType GridPartType;
45  typedef typename LFEMapType::LocalFiniteElementType LocalFiniteElementType;
46 
48 
49  static constexpr int codimension = 0;
50 
52 
53  private:
54  typedef typename GridPartType::template Codim< codimension >::EntityType EntityType;
55 
56  public:
58 
61 
63 // typedef VectorialShapeFunctionSet< ShapeFunctionSetProxy< StoredShapeFunctionSetType >, typename FunctionSpaceType::RangeType > ShapeFunctionSetType;
64 
65  private:
66  template< class LFEM >
68 
70 
71  public:
72  typedef decltype( basisFunctionSet( std::declval< const LFEMapType & >() ) ) BasisFunctionSetType;
73 
74  template< class DiscreteFunction, class Operation = DFCommunicationOperation::Copy >
76  {
78  typedef Operation OperationType;
79  };
80  };
81 
82 
83 
84  // DiscontinuousLocalFiniteElementSpace
85  // ------------------------------------
86 
96  template< class LFEMap, class FunctionSpace, template< class > class Storage >
98  : public DiscreteFunctionSpaceDefault< DiscontinuousLocalFiniteElementSpaceTraits< LFEMap, FunctionSpace, Storage > >
99  {
102 
103  typedef typename BaseType::Traits Traits;
104 
105  public:
107 
111 
114 
116 
118 
119  typedef typename Traits::LFEMapType LFEMapType;
120 
121  typedef typename LFEMapType::KeyType KeyType;
122 
123  private:
124  typedef typename LocalFiniteElementType::Traits::LocalBasisType LocalBasisType;
125  typedef typename LocalFiniteElementType::Traits::LocalInterpolationType LocalInterpolationType;
126  typedef typename LocalFiniteElementType::Traits::LocalCoefficientsType LocalCoefficientsType;
127 
129 
130  struct LFEMapFactory
131  {
132  static LFEMapType *createObject ( std::pair< GridPartType *, KeyType > key ) { return new LFEMapType( *key.first, key.second ); }
133  static void deleteObject ( LFEMapType *object ) { delete object; }
134  };
135 
136  typedef SingletonList< std::pair< GridPartType *, KeyType >, LFEMapType, LFEMapFactory > LFEMapProviderType;
137 
138  typedef typename Traits::StoredShapeFunctionSetType StoredShapeFunctionSetType;
139  typedef std::vector< std::unique_ptr< StoredShapeFunctionSetType > > StoredShapeFunctionSetVectorType;
140 
141  struct StoredShapeFunctionSetVectorFactory
142  {
143  static StoredShapeFunctionSetVectorType *createObject ( LFEMapType *lfeMap ) { return new StoredShapeFunctionSetVectorType( lfeMap->size() ); }
144  static void deleteObject ( StoredShapeFunctionSetVectorType *object ) { delete object; }
145  };
146 
147  typedef SingletonList< LFEMapType *, StoredShapeFunctionSetVectorType, StoredShapeFunctionSetVectorFactory > StoredShapeFunctionSetVectorProviderType;
148 
149  struct BlockMapperSingletonFactory
150  {
151  static BlockMapperType *createObject ( LFEMapType *lfeMap )
152  {
153  return new BlockMapperType( lfeMap->gridPart(), [ lfeMap ] ( const auto &refElement ) {
154  if( lfeMap->hasCoefficients( refElement.type() ) )
155  return Dune::Fem::generateCodimensionCode( refElement, 0, lfeMap->localCoefficients( refElement.type() ).size() );
156  else
157  return Dune::Fem::DofMapperCode();
158  } );
159  }
160 
161  static void deleteObject ( BlockMapperType *object ) { delete object; }
162  };
163 
164  typedef SingletonList< LFEMapType *, BlockMapperType, BlockMapperSingletonFactory > BlockMapperProviderType;
165 
166  public:
168 
169  using BaseType::order;
170 
171  template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value &&std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
173  const InterfaceType commInterface = InteriorBorder_All_Interface,
174  const CommunicationDirection commDirection = ForwardCommunication )
175  : BaseType( gridPart, commInterface, commDirection ),
176  lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, KeyType() ) ) ),
177  storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
178  blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get() ) )
179  {}
180 
181  template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value && !std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
182  explicit DiscontinuousLocalFiniteElementSpace ( GridPart &gridPart, const KeyType &key,
183  const InterfaceType commInterface = InteriorBorder_All_Interface,
184  const CommunicationDirection commDirection = ForwardCommunication )
185  : BaseType( gridPart, commInterface, commDirection ),
186  lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, key ) ) ),
187  storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
188  blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get() ) )
189  {}
190 
193 
194  ThisType &operator= ( const ThisType & ) = delete;
195  ThisType &operator= ( ThisType && ) = delete;
196 
198  DFSpaceIdentifier type () const { return DGSpace_id; }
199 
202  {
203  return BasisFunctionSetType( entity, shapeFunctionSet( entity ) );
204  }
205 
214  {
215  return getShapeFunctionSet( (*lfeMap_)( entity ), entity.type() );
216  }
217 
219  bool continuous () const { return false; }
220 
222  bool continuous ( const IntersectionType &intersection ) const { return false; }
223 
225  int order () const { return lfeMap_->order(); }
226 
228  bool multipleGeometryTypes () const { return true; }
229 
231  BlockMapperType &blockMapper () const { assert( blockMapper_ ); return *blockMapper_; }
232 
239  {
240  auto lfe = (*lfeMap_)( entity );
241  return InterpolationType( BasisFunctionSetType( entity, getShapeFunctionSet( lfe, entity.type() ) ), std::get< 2 >( lfe ) );
242  }
243 
244  private:
245  ShapeFunctionSetType getShapeFunctionSet ( std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & > lfe, const GeometryType &type ) const
246  {
247  auto &storedShapeFunctionSet = (*storedShapeFunctionSetVector_)[ std::get< 0 >( lfe ) ];
248  if( !storedShapeFunctionSet )
249  storedShapeFunctionSet.reset( new StoredShapeFunctionSetType( type, LocalFunctionsShapeFunctionSetType( std::get< 1 >( lfe ) ) ) );
250  return ShapeFunctionSetType( storedShapeFunctionSet.get() );
251  }
252 
253  std::unique_ptr< LFEMapType, typename LFEMapProviderType::Deleter > lfeMap_;
254  std::unique_ptr< StoredShapeFunctionSetVectorType, typename StoredShapeFunctionSetVectorProviderType::Deleter > storedShapeFunctionSetVector_;
255  std::unique_ptr< BlockMapperType, typename BlockMapperProviderType::Deleter > blockMapper_;
256  };
257 
258  } // namespace Fem
259 
260 } // namespace Dune
261 
262 #endif // #ifndef DUNE_FEM_SPACE_LOCALFINITEELEMENT_DGSPACE_HH
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: basisfunctionset/default.hh:47
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:123
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:29
Traits ::FunctionSpaceType FunctionSpaceType
type of function space
Definition: discretefunctionspace.hh:193
GridPartType ::IntersectionType IntersectionType
type of the intersections
Definition: discretefunctionspace.hh:225
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:617
Rannacher-Turek Space.
Definition: dgspace.hh:99
bool multipleGeometryTypes() const
returns true if the grid has more than one geometry type
Definition: dgspace.hh:228
Traits::LFEMapType LFEMapType
Definition: dgspace.hh:119
BaseType::EntityType EntityType
Definition: dgspace.hh:109
BaseType::GridPartType GridPartType
Definition: dgspace.hh:108
LFEMapType::KeyType KeyType
Definition: dgspace.hh:121
BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType
Definition: dgspace.hh:112
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: dgspace.hh:222
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: dgspace.hh:231
BaseType::IntersectionType IntersectionType
Definition: dgspace.hh:110
DiscontinuousLocalFiniteElementSpace(GridPart &gridPart, const KeyType &key, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
Definition: dgspace.hh:182
ThisType & operator=(const ThisType &)=delete
Traits::LocalFiniteElementType LocalFiniteElementType
Definition: dgspace.hh:117
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: dgspace.hh:198
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: dgspace.hh:219
BaseType::BasisFunctionSetType BasisFunctionSetType
Definition: dgspace.hh:113
BaseType::BlockMapperType BlockMapperType
Definition: dgspace.hh:115
BaseType::FunctionSpaceType FunctionSpaceType
Definition: dgspace.hh:106
BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: dgspace.hh:201
DiscontinuousLocalFiniteElementSpace(GridPart &gridPart, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
Definition: dgspace.hh:172
ShapeFunctionSetType shapeFunctionSet(const EntityType &entity) const
return shape function set for given entity
Definition: dgspace.hh:213
int order() const
get global order of space
Definition: dgspace.hh:225
DiscontinuousLocalFiniteElementSpace(const ThisType &)=delete
LocalFiniteElementInterpolation< BasisFunctionSetType, LocalInterpolationType > InterpolationType
Definition: dgspace.hh:167
InterpolationType interpolation(const EntityType &entity) const
return local interpolation
Definition: dgspace.hh:238
ShapeFunctionSetProxy< StoredShapeFunctionSetType > ShapeFunctionSetType
Definition: dgspace.hh:62
static constexpr int codimension
Definition: dgspace.hh:49
Dune::Fem::IndexSetDofMapper< GridPartType > BlockMapperType
Definition: dgspace.hh:57
LFEMapType::LocalFiniteElementType LocalFiniteElementType
Definition: dgspace.hh:45
GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType
Definition: dgspace.hh:47
DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > DiscreteFunctionSpaceType
Definition: dgspace.hh:40
SelectCachingShapeFunctionSet< LocalFunctionsShapeFunctionSetType, Storage > StoredShapeFunctionSetType
Definition: dgspace.hh:60
LFEMapType::GridPartType GridPartType
Definition: dgspace.hh:44
LocalFunctionsShapeFunctionSet< typename LocalFiniteElementType::Traits::LocalBasisType > LocalFunctionsShapeFunctionSetType
Definition: dgspace.hh:59
Hybrid::IndexRange< int, 1 > LocalBlockIndices
Definition: dgspace.hh:51
decltype(basisFunctionSet(std::declval< const LFEMapType & >())) typedef BasisFunctionSetType
Definition: dgspace.hh:72
DefaultCommunicationHandler< DiscreteFunction, Operation > Type
Definition: dgspace.hh:77
Definition: localfiniteelement/interpolation.hh:90
Definition: localfiniteelement/shapefunctionset.hh:49
Definition: indexsetdofmapper.hh:636
Definition: shapefunctionset/proxy.hh:33
Definition: selectcaching.hh:28
Singleton list for key/object pairs.
Definition: singletonlist.hh:54
Provides a proxy class for pointers to a shape function set.