3#ifndef DUNE_MMESH_INTERFACE_MMESHLEAFITERATOR_HH
4#define DUNE_MMESH_INTERFACE_MMESHLEAFITERATOR_HH
11#include <dune/grid/common/gridenums.hh>
19template <
int codim, PartitionIteratorType pitype,
class GridImp,
20 typename Enable =
void>
23template <
int codim, PartitionIteratorType pitype,
class Gr
idImp>
30template <PartitionIteratorType pitype,
class Gr
idImp>
32 0, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 2>> {
35 using HostGridLeafIterator =
36 typename GridImp::HostGridType::Finite_faces_iterator;
38 using HostGridFacet =
typename GridImp::MMeshType::FacetHandle;
41 enum { codimension = 0 };
43 typedef typename GridImp::template Codim<0>::Entity Entity;
49 hostLeafIterator_(pitype == Interior_Partition
50 ? mMesh->partitionHelper().leafInteriorBegin()
51 : mMesh->getHostGrid().finite_faces_begin()),
53 if (proceed()) increment();
63 hostLeafIterator_(pitype == Interior_Partition
64 ? mMesh->partitionHelper().leafInteriorEnd()
65 : mMesh->getHostGrid().finite_faces_end()),
81 return Entity{{mMesh_, HostGridFacet(hostLeafIterator_, face_)}};
86 return hostLeafIterator_ == i.hostLeafIterator_ && face_ == i.face_;
92 const auto endIterator = (pitype == Interior_Partition
93 ? mMesh_->partitionHelper().leafInteriorEnd()
94 : mMesh_->getHostGrid().finite_faces_end());
95 if (hostLeafIterator_ == endIterator)
return false;
97 HostGridFacet facet(hostLeafIterator_, face_);
98 if (!mMesh_->isInterface(facet))
return true;
100 const auto mirrored = hostLeafIterator_->neighbor(face_);
101 if (hostLeafIterator_->info().insertionIndex >
102 mirrored->info().insertionIndex)
105 return !mMesh_->partitionHelper().contains(pitype, dereference());
108 const GridImp* mMesh_;
110 HostGridLeafIterator hostLeafIterator_;
114template <PartitionIteratorType pitype,
class Gr
idImp>
115class MMeshInterfaceGridLeafIteratorImp<
116 1, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 2>> {
119 typedef typename GridImp::HostGridType::Vertex_iterator HostGridLeafIterator;
122 enum { codimension = GridImp::dimension };
124 typedef typename GridImp::template Codim<codimension>::Entity Entity;
126 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh)
128 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_begin()),
129 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end()) {
130 while (proceed()) ++hostLeafIterator_;
137 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh,
140 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_end()),
141 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end()) {}
147 while (proceed()) ++hostLeafIterator_;
151 Entity dereference()
const {
return Entity{{mMesh_, hostLeafIterator_}}; }
154 bool equals(
const MMeshInterfaceGridLeafIteratorImp& i)
const {
155 return hostLeafIterator_ == i.hostLeafIterator_;
161 if (hostLeafIterator_ == hostLeafIteratorEnd_)
return false;
162 if (!hostLeafIterator_->info().isInterface)
return true;
163 return !mMesh_->partitionHelper().contains(pitype, dereference());
166 const GridImp* mMesh_;
168 HostGridLeafIterator hostLeafIterator_;
169 HostGridLeafIterator hostLeafIteratorEnd_;
176template <PartitionIteratorType pitype,
class Gr
idImp>
178 0, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 3>> {
181 using HostGridLeafIterator =
182 typename GridImp::HostGridType::Finite_cells_iterator;
184 using HostGridFacet =
typename GridImp::MMeshType::FacetHandle;
187 enum { codimension = 0 };
189 typedef typename GridImp::template Codim<0>::Entity Entity;
195 hostLeafIterator_(pitype == Interior_Partition
196 ? mMesh->partitionHelper().leafInteriorBegin()
197 : mMesh->getHostGrid().finite_cells_begin()),
199 if (proceed()) increment();
209 hostLeafIterator_(pitype == Interior_Partition
210 ? mMesh->partitionHelper().leafInteriorEnd()
211 : mMesh->getHostGrid().finite_cells_end()),
227 return Entity{{mMesh_, HostGridFacet(hostLeafIterator_, face_)}};
232 return hostLeafIterator_ == i.hostLeafIterator_ && face_ == i.face_;
238 const auto endIterator = (pitype == Interior_Partition
239 ? mMesh_->partitionHelper().leafInteriorEnd()
240 : mMesh_->getHostGrid().finite_cells_end());
241 if (hostLeafIterator_ == endIterator)
return false;
243 HostGridFacet facet(hostLeafIterator_, face_);
244 if (!mMesh_->isInterface(facet))
return true;
246 const auto mirrored = hostLeafIterator_->neighbor(face_);
247 if (hostLeafIterator_->info().insertionIndex >
248 mirrored->info().insertionIndex)
251 return !mMesh_->partitionHelper().contains(pitype, dereference());
254 const GridImp* mMesh_;
256 HostGridLeafIterator hostLeafIterator_;
260template <PartitionIteratorType pitype,
class Gr
idImp>
261class MMeshInterfaceGridLeafIteratorImp<
262 1, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 3>> {
265 using HostGridLeafIterator =
266 typename GridImp::HostGridType::Finite_edges_iterator;
269 enum { codimension = 1 };
271 typedef typename GridImp::template Codim<1>::Entity Entity;
273 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh)
275 hostLeafIterator_(mMesh->getHostGrid().finite_edges_begin()),
276 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_edges_end()) {
277 while (proceed()) ++hostLeafIterator_;
284 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh,
287 hostLeafIterator_(mMesh->getHostGrid().finite_edges_end()),
288 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_edges_end()) {}
294 while (proceed()) ++hostLeafIterator_;
298 Entity dereference()
const {
return Entity{{mMesh_, *hostLeafIterator_}}; }
301 bool equals(
const MMeshInterfaceGridLeafIteratorImp& i)
const {
302 return hostLeafIterator_ == i.hostLeafIterator_;
308 if (hostLeafIterator_ == hostLeafIteratorEnd_)
return false;
309 if (!mMesh_->isInterface(*hostLeafIterator_))
return true;
310 return !mMesh_->partitionHelper().contains(pitype, dereference());
313 const GridImp* mMesh_;
315 HostGridLeafIterator hostLeafIterator_;
316 HostGridLeafIterator hostLeafIteratorEnd_;
319template <PartitionIteratorType pitype,
class Gr
idImp>
320class MMeshInterfaceGridLeafIteratorImp<
321 2, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 3>> {
324 typedef typename GridImp::HostGridType::Vertex_iterator HostGridLeafIterator;
327 enum { codimension = GridImp::dimension };
329 typedef typename GridImp::template Codim<codimension>::Entity Entity;
331 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh)
333 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_begin()),
334 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end()) {
335 while (proceed()) ++hostLeafIterator_;
342 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh,
345 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_end()),
346 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end()) {}
352 while (proceed()) ++hostLeafIterator_;
356 Entity dereference()
const {
return Entity{{mMesh_, hostLeafIterator_}}; }
359 bool equals(
const MMeshInterfaceGridLeafIteratorImp& i)
const {
360 return hostLeafIterator_ == i.hostLeafIterator_;
366 if (hostLeafIterator_ == hostLeafIteratorEnd_)
return false;
367 if (!hostLeafIterator_->info().isInterface)
return true;
368 return !mMesh_->partitionHelper().contains(pitype, dereference());
371 const GridImp* mMesh_;
373 HostGridLeafIterator hostLeafIterator_;
374 HostGridLeafIterator hostLeafIteratorEnd_;
void increment()
prefix increment
Definition: leafiterator.hh:215
Entity dereference() const
dereferencing
Definition: leafiterator.hh:226
bool equals(const MMeshInterfaceGridLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:231
MMeshInterfaceGridLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:206
Entity dereference() const
dereferencing
Definition: leafiterator.hh:80
MMeshInterfaceGridLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:60
void increment()
prefix increment
Definition: leafiterator.hh:69
bool equals(const MMeshInterfaceGridLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:85
Iterator over all entities of a given codimension and level of a grid (2D).
Definition: leafiterator.hh:21