Loading [MathJax]/extensions/tex2jax.js

DUNE MultiDomainGrid (2.9)

subdomaininterfaceiterator.hh
1#ifndef DUNE_MULTIDOMAINGRID_SUBDOMAININTERFACEITERATOR_HH
2#define DUNE_MULTIDOMAINGRID_SUBDOMAININTERFACEITERATOR_HH
3
4#include <dune/common/iteratorfacades.hh>
5#include <dune/geometry/type.hh>
6
7#include "entity.hh"
8
9namespace Dune {
10
11namespace mdgrid {
12
13template<typename GridImp,
14 typename GridView,
15 typename HostGridView,
16 typename IterationController>
17class SubDomainInterfaceIterator;
18
19template<typename SI>
20class SubDomainToSubDomainController;
21
22template<typename SubDomainSet>
23class AllInterfacesController;
24
25
27template<typename GridImp,
28 typename GridView,
29 typename HostGridView,
30 typename IterationController>
32{
33
34public:
35
36 typedef typename GridImp::ctype ctype;
37 static const int dimension = GridImp::dimension;
38 static const int dimensionworld = GridImp::dimensionworld;
39
40private:
41
42 using HostIterator = typename HostGridView::template Codim<0>::Iterator;
43 using HostCell = typename HostIterator::Entity;
44 typedef typename HostGridView::IntersectionIterator HostIntersectionIterator;
45 typedef typename GridView::IntersectionIterator MultiDomainIntersectionIterator;
46 typedef typename GridImp::SubDomainGrid::Traits::template Codim<0>::Entity SubDomainEntity;
47
48 typedef FieldVector<ctype,dimensionworld> GlobalCoords;
49 typedef FieldVector<ctype,dimension - 1> LocalCoords;
50
51 template<typename>
52 friend class SubDomainToSubDomainController;
53
54 template<typename>
55 friend class AllInterfacesController;
56
57 template<typename, typename, typename, typename>
58 friend class SubDomainInterfaceIterator;
59
60public:
61
62 typedef typename GridImp::SubDomainIndex SubDomainIndex;
63
64 typedef typename GridImp::Traits::template Codim<0>::Entity Entity;
65 typedef typename GridImp::Traits::template Codim<1>::Geometry Geometry;
66 typedef typename GridImp::Traits::template Codim<1>::LocalGeometry LocalGeometry;
67
68private:
69
70 SubDomainInterface(const GridView& gridView,
71 const HostGridView& hostGridView,
72 IterationController controller,
73 bool end) :
74 _gridView(gridView),
75 _hostGridView(hostGridView),
76 _controller(controller),
77 _hostIterator(end ? hostGridView.template end<0>() : hostGridView.template begin<0>()),
78 _hostEnd(hostGridView.template end<0>()),
79 _hostIntersectionIterator(hostGridView.ibegin(*hostGridView.template begin<0>())),
80 _hostIntersectionEnd(hostGridView.iend(*hostGridView.template begin<0>())),
81 _inverseHostIntersection(hostGridView.ibegin(*hostGridView.template begin<0>())),
82 _inverseHostIntersectionValid(false)
83 {
84 _controller.incrementToStartPosition(*this);
85 }
86
88 : _gridView(rhs._gridView)
89 , _hostGridView(rhs._hostGridView)
90 , _controller(rhs._controller)
91 , _hostIterator(rhs._hostIterator)
92 , _hostEnd(rhs._hostEnd)
93 , _hostIntersectionIterator(rhs._hostIntersectionIterator)
94 , _hostIntersectionEnd(rhs._hostIntersectionEnd)
95 , _inverseHostIntersection(rhs._inverseHostIntersection)
96 , _inverseHostIntersectionValid(rhs._inverseHostIntersectionValid)
97 {
98 }
99
100 SubDomainInterface& operator=(const SubDomainInterface& rhs)
101 {
102 _gridView = rhs._gridView;
103 _hostGridView = rhs._hostGridView;
104 _controller = rhs._controller;
105 _hostIterator = rhs._hostIterator;
106 _hostEnd = rhs.hostEnd;
107 _hostIntersectionIterator = rhs._hostIntersectionIterator;
108 _hostIntersectionEnd = rhs._hostIntersectionEnd;
109 _inverseHostIntersection = rhs._inverseHostIntersection;
110 _inverseHostIntersectionValid = rhs._inverseHostIntersectionValid;
111 }
112
113 void clear()
114 {
115 _inverseHostIntersectionValid = false;
116 }
117
118public:
119
120 bool operator==(const SubDomainInterface& rhs) const {
121 return (_hostIterator == rhs._hostIterator &&
122 (_hostIterator == _hostEnd ||
123 (_hostIntersectionIterator == rhs._hostIntersectionIterator &&
124 _controller.subDomain1() == rhs._controller.subDomain1() &&
125 _controller.subDomain2() == rhs._controller.subDomain2()
126 )
127 )
128 );
129 }
130
131
132private:
133
134 void findInverseHostIntersection() const {
135 assert(_hostIntersectionIterator->neighbor());
136 _hostOutsideCell = _hostIntersectionIterator->outside();
137 _inverseHostIntersection = _hostGridView.ibegin(_hostOutsideCell);
138 while (_hostCell != _inverseHostIntersection->outside()) {
139 ++_inverseHostIntersection;
140 }
141 _inverseHostIntersectionValid = true;
142 }
143
144 HostIntersectionIterator secondHostIntersectionIterator() const {
145 if (!_inverseHostIntersectionValid)
146 findInverseHostIntersection();
147 return _inverseHostIntersection;
148 }
149
150 HostIntersectionIterator firstHostIntersectionIterator() const {
151 return _hostIntersectionIterator;
152 }
153
154public:
155
158
160 Entity firstCell() const {
161 return EntityWrapper<0,GridImp::dimension,GridImp>(_hostCell);
162 }
163
165 Entity secondCell() const {
166 return EntityWrapper<0,GridImp::dimension,GridImp>(_hostIntersectionIterator->outside());
167 }
168
170 LocalGeometry geometryInFirstCell() const {
171 return LocalGeometry(_hostIntersectionIterator->geometryInInside());
172 }
173
175 LocalGeometry geometryInSecondCell() const {
176 return LocalGeometry(_hostIntersectionIterator->geometryInOutside());
177 }
178
181 int indexInFirstCell() const {
182 return _hostIntersectionIterator->indexInInside();
183 }
184
187 int indexInSecondCell() const {
188 return _hostIntersectionIterator->indexInOutside();
189 }
190
191 GlobalCoords firstOuterNormal(const LocalCoords& local) const {
192 return _hostIntersectionIterator->outerNormal(local);
193 }
194
195 GlobalCoords firstIntegrationOuterNormal(const LocalCoords& local) const {
196 return _hostIntersectionIterator->integrationOuterNormal(local);
197 }
198
199 GlobalCoords firstUnitOuterNormal(const LocalCoords& local) const {
200 return _hostIntersectionIterator->unitOuterNormal(local);
201 }
202
203 GlobalCoords secondOuterNormal(const LocalCoords& local) const {
204 return -_hostIntersectionIterator->outerNormal(local);
205 }
206
207 GlobalCoords secondIntegrationOuterNormal(const LocalCoords& local) const {
208 return -_hostIntersectionIterator->integrationOuterNormal(local);
209 }
210
211 GlobalCoords secondUnitOuterNormal(const LocalCoords& local) const {
212 return -_hostIntersectionIterator->unitOuterNormal(local);
213 }
214
216 MultiDomainIntersectionIterator secondMultiDomainIntersectionIterator() const {
217 return _gridView.grid().template multiDomainIntersectionIterator<GridView,HostGridView>(secondHostIntersectionIterator());
218 }
219
221 MultiDomainIntersectionIterator firstMultiDomainIntersectionIterator() const {
222 return _gridView.grid().template multiDomainIntersectionIterator<GridView,HostGridView>(firstHostIntersectionIterator());
223 }
224
226 SubDomainIndex subDomain1() const {
227 return _controller.subDomain1();
228 }
229
231 SubDomainIndex subDomain2() const {
232 return _controller.subDomain2();
233 }
234
239
241 Entity inside() const {
242 return EntityWrapper<0,GridImp::dimension,GridImp>(_hostCell);
243 }
244
246 Entity outside() const {
247 return EntityWrapper<0,GridImp::dimension,GridImp>(_hostIntersectionIterator->outside());
248 }
249
251 bool conforming() const {
252 return _hostIntersectionIterator->conforming();
253 }
254
256 LocalGeometry geometryInInside() const {
257 return LocalGeometry(_hostIntersectionIterator->geometryInInside());
258 }
259
261 LocalGeometry geometryInOutside() const {
262 return LocalGeometry(_hostIntersectionIterator->geometryInOutside());
263 }
264
266 Geometry geometry() const {
267 return Geometry(_hostIntersectionIterator->geometry());
268 }
269
271 GeometryType type() const {
272 return _hostIntersectionIterator->type();
273 }
274
277 int indexInInside() const {
278 return _hostIntersectionIterator->indexInInside();
279 }
280
283 int indexInOutside() const {
284 return _hostIntersectionIterator->indexInOutside();
285 }
286
288
291 SubDomainIndex subDomainInInside() const {
292 return this->subDomain1();
293 }
294
296
299 SubDomainIndex subDomainInOutside() const {
300 return this->subDomain2();
301 }
302
303 GlobalCoords outerNormal(const LocalCoords& local) const {
304 return _hostIntersectionIterator->outerNormal(local);
305 }
306
307 GlobalCoords integrationOuterNormal(const LocalCoords& local) const {
308 return _hostIntersectionIterator->integrationOuterNormal(local);
309 }
310
311 GlobalCoords unitOuterNormal(const LocalCoords& local) const {
312 return _hostIntersectionIterator->unitOuterNormal(local);
313 }
314
317private:
318
319 GridView _gridView;
320 HostGridView _hostGridView;
321
322 IterationController _controller;
323
324 HostIterator _hostIterator;
325 HostIterator _hostEnd;
326
327 HostIntersectionIterator _hostIntersectionIterator;
328 HostIntersectionIterator _hostIntersectionEnd;
329
330 HostCell _hostCell;
331
332 mutable HostIntersectionIterator _inverseHostIntersection;
333 mutable HostCell _hostOutsideCell;
334 mutable bool _inverseHostIntersectionValid;
335
336};
337
338
339template<typename GridImp,
340 typename GridView,
341 typename HostGridView,
342 typename IterationController>
343class SubDomainInterfaceIterator : public ForwardIteratorFacade<SubDomainInterfaceIterator<
344 GridImp,
345 GridView,
346 HostGridView,
347 IterationController
348 >,
349 SubDomainInterface<
350 GridImp,
351 GridView,
352 HostGridView,
353 IterationController>
354 >
355{
356
357public:
358
359 typedef SubDomainInterface<
360 GridImp,
361 GridView,
362 HostGridView,
363 IterationController> Intersection;
364
365 static const int dimension = GridImp::dimension;
366 static const int dimensionworld = GridImp::dimensionworld;
367
368 template<typename, typename, typename, typename>
369 friend class ::Dune::ForwardIteratorFacade;
370
371protected:
372
373 SubDomainInterfaceIterator(const GridView& gridView,
374 const HostGridView& hostGridView,
375 IterationController controller,
376 bool end)
377 : _intersection(gridView,hostGridView,controller,end)
378 {
379 this->controller().incrementToStartPosition(_intersection);
380 }
381
382public:
383
384 // The following method has to be public because of non-member comparison operators in the
385 // IteratorFacade framework!
386
387 bool equals(const SubDomainInterfaceIterator& rhs) const {
388 return _intersection == rhs._intersection;
389 }
390
391
392private:
393
394 void increment() {
395 this->controller().increment(_intersection);
396 _intersection.clear();
397 }
398
399
400 const Intersection& dereference() const {
401 return _intersection;
402 }
403
404 IterationController& controller()
405 {
406 return _intersection._controller;
407 }
408
409public:
410
411 const Intersection& operator*() const {
412 return dereference();
413 }
414
415 const Intersection* operator->() const {
416 return &(dereference());
417 }
418
419private:
420
421 Intersection _intersection;
422
423};
424
425
426} // namespace mdgrid
427
428} // namespace Dune
429
430#endif // DUNE_MULTIDOMAINGRID_SUBDOMAININTERFACEITERATOR_HH
An intersection that forms part of the interface between two subdomains.
Definition: subdomaininterfaceiterator.hh:32
Geometry geometry() const
Returns the global geometry of the intersection.
Definition: subdomaininterfaceiterator.hh:266
LocalGeometry geometryInFirstCell() const
Returns the local geometry in the corresponding cell of the first subdomain.
Definition: subdomaininterfaceiterator.hh:170
MultiDomainIntersectionIterator secondMultiDomainIntersectionIterator() const
Returns a standard Dune IntersectionIterator for the current intersection, but with inside and outsid...
Definition: subdomaininterfaceiterator.hh:216
Entity secondCell() const
Returns the entity of the corresponding cell in the second subdomain.
Definition: subdomaininterfaceiterator.hh:165
Entity inside() const
Returns the entity of the corresponding cell in the first subdomain.
Definition: subdomaininterfaceiterator.hh:241
LocalGeometry geometryInOutside() const
Returns the local geometry in the corresponding cell of the second subdomain.
Definition: subdomaininterfaceiterator.hh:261
int indexInOutside() const
Definition: subdomaininterfaceiterator.hh:283
SubDomainIndex subDomainInInside() const
Returns the index of the subdomain the first (inside) cell belongs to.
Definition: subdomaininterfaceiterator.hh:291
GeometryType type() const
Returns the GeometryType of this intersection.
Definition: subdomaininterfaceiterator.hh:271
int indexInFirstCell() const
Definition: subdomaininterfaceiterator.hh:181
LocalGeometry geometryInSecondCell() const
Returns the local geometry in the corresponding cell of the second subdomain.
Definition: subdomaininterfaceiterator.hh:175
bool conforming() const
Returns true if this intersection is conforming.
Definition: subdomaininterfaceiterator.hh:251
int indexInInside() const
Definition: subdomaininterfaceiterator.hh:277
Entity firstCell() const
Returns the entity of the corresponding cell in the first subdomain.
Definition: subdomaininterfaceiterator.hh:160
int indexInSecondCell() const
Definition: subdomaininterfaceiterator.hh:187
Entity outside() const
Returns the entity of the corresponding cell in the second subdomain.
Definition: subdomaininterfaceiterator.hh:246
SubDomainIndex subDomain2() const
Returns the index of the subdomain the second (outside) cell belongs to.
Definition: subdomaininterfaceiterator.hh:231
SubDomainIndex subDomainInOutside() const
Returns the index of the subdomain the second (outside) cell belongs to.
Definition: subdomaininterfaceiterator.hh:299
LocalGeometry geometryInInside() const
Returns the local geometry in the corresponding cell of the first subdomain.
Definition: subdomaininterfaceiterator.hh:256
MultiDomainIntersectionIterator firstMultiDomainIntersectionIterator() const
Returns a standard Dune IntersectionIterator for the current intersection.
Definition: subdomaininterfaceiterator.hh:221
SubDomainIndex subDomain1() const
Returns the index of the subdomain the first (inside) cell belongs to.
Definition: subdomaininterfaceiterator.hh:226
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 7, 22:57, 2025)