DUNE-FEM (unstable)

dgspace.hh
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
12#include <dune/fem/gridpart/common/capabilities.hh>
13#include <dune/fem/space/basisfunctionset/default.hh>
14#include <dune/fem/space/basisfunctionset/transformed.hh>
15#include <dune/fem/space/common/defaultcommhandler.hh>
16#include <dune/fem/space/common/discretefunctionspace.hh>
17#include <dune/fem/space/common/functionspace.hh>
18#include <dune/fem/space/mapper/compile.hh>
19#include <dune/fem/space/mapper/indexsetdofmapper.hh>
20#include <dune/fem/space/mapper/codimensionmapper.hh>
22#include <dune/fem/space/shapefunctionset/selectcaching.hh>
23#include <dune/fem/space/shapefunctionset/vectorial.hh>
24
25#include <dune/fem/space/localfiniteelement/shapefunctionset.hh>
26#include <dune/fem/space/localfiniteelement/capabilities.hh>
27#include <dune/fem/space/localfiniteelement/interpolation.hh>
28
29namespace Dune
30{
31
32 namespace Fem
33 {
34
35 // DiscontinuousLocalFiniteElementSpaceTraits
36 // ------------------------------------------
37 template< class LFEMap, class FunctionSpace, class Storage,
38 unsigned int scalarBlockSize >
39 struct DiscontinuousLocalFiniteElementSpaceTraits
40 {
41 typedef DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > DiscreteFunctionSpaceType;
42
43 typedef LFEMap LFEMapType;
44
45 typedef typename LFEMapType::GridPartType GridPartType;
46 typedef typename LFEMapType::LocalFiniteElementType LocalFiniteElementType;
47
48 typedef GridFunctionSpace< GridPartType, FunctionSpace > FunctionSpaceType;
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,
55 Hybrid::IndexRange< int, FunctionSpace::dimRange*scalarBlockSize >,
56 Hybrid::IndexRange< int, 1 >
57 > LocalBlockIndices;
58
59 private:
60 typedef typename GridPartType::template Codim< codimension >::EntityType EntityType;
61
62 public:
63 using BlockMapperType = std::conditional_t<!fullBlocking,
64 IndexSetDofMapper< GridPartType >,
65 CodimensionMapper< GridPartType, codimension > >;
66
67 // TODO: need SFINAE since not all LFEMap have a pointSetId
68 typedef LocalFunctionsShapeFunctionSet< typename LocalFiniteElementType::Traits::LocalBasisType, LFEMap::pointSetId > LocalFunctionsShapeFunctionSetType;
69 typedef SelectCachingShapeFunctionSet< LocalFunctionsShapeFunctionSetType, Storage > StoredShapeFunctionSetType;
70
71 typedef ShapeFunctionSetProxy< StoredShapeFunctionSetType > ShapeFunctionSetProxyType;
72 // only extend to vector valued in case that the original space is scalar
73 typedef std::conditional_t<isScalar,
74 VectorialShapeFunctionSet< ShapeFunctionSetProxyType, typename FunctionSpaceType::RangeType >,
75 ShapeFunctionSetProxyType
76 > ShapeFunctionSetType;
77
78 private:
79 template< class LFEM >
80 static TransformedBasisFunctionSet< EntityType, ShapeFunctionSetType, typename LFEM::TransformationType > basisFunctionSet ( const LFEM & );
81
82 static DefaultBasisFunctionSet< EntityType, ShapeFunctionSetType > basisFunctionSet ( ... );
83
84 public:
85 typedef decltype( basisFunctionSet( std::declval< const LFEMapType & >() ) ) BasisFunctionSetType;
86
87 template< class DiscreteFunction, class Operation = DFCommunicationOperation::Copy >
88 struct CommDataHandle
89 {
90 typedef DefaultCommunicationHandler< DiscreteFunction, Operation > Type;
91 typedef Operation OperationType;
92 };
93 };
94
95
96
97 // DiscontinuousLocalFiniteElementSpace
98 // ------------------------------------
99
109 template <class LFEMap,class Enabler>
110 struct FixedPolyOrder_
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>
122 using FixedPolyOrder = FixedPolyOrder_<LFEMap,std::true_type>;
123
124 template< class LFEMap, class FunctionSpace, class Storage >
127 DiscontinuousLocalFiniteElementSpaceTraits< LFEMap,
128 FunctionSpace, Storage, FixedPolyOrder<LFEMap>::scalarBlockSize > >,
129 public FixedPolyOrder<LFEMap>
130 {
133 DiscontinuousLocalFiniteElementSpaceTraits< LFEMap, FunctionSpace,
134 Storage, FixedPolyOrder<LFEMap>::scalarBlockSize > > BaseType;
135
136 typedef typename BaseType::Traits Traits;
137
138 public:
139 typedef typename BaseType::FunctionSpaceType FunctionSpaceType;
140
141 typedef typename BaseType::GridPartType GridPartType;
142 typedef typename BaseType::EntityType EntityType;
143 typedef typename BaseType::IntersectionType IntersectionType;
144
145 typedef typename BaseType::Traits::ShapeFunctionSetType ShapeFunctionSetType;
146 typedef typename BaseType::BasisFunctionSetType BasisFunctionSetType;
147
148 typedef typename BaseType::BlockMapperType BlockMapperType;
149
150 typedef typename Traits::LocalFiniteElementType LocalFiniteElementType;
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
162 typedef typename Traits::LocalFunctionsShapeFunctionSetType LocalFunctionsShapeFunctionSetType;
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
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
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
203
204 public:
205 //- internal implementation
206 typedef LocalFiniteElementInterpolation< ThisType, LocalInterpolationType, LocalBasisType::dimRange==1 > InterpolationImplType;
207
209 typedef LocalFEInterpolationWrapper< ThisType > InterpolationType;
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
233 DiscontinuousLocalFiniteElementSpace ( const ThisType & ) = delete;
234 DiscontinuousLocalFiniteElementSpace ( ThisType && ) = delete;
235
236 ThisType &operator= ( const ThisType & ) = delete;
237 ThisType &operator= ( ThisType && ) = delete;
238
240 DFSpaceIdentifier type () const { return DGSpace_id; }
241
243 BasisFunctionSetType basisFunctionSet ( const EntityType &entity ) const
244 {
245 return BasisFunctionSetType( entity, shapeFunctionSet( entity ) );
246 }
247
255 ShapeFunctionSetType shapeFunctionSet ( const EntityType &entity ) const
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!")]]
290 InterpolationImplType interpolation ( const EntityType &entity ) const
291 {
292 return localInterpolation( entity );
293 }
294
300 InterpolationImplType localInterpolation ( const EntityType &entity ) const
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 >
326 struct ToNewDimRangeFunctionSpace<
327 DiscontinuousLocalFiniteElementSpace<LFEMap, FunctionSpace, Storage>, newRange>
328 {
329 typedef DiscontinuousLocalFiniteElementSpace<LFEMap, typename ToNewDimRangeFunctionSpace<FunctionSpace,newRange>::Type, Storage> Type;
330 };
331 template <class LFEMap, class FunctionSpace, class Storage,
332 class NewFunctionSpace>
333 struct DifferentDiscreteFunctionSpace<
334 DiscontinuousLocalFiniteElementSpace<LFEMap,FunctionSpace,Storage>, NewFunctionSpace>
335 {
336 typedef DiscontinuousLocalFiniteElementSpace<LFEMap, NewFunctionSpace, Storage > Type;
337 };
338
339 } // namespace Fem
340
341} // namespace Dune
342
343#endif // #ifndef DUNE_FEM_SPACE_LOCALFINITEELEMENT_DGSPACE_HH
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
InterpolationImplType localInterpolation(const EntityType &entity) const
return local interpolation
Definition: dgspace.hh:300
bool continuous(const IntersectionType &intersection) const
returns true if the space contains only globally continuous functions
Definition: dgspace.hh:264
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
BlockMapperType & blockMapper() const
get a reference to the block mapper
Definition: dgspace.hh:273
LocalFEInterpolationWrapper< ThisType > InterpolationType
Interpolation object.
Definition: dgspace.hh:209
BasisFunctionSetType basisFunctionSet(const EntityType &entity) const
get basis function set for given entity
Definition: dgspace.hh:243
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
InterpolationType interpolation() const
return local interpolation object (uninitialized)
Definition: dgspace.hh:279
InterpolationImplType interpolation(const EntityType &entity) const
return local interpolation
Definition: dgspace.hh:290
This is the class with default implementations for discrete function. The methods not marked with hav...
Definition: discretefunctionspace.hh:649
Traits::BasisFunctionSetType BasisFunctionSetType
type of basis function set of this space
Definition: discretefunctionspace.hh:201
A vector valued function space.
Definition: functionspace.hh:60
Singleton list for key/object pairs.
Definition: singletonlist.hh:53
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:95
@ DGSpace_id
id for Discontinuous Galerkin Space
Definition: discretefunctionspace.hh:98
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:171
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:88
Dune namespace.
Definition: alignedallocator.hh:13
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
STL namespace.
Provides a proxy class for pointers to a shape function set.
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)