dune-grid  2.4.1
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  {}
64 
65  AnalyticalCoordFunctionInterface ( const This & );
66  This &operator= ( const This & );
67 
68  public:
70  void evaluate ( const DomainVector &x, RangeVector &y ) const
71  {
72  return asImp().evaluate( x, y );
73  }
74 
75  protected:
76  const Implementation &asImp () const
77  {
78  return static_cast< const Implementation & >( *this );
79  }
80 
82  {
83  return static_cast< Implementation & >( *this );
84  }
85  };
86 
87 
88 
89  // AnalyticalCoordFunction
90  // -----------------------
94  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
95  class AnalyticalCoordFunction
96  : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl >
97  {
99  typedef AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > Base;
100 
101  public:
104 
105  protected:
107  {}
108 
109  private:
110  AnalyticalCoordFunction ( const This & );
111  This &operator= ( const This & );
112 
113  void evaluate ( const DomainVector &x, RangeVector &y ) const;
114  };
115 
116 
117 
118  // DiscreteCoordFunctionInterface
119  // ------------------------------
120 
135  template< class ct, unsigned int dimR, class Impl >
137  {
139 
140  friend class DiscreteCoordFunction< ct, dimR, Impl >;
141 
142  public:
143  typedef This Interface;
144  typedef Impl Implementation;
145 
147  typedef ct ctype;
148 
150  static const unsigned int dimRange = dimR;
151 
153  typedef FieldVector< ctype, dimRange > RangeVector;
154 
155  private:
157  {}
158 
159  DiscreteCoordFunctionInterface ( const This & );
160 
161  This &operator= ( const This & );
162 
163  public:
169  template< class HostEntity >
170  void evaluate ( const HostEntity &hostEntity, unsigned int corner,
171  RangeVector &y ) const
172  {
173  asImp().evaluate( hostEntity, corner, y );
174  }
175 
179  void adapt ()
180  {
181  asImp().adapt();
182  }
183 
184  protected:
185  const Implementation &asImp () const
186  {
187  return static_cast< const Implementation & >( *this );
188  }
189 
191  {
192  return static_cast< Implementation & >( *this );
193  }
194  };
195 
196 
197 
198  // DiscreteCoordFunction
199  // ---------------------
200  //
204  template< class ct, unsigned int dimR, class Impl >
205  class DiscreteCoordFunction
206  : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
207  {
209  typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > Base;
210 
211  public:
213 
214  protected:
216  {}
217 
218  void adapt ()
219  {}
220 
221  private:
222  DiscreteCoordFunction ( const This & );
223  This &operator= ( const This & );
224 
225  template< class HostEntity >
226  void evaluate ( const HostEntity &hostEntity, unsigned int corner,
227  RangeVector &y ) const;
228  };
229 
230 
231 
232  namespace GeoGrid
233  {
234 
235  // isCoordFunctionInterface
236  // ------------------------
237 
238  template< class CoordFunctionInterface >
240  {
241  static const bool value = false;
242  };
243 
244  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
246  < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > >
247  {
248  static const bool value = true;
249  };
250 
251  template< class ct, unsigned int dimR, class Impl >
253  < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
254  {
255  static const bool value = true;
256  };
257 
258 
259 
260  // isDiscreteCoordFunctionInterface
261  // --------------------------------
262 
263  template< class CoordFunctionInterface >
265  {
266  static const bool value = false;
267  };
268 
269  template< class ct, unsigned int dimR, class Impl >
271  < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
272  {
273  static const bool value = true;
274  };
275 
276 
277 
278  // AdaptCoordFunction
279  // ------------------
280 
281  template< class CoordFunctionInterface >
283  {
284  static void adapt ( CoordFunctionInterface &coordFunction )
285  {}
286  };
287 
288  template< class ct, unsigned int dimR, class Impl >
290  {
292 
293  static void adapt ( CoordFunctionInterface &coordFunction )
294  {
295  coordFunction.adapt();
296  }
297  };
298 
299  } // namespace GeoGrid
300 
301 } // namespace Dune
302 
303 #endif // #ifndef DUNE_GEOGRID_COORDFUNCTION_HH
friend class AnalyticalCoordFunction< ct, dimD, dimR, Impl >
Definition: coordfunction.hh:42
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:147
Base::RangeVector RangeVector
Definition: coordfunction.hh:212
void evaluate(const HostEntity &hostEntity, unsigned int corner, RangeVector &y) const
evaluate method
Definition: coordfunction.hh:170
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
Definition: coordfunction.hh:239
DiscreteCoordFunctionInterface< ct, dimR, Impl > CoordFunctionInterface
Definition: coordfunction.hh:291
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:284
static const bool value
Definition: coordfunction.hh:266
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:59
This Interface
Definition: coordfunction.hh:45
This Interface
Definition: coordfunction.hh:143
Impl Implementation
Definition: coordfunction.hh:144
Definition: cachedcoordfunction.hh:24
Implementation & asImp()
Definition: coordfunction.hh:81
friend class DiscreteCoordFunction< ct, dimR, Impl >
Definition: coordfunction.hh:140
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:150
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:54
Derive an implementation of an analytical coordinate function from this class.
Definition: coordfunction.hh:15
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:136
void adapt()
Definition: coordfunction.hh:218
void evaluate(const DomainVector &x, RangeVector &y) const
evaluate method for global mapping
Definition: coordfunction.hh:70
FieldVector< ctype, dimDomain > DomainVector
domain vector for the evaluate method
Definition: coordfunction.hh:57
Impl Implementation
Definition: coordfunction.hh:46
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:153
Base::RangeVector RangeVector
Definition: coordfunction.hh:103
Base::DomainVector DomainVector
Definition: coordfunction.hh:102
const Implementation & asImp() const
Definition: coordfunction.hh:76
static const unsigned int dimDomain
dimension of the range vector (dimensionworld of host grid)
Definition: coordfunction.hh:52
const Implementation & asImp() const
Definition: coordfunction.hh:185
Derive an implementation of a discrete coordinate function from this class.
Definition: coordfunction.hh:18
static void adapt(CoordFunctionInterface &coordFunction)
Definition: coordfunction.hh:293
Implementation & asImp()
Definition: coordfunction.hh:190
Definition: dgfgeogrid.hh:41
DiscreteCoordFunction()
Definition: coordfunction.hh:215
AnalyticalCoordFunction()
Definition: coordfunction.hh:106
void adapt()
method called from grid.adapt() method to allow adaptation of the discrete coordinate function ...
Definition: coordfunction.hh:179
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:49
Definition: coordfunction.hh:264
Definition: coordfunction.hh:282
static const bool value
Definition: coordfunction.hh:241