Dune Core Modules (2.9.0)

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