5 #ifndef DUNE_ALBERTA_ELEMENTINFO_HH 6 #define DUNE_ALBERTA_ELEMENTINFO_HH 34 struct BasicNodeProjection;
66 #if !DUNE_ALBERTA_CACHE_COORDINATES 73 explicit ElementInfo (
const InstancePtr &instance );
89 explicit operator bool ()
const {
return (instance_ != null()); }
112 void setMark (
int refCount )
const;
129 template<
int codim >
130 int twist (
int subEntity )
const;
139 #if !DUNE_ALBERTA_CACHE_COORDINATES 146 template<
class Functor >
149 template<
class Functor >
169 void addReference ()
const;
170 void removeReference ()
const;
172 static InstancePtr null ();
173 static Stack &stack ();
175 InstancePtr instance_;
197 #if !DUNE_ALBERTA_CACHE_COORDINATES 257 : macroIndex_( -1 ), level_( 0 ), path_( 0 )
260 Seed (
const int macroIndex,
const int level,
const unsigned long path )
261 : macroIndex_( macroIndex ), level_(
level ), path_( path )
269 bool operator< (
const Seed &other )
const 271 const bool ml = (macroIndex() < other.
macroIndex());
272 const bool me = (macroIndex() == other.
macroIndex());
275 const bool pl = (path() < other.
path());
276 return ml | (me & (ll | (le & pl)));
280 bool operator<= (
const Seed &other )
const {
return !(other < *
this); }
281 bool operator> (
const Seed &other )
const {
return (other < *
this); }
282 bool operator>= (
const Seed &other )
const {
return !(*
this < other); }
284 bool isValid ( )
const {
return macroIndex_ != -1; }
287 int level ()
const {
return level_; }
288 unsigned long path ()
const {
return path_; }
303 : instance_( instance )
311 : instance_( null() )
322 instance_ = stack().allocate();
323 instance_->parent() = null();
324 ++(instance_->parent()->refCount);
328 elInfo().fill_flag = fillFlags;
331 for(
int k = 0; k < maxNeighbors; ++k )
332 elInfo().opp_vertex[ k ] = -1;
334 fill( mesh, ¯oElement, elInfo() );
343 instance_ = stack().allocate();
344 instance_->parent() = null();
345 ++(instance_->parent()->refCount);
350 elInfo().fill_flag = fillFlags;
353 for(
int k = 0; k < maxNeighbors; ++k )
354 elInfo().opp_vertex[ k ] = -1;
356 fill( mesh, ((
Mesh *)mesh)->macro_els + seed.macroIndex(), elInfo() );
359 unsigned long path = seed.path();
360 for(
int i = 0; i < seed.level(); ++i )
362 InstancePtr child = stack().allocate();
363 child->parent() = instance_;
366 for(
int k = 0; k < maxNeighbors; ++k )
367 child->elInfo.opp_vertex[ k ] = -2;
369 fill( path & 1, elInfo(), child->elInfo );
377 assert( this->seed() == seed );
383 : instance_( other.instance_ )
393 swap( instance_, other.instance_ );
407 other.addReference();
409 instance_ = other.instance_;
418 swap( instance_, other.instance_ );
426 return (instance_->elInfo.el == other.instance_->elInfo.el);
434 return (instance_->elInfo.el != other.instance_->elInfo.el);
443 assert( elInfo().macro_el != NULL );
444 return static_cast< const MacroElement &
>( *(elInfo().macro_el) );
460 const Element *father = elInfo().parent->el;
461 assert( father != NULL );
463 const int index = (father->child[ 0 ] == element ? 0 : 1);
464 assert( father->child[ index ] == element );
474 InstancePtr child = stack().allocate();
475 child->parent() = instance_;
479 for(
int k = 0; k < maxNeighbors; ++k )
480 child->elInfo.opp_vertex[ k ] = -2;
482 fill( i, elInfo(), child->elInfo );
490 assert( !(*
this) ==
false );
491 return isLeaf( el() );
501 unsigned long path = 0;
502 for( InstancePtr p = instance_; p->parent() != null(); p = p->parent() )
505 const Element *father = p->parent()->elInfo.el;
506 const unsigned long child =
static_cast< unsigned long >( father->child[ 1 ] == element );
507 path = (path << 1) | child;
511 if( level != elInfo().level )
512 DUNE_THROW( NotImplemented,
"Seed for fake elements not implemented." );
514 return Seed( macroElement().index, level, path );
528 return mightVanish( el(), 0 );
535 return elInfo().
level;
549 return instance_->
elInfo.el_type;
564 assert( (refCount >= -128) && (refCount < 127) );
565 el()->mark = refCount;
573 assert( (face >= 0) && (face < maxNeighbors) );
575 assert( (elInfo().fill_flag & FillFlags::boundaryId) != 0 );
576 const int macroFace = elInfo().macro_wall[ face ];
578 return (macroElement().neighbor( macroFace ) != NULL);
587 assert( (face >= 0) && (face < numFaces) );
589 Library< dimWorld >::leafNeighbor( *
this, face, neighbor );
598 assert( (face >= 0) && (face < numFaces) );
599 return Library< dimWorld >::levelNeighbors( *
this, face, neighbor, faceInNeighbor );
604 template<
int codim >
614 assert( neighbor( face ) != NULL );
623 assert( (face >= 0) && (face < maxNeighbors) );
625 assert( (elInfo().fill_flag & FillFlags::boundaryId) != 0 );
626 const int macroFace = elInfo().macro_wall[ face ];
628 return macroElement().isBoundary( macroFace );
638 assert( (face >= 0) && (face < N_WALLS_MAX) );
640 assert( (elInfo().fill_flag & FillFlags::boundaryId) != 0 );
641 const int macroFace = elInfo().macro_wall[ face ];
642 const int id = macroElement().boundaryId( macroFace );
654 assert( (face >= 0) && (face < N_WALLS_MAX) );
656 assert( (elInfo().fill_flag & FillFlags::boundaryId) != 0 );
657 const int macroFace = elInfo().macro_wall[ face ];
658 return (macroFace < 0 ? NULL : macroElement().wall_trafo[ macroFace ]);
667 assert( (face >= 0) && (face < N_WALLS_MAX) );
669 assert( (elInfo().fill_flag & FillFlags::boundaryId) != 0 );
670 const int macroFace = elInfo().macro_wall[ face ];
681 return ((elInfo().fill_flag & FillFlags::coords) != 0);
687 assert( hasCoordinates() );
689 return elInfo().coord[
vertex ];
694 template<
class Functor >
700 child( 0 ).hierarchicTraverse( functor );
701 child( 1 ).hierarchicTraverse( functor );
707 template<
class Functor >
713 child( 1 ).leafTraverse( functor );
730 assert( (face >= 0) && (face < numFaces) );
731 assert( (elInfo().fill_flag & FillFlags::neighbor) != 0 );
732 return elInfo().neigh[ face ];
746 return (instance_->elInfo);
753 const Element *element,
int level,
int type )
755 InstancePtr instance = stack().allocate();
756 instance->parent() = null();
757 ++(instance->parent()->refCount);
759 instance->elInfo.mesh = mesh;
760 instance->elInfo.macro_el = NULL;
761 instance->elInfo.el =
const_cast< Element *
>( element );
762 instance->elInfo.parent = NULL;
763 instance->elInfo.fill_flag = FillFlags::nothing;
764 instance->elInfo.level = level;
765 instance->elInfo.el_type = type;
775 InstancePtr instance = stack().allocate();
776 instance->parent() = null();
777 ++(instance->parent()->refCount);
779 instance->elInfo = elInfo;
787 return IS_LEAF_EL( element );
792 inline bool ElementInfo< dim >::mightVanish (
Alberta::Element *element,
int depth )
794 if( isLeaf( element ) )
795 return (element->mark < depth);
797 return (mightVanish( element->child[ 0 ], depth-1 ) && mightVanish( element->child[ 1 ], depth-1 ));
802 inline void ElementInfo< dim >
805 ALBERTA fill_macro_info( mesh, mel, &elInfo );
809 inline void ElementInfo< dim >
810 ::fill (
int ichild,
const ALBERTA EL_INFO &parentInfo,
ALBERTA EL_INFO &elInfo )
812 ALBERTA fill_elinfo( ichild, FILL_ANY, &parentInfo, &elInfo );
817 inline void ElementInfo< dim >::addReference ()
const 819 ++(instance_->refCount);
824 inline void ElementInfo< dim >::removeReference ()
const 830 for( InstancePtr instance = instance_; --(instance->refCount) == 0; )
832 const InstancePtr parent = instance->parent();
833 stack().release( instance );
840 inline typename ElementInfo< dim >::InstancePtr
841 ElementInfo< dim >::null ()
843 return stack().null();
848 inline typename ElementInfo< dim >::Stack &
849 ElementInfo< dim >::stack ()
899 assert( (p != null()) && (p->
refCount == 0) );
916 #endif // #if HAVE_ALBERTA 918 #endif // #ifndef DUNE_ALBERTA_ELEMENTINFO_HH ~ElementInfo()
Definition: elementinfo.hh:397
Definition: geometrycache.hh:90
ALBERTA MESH Mesh
Definition: misc.hh:53
Definition: elementinfo.hh:42
Alberta::FillFlags< dimension > FillFlags
Definition: elementinfo.hh:60
Definition: macroelement.hh:22
bool hasLeafNeighbor(const int face) const
Definition: elementinfo.hh:570
ElementInfo & operator=(const ElementInfo &other)
Definition: elementinfo.hh:405
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:744
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:695
bool mightVanish() const
Definition: elementinfo.hh:526
GeometryCache geometryCache() const
Definition: elementinfo.hh:140
unsigned int refCount
Definition: elementinfo.hh:187
Definition: geometrycache.hh:23
static const int maxNeighbors
Definition: elementinfo.hh:62
InstancePtr null()
Definition: elementinfo.hh:907
bool operator==(const ElementInfo &other) const
Definition: elementinfo.hh:424
int twist(int subEntity) const
Definition: elementinfo.hh:605
~Stack()
Definition: elementinfo.hh:871
AffineTransformation * transformation(int face) const
Definition: elementinfo.hh:651
int level() const
Definition: elementinfo.hh:533
ALBERTA AFF_TRAFO AffineTransformation
Definition: misc.hh:52
ALBERTA REAL_D GlobalVector
Definition: misc.hh:50
Alberta::GeometryCache< dim > geometryCache
Definition: elementinfo.hh:199
ALBERTA FLAGS Flags
Definition: misc.hh:232
static ElementInfo createFake(const MeshPointer &mesh, const Element *element, int level, int type=0)
Definition: elementinfo.hh:752
int getMark() const
Definition: elementinfo.hh:554
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:708
static const int maxLevelNeighbors
Definition: elementinfo.hh:64
BasicNodeProjection * boundaryProjection(int face) const
Definition: elementinfo.hh:664
Seed(const int macroIndex, const int level, const unsigned long path)
Definition: elementinfo.hh:260
InstancePtr & parent()
Definition: elementinfo.hh:189
Alberta::MacroElement< dimension > MacroElement
Definition: elementinfo.hh:58
unsigned long path() const
Definition: elementinfo.hh:288
Definition: common.hh:133
InstancePtr allocate()
Definition: elementinfo.hh:884
#define ALBERTA
Definition: albertaheader.hh:29
bool isValid() const
Definition: elementinfo.hh:284
void setMark(int refCount) const
Definition: elementinfo.hh:561
static const int numVertices
Definition: elementinfo.hh:55
int level() const
Definition: elementinfo.hh:287
static const int numFaces
Definition: elementinfo.hh:56
void release(InstancePtr &p)
Definition: elementinfo.hh:897
bool operator!=(const ElementInfo &other) const
Definition: elementinfo.hh:432
const GlobalVector & coordinate(int vertex) const
Definition: elementinfo.hh:685
Seed()
Definition: elementinfo.hh:256
Definition: elementinfo.hh:209
Element * el() const
Definition: elementinfo.hh:737
GeometryCacheProxy< dim > GeometryCache
Definition: elementinfo.hh:67
bool hasCoordinates() const
Definition: elementinfo.hh:679
Include standard header files.
Definition: agrid.hh:59
Definition: elementinfo.hh:184
ALBERTA EL Element
Definition: misc.hh:54
ElementInfo leafNeighbor(const int face) const
Definition: elementinfo.hh:585
ElementInfo()
Definition: elementinfo.hh:310
bool isLeaf() const
Definition: elementinfo.hh:488
MeshPointer mesh() const
Definition: elementinfo.hh:519
int twistInNeighbor(int face) const
Definition: elementinfo.hh:612
Definition: elementinfo.hh:254
int type() const
Definition: elementinfo.hh:540
const MacroElement & macroElement() const
Definition: elementinfo.hh:440
int macroIndex() const
Definition: elementinfo.hh:286
static const int dimension
Definition: elementinfo.hh:53
Alberta::MeshPointer< dimension > MeshPointer
Definition: elementinfo.hh:59
ALBERTA EL_INFO elInfo
Definition: elementinfo.hh:186
Definition: albertagrid/projection.hh:206
int levelNeighbors(const int face, ElementInfo(&neighbor)[maxLevelNeighbors], int(&faceInNeighbor)[maxLevelNeighbors]) const
Definition: elementinfo.hh:596
const Element * neighbor(int face) const
Definition: elementinfo.hh:728
bool isBoundary(int face) const
Definition: elementinfo.hh:620
static const Flags standard
Definition: misc.hh:256
Seed seed() const
Definition: elementinfo.hh:496
ElementInfo child(int i) const
Definition: elementinfo.hh:470
ElementInfo father() const
Definition: elementinfo.hh:449
int boundaryId(int face) const
Definition: elementinfo.hh:635
int indexInFather() const
Definition: elementinfo.hh:457
const Element * element() const
Definition: elementinfo.hh:721