5#ifndef DUNE_ALBERTA_ELEMENTINFO_HH
6#define DUNE_ALBERTA_ELEMENTINFO_HH
34 struct BasicNodeProjection;
66#if !DUNE_ALBERTA_CACHE_COORDINATES
89 explicit operator bool ()
const {
return (instance_ != null()); }
129 template<
int codim >
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
218 InstancePtr allocate ();
219 void release ( InstancePtr &p );
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 )
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 );
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;
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) );
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) );
626 const int macroFace = elInfo().macro_wall[ face ];
628 return macroElement().isBoundary( macroFace );
638 assert( (face >= 0) && (face < N_WALLS_MAX) );
641 const int macroFace = elInfo().macro_wall[ face ];
642 const int id = macroElement().boundaryId( macroFace );
654 assert( (face >= 0) && (face < N_WALLS_MAX) );
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) );
670 const int macroFace = elInfo().macro_wall[ face ];
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 >
712 child( 0 ).leafTraverse( functor );
713 child( 1 ).leafTraverse( functor );
730 assert( (face >= 0) && (face < numFaces) );
732 return elInfo().neigh[ face ];
746 return (instance_->elInfo);
753 const Element *element,
int level,
int type )
756 instance->
parent() = null();
759 instance->
elInfo.mesh = mesh;
760 instance->
elInfo.macro_el = NULL;
762 instance->
elInfo.parent = NULL;
764 instance->
elInfo.level = level;
765 instance->
elInfo.el_type = type;
776 instance->
parent() = null();
779 instance->
elInfo = elInfo;
787 return IS_LEAF_EL( element );
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) );
#define ALBERTA
Definition: albertaheader.hh:29
void swap(Dune::PersistentContainer< G, T > &a, Dune::PersistentContainer< G, T > &b)
Definition: utility/persistentcontainer.hh:83
Include standard header files.
Definition: agrid.hh:60
ALBERTA MESH Mesh
Definition: misc.hh:53
ALBERTA AFF_TRAFO AffineTransformation
Definition: misc.hh:52
ALBERTA EL Element
Definition: misc.hh:54
ALBERTA REAL_D GlobalVector
Definition: misc.hh:50
@ vertex
Definition: common.hh:133
Definition: elementinfo.hh:43
ElementInfo leafNeighbor(const int face) const
Definition: elementinfo.hh:585
bool isLeaf() const
Definition: elementinfo.hh:488
static ElementInfo createFake(const MeshPointer &mesh, const Element *element, int level, int type=0)
Definition: elementinfo.hh:752
ElementInfo child(int i) const
Definition: elementinfo.hh:470
int level() const
Definition: elementinfo.hh:533
bool mightVanish() const
Definition: elementinfo.hh:526
static const int numFaces
Definition: elementinfo.hh:56
int twist(int subEntity) const
Definition: elementinfo.hh:605
int twistInNeighbor(int face) const
Definition: elementinfo.hh:612
Alberta::MacroElement< dimension > MacroElement
Definition: elementinfo.hh:58
BasicNodeProjection * boundaryProjection(int face) const
Definition: elementinfo.hh:664
const MacroElement & macroElement() const
Definition: elementinfo.hh:440
static const int maxLevelNeighbors
Definition: elementinfo.hh:64
ElementInfo father() const
Definition: elementinfo.hh:449
ElementInfo(const ElementInfo &other)
Definition: elementinfo.hh:382
GeometryCacheProxy< dim > GeometryCache
Definition: elementinfo.hh:67
ElementInfo & operator=(const ElementInfo &other)
Definition: elementinfo.hh:405
bool hasLeafNeighbor(const int face) const
Definition: elementinfo.hh:570
bool operator==(const ElementInfo &other) const
Definition: elementinfo.hh:424
static const int dimension
Definition: elementinfo.hh:53
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:695
int type() const
Definition: elementinfo.hh:540
static const int maxNeighbors
Definition: elementinfo.hh:62
void setMark(int refCount) const
Definition: elementinfo.hh:561
~ElementInfo()
Definition: elementinfo.hh:397
const GlobalVector & coordinate(int vertex) const
Definition: elementinfo.hh:685
static const int numVertices
Definition: elementinfo.hh:55
int getMark() const
Definition: elementinfo.hh:554
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:708
Alberta::MeshPointer< dimension > MeshPointer
Definition: elementinfo.hh:59
const Element * neighbor(int face) const
Definition: elementinfo.hh:728
static ElementInfo createFake(const ALBERTA EL_INFO &elInfo)
Definition: elementinfo.hh:773
ElementInfo()
Definition: elementinfo.hh:310
int boundaryId(int face) const
Definition: elementinfo.hh:635
bool operator!=(const ElementInfo &other) const
Definition: elementinfo.hh:432
Alberta::FillFlags< dimension > FillFlags
Definition: elementinfo.hh:60
ElementInfo(const MeshPointer &mesh, const MacroElement ¯oElement, typename FillFlags::Flags fillFlags=FillFlags::standard)
Definition: elementinfo.hh:319
AffineTransformation * transformation(int face) const
Definition: elementinfo.hh:651
bool isBoundary(int face) const
Definition: elementinfo.hh:620
int indexInFather() const
Definition: elementinfo.hh:457
Seed seed() const
Definition: elementinfo.hh:496
Element * el() const
Definition: elementinfo.hh:737
const Element * element() const
Definition: elementinfo.hh:721
ALBERTA EL_INFO & elInfo() const
Definition: elementinfo.hh:744
MeshPointer mesh() const
Definition: elementinfo.hh:519
GeometryCache geometryCache() const
Definition: elementinfo.hh:140
bool hasCoordinates() const
Definition: elementinfo.hh:679
int levelNeighbors(const int face, ElementInfo(&neighbor)[maxLevelNeighbors], int(&faceInNeighbor)[maxLevelNeighbors]) const
Definition: elementinfo.hh:596
ElementInfo(ElementInfo &&other)
Definition: elementinfo.hh:389
ElementInfo(const MeshPointer &mesh, const Seed &seed, typename FillFlags::Flags fillFlags=FillFlags::standard)
Definition: elementinfo.hh:340
Definition: elementinfo.hh:185
InstancePtr & parent()
Definition: elementinfo.hh:189
Alberta::GeometryCache< dim > geometryCache
Definition: elementinfo.hh:199
ALBERTA EL_INFO elInfo
Definition: elementinfo.hh:186
unsigned int refCount
Definition: elementinfo.hh:187
Definition: elementinfo.hh:210
InstancePtr null()
Definition: elementinfo.hh:907
~Stack()
Definition: elementinfo.hh:871
void release(InstancePtr &p)
Definition: elementinfo.hh:897
Stack()
Definition: elementinfo.hh:861
InstancePtr allocate()
Definition: elementinfo.hh:884
Definition: elementinfo.hh:255
Seed(const int macroIndex, const int level, const unsigned long path)
Definition: elementinfo.hh:260
Seed()
Definition: elementinfo.hh:256
int level() const
Definition: elementinfo.hh:287
bool isValid() const
Definition: elementinfo.hh:284
unsigned long path() const
Definition: elementinfo.hh:288
int macroIndex() const
Definition: elementinfo.hh:286
Definition: geometrycache.hh:24
Definition: geometrycache.hh:91
Definition: macroelement.hh:24
static const Flags nothing
Definition: misc.hh:234
static const Flags boundaryId
Definition: misc.hh:246
ALBERTA FLAGS Flags
Definition: misc.hh:232
static const Flags coords
Definition: misc.hh:236
static const Flags standard
Definition: misc.hh:256
static const Flags neighbor
Definition: misc.hh:238
static int twist(const Element *element, int subEntity)
Definition: misc.hh:538
Definition: albertagrid/projection.hh:208