4 #ifndef DUNE_ALBERTA_TREEITERATOR_HH 5 #define DUNE_ALBERTA_TREEITERATOR_HH 7 #include <dune/common/typetraits.hh> 28 template<
int dim,
int dimworld >
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 )
69 This &operator= (
const This & );
76 template<
int firstCodim,
class Iterator >
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 >
127 template<
int codim >
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 ) ];
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;
194 static const int numSubEntities
202 typedef typename GridImp::template Codim< codim >::Entity
Entity;
214 This &operator= (
const This &other );
221 const MarkerVector *marker,
228 using Base::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 std::integral_constant< int, 0 > cdVariable,
238 ElementInfo &elementInfo );
239 void goNext (
const std::integral_constant< int, 1 > cdVariable,
240 ElementInfo &elementInfo );
242 void goNext (
const std::integral_constant< int, cd > cdVariable,
243 ElementInfo &elementInfo );
251 MacroIterator macroIterator_;
254 const MarkerVector *marker_;
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 std::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 >
328 subEntity_( (codim == 0 ? 0 : -1) ),
329 macroIterator_( grid.meshPointer().begin() ),
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 >
417 while( !(!elementInfo || stopAtElement( elementInfo )) )
418 nextElement( elementInfo );
422 template<
int codim,
class Gr
idImp,
bool leafIterator >
428 return (leafIterator ? elementInfo.isLeaf() : (level_ == elementInfo.level()));
432 template<
int codim,
class Gr
idImp,
bool leafIterator >
436 std::integral_constant< int, codim > codimVariable;
437 goNext( codimVariable, elementInfo );
440 template<
int codim,
class Gr
idImp,
bool leafIterator >
442 ::goNext (
const std::integral_constant< int, 0 > cdVariable,
445 assert( stopAtElement( elementInfo ) );
447 nextElement( elementInfo );
448 nextElementStop( elementInfo );
451 template<
int codim,
class Gr
idImp,
bool leafIterator >
453 ::goNext (
const std::integral_constant< int, 1 > cdVariable,
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 >
495 ::goNext (
const std::integral_constant< int, cd > cdVariable,
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 );
517 #endif // #if HAVE_ALBERTA 519 #endif // #ifndef DUNE_ALBERTA_TREEITERATOR_HH int size(int codim) const
Definition: dofadmin.hh:157
Definition: treeiterator.hh:128
#define ALBERTA
Definition: albertaheader.hh:27
marker assigning subentities to one element containing them
Definition: treeiterator.hh:29
GridImp::template Codim< codim >::Entity Entity
Definition: treeiterator.hh:202
Alberta::ElementInfo< dimension > ElementInfo
Definition: treeiterator.hh:132
void clear()
Definition: treeiterator.hh:79
EntityObject::ImplementationType EntityImp
Definition: treeiterator.hh:204
AlbertaGridTreeIterator()
Definition: treeiterator.hh:313
bool up2Date() const
return true if marking is up to date
Definition: treeiterator.hh:90
Alberta::MeshPointer< dimension > MeshPointer
Definition: treeiterator.hh:199
[ provides Dune::Grid ]
Definition: agrid.hh:137
Entity ::Implementation ImplementationType
Definition: common/grid.hh:1262
static const int dimension
Definition: agrid.hh:177
This & operator=(const This &other)
Constructor making end iterator.
Definition: treeiterator.hh:369
AlbertaMarkerVector(const This &other)
Definition: treeiterator.hh:56
MakeableInterfaceObject< Entity > EntityObject
Definition: treeiterator.hh:203
Include standard header files.
Definition: agrid.hh:59
AlbertaMarkerVector< dimension, dimensionworld > MarkerVector
Definition: treeiterator.hh:206
static std::conditional< std::is_reference< InterfaceType >::value, typename std::add_lvalue_reference< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type, typename std::remove_const< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: common/grid.hh:1115
provides a wrapper for ALBERTA's mesh structure
void print(std::ostream &out=std::cout) const
print for debugin' only
Definition: treeiterator.hh:290
MeshPointer::MacroIterator MacroIterator
Definition: treeiterator.hh:200
EntityImp::ElementInfo ElementInfo
Definition: albertagrid/entitypointer.hh:49
void markSubEntities(const Iterator &begin, const Iterator &end)
Definition: treeiterator.hh:281
Definition: albertagrid/entity.hh:24
Base::ElementInfo ElementInfo
Definition: treeiterator.hh:198
void increment()
increment
Definition: treeiterator.hh:383
static void apply(const DofNumbering &dofNumbering, int *(&marker)[dimension+1], const ElementInfo &elementInfo)
Definition: treeiterator.hh:134
~AlbertaMarkerVector()
Definition: treeiterator.hh:63
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:335
AlbertaMarkerVector(const DofNumbering &dofNumbering)
create AlbertaMarkerVector with empty vectors
Definition: treeiterator.hh:49
EntityPointer implementation for AlbertaGrid.
Definition: albertagrid/entity.hh:21
bool subEntityOnElement(const ElementInfo &elementInfo, int subEntity) const
visit subentity on this element?
Definition: treeiterator.hh:265