Dune Core Modules (2.3.1)

datahandle.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALU3DGRIDDATAHANDLE_HH
4#define DUNE_ALU3DGRIDDATAHANDLE_HH
5
6//- system includes
7#include <iostream>
8
11
12//- local includes
13#include "alu3dinclude.hh"
14
15using std::endl;
16using std::cout;
17using std::flush;
18
19namespace ALUGridSpace
20{
21
23 template <class GridType, class DataCollectorType, int codim >
25 : public GatherScatter
26 {
27 protected:
28 const GridType & grid_;
29 typedef typename GridType::template Codim<codim>::Entity EntityType;
30 typedef Dune :: MakeableInterfaceObject<
31 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
32 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
33
34 typedef typename GridType::MPICommunicatorType Comm;
35
36 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
37 typedef typename ImplTraits::template Codim< codim >::ImplementationType ImplElementType;
38 typedef typename ImplTraits::template Codim< codim >::InterfaceType HElementType;
39
40 EntityType & entity_;
41 RealEntityType & realEntity_;
42
43 DataCollectorType & dc_;
44
45 const bool variableSize_;
46
47 typedef typename GatherScatter :: ObjectStreamType ObjectStreamType;
48
49 typedef typename DataCollectorType:: DataType DataType;
50
51 using GatherScatter :: setData ;
52 using GatherScatter :: sendData ;
53 using GatherScatter :: recvData ;
54 using GatherScatter :: containsItem ;
55
56 public:
58 GatherScatterBaseImpl(const GridType & grid, MakeableEntityType & en,
59 RealEntityType & realEntity , DataCollectorType & dc)
60 : grid_(grid), entity_(en), realEntity_(realEntity) , dc_(dc)
61 , variableSize_( ! dc_.fixedsize(EntityType::dimension,codim) )
62 {}
63
65 bool contains(int dim, int cd) const { return dc_.contains(dim,cd); }
66
67 // returns true, if element is contained in set of comm interface
68 // this method must be overlaoded by the impl classes
69 virtual bool containsItem (const HElementType & elem) const = 0;
70
71 // set elem to realEntity
72 virtual void setElement(const HElementType & elem) = 0;
73
74 void setData ( ObjectStreamType & str , HElementType & elem )
75 {
76 // one of this should be either true
77 assert( this->containsItem( elem ) || elem.isGhost() );
78
79 // set element and then start
80 setElement(elem);
81
82 // make sure partition type is set correct
83 assert( elem.isGhost() == (entity_.partitionType() == Dune :: GhostEntity) );
84
85 size_t size = getSize(str, entity_);
86 // use normal scatter method
87 dc_.scatter(str,entity_, size );
88 }
89
91 void sendData ( ObjectStreamType & str , HElementType & elem )
92 {
93 // make sure element is contained in communication interface
94 //assert( this->containsItem( elem ) );
95 setElement(elem);
96
97 // if varaible size, also send size
98 if( variableSize_ )
99 {
100 size_t size = dc_.size( entity_ );
101 str.write( size );
102 }
103
104 dc_.gather(str, entity_ );
105 }
106
108 void recvData ( ObjectStreamType & str , HElementType & elem )
109 {
110 assert( this->containsItem( elem ) );
111 setElement( elem );
112
113 size_t size = getSize(str, entity_);
114 dc_.scatter(str,entity_, size );
115 }
116
117 protected:
118 size_t getSize(ObjectStreamType & str, EntityType & en)
119 {
120 if(variableSize_)
121 {
122 size_t size;
123 str.read(size);
124 return size;
125 }
126 else
127 return dc_.size(en);
128 }
129 };
130
131 //***********************************************************
132 //
133 // --specialisation for codim 0
134 //
135 //***********************************************************
136
138 template <class GridType, class DataCollectorType >
139 class GatherScatterBaseImpl<GridType,DataCollectorType,0> : public GatherScatter
140 {
141 protected:
142 enum { codim = 0 };
143 const GridType & grid_;
144 typedef typename GridType::template Codim<0>::Entity EntityType;
145 typedef Dune :: MakeableInterfaceObject<
146 typename GridType::template Codim<0>::Entity> MakeableEntityType;
147 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
148
149 typedef typename GridType::MPICommunicatorType Comm;
150
151 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
152 typedef typename ImplTraits::template Codim< codim >::ImplementationType ImplElementType;
153 typedef typename ImplTraits::template Codim< codim >::InterfaceType HElementType;
154
155 typedef typename ImplTraits::template Codim< 1 >::InterfaceType HFaceType;
156
157 typedef typename ImplTraits::template Codim< codim >::GhostInterfaceType HGhostType;
158 typedef typename ImplTraits::template Codim< codim >::GhostImplementationType ImplGhostType;
159
160 typedef typename ImplTraits::PllElementType PllElementType;
161
162 EntityType& entity_;
163 RealEntityType & realEntity_;
164
165 // data handle
166 DataCollectorType & dc_;
167
168 const bool variableSize_;
169
170 // used MessageBuffer
171 typedef typename GatherScatter :: ObjectStreamType ObjectStreamType;
172
173 // use all other containsItem from the base class
174 using GatherScatter :: setData ;
175 using GatherScatter :: sendData ;
176 using GatherScatter :: recvData ;
177
178 public:
179 // use all other containsItem from the base class
180 using GatherScatter :: containsItem ;
181
183 GatherScatterBaseImpl(const GridType & grid, MakeableEntityType & en,
184 RealEntityType & realEntity , DataCollectorType & dc)
185 : grid_(grid), entity_(en), realEntity_(realEntity)
186 , dc_(dc) , variableSize_ ( ! dc_.fixedsize( EntityType :: dimension, codim ))
187 {}
188
189 // return true if dim,codim combination is contained in data set
190 bool contains(int dim, int codim) const
191 {
192 return dc_.contains(dim,codim);
193 }
194
195 // return true if item might from entity belonging to data set
196 virtual bool containsItem (const HElementType & elem) const
197 {
198 return elem.isLeafEntity();
199 }
200
201 // return true if item might from entity belonging to data set
202 virtual bool containsItem (const HGhostType & ghost) const = 0;
203
205 void sendData ( ObjectStreamType & str , const HElementType & elem )
206 {
207 assert( this->containsItem(elem) );
208 realEntity_.setElement( const_cast<HElementType &> (elem) );
209
210 // write size in case of variable size
211 writeSize( str, entity_);
212 // gather data
213 dc_.gather(str, entity_);
214 }
215
217 void sendData ( ObjectStreamType & str , const HGhostType& ghost)
218 {
219 assert( this->containsItem( ghost ) );
220
221 // set ghost as entity
222 realEntity_.setGhost( const_cast <HGhostType &> (ghost) );
223
224 // write size in case of variable size
225 writeSize( str, entity_);
226 // gather data
227 dc_.gather(str, entity_);
228 }
229
231 void recvData ( ObjectStreamType & str , HElementType & elem )
232 {
233 // assert( this->containsItem( elem ) );
234 realEntity_.setElement( elem );
235
236 size_t size = getSize(str, entity_);
237 dc_.scatter(str, entity_, size);
238 }
239
241 void recvData ( ObjectStreamType & str , HGhostType & ghost )
242 {
243 assert( this->containsItem( ghost ) );
244
245 // set ghost as entity
246 realEntity_.setGhost( ghost );
247
248 size_t size = getSize(str , entity_ );
249 dc_.scatter(str, entity_, size );
250 }
251
252 protected:
253 size_t getSize(ObjectStreamType & str, EntityType & en)
254 {
255 if(variableSize_)
256 {
257 size_t size;
258 str.read(size);
259 return size;
260 }
261 else
262 return dc_.size(en);
263 }
264
265 // write variable size to stream
266 void writeSize(ObjectStreamType & str, EntityType & en)
267 {
268 if( variableSize_ )
269 {
270 size_t size = dc_.size( en );
271 str.write( size );
272 }
273 }
274 };
275
276#if ALU3DGRID_PARALLEL
278 template< class GridType, class DataCollectorType, int codim >
279 class GatherScatterLeafData
280 : public GatherScatterBaseImpl< GridType, DataCollectorType, codim >
281 {
282 enum { dim = GridType :: dimension };
283
284 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
285 typedef typename GridType::template Codim<codim>::Entity EntityType;
286 typedef Dune :: MakeableInterfaceObject<
287 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
288 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
289
290 typedef typename GridType::MPICommunicatorType Comm;
291
292 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
293 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
294 typedef typename ImplTraits::template Codim< codim >::InterfaceType HElementType;
295
296 typedef typename ImplTraits::template Codim< 1 >::InterfaceType HFaceType;
297
298 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
299 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
300
301 typedef typename ImplTraits::PllElementType PllElementType;
302
303 public:
304 // use all other containsItem methods from the base class
305 using BaseType :: containsItem ;
306
308 GatherScatterLeafData(const GridType & grid, MakeableEntityType & en,
309 RealEntityType & realEntity , DataCollectorType & dc)
310 : BaseType(grid,en,realEntity,dc)
311 {
312 // if leaf vertices are communicated,
313 // make sure that vertex list is up2date
314 // but only do this, if vertex data contained,
315 // because the list update is expensive
316 if( (codim == 3) && dc.contains(dim,codim) )
317 {
318 // call of this method forces update of list,
319 // if list is not up to date
320 grid.getLeafVertexList();
321 }
322 }
323
324 // returns true, if element is contained in set of comm interface
325 bool containsItem (const HElementType & elem) const
326 {
327 return elem.isLeafEntity();
328 }
329
330 // returns true, if element is contained in set of comm interface
331 bool containsItem (const HGhostType & ghost) const
332 {
333 return ghost.isLeafEntity();
334 }
335
336 // returns true, if interior element is contained in set of comm interface
337 bool containsInterior (const HFaceType & face, PllElementType & pll) const
338 {
339 return face.isInteriorLeaf();
340 }
341
342 // returns true, if ghost is contianed in set of comm interface
343 bool containsGhost (const HFaceType & face , PllElementType & pll) const
344 {
345 return pll.ghostLeaf();
346 }
347
348 // set elem to realEntity
349 void setElement(const HElementType & elem)
350 {
351 this->realEntity_.setElement(elem);
352 }
353 };
354
356 template <class GridType, class DataCollectorType , int codim >
357 class GatherScatterLevelData
358 : public GatherScatterBaseImpl<GridType,DataCollectorType,codim>
359 {
360 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
361 typedef typename GridType::template Codim<codim>::Entity EntityType;
362 typedef Dune :: MakeableInterfaceObject<
363 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
364 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
365
366 typedef typename GridType::MPICommunicatorType Comm;
367
368 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
369 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
370 typedef typename ImplTraits::template Codim< codim >::InterfaceType HElementType;
371
372 typedef typename ImplTraits::template Codim< 1 >::InterfaceType HFaceType;
373
374 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
375 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
376
377 typedef typename ImplTraits::PllElementType PllElementType;
378
379 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
380
381 const LevelIndexSetImp & levelSet_;
382 const int level_;
383 public:
384 // use containsItem for ghost element from BaseType
385 using BaseType :: containsItem ;
386
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)
392 {}
393
394 // returns true, if element is contained in set of comm interface
395 bool containsItem (const HElementType & elem) const
396 {
397 return levelSet_.containsIndex(codim, elem.getIndex() );
398 }
399
400 // set elem to realEntity
401 void setElement(const HElementType & elem)
402 {
403 this->realEntity_.setElement(elem,level_);
404 }
405
406 };
407
408
410 template <class GridType, class DataCollectorType>
411 class GatherScatterLevelData<GridType,DataCollectorType,0>
412 : public GatherScatterBaseImpl<GridType,DataCollectorType,0>
413 {
414 enum { codim = 0 };
415 typedef GatherScatterBaseImpl<GridType,DataCollectorType,codim> BaseType;
416 typedef typename GridType::template Codim<codim>::Entity EntityType;
417 typedef Dune :: MakeableInterfaceObject<
418 typename GridType::template Codim<codim>::Entity> MakeableEntityType;
419 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
420
421 typedef typename GridType::MPICommunicatorType Comm;
422
423 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
424 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
425 typedef typename ImplTraits::template Codim< codim >::InterfaceType HElementType;
426
427 typedef typename ImplTraits::template Codim< 1 >::InterfaceType HFaceType;
428
429 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
430 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
431
432 typedef typename ImplTraits::PllElementType PllElementType;
433
434 typedef typename GridType::LevelIndexSetImp LevelIndexSetImp;
435
436 const LevelIndexSetImp & levelSet_;
437 const int level_;
438 public:
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) {}
444
445 // returns true, if element is contained in set of comm interface
446 bool containsItem (const HElementType & elem) const
447 {
448 return levelSet_.containsIndex(codim, elem.getIndex() );
449 }
450
451 // returns true, if element is contained in set of comm interface
452 bool containsItem (const HGhostType & ghost) const
453 {
454 assert( ghost.getGhost().first );
455 return containsItem( * (ghost.getGhost().first) );
456 }
457
458 // returns true, if interior element is contained in set of comm interface
459 bool containsInterior (const HFaceType & face, PllElementType & pll) const
460 {
461 // if face level is not level_ then interior cannot be contained
462 if(face.level() != level_) return false;
463
464 typedef Gitter::helement_STI HElementType;
465 typedef Gitter::hbndseg_STI HBndSegType;
466
467 // check interior element here, might have a coarser level
468 pair< HElementType *, HBndSegType * > p( (HElementType *)0, (HBndSegType *)0 );
469 pll.getAttachedElement( p );
470 assert( p.first );
471 // check inside level
472 bool contained = (p.first->level() == level_);
473 assert( contained == this->containsItem( *p.first ));
474 return contained;
475 }
476
477 // returns true, if ghost is contianed in set of comm interface
478 bool containsGhost (const HFaceType & face, PllElementType & pll) const
479 {
480 // if face level is not level_ then ghost cannot be contained
481 if(face.level() != level_) return false;
482 // otherwise check ghost level
483 return (pll.ghostLevel() == level_);
484 }
485 };
486#endif // #if ALU3DGRID_PARALLEL
487
489 template <class GridType, class DataCollectorType, class IndexOperatorType>
490 class GatherScatterLoadBalance : public GatherScatter
491 {
492 protected:
493 enum { codim = 0 };
494 typedef typename GridType::template Codim<0>::Entity EntityType;
495 typedef Dune :: MakeableInterfaceObject<
496 typename GridType::template Codim<0>::Entity> MakeableEntityType;
497 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
498
499 typedef typename GridType::MPICommunicatorType Comm;
500
501 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
502 typedef typename ImplTraits::template Codim< codim >::ImplementationType IMPLElementType;
503 typedef typename ImplTraits::template Codim< codim >::InterfaceType HElementType;
504
505 typedef typename ImplTraits::template Codim< 1 >::InterfaceType HFaceType;
506
507 typedef typename ImplTraits::template Codim< 0 >::GhostInterfaceType HGhostType;
508 typedef typename ImplTraits::template Codim< 0 >::GhostImplementationType ImplGhostType;
509
510 typedef typename ImplTraits::PllElementType PllElementType;
511
512 GridType & grid_;
513
514 EntityType & entity_;
515 RealEntityType & realEntity_;
516
517 // data handle
518 DataCollectorType & dc_;
519 IndexOperatorType & idxOp_;
520
521 // used MessageBuffer
522 typedef typename GatherScatter :: ObjectStreamType ObjectStreamType;
523
524 using GatherScatter :: inlineData ;
525 using GatherScatter :: xtractData ;
526
527 public:
529 GatherScatterLoadBalance(GridType & grid, MakeableEntityType & en,
530 RealEntityType & realEntity , DataCollectorType & dc, IndexOperatorType & idxOp )
531 : grid_(grid), entity_(en), realEntity_(realEntity)
532 , dc_(dc) , idxOp_(idxOp)
533 {}
534
535 // return true if dim,codim combination is contained in data set
536 bool contains(int dim, int codim) const
537 {
538 return true;
539 }
540
544 void inlineData ( ObjectStreamType & str , HElementType & elem )
545 {
546 str.write(grid_.maxLevel());
547 // set element and then start
548 assert( elem.level () == 0 );
549 realEntity_.setElement(elem);
550 dc_.inlineData(str,entity_);
551 }
552
556 void xtractData ( ObjectStreamType & str , HElementType & elem )
557 {
558 assert( elem.level () == 0 );
559 int mxl;
560 str.read(mxl);
561 // set element and then start
562 grid_.setMaxLevel(mxl);
563
564 // reserve memory for new elements
565 size_t elChunk = idxOp_.newElements();
566 assert( elChunk > 0 );
567
568 realEntity_.setElement(elem);
569 dc_.xtractData(str,entity_, elChunk);
570 }
571
573 void compress ()
574 {
575 dc_.compress();
576 }
577 };
578
580 //
581 // --AdaptRestrictProlong
582 //
584 template< class GridType, class AdaptDataHandle >
585 class AdaptRestrictProlongImpl
586 : public AdaptRestrictProlongType
587 {
588 GridType & grid_;
589 typedef typename GridType::template Codim<0>::Entity EntityType;
590 typedef Dune :: MakeableInterfaceObject<
591 typename GridType::template Codim<0>::Entity> MakeableEntityType;
592 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
593
594 EntityType & reFather_;
595 EntityType & reSon_;
596 RealEntityType & realFather_;
597 RealEntityType & realSon_;
598
599 AdaptDataHandle &rp_;
600
601 typedef typename GridType::MPICommunicatorType Comm;
602
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;
607
608 //using AdaptRestrictProlongType :: postRefinement ;
609 //using AdaptRestrictProlongType :: preCoarsening ;
610
611 public:
613 AdaptRestrictProlongImpl ( GridType &grid,
614 MakeableEntityType &f, RealEntityType &rf,
615 MakeableEntityType &s, RealEntityType &rs,
616 AdaptDataHandle &rp )
617 : grid_(grid)
618 , reFather_(f)
619 , reSon_(s)
620 , realFather_(rf)
621 , realSon_(rs)
622 , rp_(rp)
623 {}
624
625 virtual ~AdaptRestrictProlongImpl ()
626 {}
627
629 int preCoarsening ( HElementType & father )
630 {
631 realFather_.setElement( father );
632 rp_.preCoarsening( reFather_ );
633
634 // reset refinement marker
635 father.resetRefinedTag();
636 return 0;
637 }
638
640 int postRefinement ( HElementType & father )
641 {
642 realFather_.setElement( father );
643 rp_.postRefinement( reFather_ );
644
645 // resert refinement markers
646 father.resetRefinedTag();
647 for( HElementType *son = father.down(); son ; son = son->next() )
648 son->resetRefinedTag();
649
650 return 0;
651 }
652
654 int preCoarsening ( HBndSegType & ghost ) { return 0; }
655
656
658 int postRefinement ( HBndSegType & ghost ) { return 0; }
659 };
660
661
662
663 template< class GridType, class AdaptDataHandle, class GlobalIdSetImp >
664 class AdaptRestrictProlongGlSet
665 : public AdaptRestrictProlongImpl< GridType, AdaptDataHandle >
666 {
667 typedef AdaptRestrictProlongImpl< GridType, AdaptDataHandle > BaseType;
668 GlobalIdSetImp & set_;
669 typedef typename GridType::template Codim<0>::Entity EntityType;
670 typedef Dune :: MakeableInterfaceObject<
671 typename GridType::template Codim<0>::Entity> MakeableEntityType;
672 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
673
674 typedef typename GridType::MPICommunicatorType Comm;
675
676 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
677 typedef typename ImplTraits::HElementType HElementType;
678 typedef typename ImplTraits::HBndSegType HBndSegType;
679
680 using AdaptRestrictProlongType :: postRefinement ;
681 using AdaptRestrictProlongType :: preCoarsening ;
682
683 public:
685 AdaptRestrictProlongGlSet ( GridType &grid,
686 MakeableEntityType &f, RealEntityType &rf,
687 MakeableEntityType &s, RealEntityType &rs,
688 AdaptDataHandle &rp,
689 GlobalIdSetImp & set )
690 : BaseType( grid, f, rf, s, rs, rp ),
691 set_( set )
692 {}
693
694 virtual ~AdaptRestrictProlongGlSet () {}
695
697 int postRefinement ( HElementType & elem )
698 {
699 set_.postRefinement( elem );
700 return BaseType :: postRefinement(elem );
701 }
702 };
703
704 // this class is for counting the tree depth of the
705 // element when unpacking data from load balance
706 template <class GridType , class DataHandleType>
707 class LoadBalanceElementCount : public AdaptRestrictProlongType
708 {
709 GridType & grid_;
710 typedef typename GridType::template Codim<0>::Entity EntityType;
711 typedef Dune :: MakeableInterfaceObject<
712 typename GridType::template Codim<0>::Entity> MakeableEntityType;
713 typedef typename MakeableEntityType :: ImplementationType RealEntityType;
714
715 typedef typename GridType::Traits::LeafIndexSet LeafIndexSetType;
716
717 EntityType & reFather_;
718 EntityType & reSon_;
719 RealEntityType & realFather_;
720 RealEntityType & realSon_;
721
722 DataHandleType & dh_;
723
724 typedef typename GridType::MPICommunicatorType Comm;
725
726 typedef Dune::ALU3dImplTraits< GridType::elementType, Comm > ImplTraits;
727 typedef typename ImplTraits::HElementType HElementType;
728 typedef typename ImplTraits::HBndSegType HBndSegType;
729
730 int newMemSize_;
731
732 using AdaptRestrictProlongType :: postRefinement ;
733 using AdaptRestrictProlongType :: preCoarsening ;
734
735 public:
737 LoadBalanceElementCount (GridType & grid,
738 MakeableEntityType & f, RealEntityType & rf,
739 MakeableEntityType & s, RealEntityType & rs,
740 DataHandleType & dh)
741 : grid_(grid)
742 , reFather_(f)
743 , reSon_(s)
744 , realFather_(rf)
745 , realSon_(rs)
746 , dh_(dh)
747 , newMemSize_ (1) // we have at least one element (the macro element)
748 {}
749
750 virtual ~LoadBalanceElementCount () {}
751
753 int postRefinement ( HElementType & elem )
754 {
755 // when called for a macro element, then a new tree is starting
756 // set to 1 because for only macro elements this method is not called
757 if( elem.level() == 0 ) newMemSize_ = 1;
758
759 for( HElementType * son = elem.down() ; son ; son= son->next())
760 {
761 ++ newMemSize_;
762 }
763 return 0;
764 }
765
767 int preCoarsening ( HElementType & elem )
768 {
769 return 0;
770 }
771
774 int preCoarsening ( HBndSegType & el )
775 {
776 return 0;
777 }
778
783 int postRefinement ( HBndSegType & el )
784 {
785 return 0;
786 }
787
788 int newElements () const { return newMemSize_; }
789 };
790
791} // end namespace ALUGridSpace
792
793#endif // #ifndef DUNE_ALU3DGRIDDATAHANDLE_HH
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and ALUGrid
void sendData(ObjectStreamType &str, const HElementType &elem)
write Data of one element to stream
Definition: datahandle.hh:205
void recvData(ObjectStreamType &str, HGhostType &ghost)
read Data of one element from stream
Definition: datahandle.hh:241
GatherScatterBaseImpl(const GridType &grid, MakeableEntityType &en, RealEntityType &realEntity, DataCollectorType &dc)
Constructor.
Definition: datahandle.hh:183
void sendData(ObjectStreamType &str, const HGhostType &ghost)
write Data of one ghost element to stream
Definition: datahandle.hh:217
void recvData(ObjectStreamType &str, HElementType &elem)
read Data of one element from stream
Definition: datahandle.hh:231
the corresponding interface class is defined in bsinclude.hh
Definition: datahandle.hh:26
GatherScatterBaseImpl(const GridType &grid, MakeableEntityType &en, RealEntityType &realEntity, DataCollectorType &dc)
Constructor.
Definition: datahandle.hh:58
bool contains(int dim, int cd) const
returns contains of dc_
Definition: datahandle.hh:65
void recvData(ObjectStreamType &str, HElementType &elem)
read Data of one element from stream
Definition: datahandle.hh:108
void sendData(ObjectStreamType &str, HElementType &elem)
write Data of one element to stream
Definition: datahandle.hh:91
the corresponding interface class is defined in bsinclude.hh
Definition: datahandle.hh:491
void xtractData(ObjectStreamType &str, HElementType &elem)
Definition: datahandle.hh:556
GatherScatterLoadBalance(GridType &grid, MakeableEntityType &en, RealEntityType &realEntity, DataCollectorType &dc, IndexOperatorType &idxOp)
Constructor.
Definition: datahandle.hh:529
void inlineData(ObjectStreamType &str, HElementType &elem)
Definition: datahandle.hh:544
void compress()
call compress on data
Definition: datahandle.hh:573
Different resources needed by all grid implementations.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)