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;
90 typedef typename ImplTraits::template Codim<cd>
::InterfaceType HItemType;
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>
208 typedef typename GridImp::MPICommunicatorType Comm;
210 typedef ALU3dImplTraits< elementType, Comm > ImplTraits;
211 typedef typename ImplTraits::template Codim<0>::InterfaceType HElementType;
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;
246 typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
247 typedef typename GridImp::Traits::template Codim< 0 >::LocalGeometryImpl LocalGeometryImpl;
250 typedef typename GridImp::GridObjectFactoryType FactoryType;
252 typedef typename GridImp::template Codim< 0 >::Geometry Geometry;
253 typedef typename GridImp::template Codim< 0 >::LocalGeometry LocalGeometry;
260 typedef typename GridImp::template Codim<0>::Entity Entity;
261 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
266 typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
270 typedef typename GridImp::template Codim<0>::EntitySeed
EntitySeed;
293 template<
int cc>
int count ()
const ;
297 template<
int codim >
298 typename Codim< codim >::EntityPointer
subEntity (
int i )
const;
321 bool isLeaf ()
const;
329 return (this->
level()>0);
347 ALU3dGridHierarchicIterator<GridImp> hbegin (
int maxlevel)
const;
350 ALU3dGridHierarchicIterator<GridImp> hend (
int maxlevel)
const;
360 bool mightVanish ()
const;
369 bool mark(
int refCount )
const;
377 void setElement(HElementType &element);
386 void reset (
int l );
407 const IMPLElementType& getItem ()
const {
return *item_; }
410 const BNDFaceType& getGhost ()
const
417 const GridImp&
grid()
const {
return factory_.grid(); }
420 const FactoryType&
factory()
const {
return factory_; }
423 bool isGhost ()
const {
return ImplTraits::isGhost( ghost_ ); }
436 int getIndex ()
const;
439 mutable GeometryImpl geo_;
442 const FactoryType& factory_;
445 mutable IMPLElementType* item_;
448 mutable BNDFaceType* ghost_;
462 template<
int codim,
class Gr
idImp >
466 enum { dim = GridImp::dimension };
467 enum { dimworld = GridImp::dimensionworld };
469 typedef typename GridImp::MPICommunicatorType Comm;
473 friend class ALU3dGrid < GridImp::elementType, Comm >;
475 typedef ALU3dImplTraits<GridImp::elementType, Comm > ImplTraits;
476 typedef typename ImplTraits::template Codim<codim>
::InterfaceType HElementType;
478 typedef typename ImplTraits::HBndSegType HBndSegType;
479 typedef typename ImplTraits::BNDFaceType BNDFaceType;
481 typedef typename GridImp::GridObjectFactoryType FactoryType;
483 enum { codimension = codim };
486 typedef typename GridImp::template Codim<codimension>::Entity
Entity;
489 typedef typename EntityObject :: ImplementationType EntityImp;
502 const HElementType & item);
506 const HElementType & item,
514 const HBndSegType & ghostFace );
552 const GridImp&
grid ()
const {
return factory_.grid(); }
559 void updateGhostPointer( HBndSegType & ghostFace );
561 void updateEntityPointer( HElementType * item ,
int level = -1 );
564 const FactoryType& factory_;
573 EntityImp & entityImp ()
const {
575 return GridImp :: getRealImplementation(*entity_);
582 template<
class Gr
idImp>
583 class ALU3dGridEntityPointer<0,GridImp> :
590 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
591 enum { dim = GridImp::dimension };
592 enum { dimworld = GridImp::dimensionworld };
594 typedef typename GridImp::MPICommunicatorType Comm;
598 friend class ALU3dGrid < GridImp::elementType, Comm >;
600 typedef ALU3dImplTraits<GridImp::elementType, Comm > ImplTraits;
601 typedef typename ImplTraits::template Codim<cd>
::InterfaceType HElementType;
603 typedef typename ImplTraits::HBndSegType HBndSegType;
604 typedef typename ImplTraits::BNDFaceType BNDFaceType;
613 typedef typename GridImp::GridObjectFactoryType FactoryType;
619 typedef typename GridImp::template Codim<cd>::Entity
Entity;
625 ALU3dGridEntityPointer(const FactoryType& factory,
626 const HElementType & item)
631 const HBndSegType & ghostFace )
641 assert( entity_ == 0 );
642 entity_ = factory_.template getNewEntity<0> ();
644 entityImp().setGhost( *seed.ghost() );
656 assert( entity_ == 0 );
657 entity_ = factory_.template getNewEntity<0> ();
659 entityImp().setEntity( entity );
676 template<
int cd,
class Gr
idImp>
677 class ALU3dGridEntityPointer :
678 public ALU3dGridEntityPointerBase<cd,GridImp>
681 typedef ALU3dGridEntityPointerBase<cd,GridImp> BaseType ;
682 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
683 enum { dim = GridImp::dimension };
684 enum { dimworld = GridImp::dimensionworld };
686 typedef typename GridImp::MPICommunicatorType Comm;
688 friend class ALU3dGridEntity<cd,dim,GridImp>;
689 friend class ALU3dGridEntity< 0,dim,GridImp>;
690 friend class ALU3dGrid < GridImp::elementType, Comm >;
692 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
693 typedef typename ImplTraits::template Codim<cd>
::InterfaceType HElementType;
695 typedef typename ImplTraits::HBndSegType HBndSegType;
696 typedef typename ImplTraits::BNDFaceType BNDFaceType;
697 typedef ALU3dGridEntity<cd,dim,GridImp> ALU3dGridEntityType;
699 using BaseType :: seed_;
700 using BaseType :: entity_;
701 using BaseType :: entityImp;
702 using BaseType :: factory_;
703 using BaseType :: getEntity;
706 typedef typename GridImp::GridObjectFactoryType FactoryType;
709 typedef ALU3dGridEntitySeed<cd, GridImp> ALU3dGridEntitySeedType;
712 typedef typename GridImp::template Codim<cd>::Entity Entity;
715 typedef ALU3dGridEntityPointer<cd,GridImp> ALU3dGridEntityPointerType;
718 static const int defaultValue = -665;
722 ALU3dGridEntityPointer(const FactoryType& factory,
724 const HElementType & item,
725 const int twist = defaultValue,
726 const int duneFace = defaultValue
730 ALU3dGridEntityPointer(const ALU3dGridEntityType& entity)
736 ALU3dGridEntityPointer(
const FactoryType& factory,
const ALU3dGridEntitySeedType& seed)
741 ALU3dGridEntityPointer(
const ALU3dGridEntityPointerType & org);
744 Entity & dereference ()
const ;
747 ThisType & operator = (
const ThisType & org);
754 void clone (
const ALU3dGridEntityPointerType & org);
756 void updateEntityPointer( HElementType * item ,
int level );
760 ALU3dGridEntityPointer(
const FactoryType& factory,
int level )
767#include "entity_inline.hh"
769#if COMPILE_ALUGRID_INLINE
770 #include "entity_imp.cc"
Definition: entity.hh:464
GridImp::template Codim< codimension >::Entity Entity
type of Entity
Definition: entity.hh:486
void freeEntity()
put entity to entity stack
Definition: entity_inline.hh:440
~ALU3dGridEntityPointerBase()
Destructor.
Definition: entity_inline.hh:426
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:492
int level() const
ask for level of entities
Definition: entity_inline.hh:475
ALU3dGridEntityPointerBase(const FactoryType &factory, const HElementType &item)
Constructor for EntityPointer that points to an element.
Definition: entity_inline.hh:293
bool equals(const ALU3dGridEntityPointerType &i) const
equality
Definition: entity_inline.hh:453
ALU3dGridEntitySeed< codimension, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:498
const GridImp & grid() const
return reference to grid
Definition: entity.hh:552
ALU3dGridEntityPointer< codimension, GridImp > EntityPointerImp
make type of entity pointer implementation available in derived classes
Definition: entity.hh:495
Entity & dereference() const
dereferencing
Definition: entity_inline.hh:461
ThisType & operator=(const ThisType &org)
assignment operator
Definition: entity_inline.hh:375
void done()
has to be called when iterator is finished
Definition: entity_inline.hh:432
MakeableInterfaceObject< Entity > EntityObject
underlying EntityImplementation
Definition: entity.hh:488
ALU3dGridEntityPointer(const ALU3dGridEntityPointerType &org)
copy constructor
Definition: entity.hh:664
GridImp::template Codim< cd >::Entity Entity
type of Entity
Definition: entity.hh:619
ALU3dGridEntityPointer(const ALU3dGridEntityType &entity)
Constructor for EntityPointer that points to an entity (interior or ghost)
Definition: entity.hh:649
ALU3dGridEntitySeed< cd, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:616
ALU3dGridEntityPointer(const FactoryType &factory, const HBndSegType &ghostFace)
Constructor for EntityPointer that points to an ghost.
Definition: entity.hh:630
ALU3dGridEntityPointer(const FactoryType &factory, int level)
Definition: entity.hh:671
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:622
ALU3dGridEntityPointer(const FactoryType &factory, const ALU3dGridEntitySeedType &seed)
Constructor for EntityPointer that points to given entity.
Definition: entity.hh:635
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:420
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:327
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:426
bool mark(int refCount) const
bool isGhost() const
returns true if entity is ghost
Definition: entity.hh:423
const GridImp & grid() const
return reference to grid
Definition: entity.hh:417
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:591
Definition: iterator.hh:510
[ provides Dune::Grid ]
Definition: grid.hh:406
Default Implementations for EntityImp.
Definition: entity.hh:553
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:239
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:334
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignment.hh:14
@ All_Partition
all entities
Definition: gridenums.hh:135
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
Removes a const qualifier while preserving others.
Definition: typetraits.hh:176