dune-mmesh (unstable)

cachingentity.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_MMESH_GRID_CACHINGENTITY_HH
4#define DUNE_MMESH_GRID_CACHINGENTITY_HH
5
10#include <set>
11
12// Dune includes
13#include <dune/grid/common/grid.hh>
14
15// MMesh includes
18#include <dune/mmesh/grid/polygoncutting.hh>
19
20namespace Dune {
21
22//**********************************************************************
23//
24// --MMeshCachingEntity
25// --Entity
26//
37template <int dim, class GridImp>
38class MMeshCachingEntity<0, dim, GridImp>
39 : public MMeshEntity<0, dim, GridImp> {
40 template <class GridImp_>
41 friend class MMeshLeafIndexSet;
42
43 template <class GridImp_>
44 friend class MMeshLocalIdSet;
45
46 template <class GridImp_>
47 friend class MMeshGlobalIdSet;
48
49 private:
50 // this type
52
53 // base type
55
56 // type of scalars
57 typedef typename GridImp::ctype ctype;
58
59 // type of the host grid
60 typedef typename GridImp::HostGridType HostGrid;
61
62 // equivalent entity in the host grid as pointer
63 typedef typename GridImp::template HostGridEntity<0> HostGridEntity;
64
65 // standard MMesh entity implementation
66 typedef typename GridImp::template Codim<0>::Entity MMeshEntityType;
67
68 // type of ids
69 typedef MMeshImpl::MultiId IdType;
70
71 public:
72 // geometry type
73 typedef AffineGeometry<ctype, dim, dim> Geometry;
74
75 // local geometry type
76 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
77
78 // type of global coordinate
79 typedef typename Geometry::GlobalCoordinate GlobalCoordinate;
80
81 MMeshCachingEntity() = delete;
82
83 explicit MMeshCachingEntity(const GridImp* mMesh,
84 const HostGridEntity& hostEntity)
85 : BaseType(mMesh, hostEntity,
86 mMesh->globalIdSet().id(mMesh->entity(hostEntity))) {
87 const auto geo = mMesh->entity(hostEntity).geometry();
88 for (int i = 0; i < dim + 1; ++i) this->vertex_[i] = geo.corner(i);
89 }
90
92 bool equals(const MMeshCachingEntity& other) const {
93 return this->id_ == other.id_;
94 }
95
97 bool operator==(const MMeshCachingEntity& other) const {
98 return this->equals(other);
99 }
100
102 bool operator==(const MMeshEntityType& entity) const {
103 return this->id_ == this->mMesh_->globalIdSet().id(entity);
104 }
105
107 bool operator<(const MMeshCachingEntity& other) const {
108 return this->id_ < other.id_;
109 }
110
112 bool hasFather() const { return true; }
113
115 const bool isNew() const { return false; }
116
118 const bool mightVanish() const { return true; }
119
121 int level() const {
122 // we only have one level
123 return 0;
124 }
125
127 PartitionType partitionType() const {
128 return PartitionType::InteriorEntity; /* dummy */
129 }
130
132 Geometry geometry() const {
133 return Geometry(GeometryTypes::simplex(dim), this->vertex_);
134 }
135
137 unsigned int subEntities(unsigned int cc) const {
138 // we have a simplex grid
139 int n = dim + 1;
140 int k = dim - cc + 1;
141
142 // binomial: n over k
143 int binomial = 1;
144 for (int i = n - k + 1; i <= n; i++) binomial *= i;
145 for (long i = 2; i <= k; i++) binomial /= i;
146
147 return binomial;
148 }
149
151 bool isLeaf() const { return false; }
152
154 template <int d = dim>
155 std::enable_if_t<d == 2, ctype> intersectionVolume(
156 const MMeshEntityType& entity) const {
157 std::array<GlobalCoordinate, 3> entityPoints;
158
159 for (int i = 0; i < 3; ++i) {
160 entityPoints[i] =
161 makeFieldVector(entity.impl().hostEntity()->vertex(i)->point());
162 }
163
164 using PC = Dune::PolygonCutting<ctype, GlobalCoordinate>;
165 return std::abs(
166 PC::polygonArea(PC::sutherlandHodgman(this->vertex_, entityPoints)));
167 }
168
169 template <int d = dim>
170 std::enable_if_t<d == 3, ctype> intersectionVolume(
171 const MMeshEntityType& entity) const {
172 DUNE_THROW(NotImplemented, "intersectionVolume in 3d");
173 }
174
175}; // end of MMeshCachingEntity codim = 0
176
177} // namespace Dune
178
179#endif
The implementation of caching entities in a MMeshThe caching entity copys the CGAL face object instea...
Definition: cachingentity.hh:39
bool operator<(const MMeshCachingEntity &other) const
returns true if id of other is greater
Definition: cachingentity.hh:107
const bool mightVanish() const
returns true if this entity will vanish after adaptation
Definition: cachingentity.hh:118
bool isLeaf() const
returns true if Entity has no children
Definition: cachingentity.hh:151
int level() const
Level of this element.
Definition: cachingentity.hh:121
bool operator==(const MMeshCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:97
const bool isNew() const
returns true if this entity is new after adaptation
Definition: cachingentity.hh:115
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension cc.
Definition: cachingentity.hh:137
bool operator==(const MMeshEntityType &entity) const
returns true if caching entity has same id like mmesh entity
Definition: cachingentity.hh:102
bool hasFather() const
returns true if father entity exists
Definition: cachingentity.hh:112
std::enable_if_t< d==2, ctype > intersectionVolume(const MMeshEntityType &entity) const
calculates the intersection volume with another MMesh entity
Definition: cachingentity.hh:155
bool equals(const MMeshCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:92
Geometry geometry() const
Geometry of this entity.
Definition: cachingentity.hh:132
PartitionType partitionType() const
The partition type for parallel computing.
Definition: cachingentity.hh:127
The implementation of entities in MMesh.
Definition: entity.hh:399
Geometry geometry() const
Geometry of this entity.
Definition: entity.hh:566
The implementation of entities in a MMesh.
Definition: entity.hh:50
The multi id class.
Helpers for conversion from CGAL::Point_x to DUNE::FieldVector.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Sep 5, 22:35, 2025)