dune-spgrid  2.7
grid.hh
Go to the documentation of this file.
1 #ifndef DUNE_SPGRID_GRID_HH
2 #define DUNE_SPGRID_GRID_HH
3 
4 #include <cstddef>
5 
6 #include <array>
7 #include <memory>
8 #include <utility>
9 
10 #include <dune/common/parallel/mpicommunication.hh>
11 
12 #include <dune/grid/albertagrid/geometryreference.hh>
13 #include <dune/grid/common/grid.hh>
14 #include <dune/grid/common/adaptcallback.hh>
15 
25 
26 namespace Dune
27 {
28 
29  // External Forward Declarations
30  // -----------------------------
31 
32  template< class Grid >
34 
35  namespace __SPGrid
36  {
37 
38  template< class, class >
39  class TreeIterator;
40 
41  } // namespace __SPGrid
42 
43 
44 
45  // Internal Forward Declarations
46  // -----------------------------
47 
48 #if HAVE_MPI
49  template< class ct, int dim, template< int > class Ref = SPIsotropicRefinement, class Comm = MPI_Comm >
50  class SPGrid;
51 #else
52  template< class ct, int dim, template< int > class Ref = SPIsotropicRefinement, class Comm = No_Comm >
53  class SPGrid;
54 #endif // #if !HAVE_MPI
55 
56 
57 
58  // SPGridFamily
59  // ------------
60 
61  template< class ct, int dim, template< int > class Ref, class Comm >
62  struct SPGridFamily
63  {
64  struct Traits
65  {
67 
72  typedef Ref< dim > Refinement;
73  typedef typename Refinement::Policy RefinementPolicy;
74 
76 
77  typedef Dune::Intersection< const Grid, SPIntersection< const Grid > > LevelIntersection;
79 
80  typedef Dune::IntersectionIterator< const Grid, SPIntersectionIterator< const Grid >, SPIntersection< const Grid > > LevelIntersectionIterator;
82 
83  typedef Dune::EntityIterator< 0, const Grid, SPHierarchicIterator< const Grid, 0 > > HierarchicIterator;
84 
87 
90  typedef unsigned long GlobalIdType;
91  typedef unsigned long LocalIdType;
92 
93  template< int codim >
94  struct Codim
95  {
96  typedef typename ReferenceCubeContainer::template Codim< codim >::ReferenceCube ReferenceCube;
97 
98  typedef Dune::Entity< codim, dim, const Grid, SPEntity > Entity;
99 
100  typedef Dune::EntitySeed< const Grid, SPEntitySeed< codim, const Grid > > EntitySeed;
101 
102  typedef SPLocalGeometry< dim - codim, dim, const Grid > LocalGeometryImpl;
103 
104  typedef Dune::Geometry< dim - codim, dim, const Grid, SPGeometry > Geometry;
105  typedef Dune::Geometry< dim - codim, dim, const Grid, LocalGeometryReference > LocalGeometry;
106 
107  template< PartitionIteratorType pitype >
108  struct Partition
109  {
110  typedef Dune::EntityIterator< codim, const Grid, SPPartitionIterator< codim, const Grid > > LevelIterator;
111  typedef Dune::EntityIterator< codim, const Grid, SPPartitionIterator< codim, const Grid > > LeafIterator;
112  };
113 
116  };
117 
118  typedef Dune::GridView< SPGridViewTraits< const Grid > > LevelGridView;
119  typedef Dune::GridView< SPGridViewTraits< const Grid > > LeafGridView;
120  };
121  };
122 
123 
124 
133  template< class ct, int dim, template< int > class Ref, class Comm >
134  class SPGrid
135  : public GridDefaultImplementation< dim, dim, ct, SPGridFamily< ct, dim, Ref, Comm > >
136  {
138  typedef GridDefaultImplementation< dim, dim, ct, SPGridFamily< ct, dim, Ref, Comm > > Base;
139 
140  friend struct BackupRestoreFacility< This >;
141  friend class SPIntersection< const This >;
142  friend class SPGridLevel< This >;
143 
144  template< class, class > friend class __SPGrid::TreeIterator;
145 
146  public:
148 
149  typedef typename GridFamily::Traits Traits;
150 
153  typedef typename Traits::Domain Domain;
154  typedef typename Traits::Mesh Mesh;
155  typedef typename Traits::Refinement Refinement;
157 
158  typedef typename ReferenceCube::ctype ctype;
159 
162 
164 
166  typedef typename Traits::LocalIdSet LocalIdSet;
167 
169 
170  template< int codim >
171  struct Codim
172  : Base::template Codim< codim >
173  {
174  typedef typename Traits::template Codim< codim >::ReferenceCube ReferenceCube;
175 
176  typedef typename Traits::template Codim< codim >::LocalGeometryImpl LocalGeometryImpl;
177  };
178 
179  typedef typename Base::LevelGridView LevelGridView;
180  typedef typename Base::LeafGridView LeafGridView;
181 
182  typedef typename LevelGridView::IndexSet LevelIndexSet;
183  typedef typename LeafGridView::IndexSet LeafIndexSet;
184 
186 
188 
191 
192  private:
193  typedef typename GridLevel::PartitionList PartitionList;
194 
195  typedef typename LevelGridView::Traits::GridViewImp LevelGridViewImpl;
196  typedef typename LeafGridView::Traits::GridViewImp LeafGridViewImpl;
197 
198  public:
199  SPGrid ( const Domain &domain, const MultiIndex &cells,
201 
202  SPGrid ( const Domain &domain, const MultiIndex &cells, const MultiIndex &overlap,
204 
205  SPGrid ( const GlobalVector &a, const GlobalVector &b, const MultiIndex &cells,
207 
208  SPGrid ( const GlobalVector &a, const GlobalVector &b, const MultiIndex &cells,
209  const MultiIndex &overlap,
211 
212  SPGrid ( const This & ) = delete;
213  SPGrid ( This &&other );
214 
215  const ReferenceCube &referenceCube () const
216  {
217  return refCubes_.get();
218  }
219 
220  template< int codim >
222  {
223  return refCubes_.template get< codim >();
224  }
225 
226  const Domain &domain () const { return domain_; }
227 
228  const MultiIndex &overlap () const { return overlap_; }
229 
230  int maxLevel () const
231  {
232  return leafLevel().level();
233  }
234 
235  int size ( const int level, const int codim ) const
236  {
237  return levelGridView( level ).size( codim );
238  }
239 
240  int size ( const int codim ) const
241  {
242  return leafGridView().size( codim );
243  }
244 
245  int size ( const int level, const GeometryType &type ) const
246  {
247  return levelGridView( level ).size( type );
248  }
249 
250  int size ( const GeometryType &type ) const
251  {
252  return leafGridView().size( type );
253  }
254 
255  LevelGridView levelGridView ( int level ) const
256  {
257  assert( (level >= 0) && (level <= maxLevel()) );
258  return levelGridViews_[ level ];
259  }
260 
261  LeafGridView leafGridView () const { return leafGridView_; }
262 
263  template< int codim, PartitionIteratorType pitype >
264  typename Traits::template Codim< codim >::template Partition< pitype >::LevelIterator
265  lbegin ( const int level, const unsigned int sweepDir = 0 ) const
266  {
267  const LevelGridView &view = levelGridView( level );
268  return view.impl().template begin< codim, pitype >( sweepDir );
269  }
270 
271  template< int codim, PartitionIteratorType pitype >
272  typename Traits::template Codim< codim >::template Partition< pitype >::LevelIterator
273  lend ( const int level, const unsigned int sweepDir = 0 ) const
274  {
275  const LevelGridView &view = levelGridView( level );
276  return view.impl().template end< codim, pitype >( sweepDir );
277  }
278 
279  template< int codim >
280  typename Traits::template Codim< codim >::LevelIterator
281  lbegin ( const int level, const unsigned int sweepDir = 0 ) const
282  {
283  const LevelGridView &view = levelGridView( level );
284  return view.impl().template begin< codim >( sweepDir );
285  }
286 
287  template< int codim >
288  typename Traits::template Codim< codim >::LevelIterator
289  lend ( const int level, const unsigned int sweepDir = 0 ) const
290  {
291  const LevelGridView &view = levelGridView( level );
292  return view.impl().template end< codim >( sweepDir );
293  }
294 
295  template< int codim, PartitionIteratorType pitype >
296  typename Traits::template Codim< codim >::template Partition< pitype >::LeafIterator
297  leafbegin ( const unsigned int sweepDir = 0 ) const
298  {
299  const LeafGridView &view = leafGridView();
300  return view.impl().template begin< codim, pitype >( sweepDir );
301  }
302 
303  template< int codim, PartitionIteratorType pitype >
304  typename Traits::template Codim< codim >::template Partition< pitype >::LeafIterator
305  leafend ( const unsigned int sweepDir = 0 ) const
306  {
307  const LeafGridView &view = leafGridView();
308  return view.impl().template end< codim, pitype >( sweepDir );
309  }
310 
311  template< int codim >
312  typename Traits::template Codim< codim >::LeafIterator
313  leafbegin ( const unsigned int sweepDir = 0 ) const
314  {
315  const LeafGridView &view = leafGridView();
316  return view.impl().template begin< codim >( sweepDir );
317  }
318 
319  template< int codim >
320  typename Traits::template Codim< codim >::LeafIterator
321  leafend ( const unsigned int sweepDir = 0 ) const
322  {
323  const LeafGridView &view = leafGridView();
324  return view.impl().template end< codim >( sweepDir );
325  }
326 
327  const GlobalIdSet &globalIdSet () const
328  {
329  return globalIdSet_;
330  }
331 
332  const LocalIdSet &localIdSet () const
333  {
334  return localIdSet_;
335  }
336 
337  const LevelIndexSet &levelIndexSet ( const int level ) const
338  {
339  return levelGridView( level ).indexSet();
340  }
341 
342  const LeafIndexSet &leafIndexSet () const
343  {
344  return leafGridView().indexSet();
345  }
346 
348  {
349  return hierarchicIndexSet_;
350  }
351 
352  bool mark ( const int refCount, const typename Codim< 0 >::Entity &e );
353  int getMark ( const typename Codim< 0 >::Entity &e ) const;
354 
355  bool preAdapt ();
356 
357  bool adapt ();
358 
359  template< class DataHandle >
360  bool adapt ( AdaptDataHandleInterface< This, DataHandle > &handle );
361 
362  void postAdapt ();
363 
364  void globalRefine ( const int refCount,
365  const RefinementPolicy &policy = RefinementPolicy() );
366 
367  template< class DataHandle >
368  void globalRefine ( const int refCount,
369  AdaptDataHandleInterface< This, DataHandle > &handle,
370  const RefinementPolicy &policy = RefinementPolicy() );
371 
372  int overlapSize ( const int level, const int codim ) const
373  {
374  return levelGridView( level ).overlapSize( codim );
375  }
376 
377  int overlapSize ( const int codim ) const
378  {
379  return leafGridView().overlapSize( codim );
380  }
381 
382  int ghostSize ( const int level, const int codim ) const
383  {
384  return levelGridView( level ).ghostSize( codim );
385  }
386 
387  int ghostSize ( const int codim ) const
388  {
389  return leafGridView().ghostSize( codim );
390  }
391 
392  template< class DataHandle, class Data >
394  communicate ( CommDataHandleIF< DataHandle, Data > &data,
395  InterfaceType interface, CommunicationDirection dir,
396  int level ) const
397  {
398  LevelGridView view = levelGridView( level );
399  return view.impl().communicate( data, interface, dir );
400  }
401 
402  template< class DataHandle, class Data >
404  communicate ( CommDataHandleIF< DataHandle, Data > &data,
405  InterfaceType interface, CommunicationDirection dir ) const
406  {
407  LeafGridView view = leafGridView();
408  return view.impl().communicate( data, interface, dir );
409  }
410 
411  const CollectiveCommunication &comm () const;
412 
413  template< class Seed >
414  typename Traits::template Codim< Seed::codimension >::Entity entity ( const Seed &seed ) const
415  {
416  typedef typename Traits::template Codim< Seed::codimension >::Entity Entity;
418  typename EntityImpl::EntityInfo entityInfo( gridLevel( seed.impl().level() ), seed.impl().id(), seed.impl().partitionNumber() );
419  return Entity( EntityImpl( std::move( entityInfo ) ) );
420  }
421 
422  template< int codim >
423  bool hasFather ( const Dune::Entity< codim, dimension, const This, SPEntity > &entity ) const
424  {
425  return ((entity.level() > 0) && entity.impl().entityInfo().hasFather());
426  }
427 
428  bool hasFather ( const Dune::Intersection< const This, SPIntersection< const This > > &intersection ) const
429  {
430  return ((intersection.impl().gridLevel().level() > 0) && intersection.impl().entityInfo().hasFather());
431  }
432 
433  template< int codim >
434  Dune::Entity< codim, dimension, const This, SPEntity >
435  father ( const Dune::Entity< codim, dimension, const This, SPEntity > &entity ) const
436  {
437  assert( hasFather( entity ) );
438  Dune::Entity< codim, dimension, const This, SPEntity > father( entity );
439  father.impl().entityInfo().up();
440  return std::move( father );
441  }
442 
443  Dune::Intersection< const This, SPIntersection< const This > >
444  father ( const Dune::Intersection< const This, SPIntersection< const This > > &intersection ) const
445  {
446  typedef SPIntersection< const This > IntersectionImpl;
447  typedef Dune::Intersection< const This, IntersectionImpl > Intersection;
448 
449  assert( hasFather( intersection ) );
450  typename IntersectionImpl::EntityInfo fatherInfo( intersection.impl().entityInfo() );
451  fatherInfo.up();
452  return Intersection( IntersectionImpl( std::move( fatherInfo ), intersection.indexInInside() ) );
453  }
454 
455  const GridLevel &gridLevel ( const int level ) const;
456  const GridLevel &leafLevel () const;
457 
458  std::size_t numBoundarySegments () const;
459 
460  private:
461  // note: this method ignores the last bit of the macroId
462  std::size_t boundaryIndex ( const MultiIndex &macroId,
463  const unsigned int partitionNumber,
464  const int face ) const;
465 
466  typename Codim< 1 >::LocalGeometry localFaceGeometry ( int face ) const
467  {
468  assert( (face >= 0) && (face < ReferenceCube::numFaces) );
469  return typename Codim< 1 >::LocalGeometry( *localFaceGeometry_[ face ] );
470  }
471 
472  void createLocalGeometries ();
473  void setupMacroGrid ();
474  void setupBoundaryIndices ();
475 
476  static CollectiveCommunication defaultCommunication ();
477 
478  Domain domain_;
479  Mesh globalMesh_;
480  MultiIndex overlap_;
481  ReferenceCubeContainer refCubes_;
482  std::vector< std::unique_ptr< GridLevel > > gridLevels_;
483  std::vector< LevelGridView > levelGridViews_;
484  LeafGridView leafGridView_;
485  HierarchicIndexSet hierarchicIndexSet_;
486  GlobalIdSet globalIdSet_;
487  LocalIdSet localIdSet_;
489  std::size_t boundarySize_;
490  std::vector< std::array< std::size_t, 2*dimension > > boundaryOffset_;
491  std::array< std::unique_ptr< const typename Codim< 1 >::LocalGeometryImpl >, ReferenceCube::numFaces > localFaceGeometry_;
492  };
493 
494 
495 
496  // Implementation of SPGrid
497  // ------------------------
498 
499  template< class ct, int dim, template< int > class Ref, class Comm >
501  ::SPGrid ( const Domain &domain, const MultiIndex &cells,
502  const CollectiveCommunication &comm )
503  : domain_( domain ),
504  globalMesh_( cells ),
505  overlap_( MultiIndex::zero() ),
506  leafGridView_( LeafGridViewImpl() ),
507  hierarchicIndexSet_( *this ),
508  comm_( comm )
509  {
510  createLocalGeometries();
511  setupMacroGrid();
512  }
513 
514 
515  template< class ct, int dim, template< int > class Ref, class Comm >
517  ::SPGrid ( const Domain &domain, const MultiIndex &cells, const MultiIndex &overlap,
518  const CollectiveCommunication &comm )
519  : domain_( domain ),
520  globalMesh_( cells ),
521  overlap_( overlap ),
522  leafGridView_( LeafGridViewImpl() ),
523  hierarchicIndexSet_( *this ),
524  comm_( comm )
525  {
526  createLocalGeometries();
527  setupMacroGrid();
528  }
529 
530 
531  template< class ct, int dim, template< int > class Ref, class Comm >
533  ::SPGrid ( const GlobalVector &a, const GlobalVector &b, const MultiIndex &cells,
534  const CollectiveCommunication &comm )
535  : domain_( a, b ),
536  globalMesh_( cells ),
537  overlap_( MultiIndex::zero() ),
538  leafGridView_( LeafGridViewImpl() ),
539  hierarchicIndexSet_( *this ),
540  comm_( comm )
541  {
542  createLocalGeometries();
543  setupMacroGrid();
544  }
545 
546 
547  template< class ct, int dim, template< int > class Ref, class Comm >
549  ::SPGrid ( const GlobalVector &a, const GlobalVector &b, const MultiIndex &cells,
550  const MultiIndex &overlap, const CollectiveCommunication &comm )
551  : domain_( a, b ),
552  globalMesh_( cells ),
553  overlap_( overlap ),
554  leafGridView_( LeafGridViewImpl() ),
555  hierarchicIndexSet_( *this ),
556  comm_( comm )
557  {
558  createLocalGeometries();
559  setupMacroGrid();
560  }
561 
562 
563  template< class ct, int dim, template< int > class Ref, class Comm >
565  : domain_( std::move( other.domain_ ) ),
566  globalMesh_( std::move( other.globalMesh_ ) ),
567  overlap_( std::move( other.overlap_ ) ),
568  leafGridView_( LeafGridViewImpl() ),
569  hierarchicIndexSet_( *this ),
570  comm_( std::move( other.comm_ ) )
571  {
572  createLocalGeometries();
573  setupMacroGrid();
574  }
575 
576 
577  template< class ct, int dim, template< int > class Ref, class Comm >
578  inline bool SPGrid< ct, dim, Ref, Comm >
579  ::mark ( const int refCount, const typename Codim< 0 >::Entity &e )
580  {
581  return false;
582  }
583 
584 
585  template< class ct, int dim, template< int > class Ref, class Comm >
587  ::getMark ( const typename Codim< 0 >::Entity &e ) const
588  {
589  return 0;
590  }
591 
592 
593  template< class ct, int dim, template< int > class Ref, class Comm >
595  {
596  return false;
597  }
598 
599 
600  template< class ct, int dim, template< int > class Ref, class Comm >
602  {
603  return false;
604  }
605 
606 
607  template< class ct, int dim, template< int > class Ref, class Comm >
608  template< class DataHandle >
609  inline bool SPGrid< ct, dim, Ref, Comm >
610  ::adapt ( AdaptDataHandleInterface< This, DataHandle > &handle )
611  {
612  return false;
613  }
614 
615 
616  template< class ct, int dim, template< int > class Ref, class Comm >
618  {}
619 
620 
621  template< class ct, int dim, template< int > class Ref, class Comm >
622  inline void SPGrid< ct, dim, Ref, Comm >
623  ::globalRefine ( const int refCount, const RefinementPolicy &policy )
624  {
625  for( int i = 0; i < refCount; ++i )
626  {
627  gridLevels_.emplace_back( new GridLevel( leafLevel(), policy ) );
628  levelGridViews_.push_back( LevelGridViewImpl( leafLevel() ) );
629  }
630  leafGridView_.impl().update( leafLevel() );
631  hierarchicIndexSet_.update();
632  }
633 
634 
635  template< class ct, int dim, template< int > class Ref, class Comm >
636  template< class DataHandle >
637  inline void SPGrid< ct, dim, Ref, Comm >
638  ::globalRefine ( const int refCount,
639  AdaptDataHandleInterface< This, DataHandle > &handle,
640  const RefinementPolicy &policy )
641  {
642  for( int i = 0; i < refCount; ++i )
643  {
644  const LevelGridView fatherView = levelGridView( maxLevel() );
645 
646  gridLevels_.emplace_back( new GridLevel( leafLevel(), policy ) );
647  levelGridViews_.push_back( LevelGridViewImpl( leafLevel() ) );
648 
649  hierarchicIndexSet_.update();
650  leafGridView_.impl().update( leafLevel() );
651 
652  handle.preAdapt( leafLevel().size() );
653  typedef typename Codim< 0 >::LevelIterator LevelIterator;
654  const LevelIterator end = fatherView.template end< 0 >();
655  for( LevelIterator it = fatherView.template begin< 0 >(); it != end; ++it )
656  handle.postRefinement( *it );
657  handle.postAdapt();
658  }
659  }
660 
661 
662  template< class ct, int dim, template< int > class Ref, class Comm >
665  {
666  return comm_;
667  }
668 
669 
670  template< class ct, int dim, template< int > class Ref, class Comm >
671  inline const typename SPGrid< ct, dim, Ref, Comm >::GridLevel &
672  SPGrid< ct, dim, Ref, Comm >::gridLevel ( const int level ) const
673  {
674  assert( (level >= 0) && (level < int( gridLevels_.size() )) );
675  return *gridLevels_[ level ];
676  }
677 
678 
679  template< class ct, int dim, template< int > class Ref, class Comm >
680  inline const typename SPGrid< ct, dim, Ref, Comm >::GridLevel &
682  {
683  assert( !gridLevels_.empty() );
684  return *gridLevels_.back();
685  }
686 
687 
688  template< class ct, int dim, template< int > class Ref, class Comm >
690  {
691  return boundarySize_;
692  }
693 
694 
695  // note: this method ignores the last bit of the macroId
696  template< class ct, int dim, template< int > class Ref, class Comm >
697  inline std::size_t SPGrid< ct, dim, Ref, Comm >
698  ::boundaryIndex ( const MultiIndex &macroId,
699  const unsigned int partitionNumber,
700  const int face ) const
701  {
702  assert( (face >= 0) && (face < 2*dimension) );
703 
704  const LevelGridView &macroView = levelGridView( 0 );
705  const GridLevel &gridLevel = macroView.impl().gridLevel();
706  const PartitionList &partitions = gridLevel.template partition< OverlapFront_Partition >();
707  const typename PartitionList::Partition &partition = partitions.partition( partitionNumber );
708 
709  std::size_t index = 0;
710  std::size_t factor = 1;
711  for( int i = 0; i < dimension; ++i )
712  {
713  if( i == face/2 )
714  continue;
715  // note: the OverlapFront_Partition is closed, i.e.,
716  // begin()[ i ] & 1 == end()[ i ] & 1 == 0.
717  const int k = (macroId[ i ] - partition.begin()[ i ]) >> 1;
718  const int w = (partition.end()[ i ] - partition.begin()[ i ]) >> 1;
719  assert( (k >= 0) && (k < w) );
720  index += std::size_t( k ) * factor;
721  factor *= std::size_t( w );
722  }
723  return index + boundaryOffset_[ partitionNumber - partitions.minNumber() ][ face ];
724  }
725 
726 
727  template< class ct, int dim, template< int > class Ref, class Comm >
728  inline void SPGrid< ct, dim, Ref, Comm >::createLocalGeometries ()
729  {
730  typedef typename Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
731 
732  const GlobalVector unitH( ctype( 1 ) );
733  for( int face = 0; face < ReferenceCube::numFaces; ++face )
734  {
735  MultiIndex id;
736  for( int i = 0; i < dimension; ++i )
737  id[ i ] = 1;
738  id += referenceCube().subId( 1, face );
739  const SPDirection< dimension > direction( id );
740  //const unsigned int direction = ((1 << dimension) - 1) ^ (1 << (face/2));
741  GlobalVector origin( ctype( 0 ) );
742  origin[ face/2 ] = ctype( face & 1 );
743  const SPGeometryCache< ctype, dimension, 1 > cache( unitH, direction );
744  localFaceGeometry_[ face ].reset( new LocalGeometryImpl( cache, origin ) );
745  }
746  }
747 
748 
749  template< class ct, int dim, template< int > class Ref, class Comm >
750  inline void SPGrid< ct, dim, Ref, Comm >::setupMacroGrid ()
751  {
752  SPDecomposition< dimension > decomposition( globalMesh_, comm().size() );
753 
754  GridLevel *leafLevel = new GridLevel( *this, decomposition );
755  gridLevels_.emplace_back( leafLevel );
756  levelGridViews_.push_back( LevelGridViewImpl( *leafLevel ) );
757  leafGridView_.impl().update( *leafLevel );
758  hierarchicIndexSet_.update();
759  setupBoundaryIndices();
760  }
761 
762 
763  template< class ct, int dim, template< int > class Ref, class Comm >
764  inline void SPGrid< ct, dim, Ref, Comm >::setupBoundaryIndices ()
765  {
766  const LevelGridView &macroView = levelGridView( 0 );
767  const GridLevel &gridLevel = macroView.impl().gridLevel();
768  const PartitionList &partitions = gridLevel.template partition< OverlapFront_Partition >();
769 
770  boundarySize_ = 0;
771  boundaryOffset_.resize( partitions.maxNumber() - partitions.minNumber() + 1 );
772  for( typename PartitionList::Iterator it = partitions.begin(); it; ++it )
773  {
774  const int partitionIndex = it->number() - partitions.minNumber();
775  for( int i = 0; i < dimension; ++i )
776  {
777  // note: the OverlapFront_Partition is closed, i.e.,
778  // begin()[ i ] & 1 == end()[ i ] & 1 == 0.
779  std::size_t size = 1;
780  for( int j = 0; j < dimension; ++j )
781  size *= (i == j ? 1 : std::size_t( (it->end()[ j ] - it->begin()[ j ]) >> 1 ));
782 
783  // offset for lower boundary
784  boundaryOffset_[ partitionIndex ][ 2*i ] = boundarySize_;
785  boundarySize_ += (it->boundary( 2*i ) ? size : 0);
786 
787  // offset for upper boundary
788  boundaryOffset_[ partitionIndex ][ 2*i+1 ] = boundarySize_;
789  boundarySize_ += (it->boundary( 2*i+1 ) ? size : 0);
790  }
791  }
792  }
793 
794 } // namespace Dune
795 
796 #endif // #ifndef DUNE_SPGRID_GRID_HH
capabilities for SPGrid
entity seed for SPGrid
Definition: iostream.hh:7
Definition: communication.hh:24
Dune::CollectiveCommunication< Comm > CollectiveCommunication
Definition: communication.hh:25
Definition: communication.hh:77
each element is split into 2dim children.
Definition: refinement.hh:453
structured, parallel DUNE grid
Definition: grid.hh:136
Traits::template Codim< codim >::LevelIterator lend(const int level, const unsigned int sweepDir=0) const
Definition: grid.hh:289
Traits::Mesh Mesh
Definition: grid.hh:154
void globalRefine(const int refCount, const RefinementPolicy &policy=RefinementPolicy())
Definition: grid.hh:623
int size(const GeometryType &type) const
Definition: grid.hh:250
bool preAdapt()
Definition: grid.hh:594
int overlapSize(const int level, const int codim) const
Definition: grid.hh:372
bool adapt()
Definition: grid.hh:601
SPGrid(const This &)=delete
GridLevel::MultiIndex MultiIndex
Definition: grid.hh:189
Traits::GlobalIdSet GlobalIdSet
Definition: grid.hh:165
int getMark(const typename Codim< 0 >::Entity &e) const
Definition: grid.hh:587
const ReferenceCube & referenceCube() const
Definition: grid.hh:215
const LevelIndexSet & levelIndexSet(const int level) const
Definition: grid.hh:337
Base::LeafGridView LeafGridView
Definition: grid.hh:180
const GridLevel & gridLevel(const int level) const
Definition: grid.hh:672
const Domain & domain() const
Definition: grid.hh:226
Traits::template Codim< codim >::LevelIterator lbegin(const int level, const unsigned int sweepDir=0) const
Definition: grid.hh:281
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin(const unsigned int sweepDir=0) const
Definition: grid.hh:297
const GridLevel & leafLevel() const
Definition: grid.hh:681
Traits::LocalIdSet LocalIdSet
Definition: grid.hh:166
LeafGridView leafGridView() const
Definition: grid.hh:261
static const int dimensionworld
Definition: grid.hh:161
Traits::RefinementPolicy RefinementPolicy
Definition: grid.hh:156
const MultiIndex & overlap() const
Definition: grid.hh:228
SPGridFamily< ct, dim, Ref, Comm > GridFamily
Definition: grid.hh:147
SPCommunication< This, CommDataHandleIF< DataHandle, Data > > communicate(CommDataHandleIF< DataHandle, Data > &data, InterfaceType interface, CommunicationDirection dir, int level) const
Definition: grid.hh:394
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafend(const unsigned int sweepDir=0) const
Definition: grid.hh:305
const Codim< codim >::ReferenceCube & referenceCube() const
Definition: grid.hh:221
int overlapSize(const int codim) const
Definition: grid.hh:377
int ghostSize(const int codim) const
Definition: grid.hh:387
int size(const int codim) const
Definition: grid.hh:240
Traits::Refinement Refinement
Definition: grid.hh:155
const LeafIndexSet & leafIndexSet() const
Definition: grid.hh:342
Dune::Intersection< const This, SPIntersection< const This > > father(const Dune::Intersection< const This, SPIntersection< const This > > &intersection) const
Definition: grid.hh:444
const CollectiveCommunication & comm() const
Definition: grid.hh:664
Traits::template Codim< codim >::LeafIterator leafend(const unsigned int sweepDir=0) const
Definition: grid.hh:321
Traits::CollectiveCommunication CollectiveCommunication
Definition: grid.hh:168
std::size_t numBoundarySegments() const
Definition: grid.hh:689
SPCommunication< This, CommDataHandleIF< DataHandle, Data > > communicate(CommDataHandleIF< DataHandle, Data > &data, InterfaceType interface, CommunicationDirection dir) const
Definition: grid.hh:404
ReferenceCube::ctype ctype
Definition: grid.hh:158
int size(const int level, const int codim) const
Definition: grid.hh:235
Base::LevelGridView LevelGridView
Definition: grid.hh:179
bool hasFather(const Dune::Entity< codim, dimension, const This, SPEntity > &entity) const
Definition: grid.hh:423
void postAdapt()
Definition: grid.hh:617
const LocalIdSet & localIdSet() const
Definition: grid.hh:332
LevelGridView levelGridView(int level) const
Definition: grid.hh:255
Traits::template Codim< Seed::codimension >::Entity entity(const Seed &seed) const
Definition: grid.hh:414
static const int dimension
Definition: grid.hh:160
int maxLevel() const
Definition: grid.hh:230
LeafGridView::IndexSet LeafIndexSet
Definition: grid.hh:183
const HierarchicIndexSet & hierarchicIndexSet() const
Definition: grid.hh:347
bool mark(const int refCount, const typename Codim< 0 >::Entity &e)
Definition: grid.hh:579
Traits::ReferenceCubeContainer ReferenceCubeContainer
Definition: grid.hh:151
const GlobalIdSet & globalIdSet() const
Definition: grid.hh:327
int ghostSize(const int level, const int codim) const
Definition: grid.hh:382
Traits::ReferenceCube ReferenceCube
Definition: grid.hh:152
static const int numDirections
Definition: grid.hh:190
LevelGridView::IndexSet LevelIndexSet
Definition: grid.hh:182
GridFamily::Traits Traits
Definition: grid.hh:149
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator lend(const int level, const unsigned int sweepDir=0) const
Definition: grid.hh:273
bool hasFather(const Dune::Intersection< const This, SPIntersection< const This > > &intersection) const
Definition: grid.hh:428
SPGridLevel< This > GridLevel
Definition: grid.hh:187
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator lbegin(const int level, const unsigned int sweepDir=0) const
Definition: grid.hh:265
Traits::Domain Domain
Definition: grid.hh:153
ReferenceCube::GlobalVector GlobalVector
Definition: grid.hh:163
Dune::Entity< codim, dimension, const This, SPEntity > father(const Dune::Entity< codim, dimension, const This, SPEntity > &entity) const
Definition: grid.hh:435
SPHierarchyIndexSet< const This > HierarchicIndexSet
Definition: grid.hh:185
SPGrid(const Domain &domain, const MultiIndex &cells, const CollectiveCommunication &comm=SPCommunicationTraits< Comm >::defaultComm())
Definition: grid.hh:501
Traits::template Codim< codim >::LeafIterator leafbegin(const unsigned int sweepDir=0) const
Definition: grid.hh:313
int size(const int level, const GeometryType &type) const
Definition: grid.hh:245
description of the computational domain
Definition: domain.hh:27
Definition: entity.hh:146
Definition: geometry.hh:87
Definition: geometry.hh:161
facility for writing and reading a SPGrid
Definition: grid.hh:33
Definition: grid.hh:39
Definition: grid.hh:63
Definition: grid.hh:65
Dune::GridView< SPGridViewTraits< const Grid > > LeafGridView
Definition: grid.hh:119
SPGrid< ct, dim, Ref, Comm > Grid
Definition: grid.hh:66
unsigned long LocalIdType
Definition: grid.hh:91
SPLocalIdSet< const Grid > LocalIdSet
Definition: grid.hh:89
SPReferenceCubeContainer< ct, dim > ReferenceCubeContainer
Definition: grid.hh:68
SPCommunicationTraits< Comm >::CollectiveCommunication CollectiveCommunication
Definition: grid.hh:75
Refinement::Policy RefinementPolicy
Definition: grid.hh:73
Ref< dim > Refinement
Definition: grid.hh:72
Dune::GridView< SPGridViewTraits< const Grid > > LevelGridView
Definition: grid.hh:118
SPDomain< ct, dim > Domain
Definition: grid.hh:70
LevelIntersection LeafIntersection
Definition: grid.hh:78
SPMesh< dim > Mesh
Definition: grid.hh:71
unsigned long GlobalIdType
Definition: grid.hh:90
SPGlobalIdSet< const Grid > GlobalIdSet
Definition: grid.hh:88
Dune::IntersectionIterator< const Grid, SPIntersectionIterator< const Grid >, SPIntersection< const Grid > > LevelIntersectionIterator
Definition: grid.hh:80
Dune::Intersection< const Grid, SPIntersection< const Grid > > LevelIntersection
Definition: grid.hh:77
Dune::EntityIterator< 0, const Grid, SPHierarchicIterator< const Grid, 0 > > HierarchicIterator
Definition: grid.hh:83
LevelIntersectionIterator LeafIntersectionIterator
Definition: grid.hh:81
LevelIndexSet LeafIndexSet
Definition: grid.hh:86
ReferenceCubeContainer::ReferenceCube ReferenceCube
Definition: grid.hh:69
SPIndexSet< const Grid > LevelIndexSet
Definition: grid.hh:85
Definition: grid.hh:95
Partition< All_Partition >::LeafIterator LeafIterator
Definition: grid.hh:115
Partition< All_Partition >::LevelIterator LevelIterator
Definition: grid.hh:114
Dune::EntitySeed< const Grid, SPEntitySeed< codim, const Grid > > EntitySeed
Definition: grid.hh:100
ReferenceCubeContainer::template Codim< codim >::ReferenceCube ReferenceCube
Definition: grid.hh:96
Dune::Geometry< dim - codim, dim, const Grid, SPGeometry > Geometry
Definition: grid.hh:104
SPLocalGeometry< dim - codim, dim, const Grid > LocalGeometryImpl
Definition: grid.hh:102
Dune::Entity< codim, dim, const Grid, SPEntity > Entity
Definition: grid.hh:98
Dune::Geometry< dim - codim, dim, const Grid, LocalGeometryReference > LocalGeometry
Definition: grid.hh:105
Dune::EntityIterator< codim, const Grid, SPPartitionIterator< codim, const Grid > > LeafIterator
Definition: grid.hh:111
Dune::EntityIterator< codim, const Grid, SPPartitionIterator< codim, const Grid > > LevelIterator
Definition: grid.hh:110
Definition: grid.hh:173
Traits::template Codim< codim >::ReferenceCube ReferenceCube
Definition: grid.hh:174
Traits::template Codim< codim >::LocalGeometryImpl LocalGeometryImpl
Definition: grid.hh:176
Definition: gridlevel.hh:35
static const unsigned int numDirections
Definition: gridlevel.hh:46
int level() const
Definition: gridlevel.hh:83
Definition: indexset.hh:19
Definition: idset.hh:20
Definition: idset.hh:160
Definition: intersection.hh:37
Definition: mesh.hh:21
Definition: referencecube.hh:43
static const int numFaces
Definition: referencecube.hh:55
FieldVector< ctype, dimension > GlobalVector
Definition: referencecube.hh:51
ct ctype
Definition: referencecube.hh:47
static const int dimension
Definition: referencecube.hh:49
Definition: referencecube.hh:189
const ReferenceCube & get() const
Definition: referencecube.hh:205