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>
27template<
int codim,
int dimentity,
class Gr
idImp>
30template<
int codim,
class Gr
idImp>
31class FoamGridEntityPointer;
33template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
34class FoamGridLevelIterator;
36template<
class Gr
idImp>
37class FoamGridLevelIntersectionIterator;
39template<
class Gr
idImp>
40class FoamGridLeafIntersectionIterator;
42template<
class Gr
idImp>
43class FoamGridHierarchicIterator;
51template<
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);
180template<
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!");
456 {
return {
target_, maxLevel }; }
461 {
return { maxLevel }; }
490template<
class Gr
idImp>
492 public EntityDefaultImplementation<0, 1, GridImp, FoamGridEntity>
495 enum {dimworld = GridImp::dimensionworld};
496 enum {dimgrid = GridImp::dimension};
500 typedef typename GridImp::ctype ctype;
504 typedef typename GridImp::template Codim<0>::Geometry
Geometry;
518 typedef typename GridImp::template Codim<0>::EntitySeed
EntitySeed;
547 if (
this != &original)
564 return InteriorEntity;
572 std::array<FieldVector<ctype, dimworld>, dimgrid+1> coordinates;
573 assert(dimgrid+1 ==
target_->corners() &&
"Target entity is not a simplex!");
574 for (
int i=0; i<
target_->corners(); i++)
575 coordinates[i] =
target_->corner(i);
592 static_assert(0<=cc && cc<=1,
"Only codimensions with 0 <= cc <= 1 are valid!");
593 return (cc==0) ? 1 : 2;
598 unsigned int count (
unsigned int codim)
const
600 assert(0<=codim && codim<=1);
601 return (codim==0) ? 1 : 2;
610 assert(0<=codim && codim<=1);
611 return (codim==0) ? 1 : 2;
616 int subId (
int i,
unsigned int codim)
const {
617 assert(0<=codim && codim<=1);
622 return target_->vertex_[i]->id_;
624 DUNE_THROW(GridError,
"Non-existing codimension requested!");
629 typename std::enable_if<codim==0, typename Codim<0>::Entity>
::type
638 typename std::enable_if<codim==1, typename Codim<1>::Entity>
::type
641 assert(i==0 || i==1);
711 DUNE_THROW(GridError,
"There is no father Element.");
725 ctype mapping[2][2] = {{0.0, 0.5}, {0.5, 1.0}};
727 std::array<FieldVector<ctype, dimgrid>, 2> coordinates;
729 for(
int corner=0; corner <2; ++corner)
730 coordinates[corner][0] = mapping[
target_->refinementIndex_][corner];
737 DUNE_THROW(NotImplemented,
"geometryInFather only supported for lines!");
747 {
return {
target_, maxLevel }; }
752 {
return { maxLevel }; }
The FoamGridGeometry class.
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
unsigned int subEntities(unsigned int codim) const
Definition: foamgridentity.hh:299
PartitionType partitionType() const
The partition type for parallel computing.
Definition: foamgridentity.hh:254
FoamGridEntity(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *hostEntity)
Constructor for an entity in a given grid level.
Definition: foamgridentity.hh:220
FoamGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: foamgridentity.hh:348
FoamGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: foamgridentity.hh:205
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
bool equals(const Dune::FoamGridEntity< 0, dimgrid, GridImp > &other) const
equality
Definition: foamgridentity.hh:476
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
std::enable_if< codim==1, typenameCodim< 1 >::Entity >::type subEntity(int i) const
Access to codim 1 subentities.
Definition: foamgridentity.hh:332
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:485
FoamGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: foamgridentity.hh:202
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:470
FoamGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: foamgridentity.hh:369
FoamGridEntity & operator=(const FoamGridEntity &original)
Definition: foamgridentity.hh:236
FoamGridEntity()
Default constructor.
Definition: foamgridentity.hh:231
FoamGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: foamgridentity.hh:354
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
std::enable_if< codim==0, typenameCodim< 0 >::Entity >::type subEntity(int i) const
Access to codim 0 subentities.
Definition: foamgridentity.hh:323
bool mightVanish() const
Definition: foamgridentity.hh:389
Entity father() const
Definition: foamgridentity.hh:396
FoamGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: foamgridentity.hh:360
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
std::enable_if< codim==2, typenameCodim< 2 >::Entity >::type subEntity(int i) const
Access to codim 2 subentities.
Definition: foamgridentity.hh:341
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:482
FoamGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: foamgridentity.hh:460
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:776
std::enable_if< codim==1, typenameCodim< 1 >::Entity >::type subEntity(int i) const
Access to codim 1 subentities.
Definition: foamgridentity.hh:639
void setToTarget(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *target)
Make this class point to a new FoamGridEntityImp object.
Definition: foamgridentity.hh:761
FoamGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: foamgridentity.hh:515
bool isNew() const
Definition: foamgridentity.hh:682
FoamGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: foamgridentity.hh:652
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:746
GridImp::Traits::template Codim< 0 >::Entity Entity
Definition: foamgridentity.hh:526
int count() const
Return the number of subEntities of codimension cc.
Definition: foamgridentity.hh:590
FoamGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: foamgridentity.hh:667
FoamGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: foamgridentity.hh:512
GridImp::template Codim< 0 >::Geometry Geometry
Definition: foamgridentity.hh:504
bool hasFather() const
Return true if this element has a father element.
Definition: foamgridentity.hh:678
Entity father() const
Definition: foamgridentity.hh:694
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: foamgridentity.hh:518
bool mightVanish() const
Definition: foamgridentity.hh:687
Geometry geometry() const
Geometry of this entity.
Definition: foamgridentity.hh:569
int subId(int i, unsigned int codim) const
Return index of sub entity with codim = cc and local number i.
Definition: foamgridentity.hh:616
std::enable_if< codim==0, typenameCodim< 0 >::Entity >::type subEntity(int i) const
Access to codim 0 subentities.
Definition: foamgridentity.hh:630
FoamGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: foamgridentity.hh:658
FoamGridEntity(const FoamGridEntity &original)
Copy constructor.
Definition: foamgridentity.hh:535
FoamGridEntity(const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > *hostEntity)
Constructor for an entity in a given grid level.
Definition: foamgridentity.hh:529
bool isLeaf() const
returns true if Entity has NO children
Definition: foamgridentity.hh:673
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: foamgridentity.hh:707
int level() const
Level of this element.
Definition: foamgridentity.hh:556
bool equals(const Dune::FoamGridEntity< 0, dimgrid, GridImp > &other) const
equality
Definition: foamgridentity.hh:767
EntitySeed seed() const
Create EntitySeed.
Definition: foamgridentity.hh:581
GeometryType type() const
return the entity's type
Definition: foamgridentity.hh:773
unsigned int count(unsigned int codim) const
Return the number of subEntities of codimension cc.
Definition: foamgridentity.hh:598
FoamGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: foamgridentity.hh:751
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: foamgridentity.hh:506
unsigned int subEntities(unsigned int codim) const
Definition: foamgridentity.hh:608
PartitionType partitionType() const
The partition type for parallel computing.
Definition: foamgridentity.hh:563
FoamGridLevelIntersectionIterator< GridImp > LevelIntersectionIterator
The Iterator over intersections on this level.
Definition: foamgridentity.hh:509
FoamGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: foamgridentity.hh:646
FoamGridEntity & operator=(const FoamGridEntity &original)
Definition: foamgridentity.hh:545
FoamGridEntity()
Default constructor.
Definition: foamgridentity.hh:540
GridImp::Traits::template Codim< codim >::Entity Entity
Definition: foamgridentity.hh:523
Definition: foamgridgeometry.hh:21
Definition: foamgridindexsets.hh:26
Definition: foamgridindexsets.hh:200
The actual entity implementation.
Definition: foamgridvertex.hh:47