4#ifndef DUNE_ALBERTA_TREEITERATOR_HH
5#define DUNE_ALBERTA_TREEITERATOR_HH
31 template<
int dim,
int dimworld >
46 struct NoMarkSubEntities;
48 struct MarkSubEntities;
53 : dofNumbering_( dofNumbering )
55 for(
int codim = 0; codim <= dimension; ++codim )
60 : dofNumbering_( other.dofNumbering_ )
62 for(
int codim = 0; codim <= dimension; ++codim )
79 template<
int firstCodim,
class Iterator >
84 for(
int codim = 0; codim <= dimension; ++codim )
86 if( marker_[ codim ] != 0 )
87 delete[] marker_[ codim ];
95 return (marker_[ dimension ] != 0);
103 int *marker_[ dimension+1 ];
111 template<
int dim,
int dimworld >
115 template<
int firstCodim,
class Iterator >
116 static void mark ( [[maybe_unused]]
const DofNumbering & dofNumbering,
117 [[maybe_unused]]
int *(&marker)[ dimension + 1 ],
118 [[maybe_unused]]
const Iterator &
begin,
119 [[maybe_unused]]
const Iterator &
end )
128 template<
int dim,
int dimworld >
130 struct AlbertaMarkerVector<
dim, dimworld >::MarkSubEntities
132 template<
int codim >
140 int *(&marker)[ dimension + 1 ],
143 int *array = marker[ codim ];
145 const int index = dofNumbering( elementInfo, 0, 0 );
146 for(
int i = 0; i < numSubEntities; ++i )
148 int &mark = array[ dofNumbering( elementInfo, codim, i ) ];
154 template<
int firstCodim,
class Iterator >
155 static void mark (
const DofNumbering &dofNumbering,
int *(&marker)[ dimension + 1 ],
156 const Iterator &
begin,
const Iterator &
end )
158 for(
int codim = firstCodim; codim <= dimension; ++codim )
160 const int size = dofNumbering.
size( codim );
161 marker[ codim ] =
new int[
size ];
163 int *array = marker[ codim ];
164 for(
int i = 0; i <
size; ++i )
168 for( Iterator it =
begin; it !=
end; ++it )
170 const ElementInfo &elementInfo = it->impl().elementInfo();
172 [ & ](
auto i ){ Codim< i+firstCodim >::apply( dofNumbering, marker, elementInfo ); } );
185 template<
int codim,
class Gr
idImp,
bool leafIterator >
198 static const int numSubEntities
231 return entity_.impl().equals( other.entity_.impl() );
243 return entity_.impl().level();
253 return entity_.impl().grid();
259 bool stopAtElement (
const ElementInfo &elementInfo )
const;
289 template<
int dim,
int dimworld >
290 template<
int codim >
291 inline bool AlbertaMarkerVector< dim, dimworld >
292 ::subEntityOnElement (
const ElementInfo &elementInfo,
int subEntity )
const
294 assert( marker_[ codim ] != 0 );
296 const int subIndex = dofNumbering_( elementInfo, codim, subEntity );
297 const int markIndex = marker_[ codim ][ subIndex ];
298 assert( (markIndex >= 0) );
300 const int index = dofNumbering_( elementInfo, 0, 0 );
301 return (markIndex ==
index);
305 template<
int dim,
int dimworld >
306 template<
int firstCodim,
class Iterator >
311 std::conditional< (firstCodim <= dimension), MarkSubEntities<true>, NoMarkSubEntities<false> >::type
312 ::template mark< firstCodim, Iterator >( dofNumbering_, marker_,
begin,
end );
316 template<
int dim,
int dimworld >
319 for(
int codim = 1; codim <= dimension; ++codim )
321 int *marker = marker_[ codim ];
324 const int size = dofNumbering_.size( codim );
326 out <<
"Codimension " << codim <<
" (" <<
size <<
" entries)" <<
std::endl;
327 for(
int i = 0; i <
size; ++i )
328 out <<
"subentity " << i <<
" visited on Element " << marker[ i ] <<
std::endl;
338 template<
int codim,
class Gr
idImp,
bool leafIterator >
348 template<
int codim,
class Gr
idImp,
bool leafIterator >
355 subEntity_( (codim == 0 ? 0 : -1) ),
356 macroIterator_( grid.meshPointer().
begin() ),
360 nextElementStop( elementInfo );
362 goNext( elementInfo );
364 entity_.impl().setElement( elementInfo, subEntity_ );
369 template<
int codim,
class Gr
idImp,
bool leafIterator >
376 macroIterator_( grid.meshPointer().
end() ),
382 template<
int codim,
class Gr
idImp,
bool leafIterator >
385 : entity_( other.entity_ ),
386 level_( other.level_ ),
387 subEntity_( other.subEntity_ ),
388 macroIterator_( other.macroIterator_ ),
389 marker_( other.marker_ )
394 template<
int codim,
class Gr
idImp,
bool leafIterator >
398 entity_ = other.entity_;
399 level_ = other.level_;
400 subEntity_ = other.subEntity_;
401 macroIterator_ = other.macroIterator_;
402 marker_ = other.marker_;
408 template<
int codim,
class Gr
idImp,
bool leafIterator >
411 ElementInfo elementInfo = entity_.impl().elementInfo_;
412 goNext ( elementInfo );
414 entity_.impl().setElement( elementInfo, subEntity_ );
418 template<
int codim,
class Gr
idImp,
bool leafIterator >
422 if( elementInfo.isLeaf() || (elementInfo.level() >= level_) )
424 while( (elementInfo.level() > 0) && (elementInfo.indexInFather() == 1) )
425 elementInfo = elementInfo.father();
426 if( elementInfo.level() == 0 )
429 elementInfo = *macroIterator_;
432 elementInfo = elementInfo.father().child( 1 );
435 elementInfo = elementInfo.child( 0 );
439 template<
int codim,
class Gr
idImp,
bool leafIterator >
440 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
441 ::nextElementStop ( ElementInfo &elementInfo )
443 while( !(!elementInfo || stopAtElement( elementInfo )) )
444 nextElement( elementInfo );
448 template<
int codim,
class Gr
idImp,
bool leafIterator >
449 inline bool AlbertaGridTreeIterator< codim, GridImp, leafIterator >
450 ::stopAtElement (
const ElementInfo &elementInfo )
const
454 return (leafIterator ? elementInfo.isLeaf() : (level_ == elementInfo.level()));
458 template<
int codim,
class Gr
idImp,
bool leafIterator >
459 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
460 ::goNext ( ElementInfo &elementInfo )
463 goNext( codimVariable, elementInfo );
466 template<
int codim,
class Gr
idImp,
bool leafIterator >
467 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
469 ElementInfo &elementInfo )
471 assert( stopAtElement( elementInfo ) );
473 nextElement( elementInfo );
474 nextElementStop( elementInfo );
477 template<
int codim,
class Gr
idImp,
bool leafIterator >
478 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
480 ElementInfo &elementInfo )
482 assert( stopAtElement( elementInfo ) );
485 if( subEntity_ >= numSubEntities )
488 nextElement( elementInfo );
489 nextElementStop( elementInfo );
496 const int face = (dimension == 1 ? (numSubEntities-1)-subEntity_ : subEntity_);
498 const ALBERTA EL *neighbor = elementInfo.elInfo().neigh[ face ];
499 if( (neighbor != NULL) && !elementInfo.isBoundary( face ) )
502 const int elIndex = grid().dofNumbering() ( elementInfo, 0, 0 );
503 const int nbIndex = grid().dofNumbering() ( neighbor, 0, 0 );
504 if( elIndex < nbIndex )
505 goNext( cdVariable, elementInfo );
512 assert( marker_ != 0 );
513 if( !marker_->template subEntityOnElement< 1 >( elementInfo, subEntity_ ) )
514 goNext( cdVariable, elementInfo );
518 template<
int codim,
class Gr
idImp,
bool leafIterator >
520 inline void AlbertaGridTreeIterator< codim, GridImp, leafIterator >
522 ElementInfo &elementInfo )
524 assert( stopAtElement( elementInfo ) );
527 if( subEntity_ >= numSubEntities )
530 nextElement( elementInfo );
531 nextElementStop( elementInfo );
536 assert( marker_ != 0 );
537 if( !marker_->template subEntityOnElement< cd >( elementInfo, subEntity_ ) )
538 goNext( cdVariable, elementInfo );
SLList< T, A > & operator=(const SLList< T, A > &other)
constexpr void forEach(Range &&range, F &&f)
std::ptrdiff_t index() const
#define ALBERTA
Definition albertaheader.hh:27
provides a wrapper for ALBERTA's mesh structure
provides a wrapper for ALBERTA's el_info structure
Include standard header files.
static const int dimension
Definition agrid.hh:143
int size(int codim) const
Definition dofadmin.hh:161
Definition treeiterator.hh:187
bool equals(const This &other) const
equality
Definition treeiterator.hh:229
MakeableInterfaceObject< Entity > EntityObject
Definition treeiterator.hh:206
Alberta::MeshPointer< dimension > MeshPointer
Definition treeiterator.hh:202
AlbertaGridTreeIterator(const GridImp &grid, const MarkerVector *marker, int travLevel)
Constructor making begin iterator.
Definition treeiterator.hh:350
AlbertaGridTreeIterator(const GridImp &grid, int travLevel)
Constructor making end iterator.
Definition treeiterator.hh:371
EntityObject::ImplementationType EntityImp
Definition treeiterator.hh:207
static const int codimension
Definition treeiterator.hh:192
MeshPointer::MacroIterator MacroIterator
Definition treeiterator.hh:203
This & operator=(const This &other)
Constructor making end iterator.
Definition treeiterator.hh:396
Entity & dereference() const
dereferencing
Definition treeiterator.hh:235
AlbertaMarkerVector< dimension, dimensionworld > MarkerVector
Definition treeiterator.hh:210
GridImp::template Codim< codim >::Entity Entity
Definition treeiterator.hh:205
int level() const
ask for level of entities
Definition treeiterator.hh:241
static const int dimensionworld
Definition treeiterator.hh:193
AlbertaGridTreeIterator()
Definition treeiterator.hh:340
void increment()
increment
Definition treeiterator.hh:409
const GridImp & grid() const
obtain a reference to the grid
Definition treeiterator.hh:251
static const int dimension
Definition treeiterator.hh:191
AlbertaGridTreeIterator(const This &other)
Constructor making end iterator.
Definition treeiterator.hh:384
EntityImp::ElementInfo ElementInfo
Definition treeiterator.hh:208
marker assigning subentities to one element containing them
Definition treeiterator.hh:33
AlbertaMarkerVector(const DofNumbering &dofNumbering)
create AlbertaMarkerVector with empty vectors
Definition treeiterator.hh:52
bool up2Date() const
return true if marking is up to date
Definition treeiterator.hh:93
bool subEntityOnElement(const ElementInfo &elementInfo, int subEntity) const
visit subentity on this element?
Definition treeiterator.hh:292
void markSubEntities(const Iterator &begin, const Iterator &end)
Definition treeiterator.hh:308
~AlbertaMarkerVector()
Definition treeiterator.hh:66
void clear()
Definition treeiterator.hh:82
AlbertaMarkerVector(const This &other)
Definition treeiterator.hh:59
void print(std::ostream &out=std::cout) const
print for debugin' only
Definition treeiterator.hh:317
Definition treeiterator.hh:134
Alberta::ElementInfo< dimension > ElementInfo
Definition treeiterator.hh:137
static void apply(const DofNumbering &dofNumbering, int *(&marker)[dimension+1], const ElementInfo &elementInfo)
Definition treeiterator.hh:139
Wrapper class for entities.
Definition common/entity.hh:64
InterfaceType::Implementation ImplementationType
Definition common/grid.hh:1093