dune-fem 2.8.0
Loading...
Searching...
No Matches
adaptiveleafgridpart.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_ADAPTIVELEAFGRIDPART_HH
2#define DUNE_FEM_ADAPTIVELEAFGRIDPART_HH
3
4//- dune-grid includes
5#include <dune/grid/common/gridview.hh>
6
7//- dune-fem includes
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 /*- see dune/grid/common/gridenums.hh
22 enum InterfaceType {
23 InteriorBorder_InteriorBorder_Interface=0, //!< send/receive interior and border entities
24 InteriorBorder_All_Interface=1, //!< send interior and border, receive all entities
25 Overlap_OverlapFront_Interface=2, //!< send overlap, receive overlap and front entities
26 Overlap_All_Interface=3, //!< send overlap, receive all entities
27 All_All_Interface=4 //!< send all and receive all entities
28 };
29 enum PartitionIteratorType {
30 Interior_Partition=0, //!< only interior entities
31 InteriorBorder_Partition=1, //!< interior and border entities
32 Overlap_Partition=2, //!< only overlap entities
33 OverlapFront_Partition=3, //!< overlap and front entities
34 All_Partition=4, //!< all entities
35 Ghost_Partition=5 //!< only ghost entities
36 };
37 */
38
39 template <PartitionIteratorType ittype>
41 {
42 static const InterfaceType value = InteriorBorder_All_Interface;
43 };
44 template <>
45 struct IteratorToInterface< InteriorBorder_Partition >
46 {
47 static const InterfaceType value = InteriorBorder_InteriorBorder_Interface;
48 };
49
51 //
52 // --AdaptiveLeafIndexGridPart
53 //
55
63 template< class TraitsImp >
65 : public GridPartDefault< TraitsImp >
66 {
69
70 public:
72 typedef TraitsImp Traits;
73
75 typedef typename Traits :: GridPartType GridPartType;
77 typedef typename Traits :: GridType GridType;
79 typedef typename Traits :: IndexSetType IndexSetType;
80
82 template< int codim >
83 struct Codim
84 : public BaseType :: template Codim< codim >
85 {};
86
87 private:
88 typedef typename GridType::LeafGridView LeafGridView;
89
90 public:
92 typedef typename Traits::IntersectionIteratorType IntersectionIteratorType;
93
95 typedef typename IntersectionIteratorType::Intersection IntersectionType;
96
97 typedef std::integral_constant< bool, false > NoIndexSetType;
98
100
101 protected:
102 // key type for singleton list is grid pointer
103 typedef SingletonList < const GridType*, IndexSetType > IndexSetProviderType;
104
105 // type of entity with codimension zero
106 typedef typename Codim< 0 > :: EntityType ElementType;
107
108 // the leaf grid view
109 LeafGridView leafGridView_ ;
110
111 // reference to index set
112 std::unique_ptr< IndexSetType, typename IndexSetProviderType::Deleter > indexSet_;
113
114 using BaseType::grid_;
115
116 public:
119 : BaseType( grid ),
120 leafGridView_( grid.leafGridView() ),
121 indexSet_( &IndexSetProviderType::getObject( &grid ) )
122 {}
123
126 : BaseType( other ),
128 indexSet_( &IndexSetProviderType::getObject( &other.grid_ ) )
129 {}
130
131 protected:
134 : BaseType( grid ),
135 leafGridView_( grid.leafGridView() ),
136 indexSet_() // not created because noIndexSet was passed
137 {}
138
139 public:
140 using BaseType::grid;
141
143 const IndexSetType &indexSet () const
144 {
145 assert( indexSet_ );
146 return *indexSet_;
147 }
148
150 template< int codim >
151 typename Codim< codim > :: IteratorType
152 begin () const
153 {
154 return begin< codim, InteriorBorder_Partition >();
155 }
156
158 template< int codim, PartitionIteratorType pitype >
159 typename Codim< codim > :: template Partition< pitype > :: IteratorType
160 begin () const
161 {
162 return leafGridView_.template begin< codim, pitype >();
163 }
164
166 template< int codim >
167 typename Codim< codim > :: IteratorType
168 end () const
169 {
170 return end< codim, InteriorBorder_Partition >();
171 }
172
174 template< int codim, PartitionIteratorType pitype >
175 typename Codim< codim > :: template Partition< pitype > :: IteratorType
176 end () const
177 {
178 return leafGridView_.template end< codim, pitype >();
179 }
180
183 ibegin ( const ElementType &entity ) const
184 {
185 return leafGridView_.ibegin( entity );
186 }
187
190 iend ( const ElementType &entity ) const
191 {
192 return leafGridView_.iend( entity );
193 }
194
196 int level () const
197 {
198 return grid().maxLevel();
199 }
200
202 template< class DataHandle, class Data >
203 decltype( auto ) communicate ( CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir ) const
204 {
205 return leafGridView_.communicate( data, iftype, dir );
206 }
207
208 protected:
209 const GridPartType& asImp() const
210 {
211 return static_cast<const GridPartType &> (*this);
212 }
213
215 {
216 return static_cast<GridPartType &> (*this);
217 }
218 };
219
227 template< class Grid, PartitionIteratorType idxpitype = All_Partition, bool onlyCodimensionZero = false >
228 class AdaptiveLeafGridPart;
229
231 template< class Grid, PartitionIteratorType idxpitype , bool onlyCodimensionZero >
233 {
234 public:
236 typedef Grid GridType;
237
240
243
244 typedef typename GridType::CollectiveCommunication CollectiveCommunicationType;
245
246 protected:
247 // choose the AdaptiveIndexSet (based on the HierarchicIndexSet)
248 // to be revised
249 template < int dummy, bool onlyCodimZero >
251 {
252 static const PartitionIteratorType indexSetPartitionType = idxpitype;
255 };
256
257 template <int dummy>
258 struct AdaptiveLeafIndexSetChooser<dummy, true >
259 {
260 static const PartitionIteratorType indexSetPartitionType = idxpitype;
263 };
264
265 // also for Cartesian grids (e.g. YaspGrid) use adaptive leaf index set in parallel
266 typedef AdaptiveLeafIndexSetChooser<-1, onlyCodimensionZero > IndexSetChooserType;
267
268 public:
271
274
275 // type of intersection iterator
276 typedef typename GridType::LeafGridView::IntersectionIterator IntersectionIteratorType;
277
278 template< int codim >
279 struct Codim
280 {
281 typedef typename GridType::template Codim< codim >::Geometry GeometryType;
282 typedef typename GridType::template Codim< codim >::LocalGeometry LocalGeometryType;
283
284 typedef typename GridType::template Codim< codim >::Entity EntityType;
285 typedef typename GridType::template Codim< codim >::EntitySeed EntitySeedType;
286
287 template< PartitionIteratorType pitype >
289 {
291 };
292 };
293
295 static const bool conforming = Dune::Capabilities::isLeafwiseConforming< GridType > :: v;
296 };
297
298 template< class Grid, PartitionIteratorType idxpitype , bool onlyCodimensionZero >
300 : public AdaptiveGridPartBase< AdaptiveLeafGridPartTraits< Grid, idxpitype, onlyCodimensionZero > >
301 , public AddGridView< AdaptiveLeafGridPartTraits< Grid, idxpitype, onlyCodimensionZero > >
302 {
305 public:
306 typedef typename BaseType :: NoIndexSetType NoIndexSetType;
307 typedef typename BaseType :: GridType GridType;
308 typedef typename BaseType :: GridViewType GridViewType;
309 typedef typename BaseType :: GridPartType GridPartType;
312 : BaseType( grid )
313 , AddGridViewType( this )
314 {}
316 : BaseType( grid )
318 {}
319
322 : BaseType( grid, dummy )
323 // , AddGridViewType( this ) this is used for the IndexSet and translating to GV not needed
324 {}
325
327 AdaptiveLeafGridPart ( const AdaptiveLeafGridPart& other ) = default;
328
330 {}
331 };
332
340 template< class Grid, PartitionIteratorType idxpitype = All_Partition >
342
343
344 template< class Grid, PartitionIteratorType idxpitype = All_Partition >
346
354 template< class Grid, PartitionIteratorType idxpitype >
356 {
357 public:
360
363 };
364
372 template< class Grid, PartitionIteratorType idxpitype >
374 : public AdaptiveGridPartBase< IntersectionAdaptiveLeafGridPartTraits< Grid, idxpitype > >
375 {
377 public:
378 typedef typename BaseType :: NoIndexSetType NoIndexSetType;
379 typedef typename BaseType :: GridType GridType;
382 : BaseType( grid )
383 {
384 }
385
388 : BaseType( grid, noIndexSet )
389 {
390 }
391
394 };
395
396
397
398 // Capabilities
399 // ------------
400
401 namespace GridPartCapabilities
402 {
403
404 // Capabilities for AdaptiveLeafGridPart
405 // -------------------------------------
406
407 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
408 struct hasGrid< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
409 {
410 static const bool v = true;
411 };
412
413 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
414 struct hasSingleGeometryType< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
415 {
416 static const bool v = Dune::Capabilities::hasSingleGeometryType< Grid >::v;
417 static const unsigned int topologyId
418 = Dune::Capabilities::hasSingleGeometryType< Grid >::topologyId;
419 };
420
421 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
422 struct isCartesian< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
423 {
424 static const bool v = Dune::Capabilities::isCartesian< Grid >::v;
425 };
426
427 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero, int codim >
428 struct hasEntity< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero >, codim >
429 {
430 static const bool v = Dune::Capabilities::hasEntity< Grid, codim >::v;
431 };
432
433 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero, int codim >
434 struct canCommunicate< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero >, codim >
435 {
436 static const bool v = Dune::Capabilities::canCommunicate< Grid, codim >::v;
437 };
438
439 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
440 struct isConforming< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
441 {
442 static const bool v = Dune::Capabilities::isLeafwiseConforming< Grid >::v;
443 };
444
445
446 // Capabilities for DGAdaptiveLeafGridPart
447 // ---------------------------------------
448
449 template< class Grid, PartitionIteratorType idxpitype >
450 struct hasGrid< DGAdaptiveLeafGridPart< Grid, idxpitype > >
451 {
452 static const bool v = true;
453 };
454
455 template< class Grid, PartitionIteratorType idxpitype >
457 {
458 static const bool v = Dune::Capabilities::hasSingleGeometryType< Grid >::v;
459 static const unsigned int topologyId
460 = Dune::Capabilities::hasSingleGeometryType< Grid >::topologyId;
461 };
462
463 template< class Grid, PartitionIteratorType idxpitype >
464 struct isCartesian< DGAdaptiveLeafGridPart< Grid, idxpitype > >
465 {
466 static const bool v = Dune::Capabilities::isCartesian< Grid >::v;
467 };
468
469 template< class Grid, PartitionIteratorType idxpitype, int codim >
470 struct hasEntity< DGAdaptiveLeafGridPart< Grid, idxpitype >, codim >
471 {
472 static const bool v = Dune::Capabilities::hasEntity< Grid, codim >::v;
473 };
474
475 template< class Grid, PartitionIteratorType idxpitype, int codim >
476 struct canCommunicate< DGAdaptiveLeafGridPart< Grid, idxpitype >, codim >
477 {
478 static const bool v = Dune::Capabilities::canCommunicate< Grid, codim >::v;
479 };
480
481 template< class Grid, PartitionIteratorType idxpitype >
482 struct isConforming< DGAdaptiveLeafGridPart< Grid, idxpitype > >
483 {
484 static const bool v = Dune::Capabilities::isLeafwiseConforming< Grid >::v;
485 };
486
487
488 // Capbilities for IntersectionAdaptiveLeafGridPart
489 // ------------------------------------------------
490
491 template< class Grid, PartitionIteratorType idxpitype >
492 struct hasGrid< IntersectionAdaptiveLeafGridPart< Grid, idxpitype > >
493 {
494 static const bool v = true;
495 };
496
497 template< class Grid, PartitionIteratorType idxpitype >
499 {
500 static const bool v = Dune::Capabilities::hasSingleGeometryType< Grid >::v;
501 static const unsigned int topologyId
502 = Dune::Capabilities::hasSingleGeometryType< Grid >::topologyId;
503 };
504
505 template< class Grid, PartitionIteratorType idxpitype >
507 {
508 static const bool v = Dune::Capabilities::isCartesian< Grid >::v;
509 };
510
511 template< class Grid, PartitionIteratorType idxpitype, int codim >
512 struct hasEntity< IntersectionAdaptiveLeafGridPart< Grid, idxpitype >, codim >
513 {
514 static const bool v = Dune::Capabilities::hasEntity< Grid, codim >::v;
515 };
516
517 template< class Grid, PartitionIteratorType idxpitype, int codim >
518 struct canCommunicate< IntersectionAdaptiveLeafGridPart< Grid, idxpitype >, codim >
519 {
520 static const bool v = Dune::Capabilities::canCommunicate< Grid, codim >::v;
521 };
522
523 template< class Grid, PartitionIteratorType idxpitype >
525 {
526 static const bool v = Dune::Capabilities::isLeafwiseConforming< Grid >::v;
527 };
528
529 } // namespace GridPartCapabilities
530
531 } // namespace Fem
532
533} // namespace Dune
534
535#endif // #ifndef DUNE_FEM_ADAPTIVELEAFGRIDPART_HH
Definition: bindguard.hh:11
Definition: adaptiveleafgridpart.hh:41
static const InterfaceType value
Definition: adaptiveleafgridpart.hh:42
A grid part with an index set specially designed for adaptive calculations.
Definition: adaptiveleafgridpart.hh:66
SingletonList< const GridType *, IndexSetType > IndexSetProviderType
Definition: adaptiveleafgridpart.hh:103
Traits::GridType GridType
Grid implementation type.
Definition: adaptiveleafgridpart.hh:77
Traits::IndexSetType IndexSetType
The leaf index set of the grid implementation.
Definition: adaptiveleafgridpart.hh:79
Codim< codim >::template Partition< pitype >::IteratorType begin() const
Begin iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:160
std::integral_constant< bool, false > NoIndexSetType
Definition: adaptiveleafgridpart.hh:97
IntersectionIteratorType iend(const ElementType &entity) const
iend of corresponding intersection iterator for given entity
Definition: adaptiveleafgridpart.hh:190
GridPartType & asImp()
Definition: adaptiveleafgridpart.hh:214
IntersectionIteratorType ibegin(const ElementType &entity) const
ibegin of corresponding intersection iterator for given entity
Definition: adaptiveleafgridpart.hh:183
std::unique_ptr< IndexSetType, typename IndexSetProviderType::Deleter > indexSet_
Definition: adaptiveleafgridpart.hh:112
int level() const
Returns maxlevel of the grid.
Definition: adaptiveleafgridpart.hh:196
LeafGridView leafGridView_
Definition: adaptiveleafgridpart.hh:109
Codim< codim >::IteratorType begin() const
Begin iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:152
GridPart2GridViewImpl< GridPartType > GridViewType
Definition: adaptiveleafgridpart.hh:99
decltype(auto) communicate(CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for this grid part
Definition: adaptiveleafgridpart.hh:203
Codim< 0 >::EntityType ElementType
Definition: adaptiveleafgridpart.hh:106
AdaptiveGridPartBase(GridType &grid, const NoIndexSetType &noIndexSet)
Constructor constructing object held by index set (for iterator access)
Definition: adaptiveleafgridpart.hh:133
TraitsImp Traits
Type definitions.
Definition: adaptiveleafgridpart.hh:72
Codim< codim >::IteratorType end() const
Begin iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:168
const GridPartType & asImp() const
Definition: adaptiveleafgridpart.hh:209
AdaptiveGridPartBase(const ThisType &other)
Copy Constructor.
Definition: adaptiveleafgridpart.hh:125
Traits::GridPartType GridPartType
Grid implementation type.
Definition: adaptiveleafgridpart.hh:75
const IndexSetType & indexSet() const
Returns reference to index set of the underlying grid.
Definition: adaptiveleafgridpart.hh:143
AdaptiveGridPartBase(GridType &grid)
constructor
Definition: adaptiveleafgridpart.hh:118
Codim< codim >::template Partition< pitype >::IteratorType end() const
End iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:176
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: adaptiveleafgridpart.hh:95
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: adaptiveleafgridpart.hh:92
Struct providing types of the leaf iterators on codimension codim.
Definition: adaptiveleafgridpart.hh:85
Definition: adaptiveleafgridpart.hh:302
~AdaptiveLeafGridPart()
Definition: adaptiveleafgridpart.hh:329
BaseType::NoIndexSetType NoIndexSetType
Definition: adaptiveleafgridpart.hh:306
AdaptiveLeafGridPart(GridType &grid)
Constructor.
Definition: adaptiveleafgridpart.hh:311
AdaptiveLeafGridPart(const AdaptiveLeafGridPart &other)=default
copy constructor
BaseType::GridViewType GridViewType
Definition: adaptiveleafgridpart.hh:308
AdaptiveLeafGridPart(GridType &grid, const GridViewType *gridView)
Definition: adaptiveleafgridpart.hh:315
BaseType::GridType GridType
Definition: adaptiveleafgridpart.hh:307
BaseType::GridPartType GridPartType
Definition: adaptiveleafgridpart.hh:309
AdaptiveLeafGridPart(GridType &grid, const NoIndexSetType &dummy)
copy constructor (for construction from IndexSet, no public use)
Definition: adaptiveleafgridpart.hh:321
Type definitions for the LeafGridPart class.
Definition: adaptiveleafgridpart.hh:233
AdaptiveLeafGridPart< GridType, idxpitype, onlyCodimensionZero > GridPartType
type of the grid part , i.e. this type
Definition: adaptiveleafgridpart.hh:239
Grid GridType
type of the grid
Definition: adaptiveleafgridpart.hh:236
static const bool conforming
is true if grid on this view only has conforming intersections
Definition: adaptiveleafgridpart.hh:295
IndexSetChooserType::IndexSetType IndexSetType
type of the index set
Definition: adaptiveleafgridpart.hh:270
AdaptiveLeafIndexSetChooser<-1, onlyCodimensionZero > IndexSetChooserType
Definition: adaptiveleafgridpart.hh:266
GridType::CollectiveCommunication CollectiveCommunicationType
Definition: adaptiveleafgridpart.hh:244
static const InterfaceType indexSetInterfaceType
Definition: adaptiveleafgridpart.hh:273
GridType::LeafGridView::IntersectionIterator IntersectionIteratorType
Definition: adaptiveleafgridpart.hh:276
static const PartitionIteratorType indexSetPartitionType
Definition: adaptiveleafgridpart.hh:272
TwistUtility< GridType > TwistUtilityType
The type of the corresponding TwistUtility.
Definition: adaptiveleafgridpart.hh:242
AdaptiveLeafIndexSet< GridPartType > IndexSetType
Definition: adaptiveleafgridpart.hh:254
static const PartitionIteratorType indexSetPartitionType
Definition: adaptiveleafgridpart.hh:252
static const InterfaceType indexSetInterfaceType
Definition: adaptiveleafgridpart.hh:253
DGAdaptiveLeafIndexSet< GridPartType > IndexSetType
Definition: adaptiveleafgridpart.hh:262
Definition: adaptiveleafgridpart.hh:280
GridType::template Codim< codim >::Geometry GeometryType
Definition: adaptiveleafgridpart.hh:281
GridType::template Codim< codim >::EntitySeed EntitySeedType
Definition: adaptiveleafgridpart.hh:285
GridType::template Codim< codim >::LocalGeometry LocalGeometryType
Definition: adaptiveleafgridpart.hh:282
GridType::template Codim< codim >::Entity EntityType
Definition: adaptiveleafgridpart.hh:284
Definition: adaptiveleafgridpart.hh:289
GridType::template Codim< codim >::template Partition< pitype >::LeafIterator IteratorType
Definition: adaptiveleafgridpart.hh:290
A grid part with an index set specially designed for adaptive calculations including indices for inte...
Definition: adaptiveleafgridpart.hh:375
IntersectionAdaptiveLeafGridPart(const IntersectionAdaptiveLeafGridPart &other)=default
copy constructor
IntersectionAdaptiveLeafGridPart(GridType &grid, const NoIndexSetType &noIndexSet)
copy constructor (for construction from IndexSet, no public use)
Definition: adaptiveleafgridpart.hh:387
BaseType::GridType GridType
Definition: adaptiveleafgridpart.hh:379
IntersectionAdaptiveLeafGridPart(GridType &grid)
Constructor.
Definition: adaptiveleafgridpart.hh:381
BaseType::NoIndexSetType NoIndexSetType
Definition: adaptiveleafgridpart.hh:378
A grid part with an index set specially designed for adaptive calculations including indices for inte...
Definition: adaptiveleafgridpart.hh:356
IntersectionAdaptiveLeafGridPart< Grid, idxpitype > GridPartType
type of the grid part , i.e. this type
Definition: adaptiveleafgridpart.hh:359
IntersectionAdaptiveLeafIndexSet< GridPartType > IndexSetType
type of the index set
Definition: adaptiveleafgridpart.hh:362
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1345
Definition: adaptiveleafindexset.hh:1418
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1489
specialize with 'false' if grid part has no underlying dune grid (default=true)
Definition: gridpart/common/capabilities.hh:18
static const bool v
Definition: gridpart/common/capabilities.hh:19
specialize with 'true' for if the codimension 0 entity of the grid part has only one possible geometr...
Definition: gridpart/common/capabilities.hh:29
static const bool v
Definition: gridpart/common/capabilities.hh:30
static const unsigned int topologyId
Definition: gridpart/common/capabilities.hh:31
specialize with 'true' if the grid part is cartesian (default=false)
Definition: gridpart/common/capabilities.hh:40
static const bool v
Definition: gridpart/common/capabilities.hh:41
specialize with 'true' for all codims that a grid implements entities for (default=false)
Definition: gridpart/common/capabilities.hh:50
static const bool v
Definition: gridpart/common/capabilities.hh:51
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: gridpart/common/capabilities.hh:60
static const bool v
Definition: gridpart/common/capabilities.hh:61
specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: gridpart/common/capabilities.hh:70
static const bool v
Definition: gridpart/common/capabilities.hh:71
Default implementation for the GridPart classes.
Definition: gridpart.hh:299
GridType & grid_
Definition: gridpart.hh:326
Traits::template Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:362
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:342
Definition: gridpart.hh:419
Definition: gridpart2gridview.hh:69
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition: twistutility.hh:84
Singleton list for key/object pairs.
Definition: singletonlist.hh:53