1#ifndef DUNE_MULTIDOMAINGRID_SUBDOMAININTERFACEITERATOR_HH
2#define DUNE_MULTIDOMAINGRID_SUBDOMAININTERFACEITERATOR_HH
4#include <dune/common/iteratorfacades.hh>
5#include <dune/geometry/type.hh>
13template<
typename GridImp,
15 typename HostGridView,
16 typename IterationController>
17class SubDomainInterfaceIterator;
20class SubDomainToSubDomainController;
22template<
typename SubDomainSet>
23class AllInterfacesController;
27template<
typename GridImp,
29 typename HostGridView,
30 typename IterationController>
36 typedef typename GridImp::ctype
ctype;
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;
48 typedef FieldVector<ctype,dimensionworld> GlobalCoords;
57 template<
typename,
typename,
typename,
typename>
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;
71 const HostGridView& hostGridView,
72 IterationController controller,
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)
84 _controller.incrementToStartPosition(*
this);
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)
100 SubDomainInterface& operator=(
const SubDomainInterface& rhs)
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;
115 _inverseHostIntersectionValid =
false;
121 return (_hostIterator == rhs._hostIterator &&
122 (_hostIterator == _hostEnd ||
123 (_hostIntersectionIterator == rhs._hostIntersectionIterator &&
124 _controller.subDomain1() == rhs._controller.subDomain1() &&
125 _controller.subDomain2() == rhs._controller.subDomain2()
134 void findInverseHostIntersection()
const {
135 assert(_hostIntersectionIterator->neighbor());
136 _hostOutsideCell = _hostIntersectionIterator->outside();
137 _inverseHostIntersection = _hostGridView.ibegin(_hostOutsideCell);
138 while (_hostCell != _inverseHostIntersection->outside()) {
139 ++_inverseHostIntersection;
141 _inverseHostIntersectionValid =
true;
144 HostIntersectionIterator secondHostIntersectionIterator()
const {
145 if (!_inverseHostIntersectionValid)
146 findInverseHostIntersection();
147 return _inverseHostIntersection;
150 HostIntersectionIterator firstHostIntersectionIterator()
const {
151 return _hostIntersectionIterator;
171 return LocalGeometry(_hostIntersectionIterator->geometryInInside());
176 return LocalGeometry(_hostIntersectionIterator->geometryInOutside());
182 return _hostIntersectionIterator->indexInInside();
188 return _hostIntersectionIterator->indexInOutside();
192 return _hostIntersectionIterator->outerNormal(local);
196 return _hostIntersectionIterator->integrationOuterNormal(local);
200 return _hostIntersectionIterator->unitOuterNormal(local);
204 return -_hostIntersectionIterator->outerNormal(local);
208 return -_hostIntersectionIterator->integrationOuterNormal(local);
212 return -_hostIntersectionIterator->unitOuterNormal(local);
217 return _gridView.grid().template multiDomainIntersectionIterator<GridView,HostGridView>(secondHostIntersectionIterator());
222 return _gridView.grid().template multiDomainIntersectionIterator<GridView,HostGridView>(firstHostIntersectionIterator());
227 return _controller.subDomain1();
232 return _controller.subDomain2();
252 return _hostIntersectionIterator->conforming();
257 return LocalGeometry(_hostIntersectionIterator->geometryInInside());
262 return LocalGeometry(_hostIntersectionIterator->geometryInOutside());
267 return Geometry(_hostIntersectionIterator->geometry());
272 return _hostIntersectionIterator->type();
278 return _hostIntersectionIterator->indexInInside();
284 return _hostIntersectionIterator->indexInOutside();
304 return _hostIntersectionIterator->outerNormal(local);
308 return _hostIntersectionIterator->integrationOuterNormal(local);
312 return _hostIntersectionIterator->unitOuterNormal(local);
320 HostGridView _hostGridView;
322 IterationController _controller;
324 HostIterator _hostIterator;
325 HostIterator _hostEnd;
327 HostIntersectionIterator _hostIntersectionIterator;
328 HostIntersectionIterator _hostIntersectionEnd;
332 mutable HostIntersectionIterator _inverseHostIntersection;
333 mutable HostCell _hostOutsideCell;
334 mutable bool _inverseHostIntersectionValid;
339template<
typename GridImp,
341 typename HostGridView,
342 typename IterationController>
368 template<
typename,
typename,
typename,
typename>
369 friend class ::Dune::ForwardIteratorFacade;
374 const HostGridView& hostGridView,
375 IterationController controller,
377 : _intersection(gridView,hostGridView,controller,end)
379 this->controller().incrementToStartPosition(_intersection);
388 return _intersection == rhs._intersection;
395 this->controller().increment(_intersection);
396 _intersection.clear();
401 return _intersection;
404 IterationController& controller()
406 return _intersection._controller;
412 return dereference();
416 return &(dereference());
Definition: multidomaingrid.hh:8
Definition: allsubdomaininterfacesiterator.hh:21
Definition: entity.hh:144
Definition: subdomaininterfaceiterator.hh:355
static const int dimension
Definition: subdomaininterfaceiterator.hh:365
const Intersection & operator*() const
Definition: subdomaininterfaceiterator.hh:411
SubDomainInterfaceIterator(const GridView &gridView, const HostGridView &hostGridView, IterationController controller, bool end)
Definition: subdomaininterfaceiterator.hh:373
SubDomainInterface< GridImp, GridView, HostGridView, IterationController > Intersection
Definition: subdomaininterfaceiterator.hh:363
bool equals(const SubDomainInterfaceIterator &rhs) const
Definition: subdomaininterfaceiterator.hh:387
const Intersection * operator->() const
Definition: subdomaininterfaceiterator.hh:415
static const int dimensionworld
Definition: subdomaininterfaceiterator.hh:366
Definition: subdomaintosubdomaininterfaceiterator.hh:19
An intersection that forms part of the interface between two subdomains.
Definition: subdomaininterfaceiterator.hh:32
GlobalCoords firstOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:191
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
GlobalCoords secondOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:203
GlobalCoords integrationOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:307
int indexInOutside() const
Definition: subdomaininterfaceiterator.hh:283
GlobalCoords firstUnitOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:199
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
GlobalCoords secondIntegrationOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:207
GlobalCoords outerNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:303
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
GridImp::ctype ctype
Definition: subdomaininterfaceiterator.hh:36
GlobalCoords firstIntegrationOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:195
bool conforming() const
Returns true if this intersection is conforming.
Definition: subdomaininterfaceiterator.hh:251
bool operator==(const SubDomainInterface &rhs) const
Definition: subdomaininterfaceiterator.hh:120
int indexInInside() const
Definition: subdomaininterfaceiterator.hh:277
GridImp::Traits::template Codim< 1 >::LocalGeometry LocalGeometry
Definition: subdomaininterfaceiterator.hh:66
Entity firstCell() const
Returns the entity of the corresponding cell in the first subdomain.
Definition: subdomaininterfaceiterator.hh:160
GridImp::Traits::template Codim< 0 >::Entity Entity
Definition: subdomaininterfaceiterator.hh:64
int indexInSecondCell() const
Definition: subdomaininterfaceiterator.hh:187
static const int dimension
Definition: subdomaininterfaceiterator.hh:37
Entity outside() const
Returns the entity of the corresponding cell in the second subdomain.
Definition: subdomaininterfaceiterator.hh:246
GlobalCoords unitOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:311
GridImp::Traits::template Codim< 1 >::Geometry Geometry
Definition: subdomaininterfaceiterator.hh:65
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
GridImp::SubDomainIndex SubDomainIndex
Definition: subdomaininterfaceiterator.hh:62
static const int dimensionworld
Definition: subdomaininterfaceiterator.hh:38
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
GlobalCoords secondUnitOuterNormal(const LocalCoords &local) const
Definition: subdomaininterfaceiterator.hh:211