DUNE-FEM (unstable)

dofmanager.hh
1 #ifndef DUNE_FEM_DOFMANAGER_HH
2 #define DUNE_FEM_DOFMANAGER_HH
3 
4 #include <cassert>
5 #include <string>
6 #include <list>
7 
10 #include <dune/common/version.hh>
11 
12 #if HAVE_DUNE_ALUGRID
13 #include <dune/alugrid/common/interfaces.hh>
14 #endif
15 
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>
26 
28 #if HAVE_DUNE_ALUGRID
29 #include <dune/alugrid/common/ldbhandleif.hh>
30 #endif
31 
32 namespace Dune
33 {
34 
35  namespace Fem
36  {
37 
43  // forward declaration
44  template <class GridType> class DofManager;
45  template <class DofManagerImp> class DofManagerFactory;
46 
47 
49  //
50  // ManagedIndexSetInterface
51  //
53 
59  {
61  protected:
62  // use address of object as id
63  typedef const void * IdentifierType;
64  // pointer to compare index sets
65  IdentifierType setPtr_;
66  // reference counter
67  size_t referenceCounter_;
68 
69  template< class IndexSet >
70  explicit ManagedIndexSetInterface ( const IndexSet &iset )
71  : setPtr_( getIdentifier( iset ) ),
72  referenceCounter_( 1 )
73  {
74  }
75 
76  public:
77  virtual ~ManagedIndexSetInterface () = default;
78 
80  virtual void resize () = 0;
82  virtual bool compress () = 0;
83 
85  virtual void backup() const = 0;
87  virtual void restore() = 0;
88 
90  virtual void write( StandardOutStream& out ) const = 0;
91  virtual void read( StandardInStream& out ) = 0;
92 
94  void addReference ( ) { ++referenceCounter_; }
95 
97  bool removeReference ( )
98  {
99  return (--referenceCounter_ == 0);
100  }
101 
102  template< class IndexSet >
103  bool equals ( const IndexSet &iset ) const
104  {
105  return (getIdentifier( iset ) == setPtr_);
106  }
107 
108  private:
109  template< class IndexSet >
110  IdentifierType getIdentifier ( const IndexSet &iset ) const
111  {
112  return static_cast< IdentifierType >( &iset );
113  }
114  };
115 
116  template <class IndexSetType, class EntityType> class RemoveIndicesFromSet;
117  template <class IndexSetType, class EntityType> class InsertIndicesToSet;
118 
119  template <class IndexSetType, class EntityType>
120  class ManagedIndexSet :
121  public ManagedIndexSetInterface ,
122  public LocalInlinePlus < ManagedIndexSet<IndexSetType,EntityType> , EntityType >
123  {
124  typedef LocalInterface<EntityType> LocalIndexSetObjectsType;
125 
126  static const bool isConsecutive =
127  Capabilities::isConsecutiveIndexSet<IndexSetType>::v;
128 
129  protected:
130  // the dof set stores number of dofs on entity for each codim
131  IndexSetType & indexSet_;
132 
133  // insertion and removal of indices
134  InsertIndicesToSet <IndexSetType, EntityType> insertIdxObj_;
135  RemoveIndicesFromSet <IndexSetType, EntityType> removeIdxObj_;
136 
137  LocalIndexSetObjectsType & insertList_;
138  LocalIndexSetObjectsType & removeList_;
139 
140  public:
143 
145  ManagedIndexSet ( const IndexSetType & iset,
146  LocalIndexSetObjectsType & insertList,
147  LocalIndexSetObjectsType & removeList )
148  : BaseType( iset )
149  , indexSet_ (const_cast<IndexSetType &> (iset))
150  , insertIdxObj_(indexSet_), removeIdxObj_(indexSet_)
151  , insertList_(insertList)
152  , removeList_(removeList)
153  {
154  this->setPtr_ = (void *) &indexSet_;
155 
156  if constexpr ( isConsecutive )
157  {
158  insertList_ += insertIdxObj_;
159  removeList_ += removeIdxObj_;
160  }
161  }
162 
165  {
166  if constexpr ( isConsecutive )
167  {
168  insertList_.remove( insertIdxObj_ );
169  removeList_.remove( removeIdxObj_ );
170  }
171  }
172 
174  void resize ()
175  {
176  indexSet_.resize();
177  }
178 
180  bool compress ()
181  {
182  return indexSet_.compress();
183  }
184 
185  // forward backup call to indexSet
186  virtual void backup () const
187  {
188  indexSet_.backup();
189  }
190 
191  // forward restore call to indexSet
192  virtual void restore ()
193  {
194  indexSet_.restore();
195  }
196 
198  virtual void read( StandardInStream& in ) { indexSet_.read( in ); }
199 
201  virtual void write( StandardOutStream& out ) const { indexSet_.write( out ); }
202  };
203 
205  //
206  // DofStorageInterface
207  //
209 
212  {
213  protected:
215  DofStorageInterface() = default;
216 
217  public:
218  typedef std::size_t SizeType;
219 
221  virtual ~DofStorageInterface() = default;
222 
224  virtual void enableDofCompression() { }
225 
227  virtual SizeType size () const = 0;
228  };
229 
230 
235  {
236  protected:
239 
240  public:
241  typedef typename DofStorageInterface::SizeType SizeType;
242  // interface for MemObject lists
243  typedef LocalInterface< SizeType > MemObjectCheckType;
244 
246  virtual ~ManagedDofStorageInterface() = default;
247 
249  virtual void resize ( const bool enlargeOnly ) = 0;
251  virtual void reserve (const SizeType newSize) = 0;
254  virtual void dofCompress ( const bool clearResizedArrays ) = 0;
256  virtual size_t usedMemorySize() const = 0;
257  };
258 
259 
260  template <class MemObjectType> class ResizeMemoryObjects;
261  template <class MemObjectType> class ReserveMemoryObjects;
262 
274  template <class GridImp, class MapperType , class DofArrayType>
276  {
277  public:
278  typedef typename ManagedDofStorageInterface::SizeType SizeType;
279  protected:
280  typedef typename ManagedDofStorageInterface::MemObjectCheckType MemObjectCheckType;
281 
282  // type of this class
284 
286 
287  // reference to dof manager
288  DofManagerType &dm_;
289 
290  // the dof set stores number of dofs on entity for each codim
291  MapperType &mapper_;
292 
293  // Array which the dofs are stored in
294  DofArrayType& array_;
295 
296  typedef ResizeMemoryObjects < ThisType > ResizeMemoryObjectType;
297  typedef ReserveMemoryObjects < ThisType > ReserveMemoryObjectType;
298  ResizeMemoryObjectType resizeMemObj_;
299  ReserveMemoryObjectType reserveMemObj_;
300 
301  // true if data need to be compressed
302  bool dataCompressionEnabled_;
303 
304  public:
306 
307  protected:
309  ManagedDofStorageImplementation ( const GridImp& grid,
310  const MapperType& mapper,
311  DofArrayType& array )
312  : dm_( DofManagerType :: instance( grid ) ),
313  mapper_ ( const_cast<MapperType& >(mapper)),
314  array_( array ),
315  resizeMemObj_(*this),
316  reserveMemObj_(*this),
317  dataCompressionEnabled_(false)
318  {
319  // add to dof manager
320  dm_.addDofStorage( *this );
321 
322  // set memory over estimate factor, only for DofArray
323  array_.setMemoryFactor( dm_.memoryFactor() );
324  }
325 
328  {
329  // remove from dof manager
330  dm_.removeDofStorage( *this );
331  }
332 
333  public:
335  ResizeMemoryObjectType& resizeMemoryObject() { return resizeMemObj_; }
336 
338  ReserveMemoryObjectType& reserveMemoryObject() { return reserveMemObj_; }
339 
341  SizeType size () const override { return array_.size(); }
342 
344  void resize ( const bool enlargeOnly ) override
345  {
346  resize( std::integral_constant< bool, Capabilities::isAdaptiveDofMapper< MapperType >::v >(), enlargeOnly );
347  }
348 
350  inline void reserve ( const SizeType needed ) override
351  {
352  // if index set is compressible, then add requested size
353  if( mapper().consecutive() )
354  {
355  const SizeType nSize = size() + (needed * SizeType(mapper().maxNumDofs()));
356  array_.reserve( nSize );
357  }
358  else
359  {
360  // if compress is not needed just resize with given size
361  // therefore use newSize to enlarge array
362  assert( ! mapper().consecutive() );
363  // resize array
364  resize ( false );
365  }
366  }
367 
369  void dofCompress ( const bool clearResizedArrays ) override
370  {
371  // get current size
372  const SizeType nSize = mapper().size();
373 
374  // if data is non-temporary do data compression
375  if( dataCompressionEnabled_ )
376  {
377  // get consecutive information about mapper
378  const bool consecutive = mapper().consecutive ();
379 
380  // get old size (which we still have in array)
381  const SizeType oldSize = array_.size();
382 
383  // NOTE: new size can also be larger than old size
384  // e.g. during loadBalancing when ghosts where
385  // introduced before compressing the index set
386 
387  // begin with block zero since closing of holes
388  // has to be done anyway if the mapper is consecutive
389  const int numBlocks = mapper().numBlocks();
390  for( int block = 0; block < numBlocks; ++block )
391  {
392  // move memory
393  moveToFront( oldSize, block );
394 
395  // only close holes for consecutive mappers
396  if( consecutive )
397  {
398  // run over all holes and copy array values to new place
399  const SizeType holes = mapper().numberOfHoles( block );
400  for( SizeType i = 0; i < holes; ++i )
401  {
402  const SizeType oldIndex = mapper().oldIndex( i, block );
403  const SizeType newIndex = mapper().newIndex( i, block );
404 
405  assert( newIndex < nSize );
406  // implements array_[ newIndex ] = array_[ oldIndex ] ;
407  array_.copyContent( newIndex, oldIndex );
408  }
409  }
410  }
411  }
412 
413  // store new size, which should be smaller then actual size
414  array_.resize( nSize );
415 
416  if( clearResizedArrays && ! dataCompressionEnabled_ )
417  {
418  // if enabled clear temporary data to avoid occasionally NaN values
419  array_.clear();
420  }
421  }
422 
424  size_t usedMemorySize() const override
425  {
426  return ((size_t) sizeof(ThisType) + array_.usedMemorySize());
427  }
428 
430  void enableDofCompression() override
431  {
432  dataCompressionEnabled_ = true;
433  }
434 
436  DofArrayType & getArray() { return array_; }
437 
438  protected:
439  inline MapperType &mapper () const
440  {
441  return mapper_;
442  }
443 
444  // resize for non-adaptive mappers
445  void resize ( std::false_type, const bool enlargeOnly )
446  {
447  // note: The mapper might already have been updated, so do not use
448  // it to obtain old array size.
449  mapper().update(); // make sure the mapper is up2date
450 
451  const SizeType newSize = mapper().size();
452  const SizeType oldSize = array_.size();
453 
454  if( enlargeOnly && newSize < oldSize ) return ;
455 
456  if( newSize != oldSize )
457  array_.resize( newSize );
458  }
459 
460  // resize for adaptive mappers
461  void resize ( std::true_type, const bool enlargeOnly )
462  {
463  // note: The mapper is adaptive and has been updated automatically, so
464  // do not use it to obtain old array size.
465  const SizeType oldSize = array_.size();
466 
467  // get current size
468  const SizeType nSize = mapper().size();
469 
470  // if enlarge only option is given only resize
471  // if new size if larger than old size
472  if( enlargeOnly && nSize <= oldSize ) return ;
473 
474  // if nothing changed do nothing
475  if( nSize == oldSize ) return ;
476 
477  // resize memory to current value
478  array_.resize( nSize );
479 
480  // if data is only temporary data, don't adjust memory
481  if( ! dataCompressionEnabled_ || enlargeOnly ) return ;
482 
483  // now check all blocks beginning with the largest
484  const int numBlocks = mapper().numBlocks();
485 
486  // initialize upperBound
487  SizeType upperBound = oldSize ;
488 
489  // make sure offset of block 0 is zero
490  assert( mapper().offSet( 0 ) == 0 );
491  assert( mapper().oldOffSet( 0 ) == 0 );
492 
493  // skip block 0 (since offset == 0)
494  for( int block = numBlocks-1; block >= 1; --block )
495  {
496  // get offsets
497  const SizeType newOffSet = mapper().offSet( block );
498  const SizeType oldOffSet = mapper().oldOffSet( block );
499 
500  // make sure new offset is larger
501  assert( newOffSet >= oldOffSet );
502 
503  // if off set is not zero
504  if( newOffSet > oldOffSet )
505  {
506  // calculate block size
507  const SizeType blockSize = upperBound - oldOffSet;
508  // move block backward
509  array_.memMoveBackward( blockSize, oldOffSet, newOffSet );
510 
511  // update upper bound
512  upperBound = oldOffSet;
513  }
514  }
515  }
516 
517  // move array to rear insertion points
518  void resizeAndMoveToRear ()
519  {
520  }
521 
523  void moveToFront ( const SizeType oldSize, const int block )
524  {
525  // make sure offset of block 0 is zero
526  assert( mapper().offSet( 0 ) == 0 );
527  assert( mapper().oldOffSet( 0 ) == 0 );
528 
529  // block 0 has always offset 0
530  if( block == 0 ) return;
531 
532  // get insertion point from block
533  const SizeType oldOffSet = mapper().oldOffSet( block );
534 
535  // get new off set
536  const SizeType newOffSet = mapper().offSet( block );
537 
538  // here we should have at least the same offsets
539  assert( newOffSet <= oldOffSet );
540 
541  // only if block is not starting from zero
542  if( newOffSet < oldOffSet )
543  {
544  // get number of blocks
545  const int numBlocks = mapper().numBlocks();
546 
547  // for last section upperBound is size
548  const SizeType upperBound
549  = (block == numBlocks - 1) ? oldSize : mapper().oldOffSet( block + 1 );
550  const SizeType blockSize = upperBound - oldOffSet;
551 
552  // move block forward
553  array_.memMoveForward( blockSize, oldOffSet, newOffSet );
554  }
555  }
556  };
557 
559  template <class GridImp, class MapperType , class DofArrayType>
560  class ManagedDofStorage : public ManagedDofStorageImplementation< GridImp, MapperType, DofArrayType >
561  {
563  protected:
564  DofArrayType myArray_;
565  public:
567  ManagedDofStorage( const GridImp& grid,
568  const MapperType& mapper )
569  : BaseType( grid, mapper, myArray_ ),
570  myArray_( mapper.size() )
571  {
572  }
573  };
574 
576  template< class DofStorageType, class GridType, class MapperType >
577  static inline std::pair< DofStorageInterface* , DofStorageType* >
578  allocateManagedDofStorage( const GridType& grid,
579  const MapperType& mapper,
580  const DofStorageType * = 0 )
581  {
582  // create managed dof storage
583  typedef ManagedDofStorage< GridType, MapperType,
584  DofStorageType > ManagedDofStorageType;
585 
586  ManagedDofStorageType* mds = new ManagedDofStorageType( grid, mapper );
587  assert( mds );
588 
589  // return pair with dof storage pointer and array pointer
590  return std::pair< DofStorageInterface* , DofStorageType* >
591  ( mds , & mds->getArray () );
592  }
593 
594 
595 
597  //
598  // RestrictPorlong for Index Sets
599  //
601 
602  template <class IndexSetType, class EntityType>
603  class RemoveIndicesFromSet
604  : public LocalInlinePlus < RemoveIndicesFromSet<IndexSetType,EntityType> , EntityType >
605  {
606  private:
607  // the dof set stores number of dofs on entity for each codim
608  IndexSetType & indexSet_;
609 
610  public:
611  // Constructor of MemObject, only to call from DofManager
612  explicit RemoveIndicesFromSet ( IndexSetType & iset ) : indexSet_ (iset) {}
613 
615  inline void apply ( EntityType & entity )
616  {
617  indexSet_.removeEntity( entity );
618  }
619  };
620 
621  template <class IndexSetType, class EntityType>
622  class InsertIndicesToSet
623  : public LocalInlinePlus < InsertIndicesToSet< IndexSetType, EntityType > , EntityType >
624  {
625  private:
626  // the dof set stores number of dofs on entity for each codim
627  IndexSetType & indexSet_;
628 
629  public:
630  // Constructor of MemObject, only to call from DofManager
631  explicit InsertIndicesToSet ( IndexSetType & iset ) : indexSet_ (iset) {}
632 
634  inline void apply ( EntityType & entity )
635  {
636  indexSet_.insertEntity( entity );
637  }
638  };
639 
640  template <class MemObjectType>
641  class ResizeMemoryObjects
642  : public LocalInlinePlus < ResizeMemoryObjects < MemObjectType > , typename MemObjectType::SizeType >
643  {
644  private:
645  // the dof set stores number of dofs on entity for each codim
646  MemObjectType& memobj_;
647 
648  public:
649  typedef typename MemObjectType::SizeType SizeType;
650 
651  // Constructor of MemObject, only to call from DofManager
652  ResizeMemoryObjects ( MemObjectType & mo ) : memobj_ (mo) {}
653  ResizeMemoryObjects ( const ResizeMemoryObjects& org )
654  : memobj_(org.memobj_)
655  {}
656 
657  // resize mem object, parameter not needed
658  inline void apply ( SizeType& enlargeOnly )
659  {
660  memobj_.resize( bool(enlargeOnly) );
661  }
662  };
663 
664  // this class is the object for a single MemObject to
665  template <class MemObjectType>
666  class ReserveMemoryObjects
667  : public LocalInlinePlus < ReserveMemoryObjects < MemObjectType > , typename MemObjectType::SizeType >
668  {
669  private:
670  // the dof set stores number of dofs on entity for each codim
671  MemObjectType& memobj_;
672 
673  public:
674  typedef typename MemObjectType::SizeType SizeType;
675 
676  // Constructor of MemObject, only to call from DofManager
677  ReserveMemoryObjects ( MemObjectType & mo ) : memobj_ (mo) {}
678 
679  // reserve for at least chunkSize new values
680  inline void apply ( SizeType& chunkSize )
681  {
682  memobj_.reserve( chunkSize );
683  }
684  };
685 
686 
687  // this is the dofmanagers object which is being used during restriction
688  // and prolongation process for adding and removing indices to and from
689  // index sets which belong to functions that belong to that dofmanager
690  template <class DofManagerType , class RestrictProlongIndexSetType, bool doResize >
691  class IndexSetRestrictProlong :
692  public RestrictProlongInterface<
693  RestrictProlongTraits<
694  IndexSetRestrictProlong<DofManagerType,RestrictProlongIndexSetType,doResize>, double > >
695  {
696  DofManagerType & dm_;
697 
698  RestrictProlongIndexSetType & insert_;
699  RestrictProlongIndexSetType & remove_;
700  public:
701 
702  IndexSetRestrictProlong ( DofManagerType & dm , RestrictProlongIndexSetType & is, RestrictProlongIndexSetType & rm )
703  : dm_(dm) , insert_( is ), remove_( rm ) {}
704 
706  template <class EntityType>
707  inline void restrictLocal ( const EntityType & father, const EntityType & son , bool initialize ) const
708  {
709  // insert index of father
710  insert_.apply( father );
711  // mark index of son for removal
712  remove_.apply( son );
713 
714  // resize memory if doResize is true
715  if ( doResize )
716  {
717  dm_.resizeMemory();
718  }
719  }
720 
721  template <class EntityType>
722  inline void restrictFinalize( const EntityType &father ) const
723  {}
724 
726  template <class EntityType>
727  inline void prolongLocal ( const EntityType & father, const EntityType & son , bool initialize ) const
728  {
729  // mark index of father for removal
730  remove_.apply( father );
731  // insert index of son
732  insert_.apply( son );
733 
734  // resize memory if doResize is true
735  if ( doResize )
736  {
737  dm_.resizeMemory();
738  }
739  }
740  };
741 
742  // empty restrict prolong operator
743  class EmptyIndexSetRestrictProlong :
744  public RestrictProlongInterface< RestrictProlongTraits< EmptyIndexSetRestrictProlong, double > >
745  {
746  public:
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 {}
754  };
755 
756 
757  class DofManError : public Exception {};
758 
774  // --DofManager
775  template< class Grid >
776  class DofManager :
777 #if HAVE_DUNE_ALUGRID
778  public IsDofManager,
779  public LoadBalanceHandleWithReserveAndCompress,
780 #endif
781 #if HAVE_DUNE_P4ESTGRID
782  public P4estGridLoadBalanceHandleWithReserveAndCompress,
783 #endif
784  // DofManager behaves like a communication data handle for load balancing
785  public CommDataHandleIF< DofManager< Grid >, char >
786  {
788 
789  friend struct DefaultSingletonFactory< const Grid*, ThisType >;
790  friend class DofManagerFactory< ThisType >;
791 
792  public:
794  typedef Grid GridType;
795 
796  typedef typename GridObjectStreamTraits< GridType >::InStreamType XtractStreamImplType;
797  typedef typename GridObjectStreamTraits< GridType >::OutStreamType InlineStreamImplType;
798  public:
799  // types of inlining and xtraction stream types
802 
803  // types of data collectors
806 
807  typedef typename GridType :: template Codim< 0 > :: Entity ElementType ;
808 
809  private:
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;
814 
815  // list with MemObjects, for each DiscreteFunction we have one MemObject
816  ListType memList_;
817 
818  // list of all different indexsets
819  IndexListType indexList_;
820 
821  // the dofmanager belong to one grid only
822  const GridType &grid_;
823 
824  // index set for mapping
825  mutable DataInlinerType dataInliner_;
826  mutable DataXtractorType dataXtractor_;
827 
830  typedef const ElementType ConstElementType;
831  typedef LocalInterface< ConstElementType > LocalIndexSetObjectsType;
832 
833  mutable LocalIndexSetObjectsType insertIndices_;
834  mutable LocalIndexSetObjectsType removeIndices_;
835 
836  // lists containing all MemObjects
837  // to have fast access during resize and reserve
838  mutable MemObjectCheckType resizeMemObjs_;
839  mutable MemObjectCheckType reserveMemObjs_;
840 
842  const MemObjSizeType defaultChunkSize_;
843 
845  int sequence_;
846 
847  public:
848  typedef IndexSetRestrictProlong< ThisType, LocalIndexSetObjectsType , true >
849  NewIndexSetRestrictProlongType;
850  typedef IndexSetRestrictProlong< ThisType, LocalIndexSetObjectsType , false >
851  IndexSetRestrictProlongNoResizeType;
852 
853  // old type
854  typedef EmptyIndexSetRestrictProlong IndexSetRestrictProlongType;
855 
856  // this class needs to call resizeMemory
857  friend class IndexSetRestrictProlong< ThisType , LocalIndexSetObjectsType , true > ;
858  friend class IndexSetRestrictProlong< ThisType , LocalIndexSetObjectsType , false > ;
859 
860  private:
861  // combine object holding all index set for restrict and prolong
862  NewIndexSetRestrictProlongType indexSetRestrictProlong_;
863  IndexSetRestrictProlongNoResizeType indexSetRestrictProlongNoResize_;
864 
865  // old type
866  IndexSetRestrictProlongType indexRPop_;
867 
869  double memoryFactor_;
870 
872  const bool clearResizedArrays_;
873 
874  //**********************************************************
875  //**********************************************************
877  inline explicit DofManager ( const GridType *grid )
878  : grid_( *grid ),
879  defaultChunkSize_( 128 ),
880  sequence_( 0 ),
881  indexSetRestrictProlong_( *this, insertIndices_ , removeIndices_ ),
882  indexSetRestrictProlongNoResize_( *this, insertIndices_ , removeIndices_ ),
883  indexRPop_(),
884  memoryFactor_( Parameter :: getValidValue( "fem.dofmanager.memoryfactor", double( 1.1 ),
885  [] ( double value ) { return value >= 1.0; } ) ),
886  clearResizedArrays_( Parameter :: getValue("fem.dofmanager.clearresizedarrays", bool( true ) ) )
887  {
888  // only print memory factor if it deviates from the default value
889  if( std::abs( memoryFactor_ - 1.1 ) > 1e-12 )
890  {
891  if( Parameter::verbose( Parameter::parameterOutput ) && (grid_.comm().rank() == 0) )
892  std::cout << "Created DofManager with memory factor " << memoryFactor_ << "." << std::endl;
893  }
894  }
895 
897  ~DofManager ();
898 
899  public:
900  DofManager( const ThisType& ) = delete;
901 
903  double memoryFactor() const { return memoryFactor_; }
904 
923  template <class IndexSetType>
924  inline void addIndexSet (const IndexSetType &iset );
925 
933  template <class IndexSetType>
934  inline void removeIndexSet (const IndexSetType &iset );
935 
940  template <class ManagedDofStorageImp>
941  void addDofStorage(ManagedDofStorageImp& dofStorage);
942 
947  template <class ManagedDofStorageImp>
948  void removeDofStorage(ManagedDofStorageImp& dofStorage);
949 
951  NewIndexSetRestrictProlongType & indexSetRestrictProlong ()
952  {
953  // hier muss statt dessen ein Combiniertes Object erzeugt werden.
954  // dafuer sollte bei einhaengen der IndexSets ein Methoden Pointer
955  // erzeugt werden, welcher die den IndexSet mit einem anderen Object
956  // kombiniert
957  return indexSetRestrictProlong_;
958  }
959 
961  IndexSetRestrictProlongNoResizeType& indexSetRestrictProlongNoResize()
962  {
963  // return index set restrict/prolong operator that is only inserting
964  // and mark for removal indices but not doing resize
965  return indexSetRestrictProlongNoResize_;
966  }
967 
969  bool hasIndexSets() const
970  {
971  return ! insertIndices_.empty();
972  }
973 
975  size_t usedMemorySize () const
976  {
977  size_t used = 0;
978  for(auto memObjectPtr : memList_)
979  used += memObjectPtr->usedMemorySize();
980  return used;
981  }
982 
987  {
988  resizeMemory();
989  }
990 
993  void reserveMemory ( std::size_t nsize, bool dummy = false )
994  {
995  MemObjSizeType localChunkSize =
996  std::max( MemObjSizeType(nsize), defaultChunkSize_ );
997  assert( localChunkSize > 0 );
998 
999  // reserves (size + chunkSize * elementMemory), see above
1000  reserveMemObjs_.apply ( localChunkSize );
1001  }
1002 
1007  int sequence () const { return sequence_; }
1008 
1012  void resize()
1013  {
1014  for(auto indexSetPtr : indexList_)
1015  indexSetPtr->resize();
1016  resizeMemory();
1017  }
1018 
1020  inline void insertEntity( ConstElementType & element )
1021  {
1022  // insert new index
1023  insertIndices_.apply( element );
1024 
1025  // resize memory
1026  resizeMemory();
1027  }
1028 
1030  inline void removeEntity( ConstElementType & element ) const
1031  {
1032  // remove entity from index sets in removeIndices list
1033  removeIndices_.apply( element );
1034  }
1035 
1038  {
1039  MemObjSizeType enlargeOnly( 0 );
1040  // pass dummy parameter
1041  resizeMemObjs_.apply ( enlargeOnly );
1042  }
1043 
1046  {
1047  MemObjSizeType enlargeOnly( 1 );
1048  // pass dummy parameter
1049  resizeMemObjs_.apply ( enlargeOnly );
1050  }
1051 
1056  {
1057  // mark next sequence
1058  ++sequence_;
1059 
1060  // check that sequence number is the same for all processes
1061  assert( sequence_ == grid_.comm().max( sequence_ ) );
1062  }
1063 
1064  //- --compress
1068  void compress()
1069  {
1070  // mark next sequence
1072 
1073  // compress indexsets first
1074  for(auto indexSetPtr : indexList_)
1075  {
1076  // reset compressed so the next time compress of index set is called
1077  indexSetPtr->compress();
1078  }
1079 
1080  // compress all data now
1081  for(auto memObjectPtr : memList_)
1082  {
1083  // if correponding index was not compressed yet, this is called in
1084  // the MemObject dofCompress, if index has not changes, nothing happens
1085  // if IndexSet actual needs no compress, nothing happens to the
1086  // data either
1087  // also data is resized, which means the vector is getting shorter
1088  memObjectPtr->dofCompress ( clearResizedArrays_ );
1089  }
1090  }
1091 
1093  bool notifyGlobalChange( const bool wasChanged ) const
1094  {
1095  // make sure that wasChanged is the same on all cores
1096  int wasChangedCounter = int( wasChanged );
1097  return bool( grid_.comm().max( wasChangedCounter ) );
1098  }
1099 
1101  template <class DataCollType>
1102  void addDataInliner ( DataCollType & d)
1103  {
1104  dataInliner_ += d;
1105  }
1106 
1109  {
1110  dataInliner_.clear();
1111  }
1112 
1114  template <class DataCollType>
1115  void addDataXtractor ( DataCollType & d)
1116  {
1117  dataXtractor_ += d;
1118  }
1119 
1122  {
1123  dataXtractor_.clear();
1124  }
1125 
1127  // CommDataHandleIF methods
1129 
1131  bool contains( const int dim, const int codim ) const
1132  {
1133  return ( codim == 0 );
1134  }
1135 
1137  bool fixedSize( const int dim, const int codim ) const
1138  {
1139  return false;
1140  }
1141 
1143  template <class Entity>
1144  size_t size( const Entity& ) const
1145  {
1146  DUNE_THROW(NotImplemented,"DofManager::size should not be called!");
1147  return -1;
1148  }
1149 
1151  void gather( InlineStreamType& str, ConstElementType& element ) const
1152  {
1153  // pack all data to stream
1154  dataInliner_.apply(str, element);
1155 
1156  // remove entity from index sets
1157  //const_cast< ThisType & >( *this ).removeEntity( element );
1158  removeEntity( element );
1159  }
1160 
1161  template <class MessageBuffer, class Entity>
1162  void gather( MessageBuffer& str, const Entity& entity ) const
1163  {
1164  // if this method is called then either the message buffer is
1165  // not of the correct type or an entity of higher codimension
1166  // was passed along
1167  DUNE_THROW(NotImplemented,"DofManager::gather( entity ) with codim > 0 not implemented");
1168  }
1169 
1171  void scatter ( XtractStreamType& str, ConstElementType& element, size_t )
1172  {
1173  // insert entity into index sets
1174  insertEntity( element );
1175 
1176  // here the elements already have been created
1177  // that means we can xtract data
1178  dataXtractor_.apply(str, element);
1179  }
1180 
1182  template <class MessageBuffer, class Entity>
1183  void scatter ( MessageBuffer & str, const Entity& entity, size_t )
1184  {
1185  // if this method is called then either the message buffer is
1186  // not of the correct type or an entity of higher codimension
1187  // was passed along
1188  DUNE_THROW(NotImplemented,"DofManager::scatter( entity ) with codim > 0 not implemented");
1189  }
1190 
1191  //********************************************************
1192  // Interface for PersistentObjects
1193  //********************************************************
1194 
1196  void backup () const
1197  {
1198  for(auto indexSetPtr : indexList_)
1199  indexSetPtr->backup();
1200  }
1201 
1203  void restore ()
1204  {
1205  for(auto indexSetPtr : indexList_)
1206  indexSetPtr->restore();
1207 
1208  // make all index sets consistent
1209  // before any data is read this can be
1210  // assured since DofManager is an
1211  // AutoPersistentObject and thus in the
1212  // beginning of the list, fater the grid of course
1213  resize();
1214  }
1215 
1216  //********************************************************
1217  // read/write using fem streams
1218  //********************************************************
1223  template < class OutStream >
1224  void write( OutStream& out ) const
1225  {
1226  for(auto indexSetPtr : indexList_)
1227  indexSetPtr->write( out );
1228  }
1229 
1234  template < class InStream >
1235  void read( InStream& in )
1236  {
1237  for(auto indexSetPtr : indexList_)
1238  indexSetPtr->read( in );
1239  }
1240 
1241  //********************************************************
1242  // Interface for DofManager access
1243  //********************************************************
1244 
1251  static inline ThisType& instance( const GridType& grid )
1252  {
1253  typedef DofManagerFactory< ThisType > DofManagerFactoryType;
1254  return DofManagerFactoryType :: instance( grid );
1255  }
1256  };
1257 
1258  //***************************************************************************
1259  //
1260  // inline implemenations
1261  //
1262  //***************************************************************************
1263 
1264  template <class GridType>
1265  inline DofManager<GridType>::~DofManager ()
1266  {
1267  // enable output if verbosity level is debugOutput
1268  const bool verbose = Parameter::verbose( Parameter::debugOutput );
1269  if(memList_.size() > 0)
1270  {
1271  while( memList_.rbegin() != memList_.rend())
1272  {
1273  DofStorageInterface * mobj = (* memList_.rbegin() );
1274  if( verbose )
1275  std::cout << "Removing '" << mobj << "' from DofManager!\n";
1276  memList_.pop_back();
1277  }
1278  }
1279 
1280  if(indexList_.size() > 0)
1281  {
1282  if( verbose )
1283  std::cerr << "ERROR: Not all index sets have been removed from DofManager yet!" << std::endl;
1284  while ( indexList_.rbegin() != indexList_.rend())
1285  {
1286  ManagedIndexSetInterface* iobj = (* indexList_.rbegin() );
1287  indexList_.pop_back();
1288  if(iobj) delete iobj;
1289  }
1290  }
1291  }
1292 
1293  template <class GridType>
1294  template <class IndexSetType>
1296  addIndexSet (const IndexSetType &iset )
1297  {
1298  // only call in single thread mode
1299  if( ! Fem :: MPIManager :: singleThreadMode() )
1300  {
1301  assert( Fem :: MPIManager :: singleThreadMode() );
1302  DUNE_THROW(InvalidStateException,"DofManager::addIndexSet: only call in single thread mode!");
1303  }
1304 
1305  typedef ManagedIndexSet< IndexSetType, ConstElementType > ManagedIndexSetType;
1306  ManagedIndexSetType * indexSet = 0;
1307 
1308  // search index set list in reverse order to find latest index sets faster
1309  auto endit = indexList_.rend();
1310  for(auto it = indexList_.rbegin(); it != endit; ++it )
1311  {
1312  ManagedIndexSetInterface *set = *it;
1313  if( set->equals( iset ) )
1314  {
1315  set->addReference();
1316 
1317  indexSet = static_cast< ManagedIndexSetType * >( set );
1318  break;
1319  }
1320  }
1321 
1322  if( !indexSet )
1323  {
1324  indexSet = new ManagedIndexSetType ( iset, insertIndices_ , removeIndices_ );
1325  indexList_.push_back( static_cast< ManagedIndexSetInterface * >( indexSet ) );
1326  }
1327  }
1328 
1329  template <class GridType>
1330  template <class IndexSetType>
1331  inline void DofManager<GridType>::removeIndexSet ( const IndexSetType &iset )
1332  {
1333  // only call in single thread mode
1334  if( ! Fem :: MPIManager :: singleThreadMode() )
1335  {
1336  assert( Fem :: MPIManager :: singleThreadMode() );
1337  DUNE_THROW(InvalidStateException,"DofManager::removeIndexSet: only call in single thread mode!");
1338  }
1339 
1340  // search index set list in reverse order to find latest index sets faster
1341  auto endit = indexList_.rend();
1342  for( auto it = indexList_.rbegin(); it != endit; ++it )
1343  {
1344  ManagedIndexSetInterface *set = *it;
1345  if( set->equals( iset ) )
1346  {
1347  if( set->removeReference() )
1348  {
1349  // reverse iterators cannot be erased directly, so erase the base
1350  // (forward) iterator
1351  // Note: see, e.g., Stroustrup, section 16.3.2 about the decrement
1352  auto fit = it.base();
1353  indexList_.erase( --fit );
1354  // delete proxy
1355  delete set;
1356  }
1357  return;
1358  }
1359  }
1360 
1361  // we should never get here
1362  DUNE_THROW(InvalidStateException,"Could not remove index from DofManager set!");
1363  }
1364 
1365  template <class GridType>
1366  template <class ManagedDofStorageImp>
1367  void DofManager<GridType>::addDofStorage(ManagedDofStorageImp& dofStorage)
1368  {
1369  // make sure we got an ManagedDofStorage
1370  ManagedDofStorageInterface* obj = &dofStorage;
1371 
1372  // push_front, makes search faster
1373  memList_.push_front( obj );
1374 
1375  // add the special object to the memResize list object
1376  resizeMemObjs_ += dofStorage.resizeMemoryObject();
1377 
1378  // the same for the reserve call
1379  reserveMemObjs_ += dofStorage.reserveMemoryObject();
1380  }
1381 
1382 
1383  template <class GridType>
1384  template <class ManagedDofStorageImp>
1385  void DofManager<GridType>::removeDofStorage(ManagedDofStorageImp& dofStorage)
1386  {
1387  // make sure we got an ManagedDofStorage
1388  auto obj = &dofStorage;
1389 
1390  // search list starting from tail
1391  auto endit = memList_.end();
1392  for( auto it = memList_.begin();it != endit ; ++it)
1393  {
1394  if(*it == obj)
1395  {
1396  // alloc new mem and copy old mem
1397  memList_.erase( it );
1398 
1399  // remove from list
1400  resizeMemObjs_.remove( dofStorage.resizeMemoryObject() );
1401  reserveMemObjs_.remove( dofStorage.reserveMemoryObject() );
1402 
1403  return ;
1404  }
1405  }
1406  }
1407 
1409 
1410 
1418  template< class DofManagerImp >
1420  {
1422 
1423  public:
1424  typedef DofManagerImp DofManagerType;
1425  typedef typename DofManagerType :: GridType GridType;
1426 
1427  private:
1428  typedef const GridType *KeyType;
1429 
1431 
1432  // declare friendship becase of methods instance
1433  friend class DofManager< GridType >;
1434 
1435  protected:
1442  inline static DofManagerType &instance ( const GridType &grid )
1443  {
1444  DofManagerType *dm = getDmFromList( grid );
1445  if( !dm )
1446  return DMProviderType :: getObject( &grid );
1447  return *dm;
1448  }
1449 
1451  inline static bool
1452  writeDofManagerNew ( const GridType &grid,
1453  const std :: string &filename,
1454  int timestep )
1455  {
1456  DofManagerType *dm = getDmFromList( grid );
1457  /*
1458  if( dm )
1459  return dm->writeIndexSets( filename, timestep );
1460  */
1461  return false;
1462  }
1463 
1465  inline static bool
1466  readDofManagerNew ( const GridType &grid,
1467  const std :: string &filename,
1468  int timestep )
1469  {
1470  DofManagerType *dm = getDmFromList( grid );
1471  /*
1472  if( dm )
1473  return dm->readIndexSets( filename, timestep );
1474  */
1475  return false;
1476  }
1477 
1478  public:
1480  inline static void deleteDofManager ( DofManagerType &dm )
1481  {
1483  }
1484 
1485  private:
1486  // return pointer to dof manager for given grid
1487  inline static DofManagerType *getDmFromList( const GridType &grid )
1488  {
1489  return (DMProviderType :: getObjFromList( &grid )).first;
1490  }
1491  };
1492 
1493  } // namespace Fem
1494 
1495 } // namespace Dune
1496 
1497 #endif // #ifndef DUNE_FEM_DOFMANAGER_HH
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:456
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
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
DofArrayType & getArray()
return reference to array for DiscreteFunction
Definition: dofmanager.hh:436
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
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
virtual void resize(const bool enlargeOnly)=0
resize memory
virtual ~ManagedDofStorageInterface()=default
destructor
IndexSetRestrictProlongNoResizeType & indexSetRestrictProlongNoResize()
returns the index set restriction and prolongation operator
Definition: dofmanager.hh:961
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
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
DofStorageInterface()=default
do not allow to create explicit instances
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
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
NewIndexSetRestrictProlongType & indexSetRestrictProlong()
returns the index set restriction and prolongation operator
Definition: dofmanager.hh:951
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
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
static DofManagerType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1442
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
ReserveMemoryObjectType & reserveMemoryObject()
return object that calls reserve of this memory object
Definition: dofmanager.hh:338
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
ResizeMemoryObjectType & resizeMemoryObject()
return object that calls resize of this memory object
Definition: dofmanager.hh:335
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
concept MessageBuffer
Model of a message buffer.
Definition: messagebuffer.hh:17
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13
Standard Dune debug streams.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 10, 22:30, 2024)