My Project
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 <opm/grid/polyhedralgrid/declaration.hh>
11
12namespace 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
54 : data_( ),
55 seed_(),
56 intersectionIdx_( -1 )
57 {}
58
59 PolyhedralGridIntersection ( ExtraData data, const EntitySeed& seed, const int intersectionIdx )
60 : data_( data ),
61 seed_( seed ),
62 intersectionIdx_( intersectionIdx )
63 {}
64
65 PolyhedralGridIntersection ( const This& other )
66 : data_( other.data_ ),
67 seed_( other.seed_ ),
68 intersectionIdx_( other.intersectionIdx_ )
69 {}
70
71 Entity inside () const
72 {
73 return Entity( EntityImpl( data(), seed_ ) );
74 }
75
76 Entity outside () const
77 {
78 return Entity( EntityImpl(data(),
79 data()->neighbor(seed_, intersectionIdx_)) );
80 }
81
83 {
84 data_ = other.data_;
85 seed_ = other.seed_;
86 intersectionIdx_ = other.intersectionIdx_;
87 return *this;
88 }
89
90 bool operator == ( const This& other ) const
91 {
92 return (seed_ == other.seed_) &&
93 (intersectionIdx_ == other.intersectionIdx_);
94 }
95
96 bool boundary () const { return !neighbor(); }
97
98 bool conforming () const { return false; }
99
100 bool neighbor () const { return data()->neighbor(seed_, intersectionIdx_).isValid(); }
101
102 int boundaryId () const { return 1; }
103
104 size_t boundarySegmentIndex () const
105 {
106 return data()->boundarySegmentIndex( seed_, intersectionIdx_);
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
125 {
126 return Dune::GeometryTypes::cube(dimension);
127 }
128
129 int indexInInside () const
130 {
131 return data()->indexInInside(seed_, intersectionIdx_);
132 }
133
134 int indexInOutside () const
135 {
136 return data()->indexInOutside(seed_, intersectionIdx_);
137 }
138
139 GlobalCoordinate
140 integrationOuterNormal ( const FieldVector< ctype, dimension-1 > &local ) const
141 {
142 return outerNormal( local );
143 }
144
145 GlobalCoordinate
146 outerNormal ( const FieldVector< ctype, dimension-1 > & ) const
147 { return outerNormal(); }
148
149 GlobalCoordinate outerNormal () const
150 { return data()->outerNormal(seed_, intersectionIdx_); }
151
152 GlobalCoordinate
153 unitOuterNormal ( const FieldVector< ctype, dimension-1 > & ) const
154 {
155 return centerUnitOuterNormal();
156 }
157
158 GlobalCoordinate
159 centerUnitOuterNormal () const
160 { return data()->unitOuterNormal(seed_, intersectionIdx_); }
161
162 ExtraData data() const { return data_; }
163
164 bool equals(const This& other) const
165 {
166 return seed_.equals(other.seed_) && intersectionIdx_ == other.intersectionIdx_;
167 }
168
169 // intersection id (here index of the face in the grid)
170 int id() const
171 {
172 // return face number of current intersection
173 return data()->template subEntitySeed<1>( seed_, intersectionIdx_).index();
174 }
175
176 protected:
177 ExtraData data_;
178 EntitySeed seed_;
179 public:
180 int intersectionIdx_; // the element-local index
181 };
182
183} // namespace Dune
184
185#endif // #ifndef DUNE_POLYHEDRALGRID_INTERSECTION_HH
Definition: intersection.hh:20
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10