3 #ifndef DUNE_ALBERTA_ELEMENTINFO_HH
4 #define DUNE_ALBERTA_ELEMENTINFO_HH
31 struct BasicNodeProjection;
63 #if !DUNE_ALBERTA_CACHE_COORDINATES
70 explicit ElementInfo (
const InstancePtr &instance );
84 operator bool ()
const {
return (instance_ != null()); }
107 void setMark (
int refCount )
const;
124 template<
int codim >
125 int twist (
int subEntity )
const;
134 #if !DUNE_ALBERTA_CACHE_COORDINATES
141 template<
class Functor >
144 template<
class Functor >
164 void addReference ()
const;
165 void removeReference ()
const;
167 static InstancePtr null ();
168 static Stack &stack ();
170 InstancePtr instance_;
192 #if !DUNE_ALBERTA_CACHE_COORDINATES
252 : macroIndex_( -1 ), level_( 0 ), path_( 0 )
255 Seed (
const int macroIndex,
const int level,
const unsigned long path )
256 : macroIndex_( macroIndex ), level_( level ), path_( path )
264 bool operator< (
const Seed &other )
const
266 const bool ml = (macroIndex() < other.
macroIndex());
267 const bool me = (macroIndex() == other.
macroIndex());
270 const bool pl = (path() < other.
path());
271 return ml | (me & (ll | (le & pl)));
275 bool operator<= (
const Seed &other )
const {
return !(other < *
this); }
276 bool operator> (
const Seed &other )
const {
return (other < *
this); }
277 bool operator>= (
const Seed &other )
const {
return !(*
this < other); }
279 bool isValid ( )
const {
return macroIndex_ != -1; }
282 int level ()
const {
return level_; }
283 unsigned long path ()
const {
return path_; }
298 : instance_( instance )
306 : instance_( null() )
317 instance_ = stack().allocate();
318 instance_->parent() = null();
319 ++(instance_->parent()->refCount);
323 elInfo().fill_flag = fillFlags;
326 for(
int k = 0; k < maxNeighbors; ++k )
327 elInfo().opp_vertex[ k ] = -1;
329 fill( mesh, ¯oElement, elInfo() );
338 instance_ = stack().allocate();
339 instance_->parent() = null();
340 ++(instance_->parent()->refCount);
345 elInfo().fill_flag = fillFlags;
348 for(
int k = 0; k < maxNeighbors; ++k )
349 elInfo().opp_vertex[ k ] = -1;
351 fill( mesh, ((
Mesh *)mesh)->macro_els + seed.
macroIndex(), elInfo() );
354 unsigned long path = seed.
path();
355 for(
int i = 0; i < seed.
level(); ++i )
358 child->
parent() = instance_;
361 for(
int k = 0; k < maxNeighbors; ++k )
362 child->
elInfo.opp_vertex[ k ] = -2;
364 fill( path & 1, elInfo(), child->
elInfo );
372 assert( this->seed() == seed );
378 : instance_( other.instance_ )
395 other.addReference();
397 instance_ = other.instance_;
406 return (instance_->elInfo.el == other.instance_->elInfo.el);
414 return (instance_->elInfo.el != other.instance_->elInfo.el);
423 assert( elInfo().macro_el != NULL );
424 return static_cast< const MacroElement &
>( *(elInfo().macro_el) );
440 #if DUNE_ALBERTA_VERSION >= 0x300
441 const Element *father = elInfo().parent->el;
443 const Element *father = elInfo().parent;
445 assert( father != NULL );
447 const int index = (father->child[ 0 ] == element ? 0 : 1);
448 assert( father->child[ index ] == element );
459 child->
parent() = instance_;
463 for(
int k = 0; k < maxNeighbors; ++k )
464 child->
elInfo.opp_vertex[ k ] = -2;
466 fill( i, elInfo(), child->
elInfo );
474 assert( !(*
this) ==
false );
475 return isLeaf( el() );
485 unsigned long path = 0;
489 const Element *father = p->parent()->elInfo.el;
490 const unsigned long child =
static_cast< unsigned long >( father->child[ 1 ] == element );
491 path = (path << 1) | child;
495 if( level != elInfo().level )
496 DUNE_THROW( NotImplemented,
"Seed for fake elements not implemented." );
498 return Seed( macroElement().index, level, path );
512 return mightVanish( el(), 0 );
519 return elInfo().level;
533 return instance_->elInfo.el_type;
548 assert( (refCount >= -128) && (refCount < 127) );
549 el()->mark = refCount;
553 #if DUNE_ALBERTA_VERSION >= 0x300
558 assert( (face >= 0) && (face < maxNeighbors) );
561 const int macroFace = elInfo().macro_wall[ face ];
563 return (macroElement().neighbor( macroFace ) != NULL);
567 #endif // DUNE_ALBERTA_VERSION >= 0x300
569 #if DUNE_ALBERTA_VERSION < 0x300
573 return (neighbor( face ) != NULL);
575 #endif // DUNE_ALBERTA_VERSION < 0x300
581 assert( (face >= 0) && (face < numFaces) );
583 Library< dimWorld >::leafNeighbor( *
this, face, neighbor );
592 assert( (face >= 0) && (face < numFaces) );
593 return Library< dimWorld >::levelNeighbors( *
this, face, neighbor, faceInNeighbor );
598 template<
int codim >
608 assert( neighbor( face ) != NULL );
613 #if DUNE_ALBERTA_VERSION >= 0x300
618 assert( (face >= 0) && (face < maxNeighbors) );
621 const int macroFace = elInfo().macro_wall[ face ];
623 return macroElement().isBoundary( macroFace );
627 #endif // DUNE_ALBERTA_VERSION >= 0x300
629 #if DUNE_ALBERTA_VERSION <= 0x200
634 assert( (face >= 0) && (face < maxNeighbors) );
635 return (elInfo().neigh[ face ] == 0);
637 #endif // DUNE_ALBERTA_VERSION <= 0x200
640 #if DUNE_ALBERTA_VERSION >= 0x300
645 assert( (face >= 0) && (face < N_WALLS_MAX) );
648 const int macroFace = elInfo().macro_wall[ face ];
649 const int id = macroElement().boundaryId( macroFace );
654 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
657 #if DUNE_ALBERTA_VERSION == 0x200
662 assert( (face >= 0) && (face < N_VERTICES_MAX) );
663 return elInfo().vertex_bound[ 1-face ];
670 assert( (face >= 0) && (face < N_EDGES_MAX) );
671 return elInfo().edge_bound[ face ];
678 assert( (face >= 0) && (face < N_FACES_MAX) );
679 return elInfo().face_bound[ face ];
681 #endif // #if DUNE_ALBERTA_VERSION == 0x200
684 #if DUNE_ALBERTA_VERSION >= 0x300
686 inline AffineTransformation *
690 assert( (face >= 0) && (face < N_WALLS_MAX) );
693 const int macroFace = elInfo().macro_wall[ face ];
694 return (macroFace < 0 ? NULL : macroElement().wall_trafo[ macroFace ]);
696 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
698 #if DUNE_ALBERTA_VERSION <= 0x200
700 inline AffineTransformation *
705 #endif // #if DUNE_ALBERTA_VERSION <= 0x200
708 #if DUNE_ALBERTA_VERSION >= 0x300
714 assert( (face >= 0) && (face < N_WALLS_MAX) );
717 const int macroFace = elInfo().macro_wall[ face ];
723 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
725 #if DUNE_ALBERTA_VERSION <= 0x200
727 inline BasicNodeProjection *
731 assert( (face >= 0) && (face < maxNeighbors) );
732 const int idx = (dim == 1 ? 2-face : 1+face);
735 #endif // #if DUNE_ALBERTA_VERSION <= 0x200
747 assert( hasCoordinates() );
748 assert( (vertex >= 0) && (vertex < numVertices) );
749 return elInfo().coord[
vertex ];
754 template<
class Functor >
760 child( 0 ).hierarchicTraverse( functor );
761 child( 1 ).hierarchicTraverse( functor );
767 template<
class Functor >
772 child( 0 ).leafTraverse( functor );
773 child( 1 ).leafTraverse( functor );
790 assert( (face >= 0) && (face < numFaces) );
792 return elInfo().neigh[ face ];
806 return (instance_->elInfo);
813 const Element *element,
int level,
int type )
816 instance->
parent() = null();
819 instance->
elInfo.mesh = mesh;
820 instance->
elInfo.macro_el = NULL;
822 instance->
elInfo.parent = NULL;
824 instance->
elInfo.level = level;
825 instance->
elInfo.el_type = type;
836 instance->
parent() = null();
839 instance->
elInfo = elInfo;
847 return IS_LEAF_EL( element );
854 if( isLeaf( element ) )
855 return (element->mark < depth);
857 return (mightVanish( element->child[ 0 ], depth-1 ) && mightVanish( element->child[ 1 ], depth-1 ));
862 inline void ElementInfo< dim >
865 ALBERTA fill_macro_info( mesh, mel, &elInfo );
867 #if DUNE_ALBERTA_VERSION < 0x300
869 if( (dim == 1) && (elInfo.fill_flag & FILL_PROJECTION) )
871 for(
int i = 0; i <= N_VERTICES_1D; ++i )
872 elInfo.projections[ i ] = mel->projection[ i ];
878 inline void ElementInfo< dim >
879 ::fill (
int ichild,
const ALBERTA EL_INFO &parentInfo,
ALBERTA EL_INFO &elInfo )
881 #if DUNE_ALBERTA_VERSION >= 0x300
882 ALBERTA fill_elinfo( ichild, FILL_ANY, &parentInfo, &elInfo );
884 ALBERTA fill_elinfo( ichild, &parentInfo, &elInfo );
887 if( (dim == 1) && (elInfo.fill_flag & FILL_PROJECTION) )
889 elInfo.projections[ 0 ] = parentInfo.projections[ 0 ];
892 elInfo.projections[ 1 ] = parentInfo.projections[ 0 ];
893 elInfo.projections[ 2 ] = parentInfo.projections[ 2 ];
897 elInfo.projections[ 1 ] = parentInfo.projections[ 1 ];
898 elInfo.projections[ 2 ] = parentInfo.projections[ 0 ];
906 inline void ElementInfo< dim >::addReference ()
const
908 ++(instance_->refCount);
913 inline void ElementInfo< dim >::removeReference ()
const
916 for( InstancePtr instance = instance_; --(instance->refCount) == 0; )
918 const InstancePtr parent = instance->parent();
919 stack().release( instance );
926 inline typename ElementInfo< dim >::InstancePtr
927 ElementInfo< dim >::null ()
929 return stack().null();
934 inline typename ElementInfo< dim >::Stack &
935 ElementInfo< dim >::stack ()
985 assert( (p != null()) && (p->
refCount == 0) );
1002 #endif // #if HAVE_ALBERTA
1004 #endif // #ifndef DUNE_ALBERTA_ELEMENTINFO_HH
int indexInFather() const
Definition: elementinfo.hh:437
ElementInfo child(int i) const
Definition: elementinfo.hh:454
bool isValid() const
Definition: elementinfo.hh:279
Definition: elementinfo.hh:179
static const int maxNeighbors
Definition: elementinfo.hh:59
Definition: elementinfo.hh:39
InstancePtr allocate()
Definition: elementinfo.hh:970
int macroIndex() const
Definition: elementinfo.hh:281
InstancePtr null()
Definition: elementinfo.hh:993
bool mightVanish() const
Definition: elementinfo.hh:510
Stack()
Definition: elementinfo.hh:947
Definition: common.hh:179
bool operator==(const ElementInfo &other) const
Definition: elementinfo.hh:404
GeometryCacheProxy< dim > GeometryCache
Definition: elementinfo.hh:64
static const Flags neighbor
Definition: misc.hh:249
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:768
int level() const
Definition: elementinfo.hh:517
int twist(int subEntity) const
Definition: elementinfo.hh:599
Alberta::GeometryCache< dim > geometryCache
Definition: elementinfo.hh:194
const Element * element() const
Definition: elementinfo.hh:781
AffineTransformation * transformation(int face) const
Definition: elementinfo.hh:701
Definition: macroelement.hh:20
BasicNodeProjection * boundaryProjection(int face) const
Definition: elementinfo.hh:728
InstancePtr & parent()
Definition: elementinfo.hh:184
ALBERTA REAL_D GlobalVector
Definition: misc.hh:47
bool hasLeafNeighbor(const int face) const
Definition: elementinfo.hh:571
~ElementInfo()
Definition: elementinfo.hh:385
Alberta::MeshPointer< dimension > MeshPointer
Definition: elementinfo.hh:56
Definition: geometrycache.hh:88
static const Flags boundaryId
Definition: misc.hh:264
unsigned int refCount
Definition: elementinfo.hh:182
Seed(const int macroIndex, const int level, const unsigned long path)
Definition: elementinfo.hh:255
MeshPointer mesh() const
Definition: elementinfo.hh:503
int levelNeighbors(const int face, ElementInfo(&neighbor)[maxLevelNeighbors], int(&faceInNeighbor)[maxLevelNeighbors]) const
Definition: elementinfo.hh:590
static const int maxLevelNeighbors
Definition: elementinfo.hh:61
bool hasCoordinates() const
Definition: elementinfo.hh:739
static const Flags nothing
Definition: misc.hh:245
static const int numVertices
Definition: elementinfo.hh:52
bool operator!=(const ElementInfo &other) const
Definition: elementinfo.hh:412
int twistInNeighbor(int face) const
Definition: elementinfo.hh:606
Alberta::MacroElement< dimension > MacroElement
Definition: elementinfo.hh:55
static int twist(const Element *element, int subEntity)
Definition: misc.hh:565
ALBERTA MESH Mesh
Definition: misc.hh:60
int level() const
Definition: elementinfo.hh:282
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:755
void setMark(int refCount) const
Definition: elementinfo.hh:545
const GlobalVector & coordinate(int vertex) const
Definition: elementinfo.hh:745
#define ALBERTA
Definition: albertaheader.hh:27
Alberta::FillFlags< dimension > FillFlags
Definition: elementinfo.hh:57
Definition: elementinfo.hh:249
int boundaryId(int face) const
ALBERTA EL Element
Definition: misc.hh:61
Definition: elementinfo.hh:204
ElementInfo()
Definition: elementinfo.hh:305
Definition: geometrycache.hh:21
static const Flags coords
Definition: misc.hh:247
~Stack()
Definition: elementinfo.hh:957
ElementInfo & operator=(const ElementInfo &other)
Definition: elementinfo.hh:393
bool isLeaf() const
Definition: elementinfo.hh:472
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:804
static ElementInfo createFake(const MeshPointer &mesh, const Element *element, int level, int type=0)
Definition: elementinfo.hh:812
bool isBoundary(int face) const
Definition: elementinfo.hh:631
ALBERTA FLAGS Flags
Definition: misc.hh:243
int type() const
Definition: elementinfo.hh:524
Definition: albertagrid/projection.hh:204
void release(InstancePtr &p)
Definition: elementinfo.hh:983
static const int dimension
Definition: elementinfo.hh:50
int getMark() const
Definition: elementinfo.hh:538
static const int numFaces
Definition: elementinfo.hh:53
const Element * neighbor(int face) const
Definition: elementinfo.hh:788
ALBERTA EL_INFO elInfo
Definition: elementinfo.hh:181
Seed seed() const
Definition: elementinfo.hh:480
ElementInfo leafNeighbor(const int face) const
Definition: elementinfo.hh:579
GeometryCache geometryCache() const
Definition: elementinfo.hh:135
const MacroElement & macroElement() const
Definition: elementinfo.hh:420
ElementInfo father() const
Definition: elementinfo.hh:429
unsigned long path() const
Definition: elementinfo.hh:283
Seed()
Definition: elementinfo.hh:251
static const Flags standard
Definition: misc.hh:283
Element * el() const
Definition: elementinfo.hh:797