1#ifndef DUNE_ALU3DGRIDENTITY_HH
2#define DUNE_ALU3DGRIDENTITY_HH
8#include <dune/grid/common/entity.hh>
10#include <dune/alugrid/common/twists.hh>
13#include "alu3dinclude.hh"
14#include "indexsets.hh"
22 template<
int cd,
int dim,
class Gr
idImp>
23 class ALU3dGridEntity;
24 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp >
25 class ALU3dGridLevelIterator;
26 template<
int cd,
class Gr
idImp >
27 class ALU3dGridEntityPointer;
28 template<
int mydim,
int coorddim,
class Gr
idImp>
29 class ALU3dGridGeometry;
30 template<
class Gr
idImp>
31 class ALU3dGridHierarchicIterator;
32 template<
class Gr
idImp>
33 class ALU3dGridIntersectionIterator;
34 template<
int codim, PartitionIteratorType,
class Gr
idImp>
35 class ALU3dGridLeafIterator;
36 template<
int dim,
int dimworld, ALU3dGr
idElementType,
class >
45template<
int cd,
int dim,
class Gr
idImp>
50 template <
class Gr
idType,
int dm,
int cdim>
53 template <
class ItemType>
54 static int getLevel(
const GridType & grid,
const ItemType & item )
63 template <
class Gr
idType>
64 struct GetLevel<GridType,dim,dim>
66 template <
class ItemType>
67 static int getLevel(
const GridType & grid,
const ItemType & item)
69 return (item.isLeafEntity()) ? grid.getLevelOfLeafVertex(item) : item.level();
73 enum { dimworld = GridImp::dimensionworld };
75 typedef typename GridImp::MPICommunicatorType Comm;
77 friend class ALU3dGrid< GridImp::
dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
85 typedef typename GridImp::Traits::template
Codim< cd >::GeometryImpl GeometryImpl;
88 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
90 typedef typename ImplTraits::template
Codim<dim, cd>::ImplementationType ItemType;
91 typedef typename ImplTraits::VertexType VertexType;
92 typedef typename ImplTraits::HBndSegType HBndSegType;
94 typedef typename GridImp::template
Codim<cd>::Entity Entity;
95 typedef typename GridImp::template
Codim<cd>::Geometry Geometry;
113 void setElement(
const HItemType & item);
114 void setElement(
const HItemType & item,
const GridImp& grid );
115 void setElement(
const HItemType & item,
const int level,
int twist=0);
121 void setGhost(
const HBndSegType &ghost);
139 int subIndex (
int i,
unsigned int codim )
const
145 const ItemType& getItem ()
const {
return *(
static_cast<ItemType *
> (
seed_.item())); }
158 int getIndex ()
const {
return getItem().getIndex(); }
189template<
int dim,
class Gr
idImp>
193 static const int dimworld = std::remove_const< GridImp >::type::dimensionworld;
194 static const ALU3dGridElementType elementType = std::remove_const< GridImp >::type::elementType;
196 typedef typename GridImp::MPICommunicatorType Comm;
198 typedef ALU3dImplTraits< elementType, Comm > ImplTraits;
201 typedef typename ImplTraits::GEOElementType GEOElementType;
202 typedef typename ImplTraits::BNDFaceType BNDFaceType;
203 typedef typename ImplTraits::IMPLElementType IMPLElementType;
204 typedef typename ImplTraits::HBndSegType HBndSegType;
206 enum { refine_element_t = ImplTraits::RefinementRules::refine_element_t };
207 enum { bisect_element_t = ImplTraits::RefinementRules::bisect_element_t };
208 enum { coarse_element_t = ImplTraits::RefinementRules::coarse_element_t };
209 enum { nosplit_element_t = ImplTraits::RefinementRules::nosplit_element_t };
211 typedef typename ImplTraits::MarkRuleType MarkRuleType;
213 friend class ALU3dGrid< GridImp::
dimension, GridImp::dimensionworld, elementType, Comm >;
216 friend class ALU3dGridHierarchicIterator < const GridImp >;
217 friend class ALU3dGridHierarchicIterator < GridImp >;
232 typedef typename GridImp :: ReferenceElementType ReferenceElementType;
234 typedef typename GridImp::Traits::template
Codim< 0 >::GeometryImpl GeometryImpl;
235 typedef typename GridImp::Traits::template
Codim< 0 >::LocalGeometryImpl LocalGeometryImpl;
238 typedef typename GridImp::template
Codim< 0 >::Geometry Geometry;
239 typedef typename GridImp::template
Codim< 0 >::LocalGeometry LocalGeometry;
246 typedef typename GridImp::template
Codim<0>::Entity Entity;
285 unsigned int subEntities (
unsigned int codim)
const;
289 template<
int codim >
290 typename Codim< codim >::Entity
subEntity (
int i )
const;
292 template<
int codim >
293 typename Codim< codim >::Twist twist (
int i )
const;
296 bool isLeaf ()
const;
300 Entity father ()
const;
305 return (this->
level()>0);
317 LocalGeometry geometryInFather ()
const;
323 ALU3dGridHierarchicIterator<GridImp> hbegin (
int maxlevel)
const;
326 ALU3dGridHierarchicIterator<GridImp> hend (
int maxlevel)
const;
336 bool mightVanish ()
const;
339 bool hasBoundaryIntersections ()
const;
345 bool mark(
const int refCount,
const bool conformingRefinement )
const;
353 void setElement(HElementType &element);
362 void reset (
int l );
380 int subIndex(
int i,
unsigned int codim)
const;
383 const IMPLElementType& getItem ()
const {
return *item_; }
386 const BNDFaceType& getGhost ()
const
388 alugrid_assert ( isGhost() );
393 bool isGhost ()
const{
return ImplTraits::isGhost( ghost_ ); }
407 return (isGhost()) ? getGhost().ldbVertexIndex() : getItem().ldbVertexIndex();
413 return (isGhost()) ? 0 : getItem().weight();
419 return (isGhost()) ? getGhost().master() : getItem().master();
430 mutable IMPLElementType* item_;
447template<
int codim,
class Gr
idImp >
451 enum { dim = GridImp::dimension };
452 enum { dimworld = GridImp::dimensionworld };
454 typedef typename GridImp::MPICommunicatorType Comm;
458 friend class ALU3dGrid < GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
460 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
463 typedef typename ImplTraits::HBndSegType HBndSegType;
464 typedef typename ImplTraits::BNDFaceType BNDFaceType;
466 enum { codimension = codim };
470 typedef Entity EntityObject;
504 alugrid_assert ( seed_.isValid() );
505 alugrid_assert ( seed_.item() == & entityImp().getItem() );
510 int level ()
const {
return seed_.level(); }
523 void updateGhostPointer( HBndSegType & ghostFace );
526 void updateEntityPointer( HElementType * item ,
int level = -1 );
532 mutable EntityObject entity_;
535 EntityImp & entityImp ()
const {
536 return entity_.impl();
543template<
class Gr
idImp>
544class ALU3dGridEntityPointer<0,GridImp> :
551 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
552 enum { dim = GridImp::dimension };
553 enum { dimworld = GridImp::dimensionworld };
555 typedef typename GridImp::MPICommunicatorType Comm;
559 friend class ALU3dGrid < GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
561 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
564 typedef typename ImplTraits::HBndSegType HBndSegType;
565 typedef typename ImplTraits::BNDFaceType BNDFaceType;
583 ALU3dGridEntityPointer(const HElementType & item)
612template<
int cd,
class Gr
idImp>
613class ALU3dGridEntityPointer :
614public ALU3dGridEntityPointerBase<cd,GridImp>
617 typedef ALU3dGridEntityPointerBase<cd,GridImp> BaseType ;
618 typedef ALU3dGridEntityPointer <cd,GridImp> ThisType;
619 enum { dim = GridImp::dimension };
620 enum { dimworld = GridImp::dimensionworld };
622 typedef typename GridImp::MPICommunicatorType Comm;
624 friend class ALU3dGridEntity<cd,dim,GridImp>;
625 friend class ALU3dGridEntity< 0,dim,GridImp>;
626 friend class ALU3dGrid < GridImp::dimension, GridImp::dimensionworld, GridImp::elementType, Comm >;
628 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
629 typedef typename ImplTraits::template Codim<dim, cd>
::InterfaceType HElementType;
631 typedef typename ImplTraits::HBndSegType HBndSegType;
632 typedef typename ImplTraits::BNDFaceType BNDFaceType;
633 typedef ALU3dGridEntity<cd,dim,GridImp> ALU3dGridEntityType;
635 using BaseType :: seed_;
636 using BaseType :: entity_;
637 using BaseType :: entityImp;
641 typedef ALU3dGridEntitySeed<cd, GridImp> ALU3dGridEntitySeedType;
644 typedef typename GridImp::template Codim<cd>::Entity Entity;
647 typedef ALU3dGridEntityPointer<cd,GridImp> ALU3dGridEntityPointerType;
650 static const int defaultValue = -665;
654 ALU3dGridEntityPointer(const ALU3dGridEntityType& entity)
659 ALU3dGridEntityPointer(
const ALU3dGridEntitySeedType& seed)
665 ALU3dGridEntityPointer()
670 void updateEntityPointer( HElementType * item ,
int level );
675#include "entity_inline.hh"
677#if COMPILE_ALUGRID_INLINE
678 #include "entity_imp.cc"
Definition: entity.hh:449
GridImp::template Codim< codimension >::Entity Entity
type of Entity
Definition: entity.hh:469
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:474
int level() const
ask for level of entities
Definition: entity.hh:510
ALU3dGridEntityPointerBase()
default empty constructor
Definition: entity_inline.hh:241
bool equals(const ALU3dGridEntityPointerType &i) const
equality
Definition: entity_inline.hh:293
ALU3dGridEntitySeed< codimension, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:480
ALU3dGridEntityPointer< codimension, GridImp > EntityPointerImp
make type of entity pointer implementation available in derived classes
Definition: entity.hh:477
ALU3dGridEntityPointerBase(const HElementType &item)
Constructor for EntityPointer that points to an element.
Definition: entity_inline.hh:216
Entity & dereference() const
dereferencing
Definition: entity.hh:501
ThisType & operator=(const ThisType &org)
assignment operator
Definition: entity_inline.hh:260
void done()
has to be called when iterator is finished
Definition: entity_inline.hh:286
ALU3dGridEntityPointer(const HBndSegType &ghostFace)
Constructor for EntityPointer that points to an ghost.
Definition: entity.hh:588
GridImp::template Codim< cd >::Entity Entity
type of Entity
Definition: entity.hh:577
ALU3dGridEntityPointer(const ALU3dGridEntityType &entity)
Constructor for EntityPointer that points to an entity (interior or ghost)
Definition: entity.hh:599
ALU3dGridEntitySeed< cd, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:574
ALU3dGridEntityPointer()
Definition: entity.hh:606
ThisType ALU3dGridEntityPointerType
typedef of my type
Definition: entity.hh:580
ALU3dGridEntityPointer(const ALU3dGridEntitySeedType &seed)
Constructor for EntityPointer that points to given entity.
Definition: entity.hh:593
Definition: entity.hh:192
BNDFaceType * ghost_
not zero if entity is ghost entity
Definition: entity.hh:433
bool hasFather() const
returns true if father entity exists
Definition: entity.hh:303
GridImp::template Codim< 0 >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:256
Codim< codim >::Entity subEntity(int i) const
GeometryImpl geo_
the entity's geometry
Definition: entity.hh:427
int getSubIndex(int i) const
EntitySeed seed() const
return key for this entity
Definition: entity.hh:396
int weight() const
weight of entity (ie number of leaf elements underneath)
Definition: entity.hh:411
bool isGhost() const
returns true if entity is ghost
Definition: entity.hh:393
int master() const
return rank number of master process
Definition: entity.hh:417
int macroId() const
return macro id of this entity
Definition: entity.hh:405
EntitySeed seed_
the information necessary to make sense of this entity
Definition: entity.hh:167
GeometryType type() const
type of geometry of this entity
Definition: entity.hh:110
void removeElement()
reset item pointer to NULL
Definition: entity.hh:124
int level() const
level of this element
Definition: entity.hh:151
PartitionType partitionType() const
return partition type of this entity ( see grid.hh )
Definition: entity.hh:154
ALU3dGridEntity()
Constructor.
Definition: entity_imp.cc:214
PartitionType convertBndId(const HItemType &item) const
convert ALUGrid partition type to dune partition type
Definition: entity_imp.cc:276
Geometry geometry() const
geometry of this entity
Definition: entity_imp.cc:295
GridImp::template Codim< cd >::EntitySeed EntitySeed
typedef of my type
Definition: entity.hh:98
void setEntity(const ALU3dGridEntity< cd, dim, GridImp > &org)
set item from other entity, mainly for copy constructor of entity pointer
Definition: entity_imp.cc:227
EntitySeed seed() const
return seed of entity
Definition: entity.hh:148
GeometryImpl geo_
the current geometry
Definition: entity.hh:164
void setGhost(const HBndSegType &ghost)
setGhost is not valid for this codim
Definition: entity_imp.cc:266
int getIndex() const
index is unique within the grid hierarchy and per codim
Definition: entity.hh:158
bool equals(const ALU3dGridEntity< cd, dim, GridImp > &org) const
compare 2 elements by comparing the item pointers
Definition: entity.hh:131
Factory class for ALUGrids.
Definition: gridfactory.hh:28
hierarchic index set of ALU3dGrid
Definition: indexsets.hh:39
Definition: iterator.hh:56
Leaf iterator.
Definition: iterator.hh:648
Definition: iterator.hh:556
[ provides Dune::Grid ]
Definition: grid.hh:434
Default Implementations for EntityImp.
Definition: entity.hh:542
static constexpr int dimension
Dimension of the grid.
Definition: entity.hh:548
unsigned int subEntities(unsigned int codim) const
Number of subentities for a given codimension.
Definition: entity.hh:567
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:26
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:125
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:246
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:346
Default exception for dummy implementations.
Definition: exceptions.hh:263
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24