4#ifndef DUNE_ALU3DGRIDITERATOR_HH
5#define DUNE_ALU3DGRIDITERATOR_HH
12#include <dune/grid/alugrid/common/memory.hh>
15#include "alu3dinclude.hh"
17#include "faceutility.hh"
18#include "alu3diterators.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 pitype,
class Gr
idImp>
35 class ALU3dGridLeafIterator;
36 template< ALU3dGr
idElementType,
class >
38 template< ALU3dGr
idElementType,
class >
39 class ALU3dGridFaceInfo;
40 template< ALU3dGr
idElementType,
class >
41 class ALU3dGridGeometricFaceInfo;
54 template<
class Gr
idImp>
58 enum { dim = GridImp::dimension };
59 enum { dimworld = GridImp::dimensionworld };
61 typedef typename GridImp::MPICommunicatorType Comm;
63 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
65 typedef typename ImplTraits::HElementType HElementType ;
66 typedef typename ImplTraits::HBndSegType HBndSegType;
67 typedef typename ImplTraits::GEOElementType GEOElementType;
68 typedef typename ImplTraits::IMPLElementType IMPLElementType;
69 typedef typename ImplTraits::GEOFaceType GEOFaceType;
70 typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
71 typedef typename ImplTraits::BNDFaceType BNDFaceType;
73 typedef typename ALU3dImplTraits< tetra, Comm >::GEOElementType GEOTetraElementType;
74 typedef typename ALU3dImplTraits< hexa, Comm >::GEOElementType GEOHexaElementType;
75 typedef typename ALU3dImplTraits< tetra, Comm >::BNDFaceType GEOTriangleBndType;
76 typedef typename ALU3dImplTraits< hexa, Comm >::BNDFaceType GEOQuadBndType;
78 typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
79 typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
82 tetra == GridImp::elementType,
89 enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
90 enum { numVerticesPerFace =
91 EntityCount<GridImp::elementType>::numVerticesPerFace };
92 enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
100 enum IntersectionIteratorType { IntersectionLeaf , IntersectionLevel, IntersectionBoth };
102 typedef typename GridImp::Traits::template Codim< 1 >::GeometryImpl GeometryImpl;
103 typedef typename GridImp::Traits::template Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
106 typedef typename GridImp::GridObjectFactoryType FactoryType;
108 typedef typename GridImp::template Codim<0>::Entity Entity;
109 typedef typename GridImp::template Codim<1>::Geometry Geometry;
110 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
125 int wLevel,
bool end=
false);
214 int outsideLevel ()
const {
return connector_.outsideLevel(); }
219 return (
connector_.conformanceState() == FaceInfoType::CONFORMING);
228 template<
class EntityType >
void done (
const EntityType &en ) { done(); }
231 void setFirstItem(
const HElementType & elem,
int wLevel);
234 void setInteriorItem(
const HElementType & elem,
235 const BNDFaceType& bnd,
int wLevel);
238 template <
class EntityType>
239 void first(
const EntityType & en,
int wLevel);
242 void setNewFace(
const GEOFaceType& newFace);
246 void setGhostFace(
const GEOFaceType& newFace);
250 void buildLocalGeometries()
const;
253 const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
254 getFace (
const GEOTriangleBndType &bnd,
int index )
const;
257 const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType *
258 getFace (
const GEOQuadBndType &bnd,
int index )
const;
261 const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
262 getFace (
const GEOTetraElementType &elem,
int index )
const;
264 const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType *
265 getFace (
const GEOHexaElementType &elem,
int index )
const;
270 mutable GeometryInfoType geoProvider_;
273 const FactoryType& factory_;
281 mutable int innerLevel_;
284 mutable GeometryImpl intersectionGlobal_;
285 mutable GeometryImpl intersectionSelfLocal_;
286 mutable GeometryImpl intersectionNeighborLocal_;
292 template<
class Gr
idImp>
293 class ALU3dGridLevelIntersectionIterator :
296 enum { dim = GridImp::dimension };
297 enum { dimworld = GridImp::dimensionworld };
299 typedef typename GridImp::MPICommunicatorType Comm;
301 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
303 typedef typename ImplTraits::HElementType HElementType ;
304 typedef typename ImplTraits::GEOElementType GEOElementType;
305 typedef typename ImplTraits::IMPLElementType IMPLElementType;
306 typedef typename ImplTraits::GEOFaceType GEOFaceType;
307 typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
308 typedef typename ImplTraits::BNDFaceType BNDFaceType;
310 typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
311 typedef typename std::auto_ptr< FaceInfoType > FaceInfoPointer;
313 typedef typename conditional<
314 tetra == GridImp::elementType,
315 ALU3dGridGeometricFaceInfoTetra< Comm >,
316 ALU3dGridGeometricFaceInfoHexa< Comm > >::type GeometryInfoType;
318 typedef ElementTopologyMapping<GridImp::elementType> ElementTopo;
319 typedef FaceTopologyMapping<GridImp::elementType> FaceTopo;
321 enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
322 enum { numVerticesPerFace =
323 EntityCount<GridImp::elementType>::numVerticesPerFace };
324 enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
326 typedef ALU3dGridIntersectionIterator<GridImp> BaseType;
327 typedef ALU3dGridLevelIntersectionIterator<GridImp> ThisType;
329 friend class ALU3dGridEntity<0,dim,GridImp>;
330 friend class IntersectionIteratorWrapper<GridImp,ThisType>;
332 using BaseType :: item_;
333 using BaseType :: ghost_;
334 using BaseType :: innerLevel_;
335 using BaseType :: index_;
336 using BaseType :: connector_;
337 using BaseType :: geoProvider_;
338 using BaseType :: factory_;
339 using BaseType :: boundary;
340 using BaseType :: done ;
341 using BaseType :: getFace;
342 using BaseType :: neighbor ;
345 typedef typename GridImp::GridObjectFactoryType FactoryType;
347 typedef ALUMemoryProvider< ThisType > StorageType;
351 ALU3dGridLevelIntersectionIterator(
const FactoryType& factory,
353 int wLevel,
bool end=
false);
355 ALU3dGridLevelIntersectionIterator(
const FactoryType& factory,
int wLevel);
358 ALU3dGridLevelIntersectionIterator(
const ThisType & org);
361 void assign(
const ThisType & org);
367 template <
class EntityType>
368 void first(
const EntityType & en,
int wLevel);
371 bool neighbor ()
const;
374 bool conforming ()
const
376 assert( ( !
connector_.conformingRefinement() ) ?
377 ( !neighbor() || this->
connector_.conformanceState() == FaceInfoType::CONFORMING ) :
true );
385 void setNewFace(
const GEOFaceType& newFace);
388 void setFirstItem(
const HElementType & elem,
int wLevel);
391 void setInteriorItem(
const HElementType & elem,
392 const BNDFaceType& bnd,
int wLevel);
403 template <
class InternalIteratorType >
404 class ALU3dGridTreeIterator
407 typedef typename InternalIteratorType :: val_t val_t;
410 template <
class Gr
idImp,
int codim>
414 template <
class ItemType>
415 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
418 return (level < 0) ? item.level() : level;
423 template <
class Gr
idImp>
424 class GetLevel<GridImp,0>
427 template <
class ItemType>
428 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
434 template <
class Gr
idImp>
435 class GetLevel<GridImp,3>
438 template <
class ItemType>
439 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level)
441 return (level < 0) ? grid.getLevelOfLeafVertex(item) : level;
447 template <
class Gr
idImp,
class IteratorImp>
448 void firstItem(
const GridImp & grid, IteratorImp & it,
int level )
450 InternalIteratorType & iter = it.internalIterator();
454 assert( iter.size() > 0 );
455 setItem(grid,it,iter,level);
464 template <
class Gr
idImp,
class IteratorImp>
465 void setItem (
const GridImp & grid, IteratorImp & it, InternalIteratorType & iter,
int level)
467 enum { codim = IteratorImp :: codimension };
468 val_t & item = iter.item();
469 assert( item.first || item.second );
472 it.updateEntityPointer( item.first ,
473 GetLevel<GridImp,codim>::getLevel(grid, *(item.first) , level) );
476 it.updateGhostPointer( *item.second );
480 template <
class Gr
idImp,
class IteratorImp>
481 void incrementIterator(
const GridImp & grid, IteratorImp & it,
int level)
484 InternalIteratorType & iter = it.internalIterator();
494 setItem(grid,it,iter,level);
506 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp>
508 :
public ALU3dGridEntityPointer< cd, GridImp >,
509 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, typename GridImp::MPICommunicatorType > >
511 enum { dim = GridImp::dimension };
512 enum { dimworld = GridImp::dimensionworld };
514 typedef typename GridImp::MPICommunicatorType Comm;
520 friend class ALU3dGrid< GridImp::elementType, Comm >;
522 friend class ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, Comm > >;
525 typedef typename GridImp::GridObjectFactoryType FactoryType;
527 typedef typename GridImp::template Codim<cd>::Entity Entity;
533 typedef typename ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, Comm > IteratorType;
534 typedef IteratorType InternalIteratorType;
535 typedef typename ALU3DSPACE IteratorElType< cd, Comm >::val_t val_t;
568 IteratorType * iter_ ;
573 IteratorType & internalIterator ()
587 template<
int cdim, PartitionIteratorType pitype,
class Gr
idImp>
589 :
public ALU3dGridEntityPointer< cdim, GridImp >,
590 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, typename GridImp::MPICommunicatorType > >
592 enum { dim = GridImp :: dimension };
595 enum { codim = cdim };
597 typedef typename GridImp::MPICommunicatorType Comm;
600 typedef typename GridImp::GridObjectFactoryType FactoryType;
602 typedef typename GridImp::template Codim<cdim>::Entity Entity;
604 typedef typename ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, Comm > IteratorType ;
605 friend class ALU3dGridTreeIterator< IteratorType > ;
607 typedef IteratorType InternalIteratorType;
608 typedef typename ALU3DSPACE IteratorElType< cdim, Comm >::val_t val_t;
638 IteratorType * iter_;
644 void assign (
const ThisType & org);
650 InternalIteratorType & internalIterator ()
659 template<
class Gr
idImp>
660 class ALU3dGridHierarchicIterator
661 :
public ALU3dGridEntityPointer<0,GridImp>
664 typedef ALU3dGridHierarchicIterator<GridImp> ThisType;
665 enum { dim = GridImp::dimension };
667 typedef typename GridImp::MPICommunicatorType Comm;
669 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
670 typedef typename ImplTraits::HElementType HElementType;
671 typedef typename ImplTraits::HBndSegType HBndSegType;
673 template <
class Po
interType,
class CommT >
674 class GhostElementStorage;
677 template <
class Po
interType >
678 class GhostElementStorage< PointerType, No_Comm >
681 GhostElementStorage() {}
682 explicit GhostElementStorage(
const PointerType& ) {}
683 PointerType& operator * () { PointerType* p = 0; assert(
false ); abort();
return *p; }
684 const PointerType* ghost ()
const {
return 0; }
685 PointerType* nextGhost ()
const {
return 0; }
686 PointerType* operator -> ()
const {
return 0; }
687 bool operator != (
const PointerType* )
const {
return false; }
688 bool operator ! ()
const {
return true ; }
689 GhostElementStorage& operator= (
const GhostElementStorage& ) {
return *
this; }
690 GhostElementStorage& operator= (
const PointerType* ) {
return *
this; }
691 bool valid ()
const {
return false; }
694#if ALU3DGRID_PARALLEL
696 template <
class Po
interType >
697 class GhostElementStorage< PointerType, MPI_Comm >
701 const HBndSegType * ghost_;
702 HBndSegType * nextGhost_;
704 GhostElementStorage() : ghost_( 0 ), nextGhost_( 0 ) {}
705 explicit GhostElementStorage(
const PointerType& gh ) : ghost_( &gh ), nextGhost_( 0 ) {}
706 GhostElementStorage(
const GhostElementStorage& org )
707 : ghost_( org.ghost_ ), nextGhost_( org.nextGhost_ ) {}
709 PointerType& operator * () { assert( nextGhost_ );
return *nextGhost_; }
710 const PointerType* ghost ()
const {
return ghost_; }
711 PointerType* nextGhost ()
const {
return nextGhost_; }
712 PointerType* operator -> () {
return nextGhost_; }
713 bool operator != (
const PointerType* p )
const {
return (nextGhost_ != p); }
714 bool operator ! ()
const {
return nextGhost_ == 0; }
715 GhostElementStorage& operator= (
const GhostElementStorage& org)
718 nextGhost_ = org.nextGhost_;
721 GhostElementStorage& operator= (PointerType* p)
726 bool valid ()
const {
return (ghost_ != 0); }
731 typedef typename GridImp::GridObjectFactoryType FactoryType;
733 typedef typename GridImp::template Codim<0>::Entity Entity;
734 typedef typename GridImp::ctype ctype;
737 ALU3dGridHierarchicIterator(
const FactoryType& factory,
738 const HElementType & elem,
739 int maxlevel,
bool end );
742 ALU3dGridHierarchicIterator(
const FactoryType& factory,
743 const HBndSegType& ghost,
748 ALU3dGridHierarchicIterator(
const ThisType &org);
754 Entity & dereference ()
const;
757 void releaseEntity () {}
760 ThisType & operator = (
const ThisType & org);
764 void assign(
const ThisType & org);
767 int getLevel(
const HElementType* item)
const;
770 int getLevel(
const HBndSegType* face)
const;
773 template <
class HItemType>
774 HItemType* goNextElement (
const HItemType* startElem, HItemType * oldEl);
777 const HElementType * elem_;
780 GhostElementStorage< HBndSegType, Comm > ghostElem_;
789#include "iterator_imp.cc"
int level() const
ask for level of entities
Definition: entity_inline.hh:475
Definition: entity.hh:585
Definition: faceutility.hh:366
Definition: faceutility.hh:322
Definition: iterator.hh:57
void increment()
increment iterator
int boundaryId() const
return information about the Boundary
int indexInInside() const
ALU3dGridIntersectionIterator(const FactoryType &factory, HElementType *el, int wLevel, bool end=false)
Geometry geometry() const
const BNDFaceType * ghost_
current pointer to ghost face if iterator was started from ghost element
Definition: iterator.hh:279
const GEOFaceType & getItem() const
return current face
Definition: iterator.hh:223
int twistInOutside() const
returns twist of face compared to outer element
int twistInInside() const
returns twist of face compared to inner element
LocalGeometry geometryInInside() const
EntityPointer outside() const
access neighbor
NormalType & outerNormal(const FieldVector< alu3d_ctype, dim-1 > &local) const
int level() const
return level of iterator (level of item)
bool boundary() const
return true if intersection is with boundary.
bool equals(const ALU3dGridIntersectionIterator< GridImp > &i) const
The copy constructor.
FaceInfoType connector_
Definition: iterator.hh:269
EntityPointer inside() const
access entity where iteration started
int twistInSelf() const
returns twist of face compared to inner element
Definition: iterator.hh:188
NormalType & unitOuterNormal(const FieldVector< alu3d_ctype, dim-1 > &local) const
void assign(const ALU3dGridIntersectionIterator< GridImp > &org)
assignment of iterators
bool neighbor() const
return true if across the face an neighbor on leaf exists
const IMPLElementType * item_
current element from which we started the intersection iterator
Definition: iterator.hh:276
bool conforming() const
return true if intersection is conforming
Definition: iterator.hh:217
int twistInNeighbor() const
returns twist of face compared to outer element
Definition: iterator.hh:191
LocalGeometry geometryInOutside() const
Dune::Intersection< GridImp, Dune::ALU3dGridIntersectionIterator< GridImp > > Intersection
type of the intersection
Definition: iterator.hh:114
GeometryType type() const
obtain the type of reference element for this intersection
size_t boundarySegmentIndex() const
return the boundary segment index
ALU3dGridIntersectionIterator(const ALU3dGridIntersectionIterator< GridImp > &org)
The copy constructor.
NormalType & integrationOuterNormal(const FieldVector< alu3d_ctype, dim-1 > &local) const
int indexInOutside() const
Leaf iterator.
Definition: iterator.hh:591
Entity & dereference() const
dereference Entity, faster then the entity pointersmethod
Definition: iterator.cc:247
void increment()
prefix increment
Definition: iterator.cc:238
ALU3dGridLeafIterator(const FactoryType &factory, int level)
Constructor for end iterators.
Definition: iterator.cc:143
void releaseEntity()
release entity
Definition: iterator.hh:631
ThisType & operator=(const ThisType &org)
assignment of iterators
Definition: iterator.cc:200
~ALU3dGridLeafIterator()
destructor deleting real iterator
Definition: iterator.cc:180
Definition: iterator.hh:510
void increment()
prefix increment
Definition: iterator.cc:111
Entity & dereference() const
dereference Entity, faster then the entity pointersmethod
Definition: iterator.cc:119
void releaseEntity()
release entity
Definition: iterator.hh:556
ThisType & operator=(const ThisType &org)
assignment of iterators
Definition: iterator.cc:103
ALU3dGridLevelIterator< cd, pitype, GridImp > ThisType
typedef of my type
Definition: iterator.hh:531
[ provides Dune::Grid ]
Definition: grid.hh:406
organize the memory management for entitys used by the NeighborIterator
Definition: memory.hh:21
Definition: topology.hh:41
Definition: topology.hh:126
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:19
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
Different resources needed by all grid implementations.
EnableIfInterOperable< T1, T2, bool >::type operator!=(const ForwardIteratorFacade< T1, V1, R1, D > &lhs, const ForwardIteratorFacade< T2, V2, R2, D > &rhs)
Checks for inequality.
Definition: iteratorfacades.hh:253
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignment.hh:14
Definition: alu3dinclude.hh:297
Select a type based on a condition.
Definition: typetraits.hh:419