Loading [MathJax]/extensions/tex2jax.js

dune-mmesh (1.4)

leafiterator.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_MMESH_GRID_MMESHLEAFITERATOR_HH
4#define DUNE_MMESH_GRID_MMESHLEAFITERATOR_HH
5
6
11// Dune includes
12#include <dune/grid/common/gridenums.hh>
13
14namespace Dune
15{
16
21 template<int codim, PartitionIteratorType pitype, class GridImp, typename Enable = void>
23
24 template<int codim, PartitionIteratorType pitype, class GridImp>
26
30 template<PartitionIteratorType pitype, class GridImp>
31 class MMeshLeafIteratorImp<0, pitype, GridImp, std::enable_if_t<GridImp::dimension == 2>>
32 {
33 public:
35 using HostGridLeafIterator = typename GridImp::HostGridType::Finite_faces_iterator;
36 enum {codimension = 0};
37
38 typedef typename GridImp::template Codim<0>::Entity Entity;
39
40 explicit MMeshLeafIteratorImp() :
41 mMesh_(nullptr)
42 {}
43
44 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
45 mMesh_(mMesh),
46 hostLeafIterator_(pitype == Interior_Partition
47 ? mMesh->partitionHelper().leafInteriorBegin()
48 : mMesh->getHostGrid().finite_faces_begin())
49 {
50 while( proceed() )
51 increment();
52 }
53
58 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
59 mMesh_(mMesh),
60 hostLeafIterator_(pitype == Interior_Partition
61 ? mMesh->partitionHelper().leafInteriorEnd()
62 : mMesh->getHostGrid().finite_faces_end())
63 {}
64
66 void increment() {
67 do {
68 ++hostLeafIterator_;
69 } while( proceed() );
70 }
71
73 Entity dereference() const {
74 return Entity {{ mMesh_, hostLeafIterator_ }};
75 }
76
78 bool equals(const MMeshLeafIteratorImp& i) const {
79 return hostLeafIterator_ == i.hostLeafIterator_;
80 }
81
82 private:
84 bool proceed()
85 {
86 const auto endIterator = (pitype == Interior_Partition ? mMesh_->partitionHelper().leafInteriorEnd() : mMesh_->getHostGrid().finite_faces_end());
87 if (hostLeafIterator_ == endIterator)
88 return false;
89 return !mMesh_->partitionHelper().contains(pitype, hostLeafIterator_->info().partition);
90 }
91
92 const GridImp* mMesh_;
93 HostGridLeafIterator hostLeafIterator_;
94 };
95
96 template<PartitionIteratorType pitype, class GridImp>
97 class MMeshLeafIteratorImp<1, pitype, GridImp, std::enable_if_t<GridImp::dimension == 2>>
98 {
99 private:
101 using HostGridLeafIterator = typename GridImp::HostGridType::Finite_edges_iterator;
102
103 public:
104 enum {codimension = 1};
105
106 typedef typename GridImp::template Codim<1>::Entity Entity;
107
108 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
109 mMesh_(mMesh),
110 hostLeafIterator_(mMesh->getHostGrid().finite_edges_begin())
111 {
112 while( proceed() )
113 increment();
114 }
115
120 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
121 mMesh_(mMesh),
122 hostLeafIterator_(mMesh->getHostGrid().finite_edges_end())
123 {}
124
126 void increment() {
127 do {
128 ++hostLeafIterator_;
129 } while( proceed() );
130 }
131
133 Entity dereference() const {
134 return Entity {{ mMesh_, *hostLeafIterator_ }};
135 }
136
138 bool equals(const MMeshLeafIteratorImp& i) const {
139 return hostLeafIterator_ == i.hostLeafIterator_;
140 }
141
142 private:
144 bool proceed()
145 {
146 if (hostLeafIterator_ == mMesh_->getHostGrid().finite_edges_end())
147 return false;
148 return !mMesh_->partitionHelper().contains(pitype, dereference());
149 }
150 const GridImp* mMesh_;
151
152 HostGridLeafIterator hostLeafIterator_;
153 };
154
155
156 template<PartitionIteratorType pitype, class GridImp>
157 class MMeshLeafIteratorImp<2, pitype, GridImp, std::enable_if_t<GridImp::dimension == 2>>
158 {
159 private:
161 using HostGridLeafIterator = typename GridImp::HostGridType::Finite_vertices_iterator;
162
163 public:
164 enum {codimension = GridImp::dimension};
165
166 typedef typename GridImp::template Codim<codimension>::Entity Entity;
167
168 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
169 mMesh_(mMesh),
170 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_begin())
171 {
172 while( proceed() )
173 increment();
174 }
175
180 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
181 mMesh_(mMesh),
182 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_end())
183 {}
184
186 void increment() {
187 do {
188 ++hostLeafIterator_;
189 } while( proceed() );
190 }
191
193 Entity dereference() const {
194 return Entity {{ mMesh_, hostLeafIterator_ }};
195 }
196
198 bool equals(const MMeshLeafIteratorImp& i) const {
199 return hostLeafIterator_ == i.hostLeafIterator_;
200 }
201
202 private:
204 bool proceed()
205 {
206 if (hostLeafIterator_ == mMesh_->getHostGrid().finite_vertices_end())
207 return false;
208 return !mMesh_->partitionHelper().contains(pitype, hostLeafIterator_->info().partition);
209 }
210
211 const GridImp* mMesh_;
212 HostGridLeafIterator hostLeafIterator_;
213 };
214
215
221 template<PartitionIteratorType pitype, class GridImp>
222 class MMeshLeafIteratorImp<0, pitype, GridImp, std::enable_if_t<GridImp::dimension == 3>>
223 {
224 public:
226 using HostGridLeafIterator = typename GridImp::HostGridType::Finite_cells_iterator;
227
228 enum {codimension = 0};
229
230 typedef typename GridImp::template Codim<0>::Entity Entity;
231
232 explicit MMeshLeafIteratorImp() :
233 mMesh_(nullptr)
234 {}
235
236 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
237 mMesh_(mMesh),
238 hostLeafIterator_(pitype == Interior_Partition
239 ? mMesh->partitionHelper().leafInteriorBegin()
240 : mMesh->getHostGrid().finite_cells_begin())
241 {
242 while( proceed() )
243 increment();
244 }
245
250 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
251 mMesh_(mMesh),
252 hostLeafIterator_(pitype == Interior_Partition
253 ? mMesh->partitionHelper().leafInteriorEnd()
254 : mMesh->getHostGrid().finite_cells_end())
255 {}
256
258 void increment() {
259 do {
260 ++hostLeafIterator_;
261 } while( proceed() );
262 }
263
265 Entity dereference() const {
266 return Entity {{ mMesh_, hostLeafIterator_ }};
267 }
268
270 bool equals(const MMeshLeafIteratorImp& i) const {
271 return hostLeafIterator_ == i.hostLeafIterator_;
272 }
273
274 private:
276 bool proceed()
277 {
278 const auto endIterator = (pitype == Interior_Partition ? mMesh_->partitionHelper().leafInteriorEnd() : mMesh_->getHostGrid().finite_cells_end());
279 if (hostLeafIterator_ == endIterator)
280 return false;
281 return !mMesh_->partitionHelper().contains(pitype, hostLeafIterator_->info().partition);
282 }
283
284 const GridImp* mMesh_;
285 HostGridLeafIterator hostLeafIterator_;
286 };
287
288
290 template<PartitionIteratorType pitype, class GridImp>
291 class MMeshLeafIteratorImp<1, pitype, GridImp, std::enable_if_t<GridImp::dimension == 3>>
292 {
293 private:
295 using HostGridLeafIterator = typename GridImp::HostGridType::Finite_facets_iterator;
296
297 public:
298 enum {codimension = 1};
299
300 typedef typename GridImp::template Codim<1>::Entity Entity;
301
302 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
303 mMesh_(mMesh),
304 hostLeafIterator_(mMesh->getHostGrid().finite_facets_begin())
305 {
306 while( proceed() )
307 increment();
308 }
309
314 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
315 mMesh_(mMesh),
316 hostLeafIterator_(mMesh->getHostGrid().finite_facets_end())
317 {}
318
320 void increment() {
321 do {
322 ++hostLeafIterator_;
323 } while( proceed() );
324 }
325
327 Entity dereference() const {
328 return Entity {{ mMesh_, *hostLeafIterator_ }};
329 }
330
332 bool equals(const MMeshLeafIteratorImp& i) const {
333 return hostLeafIterator_ == i.hostLeafIterator_;
334 }
335
336 private:
338 bool proceed()
339 {
340 if (hostLeafIterator_ == mMesh_->getHostGrid().finite_facets_end())
341 return false;
342 return !mMesh_->partitionHelper().contains(pitype, dereference());
343 }
344
345 const GridImp* mMesh_;
346 HostGridLeafIterator hostLeafIterator_;
347 };
348
349
351 template<PartitionIteratorType pitype, class GridImp>
352 class MMeshLeafIteratorImp<2, pitype, GridImp, std::enable_if_t<GridImp::dimension == 3>>
353 {
354 private:
356 using HostGridLeafIterator = typename GridImp::HostGridType::Finite_edges_iterator;
357
358 public:
359 enum {codimension = 2};
360
361 typedef typename GridImp::template Codim<2>::Entity Entity;
362
363 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
364 mMesh_(mMesh),
365 hostLeafIterator_(mMesh->getHostGrid().finite_edges_begin())
366 {
367 while( proceed() )
368 increment();
369 }
370
375 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
376 mMesh_(mMesh),
377 hostLeafIterator_(mMesh->getHostGrid().finite_edges_end())
378 {}
379
381 void increment() {
382 do {
383 ++hostLeafIterator_;
384 } while( proceed() );
385 }
386
388 Entity dereference() const {
389 return Entity {{ mMesh_, *hostLeafIterator_ }};
390 }
391
393 bool equals(const MMeshLeafIteratorImp& i) const {
394 return hostLeafIterator_ == i.hostLeafIterator_;
395 }
396
397 private:
399 bool proceed()
400 {
401 if (hostLeafIterator_ == mMesh_->getHostGrid().finite_edges_end())
402 return false;
403 return !mMesh_->partitionHelper().contains(pitype, dereference());
404 }
405
406 const GridImp* mMesh_;
407 HostGridLeafIterator hostLeafIterator_;
408 };
409
410
412 template<PartitionIteratorType pitype, class GridImp>
413 class MMeshLeafIteratorImp<3, pitype, GridImp, std::enable_if_t<GridImp::dimension == 3>>
414 {
415 private:
417 typedef typename GridImp::HostGridType::Vertex_iterator HostGridLeafIterator;
418
419 public:
420 enum {codimension = GridImp::dimension};
421
422 typedef typename GridImp::template Codim<codimension>::Entity Entity;
423
424 explicit MMeshLeafIteratorImp(const GridImp* mMesh) :
425 mMesh_(mMesh),
426 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_begin())
427 {
428 while( proceed() )
429 increment();
430 }
431
436 explicit MMeshLeafIteratorImp(const GridImp* mMesh, bool endDummy) :
437 mMesh_(mMesh),
438 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_end())
439 {}
440
442 void increment() {
443 do {
444 ++hostLeafIterator_;
445 } while( proceed() );
446 }
447
449 Entity dereference() const {
450 return Entity {{ mMesh_, hostLeafIterator_ }};
451 }
452
454 bool equals(const MMeshLeafIteratorImp& i) const {
455 return hostLeafIterator_ == i.hostLeafIterator_;
456 }
457
458 private:
460 bool proceed()
461 {
462 if (hostLeafIterator_ == HostGridLeafIterator(mMesh_->getHostGrid().finite_vertices_end()))
463 return false;
464 if (hostLeafIterator_ == mMesh_->getHostGrid().infinite_vertex())
465 return true;
466 return !mMesh_->partitionHelper().contains(pitype, hostLeafIterator_->info().partition);
467 }
468
469 const GridImp* mMesh_;
470 HostGridLeafIterator hostLeafIterator_;
471 };
472
473} // namespace Dune
474
475#endif
bool equals(const MMeshLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:78
MMeshLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:58
typename GridImp::HostGridType::Finite_faces_iterator HostGridLeafIterator
The type of the underlying entities.
Definition: leafiterator.hh:35
Entity dereference() const
dereferencing
Definition: leafiterator.hh:265
typename GridImp::HostGridType::Finite_cells_iterator HostGridLeafIterator
The type of the underlying entities.
Definition: leafiterator.hh:226
bool equals(const MMeshLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:270
MMeshLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:250
bool equals(const MMeshLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:332
MMeshLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:314
Entity dereference() const
dereferencing
Definition: leafiterator.hh:327
bool equals(const MMeshLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:393
Entity dereference() const
dereferencing
Definition: leafiterator.hh:388
MMeshLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:375
Entity dereference() const
dereferencing
Definition: leafiterator.hh:449
bool equals(const MMeshLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:454
MMeshLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which create the end iterator.
Definition: leafiterator.hh:436
Iterator over all entities of a given codimension and level of a grid (2D).
Definition: leafiterator.hh:22
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 13, 22:42, 2025)