3#ifndef DUNE_ALU3DGRIDENTITY_HH
4#define DUNE_ALU3DGRIDENTITY_HH
9#include <dune/grid/common/entity.hh>
13#include "alu3dinclude.hh"
15#include "entityseed.hh"
21 template<
int cd,
int dim,
class Gr
idImp>
22 class ALU3dGridEntity;
23 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp >
24 class ALU3dGridLevelIterator;
25 template<
int cd,
class Gr
idImp >
26 class ALU3dGridEntityPointer;
27 template<
int mydim,
int coorddim,
class Gr
idImp>
28 class ALU3dGridGeometry;
29 template<
class Gr
idImp>
30 class ALU3dGridHierarchicIterator;
31 template<
class Gr
idImp>
32 class ALU3dGridIntersectionIterator;
33 template<
int codim, PartitionIteratorType,
class Gr
idImp>
34 class ALU3dGridLeafIterator;
35 template< ALU3dGr
idElementType,
class >
44 template<
int cd,
int dim,
class Gr
idImp>
49 template <
class Gr
idType,
int cdim>
52 template <
class ItemType>
53 static int getLevel(
const GridType &
grid,
const ItemType & item )
62 template <
class Gr
idType>
63 struct GetLevel<GridType,3>
65 template <
class ItemType>
66 static int getLevel(
const GridType &
grid,
const ItemType & item)
68 return (item.isLeafEntity()) ?
grid.getLevelOfLeafVertex(item) : item.level();
72 enum { dimworld = GridImp::dimensionworld };
74 typedef typename GridImp::MPICommunicatorType Comm;
76 friend class ALU3dGrid< GridImp::elementType, Comm >;
82 template< class > friend class ALU3dGridFactory;
84 typedef typename GridImp::Traits::template
Codim< cd >::GeometryImpl GeometryImpl;
87 typedef typename GridImp::GridObjectFactoryType FactoryType;
89 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
91 typedef typename ImplTraits::template
Codim<cd>::ImplementationType ItemType;
92 typedef typename ImplTraits::VertexType VertexType;
93 typedef typename ImplTraits::HBndSegType HBndSegType;
95 typedef typename GridImp::template
Codim<cd>::Entity Entity;
96 typedef typename GridImp::template
Codim<cd>::Geometry Geometry;
98 typedef typename GridImp::template
Codim<0>::EntityPointer EntityPointer;
122 void setElement(const HItemType & item);
123 void setElement(const HItemType & item, const int level, int twist=0, int face = -1);
126 void setElement(const EntitySeed& seed);
135 void
reset ( int l );
138 bool
equals ( const ALU3dGridEntity<cd,dim,GridImp> & org ) const;
141 void
setEntity ( const ALU3dGridEntity<cd,dim,GridImp> & org );
144 const ItemType & getItem () const {
return *item_; }
147 const GridImp&
grid()
const {
return factory_.grid(); }
150 const FactoryType&
factory()
const {
return factory_; }
160 int getIndex ()
const;
166 mutable GeometryImpl geo_;
169 const FactoryType& factory_;
172 const ItemType * item_;
201 template<
int dim,
class Gr
idImp>
205 static const int dimworld = remove_const< GridImp >::type::dimensionworld;
206 static const ALU3dGridElementType elementType = remove_const< GridImp >::type::elementType;
208 typedef typename GridImp::MPICommunicatorType Comm;
210 typedef ALU3dImplTraits< elementType, Comm > ImplTraits;
213 typedef typename ImplTraits::GEOElementType GEOElementType;
214 typedef typename ImplTraits::BNDFaceType BNDFaceType;
215 typedef typename ImplTraits::IMPLElementType IMPLElementType;
216 typedef typename ImplTraits::HBndSegType HBndSegType;
218 enum { refine_element_t = ImplTraits::refine_element_t };
219 enum { bisect_element_t = ImplTraits::bisect_element_t };
220 enum { coarse_element_t = ImplTraits::coarse_element_t };
221 enum { nosplit_element_t = ImplTraits::nosplit_element_t };
223 typedef typename ImplTraits::MarkRuleType MarkRuleType;
225 friend class ALU3dGrid< elementType, Comm >;
228 friend class ALU3dGridHierarchicIterator < const GridImp >;
229 friend class ALU3dGridHierarchicIterator < GridImp >;
241 template<
class >
friend class ALU3dGridFactory;
244 typedef typename GridImp :: ReferenceElementType ReferenceElementType;
250 typedef typename GridImp::GridObjectFactoryType FactoryType;
293 template<
int cc>
int count ()
const ;
298 unsigned int subEntities (
unsigned int codim)
const ;
302 template<
int codim >
303 typename Codim< codim >::EntityPointer
subEntity (
int i )
const;
326 bool isLeaf ()
const;
334 return (this->
level()>0);
352 ALU3dGridHierarchicIterator<GridImp> hbegin (
int maxlevel)
const;
355 ALU3dGridHierarchicIterator<GridImp> hend (
int maxlevel)
const;
365 bool mightVanish ()
const;
374 bool mark(
int refCount )
const;
382 void setElement(HElementType &element);
391 void reset (
int l );
412 const IMPLElementType& getItem ()
const {
return *item_; }
415 const BNDFaceType& getGhost ()
const
422 const GridImp&
grid()
const {
return factory_.grid(); }
425 const FactoryType&
factory()
const {
return factory_; }
428 bool isGhost ()
const {
return ImplTraits::isGhost( ghost_ ); }
441 int getIndex ()
const;
444 mutable GeometryImpl geo_;
447 const FactoryType& factory_;
450 mutable IMPLElementType* item_;
453 mutable BNDFaceType* ghost_;
467 template<
int codim,
class Gr
idImp >
471 enum { dim = GridImp::dimension };
472 enum { dimworld = GridImp::dimensionworld };
474 typedef typename GridImp::MPICommunicatorType Comm;
478 friend class ALU3dGrid < GridImp::elementType, Comm >;
480 typedef ALU3dImplTraits<GridImp::elementType, Comm > ImplTraits;
483 typedef typename ImplTraits::HBndSegType HBndSegType;
484 typedef typename ImplTraits::BNDFaceType BNDFaceType;
486 typedef typename GridImp::GridObjectFactoryType FactoryType;
488 enum { codimension = codim };
494 typedef typename EntityObject :: ImplementationType EntityImp;
507 const HElementType & item);
511 const HElementType & item,
519 const HBndSegType & ghostFace );
557 const GridImp&
grid ()
const {
return factory_.grid(); }
564 void updateGhostPointer( HBndSegType & ghostFace );
566 void updateEntityPointer( HElementType * item ,
int level = -1 );
569 const FactoryType& factory_;
578 EntityImp & entityImp ()
const {
580 return GridImp :: getRealImplementation(*entity_);
587 template<
class Gr
idImp>
588 class ALU3dGridEntityPointer<0,GridImp> :
595 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
596 enum { dim = GridImp::dimension };
597 enum { dimworld = GridImp::dimensionworld };
599 typedef typename GridImp::MPICommunicatorType Comm;
603 friend class ALU3dGrid < GridImp::elementType, Comm >;
605 typedef ALU3dImplTraits<GridImp::elementType, Comm > ImplTraits;
608 typedef typename ImplTraits::HBndSegType HBndSegType;
609 typedef typename ImplTraits::BNDFaceType BNDFaceType;
618 typedef typename GridImp::GridObjectFactoryType FactoryType;
630 ALU3dGridEntityPointer(const FactoryType& factory,
631 const HElementType & item)
636 const HBndSegType & ghostFace )
646 assert( entity_ == 0 );
647 entity_ = factory_.template getNewEntity<0> ();
649 entityImp().setGhost( *seed.ghost() );
661 assert( entity_ == 0 );
662 entity_ = factory_.template getNewEntity<0> ();
664 entityImp().setEntity( entity );
681 template<
int cd,
class Gr
idImp>
682 class ALU3dGridEntityPointer :
683 public ALU3dGridEntityPointerBase<cd,GridImp>
686 typedef ALU3dGridEntityPointerBase<cd,GridImp> BaseType ;
687 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
688 enum { dim = GridImp::dimension };
689 enum { dimworld = GridImp::dimensionworld };
691 typedef typename GridImp::MPICommunicatorType Comm;
693 friend class ALU3dGridEntity<cd,dim,GridImp>;
694 friend class ALU3dGridEntity< 0,dim,GridImp>;
695 friend class ALU3dGrid < GridImp::elementType, Comm >;
697 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
698 typedef typename ImplTraits::template Codim<cd>
::InterfaceType HElementType;
700 typedef typename ImplTraits::HBndSegType HBndSegType;
701 typedef typename ImplTraits::BNDFaceType BNDFaceType;
702 typedef ALU3dGridEntity<cd,dim,GridImp> ALU3dGridEntityType;
704 using BaseType :: seed_;
705 using BaseType :: entity_;
706 using BaseType :: entityImp;
707 using BaseType :: factory_;
708 using BaseType :: getEntity;
711 typedef typename GridImp::GridObjectFactoryType FactoryType;
714 typedef ALU3dGridEntitySeed<cd, GridImp> ALU3dGridEntitySeedType;
717 typedef typename GridImp::template Codim<cd>::Entity Entity;
720 typedef ALU3dGridEntityPointer<cd,GridImp> ALU3dGridEntityPointerType;
723 static const int defaultValue = -665;
727 ALU3dGridEntityPointer(const FactoryType& factory,
729 const HElementType & item,
730 const int twist = defaultValue,
731 const int duneFace = defaultValue
735 ALU3dGridEntityPointer(const ALU3dGridEntityType& entity)
741 ALU3dGridEntityPointer(
const FactoryType& factory,
const ALU3dGridEntitySeedType& seed)
746 ALU3dGridEntityPointer(
const ALU3dGridEntityPointerType & org);
749 Entity & dereference ()
const ;
752 ThisType & operator = (
const ThisType & org);
759 void clone (
const ALU3dGridEntityPointerType & org);
761 void updateEntityPointer( HElementType * item ,
int level );
765 ALU3dGridEntityPointer(
const FactoryType& factory,
int level )
772#include "entity_inline.hh"
774#if COMPILE_ALUGRID_INLINE
775 #include "entity_imp.cc"
Definition: entity.hh:469
GridImp::template Codim< codimension >::Entity Entity
type of Entity
Definition: entity.hh:491
void freeEntity()
put entity to entity stack
Definition: entity_inline.hh:446
~ALU3dGridEntityPointerBase()
Destructor.
Definition: entity_inline.hh:432
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:497
int level() const
ask for level of entities
Definition: entity_inline.hh:481
ALU3dGridEntityPointerBase(const FactoryType &factory, const HElementType &item)
Constructor for EntityPointer that points to an element.
Definition: entity_inline.hh:299
bool equals(const ALU3dGridEntityPointerType &i) const
equality
Definition: entity_inline.hh:459
ALU3dGridEntitySeed< codimension, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:503
const GridImp & grid() const
return reference to grid
Definition: entity.hh:557
ALU3dGridEntityPointer< codimension, GridImp > EntityPointerImp
make type of entity pointer implementation available in derived classes
Definition: entity.hh:500
Entity & dereference() const
dereferencing
Definition: entity_inline.hh:467
ThisType & operator=(const ThisType &org)
assignment operator
Definition: entity_inline.hh:381
void done()
has to be called when iterator is finished
Definition: entity_inline.hh:438
MakeableInterfaceObject< Entity > EntityObject
underlying EntityImplementation
Definition: entity.hh:493
ALU3dGridEntityPointer(const ALU3dGridEntityPointerType &org)
copy constructor
Definition: entity.hh:669
GridImp::template Codim< cd >::Entity Entity
type of Entity
Definition: entity.hh:624
ALU3dGridEntityPointer(const ALU3dGridEntityType &entity)
Constructor for EntityPointer that points to an entity (interior or ghost)
Definition: entity.hh:654
ALU3dGridEntitySeed< cd, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:621
ALU3dGridEntityPointer(const FactoryType &factory, const HBndSegType &ghostFace)
Constructor for EntityPointer that points to an ghost.
Definition: entity.hh:635
ALU3dGridEntityPointer(const FactoryType &factory, int level)
Definition: entity.hh:676
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:627
ALU3dGridEntityPointer(const FactoryType &factory, const ALU3dGridEntitySeedType &seed)
Constructor for EntityPointer that points to given entity.
Definition: entity.hh:640
Definition: entity.hh:204
Codim< codim >::EntityPointer subEntity(int i) const
bool hasBoundaryIntersections() const
returns true, if entity has intersections with boundary
const FactoryType & factory() const
return reference to factory
Definition: entity.hh:425
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:332
EntityPointer father() const
GridImp::template Codim< 0 >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:270
Geometry geometry() const
geometry of this entity
ALU3dGridEntity(const FactoryType &factory, int level)
Constructor creating empty Entity.
int getMark() const
return current adaptation mark for this entity
ALU3dGridEntity(const ALU3dGridEntity &org)
copy Constructor
int subIndex(int i, unsigned int codim) const
int getSubIndex(int i) const
EntitySeed seed() const
return key for this entity
Definition: entity.hh:431
bool mark(int refCount) const
bool isGhost() const
returns true if entity is ghost
Definition: entity.hh:428
const GridImp & grid() const
return reference to grid
Definition: entity.hh:422
LocalGeometry geometryInFather() const
GeometryType type() const
type of geometry of this entity
Definition: entity_inline.hh:56
void setEntity(const ALU3dGridEntity< cd, dim, GridImp > &org)
set item from other entity, mainly for copy constructor of entity pointer
void removeElement()
reset item pointer to NULL
Definition: entity_inline.hh:22
int level() const
level of this element
Definition: entity_inline.hh:42
PartitionType partitionType() const
return partition type of this entity ( see grid.hh )
Definition: entity_inline.hh:49
void setGhost(const HBndSegType &ghost)
setGhost is not valid for this codim
const GridImp & grid() const
return reference to grid
Definition: entity.hh:147
GridImp::template Codim< cd >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:101
void reset(int l)
reset item pointer to NULL
Definition: entity_inline.hh:12
Geometry geometry() const
geometry of this entity
EntitySeed seed() const
return seed of entity
Definition: entity.hh:153
const FactoryType & factory() const
return reference to factory
Definition: entity.hh:150
bool equals(const ALU3dGridEntity< cd, dim, GridImp > &org) const
compare 2 elements by comparing the item pointers
Definition: entity_inline.hh:30
hierarchic index set of ALU3dGrid
Definition: indexsets.hh:44
Definition: iterator.hh:57
Leaf iterator.
Definition: iterator.hh:585
Definition: iterator.hh:504
[ provides Dune::Grid ]
Definition: grid.hh:406
Default Implementations for EntityImp.
Definition: entity.hh:740
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:233
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:328
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignment.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22