Dune Core Modules (2.3.1)

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
7#include "grid.hh"
8#include "entitypointer.hh"
9
10namespace Dune
11{
12
55 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
56 class Entity
57 {
58#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
59 public:
60#else
61 protected:
62 // give the GridDefaultImplementation class access to the realImp
63 friend class GridDefaultImplementation<
64 GridImp::dimension, GridImp::dimensionworld,
65 typename GridImp::ctype,
66 typename GridImp::GridFamily> ;
67
68 // Default*GridView classes need access to intersection iterators
69 template< class, PartitionIteratorType > friend class DefaultLevelGridView;
70 template< class, PartitionIteratorType > friend class DefaultLeafGridView;
71#endif
72 // type of underlying implementation, for internal use only
73 typedef EntityImp< cd, dim, GridImp > Implementation;
74
76 Implementation &impl () { return realEntity; }
78 const Implementation &impl () const { return realEntity; }
79
80 protected:
81 Implementation realEntity;
82
83 public:
84
85 //===========================================================
89 //===========================================================
90
92 typedef typename GridImp::template Codim<cd>::Geometry Geometry;
93
95 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
96
97 enum {
100 };
101 enum {
103 dimension=dim
104 };
105 enum {
107 mydimension=dim-cd
108 };
110 static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld=GridImp::dimensionworld;
111
113 typedef typename GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!");
115
116
117
118 //===========================================================
122 //===========================================================
123
125 int level () const { return realEntity.level(); }
126
128 PartitionType partitionType () const { return realEntity.partitionType(); }
129
142 Geometry geometry () const { return realEntity.geometry(); }
143
147 GeometryType type () const { return realEntity.type(); }
148
152 EntitySeed seed () const { return realEntity.seed(); }
154
155 //===========================================================
159 //===========================================================
160
162 explicit Entity(const EntityImp<cd,dim,GridImp> & e) : realEntity(e) {}
163
165
166 protected:
167
168 // need to make copy constructor of EntityPointer work for any iterator
169 template< class, class > friend class Dune::EntityPointer;
170
172 Entity(const Entity& rhs) : realEntity(rhs.realEntity) {}
174 Entity & operator = (const Entity& rhs) {
175 realEntity = rhs.realEntity;
176 return *this;
177 }
178
179 };
180
195 template<int dim, class GridImp, template<int,int,class> class EntityImp>
196 class Entity <0,dim,GridImp,EntityImp>
197 {
198#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
199 public:
200#else
201 protected:
202 // give the GridDefaultImplementation class access to the realImp
203 friend class GridDefaultImplementation<
204 GridImp::dimension, GridImp::dimensionworld,
205 typename GridImp::ctype,
206 typename GridImp::GridFamily> ;
207
208 // Default*GridView classes need access to intersection iterators
209 template< class, PartitionIteratorType > friend class DefaultLevelGridView;
210 template< class, PartitionIteratorType > friend class DefaultLeafGridView;
211#endif
212 // type of underlying implementation, for internal use only
213 typedef EntityImp< 0, dim, GridImp > Implementation;
214
216 Implementation &impl () { return realEntity; }
218 const Implementation &impl () const { return realEntity; }
219
220 protected:
221 Implementation realEntity;
222
223 public:
224
225 //===========================================================
229 //===========================================================
230
232 typedef typename GridImp::template Codim<0>::Geometry Geometry;
233
235 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
236
244 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
245
247 template <int cd>
248 struct Codim
249 {
250 typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
251 };
252
254 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
255
259 typedef typename GridImp::LeafIntersectionIterator LeafIntersectionIterator;
260
264 typedef typename GridImp::LevelIntersectionIterator LevelIntersectionIterator;
265
267 typedef typename GridImp::HierarchicIterator HierarchicIterator;
268
269 enum {
272 };
273 enum {
275 dimension=dim
276 };
277 enum {
279 mydimension=dim
280 };
282 static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld=GridImp::dimensionworld;
283
285 typedef typename GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!");
287
288
289 //===========================================================
293 //===========================================================
294
296 int level () const { return realEntity.level(); }
297
299 PartitionType partitionType () const { return realEntity.partitionType(); }
300
302 Geometry geometry () const { return realEntity.geometry(); }
303
307 GeometryType type () const { return realEntity.type(); }
308
312 EntitySeed seed () const { return realEntity.seed(); }
314
315 //===========================================================
319 //===========================================================
320
326 template<int cc> int count () const { return realEntity.template count<cc>(); }
327
338 template< int codim >
339 typename Codim< codim >::EntityPointer subEntity ( int i ) const
340 {
341 return realEntity.template subEntity< codim >( i );
342 }
343
358 DUNE_DEPRECATED_MSG("Use LeafGridView.ibegin(Entity) instead.")
359 {
360 return realEntity.ileafbegin();
361 }
362
373 DUNE_DEPRECATED_MSG("Use LeafGridView.iend(Entity) instead.")
374 {
375 return realEntity.ileafend();
376 }
377
392 DUNE_DEPRECATED_MSG("Use LevelGridView.ibegin(Entity) instead.")
393 {
394 return realEntity.ilevelbegin();
395 }
396
407 DUNE_DEPRECATED_MSG("Use LevelGridView.iend(Entity) instead.")
408 {
409 return realEntity.ilevelend();
410 }
411
422 {
423 return realEntity.father();
424 }
425
429 bool hasFather () const
430 {
431 return realEntity.hasFather();
432 }
433
435 bool isLeaf () const
436 {
437 return realEntity.isLeaf();
438 }
439
443 bool isRegular() const { return realEntity.isRegular(); }
444
470 LocalGeometry geometryInFather () const { return realEntity.geometryInFather(); }
471
483 HierarchicIterator hbegin (int maxlevel) const
484 {
485 return realEntity.hbegin(maxlevel);
486 }
487
495 HierarchicIterator hend (int maxlevel) const
496 {
497 return realEntity.hend(maxlevel);
498 }
499
502 bool isNew () const { return realEntity.isNew(); }
503
508 bool mightVanish () const { return realEntity.mightVanish(); }
509
510 //===========================================================
514 //===========================================================
517 bool hasBoundaryIntersections () const { return realEntity.hasBoundaryIntersections(); }
518
520 explicit Entity(const EntityImp<0,dim,GridImp> & e) : realEntity(e) {}
521
523
524
525 protected:
526 // needed to make copy constructor from EntityPointer work for any iterator
527 template< class, class > friend class Dune::EntityPointer;
528
530 Entity(const Entity& rhs) : realEntity(rhs.realEntity) {}
532 Entity & operator = (const Entity& rhs) {
533 realEntity = rhs.realEntity;
534 return *this;
535 }
536
537 };
538
539
540 //********************************************************************
551 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
553 {
554 public:
556 enum { codimension=cd };
557
559 enum { dimension=dim };
560
562 enum { mydimension=dim-cd };
563
565 static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld=GridImp::dimensionworld;
566
568 typedef typename GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!");
569
571 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
572
574 typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
575
579 GeometryType type () const { return asImp().geometry().type(); }
580
581 private:
583 EntityImp<cd,dim,GridImp>& asImp ()
584 {
585 return static_cast<EntityImp<cd,dim,GridImp>&>(*this);
586 }
587 const EntityImp<cd,dim,GridImp>& asImp () const
588 {
589 return static_cast<const EntityImp<cd,dim,GridImp>&>(*this);
590 }
591 }; // end EntityDefaultImplementation
592
593 //********************************************************************
604 template<int dim, class GridImp, template<int,int,class> class EntityImp>
605 class EntityDefaultImplementation <0,dim,GridImp,EntityImp>
606 {
607 public:
609 enum { codimension=0 };
610
612 enum { dimension=dim };
613
615 enum { mydimension=dim };
616
618 static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld=GridImp::dimensionworld;
619
621 typedef typename GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!");
622
624 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
625
627 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
628
632 bool isRegular() const { return true; }
633
637 GeometryType type () const { return asImp().geometry().type(); }
638
641 bool isNew () const { return false; }
642
645 bool mightVanish () const { return false; }
646
652 {
653 {
654 typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
655 IntersectionIterator end = asImp().ilevelend();
656 for(IntersectionIterator it = asImp().ilevelbegin(); it != end; ++it)
657 {
658 if( it->boundary() ) return true;
659 }
660 }
661
662 {
663 typedef typename GridImp::LeafIntersectionIterator IntersectionIterator;
664 IntersectionIterator end = asImp().ileafend();
665 for(IntersectionIterator it = asImp().ileafbegin(); it != end; ++it)
666 {
667 if( it->boundary() ) return true;
668 }
669 }
670
671 return false;
672 }
673
674 private:
675 // Barton-Nackman trick
676 EntityImp<0,dim,GridImp>& asImp () { return static_cast<EntityImp<0,dim,GridImp>&>(*this); }
677 const EntityImp<0,dim,GridImp>& asImp () const { return static_cast<const EntityImp<0,dim,GridImp>&>(*this); }
678 };
679
680}
681
682#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:641
static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld
know your own dimension of world
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary, this implementation uses the Level- and Leaf...
Definition: entity.hh:651
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:637
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt()
Definition: entity.hh:645
Default Implementations for EntityImp.
Definition: entity.hh:553
static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld
know your own dimension of world
GridImp::template Codim< cd >::EntityPointer EntityPointer
The corresponding entity seed (for storage of entities)
Definition: entity.hh:574
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:571
GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!")
define type used for coordinates in grid module
Definition: entity.hh:568
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:579
Wrapper class for pointers to entities.
Definition: entitypointer.hh:92
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:307
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt(). If the method returns false,...
Definition: entity.hh:508
GridImp::template Codim< 0 >::Geometry Geometry
The geometry type of this entity.
Definition: entity.hh:232
LeafIntersectionIterator ileafbegin() const
Access to intersections with neighboring leaf elements. A neighbor is an entity of codimension 0 whic...
Definition: entity.hh:357
Entity(const EntityImp< 0, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:520
LeafIntersectionIterator ileafend() const
Reference to an IntersectionIterator one past the last intersection.
Definition: entity.hh:372
Entity(const Entity &rhs)
Definition: entity.hh:530
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary.
Definition: entity.hh:517
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:312
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:302
GridImp::LeafIntersectionIterator LeafIntersectionIterator
The Dune::IntersectionIterator type for the LeafGridView.
Definition: entity.hh:259
bool hasFather() const
Return true if entity has a father entity which can be accessed using the father() method.
Definition: entity.hh:429
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:235
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:244
HierarchicIterator hend(int maxlevel) const
Returns iterator to one past the last son element.
Definition: entity.hh:495
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: entity.hh:502
bool isLeaf() const
Returns true if the entity is contained in the leaf grid.
Definition: entity.hh:435
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:299
const Implementation & impl() const
Return const reference to the real implementation.
Definition: entity.hh:218
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:443
int count() const
Number of subentities with codimension cc.
Definition: entity.hh:326
EntityPointer father() const
Inter-level access to father entity on the next-coarser grid. The given entity resulted directly from...
Definition: entity.hh:421
LocalGeometry geometryInFather() const
Provides information how this element has been subdivided from its father element.
Definition: entity.hh:470
static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld
Know the world dimension.
HierarchicIterator hbegin(int maxlevel) const
Inter-level access to elements that resulted from (recursive) subdivision of this element.
Definition: entity.hh:483
GridImp::LevelIntersectionIterator LevelIntersectionIterator
The Dune::IntersectionIterator type for the LevelGridView.
Definition: entity.hh:264
LevelIntersectionIterator ilevelend() const
Reference to an IntersectionIterator one past the last intersection.
Definition: entity.hh:406
Codim< codim >::EntityPointer subEntity(int i) const
Obtain a pointer to a subentity.
Definition: entity.hh:339
GridImp::template Codim< 0 >::EntityPointer EntityPointer
The codim==0 EntityPointer type.
Definition: entity.hh:254
GridImp::HierarchicIterator HierarchicIterator
The HierarchicIterator type.
Definition: entity.hh:267
LevelIntersectionIterator ilevelbegin() const
Intra-level access to intersections with neighboring elements. A neighbor is an entity of codimension...
Definition: entity.hh:391
Wrapper class for entities.
Definition: entity.hh:57
const Implementation & impl() const
Return const reference to the real implementation.
Definition: entity.hh:78
GridImp::ctype ctype DUNE_DEPRECATED_MSG("Use Geometry::ctype instead!")
coordinate type of the Grid
Definition: entity.hh:113
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:128
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:152
Entity & operator=(const Entity &rhs)
Definition: entity.hh:174
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:142
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: entity.hh:92
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:95
@ dimension
Know the grid dimension.
Definition: entity.hh:103
static const int DUNE_DEPRECATED_MSG("Use Geometry::coorddimension instead!") dimensionworld
Know the dimension of world.
int level() const
The level of this entity.
Definition: entity.hh:125
Entity(const Entity &rhs)
Definition: entity.hh:172
Implementation & impl()
Return reference to the real implementation.
Definition: entity.hh:76
@ mydimension
Dimensionality of the reference element of the entity.
Definition: entity.hh:107
@ codimension
Know your own codimension.
Definition: entity.hh:99
Entity(const EntityImp< cd, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:162
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:147
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Wrapper class for geometries.
Definition: geometry.hh:102
Definition: grid.hh:1017
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
Dune namespace.
Definition: alignment.hh:14
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)