4#ifndef DUNE_ALBERTA_TREEITERATOR_HH 
    5#define DUNE_ALBERTA_TREEITERATOR_HH 
   10#include <dune/grid/albertagrid/entitypointer.hh> 
   28  template< 
int dim, 
int dimworld >
 
   37    static const int dimension = Grid::dimension;
 
   39    typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
 
   40    typedef Alberta::ElementInfo< dimension > ElementInfo;
 
   43    struct NoMarkSubEntities;
 
   45    struct MarkSubEntities;
 
   50      : dofNumbering_( dofNumbering )
 
   52      for( 
int codim = 0; codim <= dimension; ++codim )
 
   57      : dofNumbering_( other.dofNumbering_ )
 
   59      for( 
int codim = 0; codim <= dimension; ++codim )
 
   63    ~AlbertaMarkerVector ()
 
   69    This &operator= ( 
const This & );
 
   76    template< 
int firstCodim, 
class Iterator >
 
   77    void markSubEntities ( 
const Iterator &begin, 
const Iterator &end );
 
   81      for( 
int codim = 0; codim <= dimension; ++codim )
 
   83        if( marker_[ codim ] != 0 )
 
   84          delete[] marker_[ codim ];
 
   92      return (marker_[ dimension ] != 0);
 
   96    void print ( std::ostream &out = std::cout ) 
const;
 
   99    const DofNumbering &dofNumbering_;
 
  100    int *marker_[ dimension+1 ];
 
  108  template< 
int dim, 
int dimworld >
 
  112    template< 
int firstCodim, 
class Iterator >
 
  113    static void mark ( 
const DofNumbering &dofNumbering, 
int *(&marker)[ dimension + 1 ],
 
  114                       const Iterator &begin, 
const Iterator &end )
 
  123  template< 
int dim, 
int dimworld >
 
  125  struct AlbertaMarkerVector< dim, dimworld >::MarkSubEntities
 
  127    template< 
int codim >
 
  130      static const int numSubEntities = Alberta::NumSubEntities< dimension, codim >::value;
 
  132      typedef Alberta::ElementInfo< dimension > ElementInfo;
 
  134      static void apply ( 
const DofNumbering &dofNumbering,
 
  135                          int *(&marker)[ dimension + 1 ],
 
  136                          const ElementInfo &elementInfo )
 
  138        int *array = marker[ codim ];
 
  140        const int index = dofNumbering( elementInfo, 0, 0 );
 
  141        for( 
int i = 0; i < numSubEntities; ++i )
 
  143          int &mark = array[ dofNumbering( elementInfo, codim, i ) ];
 
  144          mark = std::max( index, mark );
 
  149    template< 
int firstCodim, 
class Iterator >
 
  150    static void mark ( 
const DofNumbering &dofNumbering, 
int *(&marker)[ dimension + 1 ],
 
  151                       const Iterator &begin, 
const Iterator &end )
 
  153      for( 
int codim = firstCodim; codim <= dimension; ++codim )
 
  155        const int size = dofNumbering.size( codim );
 
  156        marker[ codim ] = 
new int[ size ];
 
  158        int *array = marker[ codim ];
 
  159        for( 
int i = 0; i < size; ++i )
 
  163      for( Iterator it = begin; it != end; ++it )
 
  166        ForLoop< Codim, firstCodim, dimension >::apply( dofNumbering, marker, elementInfo );
 
  179  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  187    static const int dimension = GridImp::dimension;
 
  188    static const int codimension = codim;
 
  189    static const int dimensionworld = GridImp::dimensionworld;
 
  192    friend class AlbertaGrid< dimension, dimensionworld >;
 
  194    static const int numSubEntities
 
  195      = Alberta::NumSubEntities< dimension, codimension >::value;
 
  198    typedef typename Base::ElementInfo ElementInfo;
 
  199    typedef Alberta::MeshPointer< dimension > MeshPointer;
 
  200    typedef typename MeshPointer::MacroIterator MacroIterator;
 
  204    typedef typename EntityObject::ImplementationType EntityImp;
 
  232    void nextElement ( ElementInfo &elementInfo );
 
  233    void nextElementStop (ElementInfo &elementInfo );
 
  234    bool stopAtElement ( 
const ElementInfo &elementInfo ) 
const;
 
  236    void goNext ( ElementInfo &elementInfo );
 
  237    void goNext ( 
const integral_constant< int, 0 > cdVariable,
 
  238                  ElementInfo &elementInfo );
 
  239    void goNext ( 
const integral_constant< int, 1 > cdVariable,
 
  240                  ElementInfo &elementInfo );
 
  242    void goNext ( 
const integral_constant< int, cd > cdVariable,
 
  243                  ElementInfo &elementInfo );
 
  251    MacroIterator macroIterator_;
 
  262  template< 
