Dune Core Modules (2.8.0)

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_COMMON_ENTITY_HH
4#define DUNE_GRID_COMMON_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 "rangegenerators.hh"
16
17namespace Dune
18{
19
62 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
63 class Entity
64 {
65 public:
71 typedef EntityImp< cd, dim, GridImp > Implementation;
72
78 Implementation &impl () { return realEntity; }
84 const Implementation &impl () const { return realEntity; }
85
86 protected:
87 Implementation realEntity;
88
89 public:
90
91 //===========================================================
95 //===========================================================
96
98 typedef typename GridImp::template Codim<cd>::Geometry Geometry;
99
101 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
102
103 enum {
105 codimension=cd
106 };
107 enum {
109 dimension=dim
110 };
111 enum {
113 mydimension=dim-cd
114 };
116
117
118
119 //===========================================================
123 //===========================================================
124
126 int level () const { return realEntity.level(); }
127
129 PartitionType partitionType () const { return realEntity.partitionType(); }
130
143 Geometry geometry () const { return realEntity.geometry(); }
144
148 GeometryType type () const { return realEntity.type(); }
149
161 unsigned int subEntities ( unsigned int codim ) const
162 {
163 return realEntity.subEntities(codim);
164 }
165
169 EntitySeed seed () const { return realEntity.seed(); }
170
172 bool operator==(const Entity& other) const
173 {
174 return realEntity.equals(other.realEntity);
175 }
176
178 bool operator!=(const Entity& other) const
179 {
180 return !realEntity.equals(other.realEntity);
181 }
182
183 Entity()
184 {}
185
187 Entity(const Entity& other)
188 : realEntity(other.realEntity)
189 {}
190
192 Entity(Entity&& other)
193 : realEntity(std::move(other.realEntity))
194 {}
195
197 Entity& operator=(const Entity& other)
198 {
199 realEntity = other.realEntity;
200 return *this;
201 }
202
205 {
206 realEntity = std::move(other.realEntity);
207 return *this;
208 }
209
211
212 //===========================================================
216 //===========================================================
217
219 Entity(const EntityImp<cd,dim,GridImp> & e) : realEntity(e) {}
220
222 Entity(EntityImp<cd,dim,GridImp> && e) : realEntity(std::move(e)) {}
223
225 };
226
241 template<int dim, class GridImp, template<int,int,class> class EntityImp>
242 class Entity <0,dim,GridImp,EntityImp>
243 {
244 public:
251 typedef EntityImp< 0, dim, GridImp > Implementation;
252
254 Implementation &impl () { return realEntity; }
256 const Implementation &impl () const { return realEntity; }
257
258 protected:
259 Implementation realEntity;
260
261 public:
262
263 //===========================================================
267 //===========================================================
268
270 typedef typename GridImp::template Codim<0>::Geometry Geometry;
271
273 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
274
282 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
283
285 template <int cd>
286 struct Codim
287 {
288 typedef typename GridImp::template Codim<cd>::Entity Entity;
289 };
290
292 typedef typename GridImp::HierarchicIterator HierarchicIterator;
293
294 enum {
297 };
298 enum {
300 dimension=dim
301 };
302 enum {
304 mydimension=dim
305 };
307
308
309 //===========================================================
313 //===========================================================
314
316 int level () const { return realEntity.level(); }
317
319 PartitionType partitionType () const { return realEntity.partitionType(); }
320
322 Geometry geometry () const { return realEntity.geometry(); }
323
335 unsigned int subEntities ( unsigned int codim ) const
336 {
337 return realEntity.subEntities(codim);
338 }
339
343 GeometryType type () const { return realEntity.type(); }
344
348 EntitySeed seed () const { return realEntity.seed(); }
349
351 bool operator==(const Entity& other) const
352 {
353 return realEntity.equals(other.realEntity);
354 }
355
357 bool operator!=(const Entity& other) const
358 {
359 return !realEntity.equals(other.realEntity);
360 }
361
362 Entity()
363 {}
364
366 Entity(const Entity& other)
367 : realEntity(other.realEntity)
368 {}
369
371 Entity(Entity&& other)
372 : realEntity(std::move(other.realEntity))
373 {}
374
376 Entity& operator=(const Entity& other)
377 {
378 realEntity = other.realEntity;
379 return *this;
380 }
381
384 {
385 realEntity = std::move(other.realEntity);
386 return *this;
387 }
388
390
391 //===========================================================
395 //===========================================================
396
407 template< int codim >
409 subEntity ( int i ) const
410 {
411 return realEntity.template subEntity< codim >( i );
412 }
413
424 Entity father () const
425 {
426 return realEntity.father();
427 }
428
432 bool hasFather () const
433 {
434 return realEntity.hasFather();
435 }
436
438 bool isLeaf () const
439 {
440 return realEntity.isLeaf();
441 }
442
446 bool isRegular() const { return realEntity.isRegular(); }
447
473 LocalGeometry geometryInFather () const { return realEntity.geometryInFather(); }
474
486 HierarchicIterator hbegin (int maxLevel) const
487 {
488 return realEntity.hbegin(maxLevel);
489 }
490
498 HierarchicIterator hend (int maxLevel) const
499 {
500 return realEntity.hend(maxLevel);
501 }
502
505 bool isNew () const { return realEntity.isNew(); }
506
511 bool mightVanish () const { return realEntity.mightVanish(); }
512
515 bool hasBoundaryIntersections () const { return realEntity.hasBoundaryIntersections(); }
516
517
518 //===========================================================
522 //===========================================================
523
525 Entity(const EntityImp<0,dim,GridImp> & e) : realEntity(e) {}
526
528 Entity(EntityImp<0,dim,GridImp> && e) : realEntity(std::move(e)) {}
529
531 };
532
533
534
535 //********************************************************************
546 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
548 {
549 public:
551 enum { codimension=cd };
552
554 enum { dimension=dim };
555
557 enum { mydimension=dim-cd };
558
560 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
561
573 unsigned int subEntities ( unsigned int codim ) const
574 {
575 typedef typename std::remove_const< GridImp >::type::ctype ctype;
576 return ReferenceElements< ctype, mydimension >::general( asImp().type() ).size( codim - codimension );
577 }
578
582 GeometryType type () const { return asImp().geometry().type(); }
583
584 private:
586 EntityImp<cd,dim,GridImp>& asImp ()
587 {
588 return static_cast<EntityImp<cd,dim,GridImp>&>(*this);
589 }
590 const EntityImp<cd,dim,GridImp>& asImp () const
591 {
592 return static_cast<const EntityImp<cd,dim,GridImp>&>(*this);
593 }
594 }; // end EntityDefaultImplementation
595
596 //********************************************************************
607 template<int dim, class GridImp, template<int,int,class> class EntityImp>
608 class EntityDefaultImplementation <0,dim,GridImp,EntityImp>
609 {
610 public:
612 enum { codimension=0 };
613
615 enum { dimension=dim };
616
618 enum { mydimension=dim };
619
621 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
622
626 bool isRegular() const { return true; }
627
639 unsigned int subEntities ( unsigned int codim ) const
640 {
641 typedef typename std::remove_const< GridImp >::type::ctype ctype;
642 return ReferenceElements< ctype, mydimension >::general( asImp().type() ).size( codim - codimension );
643 }
644
648 GeometryType type () const { return asImp().geometry().type(); }
649
652 bool isNew () const { return false; }
653
656 bool mightVanish () const { return false; }
657
663 {
664 typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
665 IntersectionIterator end = asImp().ilevelend();
666 for (IntersectionIterator it = asImp().ilevelbegin(); it != end; ++it)
667 if( it->boundary() )
668 return true;
669
670 return false;
671 }
672
673 private:
674 // Barton-Nackman trick
675 EntityImp<0,dim,GridImp>& asImp () { return static_cast<EntityImp<0,dim,GridImp>&>(*this); }
676 const EntityImp<0,dim,GridImp>& asImp () const { return static_cast<const EntityImp<0,dim,GridImp>&>(*this); }
677 };
678
680
692 template< int cd, int dim, class GridImp, template<int,int,class> class EntityImp >
694 -> decltype(referenceElement<typename GridImp::ctype,GridImp::template Codim<cd>::Geometry::mydimension>(entity.type()))
695 {
696 typedef typename GridImp::template Codim<cd>::Geometry Geo;
697 return referenceElement< typename Geo::ctype, Geo::mydimension >(entity.type());
698 }
699}
700
701#endif // DUNE_GRID_COMMON_ENTITY_HH
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: entity.hh:652
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:626
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary, this implementation uses the Level- and Leaf...
Definition: entity.hh:662
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:621
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:648
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:639
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt()
Definition: entity.hh:656
Default Implementations for EntityImp.
Definition: entity.hh:548
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:560
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:582
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:573
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:343
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt(). If the method returns false,...
Definition: entity.hh:511
HierarchicIterator hend(int maxLevel) const
Returns iterator to one past the last son element.
Definition: entity.hh:498
GridImp::template Codim< 0 >::Geometry Geometry
The geometry type of this entity.
Definition: entity.hh:270
Implementation & impl()
Return reference to the real implementation.
Definition: entity.hh:254
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: entity.hh:376
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:335
Codim< codim >::Entity subEntity(int i) const
Obtain a subentity.
Definition: entity.hh:409
Entity(EntityImp< 0, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: entity.hh:528
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: entity.hh:371
Entity father() const
Inter-level access to father entity on the next-coarser grid. The given entity resulted directly from...
Definition: entity.hh:424
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: entity.hh:383
Entity(const EntityImp< 0, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:525
HierarchicIterator hbegin(int maxLevel) const
Inter-level access to elements that resulted from (recursive) subdivision of this element.
Definition: entity.hh:486
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary.
Definition: entity.hh:515
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:348
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: entity.hh:366
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:322
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: entity.hh:351
bool hasFather() const
Return true if entity has a father entity which can be accessed using the father() method.
Definition: entity.hh:432
int level() const
The level of this entity.
Definition: entity.hh:316
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:273
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:282
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: entity.hh:505
bool isLeaf() const
Returns true if the entity is contained in the leaf grid.
Definition: entity.hh:438
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:319
const Implementation & impl() const
Return const reference to the real implementation.
Definition: entity.hh:256
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:446
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: entity.hh:357
LocalGeometry geometryInFather() const
Provides information how this element has been subdivided from its father element.
Definition: entity.hh:473
EntityImp< 0, dim, GridImp > Implementation
Type of underlying implementation.
Definition: entity.hh:251
GridImp::HierarchicIterator HierarchicIterator
The HierarchicIterator type.
Definition: entity.hh:292
Wrapper class for entities.
Definition: entity.hh:64
const Implementation & impl() const
access to the underlying implementation
Definition: entity.hh:84
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: entity.hh:178
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:161
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:129
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: entity.hh:204
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: entity.hh:192
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:169
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:143
@ codimension
Know your own codimension.
Definition: entity.hh:105
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: entity.hh:197
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: entity.hh:98
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:101
auto referenceElement(const Entity< cd, dim, GridImp, EntityImp > &entity) -> decltype(referenceElement< typename GridImp::ctype, GridImp::template Codim< cd >::Geometry::mydimension >(entity.type()))
Second-level dispatch to select the correct reference element for a grid entity.
Definition: entity.hh:693
@ mydimension
Dimensionality of the reference element of the entity.
Definition: entity.hh:113
int level() const
The level of this entity.
Definition: entity.hh:126
Implementation & impl()
access to the underlying implementation
Definition: entity.hh:78
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: entity.hh:187
@ dimension
Know the grid dimension.
Definition: entity.hh:109
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: entity.hh:172
Entity(const EntityImp< cd, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:219
EntityImp< cd, dim, GridImp > Implementation
type of underlying implementation
Definition: entity.hh:71
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:148
Entity(EntityImp< cd, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: entity.hh:222
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:81
Traits for type conversions and type information.
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Dune namespace.
Definition: alignedallocator.hh:11
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:22
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:196
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)