5#ifndef DUNE_GEOGRID_ITERATOR_HH 
    6#define DUNE_GEOGRID_ITERATOR_HH 
   13#include <dune/geometry/referenceelements.hh> 
   15#include <dune/grid/geometrygrid/capabilities.hh> 
   16#include <dune/grid/geometrygrid/declaration.hh> 
   17#include <dune/grid/geometrygrid/entity.hh> 
   29              bool fake = !Capabilities::hasHostEntity< Grid, codim >::v >
 
   32    template< 
class Gr
id >
 
   33    class HierarchicIterator;
 
   40    template< 
int codim, PartitionIteratorType pitype, 
class Gr
id >
 
   41    struct PartitionIteratorFilter;
 
   43    template< 
int codim, 
class Gr
id >
 
   46      static const int dimension = std::remove_const< Grid >::type::dimension;
 
   47      static const int codimension = codim;
 
   51      typedef typename std::remove_const< Grid >::type::ctype ctype;
 
   52      typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element;
 
   55      static bool apply ( 
const RefElement &refElement,
 
   56                          const Element &element, 
int subEntity )
 
   58        const int size = refElement.size( subEntity, codim, dimension );
 
   59        for( 
int i = 0; i < 
size; ++i )
 
   61          const int j = refElement.subEntity( subEntity, codim, i, dimension );
 
   62          PartitionType type = element.template subEntity< dimension >( j ).partitionType();
 
   70    template< 
int codim, 
class Gr
id >
 
   73      static const int dimension = std::remove_const< Grid >::type::dimension;
 
   74      static const int codimension = codim;
 
   78      typedef typename std::remove_const< Grid >::type::ctype ctype;
 
   79      typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element;
 
   82      static bool apply ( 
const RefElement &refElement,
 
   83                          const Element &element, 
int subEntity )
 
   89    template< 
int codim, 
class Gr
id >
 
   92      static const int dimension = std::remove_const< Grid >::type::dimension;
 
   93      static const int codimension = codim;
 
   97      typedef typename std::remove_const< Grid >::type::ctype ctype;
 
   98      typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element;
 
  101      static bool apply ( 
const RefElement &refElement,
 
  102                          const Element &element, 
int subEntity )
 
  107        const int size = refElement.size( subEntity, codim, dimension );
 
  108        for( 
int i = 0; i < 
size; ++i )
 
  110          const int j = refElement.subEntity( subEntity, codim, i, dimension );
 
  111          PartitionType type = element.template subEntity< dimension >( j ).partitionType();
 
  119    template< 
int codim, 
class Gr
id >
 
  122      static const int dimension = std::remove_const< Grid >::type::dimension;
 
  123      static const int codimension = codim;
 
  127      typedef typename std::remove_const< Grid >::type::ctype ctype;
 
  128      typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element;
 
  131      static bool apply ( 
const RefElement &refElement,
 
  132                          const Element &element, 
int subEntity )
 
  138    template< 
int codim, 
class Gr
id >
 
  141      static const int dimension = std::remove_const< Grid >::type::dimension;
 
  142      static const int codimension = codim;
 
  146      typedef typename std::remove_const< Grid >::type::ctype ctype;
 
  147      typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element;
 
  150      static bool apply ( 
const RefElement &refElement,
 
  151                          const Element &element, 
int subEntity )
 
  157    template< 
int codim, 
class Gr
id >
 
  160      static const int dimension = std::remove_const< Grid >::type::dimension;
 
  161      static const int codimension = codim;
 
  165      typedef typename std::remove_const< Grid >::type::ctype ctype;
 
  166      typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element;
 
  169      static bool apply ( 
const RefElement &refElement,
 
  170                          const Element &element, 
int subEntity )
 
  172        const int size = refElement.size( subEntity, codim, dimension );
 
  173        for( 
int i = 0; i < 
size; ++i )
 
  175          const int j = refElement.subEntity( subEntity, codim, i, dimension );
 
  176          PartitionType type = element.template subEntity< dimension >( j ).partitionType();
 
  189    template< 
class HostGr
idView, 
int codim, PartitionIteratorType pitype, 
class G >
 
  190    class Iterator< HostGridView, codim, pitype, G, false >
 
  192      typedef typename std::remove_const< G >::type::Traits Traits;
 
  195      typedef typename Traits::Grid Grid;
 
  197      static const int codimension = codim;
 
  199      typedef typename Traits::template Codim< codimension >::Entity Entity;
 
  201      static const bool fake = 
false;
 
  204      typedef GeoGrid::Entity< codimension, Traits::dimension, G > EntityImpl;
 
  206      typedef typename HostGridView::template Codim< codim >::template Partition< pitype >::Iterator HostEntityIterator;
 
  209      Iterator () : grid_( nullptr ) {}
 
  211      Iterator ( 
const Grid &grid, HostEntityIterator hostEntityIterator )
 
  213          hostEntityIterator_( 
std::move( hostEntityIterator ) )
 
  218        ++hostEntityIterator_;
 
  221      bool equals ( 
const Iterator &rhs )
 const 
  223        return hostEntityIterator_ == rhs.hostEntityIterator_;
 
  226      Entity dereference ()
 const 
  228        return EntityImpl( grid(), *hostEntityIterator_ );
 
  231      int level ()
 const { 
return hostEntityIterator_.level(); }
 
  233      const Grid &grid ()
 const 
  239      static Iterator begin ( 
const Grid &grid, 
const HostGridView &hostGridView )
 
  241        HostEntityIterator hostEntityIterator = hostGridView.template begin< codimension, pitype >();
 
  242        return Iterator( grid, std::move( hostEntityIterator ) );
 
  245      static Iterator end ( 
const Grid &grid, 
const HostGridView &hostGridView )
 
  247        HostEntityIterator hostEntityIterator = hostGridView.template end< codimension, pitype >();
 
  248        return Iterator( grid, std::move( hostEntityIterator ) );
 
  253      HostEntityIterator hostEntityIterator_;
 
  261    template< 
