3#ifndef DUNE_ALU2DGRID_INTERSECTION_HH
4#define DUNE_ALU2DGRID_INTERSECTION_HH
14#include <dune/grid/alugrid/2d/alu2dinclude.hh>
15#include <dune/grid/alugrid/2d/entity.hh>
21 template<
int cd,
int dim,
class Gr
idImp>
22 class ALU2dGridEntity;
23 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp >
24 class ALU2dGridLevelIterator;
25 template<
int cd,
class Gr
idImp >
26 class ALU2dGridEntityPointer;
27 template<
int mydim,
int coorddim,
class Gr
idImp>
28 class ALU2dGridGeometry;
29 template<
class Gr
idImp>
30 class ALU2dGridHierarchicIterator;
31 template<
class Gr
idImp>
32 class ALU2dGridIntersectionBase;
33 template<
class Gr
idImp>
34 class ALU2dGridLeafIntersectionIterator;
35 template<
class Gr
idImp>
36 class ALU2dGridLevelIntersectionIterator;
37 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
38 class ALU2dGridLeafIterator;
39 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
47 template<
class Gr
idImp,
class LocalGeometryImpl >
48 class ALU2DIntersectionGeometryStorage
50 typedef ALU2DIntersectionGeometryStorage< GridImp, LocalGeometryImpl > ThisType;
53 LocalGeometryImpl geoms_[ 2 ][ 4 ][ 2 ];
55#ifdef USE_SMP_PARALLEL
59 ALU2DIntersectionGeometryStorage ();
63 const LocalGeometryImpl &localGeom (
const int aluFace,
const int twist,
const int corners )
const
65 assert( corners == 3 || corners == 4 );
66 assert( 0 <= aluFace && aluFace < corners );
67 assert( twist == 0 || twist == 1 );
68 return geoms_[ corners-3 ][ aluFace ][ twist ];
72 static const ThisType &instance ()
74#ifdef USE_SMP_PARALLEL
75 typedef ALUGridObjectFactory< GridImp > GridObjectFactoryType;
76 static std::vector< ThisType > storage( GridObjectFactoryType :: maxThreads() );
77 return storage[ GridObjectFactoryType :: threadNumber () ];
79 static const ThisType geomStorage;
100 template<
class Gr
idImp>
103 static const int dim = GridImp::dimension;
104 static const int dimworld = GridImp::dimensionworld;
105 static const ALU2DSPACE ElementType eltype = GridImp::elementType;
107 typedef typename GridImp::Traits::template Codim< 1 >::GeometryImpl GeometryImpl;
108 typedef typename GridImp::Traits::template Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
111 typedef typename GridImp :: GridObjectFactoryType FactoryType;
117 enum { dimension = GridImp::dimension };
118 enum { dimensionworld = GridImp::dimensionworld };
120 typedef typename GridImp::template Codim<0>::Entity Entity;
121 typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
123 typedef typename GridImp::template Codim<1>::Geometry Geometry;
124 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
125 typedef ALU2dGridEntity<0,dim,GridImp> EntityImp;
126 typedef FieldVector< alu2d_ctype, dimworld > NormalType;
127 typedef FieldVector< alu2d_ctype, dim-1 > LocalCoordinate;
129 typedef ALU2dGridEntityPointer<0,GridImp> EntityPointerImp;
131 typedef typename ALU2dImplTraits< dimworld, eltype >::ThinelementType ThinelementType;
132 typedef typename ALU2dImplTraits< dimworld, eltype >::HElementType HElementType;
133 typedef typename ALU2dImplTraits< dimworld, eltype >::HBndElType HBndElType;
136 typedef ALU2DIntersectionGeometryStorage< GridImp, LocalGeometryImpl > LocalGeometryStorageType;
138 typedef ALU2dGridIntersectionBase<GridImp> ThisType;
139 friend class LevelIntersectionIteratorWrapper<GridImp>;
140 friend class LeafIntersectionIteratorWrapper<GridImp>;
142 friend class IntersectionIteratorWrapper<GridImp,ThisType>;
147 explicit impl( HElementType *
inside = 0 )
148 : index_(0), useOutside_(false)
154 HElementType *
inside ()
const
164 bool isBoundary ()
const
166 assert(
inside() && (index_ < nFaces()) &&
inside()->neighbour( index_ ) );
167 return inside()->neighbour( index_ )->thinis( ThinelementType::bndel_like );
172 assert( isBoundary() );
173 return (HBndElType *)
inside()->neighbour( index_ );
181 int opposite ()
const
186 void setInside ( HElementType *
inside )
192 void setOutside ( HElementType *
outside,
int opposite )
195 opposite_ = opposite;
200 HElementType *inside_;
201 HElementType *outside_;
207 mutable bool useOutside_;
217 virtual ~ALU2dGridIntersectionBase() {}
220 void assign (
const ThisType & org);
224 return reinterpret_cast< const Intersection &
>( *this );
228 bool equals (
const ThisType & i)
const;
246 EntityPointer
inside()
const;
257 int twistInInside ()
const;
258 int twistInOutside ()
const;
263 {
return twistInInside(); }
268 {
return twistInOutside(); }
270 NormalType outerNormal (
const LocalCoordinate &local )
const;
271 NormalType integrationOuterNormal (
const LocalCoordinate &local )
const;
272 NormalType unitOuterNormal (
const LocalCoordinate &local )
const;
274 LocalGeometry geometryInInside ()
const;
275 LocalGeometry geometryInOutside ()
const;
282 const GridImp& grid()
const {
return factory_.grid(); }
284 virtual bool conforming()
const = 0;
290 void done (
const HElementType *
inside );
291 void done (
const EntityImp &en ) { done( &en.getItem() ); }
294 void unsetUp2Date() ;
297 void first (
const EntityImp &en,
int wLevel );
300 virtual void setFirstItem (
const HElementType &elem,
int wLevel ) = 0;
303 mutable GeometryImpl intersectionGlobal_;
304 mutable LocalGeometryImpl intersectionSelfLocal_;
305 mutable LocalGeometryImpl intersectionNeighborLocal_;
308 const FactoryType& factory_;
309 const LocalGeometryStorageType &localGeomStorage_;
311 mutable int walkLevel_;
323 template<
class Gr
idImp >
324 class ALU2dGridLevelIntersectionIterator
325 :
public ALU2dGridIntersectionBase< GridImp >
327 typedef ALU2dGridLevelIntersectionIterator< GridImp > ThisType;
328 typedef ALU2dGridIntersectionBase< GridImp > BaseType;
330 static const int dim = GridImp::dimension;
331 static const int dimworld = GridImp::dimensionworld;
332 static const ALU2DSPACE ElementType eltype = GridImp::elementType;
334 typedef typename ALU2dImplTraits< dimworld, eltype >::ThinelementType ThinelementType;
335 typedef typename BaseType::HElementType HElementType;
336 typedef typename ALU2dImplTraits< dimworld, eltype >::HBndElType HBndElType;
337 typedef typename ALU2dImplTraits< dimworld, eltype >::PeriodicBndElType PeriodicBndElType;
339 friend class LevelIntersectionIteratorWrapper<GridImp>;
341 friend class IntersectionIteratorWrapper<GridImp,ThisType>;
343 typedef std::pair< HElementType *, int > IntersectionInfo;
346 typedef typename GridImp :: GridObjectFactoryType FactoryType;
347 typedef ALUMemoryProvider< ThisType > StorageType;
349 enum { dimension = GridImp::dimension };
350 enum { dimensionworld = GridImp::dimensionworld };
352 typedef typename GridImp::template Codim<0>::Entity Entity;
354 typedef typename GridImp::template Codim<1>::Geometry Geometry;
355 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
356 typedef ALU2dGridEntity<0,dim,GridImp> EntityImp;
357 typedef ALU2dGridGeometry<dim-1,dimworld,GridImp> GeometryImp;
358 typedef ALU2dGridGeometry<dim-1,dim,GridImp> LocalGeometryImp;
359 typedef FieldVector<alu2d_ctype, dimworld> NormalType;
360 typedef ALU2dGridEntityPointer<0,GridImp> EntityPointer;
362 typedef MakeableInterfaceObject< Geometry > GeometryObject;
365 ALU2dGridLevelIntersectionIterator(
const FactoryType& factory,
int wLevel);
368 ALU2dGridLevelIntersectionIterator(
const FactoryType& factory,
const HElementType* el,
int wLevel,
bool end=
true);
371 ALU2dGridLevelIntersectionIterator(
const ALU2dGridLevelIntersectionIterator<GridImp> & org);
373 void assign (
const ALU2dGridLevelIntersectionIterator<GridImp> & org);
381 bool conforming ()
const
383 return (this->grid().nonConform() || isConform());
387 bool isConform()
const
389 return (!current.outside() || (current.outside() == current.inside()->neighbour( current.index_ )));
396 void setFirstItem(
const HElementType & elem,
int wLevel);
399 template <
class EntityType>
400 void first(
const EntityType & en,
int wLevel);
402 void addNeighboursToStack();
404 static int getOppositeInFather (
int nrInChild,
int nrOfChild );
405 static int getOppositeInChild (
int nrInFather,
int nrOfChild );
407 void setupIntersection ();
410 using BaseType::done;
412 using BaseType::current;
413 using BaseType::walkLevel_;
416 mutable std::stack<IntersectionInfo> nbStack_;
428 template<
class Gr
idImp >
429 class ALU2dGridLeafIntersectionIterator
430 :
public ALU2dGridIntersectionBase< GridImp >
432 typedef ALU2dGridLeafIntersectionIterator< GridImp > ThisType;
433 typedef ALU2dGridIntersectionBase< GridImp > BaseType;
435 friend class LeafIntersectionIteratorWrapper<GridImp>;
436 friend class IntersectionIteratorWrapper<GridImp,ThisType>;
438 static const int dim = GridImp::dimension;
439 static const int dimworld = GridImp::dimensionworld;
440 static const ALU2DSPACE ElementType eltype = GridImp::elementType;
443 typedef typename GridImp :: GridObjectFactoryType FactoryType;
444 typedef ALUMemoryProvider< ThisType > StorageType;
446 enum { dimension = GridImp::dimension };
447 enum { dimensionworld = GridImp::dimensionworld };
450 typedef typename ALU2dImplTraits< dimworld, eltype >::ThinelementType ThinelementType;
451 typedef typename BaseType::HElementType HElementType;
452 typedef typename ALU2dImplTraits< dimworld, eltype >::HBndElType HBndElType;
453 typedef typename ALU2dImplTraits< dimworld, eltype >::PeriodicBndElType PeriodicBndElType;
455 typedef std::pair< HElementType *, int > IntersectionInfo;
458 typedef typename GridImp::template Codim<0>::Entity Entity;
459 typedef typename GridImp::template Codim<1>::Geometry Geometry;
460 typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
461 typedef ALU2dGridEntity<0,dim,GridImp> EntityImp;
462 typedef ALU2dGridGeometry<dim-1,dimworld,GridImp> GeometryImp;
463 typedef ALU2dGridGeometry<dim-1,dim,GridImp> LocalGeometryImp;
464 typedef FieldVector<alu2d_ctype, dimworld> NormalType;
465 typedef ALU2dGridEntityPointer<0,GridImp> EntityPointer;
467 typedef MakeableInterfaceObject< Geometry > GeometryObject;
470 ALU2dGridLeafIntersectionIterator(
const FactoryType& factory,
int wLevel);
473 ALU2dGridLeafIntersectionIterator(
const FactoryType& factory,
const HElementType* el,
int wLevel,
bool end=
true);
476 ALU2dGridLeafIntersectionIterator(
const ALU2dGridLeafIntersectionIterator<GridImp> & org);
478 void assign (
const ALU2dGridLeafIntersectionIterator<GridImp> & org);
485 bool conforming ()
const
487 return (!this->grid().nonConform() || isConform());
491 bool isConform()
const
493 return (!current.outside() || (current.outside()->level() == current.inside()->level()) );
499 void setFirstItem(
const HElementType & elem,
int wLevel);
502 template <
class EntityType>
503 void first(
const EntityType & en,
int wLevel);
505 void setupIntersection ();
508 using BaseType::done;
510 using BaseType::current;
511 using BaseType::walkLevel_;
514 std::stack<IntersectionInfo> nbStack_;
520#include "intersection_imp.cc"
521#if COMPILE_ALU2DGRID_INLINE
522 #include "intersection.cc"
Definition: intersection.hh:102
void checkValid()
return true if intersection is with boundary
Definition: intersection_imp.cc:92
bool boundary() const
return true if intersection is with boundary
Definition: intersection_imp.cc:104
int twistInSelf() const
Definition: intersection.hh:261
int twistInNeighbor() const
Definition: intersection.hh:266
GeometryType type() const
obtain the type of reference element for this intersection
Definition: intersection_imp.cc:309
void assign(const ThisType &org)
The copy constructor.
Definition: intersection_imp.cc:50
EntityPointer inside() const
return EntityPointer to the Entity on the inside of this intersection.
Definition: intersection_imp.cc:140
size_t boundarySegmentIndex() const
return the boundary segment index
Definition: intersection_imp.cc:118
ALU2dGridIntersectionBase(const FactoryType &factory, int wLevel)
The default Constructor , creating an empty ALU2dGridIntersectionIterator.
Definition: intersection_imp.cc:28
int level() const
return level of inside(entity)
Definition: intersection_imp.cc:71
int indexInInside() const
local index of codim 1 entity in self where intersection is contained in
Definition: intersection_imp.cc:165
void first(const EntityImp &en, int wLevel)
reset IntersectionIterator to first neighbour
Definition: intersection_imp.cc:81
int boundaryId() const
return boundary type
Definition: intersection_imp.cc:110
Dune::Intersection< GridImp, Dune::ALU2dGridIntersectionBase< GridImp > > Intersection
type of the intersection
Definition: intersection.hh:115
bool equals(const ThisType &i) const
check whether entities are the same or whether iterator is done
Definition: intersection_imp.cc:63
int indexInOutside() const
local index of codim 1 entity in neighbor where intersection is contained in
Definition: intersection_imp.cc:176
EntityPointer outside() const
return EntityPointer to the Entity on the outside of this intersection.
Definition: intersection_imp.cc:157
bool neighbor() const
return true if intersection is with neighbor on this level
Definition: intersection_imp.cc:132
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Wrapper class for geometries.
Definition: geometry.hh:102
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.
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignment.hh:14
struct DUNE_DEPRECATED_MSG("Use class StaticPower from file power.hh instead") Power_m_p
Calculates m^p at compile time.
Definition: misc.hh:54