dune-fem 2.12-git
Loading...
Searching...
No Matches
geometrygridpart/intersection.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_INTERSECTION_HH
2#define DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_INTERSECTION_HH
3
4#include <type_traits>
5
7
12
13namespace Dune
14{
15
16 namespace Fem
17 {
18
19 // GeometryGridPartIntersection
20 // ----------------------------
21
22 template< class GridFamily >
24 {
27
28 public:
30
33
34 typedef typename Traits::template Codim< 0 >::Entity Entity;
35 typedef typename Traits::template Codim< 0 >::Geometry ElementGeometry;
36 typedef typename Traits::template Codim< 1 >::Geometry Geometry;
37 typedef typename Traits::template Codim< 1 >::LocalGeometry LocalGeometry;
38
39 typedef typename Traits::GridFunctionType GridFunctionType;
40
43
44 private:
45 typedef typename Geometry::Implementation GeometryImplType;
46
47 typedef typename Traits::HostGridPartType HostGridPartType;
48 typedef typename HostGridPartType::IntersectionType HostIntersectionType;
49
50 public:
52 GeometryGridPartIntersection ( const GridFunctionType &gridFunction, const typename ElementGeometry::Implementation &insideGeo, HostIntersectionType hostIntersection )
53 : hostIntersection_( std::move( hostIntersection ) ), gridFunction_( &gridFunction ), insideGeo_( insideGeo )
54 {}
55
56 operator bool () const { return bool( hostIntersection_ ); }
57
58 Entity inside () const { return Entity( typename Entity::Implementation( gridFunction(), hostIntersection().inside() )); }
59 Entity outside () const { return Entity( typename Entity::Implementation( gridFunction(), hostIntersection().outside() )); }
60
64
65 bool boundary () const { return hostIntersection().boundary(); }
66
67 bool conforming () const { return hostIntersection().conforming(); }
68
69 int twistInSelf() const { return hostIntersection().impl().twistInSelf(); }
70
71 int twistInNeighbor() const { return hostIntersection().impl().twistInNeighbor(); }
72
73 bool neighbor () const { return hostIntersection().neighbor(); }
74
75 std::size_t boundarySegmentIndex () const { return hostIntersection().boundarySegmentIndex(); }
76
77 LocalGeometry geometryInInside () const { return hostIntersection().geometryInInside(); }
78 LocalGeometry geometryInOutside () const { return hostIntersection().geometryInOutside(); }
79
81 {
82 typedef typename Geometry::Implementation Impl;
83 return Geometry( Impl( insideGeo_, geometryInInside(), 2*insideGeo_.impl().localFunction().order()+1 ) );
84 }
85
86 bool equals ( const This &other ) const { return hostIntersection() == other.hostIntersection(); }
87
88 GeometryType type () const { return hostIntersection().type(); }
89
90 int indexInInside () const { return hostIntersection().indexInInside(); }
91 int indexInOutside () const { return hostIntersection().indexInOutside(); }
92
94 {
95 const auto &refElement = ReferenceElements< ctype, dimension >::general( insideGeo_.type() );
96 const auto &refNormal = refElement.integrationOuterNormal( indexInInside() );
97
98 const auto jit = insideGeo_.jacobianInverseTransposed( geometryInInside().global( local ) );
99
100 GlobalCoordinate normal;
101 jit.mv( refNormal, normal );
102 // double det = std::sqrt( GeometryGridPartGeometryType::MatrixHelper::template detATA<dimensionworld,dimension>( jit ) );
103 // return normal *= ctype( 1 ) / sqrt(det);
104 return normal *= geometry().integrationElement( local ) / normal.two_norm();
105
106#if 0
110FieldMatrix< ctype, 1, dimensionworld > tauT = geometry().jacobianTransposed(local);
111
112for (int i = 0; i != dimensionworld; ++i)
113 tau[i] = tauT[0][i];
114
115tau /= tau.two_norm();
116
118gridFunction().localFunction(*hostIntersection().inside()).jacobian(x, localFnGrad);
119
120for (int i = 0; i != dimensionworld; ++i)
121 for (int j = 0; j != dimensionworld; ++j )
122 localFnGradT[i][j] = localFnGrad[j][i];
123
124crossProduct(localFnGradT[0], localFnGradT[1], nu );
125nu /= nu.two_norm();
126
127/*
128nu = insideGeo_.global(x);
129nu /= nu.two_norm();
130*/
131
132crossProduct(nu, tau, normal);
133
134// get conormal in same direction as discrete conormal
136 normal *= -1;
137
138// normal /= normal.two_norm();
139// normal *= GeometryImplType(insideGeo_, gridFunction_, hostIntersection_, affineGeometry).integrationElement(local);
140normal *= geometry().integrationElement(local)/normal.two_norm();
141 // return hostIntersection().integrationOuterNormal(local);
142 return normal;
143#endif
144 }
145
146#if 0
148 {
149 assert( dimensionworld == 3 );
150
151 ret[0] = vec1[1]*vec2[2] - vec1[2]*vec2[1];
152 ret[1] = vec1[2]*vec2[0] - vec1[0]*vec2[2];
153 ret[2] = vec1[0]*vec2[1] - vec1[1]*vec2[0];
154 }
155#endif
156
158 {
159 const auto &refElement = Dune::ReferenceElements< ctype, dimension >::general( insideGeo_.type() );
160 const auto &refNormal = refElement.integrationOuterNormal( indexInInside() );
161
162 GlobalCoordinate normal;
163 insideGeo_.jacobianInverseTransposed( geometryInInside().global( local ) ).mv( refNormal, normal );
164 return normal;
165 }
166
168 {
170 return normal *= (ctype( 1 ) / normal.two_norm());
171 }
172
174 {
175 const auto &refElement = Dune::ReferenceElements< ctype, dimension >::general( insideGeo_.type() );
176 const auto &refNormal = refElement.integrationOuterNormal( indexInInside() );
177
178 GlobalCoordinate normal;
179 insideGeo_.jacobianInverseTransposed( geometryInInside().center() ).mv( refNormal, normal );
180 return normal *= (ctype( 1 ) / normal.two_norm());
181 }
182
183 const HostIntersectionType &hostIntersection () const { return hostIntersection_; }
184
186 {
187 assert( gridFunction_ );
188 return *gridFunction_;
189 }
190
191 private:
192 HostIntersectionType hostIntersection_;
193 const GridFunctionType *gridFunction_ = nullptr;
194 typename ElementGeometry::Implementation insideGeo_;
195 };
196
197 } // namespace Fem
198
199} // namespace Dune
200
201#endif // #ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_INTERSECTION_HH
const GlobalIndex & global() const
LocalIndex & local()
STL namespace.
constexpr FieldTraits< value_type >::real_type two_norm() const
GeometryImp< mydim, cdim, GridImp > Implementation
Definition geometrygridpart/intersection.hh:24
Traits::template Codim< 1 >::LocalGeometry LocalGeometry
Definition geometrygridpart/intersection.hh:37
Geometry geometry() const
Definition geometrygridpart/intersection.hh:80
GeometryGridPartIntersection(const GridFunctionType &gridFunction, const typename ElementGeometry::Implementation &insideGeo, HostIntersectionType hostIntersection)
Definition geometrygridpart/intersection.hh:52
int indexInOutside() const
Definition geometrygridpart/intersection.hh:91
bool boundary() const
Definition geometrygridpart/intersection.hh:65
FieldVector< ctype, dimensionworld > GlobalCoordinate
Definition geometrygridpart/intersection.hh:41
FieldVector< ctype, dimension-1 > LocalCoordinate
Definition geometrygridpart/intersection.hh:42
int twistInNeighbor() const
Definition geometrygridpart/intersection.hh:71
static const int dimension
Definition geometrygridpart/intersection.hh:31
Traits::template Codim< 0 >::Geometry ElementGeometry
Definition geometrygridpart/intersection.hh:35
LocalGeometry geometryInOutside() const
Definition geometrygridpart/intersection.hh:78
Traits::template Codim< 0 >::Entity Entity
Definition geometrygridpart/intersection.hh:34
int indexInInside() const
Definition geometrygridpart/intersection.hh:90
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
Definition geometrygridpart/intersection.hh:93
static const int dimensionworld
Definition geometrygridpart/intersection.hh:32
GlobalCoordinate centerUnitOuterNormal() const
Definition geometrygridpart/intersection.hh:173
bool equals(const This &other) const
Definition geometrygridpart/intersection.hh:86
LocalGeometry geometryInInside() const
Definition geometrygridpart/intersection.hh:77
bool conforming() const
Definition geometrygridpart/intersection.hh:67
const GridFunctionType & gridFunction() const
Definition geometrygridpart/intersection.hh:185
std::size_t boundarySegmentIndex() const
Definition geometrygridpart/intersection.hh:75
std::remove_const< GridFamily >::type::ctype ctype
Definition geometrygridpart/intersection.hh:29
Entity inside() const
Definition geometrygridpart/intersection.hh:58
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Definition geometrygridpart/intersection.hh:167
GeometryType type() const
Definition geometrygridpart/intersection.hh:88
Traits::template Codim< 1 >::Geometry Geometry
Definition geometrygridpart/intersection.hh:36
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Definition geometrygridpart/intersection.hh:157
Entity outside() const
Definition geometrygridpart/intersection.hh:59
Traits::GridFunctionType GridFunctionType
Definition geometrygridpart/intersection.hh:39
const HostIntersectionType & hostIntersection() const
Definition geometrygridpart/intersection.hh:183
bool neighbor() const
Definition geometrygridpart/intersection.hh:73
int twistInSelf() const
Definition geometrygridpart/intersection.hh:69
int boundaryId() const
Definition geometrygridpart/intersection.hh:61
Definition boundaryidprovider.hh:27