dune-grid  2.5.0
coordfunction.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_GEOGRID_COORDFUNCTION_HH
4 #define DUNE_GEOGRID_COORDFUNCTION_HH
5 
6 #include <dune/common/fvector.hh>
7 
8 namespace Dune
9 {
10 
11  // Internal Forward Declarations
12  // -----------------------------
13 
14  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
16 
17  template< class ct, unsigned int dimR, class Impl >
19 
20 
21 
22  // AnalyticalCoordFunctionInterface
23  // --------------------------------
24 
37  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
39  {
41 
42  friend class AnalyticalCoordFunction< ct, dimD, dimR, Impl >;
43 
44  public:
45  typedef This Interface;
46  typedef Impl Implementation;
47 
49  typedef ct ctype;
50 
52  static const unsigned int dimDomain = dimD;
54  static const unsigned int dimRange = dimR;
55 
57  typedef FieldVector< ctype, dimDomain > DomainVector;
59  typedef FieldVector< ctype, dimRange > RangeVector;
60 
61  private:
63  AnalyticalCoordFunctionInterface ( const This & ) = default;
64  AnalyticalCoordFunctionInterface ( This && ) = default;
66  This &operator= ( const This & ) = default;
67  This &operator= ( This && ) = default;
68 
69  public:
71  void evaluate ( const DomainVector &x, RangeVector &y ) const
72  {
73  return asImp().evaluate( x, y );
74  }
75 
76  protected:
77  const Implementation &asImp () const
78  {
79  return static_cast< const Implementation & >( *this );
80  }
81 
82  Implementation &asImp ()
83  {
84  return static_cast< Implementation & >( *this );
85  }
86  };
87 
88 
89 
90  // AnalyticalCoordFunction
91  // -----------------------
95  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
97  : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl >
98  {
101 
102  public:
103  typedef typename Base :: DomainVector DomainVector;
104  typedef typename Base :: RangeVector RangeVector;
105 
106  protected:
107  AnalyticalCoordFunction () = default;
108  AnalyticalCoordFunction ( const This & ) = default;
109  AnalyticalCoordFunction ( This && ) = default;
110  ~AnalyticalCoordFunction () = default;
111  This &operator= ( const This & ) = default;
112  This &operator= ( This && ) = default;
113 
114  private:
115  void evaluate ( const DomainVector &x, RangeVector &y ) const;
116  };
117 
118 
119 
120  // DiscreteCoordFunctionInterface
121  // ------------------------------
122 
137  template< class ct, unsigned int dimR, class Impl >
139  {
141 
142  friend class DiscreteCoordFunction< ct, dimR, Impl >;
143 
144  public:
145  typedef This Interface;
146  typedef Impl Implementation;
147 
149  typedef ct ctype;
150 
152  static const unsigned int dimRange = dimR;
153 
155  typedef FieldVector< ctype, dimRange > RangeVector;
156 
157  private:
158  DiscreteCoordFunctionInterface () = default;
159  DiscreteCoordFunctionInterface ( const This & ) = default;
160  DiscreteCoordFunctionInterface ( This && ) = default;
161  ~DiscreteCoordFunctionInterface () = default;
162  This &operator= ( const This & ) = default;
163  This &operator= ( This && ) = default;
164 
165  public:
171  template< class HostEntity >
172  void evaluate ( const HostEntity &hostEntity, unsigned int corner,
173  RangeVector &y ) const
174  {
175  asImp().evaluate( hostEntity, corner, y );
176  }
177 
181  void adapt ()
182  {
183  asImp().adapt();
184  }
185 
186  protected:
187  const Implementation &asImp () const
188  {
189  return static_cast< const Implementation & >( *this );
190  }
191 
192  Implementation &asImp ()
193  {
194  return static_cast< Implementation & >( *this );
195  }
196  };
197 
198 
199 
200  // DiscreteCoordFunction
201  // ---------------------
202  //
206  template< class ct, unsigned int dimR, class Impl >
208  : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
209  {
212 
213  public:
214  typedef typename Base :: RangeVector RangeVector;
215 
216  protected:
217  DiscreteCoordFunction () = default;
218  DiscreteCoordFunction ( const This & ) = default;
219  DiscreteCoordFunction ( This && ) = default;
220  ~DiscreteCoordFunction () = default;
221  This &operator= ( const This & ) = default;
222  This &operator= ( This && ) = default;
223 
224  void adapt ()
225  {}
226 
227  private:
228  template< class HostEntity >
229  void evaluate ( const HostEntity &hostEntity, unsigned int corner,
230  RangeVector &y ) const;
231  };
232 
233 
234 
235  namespace GeoGrid
236  {
237 
238  // isCoordFunctionInterface
239  // ------------------------
240 
241  template< class CoordFunctionInterface >
243  {
244  static const bool value = false;
245  };
246 
247  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
249  < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > >
250  {
251  static const bool value = true;
252  };
253 
254  template< class ct, unsigned int dimR, class Impl >
256  < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
257  {
258  static const bool value = true;
259  };
260 
261 
262 
263  // isDiscreteCoordFunctionInterface
264  // --------------------------------
265 
266  template< class CoordFunctionInterface >
268  {
269  static const bool value = false;
270  };
271 
272  template< class ct, unsigned int dimR, class Impl >
274  < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
275  {
276  static const bool value = true;
277  };
278 
279 
280 
281  // AdaptCoordFunction
282  // ------------------
283 
284  template< class CoordFunctionInterface >
286  {
287  static void adapt ( CoordFunctionInterface &coordFunction )
288  {}
289  };
290 
291  template< class ct, unsigned int dimR, class Impl >
293  {
295 
296  static void adapt ( CoordFunctionInterface &coordFunction )
297  {
298  coordFunction.adapt();
299  }
300  };
301 
302  } // namespace GeoGrid
303 
304 } // namespace Dune
305 
306 #endif // #ifndef DUNE_GEOGRID_COORDFUNCTION_HH
void adapt()
Definition: coordfunction.hh:224
Derive an implementation of an analytical coordinate function from this class.
Definition: coordfunction.hh:15
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:59
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:149
Base ::RangeVector RangeVector
Definition: coordfunction.hh:214
static const unsigned int dimDomain
dimension of the range vector (dimensionworld of host grid)
Definition: coordfunction.hh:52
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:155
Derive an implementation of a discrete coordinate function from this class.
Definition: coordfunction.hh:18
FieldVector< ctype, dimDomain > DomainVector
domain vector for the evaluate method
Definition: coordfunction.hh:57
Impl Implementation
Definition: coordfunction.hh:46
Interface class for using a discrete function to define the geometry of a Dune::GeometryGrid. An implementation should be derived from Dune::DiscreteCoordinateFunction and the evaluate method taking an entity of the host grid together with the number of a vertex returns the coordinate in of that corner. The user must ensure continuity of this mapping. In addition an adapt method is provided which is called whenever adapt() is called on the Dune::GeometryGrid.
Definition: coordfunction.hh:138
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:287
Implementation & asImp()
Definition: coordfunction.hh:192
Implementation & asImp()
Definition: coordfunction.hh:82
Include standard header files.
Definition: agrid.hh:59
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:49
This Interface
Definition: coordfunction.hh:145
Interface class for using an analytical function to define the geometry of a Dune::GeometryGrid. An implementation should be derived from Dune::AnalyticalCoordFunction and the evaluate method mapping has to be supplied.
Definition: coordfunction.hh:38
void evaluate(const DomainVector &x, RangeVector &y) const
evaluate method for global mapping
Definition: coordfunction.hh:71
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:296
Impl Implementation
Definition: coordfunction.hh:146
const Implementation & asImp() const
Definition: coordfunction.hh:77
Definition: coordfunction.hh:267
void evaluate(const HostEntity &hostEntity, unsigned int corner, RangeVector &y) const
evaluate method
Definition: coordfunction.hh:172
Definition: coordfunction.hh:242
Base ::RangeVector RangeVector
Definition: coordfunction.hh:104
This Interface
Definition: coordfunction.hh:45
Definition: coordfunction.hh:285
DiscreteCoordFunctionInterface< ct, dimR, Impl > CoordFunctionInterface
Definition: coordfunction.hh:294
void adapt()
method called from grid.adapt() method to allow adaptation of the discrete coordinate function ...
Definition: coordfunction.hh:181
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:54
const Implementation & asImp() const
Definition: coordfunction.hh:187
Base ::DomainVector DomainVector
Definition: coordfunction.hh:103