1#ifndef DUNE_FEM_COMBINEDSPACE_POWERMAPPER_HH
2#define DUNE_FEM_COMBINEDSPACE_POWERMAPPER_HH
6#include <dune/fem/gridpart/common/indexset.hh>
7#include <dune/fem/space/common/dofmanager.hh>
8#include <dune/fem/space/mapper/dofmapper.hh>
18 template<
class Gr
idPart,
class Mapper,
int N >
23 namespace __PowerMapper
29 template<
class Gr
idPart,
class Mapper,
int N >
32 typedef Mapper MapperType;
34 typedef GridPart GridPartType;
36 typedef typename MapperType::ElementType ElementType;
37 typedef typename MapperType::SizeType SizeType;
38 typedef typename MapperType::GlobalKeyType GlobalKeyType;
40 typedef PowerMapper< GridPartType, MapperType, N > DofMapperType;
42 static const int numComponents = N;
51 typedef Base< T > BaseType;
54 typedef typename BaseType::Traits Traits;
55 typedef typename BaseType::ElementType ElementType;
56 typedef typename BaseType::SizeType SizeType;
58 typedef typename Traits::GridPartType GridPartType;
59 typedef typename Traits::GlobalKeyType GlobalKeyType;
61 typedef typename Traits::MapperType MapperType;
63 static const int numComponents = Traits::numComponents;
67 template<
class Functor >
70 FunctorWrapper ( SizeType offset, Functor functor )
75 template<
class GlobalKey >
76 void operator() (
int localBlock,
const GlobalKey &globalKey )
78 int localDof = localBlock*numComponents;
79 for(
int component = 0; component < numComponents; ++component, ++localDof )
80 functor_( localDof, globalKey + component * offset_ );
83 template<
class GlobalKey >
84 void operator() (
const GlobalKey &globalKey )
86 for(
int component = 0; component < numComponents; ++component )
87 functor_( globalKey + component * offset_ );
97 DofMapper ( GridPartType &gridPart, MapperType &mapper )
98 : gridPart_( gridPart ),
100 offset_( mapper_.
size() )
103 SizeType
size ()
const {
return mapper().size() * numComponents; }
105 bool contains (
const int codim )
const {
return mapper().contains( codim ); }
107 bool fixedDataSize (
const int codim )
const {
return mapper().fixedDataSize( codim ); }
109 template<
class Functor >
110 void mapEach (
const ElementType &element, Functor f )
const
112 FunctorWrapper< Functor > wrapper( offset_, f );
113 mapper().mapEach( element, wrapper );
116 template<
class Entity,
class Functor >
117 void mapEachEntityDof (
const Entity &entity, Functor f )
const
119 FunctorWrapper< Functor > wrapper( offset_, f );
120 mapper().mapEachEntityDof( entity, wrapper );
123 int maxNumDofs ()
const {
return mapper().maxNumDofs() * numComponents; }
125 SizeType numDofs (
const ElementType &element )
const {
return mapper().numDofs( element ) * numComponents; }
127 template<
class Entity >
128 SizeType numEntityDofs (
const Entity &entity )
const {
return mapper().numEntityDofs( entity ) * numComponents; }
131 static constexpr bool consecutive () noexcept {
return false; }
133 SizeType numBlocks ()
const
135 DUNE_THROW( NotImplemented,
"Method numBlocks() called on non-adaptive block mapper" );
138 SizeType numberOfHoles (
int )
const
140 DUNE_THROW( NotImplemented,
"Method numberOfHoles() called on non-adaptive block mapper" );
143 GlobalKeyType oldIndex (
int hole,
int )
const
145 DUNE_THROW( NotImplemented,
"Method oldIndex() called on non-adaptive block mapper" );
148 GlobalKeyType newIndex (
int hole,
int )
const
150 DUNE_THROW( NotImplemented,
"Method newIndex() called on non-adaptive block mapper" );
153 SizeType oldOffSet (
int )
const
155 DUNE_THROW( NotImplemented,
"Method oldOffSet() called on non-adaptive block mapper" );
158 SizeType offSet (
int )
const
160 DUNE_THROW( NotImplemented,
"Method offSet() called on non-adaptive block mapper" );
164 MapperType &mapper () {
return mapper_; }
165 const MapperType &mapper ()
const {
return mapper_; }
167 GridPartType &gridPart_;
178 class AdaptiveDofMapper
179 :
public DofMapper< T, Dune::Fem::AdaptiveDofMapper >
181 typedef DofMapper< T, Dune::Fem::AdaptiveDofMapper > BaseType;
184 typedef typename BaseType::Traits Traits;
185 typedef typename BaseType::ElementType ElementType;
186 typedef typename BaseType::SizeType SizeType;
188 typedef typename Traits::GridPartType GridPartType;
189 typedef typename Traits::GlobalKeyType GlobalKeyType;
191 typedef typename Traits::MapperType MapperType;
193 static const int numComponents = Traits::numComponents;
196 using BaseType::mapper;
197 using BaseType::gridPart_;
198 using BaseType::offset_;
202 AdaptiveDofMapper ( GridPartType &gridPart, MapperType &mapper )
203 : BaseType( gridPart, mapper ),
209 ~AdaptiveDofMapper ()
214 bool consecutive ()
const {
return true; }
216 SizeType numBlocks ()
const {
return mapper().numBlocks() * numComponents; }
218 SizeType numberOfHoles (
const int block )
const {
return mapper().numberOfHoles( block % mapper().numBlocks() ); }
220 GlobalKeyType oldIndex (
const int hole,
const int block )
const
222 const int numContainedBlocks = mapper().numBlocks();
223 const int containedBlock = block % numContainedBlocks;
224 const int component = block / numContainedBlocks;
226 const int containedOffset = mapper().oldIndex( hole, containedBlock );
227 return containedOffset + component * oldOffset_;
230 GlobalKeyType newIndex (
const int hole,
const int block )
const
232 const int numContainedBlocks = mapper().numBlocks();
233 const int containedBlock = block % numContainedBlocks;
234 const int component = block / numContainedBlocks;
236 const int containedOffset = mapper().newIndex( hole, containedBlock );
237 return containedOffset + component * offset_;
240 SizeType oldOffSet (
const int block )
const
242 const int numContainedBlocks = mapper().numBlocks();
243 const int containedBlock = block % numContainedBlocks;
244 const int component = block / numContainedBlocks;
246 const int containedOffset = mapper().oldOffSet( containedBlock );
247 return containedOffset + component * oldOffset_;
250 SizeType offSet (
const int block )
const
252 const int numContainedBlocks = mapper().numBlocks();
253 const int containedBlock = block % numContainedBlocks;
254 const int component = block / numContainedBlocks;
256 const int containedOffset = mapper().offSet( containedBlock );
257 return containedOffset + component * offset_;
260 template<
class Entity >
261 void insertEntity (
const Entity &entity ) { update(); }
263 template<
class Entity >
264 void removeEntity (
const Entity &entity ) { }
266 void resize () { update(); }
268 bool compress () { update();
return true; }
270 template<
class StreamTraits >
271 void write ( OutStreamInterface< StreamTraits > &out )
const {}
273 template<
class StreamTraits >
274 void read ( InStreamInterface< StreamTraits > &in )
279 void backup ()
const {}
285 oldOffset_ = offset_;
286 offset_ = mapper().size();
297 template< class GridPart, class Mapper, int N, bool adapative = Capabilities::isAdaptiveDofMapper< Mapper >::v >
300 typedef __PowerMapper::Traits< GridPart, Mapper, N > Traits;
303 typedef typename std::conditional< adapative, AdaptiveDofMapper< Traits >, DofMapper< Traits > >::type Type;
327 template<
class Gr
idPart,
class Mapper,
int N >
329 :
public __PowerMapper::template Implementation< GridPart, Mapper, N >::Type
331 typedef typename __PowerMapper::template Implementation< GridPart, Mapper, N >::Type BaseType;
335 : BaseType( gridPart, mapper )
343 namespace Capabilities
345 template<
class Gr
idPart,
class Mapper,
int N >
348 static const bool v = isAdaptiveDofMapper< Mapper >::v;
351 template<
class Gr
idPart,
class Mapper,
int N >
352 struct isConsecutiveIndexSet< __PowerMapper::AdaptiveDofMapper< __PowerMapper::Traits< GridPart, Mapper, N > > >
354 static const bool v =
true;
Interface for calculating the size of a function space for a grid on a specified level....
Definition: dofmapper.hh:43
mapper allocating one DoF per subentity of a given codimension
Definition: powermapper.hh:330
Mapper interface.
Definition: mapper.hh:110
void removeIndexSet(const IndexSetType &iset)
removed index set from dof manager's list of index sets
Definition: dofmanager.hh:1331
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1251
void addIndexSet(const IndexSetType &iset)
add index set to dof manager's list of index sets
Definition: dofmanager.hh:1296
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137