dune-fem 2.8-git
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
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:
311 : BaseType( grid )
312 , AddGridViewType( this )
313 {}
315 : BaseType( grid )
317 {}
318
321 : BaseType( grid, dummy )
322 // , AddGridViewType( this ) this is used for the IndexSet and translating to GV not needed
323 {}
324
326 AdaptiveLeafGridPart ( const AdaptiveLeafGridPart& other ) = default;
327
329 {}
330 };
331
339 template< class Grid, PartitionIteratorType idxpitype = All_Partition >
341
342
343 template< class Grid, PartitionIteratorType idxpitype = All_Partition >
345
353 template< class Grid, PartitionIteratorType idxpitype >
355 {
356 public:
359
362 };
363
371 template< class Grid, PartitionIteratorType idxpitype >
373 : public AdaptiveGridPartBase< IntersectionAdaptiveLeafGridPartTraits< Grid, idxpitype > >
374 {
376 public:
381 : BaseType( grid )
382 {
383 }
384
387 : BaseType( grid, noIndexSet )
388 {
389 }
390
393 };
394
395
396
397 // Capabilities
398 // ------------
399
400 namespace GridPartCapabilities
401 {
402
403 // Capabilities for AdaptiveLeafGridPart
404 // -------------------------------------
405
406 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
407 struct hasGrid< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
408 {
409 static const bool v = true;
410 };
411
412 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
413 struct hasSingleGeometryType< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
414 {
415 static const bool v = Dune::Capabilities::hasSingleGeometryType< Grid >::v;
416 static const unsigned int topologyId
417 = Dune::Capabilities::hasSingleGeometryType< Grid >::topologyId;
418 };
419
420 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
421 struct isCartesian< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
422 {
423 static const bool v = Dune::Capabilities::isCartesian< Grid >::v;
424 };
425
426 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero, int codim >
427 struct hasEntity< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero >, codim >
428 {
429 static const bool v = Dune::Capabilities::hasEntity< Grid, codim >::v;
430 };
431
432 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero, int codim >
433 struct canCommunicate< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero >, codim >
434 {
435 static const bool v = Dune::Capabilities::canCommunicate< Grid, codim >::v;
436 };
437
438 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
439 struct isConforming< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
440 {
441 static const bool v = Dune::Capabilities::isLeafwiseConforming< Grid >::v;
442 };
443
444
445 // Capabilities for DGAdaptiveLeafGridPart
446 // ---------------------------------------
447
448 template< class Grid, PartitionIteratorType idxpitype >
449 struct hasGrid< DGAdaptiveLeafGridPart< Grid, idxpitype > >
450 {
451 static const bool v = true;
452 };
453
454 template< class Grid, PartitionIteratorType idxpitype >
456 {
457 static const bool v = Dune::Capabilities::hasSingleGeometryType< Grid >::v;
458 static const unsigned int topologyId
459 = Dune::Capabilities::hasSingleGeometryType< Grid >::topologyId;
460 };
461
462 template< class Grid, PartitionIteratorType idxpitype >
463 struct isCartesian< DGAdaptiveLeafGridPart< Grid, idxpitype > >
464 {
465 static const bool v = Dune::Capabilities::isCartesian< Grid >::v;
466 };
467
468 template< class Grid, PartitionIteratorType idxpitype, int codim >
469 struct hasEntity< DGAdaptiveLeafGridPart< Grid, idxpitype >, codim >
470 {
471 static const bool v = Dune::Capabilities::hasEntity< Grid, codim >::v;
472 };
473
474 template< class Grid, PartitionIteratorType idxpitype, int codim >
475 struct canCommunicate< DGAdaptiveLeafGridPart< Grid, idxpitype >, codim >
476 {
477 static const bool v = Dune::Capabilities::canCommunicate< Grid, codim >::v;
478 };
479
480 template< class Grid, PartitionIteratorType idxpitype >
481 struct isConforming< DGAdaptiveLeafGridPart< Grid, idxpitype > >
482 {
483 static const bool v = Dune::Capabilities::isLeafwiseConforming< Grid >::v;
484 };
485
486
487 // Capbilities for IntersectionAdaptiveLeafGridPart
488 // ------------------------------------------------
489
490 template< class Grid, PartitionIteratorType idxpitype >
491 struct hasGrid< IntersectionAdaptiveLeafGridPart< Grid, idxpitype > >
492 {
493 static const bool v = true;
494 };
495
496 template< class Grid, PartitionIteratorType idxpitype >
498 {
499 static const bool v = Dune::Capabilities::hasSingleGeometryType< Grid >::v;
500 static const unsigned int topologyId
501 = Dune::Capabilities::hasSingleGeometryType< Grid >::topologyId;
502 };
503
504 template< class Grid, PartitionIteratorType idxpitype >
506 {
507 static const bool v = Dune::Capabilities::isCartesian< Grid >::v;
508 };
509
510 template< class Grid, PartitionIteratorType idxpitype, int codim >
511 struct hasEntity< IntersectionAdaptiveLeafGridPart< Grid, idxpitype >, codim >
512 {
513 static const bool v = Dune::Capabilities::hasEntity< Grid, codim >::v;
514 };
515
516 template< class Grid, PartitionIteratorType idxpitype, int codim >
517 struct canCommunicate< IntersectionAdaptiveLeafGridPart< Grid, idxpitype >, codim >
518 {
519 static const bool v = Dune::Capabilities::canCommunicate< Grid, codim >::v;
520 };
521
522 template< class Grid, PartitionIteratorType idxpitype >
524 {
525 static const bool v = Dune::Capabilities::isLeafwiseConforming< Grid >::v;
526 };
527
528 } // namespace GridPartCapabilities
529
530 } // namespace Fem
531
532} // namespace Dune
533
534#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:328
BaseType::NoIndexSetType NoIndexSetType
Definition: adaptiveleafgridpart.hh:306
AdaptiveLeafGridPart(GridType &grid)
Constructor.
Definition: adaptiveleafgridpart.hh:310
AdaptiveLeafGridPart(const AdaptiveLeafGridPart &other)=default
copy constructor
BaseType::GridViewType GridViewType
Definition: adaptiveleafgridpart.hh:308
AdaptiveLeafGridPart(GridType &grid, const GridViewType *gridView)
Definition: adaptiveleafgridpart.hh:314
BaseType::GridType GridType
Definition: adaptiveleafgridpart.hh:307
AdaptiveLeafGridPart(GridType &grid, const NoIndexSetType &dummy)
copy constructor (for construction from IndexSet, no public use)
Definition: adaptiveleafgridpart.hh:320
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:374
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:386
BaseType::GridType GridType
Definition: adaptiveleafgridpart.hh:378
IntersectionAdaptiveLeafGridPart(GridType &grid)
Constructor.
Definition: adaptiveleafgridpart.hh:380
BaseType::NoIndexSetType NoIndexSetType
Definition: adaptiveleafgridpart.hh:377
A grid part with an index set specially designed for adaptive calculations including indices for inte...
Definition: adaptiveleafgridpart.hh:355
IntersectionAdaptiveLeafGridPart< Grid, idxpitype > GridPartType
type of the grid part , i.e. this type
Definition: adaptiveleafgridpart.hh:358
IntersectionAdaptiveLeafIndexSet< GridPartType > IndexSetType
type of the index set
Definition: adaptiveleafgridpart.hh:361
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
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