Dune Core Modules (2.9.1)

entity.hh
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_GRID_COMMON_ENTITY_HH
6#define DUNE_GRID_COMMON_ENTITY_HH
7
8#include <type_traits>
9
10#include <dune/common/iteratorrange.hh>
12
13#include <dune/geometry/dimension.hh>
14#include <dune/geometry/referenceelements.hh>
15
16#include "grid.hh"
17#include "rangegenerators.hh"
18
19namespace Dune
20{
21
64 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
65 class Entity
66 {
67 public:
73 typedef EntityImp< cd, dim, GridImp > Implementation;
74
80 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
106 constexpr static int codimension = cd;
107
109 constexpr static int dimension = dim;
110
112 constexpr static int mydimension = dim - cd;
114
115
116
117 //===========================================================
121 //===========================================================
122
124 int level () const { return realEntity.level(); }
125
127 PartitionType partitionType () const { return realEntity.partitionType(); }
128
141 Geometry geometry () const { return realEntity.geometry(); }
142
146 GeometryType type () const { return realEntity.type(); }
147
159 unsigned int subEntities ( unsigned int codim ) const
160 {
161 return realEntity.subEntities(codim);
162 }
163
167 EntitySeed seed () const { return realEntity.seed(); }
168
170 bool operator==(const Entity& other) const
171 {
172 return realEntity.equals(other.realEntity);
173 }
174
176 bool operator!=(const Entity& other) const
177 {
178 return !realEntity.equals(other.realEntity);
179 }
180
181 Entity()
182 {}
183
185 Entity(const Entity& other)
186 : realEntity(other.realEntity)
187 {}
188
190 Entity(Entity&& other)
191 : realEntity(std::move(other.realEntity))
192 {}
193
195 Entity& operator=(const Entity& other)
196 {
197 realEntity = other.realEntity;
198 return *this;
199 }
200
203 {
204 realEntity = std::move(other.realEntity);
205 return *this;
206 }
207
209
210 //===========================================================
214 //===========================================================
215
217 Entity(const EntityImp<cd,dim,GridImp> & e) : realEntity(e) {}
218
220 Entity(EntityImp<cd,dim,GridImp> && e) : realEntity(std::move(e)) {}
221
223 };
224
239 template<int dim, class GridImp, template<int,int,class> class EntityImp>
240 class Entity <0,dim,GridImp,EntityImp>
241 {
242 public:
249 typedef EntityImp< 0, dim, GridImp > Implementation;
250
252 Implementation &impl () { return realEntity; }
254 const Implementation &impl () const { return realEntity; }
255
256 protected:
257 Implementation realEntity;
258
259 public:
260
261 //===========================================================
265 //===========================================================
266
268 typedef typename GridImp::template Codim<0>::Geometry Geometry;
269
271 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
272
280 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
281
283 template <int cd>
284 struct Codim
285 {
286 typedef typename GridImp::template Codim<cd>::Entity Entity;
287 };
288
290 typedef typename GridImp::HierarchicIterator HierarchicIterator;
291
293 constexpr static int codimension = 0;
294
296 constexpr static int dimension = dim;
297
299 constexpr static int mydimension = dim;
301
302
303 //===========================================================
307 //===========================================================
308
310 int level () const { return realEntity.level(); }
311
313 PartitionType partitionType () const { return realEntity.partitionType(); }
314
316 Geometry geometry () const { return realEntity.geometry(); }
317
329 unsigned int subEntities ( unsigned int codim ) const
330 {
331 return realEntity.subEntities(codim);
332 }
333
337 GeometryType type () const { return realEntity.type(); }
338
342 EntitySeed seed () const { return realEntity.seed(); }
343
345 bool operator==(const Entity& other) const
346 {
347 return realEntity.equals(other.realEntity);
348 }
349
351 bool operator!=(const Entity& other) const
352 {
353 return !realEntity.equals(other.realEntity);
354 }
355
356 Entity()
357 {}
358
360 Entity(const Entity& other)
361 : realEntity(other.realEntity)
362 {}
363
365 Entity(Entity&& other)
366 : realEntity(std::move(other.realEntity))
367 {}
368
370 Entity& operator=(const Entity& other)
371 {
372 realEntity = other.realEntity;
373 return *this;
374 }
375
378 {
379 realEntity = std::move(other.realEntity);
380 return *this;
381 }
382
384
385 //===========================================================
389 //===========================================================
390
401 template< int codim >
403 subEntity ( int i ) const
404 {
405 return realEntity.template subEntity< codim >( i );
406 }
407
418 Entity father () const
419 {
420 return realEntity.father();
421 }
422
426 bool hasFather () const
427 {
428 return realEntity.hasFather();
429 }
430
432 bool isLeaf () const
433 {
434 return realEntity.isLeaf();
435 }
436
440 bool isRegular() const { return realEntity.isRegular(); }
441
467 LocalGeometry geometryInFather () const { return realEntity.geometryInFather(); }
468
480 HierarchicIterator hbegin (int maxLevel) const
481 {
482 return realEntity.hbegin(maxLevel);
483 }
484
492 HierarchicIterator hend (int maxLevel) const
493 {
494 return realEntity.hend(maxLevel);
495 }
496
499 bool isNew () const { return realEntity.isNew(); }
500
505 bool mightVanish () const { return realEntity.mightVanish(); }
506
509 bool hasBoundaryIntersections () const { return realEntity.hasBoundaryIntersections(); }
510
511
512 //===========================================================
516 //===========================================================
517
519 Entity(const EntityImp<0,dim,GridImp> & e) : realEntity(e) {}
520
522 Entity(EntityImp<0,dim,GridImp> && e) : realEntity(std::move(e)) {}
523
525 };
526
527
528
529 //********************************************************************
540 template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
542 {
543 public:
545 constexpr static int codimension = cd;
546
548 constexpr static int dimension = dim;
549
551 constexpr static int mydimension = dim - cd;
552
554 typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
555
567 unsigned int subEntities ( unsigned int codim ) const
568 {
569 typedef typename std::remove_const< GridImp >::type::ctype ctype;
570 return ReferenceElements< ctype, mydimension >::general( asImp().type() ).size( codim - codimension );
571 }
572
576 GeometryType type () const { return asImp().geometry().type(); }
577
578 private:
580 EntityImp<cd,dim,GridImp>& asImp ()
581 {
582 return static_cast<EntityImp<cd,dim,GridImp>&>(*this);
583 }
584 const EntityImp<cd,dim,GridImp>& asImp () const
585 {
586 return static_cast<const EntityImp<cd,dim,GridImp>&>(*this);
587 }
588 }; // end EntityDefaultImplementation
589
590 //********************************************************************
601 template<int dim, class GridImp, template<int,int,class> class EntityImp>
602 class EntityDefaultImplementation <0,dim,GridImp,EntityImp>
603 {
604 public:
606 constexpr static int codimension = 0;
607
609 constexpr static int dimension = dim;
610
612 constexpr static int mydimension = dim;
613
615 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
616
620 bool isRegular() const { return true; }
621
633 unsigned int subEntities ( unsigned int codim ) const
634 {
635 typedef typename std::remove_const< GridImp >::type::ctype ctype;
636 return ReferenceElements< ctype, mydimension >::general( asImp().type() ).size( codim - codimension );
637 }
638
642 GeometryType type () const { return asImp().geometry().type(); }
643
646 bool isNew () const { return false; }
647
650 bool mightVanish () const { return false; }
651
657 {
658 typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
659 IntersectionIterator end = asImp().ilevelend();
660 for (IntersectionIterator it = asImp().ilevelbegin(); it != end; ++it)
661 if( it->boundary() )
662 return true;
663
664 return false;
665 }
666
667 private:
668 // Barton-Nackman trick
669 EntityImp<0,dim,GridImp>& asImp () { return static_cast<EntityImp<0,dim,GridImp>&>(*this); }
670 const EntityImp<0,dim,GridImp>& asImp () const { return static_cast<const EntityImp<0,dim,GridImp>&>(*this); }
671 };
672
674
686 template< int cd, int dim, class GridImp, template<int,int,class> class EntityImp >
688 -> decltype(referenceElement<typename GridImp::ctype,GridImp::template Codim<cd>::Geometry::mydimension>(entity.type()))
689 {
690 typedef typename GridImp::template Codim<cd>::Geometry Geo;
691 return referenceElement< typename Geo::ctype, Geo::mydimension >(entity.type());
692 }
693}
694
695#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:646
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:620
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary, this implementation uses the Level- and Leaf...
Definition: entity.hh:656
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:615
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:642
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:633
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt()
Definition: entity.hh:650
Default Implementations for EntityImp.
Definition: entity.hh:542
static constexpr int dimension
Dimension of the grid.
Definition: entity.hh:548
static constexpr int codimension
know your own codimension
Definition: entity.hh:545
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:554
static constexpr int mydimension
Know dimension of the entity.
Definition: entity.hh:551
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:576
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:567
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:337
bool mightVanish() const
Returns true, if entity might disappear during the next call to adapt(). If the method returns false,...
Definition: entity.hh:505
HierarchicIterator hend(int maxLevel) const
Returns iterator to one past the last son element.
Definition: entity.hh:492
GridImp::template Codim< 0 >::Geometry Geometry
The geometry type of this entity.
Definition: entity.hh:268
Implementation & impl()
Return reference to the real implementation.
Definition: entity.hh:252
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: entity.hh:370
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:329
Codim< codim >::Entity subEntity(int i) const
Obtain a subentity.
Definition: entity.hh:403
Entity(EntityImp< 0, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: entity.hh:522
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: entity.hh:365
Entity father() const
Inter-level access to father entity on the next-coarser grid. The given entity resulted directly from...
Definition: entity.hh:418
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: entity.hh:377
Entity(const EntityImp< 0, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:519
HierarchicIterator hbegin(int maxLevel) const
Inter-level access to elements that resulted from (recursive) subdivision of this element.
Definition: entity.hh:480
bool hasBoundaryIntersections() const
Returns true, if entity has intersections with boundary.
Definition: entity.hh:509
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:342
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: entity.hh:360
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:316
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: entity.hh:345
bool hasFather() const
Return true if entity has a father entity which can be accessed using the father() method.
Definition: entity.hh:426
int level() const
The level of this entity.
Definition: entity.hh:310
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:271
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:280
bool isNew() const
Returns true, if the entity has been created during the last call to adapt()
Definition: entity.hh:499
bool isLeaf() const
Returns true if the entity is contained in the leaf grid.
Definition: entity.hh:432
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:313
const Implementation & impl() const
Return const reference to the real implementation.
Definition: entity.hh:254
bool isRegular() const
Returns true if element is of regular type in red/green type refinement. In bisection or hanging node...
Definition: entity.hh:440
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: entity.hh:351
LocalGeometry geometryInFather() const
Provides information how this element has been subdivided from its father element.
Definition: entity.hh:467
EntityImp< 0, dim, GridImp > Implementation
Type of underlying implementation.
Definition: entity.hh:249
GridImp::HierarchicIterator HierarchicIterator
The HierarchicIterator type.
Definition: entity.hh:290
Wrapper class for entities.
Definition: entity.hh:66
const Implementation & impl() const
access to the underlying implementation
Definition: entity.hh:86
bool operator!=(const Entity &other) const
Compares two entities for inequality.
Definition: entity.hh:176
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:159
PartitionType partitionType() const
Partition type of this entity.
Definition: entity.hh:127
static constexpr int mydimension
Dimensionality of the reference element of the entity.
Definition: entity.hh:112
Entity & operator=(Entity &&other)
Move assignment operator from an existing entity.
Definition: entity.hh:202
Entity(Entity &&other)
Move constructor from an existing entity.
Definition: entity.hh:190
EntitySeed seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: entity.hh:167
Geometry geometry() const
obtain geometric realization of the entity
Definition: entity.hh:141
Entity & operator=(const Entity &other)
Copy assignment operator from an existing entity.
Definition: entity.hh:195
GridImp::template Codim< cd >::Geometry Geometry
The corresponding geometry type.
Definition: entity.hh:100
GridImp::template Codim< cd >::EntitySeed EntitySeed
The corresponding entity seed (for storage of entities)
Definition: entity.hh:103
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:687
int level() const
The level of this entity.
Definition: entity.hh:124
static constexpr int codimension
Know your own codimension.
Definition: entity.hh:106
static constexpr int dimension
Know the grid dimension.
Definition: entity.hh:109
Implementation & impl()
access to the underlying implementation
Definition: entity.hh:80
Entity(const Entity &other)
Copy constructor from an existing entity.
Definition: entity.hh:185
bool operator==(const Entity &other) const
Compares two entities for equality.
Definition: entity.hh:170
Entity(const EntityImp< cd, dim, GridImp > &e)
Copy constructor from EntityImp.
Definition: entity.hh:217
EntityImp< cd, dim, GridImp > Implementation
type of underlying implementation
Definition: entity.hh:73
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:146
Entity(EntityImp< cd, dim, GridImp > &&e)
Move constructor from EntityImp.
Definition: entity.hh:220
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:126
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:24
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:198
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)