DUNE-FEM (unstable)

twistprovider.hh
1#ifndef DUNE_FEM_TWISTPROVIDER_HH
2#define DUNE_FEM_TWISTPROVIDER_HH
3
4//- System includes
5#include <cassert>
6
7#include <map>
8#include <memory>
9#include <vector>
10
11//- Dune includes
12#include <dune/geometry/referenceelements.hh>
13
14#include <dune/fem/quadrature/quadrature.hh>
15
16#include <dune/fem/storage/singleton.hh>
17
18//- Local includes
19#include "pointmapper.hh"
20#include "topology.hh"
21
22namespace Dune
23{
24
25 namespace Fem
26 {
27
28 // Forward declaration
29 template <class ct, int dim>
30 class TwistProvider;
31 template <class ct, int dim>
32 class TwistMapperCreator;
33 template <class ct, int dim>
34 class TwistStorage;
35
36
48
49
52 template <class ct, int dim>
54 {
55 typedef CachingTraits<ct, dim> Traits;
56 public:
57 typedef typename Traits::PointType PointType;
58 typedef typename Traits::PointVectorType PointVectorType;
59 typedef typename Traits::MapperType MapperType;
60
61 public:
65 explicit TwistStorage(int minTwist, int maxTwist);
66
68 void addMapper(const MapperType& mapper, int twist);
69
71 size_t addPoint(const PointType& points);
72
74 const MapperType& getMapper(int twist) const;
75
78 const PointVectorType& getPoints() const;
79
81 int minTwist() const { return minTwist_; }
82
84 int maxTwist() const { return maxTwist_; }
85
86 private:
87 typedef typename Traits::MapperVectorType MapperVectorType;
88
89 private:
90 MapperVectorType mappers_;
91 PointVectorType points_;
92
93 int minTwist_;
94 int maxTwist_;
95 };
96
97
98
99 // TiwstProvider
100 // -------------
101
107 template <class ct, int dim>
109 {
110 typedef CachingTraits<ct, dim> Traits;
111 public:
118
119 public:
121 static const TwistStorageType& getTwistStorage(const QuadratureType& quad);
122
123 private:
124 typedef std::vector< const TwistStorageType* > MapperContainerType;
125 typedef typename MapperContainerType::iterator IteratorType;
126
127 private:
128 // singleton class holding map with storages
129 class MapperContainer
130 {
131 // instance of map
132 MapperContainerType mappers_;
133
134 public:
136 MapperContainer() : mappers_(100, (TwistStorageType*) 0)
137 {}
138
140 ~MapperContainer()
141 {
142 IteratorType endit = mappers_.end();
143 for(IteratorType it = mappers_.begin(); it != endit; ++it)
144 {
145 delete (*it);
146 }
147 }
148
149 friend class Dune::Fem::Singleton< MapperContainerType >;
151 static MapperContainerType& instance()
152 {
154 }
155 };
156 };
157
158
159
160 // TwistMapperStrategy
161 // -------------------
162
164 template <class ct, int dim>
166 {
168
169 public:
170 TwistMapperStrategy(int minTwist, int maxTwist) :
171 minTwist_(minTwist),
172 maxTwist_(maxTwist)
173 {}
174
176 virtual ~TwistMapperStrategy () = default;
177
178 virtual MatrixType buildTransformationMatrix ( int twist ) const = 0;
179
180 int minTwist() const { return minTwist_; }
181 int maxTwist() const { return maxTwist_; }
182
183 private:
184 int minTwist_;
185 int maxTwist_;
186 };
187
188
189
190 // TwistMapperCreator
191 // ------------------
192
194 template <class ct, int dim>
196 {
197 typedef CachingTraits<ct, dim> Traits;
198 public:
199 typedef typename Traits::QuadratureType QuadratureType;
200 typedef typename Traits::PointType PointType;
201 typedef typename Traits::MapperType MapperType;
204
205 public:
208
211
213 const TwistStorageType* createStorage() const;
214
216 int minTwist() const {
217 return helper_->minTwist();
218 }
219
221 int maxTwist() const {
222 return helper_->maxTwist();
223 }
224
225 private:
226 typedef typename TwistMapperStrategy<ct, dim>::MatrixType MatrixType;
227
228 private:
230 TwistMapperCreator& operator=(const TwistMapperCreator&);
231
232 private:
233 const QuadratureType& quad_;
235
236 static const ct eps_;
237 };
238
239
240
241 // PointTwistMapperStrategy
242 // ------------------------
243
246 template <class ct, int dim>
248 : public TwistMapperStrategy<ct, dim>
249 {
251 typedef typename BaseType::MatrixType MatrixType;
252
253 public:
255 : BaseType( 0, 1 )
256 {
257 assert(dim == 0);
258 }
259
260 virtual MatrixType buildTransformationMatrix ( int twist ) const
261 {
262 const auto &refElement = Dune::ReferenceElements< ct, dim >::cube();
263
264 assert( twist == 0 );
265 MatrixType mat;
266 mat[ 0 ] = refElement.position( 0, dim );
267 return mat;
268 }
269 };
270
271
272
273 // LineTwistMapperStrategy
274 // -----------------------
275
278 template <class ct, int dim>
280 : public TwistMapperStrategy<ct, dim>
281 {
283 typedef typename BaseType::MatrixType MatrixType;
284
285 public:
287 : BaseType( 0, 2 )
288 {
289 assert(dim == 1);
290 }
291
292 MatrixType buildTransformationMatrix ( int twist ) const override
293 {
294 const auto &refElement = Dune::ReferenceElements< ct, dim >::cube();
295
296 assert( (twist == 0) || (twist == 1) );
297 MatrixType mat;
298 mat[ twist ] = refElement.position( 0, dim );
299 mat[ 1-twist ] = refElement.position( 1, dim );
300 return mat;
301 }
302 };
303
304
305
306 // TriangleTwistMapperStrategy
307 // ---------------------------
308
311 template <class ct, int dim>
313 : public TwistMapperStrategy<ct, dim>
314 {
316 typedef typename BaseType::MatrixType MatrixType;
317
318 public:
320 : BaseType( -3, 3 )
321 {
322 assert(dim == 2);
323 }
324
325 virtual MatrixType buildTransformationMatrix ( int twist ) const override
326 {
327 typedef Dune::Fem::FaceTopologyMapping<tetra> FaceTopo;
328
329 const auto &refElement = Dune::ReferenceElements< ct, dim >::simplex();
330
331 MatrixType mat( ct( 0 ) );
332 for (int idx = 0; idx < dim+1; ++idx)
333 mat[idx] = refElement.position( FaceTopo::twistedDuneIndex(idx, twist), dim); // dim == codim here
334 return mat;
335 }
336 };
337
338
339
340 // QuadrilateralTwistMapperStrategy
341 // --------------------------------
342
345 template <class ct, int dim>
347 : public TwistMapperStrategy<ct, dim>
348 {
350 typedef typename BaseType::MatrixType MatrixType;
351
352 public:
354 : BaseType( -4, 4 )
355 {
356 assert(dim == 2);
357 }
358
359 MatrixType buildTransformationMatrix ( int twist ) const override
360 {
361 typedef Dune::Fem::FaceTopologyMapping<hexa> FaceTopo;
362
363 const auto &refElement = Dune::ReferenceElements< ct, dim >::cube();
364
365 MatrixType mat( ct( 0 ) );
366 for (int idx = 0; idx < dim+1; ++idx)
367 mat[idx] = refElement.position( FaceTopo::twistedDuneIndex(idx, twist), dim); // dim == codim here
368 return mat;
369 }
370 };
371
372 } // namespace Fem
373
374} // namespace Dune
375
376#include "twistprovider.cc"
377#endif // #ifndef DUNE_FEM_TWISTPROVIDER_HH
Definition: twistprovider.hh:281
Definition: twistprovider.hh:249
Definition: twistprovider.hh:348
return singleton instance of given Object type.
Definition: singleton.hh:93
static DUNE_EXPORT Object & instance(Args &&... args)
return singleton instance of given Object type.
Definition: singleton.hh:123
Definition: twistprovider.hh:314
Helper class for TwistProvider which takes care of the creation process.
Definition: twistprovider.hh:196
TwistMapperCreator(const QuadratureType &quad)
Constructor.
Definition: twistprovider.cc:67
~TwistMapperCreator()
Destructor.
Definition: twistprovider.cc:98
int maxTwist() const
Largest possible twist + 1 for the quadrature's geometry.
Definition: twistprovider.hh:221
const TwistStorageType * createStorage() const
Create the actual mapper for a given twist.
Definition: twistprovider.cc:105
int minTwist() const
Lowest possible twist for the quadrature's geometry.
Definition: twistprovider.hh:216
Access point for PointMapper objects with twist information PointMapper objects get created once and ...
Definition: twistprovider.hh:109
Traits::QuadratureType QuadratureType
Generic quadrature type.
Definition: twistprovider.hh:113
TwistMapperCreator< ct, dim >::TwistStorageType TwistStorageType
Definition: twistprovider.hh:117
static const TwistStorageType & getTwistStorage(const QuadratureType &quad)
Delivers the PointMapper object for quadrature quad and twist twist.
Definition: twistprovider.cc:47
Identifies quadrature points on faces with twists For a given quadrature type and a face with a given...
Definition: twistprovider.hh:54
TwistStorage(int minTwist, int maxTwist)
Definition: twistprovider.cc:8
void addMapper(const MapperType &mapper, int twist)
Add a new mapper for a given twist.
Definition: twistprovider.cc:16
int maxTwist() const
Maximal twist + 1.
Definition: twistprovider.hh:84
const MapperType & getMapper(int twist) const
Access to a mapper.
Definition: twistprovider.cc:33
size_t addPoint(const PointType &points)
Add a point (in the case of asymmetric quadratures)
Definition: twistprovider.cc:23
const PointVectorType & getPoints() const
Definition: twistprovider.cc:40
int minTwist() const
Minimal twist.
Definition: twistprovider.hh:81
A dense n x m matrix.
Definition: fmatrix.hh:117
vector space out of a tensor product of fields.
Definition: fvector.hh:91
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Dune namespace.
Definition: alignedallocator.hh:13
This class factors out all geometry dependent stuff in a strategy class.
Definition: twistprovider.hh:166
virtual ~TwistMapperStrategy()=default
virtual desctructor because of virtual functions
static const ReferenceElement & cube()
get hypercube reference elements
Definition: referenceelements.hh:168
static const ReferenceElement & simplex()
get simplex reference elements
Definition: referenceelements.hh:162
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)