int dim, 
int dimworld >
 
  263  template< 
int codim >
 
  267    assert( marker_[ codim ] != 0 );
 
  269    const int subIndex = dofNumbering_( elementInfo, codim, subEntity );
 
  270    const int markIndex = marker_[ codim ][ subIndex ];
 
  271    assert( (markIndex >= 0) );
 
  273    const int index = dofNumbering_( elementInfo, 0, 0 );
 
  274    return (markIndex == index);
 
  278  template< 
int dim, 
int dimworld >
 
  279  template< 
int firstCodim, 
class Iterator >
 
  284    conditional< (firstCodim <= dimension), MarkSubEntities<true>, NoMarkSubEntities<false> >::type
 
  285    ::template mark< firstCodim, Iterator >( dofNumbering_, marker_, begin, end );
 
  289  template< 
int dim, 
int dimworld >
 
  292    for( 
int codim = 1; codim <= dimension; ++codim )
 
  294      int *marker = marker_[ codim ];
 
  297        const int size = dofNumbering_.size( codim );
 
  299        out << 
"Codimension " << codim << 
" (" << size << 
" entries)" << std::endl;
 
  300        for( 
int i = 0; i < size; ++i )
 
  301          out << 
"subentity " << i << 
" visited on Element " << marker[ i ] << std::endl;
 
  311  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  321  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  322  inline AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  323  ::AlbertaGridTreeIterator ( 
const GridImp &grid,
 
  328      subEntity_( (codim == 0 ? 0 : -1) ),
 
  329      macroIterator_( grid.meshPointer().begin() ),
 
  332    ElementInfo elementInfo = *macroIterator_;
 
  333    nextElementStop( elementInfo );
 
  335      goNext( elementInfo );
 
  337    entityImp().setElement( elementInfo, subEntity_ );
 
  342  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  349      macroIterator_( grid.meshPointer().end() ),
 
  355  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  359      level_( other.level_ ),
 
  360      subEntity_( other.subEntity_ ),
 
  361      macroIterator_( other.macroIterator_ ),
 
  362      marker_( other.marker_ )
 
  367  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  371    Base::operator=( other );
 
  373    level_ = other.level_;
 
  374    subEntity_ =  other.subEntity_;
 
  375    macroIterator_ = other.macroIterator_;
 
  376    marker_ = other.marker_;
 
  382  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  385    ElementInfo elementInfo = entityImp().elementInfo_;
 
  386    goNext ( elementInfo );
 
  388    entityImp().setElement( elementInfo, subEntity_ );
 
  392  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  396    if( elementInfo.isLeaf() || (elementInfo.level() >= level_) )
 
  398      while( (elementInfo.level() > 0) && (elementInfo.indexInFather() == 1) )
 
  399        elementInfo = elementInfo.father();
 
  400      if( elementInfo.level() == 0 )
 
  403        elementInfo = *macroIterator_;
 
  406        elementInfo = elementInfo.father().child( 1 );
 
  409      elementInfo = elementInfo.child( 0 );
 
  413  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  414  inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  415  ::nextElementStop ( ElementInfo &elementInfo )
 
  417    while( !(!elementInfo || stopAtElement( elementInfo )) )
 
  418      nextElement( elementInfo );
 
  422  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  423  inline bool AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  424  ::stopAtElement ( 
const ElementInfo &elementInfo )
 const 
  428    return (leafIterator ? elementInfo.isLeaf() : (level_ == elementInfo.level()));
 
  432  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  433  inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  434  ::goNext ( ElementInfo &elementInfo )
 
  436    integral_constant< int, codim > codimVariable;
 
  437    goNext( codimVariable, elementInfo );
 
  440  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  441  inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  442  ::goNext ( 
const integral_constant< int, 0 > cdVariable,
 
  443             ElementInfo &elementInfo )
 
  445    assert( stopAtElement( elementInfo ) );
 
  447    nextElement( elementInfo );
 
  448    nextElementStop( elementInfo );
 
  451  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  452  inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  453  ::goNext ( 
const integral_constant< int, 1 > cdVariable,
 
  454             ElementInfo &elementInfo )
 
  456    assert( stopAtElement( elementInfo ) );
 
  459    if( subEntity_ >= numSubEntities )
 
  462      nextElement( elementInfo );
 
  463      nextElementStop( elementInfo );
 
  470      const int face = (dimension == 1 ? (numSubEntities-1)-subEntity_ : subEntity_);
 
  472      const ALBERTA EL *neighbor = elementInfo.elInfo().neigh[ face ];
 
  473      if( (neighbor != NULL) && !elementInfo.isBoundary( face ) )
 
  476        const int elIndex = grid().dofNumbering() ( elementInfo, 0, 0 );
 
  477        const int nbIndex = grid().dofNumbering() ( neighbor, 0, 0 );
 
  478        if( elIndex < nbIndex )
 
  479          goNext( cdVariable, elementInfo );
 
  486      assert( marker_ != 0 );
 
  487      if( !marker_->template subEntityOnElement< 1 >( elementInfo, subEntity_ ) )
 
  488        goNext( cdVariable, elementInfo );
 
  492  template< 
int codim, 
class Gr
idImp, 
bool leafIterator >
 
  494  inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
 
  495  ::goNext ( 
const integral_constant< int, cd > cdVariable,
 
  496             ElementInfo &elementInfo )
 
  498    assert( stopAtElement( elementInfo ) );
 
  501    if( subEntity_ >= numSubEntities )
 
  504      nextElement( elementInfo );
 
  505      nextElementStop( elementInfo );
 
  510    assert( marker_ != 0 );
 
  511    if( !marker_->template subEntityOnElement< cd >( elementInfo, subEntity_ ) )
 
  512      goNext( cdVariable, elementInfo );
 
EntityPointer implementation for AlbertaGrid.
Definition: entitypointer.hh:29
 
const GridImp & grid() const
obtain a reference to the grid
Definition: entitypointer.hh:170
 
EntityImp & entityImp()
obtain reference to internal entity implementation
Definition: entitypointer.hh:155
 
Definition: treeiterator.hh:182
 
AlbertaGridTreeIterator(const GridImp &grid, const MarkerVector *marker, int travLevel)
Constructor making begin iterator.
Definition: treeiterator.hh:323
 
AlbertaGridTreeIterator(const GridImp &grid, int travLevel)
Constructor making end iterator.
Definition: treeiterator.hh:344
 
This & operator=(const This &other)
Constructor making end iterator.
Definition: treeiterator.hh:369
 
const GridImp & grid() const
obtain a reference to the grid
Definition: entitypointer.hh:170
 
EntityImp & entityImp()
obtain reference to internal entity implementation
Definition: entitypointer.hh:155
 
void increment()
increment
Definition: treeiterator.hh:383
 
AlbertaGridTreeIterator(const This &other)
Constructor making end iterator.
Definition: treeiterator.hh:357
 
marker assigning subentities to one element containing them
Definition: treeiterator.hh:30
 
AlbertaMarkerVector(const DofNumbering &dofNumbering)
create AlbertaMarkerVector with empty vectors
Definition: treeiterator.hh:49
 
bool up2Date() const
return true if marking is up to date
Definition: treeiterator.hh:90
 
bool subEntityOnElement(const ElementInfo &elementInfo, int subEntity) const
visit subentity on this element?
Definition: treeiterator.hh:265
 
void print(std::ostream &out=std::cout) const
print for debugin' only
Definition: treeiterator.hh:290
 
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: grid.hh:1305
 
provides a wrapper for ALBERTA's mesh structure
 
Dune namespace.
Definition: alignment.hh:10
 
Static tag representing a codimension.
Definition: dimension.hh:22
 
Traits for type conversions and type information.