Dune Core Modules (2.4.2)

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, class GridImp, typename HostEntityPointer>
21 class IdentityGridEntityPointer;
22
23 template<int codim, PartitionIteratorType pitype, class GridImp>
24 class IdentityGridLevelIterator;
25
26 template<class GridImp>
27 class IdentityGridLevelIntersectionIterator;
28
29 template<class GridImp>
30 class IdentityGridLeafIntersectionIterator;
31
32 template<class GridImp>
33 class IdentityGridHierarchicIterator;
34
35
36 // External forward declarations
37 template< class Grid >
38 struct HostGridAccess;
39
40
41 //**********************************************************************
42 //
43 // --IdentityGridEntity
44 // --Entity
45 //
53 template<int codim, int dim, class GridImp>
55 public EntityDefaultImplementation <codim,dim,GridImp,IdentityGridEntity>
56 {
57
58 template <class GridImp_>
59 friend class IdentityGridLevelIndexSet;
60
61 template <class GridImp_>
62 friend class IdentityGridLeafIndexSet;
63
64 template <class GridImp_>
65 friend class IdentityGridLocalIdSet;
66
67 template <class GridImp_>
68 friend class IdentityGridGlobalIdSet;
69
70 template<int,typename, typename>
71 friend class IdentityGridEntityPointer;
72
73 friend struct HostGridAccess< typename remove_const< GridImp >::type >;
74
75
76 private:
77
78 typedef typename GridImp::ctype ctype;
79
80 // The codimension of this entitypointer wrt the host grid
81 enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension + codim};
82
83 // EntityPointer to the equivalent entity in the host grid
84 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
85
86
87 public:
88
89 typedef typename GridImp::template Codim<codim>::Geometry Geometry;
90
92 typedef typename GridImp::template Codim<codim>::EntitySeed EntitySeed;
93
95 : identityGrid_(nullptr)
96 {}
97
98 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
99 : hostEntity_(hostEntity)
100 , identityGrid_(identityGrid)
101 {}
102
103 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
104 : hostEntity_(std::move(hostEntity))
105 , identityGrid_(identityGrid)
106 {}
107
110 : hostEntity_(original.hostEntity_)
111 , identityGrid_(original.identityGrid_)
112 {}
113
115 : hostEntity_(std::move(original.hostEntity_))
116 , identityGrid_(original.identityGrid_)
117 {}
118
121 {
122 if (this != &original)
123 {
124 identityGrid_ = original.identityGrid_;
125 hostEntity_ = original.hostEntity_;
126 }
127 return *this;
128 }
129
132 {
133 if (this != &original)
134 {
135 identityGrid_ = original.identityGrid_;
136 hostEntity_ = std::move(original.hostEntity_);
137 }
138 return *this;
139 }
140
141 bool equals(const IdentityGridEntity& other) const
142 {
143 return hostEntity_ == other.hostEntity_;
144 }
145
147 bool hasFather () const {
148 return hostEntity_.hasFather();
149 }
150
153 {
154 return EntitySeed(hostEntity_);
155 }
156
158 int level () const {
159 return hostEntity_.level();
160 }
161
162
166 return hostEntity_.partitionType();
167 }
168
169
173 template<int cc> int count () const {
174 return hostEntity_.template count<cc>();
175 }
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 remove_const< GridImp >::type >;
213
214 template<int,typename, typename>
215 friend class IdentityGridEntityPointer;
216
217 public:
218
219 // The codimension of this entitypointer wrt the host grid
220 enum {CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension};
221
222 // EntityPointer to the equivalent entity in the host grid
223 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
224
225 typedef typename GridImp::template Codim<0>::Geometry Geometry;
226
227 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
228
231
234
237
239 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
240
241
242
244 : identityGrid_(nullptr)
245 {}
246
247 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
248 : hostEntity_(hostEntity)
249 , identityGrid_(identityGrid)
250 {}
251
252 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
253 : hostEntity_(std::move(hostEntity))
254 , identityGrid_(identityGrid)
255 {}
256
259 : hostEntity_(original.hostEntity_)
260 , identityGrid_(original.identityGrid_)
261 {}
262
264 : hostEntity_(std::move(original.hostEntity_))
265 , identityGrid_(original.identityGrid_)
266 {}
267
270 {
271 if (this != &original)
272 {
273 identityGrid_ = original.identityGrid_;
274 hostEntity_ = original.hostEntity_;
275 }
276 return *this;
277 }
278
281 {
282 if (this != &original)
283 {
284 identityGrid_ = original.identityGrid_;
285 hostEntity_ = std::move(original.hostEntity_);
286 }
287 return *this;
288 }
289
290 bool equals(const IdentityGridEntity& other) const
291 {
292 return hostEntity_ == other.hostEntity_;
293 }
294
296 bool hasFather () const {
297 return hostEntity_.hasFather();
298 }
299
302 {
303 return EntitySeed(hostEntity_);
304 }
305
307 int level () const
308 {
309 return hostEntity_.level();
310 }
311
312
315 return hostEntity_.partitionType();
316 }
317
318
320 Geometry geometry () const
321 {
322 return Geometry( hostEntity_.geometry() );
323 }
324
325
328 template<int cc>
329 int count () const
330 {
331 return hostEntity_.template count<cc>();
332 }
333
334
337 unsigned int subEntities (unsigned int codim) const
338 {
339 return hostEntity_.subEntities(codim);
340 }
341
342
346 template<int cc>
347 typename GridImp::template Codim<cc>::Entity subEntity (int i) const {
348 return IdentityGridEntity<cc,dim,GridImp>(identityGrid_, hostEntity_.template subEntity<cc>(i));
349 }
350
351
355 identityGrid_,
356 identityGrid_->getHostGrid().levelGridView(level()).ibegin(hostEntity_));
357 }
358
359
363 identityGrid_,
364 identityGrid_->getHostGrid().levelGridView(level()).iend(hostEntity_));
365 }
366
367
371 identityGrid_,
372 identityGrid_->getHostGrid().leafGridView().ibegin(hostEntity_));
373 }
374
375
379 identityGrid_,
380 identityGrid_->getHostGrid().leafGridView().iend(hostEntity_));
381 }
382
383
385 bool isLeaf() const {
386 return hostEntity_.isLeaf();
387 }
388
389
392 typename GridImp::template Codim<0>::Entity father () const {
393 return IdentityGridEntity(identityGrid_, hostEntity_.father());
394 }
395
396
406 LocalGeometry geometryInFather () const
407 {
408 return LocalGeometry( hostEntity_.geometryInFather() );
409 }
410
411
417 {
418 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel);
419 }
420
421
424 {
425 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel, true);
426 }
427
428
430 bool wasRefined () const
431 {
432 if (identityGrid_->adaptationStep!=GridImp::adaptDone)
433 return false;
434
435 int level = this->level();
436 int index = identityGrid_->levelIndexSet(level).index(*this);
437 return identityGrid_->refinementMark_[level][index];
438 }
439
440
442 bool mightBeCoarsened () const
443 {
444 return true;
445 }
446
447
448 // /////////////////////////////////////////
449 // Internal stuff
450 // /////////////////////////////////////////
451
452
453 HostGridEntity hostEntity_;
454 const GridImp* identityGrid_;
455
456 private:
457
458 typedef typename GridImp::ctype ctype;
459
460 }; // end of IdentityGridEntity codim = 0
461
462
463} // namespace Dune
464
465
466#endif
Default Implementations for EntityImp.
Definition: entity.hh:740
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:760
Definition: identitygridentitypointer.hh:19
unsigned int subEntities(unsigned int codim) const
Return the number of subEntities of codimension codim.
Definition: identitygridentity.hh:337
bool isLeaf() const
returns true if Entity has NO children
Definition: identitygridentity.hh:385
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:416
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:239
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:301
IdentityGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: identitygridentity.hh:353
int level() const
Level of this element.
Definition: identitygridentity.hh:307
IdentityGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: identitygridentity.hh:369
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:269
Geometry geometry() const
Geometry of this entity.
Definition: identitygridentity.hh:320
IdentityGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: identitygridentity.hh:361
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:258
IdentityGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: identitygridentity.hh:423
IdentityGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: identitygridentity.hh:377
IdentityGridHierarchicIterator< GridImp > HierarchicIterator
Iterator over descendants of the entity.
Definition: identitygridentity.hh:236
IdentityGridLevelIntersectionIterator< GridImp > LevelIntersectionIterator
The Iterator over intersections on this level.
Definition: identitygridentity.hh:230
bool wasRefined() const
Definition: identitygridentity.hh:430
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:280
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:296
int count() const
Return the number of subEntities of codimension cc.
Definition: identitygridentity.hh:329
GridImp::template Codim< 0 >::Entity father() const
Definition: identitygridentity.hh:392
bool mightBeCoarsened() const
Definition: identitygridentity.hh:442
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: identitygridentity.hh:406
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:347
IdentityGridLeafIntersectionIterator< GridImp > LeafIntersectionIterator
The Iterator over intersections on the leaf level.
Definition: identitygridentity.hh:233
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:314
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:56
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:131
int count() const
Definition: identitygridentity.hh:173
GridImp::template Codim< codim >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:92
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:152
Geometry geometry() const
geometry of this entity
Definition: identitygridentity.hh:179
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:165
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:109
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:147
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:120
int level() const
level of this element
Definition: identitygridentity.hh:158
Iterator over the descendants of an entity.Mesh entities of codimension 0 ("elements") allow to visit...
Definition: identitygridhierarchiciterator.hh:26
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:10
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:22
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)