alugrid/3d/datahandle.hh

00001 #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH
00002 #define DUNE_ALU3DGRIDDATAHANDLE_HH
00003 
00004 //- system includes 
00005 #include <iostream>
00006 
00007 //- local includes 
00008 #include "alu3dinclude.hh"
00009 
00010 using std::endl;
00011 using std::cout;
00012 using std::flush;
00013 
00014 namespace ALUGridSpace {
00015 
00017 template <class GridType, class DataCollectorType , int codim >
00018 class GatherScatterBaseImpl : public GatherScatter
00019 {
00020 protected:  
00021   const GridType & grid_;
00022   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<codim>::Entity> EntityType;
00023   typedef typename EntityType :: ImplementationType RealEntityType;
00024   
00025   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00026     template Codim<codim>::ImplementationType ImplElementType;
00027   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00028     template Codim<codim>::InterfaceType HElementType;
00029 
00030   EntityType     & entity_;
00031   RealEntityType & realEntity_;
00032 
00033   DataCollectorType & dc_;
00034 
00035   const bool variableSize_;
00036 
00037   typedef typename GatherScatter :: ObjectStreamType ObjectStreamType;
00038 
00039   typename DataCollectorType::DataType tmp_;
00040 public:
00042   GatherScatterBaseImpl(const GridType & grid, EntityType & en, RealEntityType & realEntity , DataCollectorType & dc) 
00043     : grid_(grid), entity_(en), realEntity_(realEntity) , dc_(dc)
00044     , variableSize_( ! dc_.fixedsize(EntityType::dimension,codim) )
00045   {
00046   }
00047 
00049   bool contains(int dim, int cd) const { return dc_.contains(dim,cd); }
00050 
00051   // returns true, if element is contained in set of comm interface 
00052   // this method must be overlaoded by the impl classes 
00053   virtual bool containsItem (const HElementType & elem) const = 0;
00054 
00055   // set elem to realEntity
00056   virtual void setElement(const HElementType & elem) = 0;
00057     
00058   void setData ( ObjectStreamType & str , HElementType & elem )
00059   {
00060     // one of this should be either true 
00061     assert( this->containsItem( elem ) || elem.isGhost() );
00062 
00063     // set element and then start 
00064     setElement(elem);
00065 
00066     // contiansItem might fail for ghost elements, which is not a bug
00067     // containsItem just returns right values for interior elements 
00068     assert( entity_.partitionType() == Dune :: GhostEntity );
00069 
00070     size_t size = getSize(str, entity_);
00071     // use normal scatter method 
00072     dc_.scatter(str,entity_, size ); 
00073   }
00074 
00076   void sendData ( ObjectStreamType & str , HElementType & elem )
00077   {
00078     assert( this->containsItem( elem ) );
00079     setElement(elem);
00080 
00081     // if varaible size, also send size 
00082     if( variableSize_ )
00083     {
00084       size_t size = dc_.size( entity_ );
00085       str.write( size );
00086     }
00087 
00088     dc_.gather(str, entity_ );
00089   }
00090 
00092   void recvData ( ObjectStreamType & str , HElementType & elem )
00093   {
00094     assert( this->containsItem( elem ) );
00095     setElement( elem );
00096 
00097     size_t size = getSize(str, entity_);
00098     dc_.scatter(str,entity_, size );
00099   }
00100 
00101 protected:  
00102   size_t getSize(ObjectStreamType & str, EntityType & en)
00103   {
00104     if(variableSize_) 
00105     {
00106       size_t size;
00107       str.read(size);
00108       return size;
00109     }
00110     else 
00111       return dc_.size(en);
00112   }
00113 };
00114 
00115 //***********************************************************
00116 //
00117 //  --specialisation for codim 0 
00118 //
00119 //***********************************************************
00120 
00122 template <class GridType, class DataCollectorType >
00123 class GatherScatterBaseImpl<GridType,DataCollectorType,0> : public GatherScatter
00124 {
00125 protected:  
00126   enum { codim = 0 };
00127   const GridType & grid_;
00128   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<0>::Entity> EntityType;
00129   typedef typename EntityType :: ImplementationType RealEntityType;
00130   
00131   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00132     template Codim<codim>::ImplementationType IMPLElementType;
00133   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00134     template Codim<codim>::InterfaceType HElementType;
00135   
00136   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00137     template Codim<1>::InterfaceType HFaceType;
00138   
00139   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00140     template Codim<codim>::GhostInterfaceType HGhostType;
00141   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00142     template Codim<codim>::GhostImplementationType ImplGhostType;
00143 
00144 #if ALU3DGRID_PARALLEL 
00145   typedef ALU3DSPACE ElementPllXIF_t PllElementType;
00146 #else 
00147   typedef HElementType PllElementType;
00148 #endif
00149 
00150   EntityType     & entity_;
00151   RealEntityType & realEntity_;
00152 
00153   // data handle 
00154   DataCollectorType & dc_;
00155 
00156   const bool variableSize_;
00157 
00158   // used MessageBuffer 
00159   typedef typename GatherScatter :: ObjectStreamType ObjectStreamType;
00160 
00161 public:
00163   GatherScatterBaseImpl(const GridType & grid, EntityType & en, RealEntityType & realEntity , DataCollectorType & dc) 
00164     : grid_(grid), entity_(en), realEntity_(realEntity) 
00165     , dc_(dc) , variableSize_ ( ! dc_.fixedsize( EntityType :: dimension, codim ))
00166   {}
00167 
00168   // return true if dim,codim combination is contained in data set 
00169   bool contains(int dim, int codim) const 
00170   {
00171     return dc_.contains(dim,codim);
00172   }
00173 
00174   // return true if item might from entity belonging to data set  
00175   virtual bool containsItem (const HElementType & elem) const 
00176   {
00177     return elem.isLeafEntity();
00178   }
00179 
00180   // return true if item might from entity belonging to data set  
00181   virtual bool containsItem (const HGhostType & ghost) const = 0; 
00182 
00184   void sendData ( ObjectStreamType & str , const HElementType & elem )
00185   {
00186     assert( this->containsItem(elem) );
00187     realEntity_.setElement( const_cast<HElementType &> (elem) );
00188 
00189     // write size in case of variable size 
00190     writeSize( str, entity_);
00191     // gather data 
00192     dc_.gather(str, entity_);
00193   }
00194  
00196   void sendData ( ObjectStreamType & str , const HGhostType& ghost)
00197   {
00198     assert( this->containsItem( ghost ) );
00199 
00200     // set ghost as entity
00201     realEntity_.setGhost( const_cast <HGhostType &> (ghost) );
00202 
00203     // write size in case of variable size 
00204     writeSize( str, entity_);
00205     // gather data 
00206     dc_.gather(str, entity_);
00207   }
00208  
00210   void recvData ( ObjectStreamType & str , HElementType & elem )
00211   {
00212     assert( this->containsItem( elem ) );
00213     realEntity_.setElement( elem ); 
00214     
00215     size_t size = getSize(str, entity_); 
00216     dc_.scatter(str, entity_, size);
00217   }
00218 
00220   void recvData ( ObjectStreamType & str , HGhostType & ghost )
00221   {
00222     assert( this->containsItem( ghost ) );
00223 
00224     // set ghost as entity
00225     realEntity_.setGhost( ghost );
00226 
00227     size_t size = getSize(str , entity_ ); 
00228     dc_.scatter(str, entity_, size );
00229   }
00230   
00231 protected:  
00232   size_t getSize(ObjectStreamType & str, EntityType & en)
00233   {
00234     if(variableSize_) 
00235     {
00236       size_t size;
00237       str.read(size);
00238       return size;
00239     }
00240     else 
00241       return dc_.size(en);
00242   }
00243   
00244   // write variable size to stream 
00245   void writeSize(ObjectStreamType & str, EntityType & en)
00246   {
00247     if( variableSize_ )
00248     {
00249       size_t size = dc_.size( en );
00250       str.write( size );
00251     }
00252   }
00253 };
00254 
00255 #if ALU3DGRID_PARALLEL
00257 template <class GridType, class DataCollectorType , int codim >
00258 class GatherScatterLeafData 
00259 : public GatherScatterBaseImpl<GridType,DataCollectorType,codim> 
00260 {
00261   enum { dim = GridType :: dimension };
00262 
00263   typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
00264   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<codim>::Entity> EntityType;
00265   typedef typename EntityType :: ImplementationType RealEntityType;
00266 
00267   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00268     template Codim<codim>::ImplementationType IMPLElementType;
00269   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00270     template Codim<codim>::InterfaceType HElementType;
00271   
00272   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00273     template Codim<1>::InterfaceType HFaceType;
00274   
00275   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00276     template Codim<0>::GhostInterfaceType HGhostType;
00277   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00278     template Codim<0>::GhostImplementationType ImplGhostType;
00279 
00280   typedef ALU3DSPACE ElementPllXIF_t PllElementType;
00281 
00282 public:
00284   GatherScatterLeafData(const GridType & grid, EntityType & en, RealEntityType & realEntity , DataCollectorType & dc)
00285     : BaseType(grid,en,realEntity,dc) 
00286   {
00287     // if leaf vertices are communicated, 
00288     // make sure that vertex list is up2date 
00289     // but only do this, if vertex data contained,
00290     // because the list update is expensive  
00291     if( (codim == 3) && dc.contains(dim,codim) ) 
00292     {
00293       // call of this method forces update of list, 
00294       // if list is not up to date
00295       grid.getLeafVertexList();
00296     }
00297   } 
00298 
00299   // returns true, if element is contained in set of comm interface 
00300   bool containsItem (const HElementType & elem) const 
00301   {
00302     return elem.isLeafEntity();
00303   }
00304 
00305   // returns true, if element is contained in set of comm interface 
00306   bool containsItem (const HGhostType & ghost) const 
00307   {
00308     return ghost.isLeafEntity();
00309   }
00310 
00311   // returns true, if interior element is contained in set of comm interface 
00312   bool containsInterior (const HFaceType & face, PllElementType & pll) const 
00313   {
00314     return face.isInteriorLeaf();
00315   }
00316 
00317   // returns true, if ghost is contianed in set of comm interface 
00318   bool containsGhost (const HFaceType & face , PllElementType & pll) const 
00319   {
00320     return pll.ghostLeaf();
00321   }
00322 
00323   // set elem to realEntity
00324   void setElement(const HElementType & elem)
00325   {
00326     this->realEntity_.setElement(elem); 
00327   }
00328     
00329 
00330 };
00331 
00333 template <class GridType, class DataCollectorType , int codim >
00334 class GatherScatterLevelData 
00335 : public GatherScatterBaseImpl<GridType,DataCollectorType,codim> 
00336 {
00337   typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
00338   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<codim>::Entity> EntityType;
00339   typedef typename EntityType :: ImplementationType RealEntityType;
00340 
00341   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00342     template Codim<codim>::ImplementationType IMPLElementType;
00343   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00344     template Codim<codim>::InterfaceType HElementType;
00345   
00346   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00347     template Codim<1>::InterfaceType HFaceType;
00348   
00349   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00350     template Codim<0>::GhostInterfaceType HGhostType;
00351   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00352     template Codim<0>::GhostImplementationType ImplGhostType;
00353 
00354   typedef ALU3DSPACE ElementPllXIF_t PllElementType;
00355   typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
00356 
00357   const LevelIndexSetImp & levelSet_;
00358   const int level_;
00359 public:
00361   GatherScatterLevelData(const GridType & grid, EntityType & en, RealEntityType & realEntity , 
00362           DataCollectorType & dc, const LevelIndexSetImp & levelSet, const int level)
00363     : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level) {} 
00364 
00365   // returns true, if element is contained in set of comm interface 
00366   bool containsItem (const HElementType & elem) const 
00367   {
00368     return levelSet_.containsIndex(codim, elem.getIndex() );
00369   }
00370 
00371   // set elem to realEntity
00372   void setElement(const HElementType & elem)
00373   {
00374     this->realEntity_.setElement(elem,level_); 
00375   }
00376     
00377 };
00378 
00379 
00381 template <class GridType, class DataCollectorType>
00382 class GatherScatterLevelData<GridType,DataCollectorType,0>
00383 : public GatherScatterBaseImpl<GridType,DataCollectorType,0> 
00384 {
00385   enum { codim = 0 };
00386   typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
00387   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<codim>::Entity> EntityType;
00388   typedef typename EntityType :: ImplementationType RealEntityType;
00389 
00390   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00391     template Codim<codim>::ImplementationType IMPLElementType;
00392   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00393     template Codim<codim>::InterfaceType HElementType;
00394   
00395   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00396     template Codim<1>::InterfaceType HFaceType;
00397   
00398   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00399     template Codim<0>::GhostInterfaceType HGhostType;
00400   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00401     template Codim<0>::GhostImplementationType ImplGhostType;
00402 
00403   typedef ALU3DSPACE ElementPllXIF_t PllElementType;
00404   typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
00405 
00406   const LevelIndexSetImp & levelSet_;
00407   const int level_;
00408 public:
00410   GatherScatterLevelData(const GridType & grid, EntityType & en, RealEntityType & realEntity , 
00411           DataCollectorType & dc, const LevelIndexSetImp & levelSet, const int level)
00412     : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level) {} 
00413 
00414   // returns true, if element is contained in set of comm interface 
00415   bool containsItem (const HElementType & elem) const 
00416   {
00417     return levelSet_.containsIndex(codim, elem.getIndex() );
00418   }
00419 
00420   // returns true, if element is contained in set of comm interface 
00421   bool containsItem (const HGhostType & ghost) const 
00422   {
00423     assert( ghost.getGhost().first );
00424     return containsItem( * (ghost.getGhost().first) );
00425   }
00426   
00427   // returns true, if interior element is contained in set of comm interface 
00428   bool containsInterior (const HFaceType & face, PllElementType & pll) const 
00429   {
00430     if(face.level() != level_) return false;
00431 
00432     // check interior element here, might have a coarser level 
00433     pair < Gitter::helement_STI * , Gitter::hbndseg_STI * > p (0,0);
00434     pll.getAttachedElement( p );
00435     assert( p.first );
00436     bool contained = (p.first->level() == level_);
00437     assert( contained == this->containsItem( *p.first ));
00438     return contained;
00439   }
00440 
00441   // returns true, if ghost is contianed in set of comm interface 
00442   bool containsGhost (const HFaceType & face, PllElementType & pll) const 
00443   {
00444     return (pll.ghostLevel() == level_);
00445   }
00446 };
00447 #endif
00448 
00450 template <class GridType, class DataCollectorType, class IndexOperatorType> 
00451 class GatherScatterLoadBalance : public GatherScatter
00452 {
00453 protected:  
00454   enum { codim = 0 };
00455   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<0>::Entity> EntityType;
00456   typedef typename EntityType :: ImplementationType RealEntityType;
00457   
00458   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00459     template Codim<codim>::ImplementationType IMPLElementType;
00460   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00461     template Codim<codim>::InterfaceType HElementType;
00462   
00463   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00464     template Codim<1>::InterfaceType HFaceType;
00465   
00466   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00467     template Codim<codim>::GhostInterfaceType HGhostType;
00468   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::
00469     template Codim<codim>::GhostImplementationType ImplGhostType;
00470 
00471 #if ALU3DGRID_PARALLEL 
00472   typedef ALU3DSPACE ElementPllXIF_t PllElementType;
00473 #else 
00474   typedef HElementType PllElementType;
00475 #endif
00476   GridType & grid_;
00477 
00478   EntityType     & entity_;
00479   RealEntityType & realEntity_;
00480 
00481   // data handle 
00482   DataCollectorType & dc_;
00483   IndexOperatorType & idxOp_;
00484 
00485   // used MessageBuffer 
00486   typedef typename GatherScatter :: ObjectStreamType ObjectStreamType;
00487 
00488 public:
00490   GatherScatterLoadBalance(GridType & grid, EntityType & en, RealEntityType & realEntity , DataCollectorType & dc, IndexOperatorType & idxOp ) 
00491     : grid_(grid), entity_(en), realEntity_(realEntity) 
00492     , dc_(dc) , idxOp_(idxOp) 
00493   {}
00494 
00495   // return true if dim,codim combination is contained in data set 
00496   bool contains(int dim, int codim) const 
00497   {
00498     return true; 
00499   }
00500 
00504   void inlineData ( ObjectStreamType & str , HElementType & elem )
00505   {
00506     str.write(grid_.maxLevel());
00507     // set element and then start 
00508     assert( elem.level () == 0 );
00509     realEntity_.setElement(elem);
00510     dc_.inlineData(str,entity_);
00511   }
00512 
00516   void xtractData ( ObjectStreamType & str , HElementType & elem )
00517   {
00518     assert( elem.level () == 0 );
00519     int mxl; 
00520     str.read(mxl);
00521     // set element and then start 
00522     grid_.setMaxLevel(mxl);
00523 
00524     // reserve memory for new elements 
00525     size_t elChunk = idxOp_.newElements();
00526     assert( elChunk > 0 );
00527     
00528     realEntity_.setElement(elem);
00529     dc_.xtractData(str,entity_, elChunk);
00530   }
00531 
00533   void compress () 
00534   {
00535     dc_.compress();
00536   } 
00537 };
00538 
00540 //
00541 //  --AdaptRestrictProlong 
00542 //
00544 template <class GridType , class RestrictProlongOperatorType >
00545 class AdaptRestrictProlongImpl : public AdaptRestrictProlongType
00546 {
00547   GridType & grid_;
00548   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<0>::Entity> EntityType;
00549   typedef typename EntityType :: ImplementationType RealEntityType;
00550   
00551   EntityType & reFather_;
00552   EntityType & reSon_;
00553   RealEntityType & realFather_;
00554   RealEntityType & realSon_;
00555  
00556   //DofManagerType & dm_;
00557   RestrictProlongOperatorType & rp_;
00558 
00559   typedef typename Dune::ALU3dImplTraits<GridType::elementType>::PLLBndFaceType PLLBndFaceType;
00560 
00561 public:
00563   AdaptRestrictProlongImpl (GridType & grid, 
00564       EntityType & f, RealEntityType & rf, EntityType & s, RealEntityType & rs
00565       , RestrictProlongOperatorType & rp) 
00566     : grid_(grid)
00567     , reFather_(f)
00568     , reSon_(s)
00569     , realFather_(rf) 
00570     , realSon_(rs) 
00571     , rp_(rp) 
00572   {
00573   }
00574 
00575   virtual ~AdaptRestrictProlongImpl () 
00576   {
00577   }
00578 
00580   int preCoarsening ( HElementType & elem )
00581   {
00582     // set element and then start 
00583     HElementType * son = elem.down();
00584 
00585     assert( son );
00586    
00587     realSon_.setElement(*son);
00588     realFather_.setElement(elem);
00589     rp_.restrictLocal(reFather_,reSon_,true);
00590 
00591     son = son->next();
00592     while( son )
00593     {
00594       realSon_.setElement(*son);
00595       rp_.restrictLocal(reFather_,reSon_,false);
00596       son = son->next();
00597     }
00598    
00599     // reset refinement marker 
00600     elem.resetRefinedTag();
00601     return 0;
00602   }
00603 
00605   int postRefinement ( HElementType & elem )
00606   {
00607     // set element and then start 
00608     HElementType * son = elem.down();
00609     assert( son );
00610 
00611     // reset refinement marker 
00612     elem.resetRefinedTag();
00613    
00614     realFather_.setElement(elem);
00615     realSon_.setElement(*son);
00616     
00617     rp_.prolongLocal(reFather_,reSon_, false);
00618 
00619     son = son->next();
00620     while( son )
00621     {
00622       assert( son );
00623   
00624       realSon_.setElement(*son);
00625       rp_.prolongLocal(reFather_,reSon_, false);
00626 
00627       // reset refinement tag 
00628       son->resetRefinedTag();
00629       
00630       son = son->next();
00631     }
00632     return 0;
00633   }
00634 
00637   int preCoarsening ( HBndSegType & el )
00638   {
00639     return 0;
00640   }
00641 
00642 
00644   int postRefinement ( HBndSegType & el )
00645   {
00646     return 0;
00647   }
00648 };
00649 
00650 template <class GridType , class RestrictProlongOperatorType ,
00651           class GlobalIdSetImp >
00652 class AdaptRestrictProlongGlSet
00653   : public AdaptRestrictProlongImpl<GridType,RestrictProlongOperatorType>
00654 {
00655   typedef AdaptRestrictProlongImpl<GridType,RestrictProlongOperatorType> BaseType;
00656   GlobalIdSetImp & set_;
00657   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<0>::Entity> EntityType;
00658   typedef typename EntityType :: ImplementationType RealEntityType;
00659   
00660 public:
00662   AdaptRestrictProlongGlSet(GridType & grid,
00663       EntityType & f, RealEntityType & rf, EntityType & s, RealEntityType & rs
00664       , RestrictProlongOperatorType & rp
00665       , GlobalIdSetImp & set )
00666     : BaseType(grid,f,rf,s,rs,rp)
00667     , set_(set)
00668   {
00669   }
00670 
00671   virtual ~AdaptRestrictProlongGlSet () {}
00672 
00674   int preCoarsening ( HElementType & elem )
00675   {
00676     return BaseType :: preCoarsening (elem );
00677   }
00678 
00680   int postRefinement ( HElementType & elem )
00681   {
00682     set_.postRefinement( elem );
00683     return BaseType :: postRefinement(elem );
00684   }
00685 
00688   int preCoarsening ( HBndSegType & el )
00689   {
00690     return 0;
00691   }
00692 
00693 };
00694 
00695 // this class is for counting the tree depth of the 
00696 // element when unpacking data from load balance 
00697 template <class GridType , class DofManagerType>
00698 class LoadBalanceElementCount : public AdaptRestrictProlongType
00699 {
00700   GridType & grid_;
00701   typedef Dune :: MakeableInterfaceObject<typename GridType::template Codim<0>::Entity> EntityType;
00702   typedef typename EntityType :: ImplementationType RealEntityType;
00703 
00704   typedef typename GridType::Traits::LeafIndexSet LeafIndexSetType; 
00705 
00706   EntityType & reFather_;
00707   EntityType & reSon_;
00708   RealEntityType & realFather_;
00709   RealEntityType & realSon_;
00710  
00711   DofManagerType & dm_;
00712   typedef typename  Dune::ALU3dImplTraits<GridType::elementType>::PLLBndFaceType PLLBndFaceType;
00713 
00714   int newMemSize_;
00715 public:
00717   LoadBalanceElementCount (GridType & grid, 
00718       EntityType & f, RealEntityType & rf, EntityType & s, RealEntityType & rs,DofManagerType & dm) 
00719     : grid_(grid)
00720     , reFather_(f)
00721     , reSon_(s)
00722     , realFather_(rf) 
00723     , realSon_(rs) 
00724     , dm_(dm) 
00725     , newMemSize_ (1) // we have at least one element (the macro element)
00726   {
00727   }
00728 
00729   virtual ~LoadBalanceElementCount () {};
00730 
00732   int postRefinement ( HElementType & elem )
00733   {
00734     // when called for a macro element, then a new tree is starting 
00735     // set to 1 because for only macro elements this method is not called 
00736     if( elem.level() == 0 ) newMemSize_ = 1;
00737 
00738     for( HElementType * son = elem.down() ; son ; son= son->next()) 
00739     {
00740       ++ newMemSize_;
00741     }
00742     return 0;
00743   }
00744 
00746   int preCoarsening ( HElementType & elem )
00747   {
00748     return 0;
00749   }
00750 
00753   int preCoarsening ( HBndSegType & el )
00754   {
00755     return 0;
00756   }
00757 
00762   int postRefinement ( HBndSegType & el )
00763   {
00764     return 0;
00765   }
00766 
00767   int newElements () const { return newMemSize_; }
00768 };
00769 
00770 } // end namespace 
00771 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)