1#ifndef DUNE_FEM_DOFMANAGER_HH
2#define DUNE_FEM_DOFMANAGER_HH
13#include <dune/alugrid/common/interfaces.hh>
16#include <dune/fem/gridpart/common/indexset.hh>
17#include <dune/fem/io/parameter.hh>
18#include <dune/fem/io/streams/standardstreams.hh>
19#include <dune/fem/misc/gridobjectstreams.hh>
20#include <dune/fem/misc/mpimanager.hh>
21#include <dune/fem/space/common/datacollector.hh>
22#include <dune/fem/space/common/restrictprolonginterface.hh>
23#include <dune/fem/space/mapper/dofmapper.hh>
24#include <dune/fem/storage/dynamicarray.hh>
25#include <dune/fem/storage/singletonlist.hh>
29#include <dune/alugrid/common/ldbhandleif.hh>
44 template <
class Gr
idType>
class DofManager;
45 template <
class DofManagerImp>
class DofManagerFactory;
63 typedef const void * IdentifierType;
65 IdentifierType setPtr_;
67 size_t referenceCounter_;
69 template<
class IndexSet >
71 : setPtr_( getIdentifier( iset ) ),
72 referenceCounter_( 1 )
99 return (--referenceCounter_ == 0);
102 template<
class IndexSet >
103 bool equals (
const IndexSet &iset )
const
105 return (getIdentifier( iset ) == setPtr_);
109 template<
class IndexSet >
110 IdentifierType getIdentifier (
const IndexSet &iset )
const
112 return static_cast< IdentifierType
>( &iset );
116 template <
class IndexSetType,
class EntityType>
class RemoveIndicesFromSet;
117 template <
class IndexSetType,
class EntityType>
class InsertIndicesToSet;
119 template <
class IndexSetType,
class EntityType>
120 class ManagedIndexSet :
121 public ManagedIndexSetInterface ,
122 public LocalInlinePlus < ManagedIndexSet<IndexSetType,EntityType> , EntityType >
124 typedef LocalInterface<EntityType> LocalIndexSetObjectsType;
126 static const bool isConsecutive =
127 Capabilities::isConsecutiveIndexSet<IndexSetType>::v;
131 IndexSetType & indexSet_;
134 InsertIndicesToSet <IndexSetType, EntityType> insertIdxObj_;
135 RemoveIndicesFromSet <IndexSetType, EntityType> removeIdxObj_;
137 LocalIndexSetObjectsType & insertList_;
138 LocalIndexSetObjectsType & removeList_;
146 LocalIndexSetObjectsType & insertList,
147 LocalIndexSetObjectsType & removeList )
149 , indexSet_ (const_cast<IndexSetType &> (iset))
150 , insertIdxObj_(indexSet_), removeIdxObj_(indexSet_)
151 , insertList_(insertList)
152 , removeList_(removeList)
154 this->setPtr_ = (
void *) &indexSet_;
156 if constexpr ( isConsecutive )
158 insertList_ += insertIdxObj_;
159 removeList_ += removeIdxObj_;
166 if constexpr ( isConsecutive )
168 insertList_.remove( insertIdxObj_ );
169 removeList_.remove( removeIdxObj_ );
182 return indexSet_.compress();
186 virtual void backup ()
const
192 virtual void restore ()
218 typedef std::size_t SizeType;
227 virtual SizeType
size ()
const = 0;
241 typedef typename DofStorageInterface::SizeType SizeType;
243 typedef LocalInterface< SizeType > MemObjectCheckType;
249 virtual void resize (
const bool enlargeOnly ) = 0;
251 virtual void reserve (
const SizeType newSize) = 0;
260 template <
class MemObjectType>
class ResizeMemoryObjects;
261 template <
class MemObjectType>
class ReserveMemoryObjects;
274 template <
class Gr
idImp,
class MapperType ,
class DofArrayType>
278 typedef typename ManagedDofStorageInterface::SizeType SizeType;
280 typedef typename ManagedDofStorageInterface::MemObjectCheckType MemObjectCheckType;
294 DofArrayType& array_;
296 typedef ResizeMemoryObjects < ThisType > ResizeMemoryObjectType;
297 typedef ReserveMemoryObjects < ThisType > ReserveMemoryObjectType;
298 ResizeMemoryObjectType resizeMemObj_;
299 ReserveMemoryObjectType reserveMemObj_;
302 bool dataCompressionEnabled_;
310 const MapperType& mapper,
311 DofArrayType& array )
313 mapper_ ( const_cast<MapperType& >(mapper)),
315 resizeMemObj_(*this),
316 reserveMemObj_(*this),
317 dataCompressionEnabled_(false)
341 SizeType
size ()
const override {
return array_.size(); }
344 void resize (
const bool enlargeOnly )
override
346 resize( std::integral_constant<
bool, Capabilities::isAdaptiveDofMapper< MapperType >::v >(), enlargeOnly );
350 inline void reserve (
const SizeType needed )
override
353 if( mapper().consecutive() )
355 const SizeType nSize =
size() + (needed * SizeType(mapper().maxNumDofs()));
356 array_.reserve( nSize );
362 assert( ! mapper().consecutive() );
372 const SizeType nSize = mapper().size();
375 if( dataCompressionEnabled_ )
378 const bool consecutive = mapper().consecutive ();
381 const SizeType oldSize = array_.size();
389 const int numBlocks = mapper().numBlocks();
390 for(
int block = 0; block < numBlocks; ++block )
399 const SizeType holes = mapper().numberOfHoles( block );
400 for( SizeType i = 0; i < holes; ++i )
402 const SizeType oldIndex = mapper().oldIndex( i, block );
403 const SizeType newIndex = mapper().newIndex( i, block );
405 assert( newIndex < nSize );
407 array_.copyContent( newIndex, oldIndex );
414 array_.resize( nSize );
416 if( clearResizedArrays && ! dataCompressionEnabled_ )
426 return ((
size_t)
sizeof(
ThisType) + array_.usedMemorySize());
432 dataCompressionEnabled_ =
true;
439 inline MapperType &mapper ()
const
445 void resize ( std::false_type,
const bool enlargeOnly )
451 const SizeType newSize = mapper().size();
452 const SizeType oldSize = array_.size();
454 if( enlargeOnly && newSize < oldSize ) return ;
456 if( newSize != oldSize )
457 array_.resize( newSize );
461 void resize ( std::true_type,
const bool enlargeOnly )
465 const SizeType oldSize = array_.size();
468 const SizeType nSize = mapper().size();
472 if( enlargeOnly && nSize <= oldSize ) return ;
475 if( nSize == oldSize ) return ;
478 array_.resize( nSize );
481 if( ! dataCompressionEnabled_ || enlargeOnly ) return ;
484 const int numBlocks = mapper().numBlocks();
487 SizeType upperBound = oldSize ;
490 assert( mapper().offSet( 0 ) == 0 );
491 assert( mapper().oldOffSet( 0 ) == 0 );
494 for(
int block = numBlocks-1; block >= 1; --block )
497 const SizeType newOffSet = mapper().offSet( block );
498 const SizeType oldOffSet = mapper().oldOffSet( block );
501 assert( newOffSet >= oldOffSet );
504 if( newOffSet > oldOffSet )
507 const SizeType blockSize = upperBound - oldOffSet;
509 array_.memMoveBackward( blockSize, oldOffSet, newOffSet );
512 upperBound = oldOffSet;
518 void resizeAndMoveToRear ()
526 assert( mapper().offSet( 0 ) == 0 );
527 assert( mapper().oldOffSet( 0 ) == 0 );
530 if( block == 0 )
return;
533 const SizeType oldOffSet = mapper().oldOffSet( block );
536 const SizeType newOffSet = mapper().offSet( block );
539 assert( newOffSet <= oldOffSet );
542 if( newOffSet < oldOffSet )
545 const int numBlocks = mapper().numBlocks();
548 const SizeType upperBound
549 = (block == numBlocks - 1) ? oldSize : mapper().oldOffSet( block + 1 );
550 const SizeType blockSize = upperBound - oldOffSet;
553 array_.memMoveForward( blockSize, oldOffSet, newOffSet );
559 template <
class Gr
idImp,
class MapperType ,
class DofArrayType>
564 DofArrayType myArray_;
568 const MapperType& mapper )
569 :
BaseType( grid, mapper, myArray_ ),
570 myArray_( mapper.
size() )
576 template<
class DofStorageType,
class Gr
idType,
class MapperType >
577 static inline std::pair< DofStorageInterface* , DofStorageType* >
579 const MapperType& mapper,
580 const DofStorageType * = 0 )
584 DofStorageType > ManagedDofStorageType;
586 ManagedDofStorageType* mds =
new ManagedDofStorageType( grid, mapper );
590 return std::pair< DofStorageInterface* , DofStorageType* >
591 ( mds , & mds->getArray () );
602 template <
class IndexSetType,
class EntityType>
603 class RemoveIndicesFromSet
604 :
public LocalInlinePlus < RemoveIndicesFromSet<IndexSetType,EntityType> , EntityType >
608 IndexSetType & indexSet_;
612 explicit RemoveIndicesFromSet ( IndexSetType & iset ) : indexSet_ (iset) {}
615 inline void apply ( EntityType & entity )
617 indexSet_.removeEntity( entity );
621 template <
class IndexSetType,
class EntityType>
622 class InsertIndicesToSet
623 :
public LocalInlinePlus < InsertIndicesToSet< IndexSetType, EntityType > , EntityType >
627 IndexSetType & indexSet_;
631 explicit InsertIndicesToSet ( IndexSetType & iset ) : indexSet_ (iset) {}
634 inline void apply ( EntityType & entity )
636 indexSet_.insertEntity( entity );
640 template <
class MemObjectType>
641 class ResizeMemoryObjects
642 :
public LocalInlinePlus < ResizeMemoryObjects < MemObjectType > , typename MemObjectType::SizeType >
646 MemObjectType& memobj_;
649 typedef typename MemObjectType::SizeType SizeType;
652 ResizeMemoryObjects ( MemObjectType & mo ) : memobj_ (mo) {}
653 ResizeMemoryObjects (
const ResizeMemoryObjects& org )
654 : memobj_(org.memobj_)
658 inline void apply ( SizeType& enlargeOnly )
660 memobj_.resize(
bool(enlargeOnly) );
665 template <
class MemObjectType>
666 class ReserveMemoryObjects
667 :
public LocalInlinePlus < ReserveMemoryObjects < MemObjectType > , typename MemObjectType::SizeType >
671 MemObjectType& memobj_;
674 typedef typename MemObjectType::SizeType SizeType;
677 ReserveMemoryObjects ( MemObjectType & mo ) : memobj_ (mo) {}
680 inline void apply ( SizeType& chunkSize )
682 memobj_.reserve( chunkSize );
690 template <
class DofManagerType ,
class RestrictPro
longIndexSetType,
bool doResize >
691 class IndexSetRestrictProlong :
692 public RestrictProlongInterface<
693 RestrictProlongTraits<
694 IndexSetRestrictProlong<DofManagerType,RestrictProlongIndexSetType,doResize>, double > >
696 DofManagerType & dm_;
698 RestrictProlongIndexSetType & insert_;
699 RestrictProlongIndexSetType & remove_;
702 IndexSetRestrictProlong ( DofManagerType & dm , RestrictProlongIndexSetType & is, RestrictProlongIndexSetType & rm )
703 : dm_(dm) , insert_( is ), remove_( rm ) {}
706 template <
class EntityType>
707 inline void restrictLocal (
const EntityType & father,
const EntityType & son ,
bool initialize )
const
710 insert_.apply( father );
712 remove_.apply( son );
721 template <
class EntityType>
722 inline void restrictFinalize(
const EntityType &father )
const
726 template <
class EntityType>
727 inline void prolongLocal (
const EntityType & father,
const EntityType & son ,
bool initialize )
const
730 remove_.apply( father );
732 insert_.apply( son );
743 class EmptyIndexSetRestrictProlong :
744 public RestrictProlongInterface< RestrictProlongTraits< EmptyIndexSetRestrictProlong, double > >
747 EmptyIndexSetRestrictProlong() {}
749 template <
class EntityType>
750 inline void restrictLocal ( EntityType & father, EntityType & son ,
bool initialize )
const {}
752 template <
class EntityType>
753 inline void prolongLocal ( EntityType & father, EntityType & son ,
bool initialize )
const {}
775 template<
class Gr
id >
779 public LoadBalanceHandleWithReserveAndCompress,
781#if HAVE_DUNE_P4ESTGRID
782 public P4estGridLoadBalanceHandleWithReserveAndCompress,
789 friend struct DefaultSingletonFactory< const
Grid*,
ThisType >;
796 typedef typename GridObjectStreamTraits< GridType >::InStreamType XtractStreamImplType;
797 typedef typename GridObjectStreamTraits< GridType >::OutStreamType InlineStreamImplType;
807 typedef typename GridType :: template
Codim< 0 > :: Entity ElementType ;
810 typedef std::list< ManagedDofStorageInterface* > ListType;
811 typedef typename ManagedDofStorageInterface::MemObjectCheckType MemObjectCheckType;
812 typedef typename MemObjectCheckType::Traits::ParamType MemObjSizeType;
813 typedef std::list< ManagedIndexSetInterface * > IndexListType;
819 IndexListType indexList_;
830 typedef const ElementType ConstElementType;
831 typedef LocalInterface< ConstElementType > LocalIndexSetObjectsType;
833 mutable LocalIndexSetObjectsType insertIndices_;
834 mutable LocalIndexSetObjectsType removeIndices_;
838 mutable MemObjectCheckType resizeMemObjs_;
839 mutable MemObjectCheckType reserveMemObjs_;
842 const MemObjSizeType defaultChunkSize_;
848 typedef IndexSetRestrictProlong< ThisType, LocalIndexSetObjectsType , true >
849 NewIndexSetRestrictProlongType;
850 typedef IndexSetRestrictProlong< ThisType, LocalIndexSetObjectsType , false >
851 IndexSetRestrictProlongNoResizeType;
854 typedef EmptyIndexSetRestrictProlong IndexSetRestrictProlongType;
857 friend class IndexSetRestrictProlong<
ThisType , LocalIndexSetObjectsType , true > ;
858 friend class IndexSetRestrictProlong<
ThisType , LocalIndexSetObjectsType , false > ;
862 NewIndexSetRestrictProlongType indexSetRestrictProlong_;
863 IndexSetRestrictProlongNoResizeType indexSetRestrictProlongNoResize_;
866 IndexSetRestrictProlongType indexRPop_;
869 double memoryFactor_;
872 const bool clearResizedArrays_;
879 defaultChunkSize_( 128 ),
881 indexSetRestrictProlong_( *this, insertIndices_ , removeIndices_ ),
882 indexSetRestrictProlongNoResize_( *this, insertIndices_ , removeIndices_ ),
884 memoryFactor_(
Parameter :: getValidValue(
"fem.dofmanager.memoryfactor", double( 1.1 ),
885 [] ( double value ) {
return value >= 1.0; } ) ),
889 if( std::abs( memoryFactor_ - 1.1 ) > 1e-12 )
892 std::cout <<
"Created DofManager with memory factor " << memoryFactor_ <<
"." << std::endl;
900 DofManager(
const ThisType& ) =
delete;
923 template <
class IndexSetType>
924 inline void addIndexSet (
const IndexSetType &iset );
933 template <
class IndexSetType>
940 template <
class ManagedDofStorageImp>
947 template <
class ManagedDofStorageImp>
957 return indexSetRestrictProlong_;
965 return indexSetRestrictProlongNoResize_;
971 return ! insertIndices_.empty();
978 for(
auto memObjectPtr : memList_)
979 used += memObjectPtr->usedMemorySize();
995 MemObjSizeType localChunkSize =
996 std::max( MemObjSizeType(nsize), defaultChunkSize_ );
997 assert( localChunkSize > 0 );
1000 reserveMemObjs_.apply ( localChunkSize );
1014 for(
auto indexSetPtr : indexList_)
1015 indexSetPtr->resize();
1023 insertIndices_.apply( element );
1033 removeIndices_.apply( element );
1039 MemObjSizeType enlargeOnly( 0 );
1041 resizeMemObjs_.apply ( enlargeOnly );
1047 MemObjSizeType enlargeOnly( 1 );
1049 resizeMemObjs_.apply ( enlargeOnly );
1061 assert( sequence_ == grid_.
comm().max( sequence_ ) );
1074 for(
auto indexSetPtr : indexList_)
1077 indexSetPtr->compress();
1081 for(
auto memObjectPtr : memList_)
1088 memObjectPtr->dofCompress ( clearResizedArrays_ );
1096 int wasChangedCounter = int( wasChanged );
1097 return bool( grid_.
comm().max( wasChangedCounter ) );
1101 template <
class DataCollType>
1110 dataInliner_.
clear();
1114 template <
class DataCollType>
1123 dataXtractor_.
clear();
1133 return ( codim == 0 );
1143 template <
class Entity>
1154 dataInliner_.
apply(str, element);
1161 template <
class MessageBuffer,
class Entity>
1162 void gather( MessageBuffer& str,
const Entity& entity )
const
1178 dataXtractor_.
apply(str, element);
1182 template <
class MessageBuffer,
class Entity>
1198 for(
auto indexSetPtr : indexList_)
1199 indexSetPtr->backup();
1205 for(
auto indexSetPtr : indexList_)
1206 indexSetPtr->restore();
1223 template <
class OutStream >
1226 for(
auto indexSetPtr : indexList_)
1227 indexSetPtr->write( out );
1234 template <
class InStream >
1237 for(
auto indexSetPtr : indexList_)
1238 indexSetPtr->read( in );
1254 return DofManagerFactoryType :: instance( grid );
1264 template <
class Gr
idType>
1265 inline DofManager<GridType>::~DofManager ()
1269 if(memList_.size() > 0)
1271 while( memList_.rbegin() != memList_.rend())
1273 DofStorageInterface * mobj = (* memList_.rbegin() );
1275 std::cout <<
"Removing '" << mobj <<
"' from DofManager!\n";
1276 memList_.pop_back();
1280 if(indexList_.size() > 0)
1283 std::cerr <<
"ERROR: Not all index sets have been removed from DofManager yet!" << std::endl;
1284 while ( indexList_.rbegin() != indexList_.rend())
1286 ManagedIndexSetInterface* iobj = (* indexList_.rbegin() );
1287 indexList_.pop_back();
1288 if(iobj)
delete iobj;
1293 template <
class Gr
idType>
1294 template <
class IndexSetType>
1299 if( ! Fem :: MPIManager :: singleThreadMode() )
1301 assert( Fem :: MPIManager :: singleThreadMode() );
1305 typedef ManagedIndexSet< IndexSetType, ConstElementType > ManagedIndexSetType;
1306 ManagedIndexSetType * indexSet = 0;
1309 auto endit = indexList_.rend();
1310 for(
auto it = indexList_.rbegin(); it != endit; ++it )
1313 if( set->equals( iset ) )
1317 indexSet =
static_cast< ManagedIndexSetType *
>( set );
1324 indexSet =
new ManagedIndexSetType ( iset, insertIndices_ , removeIndices_ );
1329 template <
class Gr
idType>
1330 template <
class IndexSetType>
1334 if( ! Fem :: MPIManager :: singleThreadMode() )
1336 assert( Fem :: MPIManager :: singleThreadMode() );
1341 auto endit = indexList_.rend();
1342 for(
auto it = indexList_.rbegin(); it != endit; ++it )
1345 if( set->equals( iset ) )
1352 auto fit = it.base();
1353 indexList_.erase( --fit );
1365 template <
class Gr
idType>
1366 template <
class ManagedDofStorageImp>
1373 memList_.push_front( obj );
1376 resizeMemObjs_ += dofStorage.resizeMemoryObject();
1379 reserveMemObjs_ += dofStorage.reserveMemoryObject();
1383 template <
class Gr
idType>
1384 template <
class ManagedDofStorageImp>
1388 auto obj = &dofStorage;
1391 auto endit = memList_.end();
1392 for(
auto it = memList_.begin();it != endit ; ++it)
1397 memList_.erase( it );
1400 resizeMemObjs_.remove( dofStorage.resizeMemoryObject() );
1401 reserveMemObjs_.remove( dofStorage.reserveMemoryObject() );
1418 template<
class DofManagerImp >
1424 typedef DofManagerImp DofManagerType;
1425 typedef typename DofManagerType :: GridType GridType;
1428 typedef const GridType *KeyType;
1442 inline static DofManagerType &
instance (
const GridType &grid )
1444 DofManagerType *dm = getDmFromList( grid );
1453 const std :: string &filename,
1456 DofManagerType *dm = getDmFromList( grid );
1467 const std :: string &filename,
1470 DofManagerType *dm = getDmFromList( grid );
1487 inline static DofManagerType *getDmFromList(
const GridType &grid )
1489 return (DMProviderType :: getObjFromList( &grid )).first;
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
Wrapper class for entities.
Definition: entity.hh:66
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
virtual void clear()
clear object list
Definition: datacollector.hh:378
virtual void apply(ObjectStreamType &str, const EntityType &entity) const
Definition: datacollector.hh:289
Singleton provider for the DofManager.
Definition: dofmanager.hh:1420
Definition: dofmanager.hh:786
Interface class for a dof storage object to be stored in discrete functions.
Definition: dofmanager.hh:212
interface documentation for (grid part) index sets
Definition: indexset.hh:123
Definition: dofmanager.hh:276
Interface class for a dof storage object that can be managed (resized and compressed) by the DofManag...
Definition: dofmanager.hh:235
Definition: dofmanager.hh:561
Definition: dofmanager.hh:59
Container for User Specified Parameters.
Definition: parameter.hh:191
static bool verbose()
obtain the cached value for fem.verbose with default verbosity level 2
Definition: parameter.hh:466
static T getValue(const std::string &key)
get a mandatory parameter from the container
Definition: parameter.hh:344
Singleton list for key/object pairs.
Definition: singletonlist.hh:53
static void removeObject(const ObjectType &object)
Definition: singletonlist.hh:123
static auto getObject(const KeyType &key, Args &&... args) -> std::enable_if_t< std::is_same< decltype(FactoryType::createObject(key, std::forward< Args >(args)...)), ObjectType * >::value, ObjectType & >
Definition: singletonlist.hh:94
input stream reading from a given std::istream
Definition: standardstreams.hh:202
output stream writing into a given std::ostream
Definition: standardstreams.hh:61
Grid abstract base class.
Definition: grid.hh:375
const Communication & comm() const
return const reference to a communication object. The return type is a model of Dune::Communication.
Definition: grid.hh:722
Index Set Interface base class.
Definition: indexidset.hh:78
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
Communication message buffer interface. This class describes the interface for reading and writing da...
Definition: datahandleif.hh:33
Default exception for dummy implementations.
Definition: exceptions.hh:263
Describes the parallel communication interface class for MessageBuffers and DataHandles.
A few common exception classes.
Various macros to work with Dune module version numbers.
virtual void backup() const =0
:: backup
bool removeReference()
decrease reference counter and return true if zero reached
Definition: dofmanager.hh:97
virtual bool compress()=0
compress of index set
void restrictLocal(const EntityType &father, const EntityType &son, bool initialize) const
restrict data to father and resize memory if doResize is true
Definition: dofmanager.hh:707
void scatter(MessageBuffer &str, const Entity &entity, size_t)
unpacks all data of this entity from message buffer
Definition: dofmanager.hh:1183
void enlargeMemory()
resize the MemObject if necessary
Definition: dofmanager.hh:1045
void resize()
wrap resize of index set
Definition: dofmanager.hh:174
size_t usedMemorySize() const
return used memory size of all MemObjects in bytes.
Definition: dofmanager.hh:975
IndexSetRestrictProlongNoResizeType & indexSetRestrictProlongNoResize()
returns the index set restriction and prolongation operator
Definition: dofmanager.hh:961
static DofManagerType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1442
void addDataXtractor(DataCollType &d)
add data handler for data xtracting to dof manager
Definition: dofmanager.hh:1115
virtual void write(StandardOutStream &out) const
new write method
Definition: dofmanager.hh:201
void resize()
Resize index sets and memory due to what the mapper has as new size.
Definition: dofmanager.hh:1012
void restore()
:: restore
Definition: dofmanager.hh:1203
void enableDofCompression() override
enable dof compression for this MemObject
Definition: dofmanager.hh:430
bool compress()
wrap compress of index set
Definition: dofmanager.hh:180
void removeIndexSet(const IndexSetType &iset)
removed index set from dof manager's list of index sets
Definition: dofmanager.hh:1331
void dofCompress(const bool clearResizedArrays) override
copy the dof from the rear section of the vector to the holes
Definition: dofmanager.hh:369
virtual void restore()=0
:: restore
void prolongLocal(const EntityType &father, const EntityType &son, bool initialize) const
prolong data to children and resize memory if doResize is true
Definition: dofmanager.hh:727
void resizeMemory()
resize the MemObject if necessary
Definition: dofmanager.hh:1037
void insertEntity(ConstElementType &element)
Inserts entity to all index sets added to dof manager.
Definition: dofmanager.hh:1020
static void deleteDofManager(DofManagerType &dm)
delete the dof manager that belong to the given grid
Definition: dofmanager.hh:1480
SizeType size() const override
return size of underlying array
Definition: dofmanager.hh:341
size_t size(const Entity &) const
for convenience
Definition: dofmanager.hh:1144
void resize(const bool enlargeOnly) override
resize the memory with the new size
Definition: dofmanager.hh:344
double memoryFactor() const
return factor to over estimate new memory allocation
Definition: dofmanager.hh:903
void prolongLocal(EntityType &father, EntityType &son, bool initialize) const
prolong data to children and resize memory if doResize is true
Definition: dofmanager.hh:753
ResizeMemoryObjectType & resizeMemoryObject()
return object that calls resize of this memory object
Definition: dofmanager.hh:335
static bool writeDofManagerNew(const GridType &grid, const std ::string &filename, int timestep)
writes DofManager of corresponding grid, when DofManager exists
Definition: dofmanager.hh:1452
ManagedDofStorageImplementation(const GridImp &grid, const MapperType &mapper, DofArrayType &array)
Constructor of ManagedDofStorageImplementation, only to call from derived classes.
Definition: dofmanager.hh:309
NewIndexSetRestrictProlongType & indexSetRestrictProlong()
returns the index set restriction and prolongation operator
Definition: dofmanager.hh:951
virtual void resize(const bool enlargeOnly)=0
resize memory
virtual ~ManagedDofStorageInterface()=default
destructor
Grid GridType
type of Grid this DofManager belongs to
Definition: dofmanager.hh:794
ManagedIndexSetInterface BaseType
type of base class
Definition: dofmanager.hh:142
void moveToFront(const SizeType oldSize, const int block)
move block to front again
Definition: dofmanager.hh:523
virtual void dofCompress(const bool clearResizedArrays)=0
DofStorageInterface()=default
do not allow to create explicit instances
ReserveMemoryObjectType & reserveMemoryObject()
return object that calls reserve of this memory object
Definition: dofmanager.hh:338
void gather(InlineStreamType &str, ConstElementType &element) const
packs all data attached to this entity
Definition: dofmanager.hh:1151
~ManagedIndexSet()
destructor
Definition: dofmanager.hh:164
ManagedDofStorageInterface()=default
do not allow to create explicit instances
DofArrayType & getArray()
return reference to array for DiscreteFunction
Definition: dofmanager.hh:436
virtual void read(StandardInStream &in)
new write method
Definition: dofmanager.hh:198
void read(InStream &in)
read all index sets from a given stream
Definition: dofmanager.hh:1235
void apply(EntityType &entity)
apply wraps the insertEntity method of the index set
Definition: dofmanager.hh:634
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1251
void addDofStorage(ManagedDofStorageImp &dofStorage)
add a managed dof storage to the dof manager.
Definition: dofmanager.hh:1367
void compress()
Compress all data that is hold by this dofmanager.
Definition: dofmanager.hh:1068
void incrementSequenceNumber()
increase the DofManagers internal sequence number
Definition: dofmanager.hh:1055
size_t usedMemorySize() const override
return used memory size
Definition: dofmanager.hh:424
void restrictLocal(EntityType &father, EntityType &son, bool initialize) const
restrict data to father and resize memory if doResize is true
Definition: dofmanager.hh:750
void removeEntity(ConstElementType &element) const
Removes entity from all index sets added to dof manager.
Definition: dofmanager.hh:1030
void reserveMemory(std::size_t nsize, bool dummy=false)
reserve memory for at least nsize elements, dummy is needed for dune-grid ALUGrid version
Definition: dofmanager.hh:993
static bool readDofManagerNew(const GridType &grid, const std ::string &filename, int timestep)
reads DofManager of corresponding grid, when DofManager exists
Definition: dofmanager.hh:1466
void reserve(const SizeType needed) override
reserve memory for what is coming
Definition: dofmanager.hh:350
static std::pair< DofStorageInterface *, DofStorageType * > allocateManagedDofStorage(const GridType &grid, const MapperType &mapper, const DofStorageType *=0)
default implementation for creating a managed dof storage
Definition: dofmanager.hh:578
void addReference()
increase reference counter
Definition: dofmanager.hh:94
virtual SizeType size() const =0
size of space, i.e. mapper.size()
ManagedIndexSet(const IndexSetType &iset, LocalIndexSetObjectsType &insertList, LocalIndexSetObjectsType &removeList)
Constructor of MemObject, only to call from DofManager.
Definition: dofmanager.hh:145
virtual void write(StandardOutStream &out) const =0
new read/write methods using binary streams
void apply(EntityType &entity)
apply wraps the removeEntity Method of the index set
Definition: dofmanager.hh:615
void write(OutStream &out) const
write all index sets to a given stream
Definition: dofmanager.hh:1224
void removeDofStorage(ManagedDofStorageImp &dofStorage)
remove a managed dof storage from the dof manager.
Definition: dofmanager.hh:1385
void clearDataXtractors()
clear data xtractor list
Definition: dofmanager.hh:1121
bool contains(const int dim, const int codim) const
the dof manager only transfers element data during load balancing
Definition: dofmanager.hh:1131
void resizeForRestrict()
resize memory before data restriction during grid adaptation is done.
Definition: dofmanager.hh:986
virtual void enableDofCompression()
enable dof compression for dof storage (default is empty)
Definition: dofmanager.hh:224
void clearDataInliners()
clear data inliner list
Definition: dofmanager.hh:1108
bool notifyGlobalChange(const bool wasChanged) const
communicate new sequence number
Definition: dofmanager.hh:1093
bool fixedSize(const int dim, const int codim) const
fixed size is false
Definition: dofmanager.hh:1137
virtual void reserve(const SizeType newSize)=0
resize memory
void backup() const
:: backup
Definition: dofmanager.hh:1196
void addDataInliner(DataCollType &d)
add data handler for data inlining to dof manager
Definition: dofmanager.hh:1102
void scatter(XtractStreamType &str, ConstElementType &element, size_t)
unpacks all data attached of this entity from message buffer
Definition: dofmanager.hh:1171
ManagedDofStorage(const GridImp &grid, const MapperType &mapper)
Constructor of ManagedDofStorage.
Definition: dofmanager.hh:567
bool hasIndexSets() const
if dofmanagers list is not empty return true
Definition: dofmanager.hh:969
virtual size_t usedMemorySize() const =0
return size of mem used by MemObject
virtual void resize()=0
resize of index set
~ManagedDofStorageImplementation()
destructor deleting MemObject from resize and reserve List
Definition: dofmanager.hh:327
void addIndexSet(const IndexSetType &iset)
add index set to dof manager's list of index sets
Definition: dofmanager.hh:1296
virtual ~DofStorageInterface()=default
destructor
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize,...
Definition: dofmanager.hh:1007
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Standard Dune debug streams.