Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
globalintersectioniterator.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef GLOBAL_INTERSECTION_ITERATOR_HH
5#define GLOBAL_INTERSECTION_ITERATOR_HH
6
7#warning This header is deprecated and will be removed after 2.11. Use domains/intersectionsetiterator.hh instead.
8
19
21
27template <class IntersectionIterator, bool returnsReference>
28struct
29[[deprecated("This class is deprecated and will be removed after 2.11.")]]
31
32 typedef typename IntersectionIterator::Intersection Intersection;
33
34 static const Intersection& returnReference(IntersectionIterator* nIt,
35 const Intersection& intersection)
36 {
37 return intersection;
38 }
39};
40
41template <class IntersectionIterator>
42struct ReturnReferenceHelper<IntersectionIterator,true> {
43
44 typedef typename IntersectionIterator::Intersection Intersection;
45
46 static const Intersection& returnReference(IntersectionIterator* nIt,
47 const Intersection& intersection)
48 {
49 return **nIt;
50 }
51};
52
58template <class IntersectionIterator, bool returnsReference>
59static const typename IntersectionIterator::Intersection&
60[[deprecated("This function is deprecated and will be removed after 2.11.")]]
61returnReference(IntersectionIterator* nIt,
62 const typename IntersectionIterator::Intersection& intersection)
63{
65}
66
67
85template <class GridView, class Impl>
86class
87[[deprecated("This class is deprecated and will be removed after 2.11. Use Dune::Fufem::IntersectionSetIterator instead.")]]
89 : public Dune::ForwardIteratorFacade<GlobalIntersectionIterator<GridView, Impl>, const typename GridView::Intersection>
90{
91 enum {dim=GridView::dimension};
92
93 typedef typename GridView::IntersectionIterator IntersectionIterator;
94 typedef typename GridView::template Codim<0>::Iterator ElementIterator;
95
96public:
99 typedef typename IntersectionIterator::Intersection Intersection;
100
101private:
102 // If this value is true, then the implementation still returns the Intersection by const reference
103 // thus in this case we don't need to store the intersections at all
104 static const bool isReference = std::is_lvalue_reference<decltype(std::declval<IntersectionIterator>().operator*())>::value;
105
106public:
107
109
110
123 GlobalIntersectionIterator(const GridView& gridView, PositionFlag flag) :
124 gridView_(gridView),
125 eIt_(gridView.template end<0>()),
126 endEIt_(gridView.template end<0>()),
127 nIt_(0)
128 {
129 if (flag==begin)
130 {
131 eIt_ = gridView.template begin<0>();
132 nIt_ = new IntersectionIterator(gridView.ibegin(*eIt_));
133 }
134 }
135
149 GlobalIntersectionIterator(const GridView& gridView, const ElementIterator& eIt, const ElementIterator& endEIt) :
150 gridView_(gridView),
151 eIt_(eIt),
152 endEIt_(endEIt),
153 nIt_(0)
154 {
155 if (eIt_!=endEIt_)
156 nIt_ = new IntersectionIterator(gridView.ibegin(*eIt_));
157 }
158
164 gridView_(other.gridView_),
165 eIt_(other.eIt_),
166 endEIt_(other.endEIt_),
167 nIt_(0)
168 {
169 if (other.nIt_)
170 nIt_ = new IntersectionIterator(*other.nIt_);
171
172 updateIntersection(other.intersection_);
173 }
174
176 delete(nIt_);
177 }
178
182 {
183 // Increment until a face in the patch is found
184 do {
185 ++(*nIt_);
186
187 // if end intersection reached find next intersection
188 if ((*nIt_) == gridView_.iend(*eIt_))
189 {
190 do {
191 ++eIt_;
192 } while (eIt_ != endEIt_ and asImpl().skipElement(*eIt_));
193 if (eIt_ != endEIt_)
194 (*nIt_) = gridView_.ibegin(*eIt_);
195 }
196
197 // if we reached the end then stop
198 if (eIt_ == endEIt_)
199 break;
200
201 // check if we skip the intersection
202 const Intersection& intersection = **nIt_;
203 if (not asImpl().skipIntersection(intersection)) {
204 updateIntersection(intersection);
205 break;
206 }
207
208 } while (true);
209 }
210
211 bool equals(const GlobalIntersectionIterator& other) const
212 {
213 return (eIt_ == other.eIt_) and ((eIt_ == endEIt_) or ((*nIt_) == (*other.nIt_)));
214 }
215
217 {
218 return returnReference<IntersectionIterator,isReference>(nIt_,intersection_);
219 }
220
222 {
223 eIt_ = other.eIt_;
224 endEIt_ = other.endEIt_;
225
226 if (nIt_)
227 delete nIt_;
228
229 if (other.nIt_)
230 nIt_ = new IntersectionIterator(*other.nIt_);
231 else
232 nIt_ = 0;
233
234 updateIntersection(other.intersection_);
235
236 return *this;
237 }
238
239 bool containsInsideSubentity(int subEntity, int codim) const
240 {
241 auto re = Dune::referenceElement<double, dim>(eIt_->type());
242 return re.subEntities((*nIt_)->indexInInside(), 1,codim).contains(subEntity);
243 }
244
245protected:
246
248 void updateIntersection(const Intersection& intersection)
249 {
250 if (not isReference)
251 intersection_ = std::move(intersection);
252 }
253
262 {
263 if (eIt_ == endEIt_)
264 return;
265
266 const Intersection& intersection = **nIt_;
267 if (asImpl().skipIntersection(intersection))
268 increment();
269 else
270 updateIntersection(intersection);
271 }
272
273 const Impl& asImpl() const
274 {
275 return static_cast<const Impl&>(*this);
276 }
277
278 Impl& asImpl()
279 {
280 return static_cast<Impl&>(*this);
281 }
282
283 GridView gridView_;
284
285 ElementIterator eIt_;
286 ElementIterator endEIt_;
287
288 IntersectionIterator* nIt_;
289
294};
295
296
297
298#endif
299
static const IntersectionIterator::Intersection & returnReference(IntersectionIterator *nIt, const typename IntersectionIterator::Intersection &intersection)
Statically either dereferences the iterator, if it returns a reference, or otherwise return the 'memb...
Definition globalintersectioniterator.hh:61
iterator end()
void increment()
iterator begin()
size_type dim() const
Helper struct that statically either dereferences the iterator, if it returns a reference,...
Definition globalintersectioniterator.hh:30
static const Intersection & returnReference(IntersectionIterator *nIt, const Intersection &intersection)
Definition globalintersectioniterator.hh:34
IntersectionIterator::Intersection Intersection
Definition globalintersectioniterator.hh:32
IntersectionIterator::Intersection Intersection
Definition globalintersectioniterator.hh:44
static const Intersection & returnReference(IntersectionIterator *nIt, const Intersection &intersection)
Definition globalintersectioniterator.hh:46
Base class for iterators on intersections of a grid view.
Definition globalintersectioniterator.hh:90
void initialIncrement()
Find first valid intersection.
Definition globalintersectioniterator.hh:261
ElementIterator eIt_
Definition globalintersectioniterator.hh:285
const GlobalIntersectionIterator & operator=(const GlobalIntersectionIterator &other)
Definition globalintersectioniterator.hh:221
GlobalIntersectionIterator(const GridView &gridView, PositionFlag flag)
Create begin or end iterator for given grid view.
Definition globalintersectioniterator.hh:123
void updateIntersection(const Intersection &intersection)
Update the stored intersection if we have to.
Definition globalintersectioniterator.hh:248
GlobalIntersectionIterator(const GridView &gridView, const ElementIterator &eIt, const ElementIterator &endEIt)
Create iterator for given grid view.
Definition globalintersectioniterator.hh:149
bool containsInsideSubentity(int subEntity, int codim) const
Definition globalintersectioniterator.hh:239
GridView gridView_
Definition globalintersectioniterator.hh:283
PositionFlag
Definition globalintersectioniterator.hh:108
@ begin
Definition globalintersectioniterator.hh:108
~GlobalIntersectionIterator()
Definition globalintersectioniterator.hh:175
IntersectionIterator * nIt_
Definition globalintersectioniterator.hh:288
GlobalIntersectionIterator(const GlobalIntersectionIterator &other)
Copy constructor.
Definition globalintersectioniterator.hh:163
IntersectionIterator::Intersection Intersection
The type of objects we are iterating over.
Definition globalintersectioniterator.hh:99
void increment()
Increment the pointer to the next intersection.
Definition globalintersectioniterator.hh:181
bool equals(const GlobalIntersectionIterator &other) const
Definition globalintersectioniterator.hh:211
const Intersection & dereference() const
Definition globalintersectioniterator.hh:216
Impl & asImpl()
Definition globalintersectioniterator.hh:278
const Impl & asImpl() const
Definition globalintersectioniterator.hh:273
ElementIterator endEIt_
Definition globalintersectioniterator.hh:286
Intersection intersection_
The intersection corresponding to the actual global intersection iterator. It is only set if derefere...
Definition globalintersectioniterator.hh:293
T forward(T... args)