Loading [MathJax]/extensions/tex2jax.js

DUNE MultiDomainGrid (2.10)

entity.hh
1#ifndef DUNE_MULTIDOMAINGRID_ENTITY_HH
2#define DUNE_MULTIDOMAINGRID_ENTITY_HH
3
4#include <dune/grid/common/entity.hh>
5#include <dune/grid/common/gridenums.hh>
6
7namespace Dune {
8
9namespace mdgrid {
10
11template<int codim, int dim, typename GridImp>
12class EntityWrapper;
13
14template<typename GridImp>
15class LeafIntersectionIteratorWrapper;
16
17template<typename GridImp>
18class LevelIntersectionIteratorWrapper;
19
20template<typename GridImp>
21class HierarchicIteratorWrapper;
22
23template<typename, typename>
24class IntersectionIteratorWrapper;
25
26template<typename HostGrid, typename MDGridTraits>
27class MultiDomainGrid;
28
29template<typename>
30class LevelGridView;
31
32template<typename>
33class LeafGridView;
34
35
36template<typename HostES>
37class EntitySeedWrapper
38{
39
40 typedef HostES HostEntitySeed;
41
42 template<typename, typename>
43 friend class MultiDomainGrid;
44
45 template<int, int, typename>
46 friend class EntityWrapper;
47
48public:
49
50 static const std::size_t codimension = HostEntitySeed::codimension;
51
52 EntitySeedWrapper()
53 {}
54
55 EntitySeedWrapper(const HostEntitySeed& hostEntitySeed)
56 : _hostEntitySeed(hostEntitySeed)
57 {}
58
59 const HostEntitySeed& hostEntitySeed() const
60 {
61 return _hostEntitySeed;
62 }
63
64 bool isValid() const
65 {
66 return _hostEntitySeed.isValid();
67 }
68
69 HostEntitySeed _hostEntitySeed;
70
71};
72
73
74template<int codim, int dim, typename GridImp>
75class EntityWrapperBase :
76 public EntityDefaultImplementation<codim,dim,GridImp,EntityWrapper>
77{
78
79 template<typename,typename>
80 friend class MultiDomainGrid;
81
82 typedef typename GridImp::HostGrid::Traits::template Codim<codim>::Entity HostEntity;
83
84public:
85
86 typedef typename GridImp::template Codim<codim>::Geometry Geometry;
87
88 typedef EntitySeedWrapper<typename HostEntity::EntitySeed> EntitySeed;
89
90 EntityWrapperBase()
91 {}
92
93 explicit EntityWrapperBase(const HostEntity& e)
94 : _hostEntity(e)
95 {}
96
97 explicit EntityWrapperBase(HostEntity&& e)
98 : _hostEntity(std::move(e))
99 {}
100
101 int level() const {
102 return _hostEntity.level();
103 }
104
105 PartitionType partitionType() const {
106 return _hostEntity.partitionType();
107 }
108
109 unsigned int subEntities(unsigned int codimSubEntitiy) const {
110 return _hostEntity.subEntities(codimSubEntitiy);
111 }
112
113 Geometry geometry() const {
114 return Geometry(_hostEntity.geometry());
115 }
116
117 EntitySeed seed() const {
118 return EntitySeed(_hostEntity.seed());
119 }
120
121 bool equals(const EntityWrapperBase& other) const
122 {
123 return hostEntity() == other.hostEntity();
124 }
125
126private:
127
128 HostEntity _hostEntity;
129
130protected:
131
132 const HostEntity& hostEntity() const {
133 return _hostEntity;
134 }
135
136};
137
138
139template<int codim, int dim, typename GridImp>
140class EntityWrapper :
141 public EntityWrapperBase<codim,dim,GridImp>
142{
143
144 using Base = EntityWrapperBase<codim,dim,GridImp>;
145
146 template<typename,typename>
147 friend class MultiDomainGrid;
148
149public:
150
151 // inherit constructors
152 using Base::Base;
153
154};
155
156template<int dim, typename GridImp>
157class EntityWrapper<0,dim,GridImp> :
158 public EntityWrapperBase<0,dim,GridImp>
159{
160
161 using Base = EntityWrapperBase<0,dim,GridImp>;
162
163 template<typename,typename>
164 friend class MultiDomainGrid;
165
166 template<typename>
167 friend class LevelGridView;
168
169 template<typename>
170 friend class LeafGridView;
171
172 using Base::hostEntity;
173
174public:
175
176 using LocalGeometry = typename GridImp::template Codim<0>::LocalGeometry;
177 using LeafIntersectionIterator = typename GridImp::Traits::LeafIntersectionIterator;
178 using LevelIntersectionIterator = typename GridImp::Traits::LevelIntersectionIterator;
179 using HierarchicIterator = typename GridImp::Traits::HierarchicIterator;
180
181 // inherit constructors
182 using Base::Base;
183
184 unsigned int subEntities(unsigned int codim) const {
185 return hostEntity().subEntities(codim);
186 }
187
188 template<int cc>
189 typename GridImp::template Codim<cc>::Entity subEntity(int i) const {
190 return {EntityWrapper<cc,dim,GridImp>(hostEntity().template subEntity<cc>(i))};
191 }
192
193 typename GridImp::template Codim<0>::Entity father() const {
194 return {EntityWrapper(hostEntity().father())};
195 }
196
197 bool hasFather() const {
198 return hostEntity().hasFather();
199 }
200
201 bool isLeaf() const {
202 return hostEntity().isLeaf();
203 }
204
205 bool isRegular() const {
206 return hostEntity().isRegular();
207 }
208
209 LocalGeometry geometryInFather() const {
210 return LocalGeometry(hostEntity().geometryInFather());
211 }
212
213 HierarchicIterator hbegin(int maxLevel) const {
214 return HierarchicIteratorWrapper<GridImp>(hostEntity().hbegin(maxLevel));
215 }
216
217 HierarchicIterator hend(int maxLevel) const {
218 return HierarchicIteratorWrapper<GridImp>(hostEntity().hend(maxLevel));
219 }
220
221 LevelIntersectionIterator ilevelbegin() const {
222 return IntersectionIteratorWrapper<
223 GridImp,
224 typename GridImp::HostGrid::LevelGridView::IntersectionIterator
225 >(
226 hostEntity().ilevelbegin()
227 );
228 }
229
230 LevelIntersectionIterator ilevelend() const {
231 return IntersectionIteratorWrapper<
232 GridImp,
233 typename GridImp::HostGrid::LevelGridView::IntersectionIterator
234 >(
235 hostEntity().ilevelend()
236 );
237 }
238
239 LeafIntersectionIterator ileafbegin() const {
240 return IntersectionIteratorWrapper<
241 GridImp,
242 typename GridImp::HostGrid::LeafGridView::IntersectionIterator
243 >(
244 hostEntity().ileafbegin()
245 );
246 }
247
248 LeafIntersectionIterator ileafend() const {
249 return IntersectionIteratorWrapper<
250 GridImp,
251 typename GridImp::HostGrid::LeafGridView::IntersectionIterator
252 >(
253 hostEntity().ileafend()
254 );
255 }
256
257 bool isNew() const {
258 return hostEntity().isNew();
259 }
260
261 bool mightVanish() const {
262 return hostEntity().mightVanish();
263 }
264
265 bool hasBoundaryIntersections () const
266 {
267 return hostEntity().hasBoundaryIntersections();
268 }
269
270};
271
272} // namespace mdgrid
273
274} // namespace Dune
275
276#endif // DUNE_MULTIDOMAINGRID_ENTITY_HH
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 3, 22:46, 2025)