6#ifndef DUNE_ALBERTA_TREEITERATOR_HH
7#define DUNE_ALBERTA_TREEITERATOR_HH
11#include <dune/common/hybridutilities.hh>
12#include <dune/common/typetraits.hh>
33 template<
int dim,
int dimworld >
48 struct NoMarkSubEntities;
50 struct MarkSubEntities;
55 : dofNumbering_( dofNumbering )
57 for(
int codim = 0; codim <= dimension; ++codim )
62 : dofNumbering_( other.dofNumbering_ )
64 for(
int codim = 0; codim <= dimension; ++codim )
74 This &operator= (
const This & );
81 template<
int firstCodim,
class Iterator >
86 for(
int codim = 0; codim <= dimension; ++codim )
88 if( marker_[ codim ] != 0 )
89 delete[] marker_[ codim ];
97 return (marker_[ dimension ] != 0);
101 void print ( std::ostream &out = std::cout )
const;
105 int *marker_[ dimension+1 ];
113 template<
int dim,
int dimworld >
117 template<
int firstCodim,
class Iterator >
118 static void mark ( [[maybe_unused]]
const DofNumbering & dofNumbering,
119 [[maybe_unused]]
int *(&marker)[ dimension + 1 ],
120 [[maybe_unused]]
const Iterator &begin,
121 [[maybe_unused]]
const Iterator &end )
130 template<
int dim,
int dimworld >
132 struct AlbertaMarkerVector< dim, dimworld >::MarkSubEntities
134 template<
int codim >
142 int *(&marker)[ dimension + 1 ],
145 int *array = marker[ codim ];
147 const int index = dofNumbering( elementInfo, 0, 0 );
148 for(
int i = 0; i < numSubEntities; ++i )
150 int &mark = array[ dofNumbering( elementInfo, codim, i ) ];
156 template<
int firstCodim,
class Iterator >
157 static void mark (
const DofNumbering &dofNumbering,
int *(&marker)[ dimension + 1 ],
158 const Iterator &begin,
const Iterator &end )
160 for(
int codim = firstCodim; codim <= dimension; ++codim )
162 const int size = dofNumbering.
size( codim );
163 marker[ codim ] =
new int[ size ];
165 int *array = marker[ codim ];
166 for(
int i = 0; i < size; ++i )
170 for( Iterator it = begin; it != end; ++it )
172 const ElementInfo &elementInfo = it->impl().elementInfo();
173 Hybrid::forEach( std::make_index_sequence< dimension+1-firstCodim >{},
174 [ & ](
auto i ){ Codim< i+firstCodim >::apply( dofNumbering, marker, elementInfo ); } );
187 template<
int codim,
class Gr
idImp,
bool leafIterator >
200 static const int numSubEntities
207 typedef typename GridImp::template Codim< codim >::Entity
Entity;
233 return entity_.impl().equals( other.entity_.impl() );
245 return entity_.impl().level();
255 return entity_.impl().grid();
261 bool stopAtElement (
const ElementInfo &elementInfo )
const;
264 void goNext (
const std::integral_constant< int, 0 > cdVariable,
266 void goNext (
const std::integral_constant< int, 1 > cdVariable,
269 void goNext (
const std::integral_constant< int, cd > cdVariable,
291 template<
int dim,
int dimworld >
292 template<
int codim >
296 assert( marker_[ codim ] != 0 );
298 const int subIndex = dofNumbering_( elementInfo, codim, subEntity );
299 const int markIndex = marker_[ codim ][ subIndex ];
300 assert( (markIndex >= 0) );
302 const int index = dofNumbering_( elementInfo, 0, 0 );
303 return (markIndex == index);
307 template<
int dim,
int dimworld >
308 template<
int firstCodim,
class Iterator >
313 std::conditional< (firstCodim <= dimension), MarkSubEntities<true>, NoMarkSubEntities<false> >::type
314 ::template mark< firstCodim, Iterator >( dofNumbering_, marker_, begin, end );
318 template<
int dim,
int dimworld >
321 for(
int codim = 1; codim <= dimension; ++codim )
323 int *marker = marker_[ codim ];
326 const int size = dofNumbering_.size( codim );
328 out <<
"Codimension " << codim <<
" (" << size <<
" entries)" << std::endl;
329 for(
int i = 0; i < size; ++i )
330 out <<
"subentity " << i <<
" visited on Element " << marker[ i ] << std::endl;
340 template<
int codim,
class Gr
idImp,
bool leafIterator >
350 template<
int codim,
class Gr
idImp,
bool leafIterator >
357 subEntity_( (codim == 0 ? 0 : -1) ),
358 macroIterator_( grid.meshPointer().begin() ),
362 nextElementStop( elementInfo );
364 goNext( elementInfo );
366 entity_.impl().setElement( elementInfo, subEntity_ );
371 template<
int codim,
class Gr
idImp,
bool leafIterator >
378 macroIterator_( grid.meshPointer().end() ),
384 template<
int codim,
class Gr
idImp,
bool leafIterator >
387 : entity_( other.entity_ ),
388 level_( other.level_ ),
389 subEntity_( other.subEntity_ ),
390 macroIterator_( other.macroIterator_ ),
391 marker_( other.marker_ )
396 template<
int codim,
class Gr
idImp,
bool leafIterator >
400 entity_ = other.entity_;
401 level_ = other.level_;
402 subEntity_ = other.subEntity_;
403 macroIterator_ = other.macroIterator_;
404 marker_ = other.marker_;
410 template<
int codim,
class Gr
idImp,
bool leafIterator >
413 ElementInfo elementInfo = entity_.impl().elementInfo_;
414 goNext ( elementInfo );
416 entity_.impl().setElement( elementInfo, subEntity_ );
420 template<
int codim,
class Gr
idImp,
bool leafIterator >
424 if( elementInfo.isLeaf() || (elementInfo.level() >= level_) )
426 while( (elementInfo.level() > 0) && (elementInfo.indexInFather() == 1) )
427 elementInfo = elementInfo.father();
428 if( elementInfo.level() == 0 )
431 elementInfo = *macroIterator_;
434 elementInfo = elementInfo.father().child( 1 );
437 elementInfo = elementInfo.child( 0 );
441 template<
int codim,
class Gr
idImp,
bool leafIterator >
442 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
443 ::nextElementStop ( ElementInfo &elementInfo )
445 while( !(!elementInfo || stopAtElement( elementInfo )) )
446 nextElement( elementInfo );
450 template<
int codim,
class Gr
idImp,
bool leafIterator >
451 inline bool AlbertaGridTreeIterator< codim, GridImp, leafIterator >
452 ::stopAtElement (
const ElementInfo &elementInfo )
const
456 return (leafIterator ? elementInfo.isLeaf() : (level_ == elementInfo.level()));
460 template<
int codim,
class Gr
idImp,
bool leafIterator >
461 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
462 ::goNext ( ElementInfo &elementInfo )
464 std::integral_constant< int, codim > codimVariable;
465 goNext( codimVariable, elementInfo );
468 template<
int codim,
class Gr
idImp,
bool leafIterator >
469 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
470 ::goNext (
const std::integral_constant< int, 0 > ,
471 ElementInfo &elementInfo )
473 assert( stopAtElement( elementInfo ) );
475 nextElement( elementInfo );
476 nextElementStop( elementInfo );
479 template<
int codim,
class Gr
idImp,
bool leafIterator >
480 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
481 ::goNext (
const std::integral_constant< int, 1 > cdVariable,
482 ElementInfo &elementInfo )
484 assert( stopAtElement( elementInfo ) );
487 if( subEntity_ >= numSubEntities )
490 nextElement( elementInfo );
491 nextElementStop( elementInfo );
498 const int face = (dimension == 1 ? (numSubEntities-1)-subEntity_ : subEntity_);
500 const ALBERTA EL *neighbor = elementInfo.elInfo().neigh[ face ];
501 if( (neighbor != NULL) && !elementInfo.isBoundary( face ) )
504 const int elIndex = grid().dofNumbering() ( elementInfo, 0, 0 );
505 const int nbIndex = grid().dofNumbering() ( neighbor, 0, 0 );
506 if( elIndex < nbIndex )
507 goNext( cdVariable, elementInfo );
514 assert( marker_ != 0 );
515 if( !marker_->template subEntityOnElement< 1 >( elementInfo, subEntity_ ) )
516 goNext( cdVariable, elementInfo );
520 template<
int codim,
class Gr
idImp,
bool leafIterator >
522 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
523 ::goNext (
const std::integral_constant< int, cd > cdVariable,
524 ElementInfo &elementInfo )
526 assert( stopAtElement( elementInfo ) );
529 if( subEntity_ >= numSubEntities )
532 nextElement( elementInfo );
533 nextElementStop( elementInfo );
538 assert( marker_ != 0 );
539 if( !marker_->template subEntityOnElement< cd >( elementInfo, subEntity_ ) )
540 goNext( cdVariable, elementInfo );
provides a wrapper for ALBERTA's mesh structure
provides a wrapper for ALBERTA's el_info structure
#define ALBERTA
Definition: albertaheader.hh:29
Include standard header files.
Definition: agrid.hh:60
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:337
static const int dimension
Definition: agrid.hh:145
int size(int codim) const
Definition: dofadmin.hh:163
Definition: treeiterator.hh:189
bool equals(const This &other) const
equality
Definition: treeiterator.hh:231
MakeableInterfaceObject< Entity > EntityObject
Definition: treeiterator.hh:208
Alberta::MeshPointer< dimension > MeshPointer
Definition: treeiterator.hh:204
AlbertaGridTreeIterator(const GridImp &grid, const MarkerVector *marker, int travLevel)
Constructor making begin iterator.
Definition: treeiterator.hh:352
AlbertaGridTreeIterator(const GridImp &grid, int travLevel)
Constructor making end iterator.
Definition: treeiterator.hh:373
EntityObject::ImplementationType EntityImp
Definition: treeiterator.hh:209
static const int codimension
Definition: treeiterator.hh:194
MeshPointer::MacroIterator MacroIterator
Definition: treeiterator.hh:205
This & operator=(const This &other)
Constructor making end iterator.
Definition: treeiterator.hh:398
Entity & dereference() const
dereferencing
Definition: treeiterator.hh:237
AlbertaMarkerVector< dimension, dimensionworld > MarkerVector
Definition: treeiterator.hh:212
GridImp::template Codim< codim >::Entity Entity
Definition: treeiterator.hh:207
int level() const
ask for level of entities
Definition: treeiterator.hh:243
static const int dimensionworld
Definition: treeiterator.hh:195
AlbertaGridTreeIterator()
Definition: treeiterator.hh:342
void increment()
increment
Definition: treeiterator.hh:411
const GridImp & grid() const
obtain a reference to the grid
Definition: treeiterator.hh:253
static const int dimension
Definition: treeiterator.hh:193
AlbertaGridTreeIterator(const This &other)
Constructor making end iterator.
Definition: treeiterator.hh:386
EntityImp::ElementInfo ElementInfo
Definition: treeiterator.hh:210
marker assigning subentities to one element containing them
Definition: treeiterator.hh:35
AlbertaMarkerVector(const DofNumbering &dofNumbering)
create AlbertaMarkerVector with empty vectors
Definition: treeiterator.hh:54
bool up2Date() const
return true if marking is up to date
Definition: treeiterator.hh:95
bool subEntityOnElement(const ElementInfo &elementInfo, int subEntity) const
visit subentity on this element?
Definition: treeiterator.hh:294
void markSubEntities(const Iterator &begin, const Iterator &end)
Definition: treeiterator.hh:310
~AlbertaMarkerVector()
Definition: treeiterator.hh:68
void clear()
Definition: treeiterator.hh:84
AlbertaMarkerVector(const This &other)
Definition: treeiterator.hh:61
void print(std::ostream &out=std::cout) const
print for debugin' only
Definition: treeiterator.hh:319
Definition: treeiterator.hh:136
Alberta::ElementInfo< dimension > ElementInfo
Definition: treeiterator.hh:139
static void apply(const DofNumbering &dofNumbering, int *(&marker)[dimension+1], const ElementInfo &elementInfo)
Definition: treeiterator.hh:141
Wrapper class for entities.
Definition: common/entity.hh:66
InterfaceType::Implementation ImplementationType
Definition: common/grid.hh:1108