dune-fem 2.12-git
Loading...
Searching...
No Matches
twistutility.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_TWISTUTILITY_HH
2#define DUNE_FEM_TWISTUTILITY_HH
3
4#include <cassert>
5
7
9
11
12// this also includes the forward declarations
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 template< class Intersection >
23
24 template< class Grid, class IntersectionImpl >
25 struct GridIntersectionAccess< Dune::Intersection< const Grid, IntersectionImpl > >
26 {
29
31 {
32 return isec;
33 }
34 };
35
36 template< class Intersection >
37 const typename GridIntersectionAccess< Intersection >::GridIntersectionType &
42
43
47 template< class Grid >
49 {
50 typedef Grid GridType;
51
53 template< class Intersection >
54 static int twistInSelf ( const GridType &, const Intersection & )
55 {
56 return 0;
57 }
58
60 template< class Intersection >
61 static int twistInNeighbor ( const GridType &, const Intersection & )
62 {
63 return 0;
64 }
65
67 template< class Intersection >
68 static GeometryType elementGeometry ( const Intersection &intersection, const bool inside )
69 {
71 if( hasSingleGeometryType::v )
72 return GeometryType( hasSingleGeometryType::topologyId, GridType::dimension );
73 else
74 return inside ? intersection.inside().type() : intersection.outside().type();
75 }
76 };
77
78
79
104 template< class Grid >
106 : public TwistFreeTwistUtility< Grid >
107 {};
108
109 // Specialization for AlbertaGrid
110 // ------------------------------
111
112#if HAVE_ALBERTA
115 template< int dim, int dimW >
116 struct TwistUtility< AlbertaGrid< dim, dimW > >
117 {
119 typedef typename GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator;
120 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
121 typedef typename GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator;
122 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
123
124 static const int dimension = GridType::dimension;
125
126 public:
128 static int twistInSelf ( const GridType &grid, const LeafIntersection &it )
129 {
130 return grid.getTwistInInside( it );
131 }
132
134 static int twistInNeighbor ( const GridType &grid, const LeafIntersection &it )
135 {
136 return grid.getTwistInOutside( it );
137 }
138
141 template <class Intersection>
142 static inline GeometryType
143 elementGeometry(const Intersection& intersection,
144 const bool inside)
145 {
146 return Dune::GeometryTypes::simplex(dimension);
147 }
148 };
149#endif // #if HAVE_ALBERTA
150
151
152
153 // Specialization for ALUGrid
154 // --------------------------
155
156#if HAVE_DUNE_ALUGRID
159 template< int dim, int dimw, ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
160 struct TwistUtility< ALUGrid< dim, dimw, elType, refineType, Comm > >
161 {
162 typedef ALUGrid< dim, dimw, elType, refineType, Comm > GridType;
163
164 public:
166 template< class Intersection >
167 static inline int twistInSelf(const GridType & grid, const Intersection& isec)
168 {
169 const auto& intersection = gridIntersection( isec );
170 assert( dim == 2 ? (intersection.impl().twistInInside() == 0 ||
171 intersection.impl().twistInInside() == 1 ) : true );
172 return intersection.impl().twistInInside();
173 }
174
176 template< class Intersection >
177 static inline int twistInNeighbor(const GridType &grid, const Intersection& isec )
178 {
179 const auto& intersection = gridIntersection( isec );
180 assert( dim == 2 ? (intersection.impl().twistInOutside() == 0 ||
181 intersection.impl().twistInOutside() == 1 ) : true );
182 return intersection.impl().twistInOutside();
183 }
184
187 template <class Intersection>
188 static inline GeometryType
189 elementGeometry(const Intersection& intersection,
190 const bool inside)
191 {
193 dim );
194 }
195
196 private:
197 TwistUtility(const TwistUtility&);
198 TwistUtility& operator=(const TwistUtility&);
199 };
200#endif // #if HAVE_DUNE_ALUGRID
201
202
203
204 // Specialization for UGGrid
205 // -------------------------
206
207#if HAVE_UG
208 template< int dim >
209 struct TwistUtility< UGGrid< dim > >
210 {
211 typedef UGGrid< dim > GridType;
212
213 typedef typename GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator;
214 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
215 typedef typename GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator;
216 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
217
218 static int twistInSelf ( const GridType &grid, const LeafIntersection &it );
219 static int twistInSelf ( const GridType &grid, const LevelIntersection &it );
220
221 static int twistInNeighbor ( const GridType &grid, const LeafIntersection &it );
222 static int twistInNeighbor ( const GridType &grid, const LevelIntersection &it );
223
224 template< class Intersection >
225 static GeometryType
226 elementGeometry ( const Intersection &intersection, const bool inside )
227 {
228 return (inside ? intersection.inside().type() : intersection.outside().type());
229 }
230 };
231#endif // #ifdef ENABLE_UG
232
233
234
235 // Specialization for GeometryGrid
236 // -------------------------------
237
238 template< class HostGrid, class CoordFunction, class Allocator >
239 struct TwistUtility< GeometryGrid< HostGrid, CoordFunction, Allocator > >
240 {
243 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
245 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
246
247 private:
250
251 public:
253 template< class Intersection >
254 static int twistInSelf ( const GridType &grid, const Intersection &intersection )
255 {
256 return HostTwistUtility::twistInSelf( grid.hostGrid(), HostGridAccess::hostIntersection( intersection ) );
257 }
258
260 template< class Intersection >
261 static int twistInNeighbor ( const GridType &grid, const Intersection &intersection )
262 {
263 return HostTwistUtility::twistInNeighbor( grid.hostGrid(), HostGridAccess::hostIntersection( intersection ) );
264 }
265
267 template< class Intersection >
268 static GeometryType elementGeometry ( const Intersection &intersection, bool inside )
269 {
270 return HostTwistUtility::elementGeometry( HostGridAccess::hostIntersection( intersection ), inside );
271 }
272 };
273
274 } // namespace Fem
275
276} // namespace Dune
277
278#endif // #ifndef DUNE_FEM_TWISTUTILITY_HH
SLList< T, A > & operator=(const SLList< T, A > &other)
size_type dim() const
const GridIntersectionAccess< Intersection >::GridIntersectionType & gridIntersection(const Intersection &isec)
Definition twistutility.hh:38
Entity outside() const
Entity inside() const
static constexpr int dimension
GridFamily::Traits::LeafIntersectionIterator LeafIntersectionIterator
GridFamily::Traits::LevelIntersectionIterator LevelIntersectionIterator
Traits::LevelIntersectionIterator LevelIntersectionIterator
Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition twistutility.hh:22
Dune::Intersection< const Grid, IntersectionImpl > IntersectionType
Definition twistutility.hh:27
static const GridIntersectionType & gridIntersection(const IntersectionType &isec)
Definition twistutility.hh:30
TwistFreeTwistUtility provides the default implementation for twistfree grid such as Cartesian grids.
Definition twistutility.hh:49
Grid GridType
Definition twistutility.hh:50
static int twistInSelf(const GridType &, const Intersection &)
return 0 for inner face
Definition twistutility.hh:54
static GeometryType elementGeometry(const Intersection &intersection, const bool inside)
return geometry type of inside or outside entity
Definition twistutility.hh:68
static int twistInNeighbor(const GridType &, const Intersection &)
return 0 for outer face
Definition twistutility.hh:61
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition twistutility.hh:107
LevelIntersectionIterator::Intersection LevelIntersection
Definition twistutility.hh:245
GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator
Definition twistutility.hh:244
static int twistInSelf(const GridType &grid, const Intersection &intersection)
return twist for inner face
Definition twistutility.hh:254
LeafIntersectionIterator::Intersection LeafIntersection
Definition twistutility.hh:243
GeometryGrid< HostGrid, CoordFunction, Allocator > GridType
Definition twistutility.hh:241
static GeometryType elementGeometry(const Intersection &intersection, bool inside)
return element geometry type of inside or outside entity
Definition twistutility.hh:268
static int twistInNeighbor(const GridType &grid, const Intersection &intersection)
return twist for outer face
Definition twistutility.hh:261
GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition twistutility.hh:242