dune-grid  3.0-git
common/entity.hh
Go to the documentation of this file.
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 <dune/common/iteratorrange.hh>
7 #include <dune/common/typetraits.hh>
8 
9 #include <dune/geometry/dimension.hh>
10 
11 #include "grid.hh"
12 #include "entitypointer.hh"
13 #include "rangegenerators.hh"
14 
15 namespace Dune
16 {
17 
60  template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
61  class Entity
62  {
63 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
64  public:
65 #else
66  protected:
67  // give the GridDefaultImplementation class access to the realImp
68  friend class GridDefaultImplementation<
69  GridImp::dimension, GridImp::dimensionworld,
70  typename GridImp::ctype,
71  typename GridImp::GridFamily> ;
72 
73  // Default*GridView classes need access to intersection iterators
74  template< class > friend class DefaultLevelGridView;
75  template< class > friend class DefaultLeafGridView;
76 #endif
77  // type of underlying implementation, for internal use only
78  typedef EntityImp< cd, dim, GridImp > Implementation;
79 
81  Implementation &impl () { return realEntity; }
83  const Implementation &impl () const { return realEntity; }
84 
85  protected:
87 
88  public:
89 
90  //===========================================================
94  //===========================================================
95 
97  typedef typename GridImp::template Codim<cd>::Geometry Geometry;
98 
100  typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
101 
102  enum {
105  };
106  enum {
109  };
110  enum {
112  mydimension=dim-cd
113  };
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(); }
153 
155  bool operator==(const Entity& other) const
156  {
157  return realEntity.equals(other.realEntity);
158  }
159 
161  bool operator!=(const Entity& other) const
162  {
163  return !realEntity.equals(other.realEntity);
164  }
165 
167  {}
168 
170  Entity(const Entity& other)
171  : realEntity(other.realEntity)
172  {}
173 
175  Entity(Entity&& other)
176  : realEntity(std::move(other.realEntity))
177  {}
178 
180  Entity& operator=(const Entity& other)
181  {
182  realEntity = other.realEntity;
183  return *this;
184  }
185 
188  {
189  realEntity = std::move(other.realEntity);
190  return *this;
191  }
192 
194 
195  //===========================================================
199  //===========================================================
200 
202  Entity(const EntityImp<cd,dim,GridImp> & e) : realEntity(e) {}
203 
205  Entity(EntityImp<cd,dim,GridImp> && e) : realEntity(std::move(e)) {}
206 
208 
209  protected:
210 
211  // need to make copy constructor of EntityPointer work for any iterator
212  template< class, class > friend class Dune::EntityPointer;
213 
214  };
215 
230  template<int dim, class GridImp, template<int,int,class> class EntityImp>
231  class Entity <0,dim,GridImp,EntityImp>
232  {
233 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
234  public:
235 #else
236  protected:
237  // give the GridDefaultImplementation class access to the realImp
238  friend class GridDefaultImplementation<
239  GridImp::dimension, GridImp::dimensionworld,
240  typename GridImp::ctype,
241  typename GridImp::GridFamily> ;
242 
243  // Default*GridView classes need access to intersection iterators
244  template< class > friend class DefaultLevelGridView;
245  template< class > friend class DefaultLeafGridView;
246 #endif
247  // type of underlying implementation, for internal use only
248  typedef EntityImp< 0, dim, GridImp > Implementation;
249 
253  const Implementation &impl () const { return realEntity; }
254 
255  protected:
257 
258  public:
259 
260  //===========================================================
264  //===========================================================
265 
267  typedef typename GridImp::template Codim<0>::Geometry Geometry;
268 
270  typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
271 
279  typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
280 
282  template <int cd>
283  struct Codim
284  {
285  typedef typename GridImp::template Codim<cd>::Entity Entity;
286  };
287 
289  typedef typename GridImp::HierarchicIterator HierarchicIterator;
290 
291  enum {
294  };
295  enum {
298  };
299  enum {
302  };
304 
305 
306  //===========================================================
310  //===========================================================
311 
313  int level () const { return realEntity.level(); }
314 
316  PartitionType partitionType () const { return realEntity.partitionType(); }
317 
319  Geometry geometry () const { return realEntity.geometry(); }
320 
324  GeometryType type () const { return realEntity.type(); }
325 
329  EntitySeed seed () const { return realEntity.seed(); }
330 
332  bool operator==(const Entity& other) const
333  {
334  return realEntity.equals(other.realEntity);
335  }
336 
338  bool operator!=(const Entity& other) const
339  {
340  return !realEntity.equals(other.realEntity);
341  }
342 
344  {}
345 
347  Entity(const Entity& other)
348  : realEntity(other.realEntity)
349  {}
350 
352  Entity(Entity&& other)
353  : realEntity(std::move(other.realEntity))
354  {}
355 
357  Entity& operator=(const Entity& other)
358  {
359  realEntity = other.realEntity;
360  return *this;
361  }
362 
365  {
366  realEntity = std::move(other.realEntity);
367  return *this;
368  }
369 
371 
372  //===========================================================
376  //===========================================================
377 
383  unsigned int subEntities(unsigned int codim) const
384  {
385  return realEntity.subEntities(codim);
386  }
387 
398  template< int codim >
399  typename Codim< codim >::Entity
400  subEntity ( int i ) const
401  {
402  return realEntity.template subEntity< codim >( i );
403  }
404 
415  Entity father () const
416  {
417  return realEntity.father();
418  }
419 
423  bool hasFather () const
424  {
425  return realEntity.hasFather();
426  }
427 
429  bool isLeaf () const
430  {
431  return realEntity.isLeaf();
432  }
433 
437  bool isRegular() const { return realEntity.isRegular(); }
438 
464  LocalGeometry geometryInFather () const { return realEntity.geometryInFather(); }
465 
477  HierarchicIterator hbegin (int maxLevel) const
478  {
479  return realEntity.hbegin(maxLevel);
480  }
481 
489  HierarchicIterator hend (int maxLevel) const
490  {
491  return realEntity.hend(maxLevel);
492  }
493 
496  bool isNew () const { return realEntity.isNew(); }
497 
502  bool mightVanish () const { return realEntity.mightVanish(); }
503 
506  bool hasBoundaryIntersections () const { return realEntity.hasBoundaryIntersections(); }
507 
508 
509  //===========================================================
513  //===========================================================
514 
516  Entity(const EntityImp<0,dim,GridImp> & e) : realEntity(e) {}
517 
519  Entity(EntityImp<0,dim,GridImp> && e) : realEntity(std::move(e)) {}
520 
522 
523  protected:
524  // needed to make copy constructor from EntityPointer work for any iterator
525  template< class, class > friend class Dune::EntityPointer;
526 
527  };
528 
529 
530 
531  //********************************************************************
542  template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
544  {
545  public:
547  enum { codimension=cd };
548 
550  enum { dimension=dim };
551 
553  enum { mydimension=dim-cd };
554 
556  typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
557 
561  GeometryType type () const { return asImp().geometry().type(); }
562 
563  private:
565  EntityImp<cd,dim,GridImp>& asImp ()
566  {
567  return static_cast<EntityImp<cd,dim,GridImp>&>(*this);
568  }
569  const EntityImp<cd,dim,GridImp>& asImp () const
570  {
571  return static_cast<const EntityImp<cd,dim,GridImp>&>(*this);
572  }
573  }; // end EntityDefaultImplementation
574 
575  //********************************************************************
586  template<int dim, class GridImp, template<int,int,class> class EntityImp>
587  class EntityDefaultImplementation <0,dim,GridImp,EntityImp>
588  {
589  public:
591  enum { codimension=0 };
592 
594  enum { dimension=dim };
595 
597  enum { mydimension=dim };
598 
600  typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
601 
605  bool isRegular() const { return true; }
606 
610  GeometryType type () const { return asImp().geometry().type(); }
611 
614  bool isNew () const { return false; }
615 
618  bool mightVanish () const { return false; }
619 
625  {
626  typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
627  IntersectionIterator end = asImp().ilevelend();
628  for (IntersectionIterator it = asImp().ilevelbegin(); it != end; ++it)
629  if( it->boundary() )
630  return true;
631 
632  return false;
633  }
634 
635  private:
636  // Barton-Nackman trick
637  EntityImp<0,dim,GridImp>& asImp () { return static_cast<EntityImp<0,dim,GridImp>&>(*this); }
638  const EntityImp<0,dim,GridImp>& asImp () const { return static_cast<const EntityImp<0,dim,GridImp>&>(*this); }
639  };
640 
641 }
642 
643 #endif // DUNE_GRID_ENTITY_HH
grid.hh
Different resources needed by all grid implementations.
Dune::Entity< 0, dim, GridImp, EntityImp >::isLeaf
bool isLeaf() const
Returns true if the entity is contained in the leaf grid.
Definition: common/entity.hh:429
Dune::Entity< 0, dim, GridImp, EntityImp >::operator=
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: common/entity.hh:357
Dune::Entity< 0, dim, GridImp, EntityImp >::isRegular
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: common/entity.hh:437
Dune::Entity::Entity
Entity(EntityImp< cd, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: common/entity.hh:205
rangegenerators.hh
Dune::EntityDefaultImplementation< 0, dim, GridImp, EntityImp >::type
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/entity.hh:610
Dune
Include standard header files.
Definition: agrid.hh:59
Dune::Entity< 0, dim, GridImp, EntityImp >::subEntity
Codim< codim >::Entity subEntity(int i) const
Obtain a subentity.
Definition: common/entity.hh:400
Dune::Entity< 0, dim, GridImp, EntityImp >::mightVanish
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt(). If the method returns false,...
Definition: common/entity.hh:502
Dune::Entity< 0, dim, GridImp, EntityImp >::father
Entity father() const
Inter-level access to father entity on the next-coarser grid. The given entity resulted directly from...
Definition: common/entity.hh:415
Dune::Entity< 0, dim, GridImp, EntityImp >::Codim::Entity
GridImp::template Codim< cd >::Entity Entity
Definition: common/entity.hh:285
Dune::Entity< 0, dim, GridImp, EntityImp >::subEntities
unsigned int subEntities(unsigned int codim) const
Number of subentities with codimension codim.
Definition: common/entity.hh:383
Dune::Entity::seed
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: common/entity.hh:152
Dune::Entity< 0, dim, GridImp, EntityImp >::LocalGeometry
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
The geometry type of this entity when the geometry is expressed embedded in the father element.
Definition: common/entity.hh:279
Dune::Entity::codimension
Know your own codimension.
Definition: common/entity.hh:104
Dune::Entity< codim, dim, Grid, EntityImp >::Implementation
EntityImp< cd, dim, Grid > Implementation
Definition: common/entity.hh:78
Dune::EntityDefaultImplementation< 0, dim, GridImp, EntityImp >::mightVanish
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt()
Definition: common/entity.hh:618
Dune::IntersectionIterator
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:345
Dune::Entity::Entity
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: common/entity.hh:170
Dune::EntityDefaultImplementation::codimension
Definition: common/entity.hh:547
Dune::Entity< 0, dim, GridImp, EntityImp >::HierarchicIterator
GridImp::HierarchicIterator HierarchicIterator
The HierarchicIterator type.
Definition: common/entity.hh:289
Dune::Entity< 0, dim, GridImp, EntityImp >::Entity
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: common/entity.hh:352
Dune::Entity< 0, dim, GridImp, EntityImp >::seed
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: common/entity.hh:329
Dune::Entity< 0, dim, GridImp, EntityImp >::isNew
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: common/entity.hh:496
Dune::Entity< 0, dim, GridImp, EntityImp >::operator==
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: common/entity.hh:332
Dune::EntityDefaultImplementation::type
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/entity.hh:561
Dune::PartitionType
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Dune::VTK::GeometryType
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Dune::Entity< 0, dim, GridImp, EntityImp >::hasBoundaryIntersections
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary.
Definition: common/entity.hh:506
Dune::EntityDefaultImplementation< 0, dim, GridImp, EntityImp >::isNew
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: common/entity.hh:614
Dune::Entity::EntitySeed
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: common/entity.hh:100
Dune::Entity< 0, dim, GridImp, EntityImp >::hasFather
bool hasFather() const
Return true if entity has a father entity which can be accessed using the father() method.
Definition: common/entity.hh:423
Dune::Entity< 0, dim, GridImp, EntityImp >::Geometry
GridImp::template Codim< 0 >::Geometry Geometry
The geometry type of this entity.
Definition: common/entity.hh:267
Dune::Entity< 0, dim, GridImp, EntityImp >::type
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/entity.hh:324
Dune::EntityDefaultImplementation< 0, dim, GridImp, EntityImp >::EntitySeed
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: common/entity.hh:600
Dune::Entity
Wrapper class for entities.
Definition: common/entity.hh:61
Dune::EntityDefaultImplementation::dimension
Definition: common/entity.hh:550
Dune::Entity< 0, dim, GridImp, EntityImp >::impl
const Implementation & impl() const
Return const reference to the real implementation.
Definition: common/entity.hh:253
Dune::Entity< 0, dim, GridImp, EntityImp >::Entity
Entity(const EntityImp< 0, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: common/entity.hh:516
Dune::Entity< 0, dim, GridImp, EntityImp >::Entity
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: common/entity.hh:347
Dune::Entity< 0, dim, GridImp, EntityImp >::geometry
Geometry geometry() const
obtain geometric realization of the entity
Definition: common/entity.hh:319
Dune::Entity::operator!=
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: common/entity.hh:161
Dune::Entity< 0, dim, GridImp, EntityImp >::realEntity
Implementation realEntity
Definition: common/entity.hh:256
Dune::Entity::Geometry
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: common/entity.hh:97
Dune::Entity< 0, dim, GridImp, EntityImp >::level
int level() const
The level of this entity.
Definition: common/entity.hh:313
Dune::EntityDefaultImplementation< 0, dim, GridImp, EntityImp >::hasBoundaryIntersections
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary, this implementation uses the Level- and Leaf...
Definition: common/entity.hh:624
Dune::EntityDefaultImplementation< 0, dim, GridImp, EntityImp >::isRegular
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: common/entity.hh:605
Dune::GridDefaultImplementation
Definition: common/geometry.hh:24
Dune::Entity::operator=
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: common/entity.hh:180
Dune::Entity< 0, dim, GridImp, EntityImp >::geometryInFather
LocalGeometry geometryInFather() const
Provides information how this element has been subdivided from its father element.
Definition: common/entity.hh:464
Dune::Entity< 0, dim, GridImp, EntityImp >::EntitySeed
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: common/entity.hh:270
Dune::Entity::Entity
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: common/entity.hh:175
Dune::Entity< 0, dim, GridImp, EntityImp >::partitionType
PartitionType partitionType() const
Partition type of this entity.
Definition: common/entity.hh:316
Dune::Entity::realEntity
Implementation realEntity
Definition: common/entity.hh:86
Dune::Entity< 0, dim, GridImp, EntityImp >::hbegin
HierarchicIterator hbegin(int maxLevel) const
Inter-level access to elements that resulted from (recursive) subdivision of this element.
Definition: common/entity.hh:477
Dune::EntityDefaultImplementation::EntitySeed
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: common/entity.hh:556
Dune::Entity::impl
Implementation & impl()
Return reference to the real implementation.
Definition: common/entity.hh:81
Dune::Entity::Entity
Entity(const EntityImp< cd, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: common/entity.hh:202
Dune::Entity< 0, dim, GridImp, EntityImp >::operator!=
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: common/entity.hh:338
Dune::Entity::level
int level() const
The level of this entity.
Definition: common/entity.hh:125
Dune::Entity< 0, dim, GridImp, EntityImp >::Entity
Entity()
Definition: common/entity.hh:343
Dune::Entity::type
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: common/entity.hh:147
Dune::DefaultLevelGridView
Definition: defaultgridview.hh:16
Dune::Entity::geometry
Geometry geometry() const
obtain geometric realization of the entity
Definition: common/entity.hh:142
Dune::Entity< 0, dim, GridImp, EntityImp >::operator=
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: common/entity.hh:364
Dune::Entity::Entity
Entity()
Definition: common/entity.hh:166
entitypointer.hh
Wrapper and interface class for a static iterator (EntityPointer)
Dune::Entity::operator==
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: common/entity.hh:155
Dune::Entity::impl
const Implementation & impl() const
Return const reference to the real implementation.
Definition: common/entity.hh:83
Dune::DefaultLeafGridView
Definition: defaultgridview.hh:19
Dune::Entity< 0, dim, GridImp, EntityImp >::hend
HierarchicIterator hend(int maxLevel) const
Returns iterator to one past the last son element.
Definition: common/entity.hh:489
Dune::Entity::dimension
Know the grid dimension.
Definition: common/entity.hh:108
Dune::Entity::mydimension
Dimensionality of the reference element of the entity.
Definition: common/entity.hh:112
Dune::Entity::partitionType
PartitionType partitionType() const
Partition type of this entity.
Definition: common/entity.hh:128
Dune::EntityPointer
Wrapper class for pointers to entities.
Definition: common/entitypointer.hh:113
Dune::Entity::operator=
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: common/entity.hh:187
Dune::Entity< 0, dim, GridImp, EntityImp >::Entity
Entity(EntityImp< 0, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: common/entity.hh:519
Dune::EntityDefaultImplementation::mydimension
Definition: common/entity.hh:553
Dune::EntityDefaultImplementation
Default Implementations for EntityImp.
Definition: common/entity.hh:543