1 #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH
2 #define DUNE_ALU3DGRIDDATAHANDLE_HH
17 namespace ALUGridSpace
21 template <
class Gr
idType,
class DataCollectorType,
int codim >
23 :
public GatherScatter
27 typedef typename GridType::template Codim<codim>::Entity
EntityType;
32 typedef typename GridType::MPICommunicatorType
Comm;
35 typedef typename ImplTraits::template Codim< codim >::ImplementationType
ImplElementType;
41 DataCollectorType &
dc_;
47 typedef typename DataCollectorType:: DataType
DataType;
58 bool contains(
int dim,
int cd)
const {
return dc_.contains(dim,cd); }
131 template <
class Gr
idType,
class DataCollectorType >
137 typedef typename GridType::template Codim<0>::Entity
EntityType;
142 typedef typename GridType::MPICommunicatorType
Comm;
145 typedef typename ImplTraits::template Codim< codim >::ImplementationType
ImplElementType;
150 typedef typename ImplTraits::template Codim< codim >::GhostInterfaceType
HGhostType;
151 typedef typename ImplTraits::template Codim< codim >::GhostImplementationType
ImplGhostType;
168 using GatherScatter :: containsItem ;
180 return dc_.contains(dim,codim);
186 return elem.isLeafEntity();
190 virtual bool containsItem (
const HGhostType & ghost)
const = 0;
196 realEntity_.setElement( const_cast<HElementType &> (elem) );
210 realEntity_.setGhost( const_cast <HGhostType &> (ghost) );
258 size_t size =
dc_.size( en );
264 #if ALU3DGRID_PARALLEL
266 template<
class Gr
idType,
class DataCollectorType,
int codim >
267 class GatherScatterLeafData
268 :
public GatherScatterBaseImpl< GridType, DataCollectorType, codim >
270 enum { dim = GridType :: dimension };
272 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
273 typedef typename GridType::template Codim<codim>::Entity EntityType;
275 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
276 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
278 typedef typename GridType::MPICommunicatorType Comm;
281 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
286 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
287 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
289 typedef typename ImplTraits::PllElementType PllElementType;
293 using BaseType :: containsItem ;
296 GatherScatterLeafData(
const GridType & grid, MakeableEntityType & en,
297 RealEntityType & realEntity , DataCollectorType & dc)
298 : BaseType(grid,en,realEntity,dc)
304 if( (codim == 3) && dc.contains(dim,codim) )
308 grid.getLeafVertexList();
313 bool containsItem (
const HElementType & elem)
const
315 return elem.isLeafEntity();
319 bool containsItem (
const HGhostType & ghost)
const
321 return ghost.isLeafEntity();
325 bool containsInterior (
const HFaceType & face, PllElementType & pll)
const
327 return face.isInteriorLeaf();
331 bool containsGhost (
const HFaceType & face , PllElementType & pll)
const
333 return pll.ghostLeaf();
337 void setElement(
const HElementType & elem)
339 this->realEntity_.setElement(elem);
344 template <
class Gr
idType,
class DataCollectorType ,
int codim >
345 class GatherScatterLevelData
346 :
public GatherScatterBaseImpl<GridType,DataCollectorType,codim>
348 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
349 typedef typename GridType::template Codim<codim>::Entity EntityType;
351 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
352 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
354 typedef typename GridType::MPICommunicatorType Comm;
357 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
362 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
363 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
365 typedef typename ImplTraits::PllElementType PllElementType;
367 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
369 const LevelIndexSetImp & levelSet_;
373 using BaseType :: containsItem ;
376 GatherScatterLevelData(
const GridType & grid, MakeableEntityType & en,
377 RealEntityType & realEntity , DataCollectorType & dc,
378 const LevelIndexSetImp & levelSet,
const int level)
379 : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level)
384 bool containsItem (
const HElementType & elem)
const
386 return levelSet_.containsIndex(codim, elem.getIndex() );
390 void setElement(
const HElementType & elem)
392 this->realEntity_.setElement(elem,level_);
399 template <
class Gr
idType,
class DataCollectorType>
400 class GatherScatterLevelData<GridType,DataCollectorType,0>
401 :
public GatherScatterBaseImpl<GridType,DataCollectorType,0>
404 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
405 typedef typename GridType::template Codim<codim>::Entity EntityType;
407 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
408 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
410 typedef typename GridType::MPICommunicatorType Comm;
413 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
418 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
419 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
421 typedef typename ImplTraits::PllElementType PllElementType;
423 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
425 const LevelIndexSetImp & levelSet_;
429 GatherScatterLevelData(
const GridType & grid, MakeableEntityType & en,
430 RealEntityType & realEntity , DataCollectorType & dc,
431 const LevelIndexSetImp & levelSet,
const int level)
432 : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level) {}
435 bool containsItem (
const HElementType & elem)
const
437 return levelSet_.containsIndex(codim, elem.getIndex() );
441 bool containsItem (
const HGhostType & ghost)
const
443 assert( ghost.getGhost().first );
444 return containsItem( * (ghost.getGhost().first) );
448 bool containsInterior (
const HFaceType & face, PllElementType & pll)
const
451 if(face.level() != level_)
return false;
453 typedef Gitter::helement_STI HElementType;
454 typedef Gitter::hbndseg_STI HBndSegType;
457 pair< HElementType *, HBndSegType * > p( (HElementType *)0, (HBndSegType *)0 );
458 pll.getAttachedElement( p );
461 bool contained = (p.first->level() == level_);
462 assert( contained == this->containsItem( *p.first ));
467 bool containsGhost (
const HFaceType & face, PllElementType & pll)
const
470 if(face.level() != level_)
return false;
472 return (pll.ghostLevel() == level_);
475 #endif // #if ALU3DGRID_PARALLEL
478 template <
class Gr
idType,
class DataCollectorType,
class IndexOperatorType>
483 typedef typename GridType::template Codim<0>::Entity
EntityType;
488 typedef typename GridType::MPICommunicatorType
Comm;
491 typedef typename ImplTraits::template Codim< codim >::ImplementationType
IMPLElementType;
496 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType
HGhostType;
497 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType
ImplGhostType;
516 RealEntityType & realEntity , DataCollectorType & dc, IndexOperatorType & idxOp )
532 str.write(
grid_.maxLevel());
534 assert( elem.level () == 0 );
544 assert( elem.level () == 0 );
548 grid_.setMaxLevel(mxl);
551 size_t elChunk =
idxOp_.newElements();
552 assert( elChunk > 0 );
570 template<
class Gr
idType,
class AdaptDataHandle >
572 :
public AdaptRestrictProlongType
575 typedef typename GridType::template Codim<0>::Entity EntityType;
580 EntityType & reFather_;
582 RealEntityType & realFather_;
583 RealEntityType & realSon_;
585 AdaptDataHandle &rp_;
587 typedef typename GridType::MPICommunicatorType Comm;
590 typedef typename ImplTraits::HElementType HElementType;
591 typedef typename ImplTraits::HBndSegType HBndSegType;
592 typedef typename ImplTraits::BNDFaceType BNDFaceType;
599 AdaptDataHandle &rp )
616 realFather_.setElement( father );
617 rp_.preCoarsening( reFather_ );
620 father.resetRefinedTag();
627 realFather_.setElement( father );
628 rp_.postRefinement( reFather_ );
631 father.resetRefinedTag();
632 for( HElementType *son = father.down(); son ; son = son->next() )
633 son->resetRefinedTag();
664 template<
class Gr
idType,
class AdaptDataHandle,
class GlobalIdSetImp >
669 GlobalIdSetImp & set_;
670 typedef typename GridType::template Codim<0>::Entity EntityType;
675 typedef typename GridType::MPICommunicatorType Comm;
678 typedef typename ImplTraits::HElementType HElementType;
679 typedef typename ImplTraits::HBndSegType HBndSegType;
687 GlobalIdSetImp &
set )
688 :
BaseType( grid, f, rf, s, rs, rp ),
697 set_.postRefinement( elem );
704 template <
class Gr
idType ,
class DataHandleType>
708 typedef typename GridType::template Codim<0>::Entity EntityType;
713 typedef typename GridType::Traits::LeafIndexSet LeafIndexSetType;
715 EntityType & reFather_;
717 RealEntityType & realFather_;
718 RealEntityType & realSon_;
720 DataHandleType & dh_;
722 typedef typename GridType::MPICommunicatorType Comm;
725 typedef typename ImplTraits::HElementType HElementType;
726 typedef typename ImplTraits::HBndSegType HBndSegType;
752 if( elem.level() == 0 ) newMemSize_ = 1;
754 for( HElementType * son = elem.down() ; son ; son= son->next())
788 #endif // #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH