DUNE-FEM (unstable)

intersection.hh
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
7#include <dune/fem/gridpart/geogridpart/cornerstorage.hh>
8
9namespace Dune
10{
11
12 namespace Fem
13 {
14
15 // GeoIntersection
16 // --------------
17
18 template< class GridFamily >
19 class GeoIntersection
20 {
21 typedef typename std::remove_const< GridFamily >::type::Traits Traits;
22
23 public:
24 typedef typename std::remove_const< GridFamily >::type::ctype ctype;
25
26 static const int dimension = std::remove_const< GridFamily >::type::dimension;
27 static const int dimensionworld = std::remove_const< GridFamily >::type::dimensionworld;
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
44 typedef GeoIntersectionCoordVector< GridFamily > CoordVectorType;
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
53 GeoIntersection ()
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
94 LocalGeometry geometryInInside () const
95 {
96 return hostIntersection().geometryInInside();
97 }
98
99 LocalGeometry geometryInOutside () const
100 {
101 return hostIntersection().geometryInOutside();
102 }
103
104 Geometry geometry () const
105 {
106 const LocalGeometry &localGeo = geometryInInside();
107 CoordVectorType coords( insideGeo_, localGeo );
108 return Geometry( GeometryImplType( type(), coords ) );
109 }
110
111 GeometryType type () const
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
126 FieldVector< ctype, dimensionworld >
127 integrationOuterNormal ( const FieldVector< ctype, dimension-1 > &local ) const
128 {
129 auto refElement = referenceElement< ctype, dimension>( insideGeo_.type() );
130
131 FieldVector< ctype, dimension > x( geometryInInside().global( local ) );
132 typedef typename ElementGeometryImplType::JacobianInverseTransposed JacobianInverseTransposed;
133 const JacobianInverseTransposed &jit = insideGeo_.jacobianInverseTransposed( x );
134 const FieldVector< ctype, dimension > &refNormal = refElement.integrationOuterNormal( indexInInside() );
135
136 FieldVector< ctype, dimensionworld > normal;
137 jit.mv( refNormal, normal );
138 normal *= ctype( 1 ) / jit.det();
139 return normal;
140 }
141
142 FieldVector< ctype, dimensionworld >
143 outerNormal ( const FieldVector< ctype, dimension-1 > &local ) const
144 {
145 auto refElement = referenceElement< ctype, dimension>( insideGeo_.type() );
146
147 FieldVector< ctype, dimension > x( geometryInInside().global( local ) );
148 typedef typename ElementGeometryImplType::JacobianInverseTransposed JacobianInverseTransposed;
149 const JacobianInverseTransposed &jit = insideGeo_.jacobianInverseTransposed( x );
150 const FieldVector< ctype, dimension > &refNormal = refElement.integrationOuterNormal( indexInInside() );
151
152 FieldVector< ctype, dimensionworld > normal;
153 jit.mv( refNormal, normal );
154 return normal;
155 }
156
157 FieldVector< ctype, dimensionworld >
158 unitOuterNormal ( const FieldVector< ctype, dimension-1 > &local ) const
159 {
160 FieldVector< ctype, dimensionworld > normal = outerNormal( local );
161 normal *= (ctype( 1 ) / normal.two_norm());
162 return normal;
163 }
164
165 FieldVector< ctype, dimensionworld > centerUnitOuterNormal () const
166 {
167 auto refFace = referenceElement< ctype, dimension-1 >( type() );
168 return unitOuterNormal( refFace.position( 0, 0 ) );
169 }
170
171 const CoordFunctionType &coordFunction () const
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
EntityImp< cd, dim, GridImp > Implementation
type of underlying implementation
Definition: entity.hh:73
GeometryImp< mydim, cdim, GridImp > Implementation
type of underlying implementation
Definition: geometry.hh:78
@ conforming
Output conforming data.
Definition: common.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
unspecified value type referenceElement(T &&... t)
Returns a reference element for the objects t....
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)