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;
 
   37  static const int dimension = GridImp::dimension;
 
   38  static const int dimensionworld = GridImp::dimensionworld;
 
   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;
 
   49  typedef FieldVector<ctype,dimension - 1> LocalCoords;
 
   52  friend class SubDomainToSubDomainController;
 
   55  friend class AllInterfacesController;
 
   57  template<
typename, 
typename, 
typename, 
typename>
 
   58  friend class SubDomainInterfaceIterator;
 
   62  typedef typename GridImp::SubDomainIndex SubDomainIndex;
 
   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)
 
  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;
 
  161    return EntityWrapper<0,GridImp::dimension,GridImp>(_hostCell);
 
  166    return EntityWrapper<0,GridImp::dimension,GridImp>(_hostIntersectionIterator->outside());
 
  171    return LocalGeometry(_hostIntersectionIterator->geometryInInside());
 
  176    return LocalGeometry(_hostIntersectionIterator->geometryInOutside());
 
  182    return _hostIntersectionIterator->indexInInside();
 
  188    return _hostIntersectionIterator->indexInOutside();
 
  191  GlobalCoords firstOuterNormal(
const LocalCoords& local)
 const {
 
  192    return _hostIntersectionIterator->outerNormal(local);
 
  195  GlobalCoords firstIntegrationOuterNormal(
const LocalCoords& local)
 const {
 
  196    return _hostIntersectionIterator->integrationOuterNormal(local);
 
  199  GlobalCoords firstUnitOuterNormal(
const LocalCoords& local)
 const {
 
  200    return _hostIntersectionIterator->unitOuterNormal(local);
 
  203  GlobalCoords secondOuterNormal(
const LocalCoords& local)
 const {
 
  204    return -_hostIntersectionIterator->outerNormal(local);
 
  207  GlobalCoords secondIntegrationOuterNormal(
const LocalCoords& local)
 const {
 
  208    return -_hostIntersectionIterator->integrationOuterNormal(local);
 
  211  GlobalCoords secondUnitOuterNormal(
const LocalCoords& local)
 const {
 
  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();
 
  242    return EntityWrapper<0,GridImp::dimension,GridImp>(_hostCell);
 
  247    return EntityWrapper<0,GridImp::dimension,GridImp>(_hostIntersectionIterator->outside());
 
  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();
 
  303  GlobalCoords outerNormal(
const LocalCoords& local)
 const {
 
  304    return _hostIntersectionIterator->outerNormal(local);
 
  307  GlobalCoords integrationOuterNormal(
const LocalCoords& local)
 const {
 
  308    return _hostIntersectionIterator->integrationOuterNormal(local);
 
  311  GlobalCoords unitOuterNormal(
const LocalCoords& local)
 const {
 
  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>
 
  343class SubDomainInterfaceIterator : 
public ForwardIteratorFacade<SubDomainInterfaceIterator<
 
  359  typedef SubDomainInterface<
 
  363    IterationController> Intersection;
 
  365  static const int dimension = GridImp::dimension;
 
  366  static const int dimensionworld = GridImp::dimensionworld;
 
  368  template<
typename, 
typename, 
typename, 
typename>
 
  369  friend class ::Dune::ForwardIteratorFacade;
 
  373  SubDomainInterfaceIterator(
const GridView& gridView,
 
  374                             const HostGridView& hostGridView,
 
  375                             IterationController controller,
 
  377    : _intersection(gridView,hostGridView,controller,end)
 
  379    this->controller().incrementToStartPosition(_intersection);
 
  387  bool equals(
const SubDomainInterfaceIterator& rhs)
 const {
 
  388    return _intersection == rhs._intersection;
 
  395    this->controller().increment(_intersection);
 
  396    _intersection.clear();
 
  400  const Intersection& dereference()
 const {
 
  401    return _intersection;
 
  404  IterationController& controller()
 
  406    return _intersection._controller;
 
  411  const Intersection& operator*()
 const {
 
  412    return dereference();
 
  415  const Intersection* operator->()
 const {
 
  416    return &(dereference());
 
  421  Intersection _intersection;
 
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