All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
intersection.hh
1 // -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=2 sw=2 sts=2:
3 #ifndef DUNE_POLYHEDRALGRID_INTERSECTION_HH
4 #define DUNE_POLYHEDRALGRID_INTERSECTION_HH
5 
6 //- dune-common includes
7 #include <dune/common/version.hh>
8 
9 //- local includes
10 #include <dune/grid/polyhedralgrid/declaration.hh>
11 
12 namespace Dune
13 {
14 
15  // PolyhedralGridIntersection
16  // ------------------
17 
18  template< class Grid >
20  {
22  protected:
23  typedef typename Grid :: Traits Traits;
24 
25  typedef typename Traits :: ExtraData ExtraData ;
26 
27  public:
28  typedef typename Traits::ctype ctype;
29  typedef typename Traits::GlobalCoordinate GlobalCoordinate;
30 
31  static const int dimension = Traits::dimension;
32  static const int dimensionworld = Traits::dimensionworld;
33 
34  typedef typename Traits::template Codim< 0 >::Entity Entity;
35  typedef typename Traits::template Codim< 0 >::EntityPointer EntityPointer;
36  typedef typename Traits::template Codim< 0 >::EntitySeed EntitySeed;
37  typedef typename Traits::template Codim< 1 >::Geometry Geometry;
38  typedef typename Traits::template Codim< 1 >::LocalGeometry LocalGeometry;
39 
40  protected:
41  typedef typename Traits::template Codim< 0 >::EntityPointerImpl EntityPointerImpl;
42  typedef typename Traits::template Codim< 0 >::EntityImpl EntityImpl;
43  typedef typename Traits::template Codim< 1 >::GeometryImpl GeometryImpl;
44  typedef typename Traits::template Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
45 
46  public:
47  explicit PolyhedralGridIntersection ( ExtraData data )
48  : data_( data ),
49  seed_(),
50  intersectionIdx_( -1 )
51  {}
52 
53  PolyhedralGridIntersection ( ExtraData data, const EntitySeed& seed, const int intersectionIdx )
54  : data_( data ),
55  seed_( seed ),
56  intersectionIdx_( intersectionIdx )
57  {}
58 
59  PolyhedralGridIntersection ( const This& other )
60  : data_( other.data_ ),
61  seed_( other.seed_ ),
62  intersectionIdx_( other.intersectionIdx_ )
63  {}
64 
65 #if DUNE_VERSION_NEWER(DUNE_GRID,2,4)
66  Entity inside () const
67  {
68  return Entity( EntityImpl( data(), seed_ ) );
69  }
70 
71  Entity outside () const
72  {
73  return Entity( EntityImpl(data(),
74  data()->neighbor(seed_, intersectionIdx_)) );
75  }
76 #else
77  EntityPointer inside () const
78  {
79  return EntityPointer( EntityPointerImpl( EntityImpl( data(), seed_ ) ) );
80  }
81 
82  EntityPointer outside () const
83  {
84  return EntityPointer( EntityPointerImpl( EntityImpl(data(),
85  data()->neighbor(seed_, intersectionIdx_)) ) );
86  }
87 #endif
88 
89  bool operator == ( const This& other ) const
90  {
91  return (seed_ == other.seed_) &&
92  (intersectionIdx_ == other.intersectionIdx_);
93  }
94 
95  bool boundary () const { return !neighbor(); }
96 
97  bool conforming () const { return false; }
98 
99  bool neighbor () const { return data()->neighbor(seed_, intersectionIdx_).isValid(); }
100 
101  int boundaryId () const { return 1; }
102 
103  size_t boundarySegmentIndex () const
104  {
105  // not implementable
106  return -1;
107  }
108 
109  LocalGeometry geometryInInside () const
110  {
111  return LocalGeometry( LocalGeometryImpl( data() ) );
112  }
113 
114  LocalGeometry geometryInOutside () const
115  {
116  return LocalGeometry( LocalGeometryImpl( data() ) );
117  }
118 
119  Geometry geometry () const
120  {
121  return Geometry( GeometryImpl(data(), data()->template subEntitySeed<1>(seed_, intersectionIdx_)));
122  }
123 
124  GeometryType type () const { return GeometryType(GeometryType::cube, dimension); }
125 
126  int indexInInside () const
127  {
128  return data()->indexInInside(seed_, intersectionIdx_);
129  }
130 
131  int indexInOutside () const
132  {
133  return data()->indexInOutside(seed_, intersectionIdx_);
134  }
135 
136  GlobalCoordinate
137  integrationOuterNormal ( const FieldVector< ctype, dimension-1 > &local ) const
138  {
139  return outerNormal( local );
140  }
141 
142  GlobalCoordinate
143  outerNormal ( const FieldVector< ctype, dimension-1 > & ) const
144  { return outerNormal(); }
145 
146  GlobalCoordinate outerNormal () const
147  { return data()->outerNormal(seed_, intersectionIdx_); }
148 
149  GlobalCoordinate
150  unitOuterNormal ( const FieldVector< ctype, dimension-1 > & ) const
151  {
152  return centerUnitOuterNormal();
153  }
154 
155  GlobalCoordinate
156  centerUnitOuterNormal () const
157  { return data()->unitOuterNormal(seed_, intersectionIdx_); }
158 
159  ExtraData data() const { return data_; }
160 
161  bool equals(const This& other) const
162  {
163  return seed_.equals(other.seed_) && intersectionIdx_ == other.intersectionIdx_;
164  }
165 
166  // intersection id (here index of the face in the grid)
167  int id() const
168  {
169  // return face number of current intersection
170  return data()->template subEntitySeed<1>( seed_, intersectionIdx_).index();
171  }
172 
173  protected:
174  ExtraData data_;
175  EntitySeed seed_;
176  public:
177  int intersectionIdx_; // the element-local index
178  };
179 
180 } // namespace Dune
181 
182 #endif // #ifndef DUNE_POLYHEDRALGRID_INTERSECTION_HH
Definition: intersection.hh:19