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
308 assert( 0 == EntityType :: codimension );
314 template <
class EntityType>
315 bool exists (
const EntityType& entity )
const
317 assert(
myCodim_ == EntityType :: codimension );
325 template <
class EntityType>
327 const int subNumber )
const
329 assert( 0 == EntityType :: codimension );
358 template <
class EntityType>
361 assert(
myCodim_ == EntityType :: codimension );
366 template <
class EntityType>
370 assert( 0 == EntityType :: codimension );
375 template <
class EntityType>
378 assert(
myCodim_ == EntityType :: codimension );
390 template <
class EntityType>
393 assert(
myCodim_ == EntityType :: codimension );
400 template <
class EntityType>
403 assert(
myCodim_ == EntityType :: codimension );
407 void print( std::ostream& out )
const
409 typedef typename IndexContainerType::ConstIterator Iterator;
411 for( Iterator it =
leafIndex_.begin(); it != end; ++it )
414 out <<
"idx: " << leafIdx <<
" stat: " <<
indexState_[ leafIdx ] << std::endl;
423 assert( idx <
size() );
441 template <
class StreamTraits>
456 typedef typename IndexContainerType::ConstIterator ConstIterator;
458 for( ConstIterator it =
leafIndex_.begin(); it != end; ++it )
465 template <
class StreamTraits>
477 uint64_t storedSize = 0;
482 if( storedSize < leafsize )
484 DUNE_THROW(InvalidStateException,
"CodimIndexSet: size consistency check failed during restore!");
488 typedef typename IndexContainerType::Iterator Iterator;
491 for( Iterator it =
leafIndex_.begin(); it != end; ++it, ++count )
495 if( count < storedSize )
498 const uint64_t leftOver = storedSize - count ;
499 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:326
IndexType additionalSizeEstimate() const
return how much extra memory is needed for restriction
Definition: codimindexset.hh:282
DynamicArray< IndexType > IndexArrayType
Definition: codimindexset.hh:51
void insert(const EntityType &entity)
Definition: codimindexset.hh:359
IndexType oldIndex(int elNum) const
return old index, for dof manager only
Definition: codimindexset.hh:344
void markForRemoval(const EntityType &entity)
Definition: codimindexset.hh:391
IndexType numberOfHoles() const
return number of holes
Definition: codimindexset.hh:338
void insertGhost(const EntityType &entity)
Definition: codimindexset.hh:376
bool read(InStreamInterface< StreamTraits > &in)
Definition: codimindexset.hh:466
const int myCodim_
Definition: codimindexset.hh:73
bool write(OutStreamInterface< StreamTraits > &out) const
Definition: codimindexset.hh:442
void insertSubEntity(const EntityType &entity, const int subNumber)
Definition: codimindexset.hh:367
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
bool compress()
Definition: codimindexset.hh:165
bool exists(const EntityType &entity) const
return state of index for given hierarchic number
Definition: codimindexset.hh:315
IndexArrayType newIdx_
Definition: codimindexset.hh:67
int IndexType
Definition: codimindexset.hh:44
bool checkValidIndex(const IndexType &idx) const
Definition: codimindexset.hh:420
void insertIdx(IndexType &index)
Definition: codimindexset.hh:428
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:407
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:401
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:351
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:164
void setMemoryFactor(double memFactor)
set memory factor
Definition: dynamicarray.hh:290
void resize(size_type nsize)
Definition: dynamicarray.hh:328