dune-mmesh (1.4)

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 //
25 // --MMeshCachingEntity
26 // --Entity
27 //
36 template<int dim, class GridImp>
37 class MMeshCachingEntity<0,dim,GridImp> :
38 public MMeshEntity<0,dim,GridImp>
39 {
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, const HostGridEntity& hostEntity)
84 : BaseType(mMesh, hostEntity, mMesh->globalIdSet().id( mMesh->entity( hostEntity ) ))
85 {
86 const auto geo = mMesh->entity( hostEntity ).geometry();
87 for( int i = 0; i < dim+1; ++i )
88 this->vertex_[i] = geo.corner(i);
89 }
90
92 bool equals(const MMeshCachingEntity& other) const
93 {
94 return this->id_ == other.id_;
95 }
96
98 bool operator==(const MMeshCachingEntity& other) const
99 {
100 return this->equals(other);
101 }
102
104 bool operator==(const MMeshEntityType& entity) const
105 {
106 return this->id_ == this->mMesh_->globalIdSet().id( entity );
107 }
108
110 bool operator<(const MMeshCachingEntity& other) const
111 {
112 return this->id_ < other.id_;
113 }
114
116 bool hasFather () const
117 {
118 return true;
119 }
120
122 const bool isNew () const
123 {
124 return false;
125 }
126
128 const bool mightVanish () const
129 {
130 return true;
131 }
132
134 int level () const
135 {
136 // we only have one level
137 return 0;
138 }
139
141 PartitionType partitionType () const {
142 return PartitionType::InteriorEntity; /* dummy */
143 }
144
146 Geometry geometry () const
147 {
148 return Geometry( GeometryTypes::simplex(dim), this->vertex_ );
149 }
150
152 unsigned int subEntities (unsigned int cc) const
153 {
154 // we have a simplex grid
155 int n = dim+1;
156 int k = dim-cc+1;
157
158 // binomial: n over k
159 int binomial=1;
160 for (int i=n-k+1; i<=n; i++)
161 binomial *= i;
162 for (long i=2; i<=k; i++)
163 binomial /= i;
164
165 return binomial;
166 }
167
169 bool isLeaf() const {
170 return false;
171 }
172
174 template<int d = dim>
175 std::enable_if_t<d == 2, ctype>
176 intersectionVolume ( const MMeshEntityType& entity ) const
177 {
178 std::array<GlobalCoordinate, 3> entityPoints;
179
180 for ( int i = 0; i < 3; ++i )
181 {
182 entityPoints[i] =
183 makeFieldVector( entity.impl().hostEntity()->vertex(i)->point() );
184 }
185
186 using PC = Dune::PolygonCutting<ctype, GlobalCoordinate>;
187 return std::abs( PC::polygonArea( PC::sutherlandHodgman(this->vertex_, entityPoints) ) );
188 }
189
190 template<int d = dim>
191 std::enable_if_t<d == 3, ctype>
192 intersectionVolume( const MMeshEntityType& entity ) const
193 {
194 DUNE_THROW( NotImplemented, "intersectionVolume in 3d" );
195 }
196
197 }; // end of MMeshCachingEntity codim = 0
198
199} // namespace Dune
200
201#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:110
const bool mightVanish() const
returns true if this entity will vanish after adaptation
Definition: cachingentity.hh:128
bool isLeaf() const
returns true if Entity has no children
Definition: cachingentity.hh:169
int level() const
Level of this element.
Definition: cachingentity.hh:134
bool operator==(const MMeshCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:98
const bool isNew() const
returns true if this entity is new after adaptation
Definition: cachingentity.hh:122
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension cc.
Definition: cachingentity.hh:152
bool operator==(const MMeshEntityType &entity) const
returns true if caching entity has same id like mmesh entity
Definition: cachingentity.hh:104
bool hasFather() const
returns true if father entity exists
Definition: cachingentity.hh:116
std::enable_if_t< d==2, ctype > intersectionVolume(const MMeshEntityType &entity) const
calculates the intersection volume with another MMesh entity
Definition: cachingentity.hh:176
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:146
PartitionType partitionType() const
The partition type for parallel computing.
Definition: cachingentity.hh:141
The implementation of entities in MMesh.
Definition: entity.hh:448
Geometry geometry() const
Geometry of this entity.
Definition: entity.hh:648
The implementation of entities in a MMesh.
Definition: entity.hh:53
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 (Apr 6, 22:49, 2025)