1#ifndef DUNE_SPGRID_INTERSECTION_HH
2#define DUNE_SPGRID_INTERSECTION_HH
10#include <dune/grid/common/intersection.hh>
12#include <dune/grid/spgrid/geometry.hh>
13#include <dune/grid/spgrid/normal.hh>
21 template<
int,
int,
class >
35 template<
class Gr
id >
40 typedef typename std::remove_const< Grid >::type::Traits Traits;
42 typedef typename Traits::ReferenceCube ReferenceCube;
45 typedef typename ReferenceCube::ctype ctype;
47 static const int dimension = ReferenceCube::dimension;
48 static const int mydimension = dimension-1;
49 static const int dimensionworld = dimension;
57 typedef SPEntity< 0, dimension, Grid > EntityImpl;
58 typedef SPGeometry< mydimension, dimension, Grid > GeometryImpl;
61 typedef typename EntityImpl::EntityInfo ElementInfo;
62 typedef __SPGrid::EntityInfo< Grid, 1 > EntityInfo;
64 typedef typename EntityImpl::GridLevel GridLevel;
67 typedef SPNormalVector< ctype, dimensionworld > NormalVector;
72 typedef typename GridLevel::Mesh Mesh;
73 typedef typename GridLevel::PartitionList PartitionList;
74 typedef typename PartitionList::Partition Partition;
81 insideInfo_( insideInfo )
86 insideInfo_( entityInfo.gridLevel(), entityInfo.id() - normalId_, entityInfo.partitionNumber() )
89 bool boundary ()
const
91 return (insideInfo_.id()[ normalId_.axis() ] + normalId_.sign() == 2*gridLevel().globalMesh().bound( normalId_ ));
94 int boundaryId ()
const
96 return (boundary() ? (indexInInside()+1) : 0);
99 std::size_t boundarySegmentIndex ()
const
101 assert( boundary() );
102 return gridLevel().boundaryIndex( insideInfo_.id(), insideInfo_.partitionNumber(), normalId_.face() );
105 bool neighbor ()
const
107 const Partition &partition = gridLevel().template partition< All_Partition >().partition( insideInfo_.partitionNumber() );
108 return ((insideInfo_.id()[ normalId_.axis() ] + normalId_.sign() != partition.bound( normalId_ )) || partition.hasNeighbor( indexInInside() ));
111 Entity inside ()
const {
return Entity( EntityImpl( insideInfo_ ) ); }
113 Entity outside ()
const;
115 bool conforming ()
const
120 LocalGeometry geometryInInside ()
const
122 return gridLevel().grid().localFaceGeometry( indexInInside() );
125 LocalGeometry geometryInOutside ()
const
127 return gridLevel().grid().localFaceGeometry( indexInOutside() );
130 Geometry geometry ()
const
132 return Geometry( GeometryImpl( entityInfo() ) );
137 int indexInInside ()
const {
return normalId_.face(); }
138 int indexInOutside ()
const {
return (-normalId_).face(); }
140 NormalVector outerNormal (
const LocalVector &local )
const
142 return unitOuterNormal( local );
145 NormalVector integrationOuterNormal (
const LocalVector &local )
const
147 return gridLevel().faceVolume( indexInInside() ) * centerUnitOuterNormal();
150 NormalVector centerUnitOuterNormal ()
const {
return normalId_; }
152 NormalVector unitOuterNormal (
const LocalVector &local )
const {
return normalId_; }
154 bool equals (
const This &other )
const
156 return (indexInInside() == other.indexInInside()) && insideInfo_.equals( other.insideInfo_ );
159 const GridLevel &gridLevel ()
const {
return insideInfo_.gridLevel(); }
161 void setInside (
const ElementInfo &insideInfo ) { insideInfo_ = insideInfo; }
163 void setEntityInfo (
const EntityInfo &entityInfo )
165 insideInfo_ = ElementInfo( entityInfo.gridLevel(), entityInfo.id() - normalId_, entityInfo.partitionNumber() );
168 EntityInfo entityInfo ()
const
170 return EntityInfo( gridLevel(), insideInfo_.id() + normalId_, insideInfo_.partitionNumber() );
174 SPNormalId< dimension > normalId_;
175 ElementInfo insideInfo_;
183 template<
class Gr
id >
184 inline typename SPIntersection< Grid >::Entity
187 MultiIndex
id = insideInfo_.id() + normalId_ + normalId_;
189 return Entity( EntityImpl( ElementInfo( gridLevel(),
id, insideInfo_.partitionNumber() ) ) );
191 const PartitionList &allPartition = gridLevel().template partition< All_Partition >();
192 const Partition &partition = allPartition.partition( insideInfo_.partitionNumber() );
194 assert( partition.hasNeighbor( indexInInside() ) );
195 const Partition &nbPartition = allPartition.partition( partition.neighbor( indexInInside() ) );
198 const int bound = nbPartition.bound( -normalId_ );
199 id[ normalId_.axis() ] = bound + normalId_.sign()*(1 - (bound & 1));
200 return Entity( EntityImpl( ElementInfo( gridLevel(),
id, nbPartition.number() ) ) );
Wrapper class for entities.
Definition: entity.hh:66
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:125
Definition: intersection.hh:37
Traits for type conversions and type information.
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:472
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
A unique label for each type of element that can occur in a grid.