dune-fem 2.8.0
Loading...
Searching...
No Matches
localfiniteelement/space.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_SPACE_LOCALFINITEELEMENT_SPACE_HH
2#define DUNE_FEM_SPACE_LOCALFINITEELEMENT_SPACE_HH
3
4#include <cassert>
5
6#include <memory>
7#include <utility>
8#include <vector>
9
10#include <dune/geometry/type.hh>
11
13
26
31
32namespace Dune
33{
34
35 namespace Fem
36 {
37
38 // LocalFiniteElementSpaceTraits
39 // -----------------------------
40
41 template< class LFEMap, class FunctionSpace, class Storage >
43 {
45
46 typedef LFEMap LFEMapType;
47
48 typedef typename LFEMapType::GridPartType GridPartType;
49 typedef typename LFEMapType::LocalFiniteElementType LocalFiniteElementType;
50
52
53 static constexpr int codimension = 0;
54 static constexpr bool isScalar = LocalFiniteElementType::Traits::LocalBasisType::Traits::dimRange==1;
55
56 typedef std::conditional_t<isScalar,
60
61 private:
62 typedef typename GridPartType::template Codim< codimension >::EntityType EntityType;
63
64 // -1 is default value if pointSetId not available
65 static const int pointSetId = detail::SelectPointSetId< LFEMap >::value;
66
67 public:
68 // typedef Dune::Fem::IndexSetDofMapper< GridPartType, LagrangeLocalDofMapping< GridPartType > > BlockMapperType;
70
73
75 // only extend to vector valued in case that the original space is scalar
76 typedef std::conditional_t<isScalar,
80
81 private:
82 template< class LFEM >
84
86
87 public:
88 typedef decltype( basisFunctionSet( std::declval< const LFEMapType & >() ) ) BasisFunctionSetType;
89
90 template< class DiscreteFunction, class Operation = DFCommunicationOperation::Add >
92 {
94 typedef Operation OperationType;
95 };
96 };
97
98
99
100 // LocalFiniteElementSpace
101 // -----------------------
102
112 template< class LFEMap, class FunctionSpace, class Storage >
114 : public DiscreteFunctionSpaceDefault< LocalFiniteElementSpaceTraits< LFEMap, FunctionSpace, Storage > >
115 {
118 BaseType;
119
120 public:
121 typedef typename BaseType::Traits Traits;
123
127
128 typedef typename BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType;
130
132
134
136
137 private:
138 typedef typename LocalFiniteElementType::Traits::LocalBasisType LocalBasisType;
139 typedef typename LocalFiniteElementType::Traits::LocalInterpolationType LocalInterpolationType;
140 typedef typename LocalFiniteElementType::Traits::LocalCoefficientsType LocalCoefficientsType;
141
142 typedef typename LFEMapType::KeyType KeyType;
143
145
146 struct LFEMapFactory
147 {
148 static LFEMapType *createObject ( std::pair< GridPartType *, KeyType > key ) { return new LFEMapType( *key.first, key.second ); }
149 static void deleteObject ( LFEMapType *object ) { delete object; }
150 };
151
152 typedef SingletonList< std::pair< GridPartType *, KeyType >, LFEMapType, LFEMapFactory > LFEMapProviderType;
153
154 typedef typename Traits::StoredShapeFunctionSetType StoredShapeFunctionSetType;
155 typedef std::vector< std::unique_ptr< StoredShapeFunctionSetType > > StoredShapeFunctionSetVectorType;
156
157 struct StoredShapeFunctionSetVectorFactory
158 {
159 static StoredShapeFunctionSetVectorType *createObject ( LFEMapType *lfeMap ) { return new StoredShapeFunctionSetVectorType( lfeMap->size() ); }
160 static void deleteObject ( StoredShapeFunctionSetVectorType *object ) { delete object; }
161 };
162
163 typedef SingletonList< LFEMapType *, StoredShapeFunctionSetVectorType, StoredShapeFunctionSetVectorFactory > StoredShapeFunctionSetVectorProviderType;
164
165 struct BlockMapperSingletonFactory
166 {
167 static BlockMapperType *createObject ( LFEMapType *lfeMap )
168 {
169 return new BlockMapperType( lfeMap->gridPart(), [ lfeMap ] ( const auto &refElement ) {
170 if( lfeMap->hasCoefficients( refElement.type() ) )
171 return Dune::Fem::compile( refElement, lfeMap->localCoefficients( refElement.type() ) );
172 else
173 return Dune::Fem::DofMapperCode();
174 } );
175 }
176
177 static void deleteObject ( BlockMapperType *object ) { delete object; }
178 };
179
180 typedef SingletonList< LFEMapType *, BlockMapperType, BlockMapperSingletonFactory > BlockMapperProviderType;
181
182 public:
183 //- internal implementation
185
188
189 using BaseType::order;
190
191 template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value &&std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
192 explicit LocalFiniteElementSpace ( GridPart &gridPart,
193 const InterfaceType commInterface = InteriorBorder_All_Interface,
194 const CommunicationDirection commDirection = ForwardCommunication )
195 : BaseType( gridPart, commInterface, commDirection ),
196 lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, KeyType() ) ) ),
197 storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
198 blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get() ) )
199 {}
200
201 template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value && !std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
202 explicit LocalFiniteElementSpace ( GridPart &gridPart, const KeyType &key,
203 const InterfaceType commInterface = InteriorBorder_All_Interface,
204 const CommunicationDirection commDirection = ForwardCommunication )
205 : BaseType( gridPart, commInterface, commDirection ),
206 lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, key ) ) ),
207 storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
208 blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get() ) )
209 {}
210
211 template< class GridPart, std::enable_if_t< std::is_same< GridPart, GridPartType >::value && !std::is_same< KeyType, std::tuple<> >::value, int > = 0 >
212 explicit LocalFiniteElementSpace ( GridPart &gridPart,
213 const InterfaceType commInterface = InteriorBorder_All_Interface,
214 const CommunicationDirection commDirection = ForwardCommunication )
215 : BaseType( gridPart, commInterface, commDirection ),
216 lfeMap_( &LFEMapProviderType::getObject( std::make_pair( &gridPart, KeyType(1) ) ) ),
217 storedShapeFunctionSetVector_( &StoredShapeFunctionSetVectorProviderType::getObject( lfeMap_.get() ) ),
218 blockMapper_( &BlockMapperProviderType::getObject( lfeMap_.get() ) )
219 {}
220 LocalFiniteElementSpace ( const ThisType & ) = delete;
222
223 ThisType &operator= ( const ThisType & ) = delete;
224 ThisType &operator= ( ThisType && ) = delete;
225
228
231 {
232 return BasisFunctionSetType( entity, shapeFunctionSet( entity ) );
233 }
234
243 {
244 return getShapeFunctionSet( (*lfeMap_)( entity ), entity.type() );
245 }
246
248 bool continuous () const { return true; }
249
251 bool continuous ( const IntersectionType &intersection ) const { return true; }
252
254 int order () const { return lfeMap_->order(); }
255
257 bool multipleGeometryTypes () const { return true; }
258
260 BlockMapperType &blockMapper () const { assert( blockMapper_ ); return *blockMapper_; }
261
267 {
268 return InterpolationType( *this );
269 }
270
276 [[deprecated("Use LocalInterpolation( space ) instead!")]]
278 {
279 return localInterpolation( entity );
280 }
281
288 {
289 auto lfe = (*lfeMap_)( entity );
290 return InterpolationImplType( BasisFunctionSetType( entity, getShapeFunctionSet( lfe, entity.type() ) ), std::get< 2 >( lfe ) );
291 }
292
293 typedef typename LFEMapType::LocalCoefficientsType QuadratureType;
294 const QuadratureType& quadrature ( const GeometryType &type ) const
295 {
296 return (*lfeMap_).localCoefficients(type);
297 }
298
299 private:
300 ShapeFunctionSetType getShapeFunctionSet ( std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & > lfe, const GeometryType &type ) const
301 {
302 auto &storedShapeFunctionSet = (*storedShapeFunctionSetVector_)[ std::get< 0 > ( lfe ) ];
303 if( !storedShapeFunctionSet )
304 storedShapeFunctionSet.reset( new StoredShapeFunctionSetType( type, LocalFunctionsShapeFunctionSetType( std::get< 1 >( lfe ) ) ) );
305 return ShapeFunctionSetType( storedShapeFunctionSet.get() );
306 }
307
308 std::unique_ptr< LFEMapType, typename LFEMapProviderType::Deleter > lfeMap_;
309 std::unique_ptr< StoredShapeFunctionSetVectorType, typename StoredShapeFunctionSetVectorProviderType::Deleter > storedShapeFunctionSetVector_;
310 std::unique_ptr< BlockMapperType, typename BlockMapperProviderType::Deleter > blockMapper_;
311 };
312
313 template< class LFEMap, class FunctionSpace, class Storage, int newRange >
315 LocalFiniteElementSpace<LFEMap, FunctionSpace, Storage>, newRange>
316 {
318 };
319 template <class LFEMap, class FunctionSpace, class Storage, class NewFunctionSpace>
321 LocalFiniteElementSpace<LFEMap,FunctionSpace,Storage>, NewFunctionSpace>
322 {
324 };
325 } // namespace Fem
326
327} // namespace Dune
328
329#endif // #ifndef DUNE_FEM_SPACE_LOCALFINITEELEMENT_SPACE_HH
Provides a proxy class for pointers to a shape function set.
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:94
@ LocalFiniteElementSpace_id
id for local finite element space
Definition: discretefunctionspace.hh:106
STL namespace.
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
Default communication handler for discrete functions.
Definition: defaultcommhandler.hh:29
Definition: discretefunctionspace.hh:133
Traits::FunctionSpaceType FunctionSpaceType
type of function space
Definition: discretefunctionspace.hh:193
Traits::BasisFunctionSetType BasisFunctionSetType
type of basis function set of this space
Definition: discretefunctionspace.hh:200
GridPartType::IntersectionType IntersectionType
type of the intersections
Definition: discretefunctionspace.hh:225
int order() const
get global order of space
Definition: discretefunctionspace.hh:345
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: localfiniteelement/space.hh:115
BaseType::GridPartType GridPartType
Definition: localfiniteelement/space.hh:124
InterpolationImplType localInterpolation(const EntityType &entity) const
return local interpolation
Definition: localfiniteelement/space.hh:287
BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: localfiniteelement/space.hh:230
LocalFiniteElementSpace(const ThisType &)=delete
BaseType::IntersectionType IntersectionType
Definition: localfiniteelement/space.hh:126
Traits::LFEMapType LFEMapType
Definition: localfiniteelement/space.hh:135
LocalFiniteElementInterpolation< ThisType, LocalInterpolationType, Traits::isScalar > InterpolationImplType
Definition: localfiniteelement/space.hh:184
BaseType::FunctionSpaceType FunctionSpaceType
Definition: localfiniteelement/space.hh:122
int order() const
get global order of space
Definition: localfiniteelement/space.hh:254
LocalFiniteElementSpace(ThisType &&)=delete
bool multipleGeometryTypes() const
returns true if the grid has more than one geometry type
Definition: localfiniteelement/space.hh:257
ThisType & operator=(const ThisType &)=delete
LocalFiniteElementSpace(GridPart &gridPart, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
Definition: localfiniteelement/space.hh:192
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: localfiniteelement/space.hh:260
InterpolationType interpolation() const
return local interpolation object (uninitialized)
Definition: localfiniteelement/space.hh:266
BaseType::BasisFunctionSetType BasisFunctionSetType
Definition: localfiniteelement/space.hh:129
BaseType::BlockMapperType BlockMapperType
Definition: localfiniteelement/space.hh:131
bool continuous() const
returns true if the space contains only globally continuous functions
Definition: localfiniteelement/space.hh:248
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: localfiniteelement/space.hh:251
ShapeFunctionSetType shapeFunctionSet(const EntityType &entity) const
return shape function set for given entity
Definition: localfiniteelement/space.hh:242
BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType
Definition: localfiniteelement/space.hh:128
DFSpaceIdentifier type() const
return type identifier of discrete function space
Definition: localfiniteelement/space.hh:227
LocalFEInterpolationWrapper< ThisType > InterpolationType
Interpolation object.
Definition: localfiniteelement/space.hh:187
LFEMapType::LocalCoefficientsType QuadratureType
Definition: localfiniteelement/space.hh:293
InterpolationImplType interpolation(const EntityType &entity) const
return local interpolation
Definition: localfiniteelement/space.hh:277
BaseType::EntityType EntityType
Definition: localfiniteelement/space.hh:125
Traits::LocalFiniteElementType LocalFiniteElementType
Definition: localfiniteelement/space.hh:133
LocalFiniteElementSpace(GridPart &gridPart, const KeyType &key, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
Definition: localfiniteelement/space.hh:202
const QuadratureType & quadrature(const GeometryType &type) const
Definition: localfiniteelement/space.hh:294
BaseType::Traits Traits
Definition: localfiniteelement/space.hh:121
Definition: localfiniteelement/interpolation.hh:105
Definition: localfiniteelement/interpolation.hh:346
Definition: localfiniteelement/shapefunctionset.hh:49
Definition: localfiniteelement/space.hh:43
SelectCachingShapeFunctionSet< LocalFunctionsShapeFunctionSetType, Storage > StoredShapeFunctionSetType
Definition: localfiniteelement/space.hh:72
LFEMap LFEMapType
Definition: localfiniteelement/space.hh:46
LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > DiscreteFunctionSpaceType
Definition: localfiniteelement/space.hh:44
static constexpr bool isScalar
Definition: localfiniteelement/space.hh:54
GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType
Definition: localfiniteelement/space.hh:51
decltype(basisFunctionSet(std::declval< const LFEMapType & >())) BasisFunctionSetType
Definition: localfiniteelement/space.hh:88
LFEMapType::GridPartType GridPartType
Definition: localfiniteelement/space.hh:48
Dune::Fem::IndexSetDofMapper< GridPartType > BlockMapperType
Definition: localfiniteelement/space.hh:69
std::conditional_t< isScalar, VectorialShapeFunctionSet< ShapeFunctionSetProxyType, typename FunctionSpaceType::RangeType >, ShapeFunctionSetProxyType > ShapeFunctionSetType
Definition: localfiniteelement/space.hh:79
LocalFunctionsShapeFunctionSet< typename LocalFiniteElementType::Traits::LocalBasisType, pointSetId > LocalFunctionsShapeFunctionSetType
Definition: localfiniteelement/space.hh:71
static constexpr int codimension
Definition: localfiniteelement/space.hh:53
ShapeFunctionSetProxy< StoredShapeFunctionSetType > ShapeFunctionSetProxyType
Definition: localfiniteelement/space.hh:74
LFEMapType::LocalFiniteElementType LocalFiniteElementType
Definition: localfiniteelement/space.hh:49
std::conditional_t< isScalar, Hybrid::IndexRange< int, FunctionSpace::dimRange >, Hybrid::IndexRange< int, 1 > > LocalBlockIndices
Definition: localfiniteelement/space.hh:59
Definition: localfiniteelement/space.hh:92
DefaultCommunicationHandler< DiscreteFunction, Operation > Type
Definition: localfiniteelement/space.hh:93
Operation OperationType
Definition: localfiniteelement/space.hh:94
LocalFiniteElementSpace< LFEMap, typename ToNewDimRangeFunctionSpace< FunctionSpace, newRange >::Type, Storage > Type
Definition: localfiniteelement/space.hh:317
LocalFiniteElementSpace< LFEMap, NewFunctionSpace, Storage > Type
Definition: localfiniteelement/space.hh:323
Definition: indexsetdofmapper.hh:719
Definition: proxy.hh:35
Definition: selectcaching.hh:26
Definition: shapefunctionset/vectorial.hh:447
Singleton list for key/object pairs.
Definition: singletonlist.hh:53