dune-fem  2.8-git
powerspace.hh
Go to the documentation of this file.
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 
10 #include <dune/grid/common/grid.hh>
11 
21 
22 namespace 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 >
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 >
46  {
47  // type of i-th sub space
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
55  {
56  return (*tuple);
57  }
58 
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
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;
84 
85  // type of block mapper
87 
88  // in the most general case we will unroll all local blockings
89  typedef typename DiscreteFunctionSpace::LocalBlockIndices LocalBlockIndices;
90 
91  // type functionspace
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 >
99  {
101  typedef typename DiscreteFunctionSpace::
104  typedef typename DiscreteFunctionSpace::
106  };
107 
108  // construct new instance of blockMapper
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 >
148  : public GenericCombinedDiscreteFunctionSpace< PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > >,
149  public CombinedSpaceHelper::LagrangePointSetExporter< DiscreteFunctionSpace >
150  {
154 
155  public:
159 
162 
165 
166  typedef typename Traits::EntityType EntityType;
167 
175  const InterfaceType commInterface = InteriorBorder_All_Interface,
176  const CommunicationDirection commDirection = ForwardCommunication )
177  : BaseType( gridPart, commInterface, commDirection ),
179  {}
180 
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 
194  {
195  return BaseType::template subDiscreteFunctionSpace< 0 >();
196  }
197 
200  {
201  return InterpolationType( *this, entity );
202  }
203  };
204 
205 
207  template< class DiscreteFunctionSpace, int N, class NewFunctionSpace >
209  {
211  };
212 
213 
214  // DefaultLocalRestrictProlong
215  // ---------------------------
216 
217  template< class DiscreteFunctionSpace, int N >
219  : public PowerLocalRestrictProlong< DiscreteFunctionSpace, N >
220  {
224 
225  public:
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
Definition: bindguard.hh:11
static std::shared_ptr< T > referenceToSharedPtr(T &t)
Definition: memory.hh:19
Implementation of DofAlignment.
Definition: basisfunctionset/vectorial.hh:141
Builds a vectorial basis function set from given scalar basis function set.
Definition: basisfunctionset/vectorial.hh:279
ToNewDimRangeFunctionSpace< ScalarFunctionSpaceType, dimRange >::Type FunctionSpaceType
Definition: basisfunctionset/vectorial.hh:293
Definition: combinedspace/generic.hh:23
Definition: combinedspace/interpolation.hh:25
Definition: lagrangepointsetexporter.hh:30
Definition: powerlocalrestrictprolong.hh:24
mapper allocating one DoF per subentity of a given codimension
Definition: powermapper.hh:330
Definition: powerspace.hh:150
const ContainedDiscreteFunctionSpaceType & containedSpace() const
return tuple of const References to the contained sub spaces
Definition: powerspace.hh:193
PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > Traits
Definition: powerspace.hh:156
InterpolationType interpolation(const EntityType &entity) const
return local interpolation object
Definition: powerspace.hh:199
PowerDiscreteFunctionSpace(GridPartType &gridPart, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
constructor
Definition: powerspace.hh:174
ThisType & operator=(const ThisType &)=delete
Traits::EntityType EntityType
Definition: powerspace.hh:166
Traits::GridPartType GridPartType
type of grid part
Definition: powerspace.hh:158
PowerDiscreteFunctionSpace(std::shared_ptr< DiscreteFunctionSpace > space)
Definition: powerspace.hh:185
PowerDiscreteFunctionSpace(const DiscreteFunctionSpace &space)
Definition: powerspace.hh:181
PowerSpaceInterpolation< ThisType, N > InterpolationType
type of local Interpolation
Definition: powerspace.hh:164
PowerDiscreteFunctionSpace(const ThisType &)=delete
DiscreteFunctionSpace ContainedDiscreteFunctionSpaceType
type of contained discrete function space
Definition: powerspace.hh:161
static T accumulate(const DiscreteFunctionSpaceTupleType &tuple, T value, F &&f)
Definition: powerspace.hh:128
GridPartType::GridType GridType
Definition: powerspace.hh:67
PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > DiscreteFunctionSpaceType
Definition: powerspace.hh:74
GridPartType::IntersectionType IntersectionType
Definition: powerspace.hh:71
GridPartType::template Codim< 0 >::IteratorType IteratorType
Definition: powerspace.hh:69
DiscreteFunctionSpace::BasisFunctionSetType ScalarBasisFunctionSetType
implementation of basefunction set
Definition: powerspace.hh:79
GridPartType::IndexSetType IndexSetType
Definition: powerspace.hh:68
IteratorType::Entity EntityType
Definition: powerspace.hh:70
ScalarBasisFunctionSetType::FunctionSpaceType::RangeFieldType RangeFieldType
Definition: powerspace.hh:82
BasisFunctionSetType::FunctionSpaceType FunctionSpaceType
Definition: powerspace.hh:92
static DiscreteFunctionSpaceTupleType createSpaces(GridPartType &gridPart, InterfaceType commInterface, CommunicationDirection commDirection)
Definition: powerspace.hh:115
DiscreteFunctionSpace::LocalBlockIndices LocalBlockIndices
Definition: powerspace.hh:89
static BasisFunctionSetType getBasisFunctionSet(const Entity &entity, const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:122
PowerMapper< GridPartType, typename DiscreteFunctionSpace::BlockMapperType, N > BlockMapperType
Definition: powerspace.hh:86
std::shared_ptr< DiscreteFunctionSpace > DiscreteFunctionSpaceTupleType
Definition: powerspace.hh:41
VectorialBasisFunctionSet< ScalarBasisFunctionSetType, FieldVector< RangeFieldType, N >, VerticalDofAlignment > BasisFunctionSetType
Definition: powerspace.hh:83
static const int codimension
Definition: powerspace.hh:76
DiscreteFunctionSpace::GridPartType GridPartType
Definition: powerspace.hh:66
static BlockMapperType * getBlockMapper(const DiscreteFunctionSpaceTupleType &spaceTuple)
Definition: powerspace.hh:109
static const Type & subDiscreteFunctionSpace(const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:54
Type::BlockMapperType BlockMapperType
Definition: powerspace.hh:51
DiscreteFunctionSpace Type
Definition: powerspace.hh:48
static BlockMapperType & subBlockMapper(const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:59
DiscreteFunctionSpace::template CommDataHandle< DiscreteFunction, Operation >::Type Type
type of data handle
Definition: powerspace.hh:102
DiscreteFunctionSpace::template CommDataHandle< DiscreteFunction, Operation >::OperationType OperationType
type of operatation to perform on scatter
Definition: powerspace.hh:105
PowerDiscreteFunctionSpace< DiscreteFunctionSpace, NewFunctionSpace::dimRange > Type
Definition: powerspace.hh:210
DefaultLocalRestrictProlong(const DiscreteFunctionSpacesType &space)
Definition: powerspace.hh:226
Definition: discretefunctionspace.hh:133
GridPartType & gridPart() const
Definition: discretefunctionspace.hh:745
Definition: common/localrestrictprolong.hh:16
discrete function space