DUNE-FEM (unstable)

twistutility.hh
1#ifndef DUNE_FEM_TWISTUTILITY_HH
2#define DUNE_FEM_TWISTUTILITY_HH
3
4#include <cassert>
5
7
9
10#include <dune/grid/utility/hostgridaccess.hh>
11
12// this also includes the forward declarations
13#include <dune/fem/misc/capabilities.hh>
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 template< class Intersection >
22 struct GridIntersectionAccess;
23
24 template< class Grid, class IntersectionImpl >
25 struct GridIntersectionAccess< Dune::Intersection< const Grid, IntersectionImpl > >
26 {
28 typedef IntersectionType GridIntersectionType;
29
30 static const GridIntersectionType &gridIntersection ( const IntersectionType &isec )
31 {
32 return isec;
33 }
34 };
35
36 template< class Intersection >
37 const typename GridIntersectionAccess< Intersection >::GridIntersectionType &
38 gridIntersection ( const Intersection &isec )
39 {
40 return GridIntersectionAccess< Intersection >::gridIntersection( isec );
41 }
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 {
241 typedef GeometryGrid< HostGrid, CoordFunction, Allocator > GridType;
242 typedef typename GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator;
243 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
244 typedef typename GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator;
245 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
246
247 private:
248 typedef TwistUtility< HostGrid > HostTwistUtility;
249 typedef Dune::HostGridAccess< GridType > HostGridAccess;
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
[ provides Dune::Grid ]
Definition: agrid.hh:109
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Grid abstract base class.
Definition: grid.hh:375
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
GridFamily::Traits::LeafIntersectionIterator LeafIntersectionIterator
A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine,...
Definition: grid.hh:468
GridFamily::Traits::LevelIntersectionIterator LevelIntersectionIterator
A type that is a model of Dune::IntersectionIterator which is an iterator that allows to examine,...
Definition: grid.hh:475
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
Entity outside() const
return Entity on the outside of this intersection. That is the neighboring Entity.
Definition: intersection.hh:261
Entity inside() const
return Entity on the inside of this intersection. That is the Entity where we started this.
Definition: intersection.hh:250
Various macros to work with Dune module version numbers.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:453
Dune namespace.
Definition: alignedallocator.hh:13
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:27
TwistFreeTwistUtility provides the default implementation for twistfree grid such as Cartesian grids.
Definition: twistutility.hh:49
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
static int twistInNeighbor(const GridType &grid, const LeafIntersection &it)
return twist for outer face
Definition: twistutility.hh:134
static GeometryType elementGeometry(const Intersection &intersection, const bool inside)
return element geometry type of inside or outside entity
Definition: twistutility.hh:143
static int twistInSelf(const GridType &grid, const LeafIntersection &it)
return twist for inner face
Definition: twistutility.hh:128
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition: twistutility.hh:107
provides access to host grid objects from GeometryGrid
Definition: identitygrid.hh:37
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)