3 #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH
4 #define DUNE_ALU3DGRIDDATAHANDLE_HH
19 namespace ALUGridSpace
23 template <
class Gr
idType,
class DataCollectorType,
int codim >
25 :
public GatherScatter
29 typedef typename GridType::template Codim<codim>::Entity
EntityType;
34 typedef typename GridType::MPICommunicatorType
Comm;
36 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm >
ImplTraits;
37 typedef typename ImplTraits::template Codim< codim >::ImplementationType
ImplElementType;
43 DataCollectorType &
dc_;
49 typedef typename DataCollectorType:: DataType
DataType;
65 bool contains(
int dim,
int cd)
const {
return dc_.contains(dim,cd); }
138 template <
class Gr
idType,
class DataCollectorType >
144 typedef typename GridType::template Codim<0>::Entity
EntityType;
149 typedef typename GridType::MPICommunicatorType
Comm;
151 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm >
ImplTraits;
152 typedef typename ImplTraits::template Codim< codim >::ImplementationType
ImplElementType;
157 typedef typename ImplTraits::template Codim< codim >::GhostInterfaceType
HGhostType;
158 typedef typename ImplTraits::template Codim< codim >::GhostImplementationType
ImplGhostType;
192 return dc_.contains(dim,codim);
198 return elem.isLeafEntity();
202 virtual bool containsItem (
const HGhostType & ghost)
const = 0;
208 realEntity_.setElement( const_cast<HElementType &> (elem) );
222 realEntity_.setGhost( const_cast <HGhostType &> (ghost) );
270 size_t size =
dc_.size( en );
276 #if ALU3DGRID_PARALLEL
278 template<
class Gr
idType,
class DataCollectorType,
int codim >
279 class GatherScatterLeafData
280 :
public GatherScatterBaseImpl< GridType, DataCollectorType, codim >
282 enum { dim = GridType :: dimension };
284 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
285 typedef typename GridType::template Codim<codim>::Entity EntityType;
287 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
288 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
290 typedef typename GridType::MPICommunicatorType Comm;
292 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
293 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
298 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
299 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
301 typedef typename ImplTraits::PllElementType PllElementType;
305 using BaseType :: containsItem ;
308 GatherScatterLeafData(
const GridType & grid, MakeableEntityType & en,
309 RealEntityType & realEntity , DataCollectorType & dc)
310 : BaseType(grid,en,realEntity,dc)
316 if( (codim == 3) && dc.contains(dim,codim) )
320 grid.getLeafVertexList();
325 bool containsItem (
const HElementType & elem)
const
327 return elem.isLeafEntity();
331 bool containsItem (
const HGhostType & ghost)
const
333 return ghost.isLeafEntity();
337 bool containsInterior (
const HFaceType & face, PllElementType & pll)
const
339 return face.isInteriorLeaf();
343 bool containsGhost (
const HFaceType & face , PllElementType & pll)
const
345 return pll.ghostLeaf();
349 void setElement(
const HElementType & elem)
351 this->realEntity_.setElement(elem);
356 template <
class Gr
idType,
class DataCollectorType ,
int codim >
357 class GatherScatterLevelData
358 :
public GatherScatterBaseImpl<GridType,DataCollectorType,codim>
360 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
361 typedef typename GridType::template Codim<codim>::Entity EntityType;
363 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
364 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
366 typedef typename GridType::MPICommunicatorType Comm;
368 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
369 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
374 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
375 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
377 typedef typename ImplTraits::PllElementType PllElementType;
379 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
381 const LevelIndexSetImp & levelSet_;
385 using BaseType :: containsItem ;
388 GatherScatterLevelData(
const GridType & grid, MakeableEntityType & en,
389 RealEntityType & realEntity , DataCollectorType & dc,
390 const LevelIndexSetImp & levelSet,
const int level)
391 : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level)
395 bool containsItem (
const HElementType & elem)
const
397 return levelSet_.containsIndex(codim, elem.getIndex() );
401 void setElement(
const HElementType & elem)
403 this->realEntity_.setElement(elem,level_);
410 template <
class Gr
idType,
class DataCollectorType>
411 class GatherScatterLevelData<GridType,DataCollectorType,0>
412 :
public GatherScatterBaseImpl<GridType,DataCollectorType,0>
415 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
416 typedef typename GridType::template Codim<codim>::Entity EntityType;
418 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
419 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
421 typedef typename GridType::MPICommunicatorType Comm;
423 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
424 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
429 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
430 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
432 typedef typename ImplTraits::PllElementType PllElementType;
434 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
436 const LevelIndexSetImp & levelSet_;
440 GatherScatterLevelData(
const GridType & grid, MakeableEntityType & en,
441 RealEntityType & realEntity , DataCollectorType & dc,
442 const LevelIndexSetImp & levelSet,
const int level)
443 : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level) {}
446 bool containsItem (
const HElementType & elem)
const
448 return levelSet_.containsIndex(codim, elem.getIndex() );
452 bool containsItem (
const HGhostType & ghost)
const
454 assert( ghost.getGhost().first );
455 return containsItem( * (ghost.getGhost().first) );
459 bool containsInterior (
const HFaceType & face, PllElementType & pll)
const
462 if(face.level() != level_)
return false;
464 typedef Gitter::helement_STI HElementType;
465 typedef Gitter::hbndseg_STI HBndSegType;
468 pair< HElementType *, HBndSegType * > p( (HElementType *)0, (HBndSegType *)0 );
469 pll.getAttachedElement( p );
472 bool contained = (p.first->level() == level_);
473 assert( contained == this->containsItem( *p.first ));
478 bool containsGhost (
const HFaceType & face, PllElementType & pll)
const
481 if(face.level() != level_)
return false;
483 return (pll.ghostLevel() == level_);
486 #endif // #if ALU3DGRID_PARALLEL
489 template <
class Gr
idType,
class DataCollectorType,
class IndexOperatorType>
494 typedef typename GridType::template Codim<0>::Entity
EntityType;
499 typedef typename GridType::MPICommunicatorType
Comm;
501 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm >
ImplTraits;
502 typedef typename ImplTraits::template Codim< codim >::ImplementationType
IMPLElementType;
507 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType
HGhostType;
508 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType
ImplGhostType;
530 RealEntityType & realEntity , DataCollectorType & dc, IndexOperatorType & idxOp )
546 str.write(
grid_.maxLevel());
548 assert( elem.level () == 0 );
558 assert( elem.level () == 0 );
562 grid_.setMaxLevel(mxl);
565 size_t elChunk =
idxOp_.newElements();
566 assert( elChunk > 0 );
584 template<
class Gr
idType,
class AdaptDataHandle >
586 :
public AdaptRestrictProlongType
589 typedef typename GridType::template Codim<0>::Entity EntityType;
594 EntityType & reFather_;
596 RealEntityType & realFather_;
597 RealEntityType & realSon_;
599 AdaptDataHandle &rp_;
601 typedef typename GridType::MPICommunicatorType Comm;
603 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
604 typedef typename ImplTraits::HElementType HElementType;
605 typedef typename ImplTraits::HBndSegType HBndSegType;
606 typedef typename ImplTraits::BNDFaceType BNDFaceType;
616 AdaptDataHandle &rp )
631 realFather_.setElement( father );
632 rp_.preCoarsening( reFather_ );
635 father.resetRefinedTag();
642 realFather_.setElement( father );
643 rp_.postRefinement( reFather_ );
646 father.resetRefinedTag();
647 for( HElementType *son = father.down(); son ; son = son->next() )
648 son->resetRefinedTag();
663 template<
class Gr
idType,
class AdaptDataHandle,
class GlobalIdSetImp >
668 GlobalIdSetImp & set_;
669 typedef typename GridType::template Codim<0>::Entity EntityType;
674 typedef typename GridType::MPICommunicatorType Comm;
676 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
677 typedef typename ImplTraits::HElementType HElementType;
678 typedef typename ImplTraits::HBndSegType HBndSegType;
689 GlobalIdSetImp &
set )
690 :
BaseType( grid, f, rf, s, rs, rp ),
699 set_.postRefinement( elem );
706 template <
class Gr
idType ,
class DataHandleType>
710 typedef typename GridType::template Codim<0>::Entity EntityType;
715 typedef typename GridType::Traits::LeafIndexSet LeafIndexSetType;
717 EntityType & reFather_;
719 RealEntityType & realFather_;
720 RealEntityType & realSon_;
722 DataHandleType & dh_;
724 typedef typename GridType::MPICommunicatorType Comm;
726 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
727 typedef typename ImplTraits::HElementType HElementType;
728 typedef typename ImplTraits::HBndSegType HBndSegType;
757 if( elem.level() == 0 ) newMemSize_ = 1;
759 for( HElementType * son = elem.down() ; son ; son= son->next())
793 #endif // #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH