dune-grid  2.3.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 >
15  class AnalyticalCoordFunction;
16 
17  template< class ct, unsigned int dimR, class Impl >
18  class DiscreteCoordFunction;
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 >
96  : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl >
97  {
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 >
206  : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
207  {
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