dune-fem 2.8.0
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
6#include <dune/common/version.hh>
7
8#include <dune/geometry/type.hh>
9
10#include <dune/grid/utility/hostgridaccess.hh>
11
12// this also includes the forward declarations
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
24 template< class Grid >
26 {
27 typedef Grid GridType;
28
30 template< class Intersection >
31 static int twistInSelf ( const GridType &, const Intersection & )
32 {
33 return 0;
34 }
35
37 template< class Intersection >
38 static int twistInNeighbor ( const GridType &, const Intersection & )
39 {
40 return 0;
41 }
42
44 template< class Intersection >
45 static GeometryType elementGeometry ( const Intersection &intersection, const bool inside )
46 {
47 typedef Dune::Capabilities::hasSingleGeometryType< GridType > hasSingleGeometryType;
48 if( hasSingleGeometryType::v )
49 return GeometryType( hasSingleGeometryType::topologyId, GridType::dimension );
50 else
51 return inside ? intersection.inside().type() : intersection.outside().type();
52 }
53 };
54
55
56
81 template< class Grid >
83 : public TwistFreeTwistUtility< Grid >
84 {};
85
86 // Specialization for AlbertaGrid
87 // ------------------------------
88
89#if HAVE_ALBERTA
92 template< int dim, int dimW >
93 struct TwistUtility< AlbertaGrid< dim, dimW > >
94 {
96 typedef typename GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator;
97 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
98 typedef typename GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator;
99 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
100
101 static const int dimension = GridType::dimension;
102
103 public:
105 static int twistInSelf ( const GridType &grid, const LeafIntersection &it )
106 {
107 return grid.getTwistInInside( it );
108 }
109
111 static int twistInNeighbor ( const GridType &grid, const LeafIntersection &it )
112 {
113 return grid.getTwistInOutside( it );
114 }
115
118 template <class Intersection>
119 static inline GeometryType
120 elementGeometry(const Intersection& intersection,
121 const bool inside)
122 {
123 return Dune::GeometryTypes::simplex(dimension);
124 }
125 };
126#endif // #if HAVE_ALBERTA
127
128
129
130 // Specialization for ALUGrid
131 // --------------------------
132
133#if HAVE_DUNE_ALUGRID
136 template< int dim, int dimw, ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
137 struct TwistUtility< ALUGrid< dim, dimw, elType, refineType, Comm > >
138 {
139 typedef ALUGrid< dim, dimw, elType, refineType, Comm > GridType;
140
141 public:
143 template< class Intersection >
144 static inline int twistInSelf(const GridType & grid, const Intersection& intersection)
145 {
146 assert( dim == 2 ? (intersection.impl().twistInInside() == 0 ||
147 intersection.impl().twistInInside() == 1 ) : true );
148 return intersection.impl().twistInInside();
149 }
150
152 template< class Intersection >
153 static inline int twistInNeighbor(const GridType &grid, const Intersection& intersection )
154 {
155 assert( dim == 2 ? (intersection.impl().twistInOutside() == 0 ||
156 intersection.impl().twistInOutside() == 1 ) : true );
157 return intersection.impl().twistInOutside();
158 }
159
162 template <class Intersection>
163 static inline GeometryType
164 elementGeometry(const Intersection& intersection,
165 const bool inside)
166 {
167 return GeometryType( Dune::Capabilities::hasSingleGeometryType< GridType > :: topologyId,
168 dim );
169 }
170
171 private:
172 TwistUtility(const TwistUtility&);
173 TwistUtility& operator=(const TwistUtility&);
174 };
175#endif // #if HAVE_DUNE_ALUGRID
176
177
178
179 // Specialization for UGGrid
180 // -------------------------
181
182#if HAVE_UG
183 template< int dim >
184 struct TwistUtility< UGGrid< dim > >
185 {
186 typedef UGGrid< dim > GridType;
187
188 typedef typename GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator;
189 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
190 typedef typename GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator;
191 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
192
193 static int twistInSelf ( const GridType &grid, const LeafIntersection &it );
194 static int twistInSelf ( const GridType &grid, const LevelIntersection &it );
195
196 static int twistInNeighbor ( const GridType &grid, const LeafIntersection &it );
197 static int twistInNeighbor ( const GridType &grid, const LevelIntersection &it );
198
199 template< class Intersection >
200 static GeometryType
201 elementGeometry ( const Intersection &intersection, const bool inside )
202 {
203 return (inside ? intersection.inside().type() : intersection.outside().type());
204 }
205 };
206#endif // #ifdef ENABLE_UG
207
208
209
210 // Specialization for GeometryGrid
211 // -------------------------------
212
213 template< class HostGrid, class CoordFunction, class Allocator >
214 struct TwistUtility< GeometryGrid< HostGrid, CoordFunction, Allocator > >
215 {
216 typedef GeometryGrid< HostGrid, CoordFunction, Allocator > GridType;
217 typedef typename GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator;
218 typedef typename LeafIntersectionIterator::Intersection LeafIntersection;
219 typedef typename GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator;
220 typedef typename LevelIntersectionIterator::Intersection LevelIntersection;
221
222 private:
225
226 public:
228 template< class Intersection >
229 static int twistInSelf ( const GridType &grid, const Intersection &intersection )
230 {
231 return HostTwistUtility::twistInSelf( grid.hostGrid(), HostGridAccess::hostIntersection( intersection ) );
232 }
233
235 template< class Intersection >
236 static int twistInNeighbor ( const GridType &grid, const Intersection &intersection )
237 {
238 return HostTwistUtility::twistInNeighbor( grid.hostGrid(), HostGridAccess::hostIntersection( intersection ) );
239 }
240
242 template< class Intersection >
243 static GeometryType elementGeometry ( const Intersection &intersection, bool inside )
244 {
245 return HostTwistUtility::elementGeometry( HostGridAccess::hostIntersection( intersection ), inside );
246 }
247 };
248
249 } // namespace Fem
250
251} // namespace Dune
252
253#endif // #ifndef DUNE_FEM_TWISTUTILITY_HH
Definition: bindguard.hh:11
Definition: boundaryidprovider.hh:25
Definition: griddeclaration.hh:39
TwistFreeTwistUtility provides the default implementation for twistfree grid such as Cartesian grids.
Definition: twistutility.hh:26
Grid GridType
Definition: twistutility.hh:27
static int twistInSelf(const GridType &, const Intersection &)
return 0 for inner face
Definition: twistutility.hh:31
static GeometryType elementGeometry(const Intersection &intersection, const bool inside)
return geometry type of inside or outside entity
Definition: twistutility.hh:45
static int twistInNeighbor(const GridType &, const Intersection &)
return 0 for outer face
Definition: twistutility.hh:38
Utility to get twist from IntersectionIterator, if provided by grid (i.e. AlbertaGrid,...
Definition: twistutility.hh:84
LevelIntersectionIterator::Intersection LevelIntersection
Definition: twistutility.hh:220
GridType::Traits::LevelIntersectionIterator LevelIntersectionIterator
Definition: twistutility.hh:219
static int twistInSelf(const GridType &grid, const Intersection &intersection)
return twist for inner face
Definition: twistutility.hh:229
LeafIntersectionIterator::Intersection LeafIntersection
Definition: twistutility.hh:218
GeometryGrid< HostGrid, CoordFunction, Allocator > GridType
Definition: twistutility.hh:216
static GeometryType elementGeometry(const Intersection &intersection, bool inside)
return element geometry type of inside or outside entity
Definition: twistutility.hh:243
static int twistInNeighbor(const GridType &grid, const Intersection &intersection)
return twist for outer face
Definition: twistutility.hh:236
GridType::Traits::LeafIntersectionIterator LeafIntersectionIterator
Definition: twistutility.hh:217