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;
37 typedef typename ImplTraits::template Codim< codim >::ImplementationType
ImplElementType;
43 DataCollectorType &
dc_;
49 typedef typename DataCollectorType:: DataType
DataType;
51 using GatherScatter :: setData ;
52 using GatherScatter :: sendData ;
53 using GatherScatter :: recvData ;
54 using GatherScatter :: containsItem ;
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;
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;
174 using GatherScatter :: setData ;
175 using GatherScatter :: sendData ;
176 using GatherScatter :: recvData ;
180 using GatherScatter :: containsItem ;
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
277 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;
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;
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;
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;
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;
524 using GatherScatter :: inlineData ;
525 using GatherScatter :: xtractData ;
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;
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;
677 typedef typename ImplTraits::HElementType HElementType;
678 typedef typename ImplTraits::HBndSegType HBndSegType;
680 using AdaptRestrictProlongType :: postRefinement ;
681 using AdaptRestrictProlongType :: preCoarsening ;
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;
727 typedef typename ImplTraits::HElementType HElementType;
728 typedef typename ImplTraits::HBndSegType HBndSegType;
732 using AdaptRestrictProlongType :: postRefinement ;
733 using AdaptRestrictProlongType :: preCoarsening ;
757 if( elem.level() == 0 ) newMemSize_ = 1;
759 for( HElementType * son = elem.down() ; son ; son= son->next())
793 #endif // #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH
Definition: alugrid/3d/datahandle.hh:585
GatherScatter::ObjectStreamType ObjectStreamType
Definition: alugrid/3d/datahandle.hh:171
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and ALUGrid ...
int postRefinement(HBndSegType &el)
Definition: alugrid/3d/datahandle.hh:783
ImplTraits::PllElementType PllElementType
Definition: alugrid/3d/datahandle.hh:160
ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType
Definition: alugrid/3d/datahandle.hh:507
DataCollectorType::DataType DataType
Definition: alugrid/3d/datahandle.hh:49
void recvData(ObjectStreamType &str, HElementType &elem)
read Data of one element from stream
Definition: alugrid/3d/datahandle.hh:231
EntityType & entity_
Definition: alugrid/3d/datahandle.hh:514
ImplTraits::template Codim< codim >::ImplementationType IMPLElementType
Definition: alugrid/3d/datahandle.hh:502
bool contains(int dim, int cd) const
returns contains of dc_
Definition: alugrid/3d/datahandle.hh:65
RealEntityType & realEntity_
Definition: alugrid/3d/datahandle.hh:41
const GridType & grid_
Definition: alugrid/3d/datahandle.hh:143
void inlineData(ObjectStreamType &str, HElementType &elem)
Definition: alugrid/3d/datahandle.hh:544
the corresponding interface class is defined in bsinclude.hh
Definition: alugrid/3d/datahandle.hh:24
ImplTraits::template Codim< codim >::InterfaceType HElementType
Definition: alugrid/3d/datahandle.hh:38
void recvData(ObjectStreamType &str, HGhostType &ghost)
read Data of one element from stream
Definition: alugrid/3d/datahandle.hh:241
MakeableEntityType::ImplementationType RealEntityType
Definition: alugrid/3d/datahandle.hh:147
int preCoarsening(HElementType &elem)
prolong data, elem is the father
Definition: alugrid/3d/datahandle.hh:767
RealEntityType & realEntity_
Definition: alugrid/3d/datahandle.hh:515
Dune::MakeableInterfaceObject< typename GridType::template Codim< 0 >::Entity > MakeableEntityType
Definition: alugrid/3d/datahandle.hh:146
void setData(ObjectStreamType &str, HElementType &elem)
Definition: alugrid/3d/datahandle.hh:74
void sendData(ObjectStreamType &str, const HElementType &elem)
write Data of one element to stream
Definition: alugrid/3d/datahandle.hh:205
virtual ~AdaptRestrictProlongGlSet()
Definition: alugrid/3d/datahandle.hh:694
GatherScatter::ObjectStreamType ObjectStreamType
Definition: alugrid/3d/datahandle.hh:522
DataCollectorType & dc_
Definition: alugrid/3d/datahandle.hh:518
DataCollectorType & dc_
Definition: alugrid/3d/datahandle.hh:43
Dune::MakeableInterfaceObject< typename GridType::template Codim< codim >::Entity > MakeableEntityType
Definition: alugrid/3d/datahandle.hh:31
ImplTraits::template Codim< 1 >::InterfaceType HFaceType
Definition: alugrid/3d/datahandle.hh:155
IndexOperatorType & idxOp_
Definition: alugrid/3d/datahandle.hh:519
Definition: objectfactory.hh:23
ghost entities
Definition: gridenums.hh:29
ImplTraits::template Codim< codim >::InterfaceType HElementType
Definition: alugrid/3d/datahandle.hh:153
Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits
Definition: alugrid/3d/datahandle.hh:151
GridType::MPICommunicatorType Comm
Definition: alugrid/3d/datahandle.hh:499
GridType::MPICommunicatorType Comm
Definition: alugrid/3d/datahandle.hh:149
Definition: alugrid/3d/datahandle.hh:493
Definition: alu3dinclude.hh:201
the corresponding interface class is defined in bsinclude.hh
Definition: alugrid/3d/datahandle.hh:490
Definition: alugrid/3d/datahandle.hh:707
MakeableEntityType::ImplementationType RealEntityType
Definition: alugrid/3d/datahandle.hh:32
bool contains(int dim, int codim) const
Definition: alugrid/3d/datahandle.hh:190
void sendData(ObjectStreamType &str, HElementType &elem)
write Data of one element to stream
Definition: alugrid/3d/datahandle.hh:91
const bool variableSize_
Definition: alugrid/3d/datahandle.hh:168
int preCoarsening(HElementType &father)
restrict data for elements
Definition: alugrid/3d/datahandle.hh:629
size_t getSize(ObjectStreamType &str, EntityType &en)
Definition: alugrid/3d/datahandle.hh:118
ImplTraits::template Codim< 1 >::InterfaceType HFaceType
Definition: alugrid/3d/datahandle.hh:505
ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType
Definition: alugrid/3d/datahandle.hh:508
RealEntityType & realEntity_
Definition: alugrid/3d/datahandle.hh:163
virtual bool containsItem(const HElementType &elem) const
Definition: alugrid/3d/datahandle.hh:196
virtual ~LoadBalanceElementCount()
Definition: alugrid/3d/datahandle.hh:750
ImplTraits::template Codim< codim >::ImplementationType ImplElementType
Definition: alugrid/3d/datahandle.hh:37
int postRefinement(HBndSegType &ghost)
prolong data for ghost elements
Definition: alugrid/3d/datahandle.hh:658
GridType::template Codim< 0 >::Entity EntityType
Definition: alugrid/3d/datahandle.hh:144
AdaptRestrictProlongImpl(GridType &grid, MakeableEntityType &f, RealEntityType &rf, MakeableEntityType &s, RealEntityType &rs, AdaptDataHandle &rp)
Constructor.
Definition: alugrid/3d/datahandle.hh:613
virtual ~AdaptRestrictProlongImpl()
Definition: alugrid/3d/datahandle.hh:625
GatherScatterBaseImpl(const GridType &grid, MakeableEntityType &en, RealEntityType &realEntity, DataCollectorType &dc)
Constructor.
Definition: alugrid/3d/datahandle.hh:183
virtual void setElement(const HElementType &elem)=0
void writeSize(ObjectStreamType &str, EntityType &en)
Definition: alugrid/3d/datahandle.hh:266
InterfaceType::Implementation ImplementationType
Definition: common/grid.hh:1377
size_t getSize(ObjectStreamType &str, EntityType &en)
Definition: alugrid/3d/datahandle.hh:253
ImplTraits::template Codim< codim >::ImplementationType ImplElementType
Definition: alugrid/3d/datahandle.hh:152
Dune::MakeableInterfaceObject< typename GridType::template Codim< 0 >::Entity > MakeableEntityType
Definition: alugrid/3d/datahandle.hh:496
MakeableEntityType::ImplementationType RealEntityType
Definition: alugrid/3d/datahandle.hh:497
GridType & grid_
Definition: alugrid/3d/datahandle.hh:512
const GridType & grid_
Definition: alugrid/3d/datahandle.hh:28
GatherScatter::ObjectStreamType ObjectStreamType
Definition: alugrid/3d/datahandle.hh:47
GatherScatterBaseImpl(const GridType &grid, MakeableEntityType &en, RealEntityType &realEntity, DataCollectorType &dc)
Constructor.
Definition: alugrid/3d/datahandle.hh:58
int postRefinement(HElementType &elem)
prolong data, elem is the father
Definition: alugrid/3d/datahandle.hh:697
const bool variableSize_
Definition: alugrid/3d/datahandle.hh:45
GatherScatterLoadBalance(GridType &grid, MakeableEntityType &en, RealEntityType &realEntity, DataCollectorType &dc, IndexOperatorType &idxOp)
Constructor.
Definition: alugrid/3d/datahandle.hh:529
AdaptRestrictProlongGlSet(GridType &grid, MakeableEntityType &f, RealEntityType &rf, MakeableEntityType &s, RealEntityType &rs, AdaptDataHandle &rp, GlobalIdSetImp &set)
Constructor.
Definition: alugrid/3d/datahandle.hh:685
Different resources needed by all grid implementations.
void xtractData(ObjectStreamType &str, HElementType &elem)
Definition: alugrid/3d/datahandle.hh:556
bool contains(int dim, int codim) const
Definition: alugrid/3d/datahandle.hh:536
Definition: alugrid/3d/datahandle.hh:664
EntityType & entity_
Definition: alugrid/3d/datahandle.hh:40
GridType::template Codim< 0 >::Entity EntityType
Definition: alugrid/3d/datahandle.hh:494
int newElements() const
Definition: alugrid/3d/datahandle.hh:788
GridType::template Codim< codim >::Entity EntityType
Definition: alugrid/3d/datahandle.hh:29
ImplTraits::PllElementType PllElementType
Definition: alugrid/3d/datahandle.hh:510
GridType::MPICommunicatorType Comm
Definition: alugrid/3d/datahandle.hh:34
int preCoarsening(HBndSegType &ghost)
restrict data for ghost elements
Definition: alugrid/3d/datahandle.hh:654
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
ImplTraits::template Codim< codim >::GhostInterfaceType HGhostType
Definition: alugrid/3d/datahandle.hh:157
ImplTraits::template Codim< codim >::InterfaceType HElementType
Definition: alugrid/3d/datahandle.hh:503
EntityType & entity_
Definition: alugrid/3d/datahandle.hh:162
int postRefinement(HElementType &elem)
restrict data , elem is always the father
Definition: alugrid/3d/datahandle.hh:753
void sendData(ObjectStreamType &str, const HGhostType &ghost)
write Data of one ghost element to stream
Definition: alugrid/3d/datahandle.hh:217
Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits
Definition: alugrid/3d/datahandle.hh:36
Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits
Definition: alugrid/3d/datahandle.hh:501
LoadBalanceElementCount(GridType &grid, MakeableEntityType &f, RealEntityType &rf, MakeableEntityType &s, RealEntityType &rs, DataHandleType &dh)
Constructor.
Definition: alugrid/3d/datahandle.hh:737
ImplTraits::template Codim< codim >::GhostImplementationType ImplGhostType
Definition: alugrid/3d/datahandle.hh:158
void compress()
call compress on data
Definition: alugrid/3d/datahandle.hh:573
int postRefinement(HElementType &father)
prolong data for elements
Definition: alugrid/3d/datahandle.hh:640
virtual bool containsItem(const HElementType &elem) const =0
DataCollectorType & dc_
Definition: alugrid/3d/datahandle.hh:166
void recvData(ObjectStreamType &str, HElementType &elem)
read Data of one element from stream
Definition: alugrid/3d/datahandle.hh:108
int preCoarsening(HBndSegType &el)
Definition: alugrid/3d/datahandle.hh:774