1#ifndef DUNE_FEM_CODIMINDEXSET_HH
2#define DUNE_FEM_CODIMINDEXSET_HH
7#include <dune/grid/utility/persistentcontainer.hh>
8#include <dune/grid/utility/persistentcontainervector.hh>
9#include <dune/grid/utility/persistentcontainerwrapper.hh>
10#include <dune/grid/utility/persistentcontainermap.hh>
27 template <
class Gr
idImp>
35 enum INDEXSTATE { UNUSED = 0,
83 const double memoryFactor = 1.1)
130 std::set< int > found ;
132 typedef typename IndexContainerType::Iterator Iterator;
135 for( Iterator it =
leafIndex_.begin(); it != end; ++it )
139 if( found.find( *it ) != found.end() )
141 std::cout <<
"index " << *it <<
" exists twice " << std::endl;
143 assert( found.find( *it ) == found.end() );
171 bool haveToCopy =
false;
183 const int actSize = sizeOfVecs - actHole;
194 typedef typename IndexContainerType::Iterator Iterator;
196 for( Iterator it =
leafIndex_.begin(); it != end; ++it )
213 if(
index >= actSize )
220 assert(actHole >= 0);
221 while (
holes_[actHole] >= actSize )
224 if(actHole < 0)
break;
227 assert(actHole >= 0);
256 for(
int hole = 0; hole < holes; ++hole )
271 for(
int i=0; i<actSize; ++i )
295 template <
class EntityType>
298 assert(
myCodim_ == EntityType :: codimension );
304 template <
class EntityType>
306 const int subNumber )
const
309 std::integral_constant<bool, EntityType::codimension == 0 > () );
313 template <
class EntityType>
316 const std::integral_constant<bool,false> codim0 )
const
318 DUNE_THROW(NotImplemented,
"CodimIndexSet::subIndex: not implemented for entities with codim > 0" );
323 template <
class EntityType>
326 const std::integral_constant<bool,true> codim0 )
const
333 template <
class EntityType>
334 bool exists (
const EntityType& entity )
const
336 assert(
myCodim_ == EntityType :: codimension );
344 template <
class EntityType>
346 const int subNumber )
const
348 assert( 0 == EntityType :: codimension );
377 template <
class EntityType>
380 assert(
myCodim_ == EntityType :: codimension );
385 template <
class EntityType>
389 assert( 0 == EntityType :: codimension );
394 template <
class EntityType>
397 assert(
myCodim_ == EntityType :: codimension );
409 template <
class EntityType>
412 assert(
myCodim_ == EntityType :: codimension );
419 template <
class EntityType>
422 assert(
myCodim_ == EntityType :: codimension );
428 typedef typename IndexContainerType::ConstIterator Iterator;
430 for( Iterator it =
leafIndex_.begin(); it != end; ++it )
435 out <<
"idx: " << leafIdx <<
" stat: " <<
indexState_[ leafIdx ] << std::endl;
445 assert( idx <
size() );
463 template <
class StreamTraits>
478 typedef typename IndexContainerType::ConstIterator ConstIterator;
480 for( ConstIterator it =
leafIndex_.begin(); it != end; ++it )
487 template <
class StreamTraits>
499 uint64_t storedSize = 0;
504 if( storedSize < leafsize )
506 DUNE_THROW(InvalidStateException,
"CodimIndexSet: size consistency check failed during restore!");
510 typedef typename IndexContainerType::Iterator Iterator;
513 for( Iterator it =
leafIndex_.begin(); it != end; ++it, ++count )
517 if( count < storedSize )
520 const uint64_t leftOver = storedSize - count ;
521 for( uint64_t i = 0; i < leftOver; ++i )
Definition: bindguard.hh:11
Definition: codimindexset.hh:29
DynamicArray< INDEXSTATE > IndexStateArrayType
Definition: codimindexset.hh:52
void setMemoryFactor(const double memoryFactor)
set memory overestimation factor
Definition: codimindexset.hh:98
bool exists(const EntityType &entity, const int subNumber) const
Definition: codimindexset.hh:345
IndexType additionalSizeEstimate() const
return how much extra memory is needed for restriction
Definition: codimindexset.hh:282
DynamicArray< IndexType > IndexArrayType
Definition: codimindexset.hh:51
IndexType subIndex(const EntityType &entity, const int subNumber, const std::integral_constant< bool, false > codim0) const
return leaf index for given entity
Definition: codimindexset.hh:314
void insert(const EntityType &entity)
Definition: codimindexset.hh:378
IndexType oldIndex(int elNum) const
return old index, for dof manager only
Definition: codimindexset.hh:363
void markForRemoval(const EntityType &entity)
Definition: codimindexset.hh:410
IndexType numberOfHoles() const
return number of holes
Definition: codimindexset.hh:357
void insertGhost(const EntityType &entity)
Definition: codimindexset.hh:395
bool read(InStreamInterface< StreamTraits > &in)
Definition: codimindexset.hh:488
const int myCodim_
Definition: codimindexset.hh:73
bool write(OutStreamInterface< StreamTraits > &out) const
Definition: codimindexset.hh:464
void insertSubEntity(const EntityType &entity, const int subNumber)
Definition: codimindexset.hh:386
IndexType size() const
return size of grid entities per level and codim
Definition: codimindexset.hh:285
void resetUsed()
set all entries to unused
Definition: codimindexset.hh:123
IndexArrayType holes_
Definition: codimindexset.hh:62
CodimIndexSet< GridType > ThisType
Definition: codimindexset.hh:32
IndexStateArrayType indexState_
Definition: codimindexset.hh:59
GridImp GridType
Definition: codimindexset.hh:31
CodimIndexSet(const GridType &grid, const int codim, const double memoryFactor=1.1)
Constructor taking memory factor (default = 1.1)
Definition: codimindexset.hh:81
IndexType subIndex(const EntityType &entity, const int subNumber, const std::integral_constant< bool, true > codim0) const
return leaf index for given entity
Definition: codimindexset.hh:324
bool compress()
Definition: codimindexset.hh:165
bool exists(const EntityType &entity) const
return state of index for given hierarchic number
Definition: codimindexset.hh:334
IndexArrayType newIdx_
Definition: codimindexset.hh:67
int IndexType
Definition: codimindexset.hh:44
bool checkValidIndex(const IndexType &idx) const
Definition: codimindexset.hh:442
void insertIdx(IndexType &index)
Definition: codimindexset.hh:450
IndexType numberHoles_
Definition: codimindexset.hh:76
bool consecutive()
Definition: codimindexset.hh:128
IndexArrayType oldIdx_
Definition: codimindexset.hh:66
void print(std::ostream &out) const
Definition: codimindexset.hh:426
IndexContainerType leafIndex_
Definition: codimindexset.hh:58
IndexType realSize() const
return size of grid entities per level and codim
Definition: codimindexset.hh:288
void prepareCompress()
prepare for setup (nothing to do here)
Definition: codimindexset.hh:110
IndexType subIndex(const EntityType &entity, const int subNumber) const
return leaf index for given entity
Definition: codimindexset.hh:305
void clear()
clear set
Definition: codimindexset.hh:114
void resize()
reallocate the vectors
Definition: codimindexset.hh:107
void checkConsecutive()
set all entries to unused
Definition: codimindexset.hh:152
void clearHoles()
clear holes, i.e. set number of holes to zero
Definition: codimindexset.hh:155
bool validIndex(const EntityType &entity) const
Definition: codimindexset.hh:420
PersistentContainer< GridType, IndexType > IndexContainerType
Definition: codimindexset.hh:55
IndexType index(const EntityType &entity) const
return leaf index for given entity
Definition: codimindexset.hh:296
IndexType newIndex(int elNum) const
return new index, for dof manager only returns index
Definition: codimindexset.hh:370
IndexType lastSize_
Definition: codimindexset.hh:70
static IndexType invalidIndex()
Definition: codimindexset.hh:47
abstract interface for an output stream
Definition: streams.hh:46
abstract interface for an input stream
Definition: streams.hh:179
size_type size() const
return size of array
Definition: dynamicarray.hh:170
void setMemoryFactor(double memFactor)
set memory factor
Definition: dynamicarray.hh:296
void resize(size_type nsize)
Definition: dynamicarray.hh:334