Dune Core Modules (2.5.2)

entity.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_GRID_ENTITY_HH
4#define DUNE_GRID_ENTITY_HH
5
6#include <type_traits>
7
8#include <dune/common/iteratorrange.hh>
10
11#include <dune/geometry/dimension.hh>
12#include <dune/geometry/referenceelements.hh>
13
14#include "grid.hh"
15#include "entitypointer.hh"
16#include "rangegenerators.hh"
17
18namespace Dune
19{
20
63 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
64 class Entity
65 {
66#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
67 public:
68#else
69 protected:
70 // give the GridDefaultImplementation class access to the realImp
71 friend class GridDefaultImplementation<
72 GridImp::dimension, GridImp::dimensionworld,
73 typename GridImp::ctype,
74 typename GridImp::GridFamily> ;
75
76 // Default*GridView classes need access to intersection iterators
77 template< class > friend class DefaultLevelGridView;
78 template< class > friend class DefaultLeafGridView;
79#endif
80 // type of underlying implementation, for internal use only
81 typedef EntityImp< cd, dim, GridImp > Implementation;
82
84 Implementation &impl () { return realEntity; }
86 const Implementation &impl () const { return realEntity; }
87
88 protected:
89 Implementation realEntity;
90
91 public:
92
93 //===========================================================
97 //===========================================================
98
100 typedef typename GridImp::template Codim<cd>::Geometry Geometry;
101
103 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
104
105 enum {
107 codimension=cd
108 };
109 enum {
111 dimension=dim
112 };
113 enum {
115 mydimension=dim-cd
116 };
118
119
120
121 //===========================================================
125 //===========================================================
126
128 int level () const { return realEntity.level(); }
129
131 PartitionType partitionType () const { return realEntity.partitionType(); }
132
145 Geometry geometry () const { return realEntity.geometry(); }
146
150 GeometryType type () const { return realEntity.type(); }
151
163 unsigned int subEntities ( unsigned int codim ) const
164 {
165 return realEntity.subEntities(codim);
166 }
167
171 EntitySeed seed () const { return realEntity.seed(); }
172
174 bool operator==(const Entity& other) const
175 {
176 return realEntity.equals(other.realEntity);
177 }
178
180 bool operator!=(const Entity& other) const
181 {
182 return !realEntity.equals(other.realEntity);
183 }
184
185 Entity()
186 {}
187
189 Entity(const Entity& other)
190 : realEntity(other.realEntity)
191 {}
192
194 Entity(Entity&& other)
195 : realEntity(std::move(other.realEntity))
196 {}
197
199 Entity& operator=(const Entity& other)
200 {
201 realEntity = other.realEntity;
202 return *this;
203 }
204
207 {
208 realEntity = std::move(other.realEntity);
209 return *this;
210 }
211
213
214 //===========================================================
218 //===========================================================
219
221 Entity(const EntityImp<cd,dim,GridImp> & e) : realEntity(e) {}
222
224 Entity(EntityImp<cd,dim,GridImp> && e) : realEntity(std::move(e)) {}
225
227
228 protected:
229
230 // need to make copy constructor of EntityPointer work for any iterator
231 template< class, class > friend class Dune::EntityPointer;
232
233 };
234
249 template<int dim, class GridImp, template<int,int,class> class EntityImp>
250 class Entity <0,dim,GridImp,EntityImp>
251 {
252#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
253 public:
254#else
255 protected:
256 // give the GridDefaultImplementation class access to the realImp
257 friend class GridDefaultImplementation<
258 GridImp::dimension, GridImp::dimensionworld,
259 typename GridImp::ctype,
260 typename GridImp::GridFamily> ;
261
262 // Default*GridView classes need access to intersection iterators
263 template< class > friend class DefaultLevelGridView;
264 template< class > friend class DefaultLeafGridView;
265#endif
266 // type of underlying implementation, for internal use only
267 typedef EntityImp< 0, dim, GridImp > Implementation;
268
270 Implementation &impl () { return realEntity; }
272 const Implementation &impl () const { return realEntity; }
273
274 protected:
275 Implementation realEntity;
276
277 public:
278
279 //===========================================================
283 //===========================================================
284
286 typedef typename GridImp::template Codim<0>::Geometry Geometry;
287
289 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
290
298 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
299
301 template <int cd>
302 struct Codim
303 {
304 typedef typename GridImp::template Codim<cd>::Entity Entity;
305 };
306
308 typedef typename GridImp::HierarchicIterator HierarchicIterator;
309
310 enum {
313 };
314 enum {
316 dimension=dim
317 };
318 enum {
320 mydimension=dim
321 };
323
324
325 //===========================================================
329 //===========================================================
330
332 int level () const { return realEntity.level(); }
333
335 PartitionType partitionType () const { return realEntity.partitionType(); }
336
338 Geometry geometry () const { return realEntity.geometry(); }
339
351 unsigned int subEntities ( unsigned int codim ) const
352 {
353 return realEntity.subEntities(codim);
354 }
355
359 GeometryType type () const { return realEntity.type(); }
360
364 EntitySeed seed () const { return realEntity.seed(); }
365
367 bool operator==(const Entity& other) const
368 {
369 return realEntity.equals(other.realEntity);
370 }
371
373 bool operator!=(const Entity& other) const
374 {
375 return !realEntity.equals(other.realEntity);
376 }
377
378 Entity()
379 {}
380
382 Entity(const Entity& other)
383 : realEntity(other.realEntity)
384 {}
385
387 Entity(Entity&& other)
388 : realEntity(std::move(other.realEntity))
389 {}
390
392 Entity& operator=(const Entity& other)
393 {
394 realEntity = other.realEntity;
395 return *this;
396 }
397
400 {
401 realEntity = std::move(other.realEntity);
402 return *this;
403 }
404
406
407 //===========================================================
411 //===========================================================
412
423 template< int codim >
425 subEntity ( int i ) const
426 {
427 return realEntity.template subEntity< codim >( i );
428 }
429
440 Entity father () const
441 {
442 return realEntity.father();
443 }
444
448 bool hasFather () const
449 {
450 return realEntity.hasFather();
451 }
452
454 bool isLeaf () const
455 {
456 return realEntity.isLeaf();
457 }
458
462 bool isRegular() const { return realEntity.isRegular(); }
463
489 LocalGeometry geometryInFather () const { return realEntity.geometryInFather(); }
490
502 HierarchicIterator hbegin (int maxLevel) const
503 {
504 return realEntity.hbegin(maxLevel);
505 }
506
514 HierarchicIterator hend (int maxLevel) const
515 {
516 return realEntity.hend(maxLevel);
517 }
518
521 bool isNew () const { return realEntity.isNew(); }
522
527 bool mightVanish () const { return realEntity.mightVanish(); }
528
531 bool hasBoundaryIntersections () const { return realEntity.hasBoundaryIntersections(); }
532
533
534 //===========================================================
538 //===========================================================
539
541 Entity(const EntityImp<0,dim,GridImp> & e) : realEntity(e) {}
542
544 Entity(EntityImp<0,dim,GridImp> && e) : realEntity(std::move(e)) {}
545
547
548 protected:
549 // needed to make copy constructor from EntityPointer work for any iterator
550 template< class, class > friend class Dune::EntityPointer;
551
552 };
553
554
555
556 //********************************************************************
567 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
569 {
570 public:
572 enum { codimension=cd };
573
575 enum { dimension=dim };
576
578 enum { mydimension=dim-cd };
579
581 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
582
594 unsigned int subEntities ( unsigned int codim ) const
595 {
596 typedef typename std::remove_const< GridImp >::type::ctype ctype;
597 return ReferenceElements< ctype, mydimension >::general( asImp().type() ).size( codim - codimension );
598 }
599
603 GeometryType type () const { return asImp().geometry().type(); }
604
605 private:
607 EntityImp<cd,dim,GridImp>& asImp ()
608 {
609 return static_cast<EntityImp<cd,dim,GridImp>&>(*this);
610 }
611 const EntityImp<cd,dim,GridImp>& asImp () const
612 {
613 return static_cast<const EntityImp<cd,dim,GridImp>&>(*this);
614 }
615 }; // end EntityDefaultImplementation
616
617 //********************************************************************
628 template<int dim, class GridImp, template<int,int,class> class EntityImp>
629 class EntityDefaultImplementation <0,dim,GridImp,EntityImp>
630 {
631 public:
633 enum { codimension=0 };
634
636 enum { dimension=dim };
637
639 enum { mydimension=dim };
640
642 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
643
647 bool isRegular() const { return true; }
648
660 unsigned int subEntities ( unsigned int codim ) const
661 {
662 typedef typename std::remove_const< GridImp >::type::ctype ctype;
663 return ReferenceElements< ctype, mydimension >::general( asImp().type() ).size( codim - codimension );
664 }
665
669 GeometryType type () const { return asImp().geometry().type(); }
670
673 bool isNew () const { return false; }
674
677 bool mightVanish () const { return false; }
678
684 {
685 typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
686 IntersectionIterator end = asImp().ilevelend();
687 for (IntersectionIterator it = asImp().ilevelbegin(); it != end; ++it)
688 if( it->boundary() )
689 return true;
690
691 return false;
692 }
693
694 private:
695 // Barton-Nackman trick
696 EntityImp<0,dim,GridImp>& asImp () { return static_cast<EntityImp<0,dim,GridImp>&>(*this); }
697 const EntityImp<0,dim,GridImp>& asImp () const { return static_cast<const EntityImp<0,dim,GridImp>&>(*this); }
698 };
699
700}
701
702#endif // DUNE_GRID_ENTITY_HH
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: entity.hh:673
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:647
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary, this implementation uses the Level- and Leaf...
Definition: entity.hh:683
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:642
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:669
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:660
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt()
Definition: entity.hh:677
Default Implementations for EntityImp.
Definition: entity.hh:569
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:581
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:603
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:594
Wrapper class for pointers to entities.
Definition: entitypointer.hh:115
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:359
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt(). If the method returns false,...
Definition: entity.hh:527
HierarchicIterator hend(int maxLevel) const
Returns iterator to one past the last son element.
Definition: entity.hh:514
GridImp::template Codim< 0 >::Geometry Geometry
The geometry type of this entity.
Definition: entity.hh:286
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: entity.hh:392
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:351
Codim< codim >::Entity subEntity(int i) const
Obtain a subentity.
Definition: entity.hh:425
Entity(EntityImp< 0, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: entity.hh:544
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: entity.hh:387
Entity father() const
Inter-level access to father entity on the next-coarser grid. The given entity resulted directly from...
Definition: entity.hh:440
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: entity.hh:399
Entity(const EntityImp< 0, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:541
HierarchicIterator hbegin(int maxLevel) const
Inter-level access to elements that resulted from (recursive) subdivision of this element.
Definition: entity.hh:502
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary.
Definition: entity.hh:531
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:364
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: entity.hh:382
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:338
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: entity.hh:367
bool hasFather() const
Return true if entity has a father entity which can be accessed using the father() method.
Definition: entity.hh:448
int level() const
The level of this entity.
Definition: entity.hh:332
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:289
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
The geometry type of this entity when the geometry is expressed embedded in the father element.
Definition: entity.hh:298
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: entity.hh:521
bool isLeaf() const
Returns true if the entity is contained in the leaf grid.
Definition: entity.hh:454
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:335
const Implementation & impl() const
Return const reference to the real implementation.
Definition: entity.hh:272
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:462
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: entity.hh:373
LocalGeometry geometryInFather() const
Provides information how this element has been subdivided from its father element.
Definition: entity.hh:489
GridImp::HierarchicIterator HierarchicIterator
The HierarchicIterator type.
Definition: entity.hh:308
Wrapper class for entities.
Definition: entity.hh:65
const Implementation & impl() const
Return const reference to the real implementation.
Definition: entity.hh:86
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: entity.hh:180
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:163
@ codimension
Know your own codimension.
Definition: entity.hh:107
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:131
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: entity.hh:206
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: entity.hh:194
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:171
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:145
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: entity.hh:199
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: entity.hh:100
@ dimension
Know the grid dimension.
Definition: entity.hh:111
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:103
@ mydimension
Dimensionality of the reference element of the entity.
Definition: entity.hh:115
int level() const
The level of this entity.
Definition: entity.hh:128
Implementation & impl()
Return reference to the real implementation.
Definition: entity.hh:84
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: entity.hh:189
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: entity.hh:174
Entity(const EntityImp< cd, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:221
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:150
Entity(EntityImp< cd, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: entity.hh:224
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:268
Definition: grid.hh:920
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:81
Wrapper and interface class for a static iterator (EntityPointer)
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Dune namespace.
Definition: alignment.hh:11
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:22
static const ReferenceElement< ctype, dim > & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:758
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)