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