4 #include <dune/common/stdstreams.hh>
19 template< ALU3dGr
idElementType elType,
class Comm >
33 , localIdSet_( *this )
34 , levelIndexVec_(MAXL,0) , leafIndexSet_(0)
35 , referenceElement_( elType ==
tetra
39 #ifdef USE_SMP_PARALLEL
44 , lockPostAdapt_( false )
49 , refinementType_( refinementType )
51 assert( elType ==
tetra || elType ==
hexa );
53 geomTypes_.resize( dimension+1 );
55 for(
int codim = 0; codim <= dimension; ++codim )
58 tmpType.makeSimplex( dimension - codim );
60 tmpType.makeCube( dimension - codim );
62 geomTypes_[ codim ].push_back( tmpType );
66 checkMacroGridFile( macroTriangFilename );
68 mygrid_ = createALUGrid( macroTriangFilename );
71 dverb <<
"************************************************" << std::endl;
72 dverb <<
"Created grid on p=" << comm().rank() << std::endl;
73 dverb <<
"************************************************" << std::endl;
81 template< ALU3dGr
idElementType elType,
class Comm >
87 return myGrid().indexManager(codim).getMaxIndex();
91 template< ALU3dGr
idElementType elType,
class Comm >
95 return myGrid().indexManager(codim).getMaxIndex();
99 template< ALU3dGr
idElementType elType,
class Comm >
106 template< ALU3dGr
idElementType elType,
class Comm >
116 template< ALU3dGr
idElementType elType,
class Comm >
117 template<
int cd, PartitionIteratorType pitype >
121 assert( level >= 0 );
123 if( level > maxlevel_ )
124 return this->
template lend<cd,pitype> (level);
130 template< ALU3dGr
idElementType elType,
class Comm >
131 template<
int cd, PartitionIteratorType pitype >
135 assert( level >= 0 );
141 template< ALU3dGr
idElementType elType,
class Comm >
146 return this->
template lbegin<cd,All_Partition>( level );
150 template< ALU3dGr
idElementType elType,
class Comm >
155 assert( level >= 0 );
156 return this->
template lend<cd,All_Partition>( level );
165 template< ALU3dGr
idElementType elType,
class Comm >
166 template<
int cd, PartitionIteratorType pitype >
170 assert( level >= 0 );
175 template< ALU3dGr
idElementType elType,
class Comm >
176 template<
int cd, PartitionIteratorType pitype >
180 return createLeafIteratorBegin<cd, pitype> (level) ;
184 template< ALU3dGr
idElementType elType,
class Comm >
186 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
187 ALU3dGrid< elType, Comm >::leafbegin (
int level )
const
189 return createLeafIteratorBegin<cd, All_Partition> (level) ;
193 template< ALU3dGr
idElementType elType,
class Comm >
194 template<
int cd, PartitionIteratorType pitype >
195 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
196 ALU3dGrid< elType, Comm >::leafbegin ()
const
198 return createLeafIteratorBegin< cd, pitype > (maxlevel_) ;
202 template< ALU3dGr
idElementType elType,
class Comm >
204 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
205 ALU3dGrid< elType, Comm >::leafbegin ()
const
207 return createLeafIteratorBegin< cd, All_Partition> (maxlevel_) ;
211 template< ALU3dGr
idElementType elType,
class Comm >
212 inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
213 ALU3dGrid< elType, Comm >::leafbegin (
int level )
const
215 return createLeafIteratorBegin<0, All_Partition> (level) ;
219 template< ALU3dGr
idElementType elType,
class Comm >
220 inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
221 ALU3dGrid< elType, Comm >::leafbegin ()
const
223 return createLeafIteratorBegin<0, All_Partition> (maxlevel_) ;
232 template< ALU3dGr
idElementType elType,
class Comm >
233 template<
int cd, PartitionIteratorType pitype >
234 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
237 assert( level >= 0 );
242 template< ALU3dGr
idElementType elType,
class Comm >
243 template<
int cd, PartitionIteratorType pitype >
247 return createLeafIteratorEnd < cd, pitype> (level);
251 template< ALU3dGr
idElementType elType,
class Comm >
253 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
254 ALU3dGrid< elType, Comm >::leafend (
int level )
const
256 return createLeafIteratorEnd < cd, All_Partition> (level);
260 template< ALU3dGr
idElementType elType,
class Comm >
261 template<
int cd, PartitionIteratorType pitype >
262 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
263 ALU3dGrid< elType, Comm >::leafend ()
const
265 return createLeafIteratorEnd < cd, pitype> (maxlevel_);
269 template< ALU3dGr
idElementType elType,
class Comm >
271 inline typename ALU3dGrid< elType, Comm >::Traits::template Codim< cd >::LeafIterator
272 ALU3dGrid< elType, Comm >::leafend ()
const
274 return createLeafIteratorEnd < cd, All_Partition> (maxlevel_);
278 template< ALU3dGr
idElementType elType,
class Comm >
279 inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
280 ALU3dGrid< elType, Comm >::leafend (
int level )
const
282 return createLeafIteratorEnd <0, All_Partition> (level);
286 template< ALU3dGr
idElementType elType,
class Comm >
287 inline typename ALU3dGrid< elType, Comm >::LeafIteratorType
288 ALU3dGrid< elType, Comm >::leafend ()
const
290 return createLeafIteratorEnd <0,All_Partition> (maxlevel_);
297 template< ALU3dGr
idElementType elType,
class Comm >
301 bool marked = (this->getRealImplementation( entity )).mark(ref);
304 if(ref > 0) ++refineMarked_;
305 if(ref < 0) ++coarsenMarked_;
312 template< ALU3dGr
idElementType elType,
class Comm >
316 return this->getRealImplementation( entity ).getMark();
321 template< ALU3dGr
idElementType elType,
class Comm >
322 template<
class Gr
idImp,
class DataHandle >
327 assert( (refCount + maxLevel()) < MAXL );
329 for(
int count = refCount; count > 0; --count )
341 template< ALU3dGr
idElementType elType,
class Comm >
342 template<
class Gr
idImp,
class DataHandle >
350 EntityObject father( EntityImp( factory(), this->maxLevel() ) );
351 EntityObject son ( EntityImp( factory(), this->maxLevel() ) );
354 bool mightCoarse = preAdapt();
356 bool refined = false ;
361 ALU3DSPACE AdaptRestrictProlongGlSet< MyType, AdaptDataHandle, GlobalIdSetImp >
363 father,this->getRealImplementation(father),
364 son, this->getRealImplementation(son),
368 refined = myGrid().duneAdapt(rp);
372 ALU3DSPACE AdaptRestrictProlongImpl< MyType, AdaptDataHandle >
374 father,this->getRealImplementation(father),
375 son, this->getRealImplementation(son),
378 refined = myGrid().duneAdapt(rp);
381 if(refined || mightCoarse)
398 template< ALU3dGr
idElementType elType,
class Comm >
401 template< ALU3dGr
idElementType elType >
408 template<
class DataHandle >
411 template<
class DataHandle,
class DataType >
419 template<
class DataHandle,
class DataType >
427 #if ALU3DGRID_PARALLEL
428 template< ALU3dGr
idElementType elType >
429 struct ALU3dGridCommHelper< elType, MPI_Comm >
431 typedef ALU3dGrid< elType, MPI_Comm > Grid;
434 static bool loadBalance ( Grid &grid )
436 if( grid.comm().size() <= 1 )
439 const bool changed = grid.myGrid().duneLoadBalance();
443 grid.myGrid().duneExchangeDynamicState();
451 if( grid.globalIdSet_ )
452 grid.globalIdSet_->updateIdSet();
462 template<
class DataHandle >
463 static bool loadBalance ( Grid &grid, DataHandle &data )
465 if( grid.comm().size() <= 1 )
468 typedef typename Grid :: EntityObject EntityObject;
469 typedef typename EntityObject::ImplementationType EntityImp;
470 EntityObject en ( EntityImp( grid.factory(), grid.maxLevel()) );
471 EntityObject father ( EntityImp( grid.factory(), grid.maxLevel()) );
472 EntityObject son ( EntityImp( grid.factory(), grid.maxLevel()) );
474 typedef ALU3DSPACE LoadBalanceElementCount< Grid, DataHandle > LDBElCountType;
478 LDBElCountType elCount( grid,
479 father, Grid::getRealImplementation( father ),
480 son, Grid::getRealImplementation( son ),
483 ALU3DSPACE GatherScatterLoadBalance< Grid, DataHandle, LDBElCountType >
484 gs( grid, en, Grid::getRealImplementation( en ), data, elCount );
487 const bool changed = grid.myGrid().duneLoadBalance( gs, elCount );
492 grid.myGrid().duneExchangeDynamicState();
500 if( grid.globalIdSet_ )
501 grid.globalIdSet_->updateIdSet();
512 template<
class DataHandle,
class DataType >
513 static void communicate (
const Grid &grid,
514 CommDataHandleIF< DataHandle, DataType > &data,
519 typedef CommDataHandleIF< DataHandle, DataType > DataHandleType;
520 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 3 >::Entity > VertexObject;
521 typedef typename VertexObject::ImplementationType VertexImp;
522 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 2 >::Entity > EdgeObject;
523 typedef typename EdgeObject::ImplementationType EdgeImp;
524 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 1 >::Entity > FaceObject;
525 typedef typename FaceObject::ImplementationType FaceImp;
526 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 0 >::Entity> ElementObject;
527 typedef typename ElementObject::ImplementationType ElementImp;
529 if( grid.comm().size() > 1 )
533 const typename Grid::LevelIndexSetImp *levelISet;
534 if( !grid.levelIndexVec_[ level ] )
535 levelISet =
new typename Grid::LevelIndexSetImp(
537 grid.template lbegin<0>( level ),
538 grid.template lend<0>( level ), level );
540 levelISet = grid.levelIndexVec_[ level ];
542 VertexObject vx( VertexImp( grid.factory(), level ) );
543 ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 3 >
544 vertexData( grid, vx, Grid::getRealImplementation( vx ), data, *levelISet, level );
546 EdgeObject edge( EdgeImp( grid.factory(), level ) );
547 ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 2 >
548 edgeData( grid, edge, Grid::getRealImplementation( edge ), data, *levelISet, level );
550 FaceObject face( FaceImp( grid.factory(), level ) );
551 ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 1 >
552 faceData( grid, face, Grid::getRealImplementation( face ), data, *levelISet, level );
554 ElementObject element( ElementImp( grid.factory(), level ) );
555 ALU3DSPACE GatherScatterLevelData< Grid, DataHandleType, 0 >
556 elementData( grid, element, Grid::getRealImplementation( element ), data, *levelISet, level );
558 doCommunication( grid, vertexData, edgeData, faceData, elementData, iftype, dir );
560 if( !grid.levelIndexVec_[ level ] )
565 template<
class DataHandle,
class DataType >
566 static void communicate (
const Grid &grid,
567 CommDataHandleIF< DataHandle, DataType > &data,
571 typedef CommDataHandleIF< DataHandle, DataType > DataHandleType;
572 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 3 >::Entity > VertexObject;
573 typedef typename VertexObject::ImplementationType VertexImp;
574 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 2 >::Entity > EdgeObject;
575 typedef typename EdgeObject::ImplementationType EdgeImp;
576 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 1 >::Entity > FaceObject;
577 typedef typename FaceObject::ImplementationType FaceImp;
578 typedef MakeableInterfaceObject< typename Grid::Traits::template Codim< 0 >::Entity> ElementObject;
579 typedef typename ElementObject::ImplementationType ElementImp;
581 if( grid.comm().size() > 1 )
583 VertexObject vx( VertexImp( grid.factory(), grid.maxLevel() ) );
584 ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 3 >
585 vertexData( grid, vx, Grid::getRealImplementation( vx ), data );
587 EdgeObject edge( EdgeImp( grid.factory(), grid.maxLevel() ) );
588 ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 2 >
589 edgeData( grid, edge, Grid::getRealImplementation( edge ), data );
591 FaceObject face( FaceImp( grid.factory(), grid.maxLevel()) );
592 ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 1 >
593 faceData( grid, face, Grid::getRealImplementation( face ), data );
595 ElementObject element( ElementImp( grid.factory(), grid.maxLevel() ) );
596 ALU3DSPACE GatherScatterLeafData< Grid, DataHandleType, 0 >
597 elementData( grid, element, Grid::getRealImplementation( element ), data );
599 doCommunication( grid, vertexData, edgeData, faceData, elementData, iftype, dir );
604 doCommunication (
const Grid &grid,
612 dverb <<
"ALUGrid contains no overlap, therefore no communication for" << std::endl;
613 dverb <<
"Overlap_OverlapFront_Interface or Overlap_All_Interface interfaces!" << std::endl;
617 grid.myGrid().borderBorderCommunication(vertexData,edgeData,faceData,elementData);
622 grid.myGrid().interiorGhostCommunication(vertexData,edgeData,faceData,elementData);
625 grid.myGrid().ghostInteriorCommunication(vertexData,edgeData,faceData,elementData);
629 grid.myGrid().allAllCommunication(vertexData,edgeData,faceData,elementData);
631 DUNE_THROW( GridError,
"Wrong set of parameters in ALUGridCommHelper::doCommunication" );
634 #endif // #if ALU3DGRID_PARALLEL
638 template< ALU3dGr
idElementType elType,
class Comm >
646 template< ALU3dGr
idElementType elType,
class Comm >
647 template<
class DataHandle >
655 template< ALU3dGr
idElementType elType,
class Comm >
656 template <
class DataHandleImp,
class DataType>
666 template< ALU3dGr
idElementType elType,
class Comm >
667 template <
class DataHandleImp,
class DataType>
677 template< ALU3dGr
idElementType elType,
class Comm >
681 return "ALUCubeGrid";
683 return "ALUSimplexGrid";
Definition: topology.hh:13
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
GatherScatter GatherScatterType
Definition: alu3dinclude.hh:49
send overlap, receive overlap and front entities
Definition: gridenums.hh:87
send overlap, receive all entities
Definition: gridenums.hh:88
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible...
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: grid_inline.hh:314
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:23
Definition: alugrid/3d/grid.hh:137
static void communicate(const Grid &grid, const CommDataHandleIF< DataHandle, DataType > &data, const InterfaceType iftype, const CommunicationDirection dir)
Definition: grid_inline.hh:420
int global_size(int cd) const
number of grid entities on all levels for given codim
Definition: grid_inline.hh:82
Definition: topology.hh:13
send/receive interior and border entities
Definition: gridenums.hh:85
[ provides Dune::Grid ]
Definition: alugrid/3d/entity.hh:36
#define ALU3DSPACE
Definition: alu3dinclude.hh:26
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Communicate information on distributed entities on a given level Template parameter is a model of Dun...
Definition: alugrid/common/declaration.hh:18
Definition: objectfactory.hh:23
communicate as given in InterfaceType
Definition: gridenums.hh:169
bool loadBalance()
Calculates load of each process and repartition the grid if neccessary. For parameters of the load ba...
Definition: grid_inline.hh:639
send interior and border, receive all entities
Definition: gridenums.hh:86
static bool loadBalance(Grid &grid, DataHandle &data)
Definition: grid_inline.hh:409
Definition: adaptcallback.hh:19
static std::string name()
for grid identification
Definition: grid_inline.hh:678
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: grid_inline.hh:299
ALU3dGrid< elType, No_Comm > Grid
Definition: grid_inline.hh:404
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
boundary projection type
Definition: alugrid/3d/grid.hh:496
reverse communication direction
Definition: gridenums.hh:170
double alu3d_ctype
Definition: alu3dinclude.hh:59
bool checkMacroGrid(ALU3dGridElementType elType, const std::string filename)
ALUGridRefinementType
available refinement types for ALUGrid
Definition: alugrid/common/declaration.hh:20
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
GitterImplType & myGrid() const
Definition: grid_inline.hh:108
send all and receive all entities
Definition: gridenums.hh:89
Leaf iterator.
Definition: alugrid/3d/entity.hh:34
InterfaceType::Implementation ImplementationType
Definition: common/grid.hh:1468
static void communicate(const Grid &grid, const CommDataHandleIF< DataHandle, DataType > &data, const InterfaceType iftype, const CommunicationDirection dir, const int level)
Definition: grid_inline.hh:412
Definition: alugrid/common/declaration.hh:18
ALUGrid boundary projection implementation DuneBndProjection has to fulfil the DuneBoundaryProjection...
Definition: common/bndprojection.hh:11
int hierSetSize(int cd) const
Definition: grid_inline.hh:92
ALU3dGrid(const std::string ¯oTriangFilename, const MPICommunicatorType mpiComm, const DuneBoundaryProjectionType *bndPrj, const DuneBoundaryProjectionVector *bndVec, const ALUGridRefinementType refinementType)
Definition: grid_inline.hh:21
Definition: alugrid/3d/entity.hh:24
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
static bool loadBalance(Grid &grid)
Definition: grid_inline.hh:406
Traits::template Codim< 0 >::LeafIterator LeafIteratorType
Definition: alugrid/3d/grid.hh:531
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
Definition: alugrid/3d/grid.hh:88
int maxLevel() const
Return maximum level defined in this grid. Levels are numbered maxLevel with 0 the coarsest level...
Definition: grid_inline.hh:100
ALU3dImplTraits< elType, Comm >::GitterImplType GitterImplType
Definition: alugrid/3d/grid.hh:536
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
A Traits struct that collects all associated types of one implementation.
Definition: common/grid.hh:437
Comm MPICommunicatorType
Definition: alugrid/3d/grid.hh:559
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:30