1#ifndef DUNE_ALUGRID_ITERATOR_IMP_CC
2#define DUNE_ALUGRID_ITERATOR_IMP_CC
4#include <dune/geometry/genericgeometry/topologytypes.hh>
26template<
class Gr
idImp>
29 connector_( levelIntersectionIterator ),
30 geoProvider_(connector_),
37template<
class Gr
idImp>
47template<
class Gr
idImp>
52 item_ =
static_cast<const IMPLElementType *
> (&elem);
55 const GEOFaceType* firstFace = getFace(*item_, index_);
57 const GEOFaceType* childFace = firstFace->down();
58 if( childFace ) firstFace = childFace;
61 setNewFace(*firstFace);
64template<
class Gr
idImp>
66setInteriorItem (
const HElementType & elem,
const BNDFaceType& ghost,
int wLevel)
69 index_ = ElementTopo::alu2duneFace( ghost.getGhost().second );
75 const GEOFaceType* firstFace = getFace( ghost, index_ );
76 item_ =
static_cast<const IMPLElementType *
> (&elem);
78 const GEOFaceType* childFace = firstFace->down();
79 if( childFace ) firstFace = childFace;
82 setGhostFace(*firstFace);
85template<
class Gr
idImp>
86template <
class EntityType>
88first (
const EntityType & en,
int wLevel,
89 const bool conformingRefinement,
90 const bool ghostCellsEnabled )
92 if( ! en.isLeaf() && en.level()>0)
99 connector_.setFlags( conformingRefinement, ghostCellsEnabled );
101 innerLevel_ = en.level();
106 setInteriorItem(en.getItem(), en.getGhost(), wLevel);
113 (numFaces == en.getItem().nFaces()) :
114 (numFaces < en.getItem().nFaces()) );
115 setFirstItem(en.getItem(), wLevel);
120template<
class Gr
idImp>
123 connector_(org.connector_),
124 geoProvider_(connector_),
141template<
class Gr
idImp>
157 item_->twist(ElementTopo::dune2aluFace(index_)));
158 geoProvider_.resetFaceGeom();
167template<
class Gr
idImp>
173 return ((item_ == i.
item_) &&
178template<
class Gr
idImp>
184 const GEOFaceType * nextFace = 0;
187 if (connector_.conformanceState() == FaceInfoType::REFINED_OUTER)
189 nextFace = connector_.face().next();
194 if( ImplTraits :: isGhost( ghost_ ) )
196 setGhostFace( *nextFace );
200 setNewFace(*nextFace);
212 if (index_ >= numFaces || ghost_ )
219 nextFace = getFace(connector_.innerEntity(), index_);
224 const GEOFaceType * childFace = nextFace->down();
225 if( childFace ) nextFace = childFace;
228 setNewFace(*nextFace);
233template<
class Gr
idImp>
240 if( connector_.ghostBoundary() )
250template<
class Gr
idImp>
254 if( ImplTraits :: isGhost( ghost_ ) )
265template<
class Gr
idImp>
271template<
class Gr
idImp>
277template<
class Gr
idImp>
281 alugrid_assert (ElementTopo::dune2aluFace(index_) == connector_.innerALUFaceIndex());
285template<
class Gr
idImp >
289 buildLocalGeometries();
294template<
class Gr
idImp >
298 return ElementTopo::alu2duneFace( connector_.outerALUFaceIndex() );
301template<
class Gr
idImp >
305 return Twist( connector_.duneTwist( indexInInside(), connector_.innerTwist() ) );
308template<
class Gr
idImp >
312 return Twist( connector_.duneTwist( indexInOutside(), connector_.outerTwist() ) );
315template<
class Gr
idImp >
320 buildLocalGeometries();
324template<
class Gr
idImp>
329 return this->outerNormal(local);
332template<
class Gr
idImp>
335outerNormal(
const FieldVector<alu3d_ctype, dim-1>& local)
const
339 if(GridImp::dimension == 2 && GridImp::dimensionworld == 3 && GridImp::elementType ==
hexa)
341 typedef typename LocalGeometry::GlobalCoordinate Coordinate;
342 typedef typename GridImp::template Codim<0>::Geometry ElementGeometry;
345 const ReferenceElement< alu3d_ctype, dim > &refElement =
346 ReferenceElements< alu3d_ctype, dim >::cube();
348 Coordinate xInside = geometryInInside().global( local );
349 Coordinate refNormal = refElement.integrationOuterNormal( indexInInside() );
351#if DUNE_VERSION_NEWER(DUNE_GRID,2,4)
352 const ElementGeometry insideGeom = inside().geometry();
354 const ElementGeometry insideGeom = inside().dereference().geometry();
356 insideGeom.jacobianInverseTransposed( xInside ).mv( refNormal, outerNormal );
357 outerNormal *= insideGeom.integrationElement( xInside );
358 if(connector_.conformanceState() == FaceInfoType::REFINED_OUTER) outerNormal *=0.5;
362 return geoProvider_.outerNormal(local);
365template<
class Gr
idImp>
370 unitOuterNormal_ = this->outerNormal(local);
371 unitOuterNormal_ *= (1.0/unitOuterNormal_.two_norm());
372 return unitOuterNormal_;
375template<
class Gr
idImp >
379 geoProvider_.buildGlobalGeom( intersectionGlobal_ );
380 return Geometry( intersectionGlobal_ );
383template<
class Gr
idImp>
389 GridImp::elementType ==
tetra ?
390 GenericGeometry :: SimplexTopology< dim-1 > :: type :: id :
391 GenericGeometry :: CubeTopology < dim-1 > :: type :: id,
395template<
class Gr
idImp>
400 return ( boundary() ) ? connector_.boundaryId() : 0;
403template<
class Gr
idImp>
409 return connector_.segmentIndex();
412template<
class Gr
idImp >
415 intersectionSelfLocal_.buildGeom( geoProvider_.intersectionSelfLocal() );
416 if ( !connector_.outerBoundary() )
417 intersectionNeighborLocal_.buildGeom( geoProvider_.intersectionNeighborLocal() );
420template <
class Gr
idImp>
423getFace(
const GEOTriangleBndType& bnd,
int index)
const
425 return bnd.myhface3(0);
428template <
class Gr
idImp>
431getFace(
const GEOQuadBndType& bnd,
int index)
const
433 return bnd.myhface4(0);
436template <
class Gr
idImp>
439getFace(
const GEOTetraElementType& elem,
int index)
const
442 return elem.myhface(ElementTopo::dune2aluFace(index));
445template <
class Gr
idImp>
448getFace(
const GEOHexaElementType& elem,
int index)
const
451 return elem.myhface(ElementTopo::dune2aluFace(index));
454template <
class Gr
idImp>
460 connector_.updateFaceInfo(newFace,innerLevel_,
461 item_->twist(ElementTopo::dune2aluFace(index_)) );
462 geoProvider_.resetFaceGeom();
465template <
class Gr
idImp>
471 connector_.updateFaceInfo(newFace,innerLevel_, ghost_->twist(0) );
472 geoProvider_.resetFaceGeom();
475template <
class Gr
idImp>
494template<
class Gr
idImp>
498 , levelNeighbor_(false)
503template<
class Gr
idImp>
504template <
class EntityType>
506first (
const EntityType & en,
int wLevel,
507 const bool conformingRefinement,
const bool ghostCellsEnabled )
509 connector_.setFlags( conformingRefinement, ghostCellsEnabled );
513 isLeafItem_ = en.isLeaf();
517 setInteriorItem(en.getItem(), en.getGhost(), wLevel);
524 (numFaces == en.getItem().nFaces()) :
525 (numFaces < en.getItem().nFaces()) );
526 setFirstItem(en.getItem(), wLevel);
530template<
class Gr
idImp>
535 item_ =
static_cast<const IMPLElementType *
> (&elem);
536 this->innerLevel_ = wLevel;
538 const GEOFaceType* firstFace = getFace(*item_, index_);
540 setNewFace(*firstFace);
543template<
class Gr
idImp>
544inline void ALU3dGridLevelIntersectionIterator<GridImp> ::
545setInteriorItem (
const HElementType & elem,
const BNDFaceType& ghost,
int wLevel)
549 item_ =
static_cast<const IMPLElementType *
> (&elem);
551 index_ = ElementTopo::alu2duneFace( ghost.getGhost().second );
553 innerLevel_ = wLevel;
556 const GEOFaceType* firstFace = getFace( ghost, index_ );
559 setNewFace(*firstFace);
563template<
class Gr
idImp>
567 , levelNeighbor_(org.levelNeighbor_)
568 , isLeafItem_(org.isLeafItem_)
573template<
class Gr
idImp>
579 levelNeighbor_ = org.levelNeighbor_;
580 isLeafItem_ = org.isLeafItem_;
583template<
class Gr
idImp>
594 if ( index_ >= numFaces || ImplTraits::isGhost( ghost_ ) )
601 const GEOFaceType * nextFace = getFace(connector_.innerEntity(), index_);
604 setNewFace(*nextFace);
608template<
class Gr
idImp>
611 return levelNeighbor_ && (BaseType :: neighbor());
614template <
class Gr
idImp>
619 levelNeighbor_ = (newFace.level() == innerLevel_);
620 connector_.updateFaceInfo(newFace, innerLevel_,
621 ( ImplTraits::isGhost( ghost_ ) ) ?
623 item_->twist(ElementTopo::dune2aluFace( index_ ))
625 geoProvider_.resetFaceGeom();
631 if( connector_.ghostBoundary() )
633 const BNDFaceType & ghost = connector_.boundaryFace();
635 levelNeighbor_ = (innerLevel_ == ghost.ghostLevel() );
637 else if ( ! connector_.outerBoundary() )
639 levelNeighbor_ = (connector_.outerEntity().level() == innerLevel_);
646#if COMPILE_ALUGRID_INLINE
#define alugrid_assert(EX)
Definition alugrid_assert.hh:20
Definition alu3dinclude.hh:80
@ hexa
Definition topology.hh:12
@ tetra
Definition topology.hh:12
Definition alu3dinclude.hh:259
Definition iterator.hh:56
LocalGeometry geometryInInside() const
Definition iterator_imp.cc:287
NormalType outerNormal(const FieldVector< alu3d_ctype, dim-1 > &local) const
Definition iterator_imp.cc:335
int boundaryId() const
return information about the Boundary
Definition iterator_imp.cc:397
int indexInInside() const
Definition iterator_imp.cc:279
void done()
Definition iterator_imp.cc:39
const BNDFaceType * ghost_
current pointer to ghost face if iterator was started from ghost element
Definition iterator.hh:270
GridImp::template Codim< 1 >::Geometry Geometry
Definition iterator.hh:108
Geometry geometry() const
Definition iterator_imp.cc:377
int index_
Definition iterator.hh:273
EntityPointerImpl inside() const
access entity where iteration started
Definition iterator_imp.cc:252
NormalType integrationOuterNormal(const FieldVector< alu3d_ctype, dim-1 > &local) const
Definition iterator_imp.cc:327
int level() const
return level of iterator (level of item)
Definition iterator_imp.cc:478
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Definition iterator.hh:109
bool boundary() const
return true if intersection is with boundary.
Definition iterator_imp.cc:266
Twist twistInInside() const
returns twist of face compared to inner element
Definition iterator_imp.cc:303
Twist twistInOutside() const
returns twist of face compared to outer element
Definition iterator_imp.cc:310
NormalType unitOuterNormal(const FieldVector< alu3d_ctype, dim-1 > &local) const
Definition iterator_imp.cc:368
LocalGeometry geometryInOutside() const
Definition iterator_imp.cc:317
int innerLevel_
Definition iterator.hh:272
FaceInfoType connector_
Definition iterator.hh:263
EntityPointerImpl outside() const
access neighbor
Definition iterator_imp.cc:235
void buildLocalGeometries() const
Definition iterator_imp.cc:413
GridImp::template Codim< 0 >::EntityPointerImpl EntityPointerImpl
Definition iterator.hh:110
void setNewFace(const GEOFaceType &newFace)
Definition iterator_imp.cc:456
FieldVector< alu3d_ctype, dimworld > NormalType
Definition iterator.hh:116
const ALU3dImplTraits< tetra, Comm >::GEOFaceType * getFace(const GEOTriangleBndType &bnd, int index) const
Definition iterator_imp.cc:423
Twists::Twist Twist
Definition iterator.hh:105
void assign(const ALU3dGridIntersectionIterator< GridImp > &org)
assignment of iterators
Definition iterator_imp.cc:144
bool neighbor() const
return true if across the face an neighbor on leaf exists
Definition iterator_imp.cc:272
const IMPLElementType * item_
current element from which we started the intersection iterator
Definition iterator.hh:267
GeometryType type() const
obtain the type of reference element for this intersection
Definition iterator_imp.cc:386
size_t boundarySegmentIndex() const
return the boundary segment index
Definition iterator_imp.cc:405
int indexInOutside() const
Definition iterator_imp.cc:296
bool conformingRefinement() const
return true if conforming refinement is enabled
Definition faceutility.hh:138
bool ghostCellsEnabled() const
return true if ghost cells are enabled
Definition faceutility.hh:141
const GEOFaceType & face() const
Returns the ALU3dGrid face.
Definition faceutility_imp.cc:320
Definition iterator.hh:292
bool neighbor() const
return true if across the edge an neighbor on this level exists
Definition iterator_imp.cc:609