Dune Core Modules (2.6.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
165 unsigned int subEntities (unsigned int cc) const
166 {
167 return hostEntity_.subEntities(cc);
168 }
169
171 Geometry geometry () const
172 {
173 return Geometry( hostEntity_.geometry() );
174 }
175
176
177 HostGridEntity hostEntity_;
178
179 private:
180
181 const GridImp* identityGrid_;
182
183 };
184
185
186
187
188 //***********************
189 //
190 // --IdentityGridEntity
191 //
192 //***********************
200 template<int dim, class GridImp>
201 class IdentityGridEntity<0,dim,GridImp> :
202 public EntityDefaultImplementation<0,dim,GridImp, IdentityGridEntity>
203 {
204 friend struct HostGridAccess< typename std::remove_const< GridImp >::type >;
205
206 public:
207
208 // The codimension of this entitypointer wrt the host grid
209 enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension};
210
211 // equivalent entity in the host grid
212 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
213
214 typedef typename GridImp::template Codim<0>::Geometry Geometry;
215
216 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
217
220
223
226
228 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
229
230
231
233 : identityGrid_(nullptr)
234 {}
235
236 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
237 : hostEntity_(hostEntity)
238 , identityGrid_(identityGrid)
239 {}
240
241 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
242 : hostEntity_(std::move(hostEntity))
243 , identityGrid_(identityGrid)
244 {}
245
248 : hostEntity_(original.hostEntity_)
249 , identityGrid_(original.identityGrid_)
250 {}
251
253 : hostEntity_(std::move(original.hostEntity_))
254 , identityGrid_(original.identityGrid_)
255 {}
256
259 {
260 if (this != &original)
261 {
262 identityGrid_ = original.identityGrid_;
263 hostEntity_ = original.hostEntity_;
264 }
265 return *this;
266 }
267
270 {
271 if (this != &original)
272 {
273 identityGrid_ = original.identityGrid_;
274 hostEntity_ = std::move(original.hostEntity_);
275 }
276 return *this;
277 }
278
279 bool equals(const IdentityGridEntity& other) const
280 {
281 return hostEntity_ == other.hostEntity_;
282 }
283
285 bool hasFather () const {
286 return hostEntity_.hasFather();
287 }
288
291 {
292 return EntitySeed(hostEntity_);
293 }
294
296 int level () const
297 {
298 return hostEntity_.level();
299 }
300
301
304 return hostEntity_.partitionType();
305 }
306
307
309 Geometry geometry () const
310 {
311 return Geometry( hostEntity_.geometry() );
312 }
313
314
317 unsigned int subEntities (unsigned int codim) const
318 {
319 return hostEntity_.subEntities(codim);
320 }
321
322
326 template<int cc>
327 typename GridImp::template Codim<cc>::Entity subEntity (int i) const {
328 return IdentityGridEntity<cc,dim,GridImp>(identityGrid_, hostEntity_.template subEntity<cc>(i));
329 }
330
331
335 identityGrid_,
336 identityGrid_->getHostGrid().levelGridView(level()).ibegin(hostEntity_));
337 }
338
339
343 identityGrid_,
344 identityGrid_->getHostGrid().levelGridView(level()).iend(hostEntity_));
345 }
346
347
351 identityGrid_,
352 identityGrid_->getHostGrid().leafGridView().ibegin(hostEntity_));
353 }
354
355
359 identityGrid_,
360 identityGrid_->getHostGrid().leafGridView().iend(hostEntity_));
361 }
362
363
365 bool isLeaf() const {
366 return hostEntity_.isLeaf();
367 }
368
369
372 typename GridImp::template Codim<0>::Entity father () const {
373 return IdentityGridEntity(identityGrid_, hostEntity_.father());
374 }
375
376
386 LocalGeometry geometryInFather () const
387 {
388 return LocalGeometry( hostEntity_.geometryInFather() );
389 }
390
391
397 {
398 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel);
399 }
400
401
404 {
405 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel, true);
406 }
407
408
410 bool wasRefined () const
411 {
412 if (identityGrid_->adaptationStep!=GridImp::adaptDone)
413 return false;
414
415 int level = this->level();
416 int index = identityGrid_->levelIndexSet(level).index(*this);
417 return identityGrid_->refinementMark_[level][index];
418 }
419
420
422 bool mightBeCoarsened () const
423 {
424 return true;
425 }
426
427
428 // /////////////////////////////////////////
429 // Internal stuff
430 // /////////////////////////////////////////
431
432
433 HostGridEntity hostEntity_;
434 const GridImp* identityGrid_;
435
436 private:
437
438 typedef typename GridImp::ctype ctype;
439
440 }; // end of IdentityGridEntity codim = 0
441
442
443} // namespace Dune
444
445
446#endif
Default Implementations for EntityImp.
Definition: entity.hh:548
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:582
unsigned int subEntities(unsigned int codim) const
Return the number of subEntities of codimension codim.
Definition: identitygridentity.hh:317
bool isLeaf() const
returns true if Entity has NO children
Definition: identitygridentity.hh:365
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:396
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:228
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:290
IdentityGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: identitygridentity.hh:333
int level() const
Level of this element.
Definition: identitygridentity.hh:296
IdentityGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: identitygridentity.hh:349
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:258
Geometry geometry() const
Geometry of this entity.
Definition: identitygridentity.hh:309
IdentityGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: identitygridentity.hh:341
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:247
IdentityGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: identitygridentity.hh:403
IdentityGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: identitygridentity.hh:357
IdentityGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: identitygridentity.hh:225
IdentityGridLevelIntersectionIterator< GridImp > LevelIntersectionIterator
The Iterator over intersections on this level.
Definition: identitygridentity.hh:219
bool wasRefined() const
Definition: identitygridentity.hh:410
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:269
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:285
GridImp::template Codim< 0 >::Entity father() const
Definition: identitygridentity.hh:372
bool mightBeCoarsened() const
Definition: identitygridentity.hh:422
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: identitygridentity.hh:386
GridImp::template Codim< cc >::Entity subEntity(int i) const
Provide access to sub entity i of given codimension. Entities are numbered 0 ... subEntities(cc)-1.
Definition: identitygridentity.hh:327
IdentityGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: identitygridentity.hh:222
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:303
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:53
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:125
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:171
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:165
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: alignedallocator.hh:10
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 (Dec 26, 23:30, 2024)