1 #ifndef DUNE_FEM_COMBINEDSPACE_POWERMAPPER_HH 2 #define DUNE_FEM_COMBINEDSPACE_POWERMAPPER_HH 4 #include <dune/common/math.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;
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_;
179 :
public DofMapper< T, Dune::Fem::AdaptiveDofMapper >
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_;
203 : BaseType( gridPart, mapper ),
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 >
273 template<
class StreamTraits >
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;
310 #endif // #ifndef DOXYGEN 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 >
358 #endif //#ifndef DUNE_FEM_COMBINEDSPACE_POWERMAPPER_HH PowerMapper(GridPart &gridPart, Mapper &mapper)
Definition: powermapper.hh:334
Extended interface for adaptive DoF mappers.
Definition: mapper/dofmapper.hh:204
Interface for calculating the size of a function space for a grid on a specified level. Furthermore the local to global mapping of dof number is done. Also during grid adaptation this mapper knows about old and new indices of entities.
Definition: mapper/dofmapper.hh:40
Definition: coordinate.hh:4
abstract interface for an input stream
Definition: streams.hh:177
Definition: space/mapper/capabilities.hh:21
mapper allocating one DoF per subentity of a given codimension
Definition: powermapper.hh:19
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1319
abstract interface for an output stream
Definition: streams.hh:44