dune-fem  2.4.1-rc
dofmanager.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_DOFMANAGER_HH
2 #define DUNE_FEM_DOFMANAGER_HH
3 
4 #include <cassert>
5 #include <string>
6 #include <list>
7 
8 #include <dune/common/exceptions.hh>
9 #include <dune/common/stdstreams.hh>
10 #include <dune/common/version.hh>
11 
12 #include <dune/grid/alugrid/common/interfaces.hh>
13 
14 #include <dune/fem/io/parameter.hh>
24 
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
28 
29 #include <dune/grid/common/datahandleif.hh>
30 #if HAVE_DUNE_ALUGRID
31 #include <dune/alugrid/common/ldbhandleif.hh>
32 #endif
33 
34 namespace Dune
35 {
36 
37  namespace Fem
38  {
39 
45  // forward declaration
46  template <class GridType> class DofManager;
47  template <class DofManagerImp> class DofManagerFactory;
48 
53  template<class ArrayType>
55  {
57  typedef typename ArrayType :: value_type ValueType;
58 
60  static size_t used(const ArrayType & array)
61  {
62  return array.size() * sizeof(ValueType);
63  }
64 
66  static void setMemoryFactor(ArrayType & array, const double memFactor)
67  {
68  }
69 
71  static inline
72  void memMoveBackward(ArrayType& array, const int length,
73  const int oldStartIdx, const int newStartIdx)
74  {
75  // get new end of block which is offSet + (length of block - 1)
76  int newIdx = newStartIdx + length - 1;
77  // copy all entries backwards
78  for(int oldIdx = oldStartIdx+length-1; oldIdx >= oldStartIdx; --oldIdx, --newIdx )
79  {
80  // move value to new location
81  array[newIdx] = array[oldIdx];
82  }
83  }
84 
86  static inline
87  void memMoveForward(ArrayType& array, const int length,
88  const int oldStartIdx, const int newStartIdx)
89  {
90  const int upperBound = oldStartIdx + length;
91  // get new off set that should be smaller then old one
92  int newIdx = newStartIdx;
93  for(int oldIdx = oldStartIdx; oldIdx<upperBound; ++oldIdx, ++newIdx )
94  {
95  // copy to new location
96  array[newIdx] = array[oldIdx];
97  }
98  }
99 
101  static inline
102  void assign( ArrayType& array, const int newIndex, const int oldIndex )
103  {
104  array[ newIndex ] = array[ oldIndex ];
105  }
106  };
107 
109  //
110  // ManagedIndexSetInterface
111  //
113 
119  {
121  protected:
122  // use address of object as id
123  typedef const void * IdentifierType;
124  // pointer to compare index sets
125  IdentifierType setPtr_;
126  // reference counter
128 
129  template< class IndexSet >
130  explicit ManagedIndexSetInterface ( const IndexSet &iset )
131  : setPtr_( getIdentifier( iset ) ),
132  referenceCounter_( 1 )
133  {
134  }
135 
136  public:
138 
140  virtual void resize () = 0;
142  virtual bool compress () = 0;
143 
145  virtual void backup() const = 0;
147  virtual void restore() = 0;
148 
150  virtual void write( XDRFileOutStream& out ) const = 0;
151  virtual void read( XDRFileInStream& out ) = 0;
152 
154  virtual void write( StandardOutStream& out ) const = 0;
155  virtual void read( StandardInStream& out ) = 0;
156 
158  void addReference ( ) { ++referenceCounter_; }
159 
162  {
163  return (--referenceCounter_ == 0);
164  }
165 
166  template< class IndexSet >
167  bool equals ( const IndexSet &iset ) const
168  {
169  return (getIdentifier( iset ) == setPtr_);
170  }
171 
172  private:
173  template< class IndexSet >
174  IdentifierType getIdentifier ( const IndexSet &iset ) const
175  {
176  return static_cast< IdentifierType >( &iset );
177  }
178  };
179 
180  template <class IndexSetType, class EntityType> class RemoveIndicesFromSet;
181  template <class IndexSetType, class EntityType> class InsertIndicesToSet;
182 
183  template <class IndexSetType, class EntityType>
185  public ManagedIndexSetInterface ,
186  public LocalInlinePlus < ManagedIndexSet<IndexSetType,EntityType> , EntityType >
187  {
189  protected:
190  // the dof set stores number of dofs on entity for each codim
191  IndexSetType & indexSet_;
192 
193  // insertion and removal of indices
196 
197  LocalIndexSetObjectsType & indexSetList_;
198  LocalIndexSetObjectsType & insertList_;
199  LocalIndexSetObjectsType & removeList_;
200 
201  public:
204 
206  ManagedIndexSet ( const IndexSetType & iset,
207  LocalIndexSetObjectsType & indexSetList,
208  LocalIndexSetObjectsType & insertList,
209  LocalIndexSetObjectsType & removeList )
210  : BaseType( iset )
211  , indexSet_ (const_cast<IndexSetType &> (iset))
212  , insertIdxObj_(indexSet_), removeIdxObj_(indexSet_)
213  , indexSetList_(indexSetList)
214  , insertList_(insertList)
215  , removeList_(removeList)
216  {
217  this->setPtr_ = (void *) &indexSet_;
218 
219  indexSetList_ += *this;
220  if( indexSet_.consecutive() )
221  {
222  insertList_ += insertIdxObj_;
223  removeList_ += removeIdxObj_;
224  }
225  }
226 
229  {
230  indexSetList_.remove( *this );
231  if( indexSet_.consecutive() )
232  {
233  insertList_.remove( insertIdxObj_ );
234  removeList_.remove( removeIdxObj_ );
235  }
236  }
237 
239  void resize ()
240  {
241  indexSet_.resize();
242  }
243 
245  bool compress ()
246  {
247  return indexSet_.compress();
248  }
249 
250  // forward backup call to indexSet
251  virtual void backup () const
252  {
253  indexSet_.backup();
254  }
255 
256  // forward restore call to indexSet
257  virtual void restore ()
258  {
259  indexSet_.restore();
260  }
261 
263  virtual void read( XDRFileInStream& in ) { indexSet_.read( in ); }
264 
266  virtual void write( XDRFileOutStream& out ) const { indexSet_.write( out ); }
267 
269  virtual void read( StandardInStream& in ) { indexSet_.read( in ); }
270 
272  virtual void write( StandardOutStream& out ) const { indexSet_.write( out ); }
273  };
274 
276  //
277  // DofStorageInterface
278  //
280 
283  {
284  protected:
287 
288  public:
290  virtual ~DofStorageInterface() {};
291 
293  virtual void enableDofCompression() { }
294 
296  virtual const std::string& name () const = 0;
297 
299  virtual int size () const = 0;
300  };
301 
302 
307  {
308  protected:
311 
312  public:
315 
317  virtual void resize () = 0;
319  virtual void reserve (int newSize) = 0;
321  virtual void dofCompress () = 0;
323  virtual size_t usedMemorySize() const = 0;
324  };
325 
326 
327  template <class MemObjectType> class ResizeMemoryObjects;
328  template <class MemObjectType> class ReserveMemoryObjects;
329 
341  template <class GridImp, class MapperType , class DofArrayType>
343  {
344  // interface for MemObject lists
346  protected:
347  // type of this class
349 
351 
352  // reference to dof manager
353  DofManagerType &dm_;
354 
355  // the dof set stores number of dofs on entity for each codim
356  MapperType &mapper_;
357 
358  // Array which the dofs are stored in
359  DofArrayType& array_;
360 
361  // name of mem object, i.e. name of discrete function
362  std::string name_;
363 
366  ResizeMemoryObjectType resizeMemObj_;
367  ReserveMemoryObjectType reserveMemObj_;
368 
369  // true if data need to be compressed
371 
372  // prohibit copying
374  protected:
376  ManagedDofStorageImplementation ( const GridImp& grid,
377  const MapperType& mapper,
378  const std::string& name,
379  DofArrayType& array )
380  : dm_( DofManagerType :: instance( grid ) ),
381  mapper_ ( const_cast<MapperType& >(mapper)),
382  array_( array ),
383  name_ (name),
384  resizeMemObj_(*this),
385  reserveMemObj_(*this),
386  dataCompressionEnabled_(false)
387  {
388  // add to dof manager
389  dm_.addDofStorage( *this );
390 
391  // set memory over estimate factor, only for DofArray
393  }
394 
397  {
398  // remove from dof manager
399  dm_.removeDofStorage( *this );
400  }
401 
402  public:
404  ResizeMemoryObjectType& resizeMemoryObject() { return resizeMemObj_; }
405 
407  ReserveMemoryObjectType& reserveMemoryObject() { return reserveMemObj_; }
408 
410  const std::string& name () const { return name_; }
411 
413  int size () const { return array_.size(); }
414 
416  void resize ()
417  {
418  // store old size of space (don't use mapper here)
419  const int oldSize = array_.size();
420 
421  // get current size
422  const int nSize = mapper().size();
423 
424  // if nothing changed do nothing
425  if( nSize == oldSize ) return ;
426 
427  // resize memory to current value
428  array_.resize( nSize );
429 
430  // if data is only temporary data, don't adjust memory
431  if( ! dataCompressionEnabled_ ) return ;
432 
433  // now check all blocks beginning with the largest
434  const int numBlocks = mapper().numBlocks();
435 
436  // initialize upperBound
437  int upperBound = oldSize ;
438 
439  // make sure offset of block 0 is zero
440  assert( mapper().offSet( 0 ) == 0 );
441  assert( mapper().oldOffSet( 0 ) == 0 );
442 
443  // skip block 0 (since offset == 0)
444  for( int block = numBlocks-1; block >= 1; --block )
445  {
446  // get offsets
447  const int newOffSet = mapper().offSet( block );
448  const int oldOffSet = mapper().oldOffSet( block );
449 
450  // make sure new offset is larger
451  assert( newOffSet >= oldOffSet );
452 
453  // if off set is not zero
454  if( newOffSet > oldOffSet )
455  {
456  // calculate block size
457  const int blockSize = upperBound - oldOffSet;
458  // move block backward
460  :: memMoveBackward( array_, blockSize, oldOffSet, newOffSet );
461 
462  // update upper bound
463  upperBound = oldOffSet;
464  }
465  }
466  }
467 
469  inline void reserve ( const int needed )
470  {
471  // if index set is compressible, then add requested size
472  if( mapper().consecutive() )
473  {
474  const int nSize = size() + (needed * mapper().maxNumDofs());
475  array_.reserve( nSize );
476  }
477  else
478  {
479  // if compress is not needed just resize with given size
480  // therefore use newSize to enleage array
481  assert( ! mapper().consecutive() );
482  // resize array
483  resize ();
484  }
485  }
486 
488  void dofCompress ()
489  {
490  // get current size
491  const int nSize = mapper().size();
492 
493  // if data is non-temporary do data compression
494  if( dataCompressionEnabled_ )
495  {
496  // get old size (which we still have in array)
497  const int oldSize = array_.size();
498 
499  // NOTE: new size can also be larger than old size
500  // e.g. during loadBalancing when ghosts where
501  // introduced before compressing the index set
502 
503  // begin with block zero since closing of holes
504  // has to be done anyway if the mapper is consecutive
505  const int numBlocks = mapper().numBlocks();
506  for( int block = 0; block < numBlocks; ++block )
507  {
508  // move memory
509  moveToFront( oldSize, block );
510 
511  // only close holes for consecutive mappers
512  if( mapper().consecutive () )
513  {
514  // run over all holes and copy array vules to new place
515  const int holes = mapper().numberOfHoles( block );
516  for( int i = 0; i < holes; ++i )
517  {
518  const int oldIndex = mapper().oldIndex( i, block );
519  const int newIndex = mapper().newIndex( i, block );
520 
521  assert( newIndex < nSize );
522  // implements array_[ newIndex ] = array_[ oldIndex ] ;
523  SpecialArrayFeatures< DofArrayType > :: assign( array_, newIndex, oldIndex );
524  }
525  }
526  }
527  }
528 
529  // store new size, which should be smaller then actual size
530  array_.resize( nSize );
531  }
532 
534  size_t usedMemorySize() const
535  {
536  return ((size_t) sizeof(ThisType) + SpecialArrayFeatures<DofArrayType>::used(array_));
537  }
538 
541  {
542  dataCompressionEnabled_ = true;
543  }
544 
546  DofArrayType & getArray() { return array_; }
547 
548  protected:
549  inline MapperType &mapper () const
550  {
551  return mapper_;
552  }
553 
554  // move array to rear insertion points
556  {
557  }
558 
560  void moveToFront ( const int oldSize, const int block )
561  {
562  // get insertion point from block
563  const int oldOffSet = mapper().oldOffSet( block );
564 
565  // get new off set
566  const int newOffSet = mapper().offSet( block );
567 
568  // here we should have at least the same offsets
569  assert( newOffSet <= oldOffSet );
570 
571  // only if block is not starting from zero
572  if( newOffSet < oldOffSet )
573  {
574  // get number of blocks
575  const int numBlocks = mapper().numBlocks();
576 
577  // for last section upperBound is size
578  const int upperBound
579  = (block == numBlocks - 1) ? oldSize : mapper().oldOffSet( block + 1 );
580  const int blockSize = upperBound - oldOffSet;
581 
582  // move block forward
584  :: memMoveForward( array_, blockSize, oldOffSet, newOffSet );
585  }
586  }
587  };
588 
590  template <class GridImp, class MapperType , class DofArrayType>
591  class ManagedDofStorage : public ManagedDofStorageImplementation< GridImp, MapperType, DofArrayType >
592  {
594  protected:
595  DofArrayType myArray_;
596  public:
598  ManagedDofStorage( const GridImp& grid,
599  const MapperType& mapper,
600  const std::string& name )
601  : BaseType( grid, mapper, name, myArray_ ),
602  myArray_( mapper.size() )
603  {
604  }
605  };
606 
608  template< class DofStorageType, class GridType, class MapperType >
609  static inline std::pair< DofStorageInterface* , DofStorageType* >
610  allocateManagedDofStorage( const GridType& grid,
611  const MapperType& mapper,
612  const std::string& name,
613  const DofStorageType * = 0 )
614  {
615  // create managed dof storage
616  typedef ManagedDofStorage< GridType, MapperType,
617  DofStorageType > ManagedDofStorageType;
618 
619  ManagedDofStorageType* mds =
620  new ManagedDofStorageType( grid, mapper, name );
621  assert( mds );
622 
623  // return pair with dof storage pointer and array pointer
624  return std::pair< DofStorageInterface* , DofStorageType* >
625  ( mds , & mds->getArray () );
626  }
627 
628 
629 
631  //
632  // RestrictPorlong for Index Sets
633  //
635 
636  template <class IndexSetType, class EntityType>
638  : public LocalInlinePlus < RemoveIndicesFromSet<IndexSetType,EntityType> , EntityType >
639  {
640  private:
641  // the dof set stores number of dofs on entity for each codim
642  IndexSetType & indexSet_;
643 
644  public:
645  // Constructor of MemObject, only to call from DofManager
646  explicit RemoveIndicesFromSet ( IndexSetType & iset ) : indexSet_ (iset) {}
647 
649  inline void apply ( EntityType & entity )
650  {
651  indexSet_.removeEntity( entity );
652  }
653  };
654 
655  template <class IndexSetType, class EntityType>
656  class InsertIndicesToSet
657  : public LocalInlinePlus < InsertIndicesToSet< IndexSetType, EntityType > , EntityType >
658  {
659  private:
660  // the dof set stores number of dofs on entity for each codim
661  IndexSetType & indexSet_;
662 
663  public:
664  // Constructor of MemObject, only to call from DofManager
665  explicit InsertIndicesToSet ( IndexSetType & iset ) : indexSet_ (iset) {}
666 
668  inline void apply ( EntityType & entity )
669  {
670  indexSet_.insertEntity( entity );
671  }
672  };
673 
674  template <class MemObjectType>
675  class ResizeMemoryObjects
676  : public LocalInlinePlus < ResizeMemoryObjects < MemObjectType > , int >
677  {
678  private:
679  // the dof set stores number of dofs on entity for each codim
680  MemObjectType & memobj_;
681 
682  public:
683  // Constructor of MemObject, only to call from DofManager
684  ResizeMemoryObjects ( MemObjectType & mo ) : memobj_ (mo) {}
686  : memobj_(org.memobj_)
687  {}
688 
689  // resize mem object, parameter not needed
690  inline void apply ( int & )
691  {
692  memobj_.resize();
693  }
694  };
695 
696  // this class is the object for a single MemObject to
697  template <class MemObjectType>
699  : public LocalInlinePlus < ReserveMemoryObjects < MemObjectType > , int >
700  {
701  private:
702  // the dof set stores number of dofs on entity for each codim
703  MemObjectType & memobj_;
704 
705  public:
706  // Constructor of MemObject, only to call from DofManager
707  ReserveMemoryObjects ( MemObjectType & mo ) : memobj_ (mo) {}
708 
709  // reserve for at least chunkSize new values
710  inline void apply ( int & chunkSize )
711  {
712  memobj_.reserve( chunkSize );
713  }
714  };
715 
716 
717  // this is the dofmanagers object which is being used during restriction
718  // and prolongation process for adding and removing indices to and from
719  // index sets which belong to functions that belong to that dofmanager
720  template <class DofManagerType , class RestrictProlongIndexSetType, bool doResize >
723  RestrictProlongTraits<
724  IndexSetRestrictProlong<DofManagerType,RestrictProlongIndexSetType,doResize>, double > >
725  {
726  DofManagerType & dm_;
727 
728  RestrictProlongIndexSetType & insert_;
729  RestrictProlongIndexSetType & remove_;
730  public:
731 
732  IndexSetRestrictProlong ( DofManagerType & dm , RestrictProlongIndexSetType & is, RestrictProlongIndexSetType & rm )
733  : dm_(dm) , insert_( is ), remove_( rm ) {}
734 
736  template <class EntityType>
737  inline void restrictLocal ( const EntityType & father, const EntityType & son , bool initialize ) const
738  {
739  // insert index of father
740  insert_.apply( father );
741  // mark index of son for removal
742  remove_.apply( son );
743 
744  // resize memory if doResize is true
745  if ( doResize )
746  {
747  dm_.resizeMemory();
748  }
749  }
750 
752  template <class EntityType>
753  inline void prolongLocal ( const EntityType & father, const EntityType & son , bool initialize ) const
754  {
755  // mark index of father for removal
756  remove_.apply( father );
757  // insert index of son
758  insert_.apply( son );
759 
760  // resize memory if doResize is true
761  if ( doResize )
762  {
763  dm_.resizeMemory();
764  }
765  }
766  };
767 
768  // empty restrict prolong operator
770  public RestrictProlongInterface< RestrictProlongTraits< EmptyIndexSetRestrictProlong, double > >
771  {
772  public:
775  template <class EntityType>
776  inline void restrictLocal ( EntityType & father, EntityType & son , bool initialize ) const {}
778  template <class EntityType>
779  inline void prolongLocal ( EntityType & father, EntityType & son , bool initialize ) const {}
780  };
781 
782 
783  class DofManError : public Exception {};
784 
800  // --DofManager
801  template< class Grid >
802  class DofManager : public IsDofManager,
803 #if HAVE_DUNE_ALUGRID
804  public LoadBalanceHandleWithReserveAndCompress,
805 #endif
806  // DofManager behaves like a communication data handle for load balancing
807  public CommDataHandleIF< DofManager< Grid >, char >
808  {
809  typedef DofManager< Grid > ThisType;
810 
811  friend struct DefaultSingletonFactory< const Grid*, ThisType >;
812  friend class DofManagerFactory< ThisType >;
813 
814  public:
816  typedef Grid GridType;
817 
820  public:
821  // types of inlining and xtraction stream types
822  typedef MessageBufferIF< XtractStreamImplType > XtractStreamType;
823  typedef MessageBufferIF< InlineStreamImplType > InlineStreamType;
824 
825  // types of data collectors
828 
829  typedef typename GridType :: template Codim< 0 > :: Entity ElementType ;
830 
831  private:
832  typedef std::list< ManagedDofStorageInterface* > ListType;
833  typedef typename ListType::iterator ListIteratorType;
834  typedef typename ListType::const_iterator ConstListIteratorType;
835 
837 
838  typedef std::list< ManagedIndexSetInterface * > IndexListType;
839  typedef typename IndexListType::iterator IndexListIteratorType;
840  typedef typename IndexListType::const_iterator ConstIndexListIteratorType;
841 
842  // list with MemObjects, for each DiscreteFunction we have one MemObject
843  ListType memList_;
844 
845  // list of all different indexsets
846  IndexListType indexList_;
847 
848  // the dofmanager belong to one grid only
849  const GridType &grid_;
850 
851  // index set for mapping
852  mutable DataInlinerType dataInliner_;
853  mutable DataXtractorType dataXtractor_;
854 
857  typedef const ElementType ConstElementType;
859 
860  mutable LocalIndexSetObjectsType indexSets_;
861 
862  mutable LocalIndexSetObjectsType insertIndices_;
863  mutable LocalIndexSetObjectsType removeIndices_;
864 
865  // lists containing all MemObjects
866  // to have fast access during resize and reserve
867  mutable MemObjectCheckType resizeMemObjs_;
868  mutable MemObjectCheckType reserveMemObjs_;
869 
871  const int defaultChunkSize_;
872 
874  int sequence_;
875 
876  public:
881 
882  // old type
884 
885  // this class needs to call resizeMemory
886  friend class IndexSetRestrictProlong< ThisType , LocalIndexSetObjectsType , true > ;
887  friend class IndexSetRestrictProlong< ThisType , LocalIndexSetObjectsType , false > ;
888 
889  private:
890  // combine object holding all index set for restrict and prolong
891  NewIndexSetRestrictProlongType indexSetRestrictProlong_;
892  IndexSetRestrictProlongNoResizeType indexSetRestrictProlongNoResize_;
893 
894  // old type
895  IndexSetRestrictProlongType indexRPop_;
896 
898  double memoryFactor_;
899  //**********************************************************
900  //**********************************************************
902  inline explicit DofManager ( const GridType *grid )
903  : grid_( *grid ),
904  defaultChunkSize_( 128 ),
905  sequence_( 0 ),
906  indexSetRestrictProlong_( *this, insertIndices_ , removeIndices_ ),
907  indexSetRestrictProlongNoResize_( *this, insertIndices_ , removeIndices_ ),
908  indexRPop_(),
909  memoryFactor_( Parameter :: getValidValue( "fem.dofmanager.memoryfactor", double( 1.1 ),
910  [] ( double value ) { return value >= 1.0; } ) )
911  {
912  // only print memory factor if it deviates from the default value
913  if( std::abs( memoryFactor_ - 1.1 ) > 1e-12 )
914  {
915  if( Parameter::verbose() && (grid_.comm().rank() == 0) )
916  {
917  std::cout << "Created DofManager with memory factor "
918  << memoryFactor_ << "." << std::endl;
919  }
920  }
921  }
922 
923  // copy of dofmanagers is forbidden
924  DofManager( const ThisType & )
925  {
926  std::cerr << "DofManager(const DofManager &) not allowed!" << std :: endl;
927  abort();
928  }
929 
931  ~DofManager ();
932 
933  public:
935  double memoryFactor() const { return memoryFactor_; }
936 
955  template <class IndexSetType>
956  inline void addIndexSet (const IndexSetType &iset );
957 
965  template <class IndexSetType>
966  inline void removeIndexSet (const IndexSetType &iset );
967 
968  public:
978  template <class ManagedDofStorageImp>
979  void addDofStorage(ManagedDofStorageImp& dofStorage);
980 
985  template <class ManagedDofStorageImp>
986  void removeDofStorage(ManagedDofStorageImp& dofStorage);
987 
990  {
991  // hier muss statt dessen ein Combiniertes Object erzeugt werden.
992  // dafuer sollte bei einhaengen der IndexSets ein Methoden Pointer
993  // erzeugt werden, welcher die den IndexSet mit einem anderen Object
994  // kombiniert
995  return indexSetRestrictProlong_;
996  }
997 
1000  {
1001  // return index set restrict/prolong operator that is only inserting
1002  // and mark for removal indices but not doing resize
1003  return indexSetRestrictProlongNoResize_;
1004  }
1005 
1007  bool hasIndexSets() const
1008  {
1009  return ! insertIndices_.empty();
1010  }
1011 
1013  size_t usedMemorySize () const
1014  {
1015  size_t used = 0;
1016  ConstListIteratorType endit = memList_.end();
1017  for(ConstListIteratorType it = memList_.begin(); it != endit ; ++it)
1018  {
1019  used += (*it)->usedMemorySize();
1020  }
1021  return used;
1022  }
1023 
1028  {
1029  resizeMemory();
1030  }
1031 
1034  void reserveMemory ( int nsize, bool dummy = false )
1035  {
1036  int localChunkSize = std::max(nsize, defaultChunkSize_ );
1037  assert( localChunkSize > 0 );
1038 
1039  // reserves (size + chunkSize * elementMemory), see above
1040  reserveMemObjs_.apply ( localChunkSize );
1041  }
1042 
1047  int sequence () const { return sequence_; }
1048 
1049  //- --resize
1053  void resize()
1054  {
1055  // new number in grid series
1056 
1057  IndexListIteratorType endit = indexList_.end();
1058  for(IndexListIteratorType it = indexList_.begin(); it != endit; ++it)
1059  {
1060  (*it)->resize();
1061  }
1062  resizeMemory();
1063  }
1064 
1066  inline void insertEntity( ConstElementType & element )
1067  {
1068  // insert new index
1069  insertIndices_.apply( element );
1070 
1071  // resize memory
1072  resizeMemory();
1073  }
1074 
1076  inline void removeEntity( ConstElementType & element )
1077  {
1078  removeIndices_.apply( element );
1079  }
1080 
1083  {
1084  int dummy = -1;
1085  // pass dummy parameter
1086  resizeMemObjs_.apply ( dummy );
1087  }
1088 
1089  public:
1094  {
1095  // mark next sequence
1096  ++sequence_;
1097 
1098  // check that sequence number is the same for all processes
1099  assert( sequence_ == grid_.comm().max( sequence_ ) );
1100  }
1101 
1102  //- --compress
1106  void compress()
1107  {
1108  // mark next sequence
1109  incrementSequenceNumber ();
1110 
1111  // compress indexsets first
1112  {
1113  IndexListIteratorType endit = indexList_.end();
1114  for(IndexListIteratorType it = indexList_.begin(); it != endit; ++it)
1115  {
1116  // reset compressed so the next time compress of index set is called
1117  (*it)->compress();
1118  }
1119  }
1120 
1121  // compress all data now
1122  {
1123  ListIteratorType endit = memList_.end();
1124  for(ListIteratorType it = memList_.begin(); it != endit ; ++it)
1125  {
1126  // if correponding index was not compressed yet, this is called in
1127  // the MemObject dofCompress, if index has not changes, nothing happens
1128  // if IndexSet actual needs no compress, nothing happens to the
1129  // data either
1130  // also data is resized, which means the vector is getting shorter
1131  (*it)->dofCompress () ;
1132  }
1133  }
1134  }
1135 
1137  bool notifyGlobalChange( const bool wasChanged ) const
1138  {
1139  // make sure that wasChanged is the same on all cores
1140  int wasChangedCounter = int( wasChanged );
1141  return bool( grid_.comm().max( wasChangedCounter ) );
1142  }
1143 
1145  template <class DataCollType>
1146  void addDataInliner ( DataCollType & d)
1147  {
1148  dataInliner_ += d;
1149  }
1150 
1153  {
1154  dataInliner_.clear();
1155  }
1156 
1158  template <class DataCollType>
1159  void addDataXtractor ( DataCollType & d)
1160  {
1161  dataXtractor_ += d;
1162  }
1163 
1166  {
1167  dataXtractor_.clear();
1168  }
1169 
1171  // CommDataHandleIF methods
1173 
1175  bool contains( const int dim, const int codim ) const
1176  {
1177  return ( codim == 0 );
1178  }
1179 
1181  bool fixedsize( const int dim, const int codim ) const
1182  {
1183  return false;
1184  }
1185 
1187  template <class Entity>
1188  size_t size( const Entity& ) const
1189  {
1190  DUNE_THROW(NotImplemented,"DofManager::size should not be called!");
1191  return 0;
1192  }
1193 
1195  void gather( InlineStreamType& str, ConstElementType& element ) const
1196  {
1197  dataInliner_.apply(str, element);
1198  }
1199 
1200  template <class MessageBuffer, class Entity>
1201  void gather( MessageBuffer& str, const Entity& entity ) const
1202  {
1203  DUNE_THROW(NotImplemented,"DofManager::gather( entity ) with codim > 0 not implemented");
1204  }
1205 
1207  void scatter ( XtractStreamType& str, ConstElementType& element, size_t )
1208  {
1209  // here the elements already have been created
1210  // that means we can xtract data
1211  dataXtractor_.apply(str, element);
1212  }
1213 
1215  template <class MessageBuffer, class Entity>
1216  void scatter ( MessageBuffer & str, const Entity& entity, size_t )
1217  {
1218  DUNE_THROW(NotImplemented,"DofManager::scatter( entity ) with codim > 0 not implemented");
1219  }
1220 
1221 #if HAVE_ALUGRID
1222  // old implementation for convenience, when using dune-grid ALUGrid version
1226  void inlineData( InlineStreamImplType& str, ConstElementType& element ) const
1227  {
1228  InlineStreamType buffer( str );
1229  dataInliner_.apply( buffer, element);
1230  }
1231 
1233  void xtractData( XtractStreamImplType& str, ConstElementType& element, size_t newElements )
1234  {
1235  // reserve memory for elements to be read
1236  reserveMemory( newElements );
1237 
1238  XtractStreamType buffer( str );
1239  // here the elements already have been created
1240  // that means we can xtract data
1241  dataXtractor_.apply( buffer, element);
1242  }
1243 #endif
1244 
1245  //********************************************************
1246  // Interface for PersistentObjects
1247  //********************************************************
1248 
1250  void backup () const
1251  {
1252  // backup all index sets marked as persistent
1253  ConstIndexListIteratorType endit = indexList_.end();
1254  for(ConstIndexListIteratorType it = indexList_.begin(); it != endit; ++it)
1255  {
1256  (*it)->backup();
1257  }
1258  }
1259 
1261  void restore ()
1262  {
1263  // restore all index sets marked as persistent
1264  IndexListIteratorType endit = indexList_.end();
1265  for(IndexListIteratorType it = indexList_.begin(); it != endit; ++it)
1266  {
1267  (*it)->restore();
1268  }
1269 
1270  // make all index sets consistent
1271  // before any data is read this can be
1272  // assured since DofManager is an
1273  // AutoPersistentObject and thus in the
1274  // beginning of the list, fater the grid of course
1275  resize();
1276  }
1277 
1278  //********************************************************
1279  // read/write using fem streams
1280  //********************************************************
1285  template < class OutStream >
1286  void write( OutStream& out ) const
1287  {
1288  ConstIndexListIteratorType endit = indexList_.end();
1289  for(ConstIndexListIteratorType it = indexList_.begin(); it != endit; ++it)
1290  {
1291  (*it)->write( out );
1292  }
1293  }
1294 
1299  template < class InStream >
1300  void read( InStream& in )
1301  {
1302  IndexListIteratorType endit = indexList_.end();
1303  for(IndexListIteratorType it = indexList_.begin(); it != endit; ++it)
1304  {
1305  (*it)->read( in );
1306  }
1307  }
1308 
1309  //********************************************************
1310  // Interface for DofManager access
1311  //********************************************************
1312 
1319  static inline ThisType& instance( const GridType& grid )
1320  {
1321  typedef DofManagerFactory< ThisType > DofManagerFactoryType;
1322  return DofManagerFactoryType :: instance( grid );
1323  }
1324  };
1325 
1326  //***************************************************************************
1327  //
1328  // inline implemenations
1329  //
1330  //***************************************************************************
1331 
1332  template <class GridType>
1334  {
1335  if(memList_.size() > 0)
1336  {
1337  while( memList_.rbegin() != memList_.rend())
1338  {
1339  DofStorageInterface * mobj = (* memList_.rbegin() );
1340  memList_.pop_back();
1341 
1342  // alloc new mem an copy old mem
1343  dverb << "Removing '" << mobj->name() << "' from DofManager!\n";
1344  }
1345  }
1346 
1347  if(indexList_.size() > 0)
1348  {
1349  std::cerr << "ERROR: Not all index sets have been removed from DofManager yet!" << std::endl;
1350  while ( indexList_.rbegin() != indexList_.rend())
1351  {
1352  ManagedIndexSetInterface* iobj = (* indexList_.rbegin() );
1353  indexList_.pop_back();
1354  if(iobj) delete iobj;
1355  }
1356  }
1357  }
1358 
1359  template <class GridType>
1360  template <class IndexSetType>
1361  inline void DofManager<GridType>::
1362  addIndexSet (const IndexSetType &iset )
1363  {
1365 
1366  typedef ManagedIndexSet< IndexSetType, ConstElementType > ManagedIndexSetType;
1367 
1368  typedef typename IndexListType::reverse_iterator IndexListIteratorType;
1369 
1370  ManagedIndexSetType * indexSet = 0;
1371 
1372  // search index set list in reverse order to find latest index sets faster
1373  IndexListIteratorType endit = indexList_.rend();
1374  for( IndexListIteratorType it = indexList_.rbegin(); it != endit; ++it )
1375  {
1376  ManagedIndexSetInterface *set = *it;
1377  if( set->equals( iset ) )
1378  {
1379  set->addReference();
1380 
1381  indexSet = static_cast< ManagedIndexSetType * >( set );
1382  break;
1383  }
1384  }
1385 
1386  if( !indexSet )
1387  {
1388  indexSet = new ManagedIndexSetType ( iset, indexSets_ , insertIndices_ , removeIndices_ );
1389  indexList_.push_back( static_cast< ManagedIndexSetInterface * >( indexSet ) );
1390  }
1391  }
1392 
1393  template <class GridType>
1394  template <class IndexSetType>
1395  inline void DofManager<GridType>::
1396  removeIndexSet ( const IndexSetType &iset )
1397  {
1399  typedef typename IndexListType::reverse_iterator IndexListIteratorType;
1400 
1401  // search index set list in reverse order to find latest index sets faster
1402  IndexListIteratorType endit = indexList_.rend();
1403  for( IndexListIteratorType it = indexList_.rbegin(); it != endit; ++it )
1404  {
1405  ManagedIndexSetInterface *set = *it;
1406  if( set->equals( iset ) )
1407  {
1408  if( set->removeReference() )
1409  {
1410  // reverse iterators cannot be erased directly, so erase the base
1411  // (forward) iterator
1412  // Note: see, e.g., Stroustrup, section 16.3.2 about the decrement
1413  typename IndexListType::iterator fit = it.base();
1414  indexList_.erase( --fit );
1415  // delete proxy
1416  delete set;
1417  }
1418  return;
1419  }
1420  }
1421 
1422  // we should never get here
1423  DUNE_THROW(InvalidStateException,"Could not remove index from DofManager set!");
1424  }
1425 
1426  template <class GridType>
1427  template <class ManagedDofStorageImp>
1428  void
1430  addDofStorage(ManagedDofStorageImp& dofStorage)
1431  {
1432  dverb << "Adding '" << dofStorage.name() << "' to DofManager! \n";
1433 
1434  // make sure we got an ManagedDofStorage
1435  ManagedDofStorageInterface* obj = &dofStorage;
1436 
1437  // push_front, makes search faster
1438  memList_.push_front( obj );
1439 
1440  // add the special object to the memResize list object
1441  resizeMemObjs_ += dofStorage.resizeMemoryObject();
1442 
1443  // the same for the reserve call
1444  reserveMemObjs_ += dofStorage.reserveMemoryObject();
1445  }
1446 
1447 
1448  template <class GridType>
1449  template <class ManagedDofStorageImp>
1450  void
1452  removeDofStorage(ManagedDofStorageImp& dofStorage)
1453  {
1454  // make sure we got an ManagedDofStorage
1455  ManagedDofStorageInterface* obj = &dofStorage;
1456 
1457  // search list starting from tail
1458  ListIteratorType endit = memList_.end();
1459  for( ListIteratorType it = memList_.begin();
1460  it != endit ; ++it)
1461  {
1462  if(*it == obj)
1463  {
1464  // alloc new mem and copy old mem
1465  memList_.erase( it );
1466 
1467  dvverb << "Remove '" << dofStorage.name() << "' from DofManager!\n";
1468 
1469  // remove from list
1470  resizeMemObjs_.remove( dofStorage.resizeMemoryObject() );
1471  reserveMemObjs_.remove( dofStorage.reserveMemoryObject() );
1472 
1473  return ;
1474  }
1475  }
1476  }
1477 
1479 
1480 
1488  template< class DofManagerImp >
1489  class DofManagerFactory
1490  {
1491  typedef DofManagerFactory< DofManagerImp > ThisType;
1492 
1493  public:
1494  typedef DofManagerImp DofManagerType;
1495  typedef typename DofManagerType :: GridType GridType;
1496 
1497  private:
1498  typedef const GridType *KeyType;
1499 
1501 
1502  // declare friendship becase of methods instance
1503  friend class DofManager< GridType >;
1504 
1505  protected:
1512  inline static DofManagerType &instance ( const GridType &grid )
1513  {
1514  DofManagerType *dm = getDmFromList( grid );
1515  if( !dm )
1516  return DMProviderType :: getObject( &grid );
1517  return *dm;
1518  }
1519 
1521  inline static bool
1522  writeDofManagerNew ( const GridType &grid,
1523  const std :: string &filename,
1524  int timestep )
1525  {
1526  DofManagerType *dm = getDmFromList( grid );
1527  /*
1528  if( dm )
1529  return dm->writeIndexSets( filename, timestep );
1530  */
1531  return false;
1532  }
1533 
1535  inline static bool
1536  readDofManagerNew ( const GridType &grid,
1537  const std :: string &filename,
1538  int timestep )
1539  {
1540  DofManagerType *dm = getDmFromList( grid );
1541  /*
1542  if( dm )
1543  return dm->readIndexSets( filename, timestep );
1544  */
1545  return false;
1546  }
1547 
1548  public:
1550  inline static void deleteDofManager ( DofManagerType &dm )
1551  {
1552  DMProviderType :: removeObject( &dm );
1553  }
1554 
1555  private:
1556  // return pointer to dof manager for given grid
1557  inline static DofManagerType *getDmFromList( const GridType &grid )
1558  {
1559  return (DMProviderType :: getObjFromList( &grid )).first;
1560  }
1561  };
1562 
1563  } // namespace Fem
1564 
1565 } // namespace Dune
1566 
1567 #endif // #ifndef DUNE_FEM_DOFMANAGER_HH
Definition: datacollector.hh:47
Definition: dofmanager.hh:342
void removeEntity(ConstElementType &element)
Removes entity from all index sets added to dof manager.
Definition: dofmanager.hh:1076
void clearDataXtractors()
clear data xtractor list
Definition: dofmanager.hh:1165
MapperType & mapper() const
Definition: dofmanager.hh:549
static void memMoveForward(ArrayType &array, const int length, const int oldStartIdx, const int newStartIdx)
move memory blocks forward
Definition: dofmanager.hh:87
void backup() const
:: backup
Definition: dofmanager.hh:1250
virtual void read(XDRFileInStream &in)
new write method
Definition: dofmanager.hh:263
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:737
ManagedIndexSet(const IndexSetType &iset, LocalIndexSetObjectsType &indexSetList, LocalIndexSetObjectsType &insertList, LocalIndexSetObjectsType &removeList)
Constructor of MemObject, only to call from DofManager.
Definition: dofmanager.hh:206
Definition: dofmanager.hh:180
ResizeMemoryObjects(MemObjectType &mo)
Definition: dofmanager.hh:684
DofManagerType & dm_
Definition: dofmanager.hh:353
void reserveMemory(int nsize, bool dummy=false)
reserve memory for at least nsize elements, dummy is needed for dune-grid ALUGrid version ...
Definition: dofmanager.hh:1034
GridObjectStreamTraits< GridType >::InStreamType XtractStreamImplType
Definition: dofmanager.hh:818
void removeIndexSet(const IndexSetType &iset)
removed index set from dof manager&#39;s list of index sets
Definition: dofmanager.hh:1396
virtual const std::string & name() const =0
returns name of dof storage
input stream reading from a given std::istream
Definition: standardstreams.hh:194
interface documentation for (grid part) index sets
Definition: common/indexset.hh:25
Definition: dofmanager.hh:118
double memoryFactor() const
return factor to over estimate new memory allocation
Definition: dofmanager.hh:935
void apply(EntityType &entity)
apply wraps the removeEntity Method of the index set
Definition: dofmanager.hh:649
Container for User Specified Parameters.
Definition: io/parameter.hh:187
void insertEntity(ConstElementType &element)
Inserts entity to all index sets added to dof manager.
Definition: dofmanager.hh:1066
IndexSetRestrictProlong< ThisType, LocalIndexSetObjectsType, false > IndexSetRestrictProlongNoResizeType
Definition: dofmanager.hh:880
~ManagedIndexSet()
desctructor
Definition: dofmanager.hh:228
DofManager< GridImp > DofManagerType
Definition: dofmanager.hh:350
bool compress()
wrap compress of index set
Definition: dofmanager.hh:245
bool empty() const
Definition: datacollector.hh:224
DofArrayType & getArray()
return reference to array for DiscreteFunction
Definition: dofmanager.hh:546
virtual ~ManagedDofStorageInterface()
destructor
Definition: dofmanager.hh:314
void addReference()
increase reference counter
Definition: dofmanager.hh:158
static constexpr T max(T a)
Definition: utility.hh:65
void addDataXtractor(DataCollType &d)
add data handler for data xtracting to dof manager
Definition: dofmanager.hh:1159
void gather(MessageBuffer &str, const Entity &entity) const
Definition: dofmanager.hh:1201
Singleton list for key/object pairs.
Definition: singletonlist.hh:49
Definition: dofmanager.hh:591
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:753
void compress()
Compress all data that is hold by this dofmanager.
Definition: dofmanager.hh:1106
void addDataInliner(DataCollType &d)
add data handler for data inlining to dof manager
Definition: dofmanager.hh:1146
Grid GridType
type of Grid this DofManager belongs to
Definition: dofmanager.hh:816
static size_t used(const ArrayType &array)
return used memory size of Array
Definition: dofmanager.hh:60
virtual void read(StandardInStream &in)
new write method
Definition: dofmanager.hh:269
static void deleteDofManager(DofManagerType &dm)
delete the dof manager that belong to the given grid
Definition: dofmanager.hh:1550
DofManagerType::GridType GridType
Definition: dofmanager.hh:1495
InsertIndicesToSet< IndexSetType, EntityType > insertIdxObj_
Definition: dofmanager.hh:194
virtual void write(XDRFileOutStream &out) const
new write method
Definition: dofmanager.hh:266
Definition: datacollector.hh:45
static std::pair< DofStorageInterface *, DofStorageType * > allocateManagedDofStorage(const GridType &grid, const MapperType &mapper, const std::string &name, const DofStorageType *=0)
default implementation for creating a managed dof storage
Definition: dofmanager.hh:610
XDR output stream reading from a file.
Definition: xdrstreams.hh:319
bool removeReference()
decrease reference counter and return true if zero reached
Definition: dofmanager.hh:161
void resizeForRestrict()
resize memory before data restriction during grid adaptation is done.
Definition: dofmanager.hh:1027
virtual void restore()
:: restore
Definition: dofmanager.hh:257
void addIndexSet(const IndexSetType &iset)
add index set to dof manager&#39;s list of index sets
Definition: dofmanager.hh:1362
void incrementSequenceNumber()
increase the DofManagers internal sequence number
Definition: dofmanager.hh:1093
DofArrayType myArray_
Definition: dofmanager.hh:595
ResizeMemoryObjects< ThisType > ResizeMemoryObjectType
Definition: dofmanager.hh:364
bool hasIndexSets() const
if dofmanagers list is not empty return true
Definition: dofmanager.hh:1007
void write(OutStream &out) const
write all index sets to a given stream
Definition: dofmanager.hh:1286
DataCollectorInterface< GridType, XtractStreamType > DataXtractorType
Definition: dofmanager.hh:826
size_t referenceCounter_
Definition: dofmanager.hh:127
EmptyIndexSetRestrictProlong IndexSetRestrictProlongType
Definition: dofmanager.hh:883
void scatter(MessageBuffer &str, const Entity &entity, size_t)
unpacks all data of this entity from message buffer
Definition: dofmanager.hh:1216
SpecialArrayFeatures is a wrapper class to extend some array classes with some special features neede...
Definition: arrays.hh:39
DofStorageInterface()
do not allow to create explicit instances
Definition: dofmanager.hh:286
size_t usedMemorySize() const
return used memory size
Definition: dofmanager.hh:534
EmptyIndexSetRestrictProlong()
Definition: dofmanager.hh:773
~ManagedDofStorageImplementation()
destructor deleting MemObject from resize and reserve List
Definition: dofmanager.hh:396
void reserve(const int needed)
reserve memory for what is comming
Definition: dofmanager.hh:469
ResizeMemoryObjectType resizeMemObj_
Definition: dofmanager.hh:366
Double abs(const Double &a)
Definition: double.hh:860
size_t size(const Entity &) const
for convenience
Definition: dofmanager.hh:1188
Definition: dofmanager.hh:184
virtual ~ManagedIndexSetInterface()
Definition: dofmanager.hh:137
void dofCompress()
copy the dof from the rear section of the vector to the holes
Definition: dofmanager.hh:488
void scatter(XtractStreamType &str, ConstElementType &element, size_t)
unpacks all data attached of this entity from message buffer
Definition: dofmanager.hh:1207
void read(InStream &in)
read all index sets from a given stream
Definition: dofmanager.hh:1300
static void assign(ArrayType &array, const int newIndex, const int oldIndex)
implements array[ newIndex ] = array[ oldIndex ]
Definition: dofmanager.hh:102
void resizeMemory()
resize the MemObject if necessary
Definition: dofmanager.hh:1082
void restore()
:: restore
Definition: dofmanager.hh:1261
Interface class defining the local behaviour of the restrict/prolong operation (using BN) ...
Definition: restrictprolonginterface.hh:38
IdentifierType setPtr_
Definition: dofmanager.hh:125
Definition: dofmanager.hh:328
LocalIndexSetObjectsType & insertList_
Definition: dofmanager.hh:198
int sequence() const
return number of sequence, if dofmanagers memory was changed by calling some method like resize...
Definition: dofmanager.hh:1047
output stream writing into a given std::ostream
Definition: standardstreams.hh:59
MapperType & mapper_
Definition: dofmanager.hh:356
ManagedIndexSetInterface(const IndexSet &iset)
Definition: dofmanager.hh:130
Definition: coordinate.hh:4
ManagedIndexSetInterface BaseType
type of base class
Definition: dofmanager.hh:203
void gather(InlineStreamType &str, ConstElementType &element) const
packs all data attached to this entity
Definition: dofmanager.hh:1195
ReserveMemoryObjectType & reserveMemoryObject()
return object that calls reserve of this memory object
Definition: dofmanager.hh:407
Interface class for a dof storage object to be stored in discrete functions.
Definition: dofmanager.hh:282
DataCollectorInterface< GridType, InlineStreamType > DataInlinerType
Definition: dofmanager.hh:827
void resizeAndMoveToRear()
Definition: dofmanager.hh:555
Definition: dofmanager.hh:721
ResizeMemoryObjects(const ResizeMemoryObjects &org)
Definition: dofmanager.hh:685
static bool readDofManagerNew(const GridType &grid, const std::string &filename, int timestep)
reads DofManager of corresponding grid, when DofManager exists
Definition: dofmanager.hh:1536
static void memMoveBackward(ArrayType &array, const int length, const int oldStartIdx, const int newStartIdx)
move memory blocks backwards
Definition: dofmanager.hh:72
void resize()
Resize index sets and memory due to what the mapper has as new size.
Definition: dofmanager.hh:1053
virtual void apply(ObjectStreamType &str, const EntityType &entity) const
Definition: datacollector.hh:289
virtual void clear()
clear object list
Definition: datacollector.hh:379
void resize()
wrap resize of index set
Definition: dofmanager.hh:239
void moveToFront(const int oldSize, const int block)
move block to front again
Definition: dofmanager.hh:560
void prolongLocal(EntityType &father, EntityType &son, bool initialize) const
prolong data to children and resize memory if doResize is true
Definition: dofmanager.hh:779
bool contains(const int dim, const int codim) const
the dof manager only transfers element data during load balancing
Definition: dofmanager.hh:1175
Definition: dofmanager.hh:327
std::string name_
Definition: dofmanager.hh:362
IndexSetRestrictProlong(DofManagerType &dm, RestrictProlongIndexSetType &is, RestrictProlongIndexSetType &rm)
Definition: dofmanager.hh:732
void apply(int &chunkSize)
Definition: dofmanager.hh:710
void resize()
resize the memory with the new size
Definition: dofmanager.hh:416
IndexSetRestrictProlong< ThisType, LocalIndexSetObjectsType, true > NewIndexSetRestrictProlongType
Definition: dofmanager.hh:878
DofManagerImp DofManagerType
Definition: dofmanager.hh:1494
Interface class for a dof storage object that can be managed (resized and compressed) by the DofManag...
Definition: dofmanager.hh:306
void restrictLocal(EntityType &father, EntityType &son, bool initialize) const
restrict data to father and resize memory if doResize is true
Definition: dofmanager.hh:776
IndexSetRestrictProlongNoResizeType & indexSetRestrictProlongNoResize()
returns the index set restriction and prolongation operator
Definition: dofmanager.hh:999
void apply(int &)
Definition: dofmanager.hh:690
size_t usedMemorySize() const
return used memory size of all MemObjects in bytes.
Definition: dofmanager.hh:1013
virtual ~DofStorageInterface()
destructor
Definition: dofmanager.hh:290
Definition: gridobjectstreams.hh:17
Definition: dofmanager.hh:181
Definition: dofmanager.hh:783
DofArrayType & array_
Definition: dofmanager.hh:359
static bool verbose()
obtain the cached value for fem.verbose
Definition: io/parameter.hh:444
static DofManagerType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1512
void apply(ParamType &p) const
for all pointer to local operators call the func pointer
Definition: datacollector.hh:163
ArrayType::value_type ValueType
value type of array, i.e. double
Definition: dofmanager.hh:57
ManagedDofStorageImplementation< GridImp, MapperType, DofArrayType > ThisType
Definition: dofmanager.hh:348
bool notifyGlobalChange(const bool wasChanged) const
communicate new sequence number
Definition: dofmanager.hh:1137
Definition: dofmanager.hh:769
ManagedDofStorage(const GridImp &grid, const MapperType &mapper, const std::string &name)
Constructor of ManagedDofStorage.
Definition: dofmanager.hh:598
int size() const
return size of underlying array
Definition: dofmanager.hh:413
void clearDataInliners()
clear data inliner list
Definition: dofmanager.hh:1152
bool fixedsize(const int dim, const int codim) const
fixed size is false
Definition: dofmanager.hh:1181
ReserveMemoryObjects(MemObjectType &mo)
Definition: dofmanager.hh:707
ReserveMemoryObjects< ThisType > ReserveMemoryObjectType
Definition: dofmanager.hh:365
ResizeMemoryObjectType & resizeMemoryObject()
return object that calls resize of this memory object
Definition: dofmanager.hh:404
MessageBufferIF< InlineStreamImplType > InlineStreamType
Definition: dofmanager.hh:823
InsertIndicesToSet(IndexSetType &iset)
Definition: dofmanager.hh:665
void enableDofCompression()
enable dof compression for this MemObject
Definition: dofmanager.hh:540
virtual void backup() const
:: backup
Definition: dofmanager.hh:251
void removeDofStorage(ManagedDofStorageImp &dofStorage)
remove a managed dof storage from the dof manager.
Definition: dofmanager.hh:1452
MessageBufferIF< XtractStreamImplType > XtractStreamType
Definition: dofmanager.hh:822
virtual void write(StandardOutStream &out) const
new write method
Definition: dofmanager.hh:272
ManagedDofStorageInterface()
do not allow to create explicit instances
Definition: dofmanager.hh:310
RemoveIndicesFromSet< IndexSetType, EntityType > removeIdxObj_
Definition: dofmanager.hh:195
virtual void enableDofCompression()
enable dof compression for dof storage (default is empty)
Definition: dofmanager.hh:293
RemoveIndicesFromSet(IndexSetType &iset)
Definition: dofmanager.hh:646
static bool singleThreadMode()
returns true if program is operating on one thread currently
Definition: threadmanager.hh:217
bool dataCompressionEnabled_
Definition: dofmanager.hh:370
ManagedDofStorageImplementation(const GridImp &grid, const MapperType &mapper, const std::string &name, DofArrayType &array)
Constructor of ManagedDofStorageImplementation, only to call from derived classes.
Definition: dofmanager.hh:376
LocalIndexSetObjectsType & indexSetList_
Definition: dofmanager.hh:197
Singleton provider for the DofManager.
Definition: dofmanager.hh:47
static void setMemoryFactor(ArrayType &array, const double memFactor)
set memory overestimate factor, here does nothing
Definition: dofmanager.hh:66
const void * IdentifierType
Definition: dofmanager.hh:123
NewIndexSetRestrictProlongType & indexSetRestrictProlong()
returns the index set restriction and prolongation operator
Definition: dofmanager.hh:989
void remove(const OpType &op)
Definition: datacollector.hh:203
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1319
XDR output stream writing into a file.
Definition: xdrstreams.hh:267
static bool writeDofManagerNew(const GridType &grid, const std::string &filename, int timestep)
writes DofManager of corresponding grid, when DofManager exists
Definition: dofmanager.hh:1522
GridType::template Codim< 0 >::Entity ElementType
Definition: dofmanager.hh:829
void addDofStorage(ManagedDofStorageImp &dofStorage)
add a managed dof storage to the dof manager.
Definition: dofmanager.hh:1430
GridObjectStreamTraits< GridType >::OutStreamType InlineStreamImplType
Definition: dofmanager.hh:819
void apply(EntityType &entity)
apply wraps the insertEntity method of the index set
Definition: dofmanager.hh:668
const std::string & name() const
returns name of this vector
Definition: dofmanager.hh:410
bool equals(const IndexSet &iset) const
Definition: dofmanager.hh:167
Definition: singletonlist.hh:21
ReserveMemoryObjectType reserveMemObj_
Definition: dofmanager.hh:367
LocalIndexSetObjectsType & removeList_
Definition: dofmanager.hh:199
IndexSetType & indexSet_
Definition: dofmanager.hh:191