3 #ifndef DUNE_ALBERTA_ELEMENTINFO_HH
4 #define DUNE_ALBERTA_ELEMENTINFO_HH
32 struct BasicNodeProjection;
64 #if !DUNE_ALBERTA_CACHE_COORDINATES
87 explicit operator bool ()
const {
return (instance_ !=
null()); }
127 template<
int codim >
137 #if !DUNE_ALBERTA_CACHE_COORDINATES
144 template<
class Functor >
147 template<
class Functor >
167 void addReference ()
const;
168 void removeReference ()
const;
170 static InstancePtr
null ();
171 static Stack &stack ();
173 InstancePtr instance_;
195 #if !DUNE_ALBERTA_CACHE_COORDINATES
216 InstancePtr allocate ();
217 void release ( InstancePtr &p );
255 : macroIndex_( -1 ), level_( 0 ), path_( 0 )
258 Seed (
const int macroIndex,
const int level,
const unsigned long path )
259 : macroIndex_( macroIndex ), level_(
level ), path_( path )
267 bool operator< (
const Seed &other )
const
269 const bool ml = (macroIndex() < other.
macroIndex());
270 const bool me = (macroIndex() == other.
macroIndex());
273 const bool pl = (path() < other.
path());
274 return ml | (me & (ll | (le & pl)));
278 bool operator<= (
const Seed &other )
const {
return !(other < *
this); }
279 bool operator> (
const Seed &other )
const {
return (other < *
this); }
280 bool operator>= (
const Seed &other )
const {
return !(*
this < other); }
282 bool isValid ( )
const {
return macroIndex_ != -1; }
285 int level ()
const {
return level_; }
286 unsigned long path ()
const {
return path_; }
301 : instance_( instance )
309 : instance_( null() )
320 instance_ = stack().allocate();
321 instance_->parent() =
null();
322 ++(instance_->parent()->refCount);
326 elInfo().fill_flag = fillFlags;
329 for(
int k = 0; k < maxNeighbors; ++k )
330 elInfo().opp_vertex[ k ] = -1;
332 fill( mesh, ¯oElement, elInfo() );
341 instance_ = stack().allocate();
342 instance_->parent() =
null();
343 ++(instance_->parent()->refCount);
348 elInfo().fill_flag = fillFlags;
351 for(
int k = 0; k < maxNeighbors; ++k )
352 elInfo().opp_vertex[ k ] = -1;
354 fill( mesh, ((
Mesh *)mesh)->macro_els + seed.
macroIndex(), elInfo() );
357 unsigned long path = seed.
path();
358 for(
int i = 0; i < seed.
level(); ++i )
361 child->
parent() = instance_;
364 for(
int k = 0; k < maxNeighbors; ++k )
365 child->
elInfo.opp_vertex[ k ] = -2;
367 fill( path & 1, elInfo(), child->
elInfo );
375 assert( this->seed() == seed );
381 : instance_( other.instance_ )
391 swap( instance_, other.instance_ );
405 other.addReference();
407 instance_ = other.instance_;
416 swap( instance_, other.instance_ );
424 return (instance_->elInfo.el == other.instance_->
elInfo.el);
432 return (instance_->elInfo.el != other.instance_->
elInfo.el);
441 assert( elInfo().macro_el != NULL );
442 return static_cast< const MacroElement &
>( *(elInfo().macro_el) );
457 const Element *element = elInfo().el;
458 const Element *father = elInfo().parent->el;
459 assert( father != NULL );
461 const int index = (father->child[ 0 ] == element ? 0 : 1);
462 assert( father->child[ index ] == element );
473 child->
parent() = instance_;
477 for(
int k = 0; k < maxNeighbors; ++k )
478 child->
elInfo.opp_vertex[ k ] = -2;
480 fill( i, elInfo(), child->
elInfo );
488 assert( !(*
this) ==
false );
489 return isLeaf( el() );
499 unsigned long path = 0;
502 const Element *element = p->elInfo.el;
503 const Element *father = p->parent()->elInfo.el;
504 const unsigned long child =
static_cast< unsigned long >( father->child[ 1 ] == element );
505 path = (path << 1) | child;
509 if( level != elInfo().level )
510 DUNE_THROW( NotImplemented,
"Seed for fake elements not implemented." );
512 return Seed( macroElement().index, level, path );
526 return mightVanish( el(), 0 );
533 return elInfo().level;
547 return instance_->elInfo.el_type;
562 assert( (refCount >= -128) && (refCount < 127) );
563 el()->mark = refCount;
571 assert( (face >= 0) && (face < maxNeighbors) );
574 const int macroFace = elInfo().macro_wall[ face ];
576 return (macroElement().neighbor( macroFace ) != NULL);
585 assert( (face >= 0) && (face < numFaces) );
587 Library< dimWorld >::leafNeighbor( *
this, face, neighbor );
596 assert( (face >= 0) && (face < numFaces) );
597 return Library< dimWorld >::levelNeighbors( *
this, face, neighbor, faceInNeighbor );
602 template<
int codim >
612 assert( neighbor( face ) != NULL );
621 assert( (face >= 0) && (face < maxNeighbors) );
624 const int macroFace = elInfo().macro_wall[ face ];
626 return macroElement().isBoundary( macroFace );
636 assert( (face >= 0) && (face < N_WALLS_MAX) );
639 const int macroFace = elInfo().macro_wall[ face ];
640 const int id = macroElement().boundaryId( macroFace );
652 assert( (face >= 0) && (face < N_WALLS_MAX) );
655 const int macroFace = elInfo().macro_wall[ face ];
656 return (macroFace < 0 ? NULL : macroElement().wall_trafo[ macroFace ]);
665 assert( (face >= 0) && (face < N_WALLS_MAX) );
668 const int macroFace = elInfo().macro_wall[ face ];
685 assert( hasCoordinates() );
687 return elInfo().coord[
vertex ];
692 template<
class Functor >
698 child( 0 ).hierarchicTraverse( functor );
699 child( 1 ).hierarchicTraverse( functor );
705 template<
class Functor >
710 child( 0 ).leafTraverse( functor );
711 child( 1 ).leafTraverse( functor );
728 assert( (face >= 0) && (face < numFaces) );
730 return elInfo().neigh[ face ];
744 return (instance_->elInfo);
751 const Element *element,
int level,
int type )
754 instance->
parent() =
null();
757 instance->
elInfo.mesh = mesh;
758 instance->
elInfo.macro_el = NULL;
760 instance->
elInfo.parent = NULL;
762 instance->
elInfo.level = level;
763 instance->
elInfo.el_type = type;
774 instance->
parent() =
null();
777 instance->
elInfo = elInfo;
785 return IS_LEAF_EL( element );
792 if( isLeaf( element ) )
793 return (element->mark < depth);
795 return (mightVanish( element->child[ 0 ], depth-1 ) && mightVanish( element->child[ 1 ], depth-1 ));
800 inline void ElementInfo< dim >
803 ALBERTA fill_macro_info( mesh, mel, &elInfo );
807 inline void ElementInfo< dim >
808 ::fill (
int ichild,
const ALBERTA EL_INFO &parentInfo,
ALBERTA EL_INFO &elInfo )
810 ALBERTA fill_elinfo( ichild, FILL_ANY, &parentInfo, &elInfo );
815 inline void ElementInfo< dim >::addReference ()
const
817 ++(instance_->refCount);
822 inline void ElementInfo< dim >::removeReference ()
const
828 for( InstancePtr instance = instance_; --(instance->refCount) == 0; )
830 const InstancePtr parent = instance->parent();
831 stack().release( instance );
838 inline typename ElementInfo< dim >::InstancePtr
839 ElementInfo< dim >::null ()
841 return stack().null();
846 inline typename ElementInfo< dim >::Stack &
847 ElementInfo< dim >::stack ()
897 assert( (p !=
null()) && (p->
refCount == 0) );
#define ALBERTA
Definition: albertaheader.hh:27
Include standard header files.
Definition: agrid.hh:59
ALBERTA MESH Mesh
Definition: misc.hh:51
ALBERTA AFF_TRAFO AffineTransformation
Definition: misc.hh:50
ALBERTA EL Element
Definition: misc.hh:52
ALBERTA REAL_D GlobalVector
Definition: misc.hh:48
@ vertex
Definition: common.hh:181
Definition: elementinfo.hh:41
ElementInfo leafNeighbor(const int face) const
Definition: elementinfo.hh:583
bool isLeaf() const
Definition: elementinfo.hh:486
static ElementInfo createFake(const MeshPointer &mesh, const Element *element, int level, int type=0)
Definition: elementinfo.hh:750
ElementInfo child(int i) const
Definition: elementinfo.hh:468
int level() const
Definition: elementinfo.hh:531
bool mightVanish() const
Definition: elementinfo.hh:524
static const int numFaces
Definition: elementinfo.hh:54
int twist(int subEntity) const
Definition: elementinfo.hh:603
int twistInNeighbor(int face) const
Definition: elementinfo.hh:610
Alberta::MacroElement< dimension > MacroElement
Definition: elementinfo.hh:56
BasicNodeProjection * boundaryProjection(int face) const
Definition: elementinfo.hh:662
const MacroElement & macroElement() const
Definition: elementinfo.hh:438
static const int maxLevelNeighbors
Definition: elementinfo.hh:62
ElementInfo father() const
Definition: elementinfo.hh:447
ElementInfo(const ElementInfo &other)
Definition: elementinfo.hh:380
GeometryCacheProxy< dim > GeometryCache
Definition: elementinfo.hh:65
ElementInfo & operator=(const ElementInfo &other)
Definition: elementinfo.hh:403
bool hasLeafNeighbor(const int face) const
Definition: elementinfo.hh:568
bool operator==(const ElementInfo &other) const
Definition: elementinfo.hh:422
static const int dimension
Definition: elementinfo.hh:51
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:693
int type() const
Definition: elementinfo.hh:538
static const int maxNeighbors
Definition: elementinfo.hh:60
void setMark(int refCount) const
Definition: elementinfo.hh:559
~ElementInfo()
Definition: elementinfo.hh:395
const GlobalVector & coordinate(int vertex) const
Definition: elementinfo.hh:683
static const int numVertices
Definition: elementinfo.hh:53
int getMark() const
Definition: elementinfo.hh:552
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:706
Alberta::MeshPointer< dimension > MeshPointer
Definition: elementinfo.hh:57
const Element * neighbor(int face) const
Definition: elementinfo.hh:726
static ElementInfo createFake(const ALBERTA EL_INFO &elInfo)
Definition: elementinfo.hh:771
ElementInfo()
Definition: elementinfo.hh:308
int boundaryId(int face) const
Definition: elementinfo.hh:633
bool operator!=(const ElementInfo &other) const
Definition: elementinfo.hh:430
Alberta::FillFlags< dimension > FillFlags
Definition: elementinfo.hh:58
ElementInfo(const MeshPointer &mesh, const MacroElement ¯oElement, typename FillFlags::Flags fillFlags=FillFlags::standard)
Definition: elementinfo.hh:317
AffineTransformation * transformation(int face) const
Definition: elementinfo.hh:649
bool isBoundary(int face) const
Definition: elementinfo.hh:618
int indexInFather() const
Definition: elementinfo.hh:455
Seed seed() const
Definition: elementinfo.hh:494
Element * el() const
Definition: elementinfo.hh:735
const Element * element() const
Definition: elementinfo.hh:719
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:742
MeshPointer mesh() const
Definition: elementinfo.hh:517
GeometryCache geometryCache() const
Definition: elementinfo.hh:138
bool hasCoordinates() const
Definition: elementinfo.hh:677
int levelNeighbors(const int face, ElementInfo(&neighbor)[maxLevelNeighbors], int(&faceInNeighbor)[maxLevelNeighbors]) const
Definition: elementinfo.hh:594
ElementInfo(ElementInfo &&other)
Definition: elementinfo.hh:387
ElementInfo(const MeshPointer &mesh, const Seed &seed, typename FillFlags::Flags fillFlags=FillFlags::standard)
Definition: elementinfo.hh:338
Definition: elementinfo.hh:183
Alberta::GeometryCache< dim > geometryCache
Definition: elementinfo.hh:197
ALBERTA EL_INFO elInfo
Definition: elementinfo.hh:184
InstancePtr & parent()
Definition: elementinfo.hh:187
unsigned int refCount
Definition: elementinfo.hh:185
Definition: elementinfo.hh:208
InstancePtr null()
Definition: elementinfo.hh:905
~Stack()
Definition: elementinfo.hh:869
void release(InstancePtr &p)
Definition: elementinfo.hh:895
Stack()
Definition: elementinfo.hh:859
InstancePtr allocate()
Definition: elementinfo.hh:882
Definition: elementinfo.hh:253
Seed(const int macroIndex, const int level, const unsigned long path)
Definition: elementinfo.hh:258
Seed()
Definition: elementinfo.hh:254
int level() const
Definition: elementinfo.hh:285
bool isValid() const
Definition: elementinfo.hh:282
unsigned long path() const
Definition: elementinfo.hh:286
int macroIndex() const
Definition: elementinfo.hh:284
Definition: geometrycache.hh:22
Definition: geometrycache.hh:89
Definition: macroelement.hh:22
static const Flags nothing
Definition: misc.hh:232
static const Flags boundaryId
Definition: misc.hh:244
ALBERTA FLAGS Flags
Definition: misc.hh:230
static const Flags coords
Definition: misc.hh:234
static const Flags standard
Definition: misc.hh:254
static const Flags neighbor
Definition: misc.hh:236
static int twist(const Element *element, int subEntity)
Definition: misc.hh:536
Definition: albertagrid/projection.hh:206