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::unique_ptr< FaceInfoType > FaceInfoPointer;
81 typedef typename conditional<
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 };
106 typedef typename GridImp::GridObjectFactoryType FactoryType;
125 int wLevel,
bool end=
false);
208 int outsideLevel ()
const {
return connector_.outsideLevel(); }
213 return (
connector_.conformanceState() == FaceInfoType::CONFORMING);
222 template<
class EntityType >
void done (
const EntityType &en ) { done(); }
225 void setFirstItem(
const HElementType & elem,
int wLevel);
228 void setInteriorItem(
const HElementType & elem,
229 const BNDFaceType& bnd,
int wLevel);
232 template <
class EntityType>
233 void first(
const EntityType & en,
int wLevel);
236 void setNewFace(
const GEOFaceType& newFace);
240 void setGhostFace(
const GEOFaceType& newFace);
244 void buildLocalGeometries()
const;
247 const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
248 getFace (
const GEOTriangleBndType &bnd,
int index )
const;
251 const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType *
252 getFace (
const GEOQuadBndType &bnd,
int index )
const;
255 const typename ALU3dImplTraits< tetra, Comm >::GEOFaceType *
256 getFace (
const GEOTetraElementType &elem,
int index )
const;
258 const typename ALU3dImplTraits< hexa, Comm >::GEOFaceType *
259 getFace (
const GEOHexaElementType &elem,
int index )
const;
264 mutable GeometryInfoType geoProvider_;
267 const FactoryType& factory_;
275 mutable int innerLevel_;
278 mutable GeometryImpl intersectionGlobal_;
279 mutable GeometryImpl intersectionSelfLocal_;
280 mutable GeometryImpl intersectionNeighborLocal_;
286 template<
class Gr
idImp>
287 class ALU3dGridLevelIntersectionIterator :
290 enum { dim = GridImp::dimension };
291 enum { dimworld = GridImp::dimensionworld };
293 typedef typename GridImp::MPICommunicatorType Comm;
295 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
297 typedef typename ImplTraits::HElementType HElementType ;
298 typedef typename ImplTraits::GEOElementType GEOElementType;
299 typedef typename ImplTraits::IMPLElementType IMPLElementType;
300 typedef typename ImplTraits::GEOFaceType GEOFaceType;
301 typedef typename ImplTraits::NeighbourPairType NeighbourPairType;
302 typedef typename ImplTraits::BNDFaceType BNDFaceType;
304 typedef ALU3dGridFaceInfo< GridImp::elementType, Comm > FaceInfoType;
305 typedef typename std::unique_ptr< FaceInfoType > FaceInfoPointer;
307 typedef typename conditional<
308 tetra == GridImp::elementType,
309 ALU3dGridGeometricFaceInfoTetra< Comm >,
310 ALU3dGridGeometricFaceInfoHexa< Comm > >::type GeometryInfoType;
312 typedef ElementTopologyMapping<GridImp::elementType> ElementTopo;
313 typedef FaceTopologyMapping<GridImp::elementType> FaceTopo;
315 enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
316 enum { numVerticesPerFace =
317 EntityCount<GridImp::elementType>::numVerticesPerFace };
318 enum { numVertices = EntityCount<GridImp::elementType>::numVertices };
320 typedef ALU3dGridIntersectionIterator<GridImp> BaseType;
321 typedef ALU3dGridLevelIntersectionIterator<GridImp> ThisType;
323 friend class ALU3dGridEntity<0,dim,GridImp>;
324 friend class IntersectionIteratorWrapper<GridImp,ThisType>;
326 using BaseType :: item_;
327 using BaseType :: ghost_;
328 using BaseType :: innerLevel_;
329 using BaseType :: index_;
330 using BaseType :: connector_;
331 using BaseType :: geoProvider_;
332 using BaseType :: factory_;
333 using BaseType :: boundary;
334 using BaseType :: done ;
335 using BaseType :: getFace;
336 using BaseType :: neighbor ;
339 typedef typename GridImp::GridObjectFactoryType FactoryType;
341 typedef ALUMemoryProvider< ThisType > StorageType;
345 ALU3dGridLevelIntersectionIterator(
const FactoryType& factory,
347 int wLevel,
bool end=
false);
349 ALU3dGridLevelIntersectionIterator(
const FactoryType& factory,
int wLevel);
352 ALU3dGridLevelIntersectionIterator(
const ThisType & org);
355 void assign(
const ThisType & org);
361 template <
class EntityType>
362 void first(
const EntityType & en,
int wLevel);
365 bool neighbor ()
const;
368 bool conforming ()
const
370 assert( ( !
connector_.conformingRefinement() ) ?
371 ( !neighbor() || this->
connector_.conformanceState() == FaceInfoType::CONFORMING ) :
true );
379 void setNewFace(
const GEOFaceType& newFace);
382 void setFirstItem(
const HElementType & elem,
int wLevel);
385 void setInteriorItem(
const HElementType & elem,
386 const BNDFaceType& bnd,
int wLevel);
397 template <
class InternalIteratorType >
398 class ALU3dGridTreeIterator
401 typedef typename InternalIteratorType :: val_t val_t;
404 template <
class Gr
idImp,
int codim>
408 template <
class ItemType>
409 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
412 return (level < 0) ? item.level() : level;
417 template <
class Gr
idImp>
418 class GetLevel<GridImp,0>
421 template <
class ItemType>
422 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level )
428 template <
class Gr
idImp>
429 class GetLevel<GridImp,3>
432 template <
class ItemType>
433 static int getLevel(
const GridImp & grid,
const ItemType & item,
int level)
435 return (level < 0) ? grid.getLevelOfLeafVertex(item) : level;
441 template <
class Gr
idImp,
class IteratorImp>
442 void firstItem(
const GridImp & grid, IteratorImp & it,
int level )
444 InternalIteratorType & iter = it.internalIterator();
448 assert( iter.size() > 0 );
449 setItem(grid,it,iter,level);
458 template <
class Gr
idImp,
class IteratorImp>
459 void setItem (
const GridImp & grid, IteratorImp & it, InternalIteratorType & iter,
int level)
461 enum { codim = IteratorImp :: codimension };
462 val_t & item = iter.item();
463 assert( item.first || item.second );
466 it.updateEntityPointer( item.first ,
467 GetLevel<GridImp,codim>::getLevel(grid, *(item.first) , level) );
470 it.updateGhostPointer( *item.second );
474 template <
class Gr
idImp,
class IteratorImp>
475 void incrementIterator(
const GridImp & grid, IteratorImp & it,
int level)
478 InternalIteratorType & iter = it.internalIterator();
488 setItem(grid,it,iter,level);
500 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp>
502 :
public ALU3dGridEntityPointer< cd, GridImp >,
503 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, typename GridImp::MPICommunicatorType > >
505 enum { dim = GridImp::dimension };
506 enum { dimworld = GridImp::dimensionworld };
508 typedef typename GridImp::MPICommunicatorType Comm;
514 friend class ALU3dGrid< GridImp::elementType, Comm >;
516 friend class ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, Comm > >;
519 typedef typename GridImp::GridObjectFactoryType FactoryType;
521 typedef typename GridImp::template
Codim<cd>::Entity Entity;
527 typedef typename ALU3DSPACE ALU3dGridLevelIteratorWrapper< cd, pitype, Comm > IteratorType;
528 typedef IteratorType InternalIteratorType;
529 typedef typename ALU3DSPACE IteratorElType< cd, Comm >::val_t val_t;
562 IteratorType * iter_ ;
567 IteratorType & internalIterator ()
581 template<
int cdim, PartitionIteratorType pitype,
class Gr
idImp>
583 :
public ALU3dGridEntityPointer< cdim, GridImp >,
584 public ALU3dGridTreeIterator< ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, typename GridImp::MPICommunicatorType > >
586 enum { dim = GridImp :: dimension };
589 enum { codim = cdim };
591 typedef typename GridImp::MPICommunicatorType Comm;
594 typedef typename GridImp::GridObjectFactoryType FactoryType;
598 typedef typename ALU3DSPACE ALU3dGridLeafIteratorWrapper< cdim, pitype, Comm > IteratorType ;
599 friend class ALU3dGridTreeIterator< IteratorType > ;
601 typedef IteratorType InternalIteratorType;
602 typedef typename ALU3DSPACE IteratorElType< cdim, Comm >::val_t val_t;
632 IteratorType * iter_;
638 void assign (
const ThisType & org);
644 InternalIteratorType & internalIterator ()
653 template<
class Gr
idImp>
654 class ALU3dGridHierarchicIterator
655 :
public ALU3dGridEntityPointer<0,GridImp>
658 typedef ALU3dGridHierarchicIterator<GridImp> ThisType;
659 enum { dim = GridImp::dimension };
661 typedef typename GridImp::MPICommunicatorType Comm;
663 typedef ALU3dImplTraits< GridImp::elementType, Comm > ImplTraits;
664 typedef typename ImplTraits::HElementType HElementType;
665 typedef typename ImplTraits::HBndSegType HBndSegType;
667 template <
class Po
interType,
class CommT >
668 class GhostElementStorage;
671 template <
class Po
interType >
672 class GhostElementStorage< PointerType, No_Comm >
675 GhostElementStorage() {}
676 explicit GhostElementStorage(
const PointerType& ) {}
677 PointerType& operator * () { PointerType* p = 0; assert(
false ); abort();
return *p; }
678 const PointerType*
ghost ()
const {
return 0; }
679 PointerType* nextGhost ()
const {
return 0; }
680 PointerType* operator -> ()
const {
return 0; }
681 bool operator != (
const PointerType* )
const {
return false; }
682 bool operator ! ()
const {
return true ; }
683 GhostElementStorage& operator= (
const GhostElementStorage& ) {
return *
this; }
684 GhostElementStorage& operator= (
const PointerType* ) {
return *
this; }
685 bool valid ()
const {
return false; }
688#if ALU3DGRID_PARALLEL
690 template <
class Po
interType >
691 class GhostElementStorage< PointerType, MPI_Comm >
695 const HBndSegType * ghost_;
696 HBndSegType * nextGhost_;
698 GhostElementStorage() : ghost_( 0 ), nextGhost_( 0 ) {}
699 explicit GhostElementStorage(
const PointerType& gh ) : ghost_( &gh ), nextGhost_( 0 ) {}
700 GhostElementStorage(
const GhostElementStorage& org )
701 : ghost_( org.ghost_ ), nextGhost_( org.nextGhost_ ) {}
703 PointerType& operator * () { assert( nextGhost_ );
return *nextGhost_; }
704 const PointerType*
ghost ()
const {
return ghost_; }
705 PointerType* nextGhost ()
const {
return nextGhost_; }
706 PointerType* operator -> () {
return nextGhost_; }
707 bool operator != (
const PointerType* p )
const {
return (nextGhost_ != p); }
708 bool operator ! ()
const {
return nextGhost_ == 0; }
709 GhostElementStorage& operator= (
const GhostElementStorage& org)
712 nextGhost_ = org.nextGhost_;
715 GhostElementStorage& operator= (PointerType* p)
720 bool valid ()
const {
return (ghost_ != 0); }
725 typedef typename GridImp::GridObjectFactoryType FactoryType;
727 typedef typename GridImp::template Codim<0>::Entity Entity;
728 typedef typename GridImp::ctype ctype;
731 ALU3dGridHierarchicIterator(
const FactoryType& factory,
732 const HElementType & elem,
733 int maxlevel,
bool end );
736 ALU3dGridHierarchicIterator(
const FactoryType& factory,
737 const HBndSegType& ghost,
742 ALU3dGridHierarchicIterator(
const ThisType &org);
748 Entity & dereference ()
const;
751 void releaseEntity () {}
754 ThisType & operator = (
const ThisType & org);
758 void assign(
const ThisType & org);
761 int getLevel(
const HElementType* item)
const;
764 int getLevel(
const HBndSegType* face)
const;
767 template <
class HItemType>
768 HItemType* goNextElement (
const HItemType* startElem, HItemType * oldEl);
771 const HElementType * elem_;
774 GhostElementStorage< HBndSegType, Comm > ghostElem_;
783#include "iterator_imp.cc"
int level() const
ask for level of entities
Definition: entity_inline.hh:481
Definition: entity.hh:590
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:273
const GEOFaceType & getItem() const
return current face
Definition: iterator.hh:217
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:263
EntityPointer inside() const
access entity where iteration started
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:270
bool conforming() const
return true if intersection is conforming
Definition: iterator.hh:211
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:585
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:625
ThisType & operator=(const ThisType &org)
assignment of iterators
Definition: iterator.cc:200
~ALU3dGridLeafIterator()
destructor deleting real iterator
Definition: iterator.cc:180
Definition: iterator.hh:504
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:550
ThisType & operator=(const ThisType &org)
assignment of iterators
Definition: iterator.cc:103
ALU3dGridLevelIterator< cd, pitype, GridImp > ThisType
typedef of my type
Definition: iterator.hh:525
[ 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:252
Provides proxy classes for IntersectionsIterators.
Ghost ghost
PartitionSet for the ghost partition.
Definition: partitionset.hh:238
Dune namespace.
Definition: alignment.hh:10
Definition: alu3dinclude.hh:297
Static tag representing a codimension.
Definition: dimension.hh:22