dune-fem  2.4.1-rc
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 <type_traits>
6 
7 #include <dune/common/math.hh>
8 #include <dune/common/typetraits.hh>
9 #include <dune/grid/common/grid.hh>
10 
12 
19 
20 namespace Dune
21 {
22 
23  namespace Fem
24  {
25 
26  // forward declaration
27 
28  template< class DiscreteFunctionSpace, int N >
30 
31 
32  // PowerDiscreteFunctionSpaceTraits
33  // --------------------------------
34 
35  template< class DiscreteFunctionSpace, int N >
37  {
38  // we need to store pointer to the spaces in the SpaceTuple, since space can not be copied.
40 
41  // helper struct to access contained sub spaces
42  template< int >
44  {
45  // type of i-th sub space
47 
48  // type of i-th sub BlockMapper
49  typedef typename Type::BlockMapperType BlockMapperType;
50 
51  // access to a const ref of the i-th subspace
52  static const Type &subDiscreteFunctionSpace ( const DiscreteFunctionSpaceTupleType &tuple )
53  {
54  return (*tuple);
55  }
56 
57  static BlockMapperType &subBlockMapper ( const DiscreteFunctionSpaceTupleType &tuple )
58  {
59  return subDiscreteFunctionSpace().blockMapper();
60  }
61  };
62 
63  // type of GridPart
64  typedef typename DiscreteFunctionSpace::GridPartType GridPartType;
65  typedef typename GridPartType::GridType GridType;
66  typedef typename GridPartType::IndexSetType IndexSetType;
67  typedef typename GridPartType::template Codim< 0 >::IteratorType IteratorType;
68  typedef typename IteratorType::Entity EntityType;
69  typedef typename GridPartType::IntersectionType IntersectionType;
70 
71  // type of this space
73 
74  static const int codimension = DiscreteFunctionSpace::Traits::codimension;
75 
76  static_assert( DiscreteFunctionSpace::FunctionSpaceType::dimRange == 1,
77  "PowerDiscreteFunctionSpace only works for ContainedSpaces with dimRange = 1" );
79  typedef typename DiscreteFunctionSpace::BasisFunctionSetType ScalarBasisFunctionSetType;
80  typedef typename ScalarBasisFunctionSetType::FunctionSpaceType::RangeFieldType RangeFieldType;
82 
83  // type of block mapper
85 
86  // in the most general case we will unroll all local blockings
87  enum { localBlockSize = DiscreteFunctionSpace::localBlockSize };
88 
89  // type functionspace
91 
92  static constexpr int polynomialOrder = DiscreteFunctionSpace::polynomialOrder;
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
109  static BlockMapperType *getBlockMapper ( const DiscreteFunctionSpaceTupleType &spaceTuple )
110  {
111  return new BlockMapperType( spaceTuple->gridPart(), spaceTuple->blockMapper() );
112  }
113 
114  // delete instance of BlockMapper
115  static void deleteBlockMapper ( BlockMapperType *blockMapper )
116  {
117  delete blockMapper;
118  }
119 
120  // create Tuple of contained subspaces
121  static DiscreteFunctionSpaceTupleType createSpaces ( GridPartType &gridPart, InterfaceType commInterface,
122  CommunicationDirection commDirection )
123  {
124  return new DiscreteFunctionSpace( gridPart, commInterface, commDirection );
125  }
126 
127  // delete Tuple of contained subspaces
128  static void deleteSpaces ( DiscreteFunctionSpaceTupleType &tuple )
129  {
130  delete tuple;
131  }
132 
133  template< class Entity >
134  static BasisFunctionSetType getBasisFunctionSet ( const Entity &entity, const DiscreteFunctionSpaceTupleType &tuple )
135  {
136  return BasisFunctionSetType( tuple->basisFunctionSet( entity ) );
137  }
138 
139  static bool continuous ( const DiscreteFunctionSpaceTupleType &tuple )
140  {
141  return tuple->continuous();
142  }
143 
144  static bool continuous ( const IntersectionType &intersection, const DiscreteFunctionSpaceTupleType &tuple )
145  {
146  return tuple->continuous( intersection );
147  }
148  };
149 
150 
151 
164  template< class DiscreteFunctionSpace, int N >
166  : public GenericCombinedDiscreteFunctionSpace< PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > >,
167  public CombinedSpaceHelper::LagrangePointSetExporter< DiscreteFunctionSpace >
168  {
172 
173  public:
178 
181 
188  PowerDiscreteFunctionSpace ( GridPartType &gridPart,
189  const InterfaceType commInterface = InteriorBorder_All_Interface,
190  const CommunicationDirection commDirection = ForwardCommunication )
191  : BaseType( gridPart, commInterface, commDirection ),
192  LagrangePointSetExporterType( containedSpace() )
193  {}
194 
195  // prohibit copy constructor and copy assignment
196  PowerDiscreteFunctionSpace ( const ThisType & ) = delete;
197  ThisType &operator= ( const ThisType & ) = delete;
198 
200  const ContainedDiscreteFunctionSpaceType &containedSpace () const
201  {
202  return BaseType::template subDiscreteFunctionSpace< 0 >();
203  }
204  };
205 
206 
208  template< class DiscreteFunctionSpace, int N, class NewFunctionSpace >
210  {
212  };
213 
214 
215  // DefaultLocalRestrictProlong
216  // ---------------------------
217 
218  template< class DiscreteFunctionSpace, int N >
220  : public PowerLocalRestrictProlong< DiscreteFunctionSpace, N >
221  {
225 
226  public:
227  DefaultLocalRestrictProlong ( const DiscreteFunctionSpacesType &space )
228  : BaseType( space.containedSpace() )
229  {}
230 
231  };
232 
233  } // namespace Fem
234 
235 } // namespace Dune
236 
237 #endif // #ifndef DUNE_FEM_SPACE_COMBINEDSPACE_POWERSPACE_HH
const ContainedDiscreteFunctionSpaceType & containedSpace() const
return tuple of const References to the contained sub spaces
Definition: powerspace.hh:200
PowerDiscreteFunctionSpace< DiscreteFunctionSpace, N > DiscreteFunctionSpaceType
Definition: powerspace.hh:72
Definition: powerlocalrestrictprolong.hh:25
ScalarBasisFunctionSetType::FunctionSpaceType::RangeFieldType RangeFieldType
Definition: powerspace.hh:80
BasisFunctionSetType::FunctionSpaceType FunctionSpaceType
Definition: powerspace.hh:90
static void deleteBlockMapper(BlockMapperType *blockMapper)
Definition: powerspace.hh:115
DiscreteFunctionSpace::GridPartType GridPartType
Definition: powerspace.hh:64
PowerDiscreteFunctionSpaceTraits< DiscreteFunctionSpace, N > Traits
Definition: powerspace.hh:174
Definition: discretefunctionspace.hh:126
static BasisFunctionSetType getBasisFunctionSet(const Entity &entity, const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:134
GridPartType::template Codim< 0 >::IteratorType IteratorType
Definition: powerspace.hh:67
PowerDiscreteFunctionSpace< DiscreteFunctionSpace, NewFunctionSpace::dimRange > Type
Definition: powerspace.hh:211
GridPartType::IntersectionType IntersectionType
Definition: powerspace.hh:69
static void deleteSpaces(DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:128
static BlockMapperType & subBlockMapper(const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:57
Definition: coordinate.hh:4
static const Type & subDiscreteFunctionSpace(const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:52
VectorialBasisFunctionSet< ScalarBasisFunctionSetType, FieldVector< RangeFieldType, N >, VerticalDofAlignment > BasisFunctionSetType
Definition: powerspace.hh:81
Definition: lagrangepointsetexporter.hh:29
static DiscreteFunctionSpaceTupleType createSpaces(GridPartType &gridPart, InterfaceType commInterface, CommunicationDirection commDirection)
Definition: powerspace.hh:121
static bool continuous(const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:139
DiscreteFunctionSpace::template CommDataHandle< DiscreteFunction, Operation >::OperationType OperationType
type of operatation to perform on scatter
Definition: powerspace.hh:105
DiscreteFunctionSpace ContainedDiscreteFunctionSpaceType
type of contained discrete function space
Definition: powerspace.hh:180
ToNewDimRangeFunctionSpace< ScalarFunctionSpaceType, dimRange >::Type FunctionSpaceType
Definition: basisfunctionset/vectorial.hh:265
static constexpr int polynomialOrder
Definition: powerspace.hh:92
IteratorType::Entity EntityType
Definition: powerspace.hh:68
Implementation of DofAlignment.
Definition: basisfunctionset/vectorial.hh:139
GridPartType::IndexSetType IndexSetType
Definition: powerspace.hh:66
static const int codimension
Definition: powerspace.hh:74
Definition: powerspace.hh:29
GridPartType::GridType GridType
Definition: powerspace.hh:65
static BlockMapperType * getBlockMapper(const DiscreteFunctionSpaceTupleType &spaceTuple)
Definition: powerspace.hh:109
DiscreteFunctionSpace * DiscreteFunctionSpaceTupleType
Definition: powerspace.hh:39
Traits::GridPartType GridPartType
Definition: powerspace.hh:177
discrete function space
Builds a vectorial basis function set from given scalar basis function set.
Definition: basisfunctionset/vectorial.hh:250
mapper allocating one DoF per subentity of a given codimension
Definition: powermapper.hh:19
DiscreteFunctionSpace::BasisFunctionSetType ScalarBasisFunctionSetType
implementation of basefunction set
Definition: powerspace.hh:77
Type::BlockMapperType BlockMapperType
Definition: powerspace.hh:49
Definition: common/localrestrictprolong.hh:16
DefaultLocalRestrictProlong(const DiscreteFunctionSpacesType &space)
Definition: powerspace.hh:227
PowerDiscreteFunctionSpace(GridPartType &gridPart, const InterfaceType commInterface=InteriorBorder_All_Interface, const CommunicationDirection commDirection=ForwardCommunication)
constructor
Definition: powerspace.hh:188
DiscreteFunctionSpace::template CommDataHandle< DiscreteFunction, Operation >::Type Type
type of data handle
Definition: powerspace.hh:102
PowerMapper< GridPartType, typename DiscreteFunctionSpace::BlockMapperType, N > BlockMapperType
Definition: powerspace.hh:84
Definition: combinedspace/generic.hh:24
static bool continuous(const IntersectionType &intersection, const DiscreteFunctionSpaceTupleType &tuple)
Definition: powerspace.hh:144
DiscreteFunctionSpace Type
Definition: powerspace.hh:46