12
//**********************************************************************
14
// --UGGridLevelIterator
14
//**********************************************************************
16
// --UGGridLevelIterator
16
18
/** \brief Iterator over all entities of a given codimension and level of a grid.
19
template<int codim, PartitionIteratorType pitype, class GridImp>
20
class UGGridLevelIterator :
21
public Dune::UGGridEntityPointer <codim,GridImp>
21
template<int codim, PartitionIteratorType pitype, class GridImp>
22
class UGGridLevelIterator :
23
public Dune::UGGridEntityPointer <codim,GridImp>
23
25
enum {dim = GridImp::dimension};
25
27
friend class UGGridEntity<codim,GridImp::dimension,GridImp>;
28
30
// The type of the UG entity we're pointing to
29
31
typedef typename UG_NS<dim>::template Entity<codim>::T UGEntity;
33
35
typedef typename GridImp::template Codim<codim>::Entity Entity;
36
38
explicit UGGridLevelIterator()
38
this->virtualEntity_.setToTarget(nullptr,nullptr);
40
this->virtualEntity_.setToTarget(nullptr,nullptr);
42
44
explicit UGGridLevelIterator(const GridImp& gridImp, int level) : gridImp_(&gridImp)
44
typename UG_NS<dim>::Grid *theGrid = const_cast<typename UG_NS<dim>::Grid* >(gridImp_->multigrid_->grids[level]);
47
if (pitype==All_Partition || pitype==Ghost_Partition)
48
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::PFirstNode(theGrid),gridImp_);
49
else if (pitype == Dune::Interior_Partition || pitype == Dune::InteriorBorder_Partition)
50
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::FirstNode(theGrid),gridImp_);
51
else // overlap and overlap-front
52
this->virtualEntity_.setToTarget(0,nullptr);
56
if (pitype==All_Partition || pitype==Ghost_Partition)
57
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::PFirstElement(theGrid),gridImp_);
58
else if (pitype == Dune::Interior_Partition || pitype == Dune::InteriorBorder_Partition)
59
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::FirstElement(theGrid),gridImp_);
60
else // overlap and overlap-front
61
this->virtualEntity_.setToTarget(0,nullptr);
64
DUNE_THROW(NotImplemented, "UGGrid level iterators for codimension " << codim);
66
if (this->virtualEntity_.getTarget() && !entityOK_())
46
typename UG_NS<dim>::Grid *theGrid = const_cast<typename UG_NS<dim>::Grid* >(gridImp_->multigrid_->grids[level]);
49
if (pitype==All_Partition || pitype==Ghost_Partition)
50
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::PFirstNode(theGrid),gridImp_);
51
else if (pitype == Dune::Interior_Partition || pitype == Dune::InteriorBorder_Partition)
52
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::FirstNode(theGrid),gridImp_);
53
else // overlap and overlap-front
54
this->virtualEntity_.setToTarget(0,nullptr);
58
if (pitype==All_Partition || pitype==Ghost_Partition)
59
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::PFirstElement(theGrid),gridImp_);
60
else if (pitype == Dune::Interior_Partition || pitype == Dune::InteriorBorder_Partition)
61
this->virtualEntity_.setToTarget((UGEntity*)UG_NS<dim>::FirstElement(theGrid),gridImp_);
62
else // overlap and overlap-front
63
this->virtualEntity_.setToTarget(0,nullptr);
66
DUNE_THROW(NotImplemented, "UGGrid level iterators for codimension " << codim);
68
if (this->virtualEntity_.getTarget() && !entityOK_())
70
72
//! prefix increment
73
assert(this->level() == UG_NS<dim>::myLevel(this->virtualEntity_.getTarget()));
76
this->virtualEntity_.setToTarget(UG_NS<dim>::succ(this->virtualEntity_.getTarget()),gridImp_);
78
while (this->virtualEntity_.getTarget() && !entityOK_());
75
assert(this->level() == UG_NS<dim>::myLevel(this->virtualEntity_.getTarget()));
78
this->virtualEntity_.setToTarget(UG_NS<dim>::succ(this->virtualEntity_.getTarget()),gridImp_);
80
while (this->virtualEntity_.getTarget() && !entityOK_());
83
85
* \brief Return true iff the current entity is within the right
88
if (pitype == All_Partition)
90
if (pitype == All_Partition)
91
Dune::PartitionType entityPIType = this->virtualEntity_.partitionType();
92
if (pitype == Ghost_Partition && entityPIType == GhostEntity)
94
else if (pitype == Interior_Partition && entityPIType == InteriorEntity)
96
else if (pitype == InteriorBorder_Partition &&
97
(entityPIType == BorderEntity ||
98
entityPIType == InteriorEntity))
93
Dune::PartitionType entityPIType = this->virtualEntity_.partitionType();
94
if (pitype == Ghost_Partition && entityPIType == GhostEntity)
96
else if (pitype == Interior_Partition && entityPIType == InteriorEntity)
98
else if (pitype == InteriorBorder_Partition &&
99
(entityPIType == BorderEntity ||
100
entityPIType == InteriorEntity))
103
105
// /////////////////////////////////////