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;
34 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm >
ImplTraits;
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;
144 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm >
ImplTraits;
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;
177 return dc_.contains(dim,codim);
183 return elem.isLeafEntity();
187 virtual bool containsItem (
const HGhostType & ghost)
const = 0;
193 realEntity_.setElement( const_cast<HElementType &> (elem) );
207 realEntity_.setGhost( const_cast <HGhostType &> (ghost) );
255 size_t size =
dc_.size( en );
261 #if ALU3DGRID_PARALLEL
263 template<
class Gr
idType,
class DataCollectorType,
int codim >
264 class GatherScatterLeafData
265 :
public GatherScatterBaseImpl< GridType, DataCollectorType, codim >
267 enum { dim = GridType :: dimension };
269 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
270 typedef typename GridType::template Codim<codim>::Entity EntityType;
272 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
273 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
275 typedef typename GridType::MPICommunicatorType Comm;
277 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
278 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
283 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
284 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
286 typedef typename ImplTraits::PllElementType PllElementType;
290 GatherScatterLeafData(
const GridType & grid, MakeableEntityType & en,
291 RealEntityType & realEntity , DataCollectorType & dc)
292 : BaseType(grid,en,realEntity,dc)
298 if( (codim == 3) && dc.contains(dim,codim) )
302 grid.getLeafVertexList();
307 bool containsItem (
const HElementType & elem)
const
309 return elem.isLeafEntity();
313 bool containsItem (
const HGhostType & ghost)
const
315 return ghost.isLeafEntity();
319 bool containsInterior (
const HFaceType & face, PllElementType & pll)
const
321 return face.isInteriorLeaf();
325 bool containsGhost (
const HFaceType & face , PllElementType & pll)
const
327 return pll.ghostLeaf();
331 void setElement(
const HElementType & elem)
333 this->realEntity_.setElement(elem);
338 template <
class Gr
idType,
class DataCollectorType ,
int codim >
339 class GatherScatterLevelData
340 :
public GatherScatterBaseImpl<GridType,DataCollectorType,codim>
342 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
343 typedef typename GridType::template Codim<codim>::Entity EntityType;
345 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
346 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
348 typedef typename GridType::MPICommunicatorType Comm;
350 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
351 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
356 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
357 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
359 typedef typename ImplTraits::PllElementType PllElementType;
361 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
363 const LevelIndexSetImp & levelSet_;
367 GatherScatterLevelData(
const GridType & grid, MakeableEntityType & en,
368 RealEntityType & realEntity , DataCollectorType & dc,
369 const LevelIndexSetImp & levelSet,
const int level)
370 : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level)
375 bool containsItem (
const HElementType & elem)
const
377 return levelSet_.containsIndex(codim, elem.getIndex() );
381 void setElement(
const HElementType & elem)
383 this->realEntity_.setElement(elem,level_);
390 template <
class Gr
idType,
class DataCollectorType>
391 class GatherScatterLevelData<GridType,DataCollectorType,0>
392 :
public GatherScatterBaseImpl<GridType,DataCollectorType,0>
395 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
396 typedef typename GridType::template Codim<codim>::Entity EntityType;
398 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
399 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
401 typedef typename GridType::MPICommunicatorType Comm;
403 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
404 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
409 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
410 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
412 typedef typename ImplTraits::PllElementType PllElementType;
414 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
416 const LevelIndexSetImp & levelSet_;
420 GatherScatterLevelData(
const GridType & grid, MakeableEntityType & en,
421 RealEntityType & realEntity , DataCollectorType & dc,
422 const LevelIndexSetImp & levelSet,
const int level)
423 : BaseType(grid,en,realEntity,dc) , levelSet_(levelSet) , level_(level) {}
426 bool containsItem (
const HElementType & elem)
const
428 return levelSet_.containsIndex(codim, elem.getIndex() );
432 bool containsItem (
const HGhostType & ghost)
const
434 assert( ghost.getGhost().first );
435 return containsItem( * (ghost.getGhost().first) );
439 bool containsInterior (
const HFaceType & face, PllElementType & pll)
const
442 if(face.level() != level_)
return false;
444 typedef Gitter::helement_STI HElementType;
445 typedef Gitter::hbndseg_STI HBndSegType;
448 pair< HElementType *, HBndSegType * > p( (HElementType *)0, (HBndSegType *)0 );
449 pll.getAttachedElement( p );
452 bool contained = (p.first->level() == level_);
453 assert( contained == this->containsItem( *p.first ));
458 bool containsGhost (
const HFaceType & face, PllElementType & pll)
const
461 if(face.level() != level_)
return false;
463 return (pll.ghostLevel() == level_);
466 #endif // #if ALU3DGRID_PARALLEL
469 template <
class Gr
idType,
class DataCollectorType,
class IndexOperatorType>
474 typedef typename GridType::template Codim<0>::Entity
EntityType;
479 typedef typename GridType::MPICommunicatorType
Comm;
481 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm >
ImplTraits;
482 typedef typename ImplTraits::template Codim< codim >::ImplementationType
IMPLElementType;
487 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType
HGhostType;
488 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType
ImplGhostType;
507 RealEntityType & realEntity , DataCollectorType & dc, IndexOperatorType & idxOp )
523 str.write(
grid_.maxLevel());
525 assert( elem.level () == 0 );
535 assert( elem.level () == 0 );
539 grid_.setMaxLevel(mxl);
542 size_t elChunk =
idxOp_.newElements();
543 assert( elChunk > 0 );
561 template<
class Gr
idType,
class AdaptDataHandle >
563 :
public AdaptRestrictProlongType
566 typedef typename GridType::template Codim<0>::Entity EntityType;
571 EntityType & reFather_;
573 RealEntityType & realFather_;
574 RealEntityType & realSon_;
576 AdaptDataHandle &rp_;
578 typedef typename GridType::MPICommunicatorType Comm;
580 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
581 typedef typename ImplTraits::HElementType HElementType;
582 typedef typename ImplTraits::HBndSegType HBndSegType;
583 typedef typename ImplTraits::BNDFaceType BNDFaceType;
590 AdaptDataHandle &rp )
607 realFather_.setElement( father );
608 rp_.preCoarsening( reFather_ );
611 father.resetRefinedTag();
618 realFather_.setElement( father );
619 rp_.postRefinement( reFather_ );
622 father.resetRefinedTag();
623 for( HElementType *son = father.down(); son ; son = son->next() )
624 son->resetRefinedTag();
655 template<
class Gr
idType,
class AdaptDataHandle,
class GlobalIdSetImp >
660 GlobalIdSetImp & set_;
661 typedef typename GridType::template Codim<0>::Entity EntityType;
666 typedef typename GridType::MPICommunicatorType Comm;
668 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
669 typedef typename ImplTraits::HElementType HElementType;
670 typedef typename ImplTraits::HBndSegType HBndSegType;
678 GlobalIdSetImp &
set )
679 :
BaseType( grid, f, rf, s, rs, rp ),
688 set_.postRefinement( elem );
695 template <
class Gr
idType ,
class DataHandleType>
699 typedef typename GridType::template Codim<0>::Entity EntityType;
704 typedef typename GridType::Traits::LeafIndexSet LeafIndexSetType;
706 EntityType & reFather_;
708 RealEntityType & realFather_;
709 RealEntityType & realSon_;
711 DataHandleType & dh_;
713 typedef typename GridType::MPICommunicatorType Comm;
715 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
716 typedef typename ImplTraits::HElementType HElementType;
717 typedef typename ImplTraits::HBndSegType HBndSegType;
743 if( elem.level() == 0 ) newMemSize_ = 1;
745 for( HElementType * son = elem.down() ; son ; son= son->next())
779 #endif // #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH