DUNE-FEM (unstable)

powerspace.hh
1#ifndef DUNE_FEM_SPACE_COMBINEDSPACE_POWERSPACE_HH
2#define DUNE_FEM_SPACE_COMBINEDSPACE_POWERSPACE_HH
3
4#include <algorithm>
5#include <memory>
6#include <type_traits>
7
8#include <dune/common/math.hh>
9
11
12#include <dune/fem/common/memory.hh>
13#include <dune/fem/common/utility.hh>
14#include <dune/fem/space/basisfunctionset/vectorial.hh>
15#include <dune/fem/space/combinedspace/generic.hh>
16#include <dune/fem/space/combinedspace/interpolation.hh>
17#include <dune/fem/space/combinedspace/lagrangepointsetexporter.hh>
18#include <dune/fem/space/combinedspace/powerlocalrestrictprolong.hh>
19#include <dune/fem/space/combinedspace/powermapper.hh>
20#include <dune/fem/space/common/defaultcommhandler.hh>
21
22namespace Dune
23{
24
25 namespace Fem
26 {
27
28 // forward declaration
29
30 template< class DiscreteFunctionSpace, int N >
31 class PowerDiscreteFunctionSpace;
32
33
34 // PowerDiscreteFunctionSpaceTraits
35 // --------------------------------
36
37 template< class DiscreteFunctionSpace, int N >
38 struct PowerDiscreteFunctionSpaceTraits
39 {
40 // we need to store pointer to the spaces in the SpaceTuple, since space can not be copied.
41 typedef std::shared_ptr< DiscreteFunctionSpace > DiscreteFunctionSpaceTupleType;
42
43 // helper struct to access contained sub spaces
44 template< int >
45 struct SubDiscreteFunctionSpace
46 {
47 // type of i-th sub space
48 typedef DiscreteFunctionSpace Type;
49
50 // type of i-th sub BlockMapper
51 typedef typename Type::BlockMapperType BlockMapperType;
52
53 // access to a const ref of the i-th subspace
54 static const Type &subDiscreteFunctionSpace ( const DiscreteFunctionSpaceTupleType &tuple )
55 {
56 return (*tuple);
57 }
58
59 static BlockMapperType &subBlockMapper ( const DiscreteFunctionSpaceTupleType &tuple )
60 {
61 return subDiscreteFunctionSpace().blockMapper();
62 }
63 };
64
65 // type of GridPart
66 typedef typename DiscreteFunctionSpace::GridPartType GridPartType;
67 typedef typename GridPartType::GridType GridType;
68 typedef typename GridPartType::IndexSetType IndexSetType;
69 typedef typename GridPartType::template Codim< 0 >::IteratorType IteratorType;
70 typedef typename IteratorType::Entity EntityType;
71 typedef typename GridPartType::IntersectionType IntersectionType;
72
73 // type of this space
74 typedef PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > DiscreteFunctionSpaceType;
75
76 static const int codimension = DiscreteFunctionSpace::Traits::codimension;
77
78 static_assert( DiscreteFunctionSpace::FunctionSpaceType::dimRange == 1,
79 "PowerDiscreteFunctionSpace only works for ContainedSpaces with dimRange = 1" );
81 typedef typename DiscreteFunctionSpace::BasisFunctionSetType ScalarBasisFunctionSetType;
82 typedef typename ScalarBasisFunctionSetType::FunctionSpaceType::RangeFieldType RangeFieldType;
83 typedef VectorialBasisFunctionSet< ScalarBasisFunctionSetType, FieldVector< RangeFieldType, N >, VerticalDofAlignment > BasisFunctionSetType;
84
85 // type of block mapper
86 typedef PowerMapper< GridPartType, typename DiscreteFunctionSpace::BlockMapperType, N > BlockMapperType;
87
88 // in the most general case we will unroll all local blockings
89 typedef typename DiscreteFunctionSpace::LocalBlockIndices LocalBlockIndices;
90
91 // type functionspace
92 typedef typename BasisFunctionSetType::FunctionSpaceType FunctionSpaceType;
93
94 // review to make it work for all kind of combinations
95 template< class DiscreteFunction,
96 class Operation
97 = typename DiscreteFunctionSpace::template CommDataHandle< DiscreteFunctionSpace >::OperationType >
98 struct CommDataHandle
99 {
101 typedef typename DiscreteFunctionSpace::
102 template CommDataHandle< DiscreteFunction, Operation >::Type Type;
104 typedef typename DiscreteFunctionSpace::
105 template CommDataHandle< DiscreteFunction, Operation >::OperationType OperationType;
106 };
107
108 // construct new instance of blockMapper
109 static BlockMapperType *getBlockMapper ( const DiscreteFunctionSpaceTupleType &spaceTuple )
110 {
111 return new BlockMapperType( spaceTuple->gridPart(), spaceTuple->blockMapper() );
112 }
113
114 // create Tuple of contained subspaces
115 static DiscreteFunctionSpaceTupleType createSpaces ( GridPartType &gridPart, InterfaceType commInterface,
116 CommunicationDirection commDirection )
117 {
118 return std::make_shared< DiscreteFunctionSpace >( gridPart, commInterface, commDirection );
119 }
120
121 template< class Entity >
122 static BasisFunctionSetType getBasisFunctionSet ( const Entity &entity, const DiscreteFunctionSpaceTupleType &tuple )
123 {
124 return BasisFunctionSetType( tuple->basisFunctionSet( entity ) );
125 }
126
127 template< class T, class F >
128 static T accumulate ( const DiscreteFunctionSpaceTupleType &tuple, T value, F &&f )
129 {
130 return f( value, *tuple );
131 }
132 };
133
134
135
146 template< class DiscreteFunctionSpace, int N >
147 class PowerDiscreteFunctionSpace
148 : public GenericCombinedDiscreteFunctionSpace< PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > >,
149 public CombinedSpaceHelper::LagrangePointSetExporter< DiscreteFunctionSpace >
150 {
151 typedef PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > ThisType;
152 typedef GenericCombinedDiscreteFunctionSpace< PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > > BaseType;
153 typedef CombinedSpaceHelper::LagrangePointSetExporter< DiscreteFunctionSpace > LagrangePointSetExporterType;
154
155 public:
156 typedef PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > Traits;
158 typedef typename Traits::GridPartType GridPartType;
159
161 typedef DiscreteFunctionSpace ContainedDiscreteFunctionSpaceType;
162
164 typedef PowerSpaceInterpolation< ThisType, N > InterpolationType;
165
166 typedef typename Traits::EntityType EntityType;
167
174 PowerDiscreteFunctionSpace ( GridPartType &gridPart,
175 const InterfaceType commInterface = InteriorBorder_All_Interface,
176 const CommunicationDirection commDirection = ForwardCommunication )
177 : BaseType( gridPart, commInterface, commDirection ),
178 LagrangePointSetExporterType( containedSpace() )
179 {}
180
181 PowerDiscreteFunctionSpace ( const DiscreteFunctionSpace &space )
182 : BaseType( referenceToSharedPtr( space ) )
183 {}
184
185 PowerDiscreteFunctionSpace ( std::shared_ptr< DiscreteFunctionSpace > space )
186 : BaseType( std::move( space ) )
187 {}
188
189 PowerDiscreteFunctionSpace ( const ThisType & ) = delete;
190 ThisType &operator= ( const ThisType & ) = delete;
191
193 const ContainedDiscreteFunctionSpaceType &containedSpace () const
194 {
195 return BaseType::template subDiscreteFunctionSpace< 0 >();
196 }
197
199 InterpolationType interpolation ( const EntityType &entity ) const
200 {
201 return InterpolationType( *this, entity );
202 }
203 };
204
205
207 template< class DiscreteFunctionSpace, int N, class NewFunctionSpace >
208 struct DifferentDiscreteFunctionSpace< PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N >, NewFunctionSpace >
209 {
210 typedef PowerDiscreteFunctionSpace< DiscreteFunctionSpace, NewFunctionSpace::dimRange > Type;
211 };
212
213
214 // DefaultLocalRestrictProlong
215 // ---------------------------
216
217 template< class DiscreteFunctionSpace, int N >
218 class DefaultLocalRestrictProlong< PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > >
219 : public PowerLocalRestrictProlong< DiscreteFunctionSpace, N >
220 {
221 typedef DefaultLocalRestrictProlong< PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > > ThisType;
222 typedef PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > DiscreteFunctionSpacesType;
223 typedef PowerLocalRestrictProlong< DiscreteFunctionSpace, N > BaseType;
224
225 public:
226 DefaultLocalRestrictProlong ( const DiscreteFunctionSpacesType &space )
227 : BaseType( space.containedSpace() )
228 {}
229
230 };
231
232 } // namespace Fem
233
234} // namespace Dune
235
236#endif // #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_POWERSPACE_HH
discrete function space
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: adaptiveleafgridpart.hh:95
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1351
A vector valued function space.
Definition: functionspace.hh:60
Different resources needed by all grid implementations.
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
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:279
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)