Dune Core Modules (2.9.0)

entity.hh
1#ifndef DUNE_ALU3DGRIDENTITY_HH
2#define DUNE_ALU3DGRIDENTITY_HH
3
4// System includes
5#include <type_traits>
6
7// Dune includes
8#include <dune/grid/common/entity.hh>
10#include <dune/alugrid/common/twists.hh>
11
12// Local includes
13#include "alu3dinclude.hh"
14#include "indexsets.hh"
15#include "iterator.hh"
16#include "entityseed.hh"
17
18namespace Dune
19{
20
21 // Forward declarations
22 template<int cd, int dim, class GridImp>
23 class ALU3dGridEntity;
24 template<int cd, PartitionIteratorType pitype, class GridImp >
25 class ALU3dGridLevelIterator;
26 template<int cd, class GridImp >
27 class ALU3dGridEntityPointer;
28 template<int mydim, int coorddim, class GridImp>
29 class ALU3dGridGeometry;
30 template<class GridImp>
31 class ALU3dGridHierarchicIterator;
32 template<class GridImp>
33 class ALU3dGridIntersectionIterator;
34 template<int codim, PartitionIteratorType, class GridImp>
35 class ALU3dGridLeafIterator;
36 template<int dim, int dimworld, ALU3dGridElementType, class >
37 class ALU3dGrid;
38
45template<int cd, int dim, class GridImp>
47public EntityDefaultImplementation <cd,dim,GridImp,ALU3dGridEntity>
48{
49 // default just returns level
50 template <class GridType, int dm, int cdim>
51 struct GetLevel
52 {
53 template <class ItemType>
54 static int getLevel(const GridType & grid, const ItemType & item )
55 {
56 return item.level();
57 }
58 };
59
60 // for leaf vertices the level is somewhat difficult to obtain, because
61 // this the maximum of levels of elements that have this vertex as sub
62 // entity
63 template <class GridType>
64 struct GetLevel<GridType,dim,dim>
65 {
66 template <class ItemType>
67 static int getLevel(const GridType & grid, const ItemType & item)
68 {
69 return (item.isLeafEntity()) ? grid.getLevelOfLeafVertex(item) : item.level();
70 }
71 };
72
73 enum { dimworld = GridImp::dimensionworld };
74
75 typedef typename GridImp::MPICommunicatorType Comm;
76
77 friend class ALU3dGrid< GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
78 friend class ALU3dGridEntity < 0, dim, GridImp >;
79 friend class ALU3dGridLevelIterator < cd, All_Partition, GridImp >;
80
81 friend class ALU3dGridHierarchicIndexSet< GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
82
83 template< class > friend class ALU3dGridFactory;
84
85 typedef typename GridImp::Traits::template Codim< cd >::GeometryImpl GeometryImpl;
86
87public:
88 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
89 typedef typename ImplTraits::template Codim<dim, cd>::InterfaceType HItemType;
90 typedef typename ImplTraits::template Codim<dim, cd>::ImplementationType ItemType;
91 typedef typename ImplTraits::VertexType VertexType;
92 typedef typename ImplTraits::HBndSegType HBndSegType;
93
94 typedef typename GridImp::template Codim<cd>::Entity Entity;
95 typedef typename GridImp::template Codim<cd>::Geometry Geometry;
96
98 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
99
102
104 ALU3dGridEntity( const EntitySeed& seed );
105
107 Geometry geometry () const;
108
110 GeometryType type () const { return geo_.type(); }
111
112 // set element as normal entity
113 void setElement(const HItemType & item);
114 void setElement(const HItemType & item, const GridImp& grid );
115 void setElement(const HItemType & item, const int level, int twist=0);
116
117 /* set entity from seed */
118 void setElement(const EntitySeed& seed);
119
121 void setGhost(const HBndSegType &ghost);
122
125 {
126 seed_.clear();
127 geo_.invalidate();
128 }
129
131 bool equals ( const ALU3dGridEntity<cd,dim,GridImp> & org ) const
132 {
133 return seed_ == org.seed_;
134 }
135
137 void setEntity ( const ALU3dGridEntity<cd,dim,GridImp> & org );
138
139 int subIndex ( int i, unsigned int codim ) const
140 {
141 DUNE_THROW( NotImplemented, "Method subIndex for higher codimension not implemented, yet." );
142 }
143
144 // return reference to internal item
145 const ItemType& getItem () const { return *(static_cast<ItemType *> (seed_.item())); }
146
148 EntitySeed seed() const { return seed_; }
149
151 int level () const { return seed_.level(); }
152
154 PartitionType partitionType() const { return this->convertBndId( getItem() ); }
155
156protected:
158 int getIndex () const { return getItem().getIndex(); }
159
161 PartitionType convertBndId(const HItemType & item) const ;
162
164 mutable GeometryImpl geo_;
165
168};
169
183//***********************
184//
185// --ALU3dGridEntity
186// --0Entity
187//
188//***********************
189template<int dim, class GridImp>
190class ALU3dGridEntity<0,dim,GridImp>
191: public EntityDefaultImplementation<0,dim,GridImp,ALU3dGridEntity>
192{
193 static const int dimworld = std::remove_const< GridImp >::type::dimensionworld;
194 static const ALU3dGridElementType elementType = std::remove_const< GridImp >::type::elementType;
195
196 typedef typename GridImp::MPICommunicatorType Comm;
197
198 typedef ALU3dImplTraits< elementType, Comm > ImplTraits;
199 typedef typename ImplTraits::template Codim<dim, 0>::InterfaceType HElementType;
200
201 typedef typename ImplTraits::GEOElementType GEOElementType;
202 typedef typename ImplTraits::BNDFaceType BNDFaceType;
203 typedef typename ImplTraits::IMPLElementType IMPLElementType;
204 typedef typename ImplTraits::HBndSegType HBndSegType;
205
206 enum { refine_element_t = ImplTraits::RefinementRules::refine_element_t };
207 enum { bisect_element_t = ImplTraits::RefinementRules::bisect_element_t };
208 enum { coarse_element_t = ImplTraits::RefinementRules::coarse_element_t };
209 enum { nosplit_element_t = ImplTraits::RefinementRules::nosplit_element_t };
210
211 typedef typename ImplTraits::MarkRuleType MarkRuleType;
212
213 friend class ALU3dGrid< GridImp::dimension, GridImp::dimensionworld, elementType, Comm >;
214 friend class ALU3dGridIntersectionIterator < GridImp >;
215 friend class ALU3dGridIntersectionIterator < const GridImp >;
216 friend class ALU3dGridHierarchicIterator < const GridImp >;
217 friend class ALU3dGridHierarchicIterator < GridImp >;
218 friend class ALU3dGridLevelIterator <0,All_Partition,GridImp>;
219 friend class ALU3dGridLevelIterator <1,All_Partition,GridImp>;
220 friend class ALU3dGridLevelIterator <2,All_Partition,GridImp>;
221 friend class ALU3dGridLevelIterator <3,All_Partition,GridImp>;
222 friend class ALU3dGridLeafIterator <0, All_Partition,GridImp>;
223 friend class ALU3dGridLeafIterator <1, All_Partition,GridImp>;
224 friend class ALU3dGridLeafIterator <2, All_Partition,GridImp>;
225 friend class ALU3dGridLeafIterator <3, All_Partition,GridImp>;
226
227 friend class ALU3dGridHierarchicIndexSet< GridImp::dimension, GridImp::dimensionworld, elementType, Comm >;
228
229 template< class > friend class ALU3dGridFactory;
230
231 // type of reference element
232 typedef typename GridImp :: ReferenceElementType ReferenceElementType;
233
234 typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
235 typedef typename GridImp::Traits::template Codim< 0 >::LocalGeometryImpl LocalGeometryImpl;
236
237public:
238 typedef typename GridImp::template Codim< 0 >::Geometry Geometry;
239 typedef typename GridImp::template Codim< 0 >::LocalGeometry LocalGeometry;
241
245
246 typedef typename GridImp::template Codim<0>::Entity Entity;
247
248 template <int cd>
249 struct Codim
250 {
251 typedef typename GridImp::Traits::template Codim< cd >::Twists::Twist Twist;
252 typedef typename GridImp::template Codim< cd >::Entity Entity;
253 };
254
256 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
257
260
263
265 ALU3dGridEntity( const HElementType& element );
266
268 ALU3dGridEntity( const HBndSegType& ghost );
269
271 int level () const ;
272
274 Geometry geometry () const;
275
277 GeometryType type () const;
278
281
285 unsigned int subEntities (unsigned int codim) const;
286
289 template< int codim >
290 typename Codim< codim >::Entity subEntity ( int i ) const;
291
292 template< int codim >
293 typename Codim< codim >::Twist twist ( int i ) const;
294
296 bool isLeaf () const;
297
300 Entity father () const;
301
303 bool hasFather () const
304 {
305 return (this->level()>0);
306 }
307
317 LocalGeometry geometryInFather () const;
318
323 ALU3dGridHierarchicIterator<GridImp> hbegin (int maxlevel) const;
324
326 ALU3dGridHierarchicIterator<GridImp> hend (int maxlevel) const;
327
328 //***************************************************************
329 // Interface for Adaptation
330 //***************************************************************
331
333 bool isNew () const;
334
336 bool mightVanish () const;
337
339 bool hasBoundaryIntersections () const;
340
341 // private method
345 bool mark( const int refCount, const bool conformingRefinement ) const;
346
348 int getMark() const;
349
353 void setElement(HElementType &element);
354
355 /* set entity from seed */
356 void setElement(const EntitySeed& seed);
357
359 void setGhost(HBndSegType & ghost);
360
362 void reset ( int l );
363
365 void removeElement();
366
368 bool equals ( const ALU3dGridEntity<0,dim,GridImp> & org ) const;
369
370 void setEntity ( const ALU3dGridEntity<0,dim,GridImp> & org );
371
375 template<int cc> int getSubIndex (int i) const;
376
380 int subIndex(int i, unsigned int codim) const;
381
382 // return reference to internal item
383 const IMPLElementType& getItem () const { return *item_; }
384
385 // return reference to internal item
386 const BNDFaceType& getGhost () const
387 {
388 alugrid_assert ( isGhost() );
389 return *ghost_;
390 }
391
393 bool isGhost () const{ return ImplTraits::isGhost( ghost_ ); }
394
397 {
398 if( isGhost() )
399 return EntitySeed( getGhost () );
400 else
401 return EntitySeed( getItem() );
402 }
403
405 int macroId() const
406 {
407 return (isGhost()) ? getGhost().ldbVertexIndex() : getItem().ldbVertexIndex();
408 }
409
411 int weight() const
412 {
413 return (isGhost()) ? 0 : getItem().weight();
414 }
415
417 int master() const
418 {
419 return (isGhost()) ? getGhost().master() : getItem().master();
420 }
421
422protected:
424 int getIndex () const;
425
427 mutable GeometryImpl geo_;
428
429 // the current element of grid
430 mutable IMPLElementType* item_;
431
433 mutable BNDFaceType* ghost_;
434
435}; // end of ALU3dGridEntity codim = 0
436
437
438
439//**********************************************************************
440//
441// --ALU3dGridEntityPointer
442// --EntityPointer
443// --EnPointer
447template< int codim, class GridImp >
449{
451 enum { dim = GridImp::dimension };
452 enum { dimworld = GridImp::dimensionworld };
453
454 typedef typename GridImp::MPICommunicatorType Comm;
455
456 friend class ALU3dGridEntity<codim,dim,GridImp>;
457 friend class ALU3dGridEntity< 0,dim,GridImp>;
458 friend class ALU3dGrid < GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
459
460 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
461 typedef typename ImplTraits::template Codim<dim, codim>::InterfaceType HElementType;
462
463 typedef typename ImplTraits::HBndSegType HBndSegType;
464 typedef typename ImplTraits::BNDFaceType BNDFaceType;
465public:
466 enum { codimension = codim };
467
469 typedef typename GridImp::template Codim<codimension>::Entity Entity;
470 typedef Entity EntityObject;
472
475
477 typedef ALU3dGridEntityPointer<codimension,GridImp> EntityPointerImp;
478
480 typedef ALU3dGridEntitySeed<codimension, GridImp> ALU3dGridEntitySeedType;
481
483 ALU3dGridEntityPointerBase(const HElementType & item);
484
486 ALU3dGridEntityPointerBase(const HBndSegType & ghostFace );
487
490
493
495 bool equals (const ALU3dGridEntityPointerType& i) const;
496
498 ThisType & operator = (const ThisType & org);
499
502 {
503 // don't dereference empty entity pointer
504 alugrid_assert ( seed_.isValid() );
505 alugrid_assert ( seed_.item() == & entityImp().getItem() );
506 return entity_;
507 }
508
510 int level () const { return seed_.level(); }
511
514
515protected:
516 // clones object
517 void clone (const ALU3dGridEntityPointerType & org);
518
520 void done ();
521
522 // update underlying item pointer and set ghost entity
523 void updateGhostPointer( HBndSegType & ghostFace );
524
525 // update underlying item pointer and set entity
526 void updateEntityPointer( HElementType * item , int level = -1 );
527
528 // key to gererate entity
530
531 // entity that this EntityPointer points to
532 mutable EntityObject entity_;
533
534 // return reference to internal entity implementation
535 EntityImp & entityImp () const {
536 return entity_.impl();
537 }
538};
539
543template<class GridImp>
544class ALU3dGridEntityPointer<0,GridImp> :
545public ALU3dGridEntityPointerBase<0,GridImp>
546{
547protected:
549
550 enum { cd = 0 };
551 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
552 enum { dim = GridImp::dimension };
553 enum { dimworld = GridImp::dimensionworld };
554
555 typedef typename GridImp::MPICommunicatorType Comm;
556
557 friend class ALU3dGridEntity<cd,dim,GridImp>;
558 friend class ALU3dGridEntity< 0,dim,GridImp>;
559 friend class ALU3dGrid < GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
560
561 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
562 typedef typename ImplTraits::template Codim<dim, cd>::InterfaceType HElementType;
563
564 typedef typename ImplTraits::HBndSegType HBndSegType;
565 typedef typename ImplTraits::BNDFaceType BNDFaceType;
566
567 typedef ALU3dGridEntity< 0,dim,GridImp> ALU3dGridEntityType ;
568
569 using BaseType :: seed_;
570 using BaseType :: entity_;
571 using BaseType :: entityImp;
572public:
574 typedef ALU3dGridEntitySeed<cd, GridImp> ALU3dGridEntitySeedType;
575
577 typedef typename GridImp::template Codim<cd>::Entity Entity;
578
581
583 ALU3dGridEntityPointer(const HElementType & item)
584 : ALU3dGridEntityPointerBase<cd,GridImp> ( item )
585 {}
586
588 ALU3dGridEntityPointer(const HBndSegType & ghostFace )
589 : ALU3dGridEntityPointerBase<cd,GridImp> ( ghostFace )
590 {}
591
594 : ALU3dGridEntityPointerBase<cd,GridImp> ( seed )
595 {
596 }
597
600 : ALU3dGridEntityPointerBase<cd,GridImp> ( entity.seed() )
601 {
602 }
603
607 : ALU3dGridEntityPointerBase<cd,GridImp> ()
608 {}
609};
610
611
612template<int cd, class GridImp>
613class ALU3dGridEntityPointer :
614public ALU3dGridEntityPointerBase<cd,GridImp>
615{
616protected:
617 typedef ALU3dGridEntityPointerBase<cd,GridImp> BaseType ;
618 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
619 enum { dim = GridImp::dimension };
620 enum { dimworld = GridImp::dimensionworld };
621
622 typedef typename GridImp::MPICommunicatorType Comm;
623
624 friend class ALU3dGridEntity<cd,dim,GridImp>;
625 friend class ALU3dGridEntity< 0,dim,GridImp>;
626 friend class ALU3dGrid < GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
627
628 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
629 typedef typename ImplTraits::template Codim<dim, cd>::InterfaceType HElementType;
630
631 typedef typename ImplTraits::HBndSegType HBndSegType;
632 typedef typename ImplTraits::BNDFaceType BNDFaceType;
633 typedef ALU3dGridEntity<cd,dim,GridImp> ALU3dGridEntityType;
634
635 using BaseType :: seed_;
636 using BaseType :: entity_;
637 using BaseType :: entityImp;
638
639public:
641 typedef ALU3dGridEntitySeed<cd, GridImp> ALU3dGridEntitySeedType;
642
644 typedef typename GridImp::template Codim<cd>::Entity Entity;
645
647 typedef ALU3dGridEntityPointer<cd,GridImp> ALU3dGridEntityPointerType;
648
649protected:
650 static const int defaultValue = -665; //ALU3dGridEntityPointerType :: defaultValue;
651
652public:
654 ALU3dGridEntityPointer(const ALU3dGridEntityType& entity)
655 : ALU3dGridEntityPointerBase<cd,GridImp> ( entity.seed() )
656 {}
657
659 ALU3dGridEntityPointer(const ALU3dGridEntitySeedType& seed)
660 : ALU3dGridEntityPointerBase<cd,GridImp> ( seed )
661 {}
662
665 ALU3dGridEntityPointer()
666 : ALU3dGridEntityPointerBase<cd,GridImp> ()
667 {}
668
669protected:
670 void updateEntityPointer( HElementType * item , int level );
671};
672
673} // end namespace Dune
674
675#include "entity_inline.hh"
676
677#if COMPILE_ALUGRID_INLINE
678 #include "entity_imp.cc"
679#endif
680#endif
Definition: entity.hh:449
GridImp::template Codim< codimension >::Entity Entity
type of Entity
Definition: entity.hh:469
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:474
int level() const
ask for level of entities
Definition: entity.hh:510
ALU3dGridEntityPointerBase()
default empty constructor
Definition: entity_inline.hh:241
bool equals(const ALU3dGridEntityPointerType &i) const
equality
Definition: entity_inline.hh:293
ALU3dGridEntitySeed< codimension, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:480
ALU3dGridEntityPointer< codimension, GridImp > EntityPointerImp
make type of entity pointer implementation available in derived classes
Definition: entity.hh:477
ALU3dGridEntityPointerBase(const HElementType &item)
Constructor for EntityPointer that points to an element.
Definition: entity_inline.hh:216
Entity & dereference() const
dereferencing
Definition: entity.hh:501
ThisType & operator=(const ThisType &org)
assignment operator
Definition: entity_inline.hh:260
void done()
has to be called when iterator is finished
Definition: entity_inline.hh:286
ALU3dGridEntityPointer(const HBndSegType &ghostFace)
Constructor for EntityPointer that points to an ghost.
Definition: entity.hh:588
GridImp::template Codim< cd >::Entity Entity
type of Entity
Definition: entity.hh:577
ALU3dGridEntityPointer(const ALU3dGridEntityType &entity)
Constructor for EntityPointer that points to an entity (interior or ghost)
Definition: entity.hh:599
ALU3dGridEntitySeed< cd, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:574
ALU3dGridEntityPointer()
Definition: entity.hh:606
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:580
ALU3dGridEntityPointer(const ALU3dGridEntitySeedType &seed)
Constructor for EntityPointer that points to given entity.
Definition: entity.hh:593
BNDFaceType * ghost_
not zero if entity is ghost entity
Definition: entity.hh:433
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:303
GridImp::template Codim< 0 >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:256
Codim< codim >::Entity subEntity(int i) const
GeometryImpl geo_
the entity's geometry
Definition: entity.hh:427
EntitySeed seed() const
return key for this entity
Definition: entity.hh:396
int weight() const
weight of entity (ie number of leaf elements underneath)
Definition: entity.hh:411
bool isGhost() const
returns true if entity is ghost
Definition: entity.hh:393
int master() const
return rank number of master process
Definition: entity.hh:417
int macroId() const
return macro id of this entity
Definition: entity.hh:405
Definition: entity.hh:48
EntitySeed seed_
the information necessary to make sense of this entity
Definition: entity.hh:167
GeometryType type() const
type of geometry of this entity
Definition: entity.hh:110
void removeElement()
reset item pointer to NULL
Definition: entity.hh:124
int level() const
level of this element
Definition: entity.hh:151
PartitionType partitionType() const
return partition type of this entity ( see grid.hh )
Definition: entity.hh:154
ALU3dGridEntity()
Constructor.
Definition: entity_imp.cc:214
PartitionType convertBndId(const HItemType &item) const
convert ALUGrid partition type to dune partition type
Definition: entity_imp.cc:276
Geometry geometry() const
geometry of this entity
Definition: entity_imp.cc:295
GridImp::template Codim< cd >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:98
void setEntity(const ALU3dGridEntity< cd, dim, GridImp > &org)
set item from other entity, mainly for copy constructor of entity pointer
Definition: entity_imp.cc:227
EntitySeed seed() const
return seed of entity
Definition: entity.hh:148
GeometryImpl geo_
the current geometry
Definition: entity.hh:164
void setGhost(const HBndSegType &ghost)
setGhost is not valid for this codim
Definition: entity_imp.cc:266
int getIndex() const
index is unique within the grid hierarchy and per codim
Definition: entity.hh:158
bool equals(const ALU3dGridEntity< cd, dim, GridImp > &org) const
compare 2 elements by comparing the item pointers
Definition: entity.hh:131
Factory class for ALUGrids.
Definition: gridfactory.hh:28
hierarchic index set of ALU3dGrid
Definition: indexsets.hh:39
Definition: iterator.hh:56
Leaf iterator.
Definition: iterator.hh:648
Definition: iterator.hh:556
[ provides Dune::Grid ]
Definition: grid.hh:434
Default Implementations for EntityImp.
Definition: entity.hh:542
static constexpr int dimension
Dimension of the grid.
Definition: entity.hh:548
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:567
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:26
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:125
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:246
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:346
Default exception for dummy implementations.
Definition: exceptions.hh:263
entity seed for SPGrid
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)