dune-fem 2.12-git
Loading...
Searching...
No Matches
geogridpart/intersection.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_INTERSECTION_HH
2#define DUNE_FEM_GRIDPART_GEOGRIDPART_INTERSECTION_HH
3
4#include <type_traits>
5#include <utility>
6
8
9namespace Dune
10{
11
12 namespace Fem
13 {
14
15 // GeoIntersection
16 // --------------
17
18 template< class GridFamily >
20 {
22
23 public:
25
28
29 typedef typename Traits::template Codim< 0 >::Entity Entity;
30 typedef typename Traits::template Codim< 0 >::Geometry ElementGeometry;
31 typedef typename Traits::template Codim< 1 >::Geometry Geometry;
32 typedef typename Traits::template Codim< 1 >::LocalGeometry LocalGeometry;
33
34 typedef typename Traits::CoordFunctionType CoordFunctionType;
35
36 private:
37 typedef typename Entity::Implementation EntityImplType;
38 typedef typename ElementGeometry::Implementation ElementGeometryImplType;
39 typedef typename Geometry::Implementation GeometryImplType;
40
41 typedef typename Traits::HostGridPartType HostGridPartType;
42 typedef typename HostGridPartType::IntersectionType HostIntersectionType;
43
45
46 public:
47 GeoIntersection ( const CoordFunctionType &coordFunction, const ElementGeometry &insideGeo, HostIntersectionType hostIntersection )
48 : coordFunction_( &coordFunction ),
49 insideGeo_( insideGeo.impl() ),
50 hostIntersection_( std::move( hostIntersection ) )
51 {}
52
54 : coordFunction_( nullptr ),
55 insideGeo_(),
56 hostIntersection_()
57 {}
58
59 Entity inside () const
60 {
61 return Entity( EntityImplType( coordFunction(), hostIntersection().inside() ) );
62 }
63
64 Entity outside () const
65 {
66 return Entity( EntityImplType( coordFunction(), hostIntersection().outside() ) );
67 }
68
69 bool boundary () const
70 {
71 return hostIntersection().boundary();
72 }
73
74 bool conforming () const
75 {
76 return hostIntersection().conforming();
77 }
78
79 bool neighbor () const
80 {
81 return hostIntersection().neighbor();
82 }
83
84 int boundaryId () const
85 {
86 return hostIntersection().boundaryId();
87 }
88
89 size_t boundarySegmentIndex () const
90 {
91 return hostIntersection().boundarySegmentIndex();
92 }
93
95 {
96 return hostIntersection().geometryInInside();
97 }
98
100 {
101 return hostIntersection().geometryInOutside();
102 }
103
105 {
106 const LocalGeometry &localGeo = geometryInInside();
107 CoordVectorType coords( insideGeo_, localGeo );
108 return Geometry( GeometryImplType( type(), coords ) );
109 }
110
112 {
113 return hostIntersection().type();
114 }
115
116 int indexInInside () const
117 {
118 return hostIntersection().indexInInside();
119 }
120
121 int indexInOutside () const
122 {
123 return hostIntersection().indexInOutside();
124 }
125
128 {
129 auto refElement = referenceElement< ctype, dimension>( insideGeo_.type() );
130
132 typedef typename ElementGeometryImplType::JacobianInverseTransposed JacobianInverseTransposed;
133 const JacobianInverseTransposed &jit = insideGeo_.jacobianInverseTransposed( x );
134 const FieldVector< ctype, dimension > &refNormal = refElement.integrationOuterNormal( indexInInside() );
135
137 jit.mv( refNormal, normal );
138 normal *= ctype( 1 ) / jit.det();
139 return normal;
140 }
141
144 {
145 auto refElement = referenceElement< ctype, dimension>( insideGeo_.type() );
146
148 typedef typename ElementGeometryImplType::JacobianInverseTransposed JacobianInverseTransposed;
149 const JacobianInverseTransposed &jit = insideGeo_.jacobianInverseTransposed( x );
150 const FieldVector< ctype, dimension > &refNormal = refElement.integrationOuterNormal( indexInInside() );
151
153 jit.mv( refNormal, normal );
154 return normal;
155 }
156
159 {
161 normal *= (ctype( 1 ) / normal.two_norm());
162 return normal;
163 }
164
166 {
167 auto refFace = referenceElement< ctype, dimension-1 >( type() );
168 return unitOuterNormal( refFace.position( 0, 0 ) );
169 }
170
172 {
173 assert( coordFunction_ );
174 return *coordFunction_;
175 }
176
177 const HostIntersectionType &hostIntersection () const
178 {
179 return hostIntersection_;
180 }
181
182 private:
183 const CoordFunctionType *coordFunction_ = nullptr;
184 ElementGeometryImplType insideGeo_;
185 HostIntersectionType hostIntersection_;
186 };
187
188 } // namespace Fem
189
190} // namespace Dune
191
192#endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_INTERSECTION_HH
unspecified value type referenceElement(T &&... t)
const GlobalIndex & global() const
LocalIndex & local()
STL namespace.
constexpr FieldTraits< value_type >::real_type two_norm() const
GeometryImp< mydim, cdim, GridImp > Implementation
Definition cornerstorage.hh:234
Definition geogridpart/intersection.hh:20
FieldVector< ctype, dimensionworld > unitOuterNormal(const FieldVector< ctype, dimension-1 > &local) const
Definition geogridpart/intersection.hh:158
bool neighbor() const
Definition geogridpart/intersection.hh:79
static const int dimensionworld
Definition geogridpart/intersection.hh:27
std::remove_const< GridFamily >::type::ctype ctype
Definition geogridpart/intersection.hh:24
bool conforming() const
Definition geogridpart/intersection.hh:74
LocalGeometry geometryInInside() const
Definition geogridpart/intersection.hh:94
Entity outside() const
Definition geogridpart/intersection.hh:64
int indexInInside() const
Definition geogridpart/intersection.hh:116
int boundaryId() const
Definition geogridpart/intersection.hh:84
GeoIntersection(const CoordFunctionType &coordFunction, const ElementGeometry &insideGeo, HostIntersectionType hostIntersection)
Definition geogridpart/intersection.hh:47
FieldVector< ctype, dimensionworld > centerUnitOuterNormal() const
Definition geogridpart/intersection.hh:165
FieldVector< ctype, dimensionworld > outerNormal(const FieldVector< ctype, dimension-1 > &local) const
Definition geogridpart/intersection.hh:143
const CoordFunctionType & coordFunction() const
Definition geogridpart/intersection.hh:171
LocalGeometry geometryInOutside() const
Definition geogridpart/intersection.hh:99
Traits::template Codim< 0 >::Entity Entity
Definition geogridpart/intersection.hh:29
bool boundary() const
Definition geogridpart/intersection.hh:69
Traits::template Codim< 1 >::LocalGeometry LocalGeometry
Definition geogridpart/intersection.hh:32
Geometry geometry() const
Definition geogridpart/intersection.hh:104
const HostIntersectionType & hostIntersection() const
Definition geogridpart/intersection.hh:177
Traits::CoordFunctionType CoordFunctionType
Definition geogridpart/intersection.hh:34
GeometryType type() const
Definition geogridpart/intersection.hh:111
Entity inside() const
Definition geogridpart/intersection.hh:59
int indexInOutside() const
Definition geogridpart/intersection.hh:121
FieldVector< ctype, dimensionworld > integrationOuterNormal(const FieldVector< ctype, dimension-1 > &local) const
Definition geogridpart/intersection.hh:127
Traits::template Codim< 0 >::Geometry ElementGeometry
Definition geogridpart/intersection.hh:30
static const int dimension
Definition geogridpart/intersection.hh:26
GeoIntersection()
Definition geogridpart/intersection.hh:53
Traits::template Codim< 1 >::Geometry Geometry
Definition geogridpart/intersection.hh:31
size_t boundarySegmentIndex() const
Definition geogridpart/intersection.hh:89