DUNE PDELab (git)

identitygridentity.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_IDENTITYGRIDENTITY_HH
6#define DUNE_IDENTITYGRIDENTITY_HH
7
13
14namespace Dune {
15
16
17 // Forward declarations
18
19 template<int codim, int dim, class GridImp>
20 class IdentityGridEntity;
21
22 template<int codim, PartitionIteratorType pitype, class GridImp>
23 class IdentityGridLevelIterator;
24
25 template<class GridImp>
26 class IdentityGridLevelIntersectionIterator;
27
28 template<class GridImp>
29 class IdentityGridLeafIntersectionIterator;
30
31 template<class GridImp>
32 class IdentityGridHierarchicIterator;
33
34
35 // External forward declarations
36 template< class Grid >
37 struct HostGridAccess;
38
39
40 //**********************************************************************
41 //
42 // --IdentityGridEntity
43 // --Entity
44 //
52 template<int codim, int dim, class GridImp>
54 public EntityDefaultImplementation <codim,dim,GridImp,IdentityGridEntity>
55 {
56
57 template <class GridImp_>
58 friend class IdentityGridLevelIndexSet;
59
60 template <class GridImp_>
61 friend class IdentityGridLeafIndexSet;
62
63 template <class GridImp_>
64 friend class IdentityGridLocalIdSet;
65
66 template <class GridImp_>
67 friend class IdentityGridGlobalIdSet;
68
69 friend struct HostGridAccess< typename std::remove_const< GridImp >::type >;
70
71
72 private:
73
74 typedef typename GridImp::ctype ctype;
75
76 // The codimension of this entity wrt the host grid
77 constexpr static int CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension + codim;
78
79 // equivalent entity in the host grid
80 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
81
82
83 public:
84
85 typedef typename GridImp::template Codim<codim>::Geometry Geometry;
86
88 typedef typename GridImp::template Codim<codim>::EntitySeed EntitySeed;
89
91 : identityGrid_(nullptr)
92 {}
93
94 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
95 : hostEntity_(hostEntity)
96 , identityGrid_(identityGrid)
97 {}
98
99 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
100 : hostEntity_(std::move(hostEntity))
101 , identityGrid_(identityGrid)
102 {}
103
106 : hostEntity_(original.hostEntity_)
107 , identityGrid_(original.identityGrid_)
108 {}
109
111 : hostEntity_(std::move(original.hostEntity_))
112 , identityGrid_(original.identityGrid_)
113 {}
114
117 {
118 if (this != &original)
119 {
120 identityGrid_ = original.identityGrid_;
121 hostEntity_ = original.hostEntity_;
122 }
123 return *this;
124 }
125
128 {
129 if (this != &original)
130 {
131 identityGrid_ = original.identityGrid_;
132 hostEntity_ = std::move(original.hostEntity_);
133 }
134 return *this;
135 }
136
137 bool equals(const IdentityGridEntity& other) const
138 {
139 return hostEntity_ == other.hostEntity_;
140 }
141
143 bool hasFather () const {
144 return hostEntity_.hasFather();
145 }
146
149 {
150 return EntitySeed(hostEntity_);
151 }
152
154 int level () const {
155 return hostEntity_.level();
156 }
157
158
162 return hostEntity_.partitionType();
163 }
164
167 unsigned int subEntities (unsigned int cc) const
168 {
169 return hostEntity_.subEntities(cc);
170 }
171
173 Geometry geometry () const
174 {
175 return Geometry( hostEntity_.geometry() );
176 }
177
178
179 HostGridEntity hostEntity_;
180
181 private:
182
183 const GridImp* identityGrid_;
184
185 };
186
187
188
189
190 //***********************
191 //
192 // --IdentityGridEntity
193 //
194 //***********************
202 template<int dim, class GridImp>
203 class IdentityGridEntity<0,dim,GridImp> :
204 public EntityDefaultImplementation<0,dim,GridImp, IdentityGridEntity>
205 {
206 friend struct HostGridAccess< typename std::remove_const< GridImp >::type >;
207
208 public:
209
210 // The codimension of this entitypointer wrt the host grid
211 constexpr static int CodimInHostGrid = GridImp::HostGridType::dimension - GridImp::dimension;
212
213 // equivalent entity in the host grid
214 typedef typename GridImp::HostGridType::Traits::template Codim<CodimInHostGrid>::Entity HostGridEntity;
215
216 typedef typename GridImp::template Codim<0>::Geometry Geometry;
217
218 typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
219
222
225
228
230 typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
231
232
233
235 : identityGrid_(nullptr)
236 {}
237
238 IdentityGridEntity(const GridImp* identityGrid, const HostGridEntity& hostEntity)
239 : hostEntity_(hostEntity)
240 , identityGrid_(identityGrid)
241 {}
242
243 IdentityGridEntity(const GridImp* identityGrid, HostGridEntity&& hostEntity)
244 : hostEntity_(std::move(hostEntity))
245 , identityGrid_(identityGrid)
246 {}
247
250 : hostEntity_(original.hostEntity_)
251 , identityGrid_(original.identityGrid_)
252 {}
253
255 : hostEntity_(std::move(original.hostEntity_))
256 , identityGrid_(original.identityGrid_)
257 {}
258
261 {
262 if (this != &original)
263 {
264 identityGrid_ = original.identityGrid_;
265 hostEntity_ = original.hostEntity_;
266 }
267 return *this;
268 }
269
272 {
273 if (this != &original)
274 {
275 identityGrid_ = original.identityGrid_;
276 hostEntity_ = std::move(original.hostEntity_);
277 }
278 return *this;
279 }
280
281 bool equals(const IdentityGridEntity& other) const
282 {
283 return hostEntity_ == other.hostEntity_;
284 }
285
287 bool hasFather () const {
288 return hostEntity_.hasFather();
289 }
290
293 {
294 return EntitySeed(hostEntity_);
295 }
296
298 int level () const
299 {
300 return hostEntity_.level();
301 }
302
303
306 return hostEntity_.partitionType();
307 }
308
309
311 Geometry geometry () const
312 {
313 return Geometry( hostEntity_.geometry() );
314 }
315
316
319 unsigned int subEntities (unsigned int codim) const
320 {
321 return hostEntity_.subEntities(codim);
322 }
323
324
328 template<int cc>
329 typename GridImp::template Codim<cc>::Entity subEntity (int i) const {
330 return IdentityGridEntity<cc,dim,GridImp>(identityGrid_, hostEntity_.template subEntity<cc>(i));
331 }
332
333
337 identityGrid_,
338 identityGrid_->getHostGrid().levelGridView(level()).ibegin(hostEntity_));
339 }
340
341
345 identityGrid_,
346 identityGrid_->getHostGrid().levelGridView(level()).iend(hostEntity_));
347 }
348
349
353 identityGrid_,
354 identityGrid_->getHostGrid().leafGridView().ibegin(hostEntity_));
355 }
356
357
361 identityGrid_,
362 identityGrid_->getHostGrid().leafGridView().iend(hostEntity_));
363 }
364
365
367 bool isLeaf() const {
368 return hostEntity_.isLeaf();
369 }
370
371
374 typename GridImp::template Codim<0>::Entity father () const {
375 return IdentityGridEntity(identityGrid_, hostEntity_.father());
376 }
377
378
388 LocalGeometry geometryInFather () const
389 {
390 return LocalGeometry( hostEntity_.geometryInFather() );
391 }
392
393
399 {
400 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel);
401 }
402
403
406 {
407 return IdentityGridHierarchicIterator<const GridImp>(identityGrid_, *this, maxLevel, true);
408 }
409
410
412 bool wasRefined () const
413 {
414 if (identityGrid_->adaptationStep!=GridImp::adaptDone)
415 return false;
416
417 int level = this->level();
418 int index = identityGrid_->levelIndexSet(level).index(*this);
419 return identityGrid_->refinementMark_[level][index];
420 }
421
422
424 bool mightBeCoarsened () const
425 {
426 return true;
427 }
428
429
430 // /////////////////////////////////////////
431 // Internal stuff
432 // /////////////////////////////////////////
433
434
435 HostGridEntity hostEntity_;
436 const GridImp* identityGrid_;
437
438 private:
439
440 typedef typename GridImp::ctype ctype;
441
442 }; // end of IdentityGridEntity codim = 0
443
444
445} // namespace Dune
446
447
448#endif
Default Implementations for EntityImp.
Definition: entity.hh:542
GeometryType type() const
Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.
Definition: entity.hh:576
unsigned int subEntities(unsigned int codim) const
Return the number of subEntities of codimension codim.
Definition: identitygridentity.hh:319
bool isLeaf() const
returns true if Entity has NO children
Definition: identitygridentity.hh:367
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:398
GridImp::template Codim< 0 >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:230
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:292
IdentityGridLevelIntersectionIterator< GridImp > ilevelbegin() const
First level intersection.
Definition: identitygridentity.hh:335
int level() const
Level of this element.
Definition: identitygridentity.hh:298
IdentityGridLeafIntersectionIterator< GridImp > ileafbegin() const
First leaf intersection.
Definition: identitygridentity.hh:351
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:260
Geometry geometry() const
Geometry of this entity.
Definition: identitygridentity.hh:311
IdentityGridLevelIntersectionIterator< GridImp > ilevelend() const
Reference to one past the last neighbor.
Definition: identitygridentity.hh:343
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:249
IdentityGridHierarchicIterator< GridImp > hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: identitygridentity.hh:405
IdentityGridLeafIntersectionIterator< GridImp > ileafend() const
Reference to one past the last leaf intersection.
Definition: identitygridentity.hh:359
bool wasRefined() const
Definition: identitygridentity.hh:412
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:271
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:287
GridImp::template Codim< 0 >::Entity father() const
Definition: identitygridentity.hh:374
bool mightBeCoarsened() const
Definition: identitygridentity.hh:424
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father. This is sufficient ...
Definition: identitygridentity.hh:388
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:329
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:305
The implementation of entities in a IdentityGrid.
Definition: identitygridentity.hh:55
IdentityGridEntity & operator=(IdentityGridEntity &&original)
Definition: identitygridentity.hh:127
GridImp::template Codim< codim >::EntitySeed EntitySeed
The type of the EntitySeed interface class.
Definition: identitygridentity.hh:88
EntitySeed seed() const
Create EntitySeed.
Definition: identitygridentity.hh:148
Geometry geometry() const
geometry of this entity
Definition: identitygridentity.hh:173
PartitionType partitionType() const
The partition type for parallel computing.
Definition: identitygridentity.hh:161
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension codim.
Definition: identitygridentity.hh:167
IdentityGridEntity(const IdentityGridEntity &original)
Definition: identitygridentity.hh:105
bool hasFather() const
returns true if father entity exists
Definition: identitygridentity.hh:143
IdentityGridEntity & operator=(const IdentityGridEntity &original)
Definition: identitygridentity.hh:116
int level() const
level of this element
Definition: identitygridentity.hh:154
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:29
Definition: identitygridindexsets.hh:26
Definition: identitygridintersectioniterator.hh:84
Different resources needed by all grid implementations.
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Static tag representing a codimension.
Definition: dimension.hh:24
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 (Nov 13, 23:29, 2024)