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