dune-fem  2.4.1-rc
twistprovider.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_TWISTPROVIDER_HH
2 #define DUNE_FEM_TWISTPROVIDER_HH
3 
4 //- System includes
5 #include <vector>
6 #include <map>
7 #include <memory>
8 #include <cassert>
9 
10 //- Dune includes
11 #include <dune/geometry/referenceelements.hh>
13 
14 //- Local includes
15 #include "pointmapper.hh"
16 #include "topology.hh"
17 
18 namespace Dune
19 {
20 
21  namespace Fem
22  {
23 
24  // Forward declaration
25  template <class ct, int dim>
27  template <class ct, int dim>
29  template <class ct, int dim>
30  class TwistStorage;
31 
32 
44 
45 
48  template <class ct, int dim>
49  class TwistStorage
50  {
52  public:
53  typedef typename Traits::PointType PointType;
55  typedef typename Traits::MapperType MapperType;
56 
57  public:
61  explicit TwistStorage(int minTwist, int maxTwist);
62 
64  void addMapper(const MapperType& mapper, int twist);
65 
67  size_t addPoint(const PointType& points);
68 
70  const MapperType& getMapper(int twist) const;
71 
74  const PointVectorType& getPoints() const;
75 
77  int minTwist() const;
78 
80  int maxTwist() const;
81 
82  private:
83  typedef typename Traits::MapperVectorType MapperVectorType;
84 
85  private:
86  MapperVectorType mappers_;
87  PointVectorType points_;
88 
89  int minTwist_;
90  int maxTwist_;
91  };
92 
98  template <class ct, int dim>
99  class TwistProvider
100  {
102  public:
109 
110  public:
112  static const TwistStorageType& getTwistStorage(const QuadratureType& quad);
113 
114  private:
115  typedef std::vector< const TwistStorageType* > MapperContainerType;
116  typedef typename MapperContainerType::iterator IteratorType;
117 
118  private:
119  // singleton class holding map with storages
120  class MapperContainer
121  {
122  // instance of map
123  MapperContainerType mappers_;
124 
126  MapperContainer() : mappers_(100, (TwistStorageType*) 0)
127  {}
128 
130  ~MapperContainer()
131  {
132  IteratorType endit = mappers_.end();
133  for(IteratorType it = mappers_.begin(); it != endit; ++it)
134  {
135  delete (*it);
136  }
137  }
138 
139  public:
141  static MapperContainerType& instance()
142  {
143  // create singleton instance
144  static MapperContainer mc;
145  return mc.mappers_;
146  }
147  };
148  };
149 
151  template <class ct, int dim>
153  {
154  public:
155  typedef FieldMatrix<ct, dim+1, dim> MatrixType;
156 
157  public:
159  minTwist_(minTwist),
160  maxTwist_(maxTwist)
161  {}
162 
164  virtual ~TwistMapperStrategy() {}
165 
166  virtual const MatrixType& buildTransformationMatrix(int twist) const = 0;
167 
168  int minTwist() const { return minTwist_; }
169  int maxTwist() const { return maxTwist_; }
170 
171  private:
172  int minTwist_;
173  int maxTwist_;
174  };
175 
177  template <class ct, int dim>
178  class TwistMapperCreator
179  {
180  typedef CachingTraits<ct, dim> Traits;
181  public:
183  typedef typename Traits::PointType PointType;
184  typedef typename Traits::MapperType MapperType;
185  typedef FieldVector<ct, dim+1> CoordinateType;
187 
188  public:
190  TwistMapperCreator(const QuadratureType& quad);
191 
194 
196  const TwistStorageType* createStorage() const;
197 
199  int minTwist() const {
200  return helper_->minTwist();
201  }
202 
204  int maxTwist() const {
205  return helper_->maxTwist();
206  }
207 
208  private:
209  typedef typename TwistMapperStrategy<ct, dim>::MatrixType MatrixType;
210 
211  private:
213  TwistMapperCreator& operator=(const TwistMapperCreator&);
214 
215  private:
216  const QuadratureType& quad_;
218 
219  static const ct eps_;
220  };
221 
224  template <class ct, int dim>
226  public:
229 
230  public:
231  PointTwistMapperStrategy(GeometryType geo);
232 
235 
236  virtual const MatrixType& buildTransformationMatrix(int tiwst) const;
237 
238  private:
239  const Dune::ReferenceElement<ct, dim>& refElem_;
240  mutable MatrixType mat_;
241  };
242 
245  template <class ct, int dim>
247  public:
250 
251  public:
252  LineTwistMapperStrategy(GeometryType geo);
253 
256 
257  virtual const MatrixType& buildTransformationMatrix(int tiwst) const;
258 
259  private:
260  const Dune::ReferenceElement<ct, dim>& refElem_;
261  mutable MatrixType mat_;
262  };
263 
266  template <class ct, int dim>
268  public:
271 
272  public:
273  TriangleTwistMapperStrategy(GeometryType geo);
276 
277  virtual const MatrixType& buildTransformationMatrix(int twist) const;
278 
279  private:
280  const Dune::ReferenceElement<ct, dim>& refElem_;
281  mutable MatrixType mat_;
282  };
283 
286  template <class ct, int dim>
288  public TwistMapperStrategy<ct, dim> {
289  public:
292 
293  public:
294  QuadrilateralTwistMapperStrategy(GeometryType geo);
295 
298 
299  virtual const MatrixType& buildTransformationMatrix(int twist) const;
300 
301  private:
302  const Dune::ReferenceElement<ct, dim>& refElem_;
303  mutable MatrixType mat_;
304  };
305 
306  } // namespace Fem
307 
308 } // namespace Dune
309 
310 #include "twistprovider.cc"
311 #endif // #ifndef DUNE_FEM_TWISTPROVIDER_HH
BaseType::MatrixType MatrixType
Definition: twistprovider.hh:291
TwistMapperStrategy< ct, dim > BaseType
Definition: twistprovider.hh:248
std::vector< size_t > MapperType
Definition: pointmapper.hh:58
virtual ~TwistMapperStrategy()
virtual desctructor because of virtual functions
Definition: twistprovider.hh:164
int minTwist() const
Definition: twistprovider.hh:168
Traits::QuadratureType QuadratureType
Definition: twistprovider.hh:182
Helper class for TwistProvider which takes care of the creation process.
Definition: twistprovider.hh:28
Traits::PointVectorType PointVectorType
Definition: twistprovider.hh:54
Definition: pointmapper.hh:52
void addMapper(const MapperType &mapper, int twist)
Add a new mapper for a given twist.
Definition: twistprovider.cc:16
FieldMatrix< ct, dim+1, dim > MatrixType
Definition: twistprovider.hh:155
Definition: twistprovider.hh:267
TwistStorage(int minTwist, int maxTwist)
Definition: twistprovider.cc:8
Identifies quadrature points on faces with twists For a given quadrature type and a face with a given...
Definition: twistprovider.hh:30
int maxTwist() const
Largest possible twist + 1 for the quadrature&#39;s geometry.
Definition: twistprovider.hh:204
virtual ~QuadrilateralTwistMapperStrategy()
virtual desctructor because of virtual functions
Definition: twistprovider.hh:297
Definition: twistprovider.hh:225
BaseType::MatrixType MatrixType
Definition: twistprovider.hh:249
Traits::MapperType MapperType
Definition: twistprovider.hh:184
virtual ~PointTwistMapperStrategy()
virtual desctructor because of virtual functions
Definition: twistprovider.hh:234
int maxTwist() const
Definition: twistprovider.hh:169
int maxTwist() const
Maximal twist + 1.
Definition: twistprovider.cc:52
Definition: coordinate.hh:4
FieldVector< ct, dim+1 > CoordinateType
Definition: twistprovider.hh:185
size_t addPoint(const PointType &points)
Add a point (in the case of asymmetric quadratures)
Definition: twistprovider.cc:23
Traits::QuadratureType QuadratureType
Generic quadrature type.
Definition: twistprovider.hh:104
Access point for PointMapper objects with twist information PointMapper objects get created once and ...
Definition: twistprovider.hh:26
virtual ~LineTwistMapperStrategy()
virtual desctructor because of virtual functions
Definition: twistprovider.hh:255
TwistMapperStrategy< ct, dim > BaseType
Definition: twistprovider.hh:290
QuadratureType::CoordinateType PointType
extracted types from integration point list
Definition: pointmapper.hh:56
const PointVectorType & getPoints() const
Definition: twistprovider.cc:40
BaseType::MatrixType MatrixType
Definition: twistprovider.hh:228
BaseType::MatrixType MatrixType
Definition: twistprovider.hh:270
TwistMapperStrategy< ct, dim > BaseType
Definition: twistprovider.hh:269
Traits::PointType PointType
Definition: twistprovider.hh:53
TwistMapperCreator< ct, dim >::TwistStorageType TwistStorageType
Definition: twistprovider.hh:108
std::vector< PointType > PointVectorType
Definition: pointmapper.hh:57
int minTwist() const
Lowest possible twist for the quadrature&#39;s geometry.
Definition: twistprovider.hh:199
const MapperType & getMapper(int twist) const
Access to a mapper.
Definition: twistprovider.cc:33
TwistStorage< ct, dim > TwistStorageType
Definition: twistprovider.hh:186
std::vector< MapperType > MapperVectorType
Definition: pointmapper.hh:59
Definition: twistprovider.hh:246
virtual ~TriangleTwistMapperStrategy()
virtual desctructor because of virtual functions
Definition: twistprovider.hh:275
Traits::PointType PointType
Definition: twistprovider.hh:183
TwistMapperStrategy(int minTwist, int maxTwist)
Definition: twistprovider.hh:158
int minTwist() const
Minimal twist.
Definition: twistprovider.cc:46
TwistMapperStrategy< ct, dim > BaseType
Definition: twistprovider.hh:227
Definition: twistprovider.hh:287
Traits::MapperType MapperType
Definition: twistprovider.hh:55
This class factors out all geometry dependent stuff in a strategy class.
Definition: twistprovider.hh:152