1 #ifndef DUNE_FEM_DOFMAPPER_INDEXSETDOFMAPPER_HH 2 #define DUNE_FEM_DOFMAPPER_INDEXSETDOFMAPPER_HH 8 #include <dune/geometry/referenceelements.hh> 9 #include <dune/geometry/type.hh> 10 #include <dune/geometry/typeindex.hh> 26 namespace __IndexSetDofMapper
32 template<
class Gr
idPart >
52 typedef Dune::ReferenceElement< typename GridPart::ctype, dimension >
RefElementType;
53 typedef Dune::ReferenceElements< typename GridPart::ctype, dimension >
RefElementsType;
60 : active_(dimension+1),
size_(0)
64 std::vector<bool> &a = active_[c];
65 a.resize( refElement.size( c ), false );
66 if (c<codim)
continue;
67 if (c==codim) { a[subEntity]=
true; ++
size_;
continue; }
68 for (
int i=0;i<refElement.size(subEntity, codim, c);++i)
70 a[refElement.subEntity(subEntity, codim, i, c)] =
true;
75 bool operator()(
int i,
int c)
const {
return active_[c][i]; }
77 std::vector< std::vector< bool > > active_;
80 template<
class Functor >
89 typedef typename GridPartType::template Codim< 0 >::EntityType
ElementType;
91 template<
class CodeFactory >
92 DofMapper (
const GridPartType &gridPart,
const CodeFactory &codeFactory );
115 template<
class Functor >
116 void mapEach (
const ElementType &element, Functor f )
const;
118 void map (
const ElementType &element, std::vector< GlobalKeyType > &indices )
const;
129 void onSubEntity(
const ElementType &element,
int i,
int c, std::vector< bool > &indices )
const;
135 template<
class Entity,
class Functor >
138 template<
class Entity >
139 void mapEntityDofs (
const Entity &entity, std::vector< GlobalKeyType > &indices )
const;
141 template<
class Entity >
175 DUNE_THROW( NotImplemented,
"Method numBlocks() called on non-adaptive block mapper" );
180 DUNE_THROW( NotImplemented,
"Method numberOfHoles() called on non-adaptive block mapper" );
185 DUNE_THROW( NotImplemented,
"Method oldIndex() called on non-adaptive block mapper" );
190 DUNE_THROW( NotImplemented,
"Method newIndex() called on non-adaptive block mapper" );
195 DUNE_THROW( NotImplemented,
"Method oldOffSet() called on non-adaptive block mapper" );
200 DUNE_THROW( NotImplemented,
"Method offSet() called on non-adaptive block mapper" );
212 template<
class Entity >
231 template<
class Gr
idPart >
238 template<
class Iterator >
239 void operator() (
unsigned int gtIndex,
unsigned int subEntity, Iterator it, Iterator end )
242 const unsigned int numDofs = end - it;
245 else if( info.
numDofs != numDofs )
246 DUNE_THROW(
DofMapperError,
"Inconsistent number of DoFs on subEntity (codim = " << info.
codim <<
")." );
259 template<
class Gr
idPart >
260 template<
class Functor >
263 static const bool isCartesian = Dune::Capabilities::
264 isCartesian< typename GridPart :: GridType > :: v ;
278 template<
class Iterator >
279 void operator() (
unsigned int gtIndex,
unsigned int subEntity, Iterator it, Iterator end )
281 enum {
dimension = GridPart :: dimension };
284 const SizeType subIndex = indexSet_.subIndex( element_, subEntity, info.
codim );
293 if( ! isCartesian && codim ==
dimension-1 && numDofs > 1 )
295 typedef typename GridPart::ctype FieldType ;
296 const Dune::ReferenceElement< FieldType, dimension > &refElem
297 = Dune::ReferenceElements< FieldType, dimension >::general( element_.type() );
300 const int vxSize = refElem.size( subEntity, codim,
dimension );
302 assert( vxSize == 2 );
304 const int vx[ 2 ] = { refElem.subEntity ( subEntity, codim, 0,
dimension ),
305 refElem.subEntity ( subEntity, codim, 1,
dimension ) };
311 std::vector< unsigned int > global( numDofs );
312 std::vector< unsigned int > local ( numDofs );
314 unsigned int count = 0 ;
317 global[ count ] = index++;
318 local [ count ] = *(it++);
322 unsigned int reverse = numDofs - 1;
323 for(
unsigned int i=0; i<
numDofs; ++ i, --reverse )
325 functor_( local[ i ], global[ reverse ] );
336 functor_( *(it++), index++ );
348 template<
class Gr
idPart >
351 static const bool isCartesian = Dune::Capabilities::
352 isCartesian< typename GridPart :: GridType > :: v ;
356 std::vector<bool> &vec )
364 template<
class Iterator >
365 void operator() (
unsigned int gtIndex,
unsigned int subEntity, Iterator it, Iterator end )
367 enum {
dimension = GridPart :: dimension };
375 bool active = filter_(subEntity,codim);
379 if( ! isCartesian && codim ==
dimension-1 && numDofs > 1 )
381 typedef typename GridPart::ctype FieldType ;
382 const Dune::ReferenceElement< FieldType, dimension > &refElem
383 = Dune::ReferenceElements< FieldType, dimension >::general( element_.type() );
386 const int vxSize = refElem.size( subEntity, codim,
dimension );
388 assert( vxSize == 2 );
390 const int vx[ 2 ] = { refElem.subEntity ( subEntity, codim, 0,
dimension ),
391 refElem.subEntity ( subEntity, codim, 1,
dimension ) };
397 std::vector< unsigned int > global( numDofs );
398 std::vector< unsigned int > local ( numDofs );
400 unsigned int count = 0 ;
403 local [ count ] = *(it++);
407 unsigned int reverse = numDofs - 1;
408 for(
unsigned int i=0; i<
numDofs; ++ i, --reverse )
410 vec_[ local[i] ] = active;
421 vec_[ *(it++) ] = active;
429 std::vector<bool> &vec_;
436 template<
class Gr
idPart >
439 template<
class Gr
idPart >
440 template<
class CodeFactory >
448 std::vector< GeometryType > gt( GlobalGeometryTypeIndex::size(
dimension ) );
450 const typename RefElementsType::Iterator end = RefElementsType::end();
451 for(
typename RefElementsType::Iterator it = RefElementsType::begin(); it != end; ++it )
457 for(
int i = 0; i < refElement.size(
codim ); ++i )
459 const unsigned int gtIdx = GlobalGeometryTypeIndex::index( refElement.type( i,
codim ) );
460 gt[ gtIdx ] = refElement.type( i,
codim );
466 code = codeFactory( refElement );
494 template<
class Gr
idPart >
495 template<
class Functor >
503 template<
class Gr
idPart >
507 indices.resize(
numDofs( element ) );
511 template<
class Gr
idPart >
512 template<
class Entity,
class Functor >
519 for(
unsigned int i = 0; i < info.
numDofs; ++i )
524 template<
class Gr
idPart >
525 template<
class Entity >
533 template<
class Gr
idPart >
541 template<
class Gr
idPart >
542 template<
class Entity >
551 template<
class Gr
idPart >
555 for(
typename BlockMapType::const_iterator it =
blockMap_.begin(); it !=
blockMap_.end(); ++it )
565 template<
class Gr
idPart >
569 return code_[ LocalGeometryTypeIndex::index( gt ) ];
573 template<
class Gr
idPart >
574 template<
class Entity >
578 return subEntityInfo_[ GlobalGeometryTypeIndex::index( entity.type() ) ];
586 template<
class Gr
idPart >
600 using BaseType::update;
602 template<
class CodeFactory >
604 : BaseType( gridPart, codeFactory )
616 ThisType &operator= (
const ThisType & ) =
delete;
621 SizeType
offSet (
int blk )
const;
626 SizeType
oldIndex ( SizeType hole,
int blk )
const;
627 SizeType
newIndex ( SizeType hole,
int blk )
const;
633 template<
class Entity >
636 template<
class Entity >
643 template <
class StreamTraits>
646 template <
class StreamTraits>
656 using BaseType::indexSet;
658 using BaseType::blockMap_;
659 using BaseType::gridPart_;
660 using BaseType::subEntityInfo_;
668 template<
class Gr
idPart >
672 assert( (blk >= 0) && (blk <
numBlocks()) );
673 const unsigned int gtIdx = GlobalGeometryTypeIndex::index(
blockMap_[ blk ] );
678 template<
class Gr
idPart >
682 assert( (blk >= 0) && (blk <
numBlocks()) );
683 const unsigned int gtIdx = GlobalGeometryTypeIndex::index(
blockMap_[ blk ] );
688 template<
class Gr
idPart >
692 assert( (blk >= 0) && (blk <
numBlocks()) );
693 const unsigned int gtIdx = GlobalGeometryTypeIndex::index(
blockMap_[ blk ] );
699 template<
class Gr
idPart >
704 const unsigned int gtIdx = GlobalGeometryTypeIndex::index(
blockMap_[ blk ] );
712 template<
class Gr
idPart >
717 const unsigned int gtIdx = GlobalGeometryTypeIndex::index(
blockMap_[ blk ] );
729 template< class GridPart, bool adaptive = Capabilities::isAdaptiveIndexSet< typename GridPart::IndexSetType >::v >
742 template<
class Gr
idPart >
744 :
public __IndexSetDofMapper::template Implementation< GridPart >::Type
751 template<
class CodeFactory >
753 : BaseType( gridPart, codeFactory )
761 namespace Capabilities
766 template<
class Gr
idPart >
778 #endif //#ifndef DUNE_FEM_DOFMAPPER_INDEXSETDOFMAPPER_HH Definition: indexsetdofmapper.hh:587
BaseType::GridPartType GridPartType
Definition: indexsetdofmapper.hh:749
bool compress()
Definition: indexsetdofmapper.hh:641
Definition: indexsetdofmapper.hh:730
SizeType size_
Definition: indexsetdofmapper.hh:220
MapFunctor(const GridPart &gridPart, const std::vector< SubEntityInfo > &subEntityInfo, const ElementType &element, Functor functor)
Definition: indexsetdofmapper.hh:266
std::vector< GeometryType > BlockMapType
Definition: indexsetdofmapper.hh:207
bool consecutive() const
Definition: indexsetdofmapper.hh:631
SizeType newIndex(SizeType hole, int blk) const
Definition: indexsetdofmapper.hh:714
void read(InStreamInterface< StreamTraits > &in)
Definition: indexsetdofmapper.hh:647
SizeType offSet(int) const
Definition: indexsetdofmapper.hh:198
SubEntityInfo()
Definition: indexsetdofmapper.hh:41
void removeEntity(const Entity &entity)
Definition: indexsetdofmapper.hh:637
void insertEntity(const Entity &entity)
Definition: indexsetdofmapper.hh:634
Definition: indexsetdofmapper.hh:349
DofMapper(const GridPartType &gridPart, const CodeFactory &codeFactory)
Definition: indexsetdofmapper.hh:442
static constexpr T max(T a)
Definition: utility.hh:65
SizeType size() const
Definition: indexsetdofmapper.hh:150
int numBlocks() const
Definition: indexsetdofmapper.hh:620
unsigned int numEntityDofs(const Entity &entity) const
Definition: indexsetdofmapper.hh:545
SizeType oldOffset
Definition: indexsetdofmapper.hh:47
SubEntityFilter(const RefElementType &refElement, int subEntity, int codim)
Definition: indexsetdofmapper.hh:59
static const int dimension
Definition: indexsetdofmapper.hh:51
unsigned int maxNumDofs_
Definition: indexsetdofmapper.hh:219
bool operator()(int i, int c) const
Definition: indexsetdofmapper.hh:75
Dune::ReferenceElements< typename GridPart::ctype, dimension > RefElementsType
Definition: indexsetdofmapper.hh:53
GlobalKeyType newIndex(int hole, int) const
Definition: indexsetdofmapper.hh:188
void restore()
Definition: indexsetdofmapper.hh:653
GridPart GridPartType
Definition: indexsetdofmapper.hh:87
GridPartType::IndexSetType IndexSetType
Definition: indexsetdofmapper.hh:206
void backup() const
Definition: indexsetdofmapper.hh:652
Definition: indexsetdofmapper.hh:50
std::size_t SizeType
Definition: indexsetdofmapper.hh:37
Definition: misc/functor.hh:30
const DofMapperCode & code(const GeometryType >) const
Definition: indexsetdofmapper.hh:567
SizeType oldOffSet(int blk) const
Definition: indexsetdofmapper.hh:680
GridPartType::template Codim< 0 >::EntityType ElementType
Definition: indexsetdofmapper.hh:89
unsigned int numDofs
Definition: indexsetdofmapper.hh:46
BuildFunctor(std::vector< SubEntityInfo > &subEntityInfo)
Definition: indexsetdofmapper.hh:234
Definition: indexsetdofmapper.hh:33
Definition: coordinate.hh:4
GlobalKeyType oldIndex(int hole, int) const
Definition: indexsetdofmapper.hh:183
SizeType offSet(int blk) const
Definition: indexsetdofmapper.hh:670
specialize with true if index set implements the interface for adaptive index sets ...
Definition: common/indexset.hh:69
abstract interface for an input stream
Definition: streams.hh:177
Definition: indexsetdofmapper.hh:57
void onSubEntity(const ElementType &element, int i, int c, std::vector< bool > &indices) const
fills a vector of bools with true indicating that the corresponding local degree of freedom is attach...
Definition: indexsetdofmapper.hh:535
std::vector< SubEntityInfo > subEntityInfo_
Definition: indexsetdofmapper.hh:221
SizeType oldIndex(SizeType hole, int blk) const
Definition: indexsetdofmapper.hh:701
Definition: indexsetdofmapper.hh:50
std::conditional< adaptive, AdaptiveDofMapper< GridPart >, DofMapper< GridPart > >::type Type
Definition: indexsetdofmapper.hh:732
SizeType numBlocks() const
Definition: indexsetdofmapper.hh:173
void mapEachEntityDof(const Entity &entity, Functor f) const
Definition: indexsetdofmapper.hh:514
Definition: indexsetdofmapper.hh:50
BlockMapType blockMap_
Definition: indexsetdofmapper.hh:222
SizeType oldOffSet(int) const
Definition: indexsetdofmapper.hh:193
BaseType::SizeType SizeType
Definition: indexsetdofmapper.hh:598
SizeType numberOfHoles(int) const
Definition: indexsetdofmapper.hh:178
AdaptiveDofMapper(const GridPartType &gridPart, const CodeFactory &codeFactory)
Definition: indexsetdofmapper.hh:603
void resize()
Definition: indexsetdofmapper.hh:639
void write(OutStreamInterface< StreamTraits > &out) const
Definition: indexsetdofmapper.hh:644
SizeType numberOfHoles(int blk) const
Definition: indexsetdofmapper.hh:690
BaseType::SubEntityInfo SubEntityInfo
Definition: indexsetdofmapper.hh:594
const GridEntityAccess< Entity >::GridEntityType & gridEntity(const Entity &entity)
Definition: gridpart.hh:410
const DofMapperCode & code(const ElementType &element) const
Definition: indexsetdofmapper.hh:210
BaseType::GridPartType GridPartType
Definition: indexsetdofmapper.hh:597
Definition: indexsetdofmapper.hh:81
bool contains(int codim) const
Definition: indexsetdofmapper.hh:146
IndexSetDofMapper(const GridPartType &gridPart, const CodeFactory &codeFactory)
Definition: indexsetdofmapper.hh:752
SizeType offset
Definition: indexsetdofmapper.hh:47
void update()
Definition: indexsetdofmapper.hh:552
CodimType
Definition: indexsetdofmapper.hh:50
Definition: space/mapper/capabilities.hh:21
const GridPartType & gridPart_
Definition: indexsetdofmapper.hh:217
unsigned int numDofs() const
Definition: code.hh:92
unsigned int maxNumDofs() const
Definition: indexsetdofmapper.hh:131
Definition: indexsetdofmapper.hh:743
CodimType codimType_[dimension+1]
Definition: indexsetdofmapper.hh:223
unsigned int numDofs(const ElementType &element) const
Definition: indexsetdofmapper.hh:132
Definition: indexsetdofmapper.hh:39
const IndexSetType & indexSet() const
Definition: indexsetdofmapper.hh:215
const SubEntityInfo & subEntityInfo(const Entity &entity) const
Definition: indexsetdofmapper.hh:576
std::vector< DofMapperCode > code_
Definition: indexsetdofmapper.hh:218
~AdaptiveDofMapper()
Definition: indexsetdofmapper.hh:611
void mapEach(const ElementType &element, Functor f) const
map each local DoF number to a global one
Definition: indexsetdofmapper.hh:497
bool fixedDataSize(int codim) const
Definition: indexsetdofmapper.hh:148
Definition: space/mapper/exceptions.hh:12
void map(const ElementType &element, std::vector< GlobalKeyType > &indices) const
Definition: indexsetdofmapper.hh:505
Definition: indexsetdofmapper.hh:232
SubEntityFilterFunctor(const GridPart &gridPart, const std::vector< SubEntityInfo > &subEntityInfo, const ElementType &element, int i, int c, std::vector< bool > &vec)
Definition: indexsetdofmapper.hh:354
static constexpr bool consecutive() noexcept
Definition: indexsetdofmapper.hh:171
unsigned int codim
Definition: indexsetdofmapper.hh:45
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1319
SizeType GlobalKeyType
Definition: indexsetdofmapper.hh:82
void mapEntityDofs(const Entity &entity, std::vector< GlobalKeyType > &indices) const
Definition: indexsetdofmapper.hh:527
abstract interface for an output stream
Definition: streams.hh:44
Dune::ReferenceElement< typename GridPart::ctype, dimension > RefElementType
Definition: indexsetdofmapper.hh:52