Dune Core Modules (2.5.0)

identitygridentity.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_IDENTITYGRIDENTITY_HH
4#define DUNE_IDENTITYGRIDENTITY_HH
5
11
12namespace Dune {
13
14
15 // Forward declarations
16
17 template<int codim, int dim, class GridImp>
18 class IdentityGridEntity;
19
20 template<int codim, PartitionIteratorType pitype, class GridImp>
21 class IdentityGridLevelIterator;
22
23 template<class GridImp>
24 class IdentityGridLevelIntersectionIterator;
25
26 template<class GridImp>
27 class IdentityGridLeafIntersectionIterator;
28
29 template<class GridImp>
30 class IdentityGridHierarchicIterator;
31
32
33 // External forward declarations
34 template< class Grid >
35 struct HostGridAccess;
36
37
38 //**********************************************************************
39 //
40 // --IdentityGridEntity
41 // --Entity
42 //
50 template<int codim, int dim, class GridImp>
52 public EntityDefaultImplementation <codim,dim,GridImp,IdentityGridEntity>
53 {
54
55 template <class GridImp_>
56 friend class IdentityGridLevelIndexSet;
57
58 template <class GridImp_>
59 friend class IdentityGridLeafIndexSet;
60
61 template <class GridImp_>
62 friend class IdentityGridLocalIdSet;
63
64 template <class GridImp_>
65 friend class IdentityGridGlobalIdSet;
66
67 friend struct HostGridAccess< typename std::remove_const< GridImp >::type >;
68
69
70 private:
71
72 typedef typename GridImp::ctype ctype;
73
74 // The codimension of this entity wrt the host grid
75 enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension + codim};
76
77 // equivalent entity in the host grid
78 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
79
80
81 public:
82
83 typedef typename GridImp::template Codim<codim>::Geometry Geometry;
84
86 typedef typename GridImp::template Codim<codim>::EntitySeed EntitySeed;
87
89 : identityGrid_(nullptr)
90 {}
91
92 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
93 : hostEntity_(hostEntity)
94 , identityGrid_(identityGrid)
95 {}
96
97 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
98 : hostEntity_(std::move(hostEntity))
99 , identityGrid_(identityGrid)
100 {}
101
104 : hostEntity_(original.hostEntity_)
105 , identityGrid_(original.identityGrid_)
106 {}
107
109 : hostEntity_(std::move(original.hostEntity_))
110 , identityGrid_(original.identityGrid_)
111 {}
112
115 {
116 if (this != &original)
117 {
118 identityGrid_ = original.identityGrid_;
119 hostEntity_ = original.hostEntity_;
120 }
121 return *this;
122 }
123
126 {
127 if (this != &original)
128 {
129 identityGrid_ = original.identityGrid_;
130 hostEntity_ = std::move(original.hostEntity_);
131 }
132 return *this;
133 }
134
135 bool equals(const IdentityGridEntity& other) const
136 {
137 return hostEntity_ == other.hostEntity_;
138 }
139
141 bool hasFather () const {
142 return hostEntity_.hasFather();
143 }
144
147 {
148 return EntitySeed(hostEntity_);
149 }
150
152 int level () const {
153 return hostEntity_.level();
154 }
155
156
160 return hostEntity_.partitionType();
161 }
162
163
167 template<int cc> int count () const {
168 return hostEntity_.template count<cc>();
169 }
170
173 unsigned int subEntities (unsigned int cc) const
174 {
175 return hostEntity_.subEntities(cc);
176 }
177
179 Geometry geometry () const
180 {
181 return Geometry( hostEntity_.geometry() );
182 }
183
184
185 HostGridEntity hostEntity_;
186
187 private:
188
189 const GridImp* identityGrid_;
190
191 };
192
193
194
195
196 //***********************
197 //
198 // --IdentityGridEntity
199 //
200 //***********************
208 template<int dim, class GridImp>
209 class IdentityGridEntity<0,dim,GridImp> :
210 public EntityDefaultImplementation<0,dim,GridImp, IdentityGridEntity>
211 {
212 friend struct HostGridAccess< typename std::remove_const< GridImp >::type >;
213
214 public:
215
216 // The codimension of this entitypointer wrt the host grid
217 enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension};
218
219 // equivalent entity in the host grid
220 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
221
222 typedef typename GridImp::template Codim<0>::Geometry Geometry;
223
224 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
225
228
231
234
236 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
237
238
239
241 : identityGrid_(nullptr)
242 {}
243
244 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
245 : hostEntity_(hostEntity)
246 , identityGrid_(identityGrid)
247 {}
248
249 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
250 : hostEntity_(std::move(hostEntity))
251 , identityGrid_(identityGrid)
252 {}
253
256 : hostEntity_(original.hostEntity_)
257 , identityGrid_(original.identityGrid_)
258 {}
259
261 : hostEntity_(std::move(original.hostEntity_))
262 , identityGrid_(original.identityGrid_)
263 {}
264
267 {
268 if (this != &original)
269 {
270 identityGrid_ = original.identityGrid_;
271 hostEntity_ = original.hostEntity_;
272 }
273 return *this;
274 }
275
278 {
279 if (this != &original)
280 {
281 identityGrid_ = original.identityGrid_;
282 hostEntity_ = std::move(original.hostEntity_);
283 }
284 return *this;
285 }
286
287 bool equals(const IdentityGridEntity& other) const
288 {
289 return hostEntity_ == other.hostEntity_;
290 }
291
293 bool hasFather () const {
294 return hostEntity_.hasFather();
295 }
296
299 {
300 return EntitySeed(hostEntity_);
301 }
302
304 int level () const
305 {
306 return hostEntity_.level();
307 }
308
309
312 return hostEntity_.partitionType();
313 }
314
315
317 Geometry geometry () const
318 {
319 return Geometry( hostEntity_.geometry() );
320 }
321
322
325 template<int cc>
326 int count () const
327 {
328 return hostEntity_.template count<cc>();
329 }
330
331
334 unsigned int subEntities (unsigned int codim) const
335 {
336 return hostEntity_.subEntities(codim);
337 }
338
339
343 template<int cc>
344 typename GridImp::template Codim<cc>::Entity subEntity (int i) const {
345 return IdentityGridEntity<cc,dim,GridImp>(identityGrid_, hostEntity_.template subEntity<cc>(i));
346 }
347
348
352 identityGrid_,
353 identityGrid_->getHostGrid().levelGridView(level()).ibegin(hostEntity_));
354 }
355
356
360 identityGrid_,
361 identityGrid_->getHostGrid().levelGridView(level()).iend(hostEntity_));
362 }
363
364
368 identityGrid_,
369 identityGrid_->getHostGrid().leafGridView().ibegin(hostEntity_));
370 }
371
372
376 identityGrid_,
377 identityGrid_->getHostGrid().leafGridView().iend(hostEntity_));
378 }
379
380
382 bool isLeaf() const {
383 return hostEntity_.isLeaf();
384 }
385
386
389 typename GridImp::template Codim<0>::Entity father () const {
390 return IdentityGridEntity(identityGrid_, hostEntity_.father());
391 }
392
393
403 LocalGeometry geometryInFather () const
404 {
405 return LocalGeometry( hostEntity_.geometryInFather() );
406 }
407
408
414 {
415 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel);
416 }
417
418
421 {
422 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel, true);
423 }
424
425
427 bool wasRefined () const
428 {
429 if (identityGrid_->adaptationStep!=GridImp::adaptDone)
430 return false;
431
432 int level = this->level();
433 int index = identityGrid_->levelIndexSet(level).index(*this);
434 return identityGrid_->refinementMark_[level][index];
435 }
436
437
439 bool mightBeCoarsened () const
440 {
441 return true;
442 }
443
444
445 // /////////////////////////////////////////
446 // Internal stuff
447 // /////////////////////////////////////////
448
449
450 HostGridEntity hostEntity_;
451 const GridImp* identityGrid_;
452
453 private:
454
455 typedef typename GridImp::ctype ctype;
456
457 }; // end of IdentityGridEntity codim = 0
458
459
460} // namespace Dune
461
462
463#endif
Default Implementations for EntityImp.
Definition: entity.hh:569
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:603
unsigned int subEntities(unsigned int codim) const
Return the number of subEntities of codimension codim.
Definition: identitygridentity.hh:334
bool isLeaf() const
returns true if Entity has NO children
Definition: identitygridentity.hh:382
IdentityGridHierarchicIterator< GridImp > hbegin(int maxLevel) const
Inter-level access to son elements on higher levels<=maxlevel. This is provided for sparsely stored n...
Definition: identitygridentity.hh:413
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:236
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:298
IdentityGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: identitygridentity.hh:350
int level() const
Level of this element.
Definition: identitygridentity.hh:304
IdentityGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: identitygridentity.hh:366
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:266
Geometry geometry() const
Geometry of this entity.
Definition: identitygridentity.hh:317
IdentityGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: identitygridentity.hh:358
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:255
IdentityGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: identitygridentity.hh:420
IdentityGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: identitygridentity.hh:374
IdentityGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: identitygridentity.hh:233
IdentityGridLevelIntersectionIterator< GridImp > LevelIntersectionIterator
The Iterator over intersections on this level.
Definition: identitygridentity.hh:227
bool wasRefined() const
Definition: identitygridentity.hh:427
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:277
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:293
int count() const
Return the number of subEntities of codimension cc.
Definition: identitygridentity.hh:326
GridImp::template Codim< 0 >::Entity father() const
Definition: identitygridentity.hh:389
bool mightBeCoarsened() const
Definition: identitygridentity.hh:439
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: identitygridentity.hh:403
GridImp::template Codim< cc >::Entity subEntity(int i) const
Provide access to sub entity i of given codimension. Entities are numbered 0 ... count<cc>()-1.
Definition: identitygridentity.hh:344
IdentityGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: identitygridentity.hh:230
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:311
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:53
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:125
int count() const
Definition: identitygridentity.hh:167
GridImp::template Codim< codim >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:86
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:146
Geometry geometry() const
geometry of this entity
Definition: identitygridentity.hh:179
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:159
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension codim.
Definition: identitygridentity.hh:173
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:103
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:141
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:114
int level() const
level of this element
Definition: identitygridentity.hh:152
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: identitygridhierarchiciterator.hh:24
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: identitygridintersectioniterator.hh:27
Definition: identitygridindexsets.hh:24
Definition: identitygridintersectioniterator.hh:82
Different resources needed by all grid implementations.
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Dune namespace.
Definition: alignment.hh:11
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:22
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:36
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)