3 #ifndef DUNE_FOAMGRID_ENTITY_HH
4 #define DUNE_FOAMGRID_ENTITY_HH
13 #include <dune/common/version.hh>
15 #include <dune/geometry/type.hh>
16 #include <dune/grid/common/gridenums.hh>
17 #include <dune/grid/common/grid.hh>
27 template<
int codim,
int dimentity,
class Gr
idImp>
30 template<
int codim,
class Gr
idImp>
31 class FoamGridEntityPointer;
33 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
34 class FoamGridLevelIterator;
36 template<
class Gr
idImp>
37 class FoamGridLevelIntersectionIterator;
39 template<
class Gr
idImp>
40 class FoamGridLeafIntersectionIterator;
42 template<
class Gr
idImp>
43 class FoamGridHierarchicIterator;
51 template<
int codim,
int dimgr
id,
class Gr
idImp>
53 public EntityDefaultImplementation <codim, dimgrid, GridImp, FoamGridEntity>
55 template <
class Gr
idImp_>
58 template <
class Gr
idImp_>
61 template <
class Gr
idImp_>
64 template <
class Gr
idImp_>
72 typedef typename GridImp::ctype ctype;
74 enum{dimworld = GridImp::dimensionworld};
78 typedef typename GridImp::template Codim<codim>::Geometry
Geometry;
81 typedef typename GridImp::template Codim<codim>::EntitySeed
EntitySeed;
104 if (
this != &original)
121 return target_->partitionType();
128 template<
int cc>
int count ()
const{
129 return target_->template count<cc>();
137 std::array<FieldVector<ctype, dimworld>, dimgrid-codim+1> coordinates;
138 assert(dimgrid-codim+1 ==
target_->corners() &&
"Target entity is not a simplex!");
139 for (
int i=0; i<
target_->corners(); i++)
140 coordinates[i] =
target_->corner(i);
180 template<
class Gr
idImp>
182 public EntityDefaultImplementation<0, 2, GridImp, FoamGridEntity>
185 enum {dimworld = GridImp::dimensionworld};
186 enum {dimgrid = GridImp::dimension};
190 typedef typename GridImp::ctype ctype;
194 typedef typename GridImp::template Codim<0>::Geometry
Geometry;
208 typedef typename GridImp::template Codim<0>::EntitySeed
EntitySeed;
238 if (
this != &original)
255 return InteriorEntity;
263 std::array<FieldVector<ctype, dimworld>, dimgrid+1> coordinates;
264 assert(dimgrid+1 ==
target_->corners() &&
"Target entity is not a simplex!");
265 for (
int i=0; i<
target_->corners(); i++)
266 coordinates[i] =
target_->vertex_[i]->pos_;
283 static_assert(0<=cc && cc<=2,
"Only codimensions with 0 <= cc <= 2 are valid!");
284 return (cc==0) ? 1 : 3;
289 unsigned int count (
unsigned int codim)
const
291 assert(0<=codim && codim<=2);
292 return (codim==0) ? 1 : 3;
301 assert(0<=codim && codim<=2);
302 return (codim==0) ? 1 : 3;
307 int subId (
int i,
unsigned int codim)
const {
308 assert(0<=codim && codim<=dimgrid);
313 return target_->facet_[i]->id_;
315 return target_->vertex_[i]->id_;
317 DUNE_THROW(GridError,
"Non-existing codimension requested!");
322 typename std::enable_if<codim==0, typename Codim<0>::Entity>
::type
331 typename std::enable_if<codim==1, typename Codim<1>::Entity>
::type
334 assert(i==0 || i==1 || i==2);
340 typename std::enable_if<codim==2, typename Codim<2>::Entity>
::type
343 assert(i==0 || i==1 || i==2);
413 DUNE_THROW(GridError,
"There is no father Element.");
416 if(
target_->type().isTriangle()){
427 ctype mapping[4][3][2] ={
428 { {0.0,0.0}, {0.5,0.0}, {0.0,0.5} },
429 { {1.0,0.0}, {0.5,0.5}, {0.5,0.0} },
430 { {0.0,1.0}, {0.0,0.5}, {0.5,0.5} },
431 { {0.5,0.0}, {0.5,0.5}, {0.0,0.5} }
434 std::array<FieldVector<ctype, dimgrid>, 3> coordinates;
436 for(
int corner=0; corner <3; ++corner)
437 for(
int entry=0; entry <2; ++entry)
438 coordinates[corner][entry]=
439 mapping[
target_->refinementIndex_][corner][entry];
445 DUNE_THROW(NotImplemented,
"geometryInFather only supported for triangles!");
460 if (
level()<=maxLevel && !isLeaf())
461 for (std::size_t i=0; i<
target_->nSons(); i++)
462 it.elemStack.push(
target_->sons_[i]);
464 it.virtualEntity_.impl().setToTarget((it.elemStack.empty())
465 ?
nullptr : it.elemStack.top());
504 template<
class Gr
idImp>
506 public EntityDefaultImplementation<0, 1, GridImp, FoamGridEntity>
509 enum {dimworld = GridImp::dimensionworld};
510 enum {dimgrid = GridImp::dimension};
514 typedef typename GridImp::ctype ctype;
518 typedef typename GridImp::template Codim<0>::Geometry
Geometry;
532 typedef typename GridImp::template Codim<0>::EntitySeed
EntitySeed;
561 if (
this != &original)
578 return InteriorEntity;
586 std::array<FieldVector<ctype, dimworld>, dimgrid+1> coordinates;
587 assert(dimgrid+1 ==
target_->corners() &&
"Target entity is not a simplex!");
588 for (
int i=0; i<
target_->corners(); i++)
589 coordinates[i] =
target_->corner(i);
606 static_assert(0<=cc && cc<=1,
"Only codimensions with 0 <= cc <= 1 are valid!");
607 return (cc==0) ? 1 : 2;
612 unsigned int count (
unsigned int codim)
const
614 assert(0<=codim && codim<=1);
615 return (codim==0) ? 1 : 2;
624 assert(0<=codim && codim<=1);
625 return (codim==0) ? 1 : 2;
630 int subId (
int i,
unsigned int codim)
const {
631 assert(0<=codim && codim<=1);
636 return target_->vertex_[i]->id_;
638 DUNE_THROW(GridError,
"Non-existing codimension requested!");
643 typename std::enable_if<codim==0, typename Codim<0>::Entity>
::type
652 typename std::enable_if<codim==1, typename Codim<1>::Entity>
::type
655 assert(i==0 || i==1);
725 DUNE_THROW(GridError,
"There is no father Element.");
739 ctype mapping[2][2] = {{0.0, 0.5}, {0.5, 1.0}};
741 std::array<FieldVector<ctype, dimgrid>, 2> coordinates;
743 for(
int corner=0; corner <2; ++corner)
744 coordinates[corner][0] = mapping[
target_->refinementIndex_][corner];
751 DUNE_THROW(NotImplemented,
"geometryInFather only supported for lines!");
765 if (
level()<=maxLevel && !isLeaf())
766 for (std::size_t i=0; i<
target_->nSons(); i++)
767 it.elemStack.push(
target_->sons_[i]);
769 it.virtualEntity_.impl().setToTarget((it.elemStack.empty())
770 ?
nullptr : it.elemStack.top());
The FoamGridGeometry class.
Element specialization of FoamGridEntityImp. Element is a grid entity of topological codimension 0 an...
Definition: foamgridelements.hh:18
The implementation of entities in a FoamGrid.
Definition: foamgridentity.hh:54
friend class FoamGridGlobalIdSet
Definition: foamgridentity.hh:65
Geometry geometry() const
geometry of this entity
Definition: foamgridentity.hh:134
FoamGridEntity & operator=(const FoamGridEntity &original)
Definition: foamgridentity.hh:102
GridImp::template Codim< codim >::Geometry Geometry
Definition: foamgridentity.hh:78
void setToTarget(const FoamGridEntityImp< dimgrid-codim, dimgrid, dimworld, ctype > *target)
Definition: foamgridentity.hh:155
int level() const
level of this element
Definition: foamgridentity.hh:113
bool equals(const Dune::FoamGridEntity< codim, dimgrid, GridImp > &other) const
equality
Definition: foamgridentity.hh:161
int count() const
Definition: foamgridentity.hh:128
FoamGridEntity(const FoamGridEntity &original)
Copy constructor.
Definition: foamgridentity.hh:91
PartitionType partitionType() const
The partition type for parallel computing.
Definition: foamgridentity.hh:120
EntitySeed seed() const
Create EntitySeed.
Definition: foamgridentity.hh:146
FoamGridEntity()
Default constructor.
Definition: foamgridentity.hh:96
friend class FoamGridLocalIdSet
Definition: foamgridentity.hh:62
const FoamGridEntityImp< dimgrid-codim, dimgrid, dimworld, ctype > * target_
Definition: foamgridentity.hh:151
GeometryType type() const
return the entity's type
Definition: foamgridentity.hh:167
GridImp::template Codim< codim >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: foamgridentity.hh:81
FoamGridEntity(const FoamGridEntityImp< dimgrid-codim, dimgrid, dimworld, ctype > *target)
Constructor for an entity in a given grid level.
Definition: foamgridentity.hh:86
Definition: foamgridentitypointer.hh:20
Definition: foamgridintersectioniterators.hh:239
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: foamgridintersectioniterators.hh:28
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: foamgridhierarchiciterator.hh:24
FoamGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: foamgridentity.hh:348
unsigned int subEntities(unsigned int codim) const
Definition: foamgridentity.hh:299
PartitionType partitionType() const
The partition type for parallel computing.
Definition: foamgridentity.hh:254
FoamGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: foamgridentity.hh:354
FoamGridEntity(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *hostEntity)
Constructor for an entity in a given grid level.
Definition: foamgridentity.hh:220
FoamGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: foamgridentity.hh:205
FoamGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: foamgridentity.hh:369
bool equals(const Dune::FoamGridEntity< 0, dimgrid, GridImp > &other) const
equality
Definition: foamgridentity.hh:490
std::enable_if< codim==0, typename Codim< 0 >::Entity >::type subEntity(int i) const
Access to codim 0 subentities.
Definition: foamgridentity.hh:323
GridImp::template Codim< 0 >::Geometry Geometry
Definition: foamgridentity.hh:194
int subId(int i, unsigned int codim) const
Return index of sub entity with codim = cc and local number i.
Definition: foamgridentity.hh:307
FoamGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: foamgridentity.hh:472
FoamGridHierarchicIterator< GridImp > hbegin(int maxLevel) const
Inter-level access to son elements on higher levels<=maxlevel. This is provided for sparsely stored n...
Definition: foamgridentity.hh:455
Geometry geometry() const
Geometry of this entity.
Definition: foamgridentity.hh:260
const FoamGridEntityImp< dimgrid, dimgrid,dimworld, ctype > * target_
pointer to the implementation
Definition: foamgridentity.hh:499
FoamGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: foamgridentity.hh:202
FoamGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: foamgridentity.hh:360
GridImp::Traits::template Codim< 0 >::Entity Entity
Definition: foamgridentity.hh:216
bool hasFather() const
Return true if this element has a father element.
Definition: foamgridentity.hh:380
void setToTarget(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *target)
Make this class point to a new FoamGridEntityImp object.
Definition: foamgridentity.hh:484
std::enable_if< codim==1, typename Codim< 1 >::Entity >::type subEntity(int i) const
Access to codim 1 subentities.
Definition: foamgridentity.hh:332
FoamGridEntity()
Default constructor.
Definition: foamgridentity.hh:231
std::enable_if< codim==2, typename Codim< 2 >::Entity >::type subEntity(int i) const
Access to codim 2 subentities.
Definition: foamgridentity.hh:341
unsigned int count(unsigned int codim) const
Return the number of subEntities of codimension cc.
Definition: foamgridentity.hh:289
FoamGridEntity(const FoamGridEntity &original)
Copy constructor.
Definition: foamgridentity.hh:226
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: foamgridentity.hh:196
bool mightVanish() const
Definition: foamgridentity.hh:389
Entity father() const
Definition: foamgridentity.hh:396
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: foamgridentity.hh:409
bool isNew() const
Definition: foamgridentity.hh:384
EntitySeed seed() const
Create EntitySeed.
Definition: foamgridentity.hh:272
FoamGridEntity & operator=(const FoamGridEntity &original)
Definition: foamgridentity.hh:236
int count() const
Return the number of subEntities of codimension cc.
Definition: foamgridentity.hh:281
int level() const
Level of this element.
Definition: foamgridentity.hh:247
bool isLeaf() const
returns true if Entity has NO children
Definition: foamgridentity.hh:375
GeometryType type() const
return the entity's type
Definition: foamgridentity.hh:496
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: foamgridentity.hh:208
FoamGridLevelIntersectionIterator< GridImp > LevelIntersectionIterator
The Iterator over intersections on this level.
Definition: foamgridentity.hh:199
GridImp::Traits::template Codim< codim >::Entity Entity
Definition: foamgridentity.hh:213
const FoamGridEntityImp< dimgrid, dimgrid,dimworld, ctype > * target_
pointer to the implementation
Definition: foamgridentity.hh:804
void setToTarget(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *target)
Make this class point to a new FoamGridEntityImp object.
Definition: foamgridentity.hh:789
FoamGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: foamgridentity.hh:529
FoamGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: foamgridentity.hh:672
bool isNew() const
Definition: foamgridentity.hh:696
GridImp::Traits::template Codim< 0 >::Entity Entity
Definition: foamgridentity.hh:540
int count() const
Return the number of subEntities of codimension cc.
Definition: foamgridentity.hh:604
FoamGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: foamgridentity.hh:526
FoamGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: foamgridentity.hh:777
GridImp::template Codim< 0 >::Geometry Geometry
Definition: foamgridentity.hh:518
bool hasFather() const
Return true if this element has a father element.
Definition: foamgridentity.hh:692
Entity father() const
Definition: foamgridentity.hh:708
FoamGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: foamgridentity.hh:660
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: foamgridentity.hh:532
bool mightVanish() const
Definition: foamgridentity.hh:701
Geometry geometry() const
Geometry of this entity.
Definition: foamgridentity.hh:583
int subId(int i, unsigned int codim) const
Return index of sub entity with codim = cc and local number i.
Definition: foamgridentity.hh:630
std::enable_if< codim==1, typename Codim< 1 >::Entity >::type subEntity(int i) const
Access to codim 1 subentities.
Definition: foamgridentity.hh:653
FoamGridEntity(const FoamGridEntity &original)
Copy constructor.
Definition: foamgridentity.hh:549
FoamGridHierarchicIterator< GridImp > hbegin(int maxLevel) const
Inter-level access to son elements on higher levels<=maxlevel. This is provided for sparsely stored n...
Definition: foamgridentity.hh:760
FoamGridEntity(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *hostEntity)
Constructor for an entity in a given grid level.
Definition: foamgridentity.hh:543
FoamGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: foamgridentity.hh:666
std::enable_if< codim==0, typename Codim< 0 >::Entity >::type subEntity(int i) const
Access to codim 0 subentities.
Definition: foamgridentity.hh:644
bool isLeaf() const
returns true if Entity has NO children
Definition: foamgridentity.hh:687
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: foamgridentity.hh:721
int level() const
Level of this element.
Definition: foamgridentity.hh:570
FoamGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: foamgridentity.hh:681
bool equals(const Dune::FoamGridEntity< 0, dimgrid, GridImp > &other) const
equality
Definition: foamgridentity.hh:795
EntitySeed seed() const
Create EntitySeed.
Definition: foamgridentity.hh:595
GeometryType type() const
return the entity's type
Definition: foamgridentity.hh:801
unsigned int count(unsigned int codim) const
Return the number of subEntities of codimension cc.
Definition: foamgridentity.hh:612
FoamGridEntity & operator=(const FoamGridEntity &original)
Definition: foamgridentity.hh:559
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: foamgridentity.hh:520
unsigned int subEntities(unsigned int codim) const
Definition: foamgridentity.hh:622
PartitionType partitionType() const
The partition type for parallel computing.
Definition: foamgridentity.hh:577
FoamGridLevelIntersectionIterator< GridImp > LevelIntersectionIterator
The Iterator over intersections on this level.
Definition: foamgridentity.hh:523
FoamGridEntity()
Default constructor.
Definition: foamgridentity.hh:554
GridImp::Traits::template Codim< codim >::Entity Entity
Definition: foamgridentity.hh:537
Definition: foamgridgeometry.hh:21
Definition: foamgridindexsets.hh:26
Definition: foamgridindexsets.hh:200