dune-grid  2.2.0
grid_inline.hh
Go to the documentation of this file.
00001 // Dune includes
00002 #include <dune/common/stdstreams.hh>
00003 
00004 // Local includes
00005 #include "alu3dinclude.hh"
00006 #include "entity.hh"
00007 #include "iterator.hh"
00008 #include "datahandle.hh"
00009 #include "grid.hh"
00010 
00011 namespace Dune
00012 {
00013 
00014   // Implementation of ALU3dGrid
00015   // ---------------------------
00016 
00017   template< ALU3dGridElementType elType, class Comm >
00018   inline ALU3dGrid< elType, Comm >
00019     ::ALU3dGrid ( const std::string &macroTriangFilename,
00020                   const MPICommunicatorType mpiComm,
00021                   const DuneBoundaryProjectionType *bndPrj,
00022                   const DuneBoundaryProjectionVector *bndVec,
00023                   const ALUGridRefinementType refinementType ) 
00024     : mygrid_( 0 )
00025     , maxlevel_( 0 )
00026     , coarsenMarked_( 0 )
00027     , refineMarked_( 0 )
00028     , geomTypes_() //dim+1, std::vector<GeometryType>(1) )
00029     , hIndexSet_ (*this)
00030     , globalIdSet_( 0 )
00031     , localIdSet_( *this )
00032     , levelIndexVec_(MAXL,0) , leafIndexSet_(0)
00033     , referenceElement_( elType == tetra
00034         ? GenericReferenceElements< alu3d_ctype, dimension > :: simplex()
00035         : GenericReferenceElements< alu3d_ctype, dimension > :: cube() )
00036     , sizeCache_ ( 0 )
00037 #ifdef USE_SMP_PARALLEL
00038     , factoryVec_( GridObjectFactoryType :: maxThreads(), GridObjectFactoryType( *this ) )
00039 #else 
00040     , factory_( *this )
00041 #endif
00042     , lockPostAdapt_( false )
00043     , bndPrj_ ( bndPrj )
00044     , bndVec_ ( (bndVec) ? (new DuneBoundaryProjectionVector( *bndVec )) : 0 )
00045     , vertexProjection_( (bndPrj || bndVec) ? new ALUGridBoundaryProjectionType( *this ) : 0 )
00046     , communications_( new Communications( mpiComm ) )
00047     , refinementType_( refinementType )
00048   {
00049     assert( elType == tetra || elType == hexa );
00050 
00051     geomTypes_.resize( dimension+1 );
00052     GeometryType tmpType;
00053     for( int codim = 0; codim <= dimension; ++codim ) 
00054     {
00055         if (elType == tetra)
00056             tmpType.makeSimplex( dimension - codim );
00057         else
00058             tmpType.makeCube( dimension - codim );
00059         
00060         geomTypes_[ codim ].push_back( tmpType );
00061     }
00062     
00063     // check macro grid file for keyword 
00064     checkMacroGridFile( macroTriangFilename );
00065    
00066     mygrid_ = createALUGrid( macroTriangFilename );
00067     assert( mygrid_ );
00068 
00069     dverb << "************************************************" << std::endl;
00070     dverb << "Created grid on p=" << comm().rank() << std::endl;
00071     dverb << "************************************************" << std::endl;
00072     checkMacroGrid ();
00073   
00074     postAdapt();
00075     calcExtras();
00076   } // end constructor
00077 
00078 
00079   template< ALU3dGridElementType elType, class Comm >
00080   inline int ALU3dGrid< elType, Comm >::global_size ( int codim ) const 
00081   {
00082     // return actual size of hierarchical index set 
00083     // this is always up to date 
00084     // maxIndex is the largest index used + 1 
00085     return myGrid().indexManager(codim).getMaxIndex();
00086   }
00087 
00088 
00089   template< ALU3dGridElementType elType, class Comm >
00090   inline int ALU3dGrid< elType, Comm >::hierSetSize ( int codim ) const
00091   {
00092     // return actual size of hierarchical index set 
00093     return myGrid().indexManager(codim).getMaxIndex();
00094   }
00095 
00096 
00097   template< ALU3dGridElementType elType, class Comm >
00098   inline int ALU3dGrid< elType, Comm >::maxLevel () const 
00099   { 
00100     return maxlevel_;
00101   }
00102 
00103 
00104   template< ALU3dGridElementType elType, class Comm >
00105   inline typename ALU3dGrid< elType, Comm >::GitterImplType &
00106   ALU3dGrid< elType, Comm >::myGrid () const
00107   {
00108     assert( mygrid_ );
00109     return *mygrid_;
00110   }
00111 
00112 
00113   // lbegin methods 
00114   template< ALU3dGridElementType elType, class Comm >
00115   template< int cd, PartitionIteratorType pitype >
00116   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator
00117   ALU3dGrid< elType, Comm >::lbegin ( int level ) const
00118   {
00119     assert( level >= 0 );
00120     // if we dont have this level return empty iterator 
00121     if( level > maxlevel_ )
00122       return this->template lend<cd,pitype> (level);
00123 
00124     return ALU3dGridLevelIterator< cd, pitype, const ThisType >( factory(), level, true );
00125   }
00126 
00127 
00128   template< ALU3dGridElementType elType, class Comm >
00129   template< int cd, PartitionIteratorType pitype >
00130   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LevelIterator
00131   ALU3dGrid< elType, Comm >::lend ( int level ) const
00132   {
00133     assert( level >= 0 );
00134     return ALU3dGridLevelIterator< cd, pitype, const ThisType >( factory(), level );
00135   }
00136 
00137 
00138   // lbegin methods 
00139   template< ALU3dGridElementType elType, class Comm >
00140   template< int cd >
00141   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator
00142   ALU3dGrid< elType, Comm >::lbegin ( int level ) const
00143   {
00144     return this->template lbegin<cd,All_Partition>( level );
00145   }
00146 
00147 
00148   template< ALU3dGridElementType elType, class Comm >
00149   template< int cd >
00150   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator
00151   ALU3dGrid< elType, Comm >::lend ( int level ) const
00152   {
00153     assert( level >= 0 );
00154     return this->template lend<cd,All_Partition>( level );
00155   }
00156 
00157 
00158   //***********************************************************
00159   //
00160   // leaf methods , first all begin methods 
00161   //
00162   //***********************************************************
00163   template< ALU3dGridElementType elType, class Comm >
00164   template< int cd, PartitionIteratorType pitype >
00165   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
00166   ALU3dGrid< elType, Comm >::createLeafIteratorBegin ( int level ) const
00167   {
00168     assert( level >= 0 );
00169     return ALU3dGridLeafIterator< cd, pitype, const ThisType >( factory(), level, true );
00170   }
00171 
00172 
00173   template< ALU3dGridElementType elType, class Comm >
00174   template< int cd, PartitionIteratorType pitype >
00175   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
00176   ALU3dGrid< elType, Comm >::leafbegin ( int level ) const
00177   {
00178     return createLeafIteratorBegin<cd, pitype> (level) ;
00179   }
00180 
00181 
00182   template< ALU3dGridElementType elType, class Comm >
00183   template< int cd >
00184   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
00185   ALU3dGrid< elType, Comm >::leafbegin ( int level ) const
00186   {
00187     return createLeafIteratorBegin<cd, All_Partition> (level) ;
00188   }
00189 
00190 
00191   template< ALU3dGridElementType elType, class Comm >
00192   template< int cd, PartitionIteratorType pitype >
00193   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
00194   ALU3dGrid< elType, Comm >::leafbegin () const
00195   {
00196     return createLeafIteratorBegin< cd, pitype > (maxlevel_) ;
00197   }
00198 
00199 
00200   template< ALU3dGridElementType elType, class Comm >
00201   template< int cd >
00202   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
00203   ALU3dGrid< elType, Comm >::leafbegin () const
00204   {
00205     return createLeafIteratorBegin< cd, All_Partition> (maxlevel_) ;
00206   }
00207 
00208 
00209   template< ALU3dGridElementType elType, class Comm >
00210   inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
00211   ALU3dGrid< elType, Comm >::leafbegin ( int level ) const
00212   {
00213     return createLeafIteratorBegin<0, All_Partition> (level) ;
00214   }
00215 
00216 
00217   template< ALU3dGridElementType elType, class Comm >
00218   inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
00219   ALU3dGrid< elType, Comm >::leafbegin () const
00220   {
00221     return createLeafIteratorBegin<0, All_Partition> (maxlevel_) ;
00222   }
00223 
00224 
00225   //****************************************************************
00226   //
00227   // all leaf end methods 
00228   //
00229   //****************************************************************
00230   template< ALU3dGridElementType elType, class Comm >
00231   template< int cd, PartitionIteratorType pitype >
00232   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
00233   ALU3dGrid< elType, Comm >::createLeafIteratorEnd ( int level ) const
00234   {
00235     assert( level >= 0 );
00236     return ALU3dGridLeafIterator<cd, pitype, const MyType> ( factory() , level);
00237   }
00238 
00239 
00240   template< ALU3dGridElementType elType, class Comm >
00241   template< int cd, PartitionIteratorType pitype >
00242   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
00243   ALU3dGrid< elType, Comm >::leafend ( int level ) const
00244   {
00245     return createLeafIteratorEnd < cd, pitype> (level);
00246   }
00247 
00248 
00249   template< ALU3dGridElementType elType, class Comm >
00250   template< int cd >
00251   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
00252   ALU3dGrid< elType, Comm >::leafend ( int level ) const
00253   {
00254     return createLeafIteratorEnd < cd, All_Partition> (level);
00255   }
00256 
00257 
00258   template< ALU3dGridElementType elType, class Comm >
00259   template< int cd, PartitionIteratorType pitype >
00260   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
00261   ALU3dGrid< elType, Comm >::leafend () const
00262   {
00263     return createLeafIteratorEnd < cd, pitype> (maxlevel_);
00264   }
00265 
00266 
00267   template< ALU3dGridElementType elType, class Comm >
00268   template< int cd >
00269   inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
00270   ALU3dGrid< elType, Comm >::leafend () const
00271   {
00272     return createLeafIteratorEnd < cd, All_Partition> (maxlevel_);
00273   }
00274 
00275 
00276   template< ALU3dGridElementType elType, class Comm >
00277   inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
00278   ALU3dGrid< elType, Comm >::leafend ( int level ) const
00279   {
00280     return createLeafIteratorEnd <0, All_Partition> (level);
00281   }
00282 
00283 
00284   template< ALU3dGridElementType elType, class Comm >
00285   inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
00286   ALU3dGrid< elType, Comm >::leafend () const
00287   {
00288     return createLeafIteratorEnd <0,All_Partition> (maxlevel_);
00289   }
00290 
00291 
00292   //*****************************************************************
00293 
00294   // mark given entity  
00295   template< ALU3dGridElementType elType, class Comm >
00296   inline bool ALU3dGrid< elType, Comm >
00297     ::mark ( int ref, const typename Traits::template Codim< 0 >::Entity &entity )
00298   {
00299     bool marked = (this->getRealImplementation( entity )).mark(ref);
00300     if(marked) 
00301       {
00302         if(ref > 0) ++refineMarked_;
00303         if(ref < 0) ++coarsenMarked_;
00304       }
00305     return marked;
00306   }
00307 
00308 
00309   // get Mark of given entity  
00310   template< ALU3dGridElementType elType, class Comm >
00311   inline int ALU3dGrid< elType, Comm >
00312     ::getMark ( const typename Traits::template Codim< 0 >::Entity &entity ) const
00313   {
00314     return this->getRealImplementation( entity ).getMark();
00315   }
00316 
00317 
00318   // global refine 
00319   template< ALU3dGridElementType elType, class Comm >
00320   template< class GridImp, class DataHandle >
00321   inline 
00322   void ALU3dGrid< elType, Comm >
00323     ::globalRefine ( int refCount, AdaptDataHandleInterface< GridImp, DataHandle > &handle )
00324   {
00325     assert( (refCount + maxLevel()) < MAXL ); 
00326     
00327     for( int count = refCount; count > 0; --count )
00328     {
00329       const LeafIteratorType end = leafend();
00330       for( LeafIteratorType it = leafbegin(); it != end; ++it )
00331         mark( 1 , *it );
00332       adapt( handle );
00333     }
00334   }
00335 
00336 
00337   // adapt grid  
00338   // --adapt
00339   template< ALU3dGridElementType elType, class Comm >
00340   template< class GridImp, class DataHandle >
00341   inline  
00342   bool ALU3dGrid< elType, Comm >
00343     ::adapt ( AdaptDataHandleInterface< GridImp, DataHandle > &handle )
00344   {
00345     typedef AdaptDataHandleInterface< GridImp, DataHandle > AdaptDataHandle;
00346 
00347     typedef typename EntityObject::ImplementationType EntityImp;
00348     EntityObject father( EntityImp( *this, this->maxLevel() ) );
00349     EntityObject son( EntityImp( *this, this->maxLevel() ) );
00350 
00351     int defaultChunk = newElementsChunk_;
00352     int actChunk     = refineEstimate_ * refineMarked_; 
00353 
00354     // guess how many new elements we get 
00355     int newElements = std::max( actChunk , defaultChunk ); 
00356 
00357     // true if at least one element was marked for coarsening
00358     bool mightCoarse = preAdapt();
00359     // reserve memory
00360     handle.preAdapt( newElements );
00361     
00362     bool refined = false ; 
00363     if(globalIdSet_)
00364     {
00365       // if global id set exists then include into 
00366       // prolongation process 
00367       ALU3DSPACE AdaptRestrictProlongGlSet< MyType, AdaptDataHandle, GlobalIdSetImp >
00368       rp(*this,
00369          father,this->getRealImplementation(father), 
00370          son,   this->getRealImplementation(son),
00371          handle,
00372          *globalIdSet_);
00373 
00374       refined = myGrid().duneAdapt(rp); // adapt grid 
00375     }
00376     else 
00377     {
00378        ALU3DSPACE AdaptRestrictProlongImpl< MyType, AdaptDataHandle >
00379        rp(*this,
00380           father,this->getRealImplementation(father), 
00381           son,   this->getRealImplementation(son),
00382           handle);
00383 
00384       refined = myGrid().duneAdapt(rp); // adapt grid 
00385     }
00386   
00387     if(refined || mightCoarse)
00388     {
00389       // only calc extras and skip maxLevel calculation, because of
00390       // refinement maxLevel was calculated already 
00391       updateStatus();
00392 
00393       // no need to call postAdapt here, because markers 
00394       // are cleand during refinement callback
00395     }
00396 
00397     // check whether we have balance 
00398     handle.postAdapt();
00399 
00400     // here postAdapt is not called, because 
00401     // reset of refinedTag is done in preCoarsening and postRefinement
00402     // methods of datahandle (see datahandle.hh) 
00403     
00404     return refined;
00405   }
00406 
00407 
00408 
00409   //*****************************************************************
00410 
00411   template< ALU3dGridElementType elType, class Comm >
00412   struct ALU3dGridCommHelper;
00413 
00414   template< ALU3dGridElementType elType >
00415   struct ALU3dGridCommHelper< elType, No_Comm >
00416   {
00417     typedef ALU3dGrid< elType, No_Comm > Grid;
00418 
00419     static bool loadBalance ( Grid &grid ) { return false; }
00420 
00421     template< class DataHandle >
00422     static bool loadBalance ( Grid &grid, DataHandle &data ) { return false; }
00423 
00424     template< class DataHandle, class DataType >
00425     static void communicate ( const Grid &grid, 
00426                               const CommDataHandleIF< DataHandle, DataType > &data,
00427                               const InterfaceType iftype, 
00428                               const CommunicationDirection dir, 
00429                               const int level )
00430     {}
00431 
00432     template< class DataHandle, class DataType >
00433     static void communicate ( const Grid &grid, 
00434                               const CommDataHandleIF< DataHandle, DataType > &data,
00435                               const InterfaceType iftype, 
00436                               const CommunicationDirection dir )
00437     {}
00438   }; // ALU3dGridCommHelper
00439 
00440 #if ALU3DGRID_PARALLEL
00441   template< ALU3dGridElementType elType >
00442   struct ALU3dGridCommHelper< elType, MPI_Comm >
00443   {
00444     typedef ALU3dGrid< elType, MPI_Comm > Grid;
00445     typedef ALU3DSPACE GatherScatter GatherScatterType;
00446 
00447     static bool loadBalance ( Grid &grid )
00448     {
00449       if( grid.comm().size() <= 1 )
00450         return false;
00451 
00452       const bool changed = grid.myGrid().duneLoadBalance();
00453       if( changed )
00454       {
00455         // some exchanges on ALUGrid side 
00456         grid.myGrid().duneExchangeDynamicState();
00457 
00458         // calculate new maxlevel 
00459         // reset size and things  
00460         grid.updateStatus();
00461         
00462         // build new Id Set. Only do that after updateStatus, because here
00463         // the item lists are needed 
00464         if( grid.globalIdSet_ )
00465           grid.globalIdSet_->updateIdSet();
00466       
00467         // unset all leaf markers
00468         grid.postAdapt();
00469       }
00470 
00471       return changed;
00472     }
00473 
00474 
00475     template< class DataHandle >
00476     static bool loadBalance ( Grid &grid, DataHandle &data )
00477     {
00478       if( grid.comm().size() <= 1 )
00479         return false;
00480 
00481       typedef typename Grid :: EntityObject EntityObject;
00482       typedef typename EntityObject::ImplementationType EntityImp;
00483       EntityObject en     ( EntityImp( grid, grid.maxLevel()) );
00484       EntityObject father ( EntityImp( grid, grid.maxLevel()) );
00485       EntityObject son    ( EntityImp( grid, grid.maxLevel()) );
00486 
00487       typedef ALU3DSPACE LoadBalanceElementCount< Grid, DataHandle > LDBElCountType;
00488 
00489       // elCount is the adaption restPro operator used during the refinement
00490       // cause be creating new elements on processors  
00491       LDBElCountType elCount( grid,
00492                               father, Grid::getRealImplementation( father ),
00493                               son, Grid::getRealImplementation( son ),
00494                               data );
00495 
00496       ALU3DSPACE GatherScatterLoadBalance< Grid, DataHandle, LDBElCountType >
00497         gs( grid, en, Grid::getRealImplementation( en ), data, elCount );
00498     
00499       // call load Balance 
00500       const bool changed = grid.myGrid().duneLoadBalance( gs, elCount );
00501 
00502       if( changed )
00503       {
00504         // exchange some data for internal useage
00505         grid.myGrid().duneExchangeDynamicState();
00506 
00507         // calculate new maxlevel 
00508         // reset size and things  
00509         grid.updateStatus();
00510 
00511         // build new Id Set. Only do that after updateStatus, because here
00512         // the item lists are needed 
00513         if( grid.globalIdSet_ )
00514           grid.globalIdSet_->updateIdSet();
00515         
00516         // compress data, wrapper for dof manager
00517         gs.compress();
00518 
00519         grid.postAdapt();
00520       }
00521       return changed;
00522     }
00523 
00524 
00525     template< class DataHandle, class DataType >
00526     static void communicate ( const Grid &grid, 
00527                               CommDataHandleIF< DataHandle, DataType > &data,
00528                               const InterfaceType iftype, 
00529                               const CommunicationDirection dir, 
00530                               const int level )
00531     {
00532       typedef CommDataHandleIF< DataHandle, DataType > DataHandleType;
00533       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 3 >::Entity > VertexObject;
00534       typedef typename VertexObject::ImplementationType VertexImp;
00535       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 2 >::Entity > EdgeObject;
00536       typedef typename EdgeObject::ImplementationType EdgeImp;
00537       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 1 >::Entity > FaceObject;
00538       typedef typename FaceObject::ImplementationType FaceImp;
00539       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 0 >::Entity> ElementObject;
00540       typedef typename ElementObject::ImplementationType ElementImp;
00541 
00542       if( grid.comm().size() > 1 )
00543       {
00544         // for level communication the level index set is needed. 
00545         // if non-existent, then create for communicaton
00546         const typename Grid::LevelIndexSetImp *levelISet;
00547         if( !grid.levelIndexVec_[ level ] )
00548           levelISet = new typename Grid::LevelIndexSetImp(
00549               grid, 
00550               grid.template lbegin<0>( level ),
00551               grid.template lend<0>( level ), level );
00552         else 
00553           levelISet = grid.levelIndexVec_[ level ];
00554         
00555         VertexObject vx( VertexImp( grid, level ) );    
00556         ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 3 >
00557           vertexData( grid, vx, Grid::getRealImplementation( vx ), data, *levelISet, level );
00558         
00559         EdgeObject edge( EdgeImp( grid, level ) );
00560         ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 2 >
00561           edgeData( grid, edge, Grid::getRealImplementation( edge ), data, *levelISet, level );
00562         
00563         FaceObject face( FaceImp( grid, level ) );
00564         ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 1 >
00565           faceData( grid, face, Grid::getRealImplementation( face ), data, *levelISet, level );
00566 
00567         ElementObject element( ElementImp( grid, level ) );    
00568         ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 0 >
00569           elementData( grid, element, Grid::getRealImplementation( element ), data, *levelISet, level );
00570 
00571         doCommunication( grid, vertexData, edgeData, faceData, elementData, iftype, dir );
00572 
00573         if( !grid.levelIndexVec_[ level ] )
00574           delete levelISet;
00575       }
00576     }
00577 
00578     template< class DataHandle, class DataType >
00579     static void communicate ( const Grid &grid, 
00580                               CommDataHandleIF< DataHandle, DataType > &data,
00581                               const InterfaceType iftype, 
00582                               const CommunicationDirection dir )
00583     {
00584       typedef CommDataHandleIF< DataHandle, DataType > DataHandleType;
00585       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 3 >::Entity > VertexObject;
00586       typedef typename VertexObject::ImplementationType VertexImp;
00587       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 2 >::Entity > EdgeObject;
00588       typedef typename EdgeObject::ImplementationType EdgeImp;
00589       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 1 >::Entity > FaceObject;
00590       typedef typename FaceObject::ImplementationType FaceImp;
00591       typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 0 >::Entity> ElementObject;
00592       typedef typename ElementObject::ImplementationType ElementImp;
00593 
00594       if( grid.comm().size() > 1 )
00595       {
00596         VertexObject vx( VertexImp( grid, grid.maxLevel() ) );
00597         ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 3 >
00598           vertexData( grid, vx, Grid::getRealImplementation( vx ), data );
00599         
00600         EdgeObject edge( EdgeImp( grid, grid.maxLevel() ) );
00601         ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 2 >
00602           edgeData( grid, edge, Grid::getRealImplementation( edge ), data );
00603         
00604         FaceObject face( FaceImp( grid, grid.maxLevel()) );    
00605         ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 1 >
00606           faceData( grid, face, Grid::getRealImplementation( face ), data );
00607 
00608         ElementObject element( ElementImp( grid, grid.maxLevel() ) );
00609         ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 0 >
00610           elementData( grid, element, Grid::getRealImplementation( element ), data );
00611 
00612         doCommunication( grid, vertexData, edgeData, faceData, elementData, iftype, dir );
00613       }
00614     }
00615 
00616     static void
00617     doCommunication ( const Grid &grid,
00618                       GatherScatterType &vertexData, GatherScatterType &edgeData,
00619                       GatherScatterType &faceData, GatherScatterType &elementData,
00620                       InterfaceType iftype, CommunicationDirection dir )
00621     {
00622       // check interface types 
00623       if( (iftype == Overlap_OverlapFront_Interface) || (iftype == Overlap_All_Interface) )
00624       {
00625         dverb << "ALUGrid contains no overlap, therefore no communication for" << std::endl;
00626         dverb << "Overlap_OverlapFront_Interface or Overlap_All_Interface interfaces!" << std::endl;
00627       }
00628       // communication from border to border 
00629       else if( iftype == InteriorBorder_InteriorBorder_Interface )
00630         grid.myGrid().borderBorderCommunication(vertexData,edgeData,faceData,elementData);
00631       // communication from interior to ghost including border 
00632       else if( iftype == InteriorBorder_All_Interface )
00633       {
00634         if( dir == ForwardCommunication )
00635           grid.myGrid().interiorGhostCommunication(vertexData,edgeData,faceData,elementData);
00636         // reverse communiction interface (here All_InteriorBorder) 
00637         else if( dir == BackwardCommunication )
00638           grid.myGrid().ghostInteriorCommunication(vertexData,edgeData,faceData,elementData);
00639       }
00640       // communication from interior to ghost including border 
00641       else if( iftype == All_All_Interface )
00642         grid.myGrid().allAllCommunication(vertexData,edgeData,faceData,elementData);
00643       else
00644         DUNE_THROW( GridError, "Wrong set of parameters in ALUGridCommHelper::doCommunication" );
00645     }
00646   }; // ALU3dGridCommHelper
00647 #endif // #if ALU3DGRID_PARALLEL
00648 
00649 
00650 
00651   template< ALU3dGridElementType elType, class Comm >
00652   inline bool ALU3dGrid< elType, Comm >::loadBalance ()
00653   {
00654     return ALU3dGridCommHelper< elType, Comm >::loadBalance( *this );
00655   }
00656 
00657 
00658   // load balance grid  
00659   template< ALU3dGridElementType elType, class Comm >
00660   template< class DataHandle >
00661   inline bool ALU3dGrid< elType, Comm >::loadBalance ( DataHandle &data )
00662   {
00663     return ALU3dGridCommHelper< elType, Comm >::loadBalance( *this, data );
00664   }
00665 
00666 
00667   // communicate level data   
00668   template< ALU3dGridElementType elType, class Comm >
00669   template <class DataHandleImp,class DataType> 
00670   inline void ALU3dGrid< elType, Comm >::
00671   communicate (CommDataHandleIF<DataHandleImp,DataType> &data, 
00672                InterfaceType iftype, CommunicationDirection dir, int level ) const
00673   {
00674     ALU3dGridCommHelper< elType, Comm >::communicate( *this, data, iftype, dir, level );
00675   }
00676 
00677 
00678   // communicate data   
00679   template< ALU3dGridElementType elType, class Comm >
00680   template <class DataHandleImp, class DataType> 
00681   inline void ALU3dGrid< elType, Comm >::
00682   communicate (CommDataHandleIF<DataHandleImp,DataType> & data, 
00683                InterfaceType iftype, CommunicationDirection dir) const
00684   {
00685     ALU3dGridCommHelper< elType, Comm >::communicate( *this, data, iftype, dir );
00686   }
00687 
00688 
00689   // return Grid name 
00690   template< ALU3dGridElementType elType, class Comm >
00691   inline std::string ALU3dGrid< elType, Comm >::name ()
00692   {
00693     if( elType == hexa )
00694       return "ALUCubeGrid";
00695     else
00696       return "ALUSimplexGrid";
00697   }
00698 
00699 } // end namespace Dune