class HostGr
idView, 
int codim, PartitionIteratorType pitype, 
class G >
 
  262    class Iterator< HostGridView, codim, pitype, G, true >
 
  264      typedef typename std::remove_const< G >::type::Traits Traits;
 
  267      typedef typename Traits::Grid Grid;
 
  269      static const int codimension = codim;
 
  271      typedef typename Traits::template Codim< codimension >::Entity Entity;
 
  274      typedef GeoGrid::Entity< codimension, Traits::dimension, G > EntityImpl;
 
  276      typedef PartitionIteratorFilter< codim, pitype, typename HostGridView::Grid > Filter;
 
  278      typedef typename HostGridView::template Codim<0>::template Partition< Filter::Element_Partition >::Iterator HostElementIterator;
 
  279      typedef typename HostElementIterator::Entity HostElement;
 
  280      typedef typename HostGridView::IndexSet HostIndexSet;
 
  283      Iterator () : grid_( nullptr ), subEntity_( -1 ), hostIndexSet_( nullptr ) {}
 
  285      Iterator ( 
const Grid &grid, HostElementIterator hostElementIterator, HostElementIterator hostEnd, 
const HostIndexSet &hostIndexSet )
 
  287          hostElementIterator_( hostElementIterator ),
 
  290          hostIndexSet_( &hostIndexSet )
 
  292        if( hostElementIterator_ != hostEnd_ )
 
  294          visited_.resize( hostIndexSet_->size( codimension ), 
false );
 
  301        typedef typename Traits::ctype ctype;
 
  303        while( hostElementIterator_ != hostEnd_ )
 
  305          const HostElement &hostElement = *hostElementIterator_;
 
  307          auto refElement = referenceElement< ctype, Traits::dimension >( hostElement.type() );
 
  310          const int count = refElement.size( codimension );
 
  311          for( ; subEntity_ < count; ++subEntity_ )
 
  313            if( !Filter::apply( refElement, hostElement, subEntity_ ) )
 
  316            const size_t index = hostIndexSet_->subIndex( hostElement, subEntity_, codimension );
 
  317            if( !visited_[ index ] )
 
  319              visited_[ index ] = 
true;
 
  323          ++hostElementIterator_;
 
  328      bool equals ( 
const Iterator &rhs )
 const 
  330        return hostElementIterator_ == rhs.hostElementIterator_ && ( hostElementIterator_ == hostEnd_ || subEntity_ == rhs.subEntity_ );
 
  333      Entity dereference ()
 const 
  335        return EntityImpl( grid(), *hostElementIterator_, subEntity_ );
 
  338      int level ()
 const { 
return hostElementIterator_.level(); }
 
  340      const Grid &grid ()
 const 
  346      static Iterator begin ( 
const Grid &grid, 
const HostGridView &hostGridView )
 
  348        HostElementIterator first = hostGridView.template begin< 0, Filter::Element_Partition >();
 
  349        HostElementIterator last = hostGridView.template end< 0, Filter::Element_Partition >();
 
  350        return Iterator( grid, std::move( first ), std::move( last ), hostGridView.indexSet() );
 
  353      static Iterator end ( 
const Grid &grid, 
const HostGridView &hostGridView )
 
  355        HostElementIterator last = hostGridView.template end< 0, Filter::Element_Partition >();
 
  356        return Iterator( grid, last, last, hostGridView.indexSet() );
 
  361      HostElementIterator hostElementIterator_, hostEnd_;
 
  363      const HostIndexSet *hostIndexSet_;
 
  364      std::vector< bool > visited_;
 
  373    class HierarchicIterator
 
  375      typedef typename std::remove_const< G >::type::Traits Traits;
 
  378      typedef typename Traits::Grid Grid;
 
  380      static const int codimension = 0;
 
  382      typedef typename Traits::template Codim< codimension >::Entity Entity;
 
  385      typedef GeoGrid::Entity< codimension, Traits::dimension, G > EntityImpl;
 
  387      typedef typename Grid::HostGrid::HierarchicIterator HostEntityIterator;
 
  390      HierarchicIterator () : grid_( nullptr ) {}
 
  392      HierarchicIterator ( 
const Grid &grid, HostEntityIterator hostEntityIterator )
 
  394          hostEntityIterator_( 
std::move( hostEntityIterator ) )
 
  399        ++hostEntityIterator_;
 
  402      bool equals ( 
const HierarchicIterator &rhs )
 const 
  404        return hostEntityIterator_ == rhs.hostEntityIterator_;
 
  407      Entity dereference ()
 const 
  409        return EntityImpl( grid(), *hostEntityIterator_ );
 
  412      int level ()
 const { 
return hostEntityIterator_.level(); }
 
  414      const Grid &grid ()
 const 
  422      HostEntityIterator hostEntityIterator_;
 
Dune namespace.
Definition: alignedallocator.hh:13
 
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
 
typename Container::ReferenceElement ReferenceElement
The reference element type.
Definition: referenceelements.hh:146