3#ifndef DUNE_MMESH_INTERFACE_MMESHLEAFITERATOR_HH
4#define DUNE_MMESH_INTERFACE_MMESHLEAFITERATOR_HH
12#include <dune/grid/common/gridenums.hh>
21 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp,
typename Enable =
void>
24 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
30 template<PartitionIteratorType pitype,
class Gr
idImp>
35 using HostGridLeafIterator =
typename GridImp::HostGridType::Finite_faces_iterator;
37 using HostGridFacet =
typename GridImp::MMeshType::FacetHandle;
40 enum {codimension = 0};
42 typedef typename GridImp::template Codim<0>::Entity Entity;
50 hostLeafIterator_(pitype == Interior_Partition
51 ? mMesh->partitionHelper().leafInteriorBegin()
52 : mMesh->getHostGrid().finite_faces_begin()),
65 hostLeafIterator_(pitype == Interior_Partition
66 ? mMesh->partitionHelper().leafInteriorEnd()
67 : mMesh->getHostGrid().finite_faces_end()),
86 return Entity {{ mMesh_, HostGridFacet( hostLeafIterator_, face_ ) }};
91 return hostLeafIterator_ == i.hostLeafIterator_ && face_ == i.face_;
98 const auto endIterator = (pitype == Interior_Partition ? mMesh_->partitionHelper().leafInteriorEnd() : mMesh_->getHostGrid().finite_faces_end());
99 if (hostLeafIterator_ == endIterator)
102 HostGridFacet facet ( hostLeafIterator_, face_ );
103 if (!mMesh_->isInterface( facet ))
106 const auto mirrored = hostLeafIterator_->neighbor( face_ );
107 if ( hostLeafIterator_->info().insertionIndex > mirrored->info().insertionIndex )
110 return !mMesh_->partitionHelper().contains(pitype, dereference());
113 const GridImp* mMesh_;
115 HostGridLeafIterator hostLeafIterator_;
120 template<PartitionIteratorType pitype,
class Gr
idImp>
121 class MMeshInterfaceGridLeafIteratorImp<1, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 2>>
125 typedef typename GridImp::HostGridType::Vertex_iterator HostGridLeafIterator;
128 enum {codimension = GridImp::dimension};
130 typedef typename GridImp::template Codim<codimension>::Entity Entity;
132 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh) :
134 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_begin()),
135 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end())
145 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh,
bool endDummy) :
147 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_end()),
148 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end())
160 Entity dereference()
const {
161 return Entity {{ mMesh_, hostLeafIterator_ }};
165 bool equals(
const MMeshInterfaceGridLeafIteratorImp& i)
const {
166 return hostLeafIterator_ == i.hostLeafIterator_;
173 if (hostLeafIterator_ == hostLeafIteratorEnd_)
175 if (!hostLeafIterator_->info().isInterface)
177 return !mMesh_->partitionHelper().contains(pitype, dereference());
180 const GridImp* mMesh_;
182 HostGridLeafIterator hostLeafIterator_;
183 HostGridLeafIterator hostLeafIteratorEnd_;
191 template<PartitionIteratorType pitype,
class Gr
idImp>
196 using HostGridLeafIterator =
typename GridImp::HostGridType::Finite_cells_iterator;
198 using HostGridFacet =
typename GridImp::MMeshType::FacetHandle;
201 enum {codimension = 0};
203 typedef typename GridImp::template Codim<0>::Entity Entity;
211 hostLeafIterator_(pitype == Interior_Partition
212 ? mMesh->partitionHelper().leafInteriorBegin()
213 : mMesh->getHostGrid().finite_cells_begin()),
226 hostLeafIterator_(pitype == Interior_Partition
227 ? mMesh->partitionHelper().leafInteriorEnd()
228 : mMesh->getHostGrid().finite_cells_end()),
247 return Entity {{ mMesh_, HostGridFacet( hostLeafIterator_, face_ ) }};
252 return hostLeafIterator_ == i.hostLeafIterator_ && face_ == i.face_;
259 const auto endIterator = (pitype == Interior_Partition ? mMesh_->partitionHelper().leafInteriorEnd() : mMesh_->getHostGrid().finite_cells_end());
260 if (hostLeafIterator_ == endIterator)
263 HostGridFacet facet ( hostLeafIterator_, face_ );
264 if (!mMesh_->isInterface( facet ))
267 const auto mirrored = hostLeafIterator_->neighbor( face_ );
268 if ( hostLeafIterator_->info().insertionIndex > mirrored->info().insertionIndex )
271 return !mMesh_->partitionHelper().contains(pitype, dereference());
274 const GridImp* mMesh_;
276 HostGridLeafIterator hostLeafIterator_;
280 template<PartitionIteratorType pitype,
class Gr
idImp>
281 class MMeshInterfaceGridLeafIteratorImp<1, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 3>>
285 using HostGridLeafIterator =
typename GridImp::HostGridType::Finite_edges_iterator;
288 enum {codimension = 1};
290 typedef typename GridImp::template Codim<1>::Entity Entity;
292 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh) :
294 hostLeafIterator_(mMesh->getHostGrid().finite_edges_begin()),
295 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_edges_end())
305 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh,
bool endDummy) :
307 hostLeafIterator_(mMesh->getHostGrid().finite_edges_end()),
308 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_edges_end())
320 Entity dereference()
const {
321 return Entity {{ mMesh_, *hostLeafIterator_ }};
325 bool equals(
const MMeshInterfaceGridLeafIteratorImp& i)
const {
326 return hostLeafIterator_ == i.hostLeafIterator_;
333 if (hostLeafIterator_ == hostLeafIteratorEnd_)
335 if (!mMesh_->isInterface( *hostLeafIterator_ ))
337 return !mMesh_->partitionHelper().contains(pitype, dereference());
340 const GridImp* mMesh_;
342 HostGridLeafIterator hostLeafIterator_;
343 HostGridLeafIterator hostLeafIteratorEnd_;
346 template<PartitionIteratorType pitype,
class Gr
idImp>
347 class MMeshInterfaceGridLeafIteratorImp<2, pitype, GridImp,
std::enable_if_t<GridImp::dimensionworld == 3>>
351 typedef typename GridImp::HostGridType::Vertex_iterator HostGridLeafIterator;
354 enum {codimension = GridImp::dimension};
356 typedef typename GridImp::template Codim<codimension>::Entity Entity;
358 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh) :
360 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_begin()),
361 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end())
371 explicit MMeshInterfaceGridLeafIteratorImp(
const GridImp* mMesh,
bool endDummy) :
373 hostLeafIterator_(mMesh->getHostGrid().finite_vertices_end()),
374 hostLeafIteratorEnd_(mMesh->getHostGrid().finite_vertices_end())
386 Entity dereference()
const {
387 return Entity {{ mMesh_, hostLeafIterator_ }};
391 bool equals(
const MMeshInterfaceGridLeafIteratorImp& i)
const {
392 return hostLeafIterator_ == i.hostLeafIterator_;
399 if (hostLeafIterator_ == hostLeafIteratorEnd_)
401 if (!hostLeafIterator_->info().isInterface)
403 return !mMesh_->partitionHelper().contains(pitype, dereference());
406 const GridImp* mMesh_;
408 HostGridLeafIterator hostLeafIterator_;
409 HostGridLeafIterator hostLeafIteratorEnd_;
void increment()
prefix increment
Definition: leafiterator.hh:233
Entity dereference() const
dereferencing
Definition: leafiterator.hh:246
bool equals(const MMeshInterfaceGridLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:251
MMeshInterfaceGridLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:224
Entity dereference() const
dereferencing
Definition: leafiterator.hh:85
MMeshInterfaceGridLeafIteratorImp(const GridImp *mMesh, bool endDummy)
Constructor which creates the end iterator.
Definition: leafiterator.hh:63
void increment()
prefix increment
Definition: leafiterator.hh:72
bool equals(const MMeshInterfaceGridLeafIteratorImp &i) const
equality
Definition: leafiterator.hh:90
Iterator over all entities of a given codimension and level of a grid (2D).
Definition: leafiterator.hh:22