DUNE-FEM (unstable)

adaptiveleafgridpart.hh
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
8#include <dune/fem/gridpart/adaptiveleafindexset.hh>
9#include <dune/fem/gridpart/common/capabilities.hh>
10#include <dune/fem/gridpart/common/gridpart.hh>
11#include <dune/fem/misc/capabilities.hh>
12#include <dune/fem/space/common/dofmanager.hh>
13#include <dune/fem/storage/singletonlist.hh>
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>
40 struct IteratorToInterface
41 {
43 };
44 template <>
45 struct IteratorToInterface< InteriorBorder_Partition >
46 {
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
99 typedef GridPartType GridViewType;
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::shared_ptr< IndexSetType > indexSet_;
113
114 public:
117 : BaseType( grid ),
118 leafGridView_( grid.leafGridView() ),
119 indexSet_( &IndexSetProviderType::getObject( &grid ),
120 typename IndexSetProviderType::Deleter() )
121 {}
122
124 AdaptiveGridPartBase ( const ThisType &other ) = default;
125
126 AdaptiveGridPartBase& operator= ( const AdaptiveGridPartBase& other ) = default;
127
128 protected:
130 AdaptiveGridPartBase ( GridType& grid, const NoIndexSetType& noIndexSet )
131 : BaseType( grid ),
132 leafGridView_( grid.leafGridView() ),
133 indexSet_() // not created because noIndexSet was passed
134 {}
135
136 public:
137 using BaseType::grid;
138
140 const IndexSetType &indexSet () const
141 {
142 assert( indexSet_ );
143 return *indexSet_;
144 }
145
148 {
149 assert( indexSet_ );
150 return *indexSet_;
151 }
152
154 template< int codim >
155 typename Codim< codim > :: IteratorType
156 begin () const
157 {
158 return begin< codim, InteriorBorder_Partition >();
159 }
160
162 template< int codim, PartitionIteratorType pitype >
163 typename Codim< codim > :: template Partition< pitype > :: IteratorType
164 begin () const
165 {
166 return leafGridView_.template begin< codim, pitype >();
167 }
168
170 template< int codim >
171 typename Codim< codim > :: IteratorType
172 end () const
173 {
174 return end< codim, InteriorBorder_Partition >();
175 }
176
178 template< int codim, PartitionIteratorType pitype >
179 typename Codim< codim > :: template Partition< pitype > :: IteratorType
180 end () const
181 {
182 return leafGridView_.template end< codim, pitype >();
183 }
184
187 ibegin ( const ElementType &entity ) const
188 {
189 return leafGridView_.ibegin( entity );
190 }
191
194 iend ( const ElementType &entity ) const
195 {
196 return leafGridView_.iend( entity );
197 }
198
200 template< class DataHandle, class Data >
202 {
203 return leafGridView_.communicate( data, iftype, dir );
204 }
205
206 protected:
207 const GridPartType& asImp() const
208 {
209 return static_cast<const GridPartType &> (*this);
210 }
211
212 GridPartType& asImp()
213 {
214 return static_cast<GridPartType &> (*this);
215 }
216 };
217
225 template< class Grid, PartitionIteratorType idxpitype = All_Partition, bool onlyCodimensionZero = false >
226 class AdaptiveLeafGridPart;
227
229 template< class Grid, PartitionIteratorType idxpitype , bool onlyCodimensionZero >
231 {
232 public:
234 typedef Grid GridType;
235
237 typedef AdaptiveLeafGridPart< GridType, idxpitype, onlyCodimensionZero > GridPartType;
238
241
242 typedef typename GridType::Communication CommunicationType;
243
244 protected:
245 // choose the AdaptiveIndexSet (based on the HierarchicIndexSet)
246 // to be revised
247 template < int dummy, bool onlyCodimZero >
248 struct AdaptiveLeafIndexSetChooser
249 {
250 static const PartitionIteratorType indexSetPartitionType = idxpitype;
251 static const InterfaceType indexSetInterfaceType = IteratorToInterface<idxpitype>::value;
253 };
254
255 template <int dummy>
256 struct AdaptiveLeafIndexSetChooser<dummy, true >
257 {
258 static const PartitionIteratorType indexSetPartitionType = idxpitype;
259 static const InterfaceType indexSetInterfaceType = IteratorToInterface<idxpitype>::value;
261 };
262
263 // also for Cartesian grids (e.g. YaspGrid) use adaptive leaf index set in parallel
264 typedef AdaptiveLeafIndexSetChooser<-1, onlyCodimensionZero > IndexSetChooserType;
265
266 public:
269
270 static const PartitionIteratorType indexSetPartitionType = IndexSetChooserType::indexSetPartitionType;
271 static const InterfaceType indexSetInterfaceType = IndexSetChooserType::indexSetInterfaceType;
272
273 // type of intersection iterator
274 typedef typename GridType::LeafGridView::IntersectionIterator IntersectionIteratorType;
275
276 template< int codim >
277 struct Codim
278 {
279 typedef typename GridType::template Codim< codim >::Geometry GeometryType;
280 typedef typename GridType::template Codim< codim >::LocalGeometry LocalGeometryType;
281
282 typedef typename GridType::template Codim< codim >::Entity EntityType;
283 typedef typename GridType::template Codim< codim >::EntitySeed EntitySeedType;
284
285 // GridView typedefs interface
286 typedef GeometryType Geometry;
287 typedef LocalGeometryType LocalGeometry;
288 typedef EntityType Entity;
289 typedef EntitySeedType EntitySeed;
290
291 template< PartitionIteratorType pitype >
292 struct Partition
293 {
294 typedef typename GridType::template Codim< codim >::template Partition< pitype >::LeafIterator IteratorType;
295 // GridView typedef
296 typedef IteratorType Iterator;
297 };
298
299 typedef typename Partition< InteriorBorder_Partition >::IteratorType IteratorType;
300 // GridView typedef
301 typedef IteratorType Iterator;
302 };
303
306 };
307
308 template< class Grid, PartitionIteratorType idxpitype , bool onlyCodimensionZero >
309 class AdaptiveLeafGridPart
310 : public AdaptiveGridPartBase< AdaptiveLeafGridPartTraits< Grid, idxpitype, onlyCodimensionZero > >
311 {
313 public:
314 typedef typename BaseType :: NoIndexSetType NoIndexSetType;
315 typedef typename BaseType :: GridType GridType;
316 typedef typename BaseType :: GridViewType GridViewType;
317 typedef typename BaseType :: GridPartType GridPartType;
319 explicit AdaptiveLeafGridPart ( GridType &grid )
320 : BaseType( grid )
321 {}
322
324 AdaptiveLeafGridPart ( GridType& grid, const NoIndexSetType& dummy )
325 : BaseType( grid, dummy )
326 {}
327
329 AdaptiveLeafGridPart ( const AdaptiveLeafGridPart& other ) = default;
330 };
331
339 template< class Grid, PartitionIteratorType idxpitype = All_Partition >
340 using DGAdaptiveLeafGridPart = AdaptiveLeafGridPart< Grid, idxpitype, true >;
341
342
343 template< class Grid, PartitionIteratorType idxpitype = All_Partition >
345
353 template< class Grid, PartitionIteratorType idxpitype >
355 {
356 public:
359
361 typedef IntersectionAdaptiveLeafIndexSet< GridPartType > IndexSetType;
362 };
363
371 template< class Grid, PartitionIteratorType idxpitype >
373 : public AdaptiveGridPartBase< IntersectionAdaptiveLeafGridPartTraits< Grid, idxpitype > >
374 {
376 public:
377 typedef typename BaseType :: NoIndexSetType NoIndexSetType;
378 typedef typename BaseType :: GridType GridType;
381 : BaseType( grid )
382 {
383 }
384
386 IntersectionAdaptiveLeafGridPart ( GridType& grid, const NoIndexSetType& noIndexSet )
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 {
416 static const unsigned int 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 {
430 };
431
432 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero, int codim >
433 struct canCommunicate< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero >, codim >
434 {
436 };
437
438 template< class Grid, PartitionIteratorType idxpitype, bool onlyCodimensionZero >
439 struct isConforming< AdaptiveLeafGridPart< Grid, idxpitype, onlyCodimensionZero > >
440 {
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 >
455 struct hasSingleGeometryType< DGAdaptiveLeafGridPart< Grid, idxpitype > >
456 {
458 static const unsigned int 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 {
472 };
473
474 template< class Grid, PartitionIteratorType idxpitype, int codim >
475 struct canCommunicate< DGAdaptiveLeafGridPart< Grid, idxpitype >, codim >
476 {
478 };
479
480 template< class Grid, PartitionIteratorType idxpitype >
481 struct isConforming< DGAdaptiveLeafGridPart< Grid, idxpitype > >
482 {
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 >
497 struct hasSingleGeometryType< IntersectionAdaptiveLeafGridPart< Grid, idxpitype > >
498 {
500 static const unsigned int topologyId
502 };
503
504 template< class Grid, PartitionIteratorType idxpitype >
505 struct isCartesian< IntersectionAdaptiveLeafGridPart< Grid, 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 {
514 };
515
516 template< class Grid, PartitionIteratorType idxpitype, int codim >
517 struct canCommunicate< IntersectionAdaptiveLeafGridPart< Grid, idxpitype >, codim >
518 {
520 };
521
522 template< class Grid, PartitionIteratorType idxpitype >
523 struct isConforming< IntersectionAdaptiveLeafGridPart< Grid, idxpitype > >
524 {
526 };
527
528 } // namespace GridPartCapabilities
529
530 } // namespace Fem
531
532} // namespace Dune
533
534#endif // #ifndef DUNE_FEM_ADAPTIVELEAFGRIDPART_HH
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:26
Wrapper class for entities.
Definition: entity.hh:66
A grid part with an index set specially designed for adaptive calculations.
Definition: adaptiveleafgridpart.hh:66
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:164
IntersectionIteratorType iend(const ElementType &entity) const
iend of corresponding intersection iterator for given entity
Definition: adaptiveleafgridpart.hh:194
IntersectionIteratorType ibegin(const ElementType &entity) const
ibegin of corresponding intersection iterator for given entity
Definition: adaptiveleafgridpart.hh:187
AdaptiveGridPartBase(const ThisType &other)=default
Copy Constructor.
Codim< codim >::IteratorType begin() const
Begin iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:156
IndexSetType & indexSet()
Returns reference to index set of the underlying grid.
Definition: adaptiveleafgridpart.hh:147
decltype(auto) communicate(CommDataHandleIF< DataHandle, Data > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for this grid part
Definition: adaptiveleafgridpart.hh:201
AdaptiveGridPartBase(GridType &grid, const NoIndexSetType &noIndexSet)
Constructor constructing object held by index set (for iterator access)
Definition: adaptiveleafgridpart.hh:130
TraitsImp Traits
Type definitions.
Definition: adaptiveleafgridpart.hh:72
Codim< codim >::IteratorType end() const
Begin iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:172
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:140
AdaptiveGridPartBase(GridType &grid)
constructor
Definition: adaptiveleafgridpart.hh:116
Codim< codim >::template Partition< pitype >::IteratorType end() const
End iterator on the leaf level.
Definition: adaptiveleafgridpart.hh:180
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: adaptiveleafgridpart.hh:95
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: adaptiveleafgridpart.hh:92
Type definitions for the LeafGridPart class.
Definition: adaptiveleafgridpart.hh:231
AdaptiveLeafGridPart< GridType, idxpitype, onlyCodimensionZero > GridPartType
type of the grid part , i.e. this type
Definition: adaptiveleafgridpart.hh:237
Grid GridType
type of the grid
Definition: adaptiveleafgridpart.hh:234
static const bool conforming
is true if grid on this view only has conforming intersections
Definition: adaptiveleafgridpart.hh:305
IndexSetChooserType::IndexSetType IndexSetType
type of the index set
Definition: adaptiveleafgridpart.hh:268
TwistUtility< GridType > TwistUtilityType
The type of the corresponding TwistUtility.
Definition: adaptiveleafgridpart.hh:240
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1351
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1496
Default implementation for the GridPart classes.
Definition: gridpart.hh:372
Traits::template Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
Definition: gridpart.hh:468
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:423
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
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
IntersectionAdaptiveLeafGridPart(GridType &grid)
Constructor.
Definition: adaptiveleafgridpart.hh:380
Singleton list for key/object pairs.
Definition: singletonlist.hh:53
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Wrapper class for geometries.
Definition: geometry.hh:71
Grid abstract base class.
Definition: grid.hh:375
typename GridFamily::Traits::Communication Communication
A type that is a model of Dune::Communication. It provides a portable way for communication on the se...
Definition: grid.hh:515
AdaptiveLeafGridPart< Grid, idxpitype, true > DGAdaptiveLeafGridPart
A grid part with an index set specially designed for adaptive calculations.
Definition: adaptiveleafgridpart.hh:340
Grid< dim, dimworld, ct, GridFamily >::LeafGridView leafGridView(const Grid< dim, dimworld, ct, GridFamily > &grid)
leaf grid view for the given grid
Definition: grid.hh:805
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136
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
@ InteriorBorder_Partition
interior and border entities
Definition: gridenums.hh:138
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:88
@ InteriorBorder_InteriorBorder_Interface
send/receive interior and border entities
Definition: gridenums.hh:87
Dune namespace.
Definition: alignedallocator.hh:13
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: capabilities.hh:97
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:27
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:115
Struct providing types of the leaf iterators on codimension codim.
Definition: adaptiveleafgridpart.hh:85
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition: twistutility.hh:107
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)