dune-grid  2.2.1
coordfunction.hh
Go to the documentation of this file.
1 #ifndef DUNE_GEOGRID_COORDFUNCTION_HH
2 #define DUNE_GEOGRID_COORDFUNCTION_HH
3 
4 #include <dune/common/fvector.hh>
5 
6 namespace Dune
7 {
8 
9  // Internal Forward Declarations
10  // -----------------------------
11 
12  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
14 
15  template< class ct, unsigned int dimR, class Impl >
17 
18 
19 
20  // AnalyticalCoordFunctionInterface
21  // --------------------------------
22 
35  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
37  {
39 
40  friend class AnalyticalCoordFunction< ct, dimD, dimR, Impl >;
41 
42  public:
43  typedef This Interface;
44  typedef Impl Implementation;
45 
47  typedef ct ctype;
48 
50  static const unsigned int dimDomain = dimD;
52  static const unsigned int dimRange = dimR;
53 
55  typedef FieldVector< ctype, dimDomain > DomainVector;
57  typedef FieldVector< ctype, dimRange > RangeVector;
58 
59  private:
61  {}
62 
63  AnalyticalCoordFunctionInterface ( const This & );
64  This &operator= ( const This & );
65 
66  public:
68  void evaluate ( const DomainVector &x, RangeVector &y ) const
69  {
70  return asImp().evaluate( x, y );
71  }
72 
73  protected:
74  const Implementation &asImp () const
75  {
76  return static_cast< const Implementation & >( *this );
77  }
78 
80  {
81  return static_cast< Implementation & >( *this );
82  }
83  };
84 
85 
86 
87  // AnalyticalCoordFunction
88  // -----------------------
92  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
93  class AnalyticalCoordFunction
94  : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl >
95  {
97  typedef AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > Base;
98 
99  public:
102 
103  protected:
105  {}
106 
107  private:
108  AnalyticalCoordFunction ( const This & );
109  This &operator= ( const This & );
110 
111  void evaluate ( const DomainVector &x, RangeVector &y ) const;
112  };
113 
114 
115 
116  // DiscreteCoordFunctionInterface
117  // ------------------------------
118 
133  template< class ct, unsigned int dimR, class Impl >
135  {
137 
138  friend class DiscreteCoordFunction< ct, dimR, Impl >;
139 
140  public:
141  typedef This Interface;
142  typedef Impl Implementation;
143 
145  typedef ct ctype;
146 
148  static const unsigned int dimRange = dimR;
149 
151  typedef FieldVector< ctype, dimRange > RangeVector;
152 
153  private:
155  {}
156 
157  DiscreteCoordFunctionInterface ( const This & );
158 
159  This &operator= ( const This & );
160 
161  public:
167  template< class HostEntity >
168  void evaluate ( const HostEntity &hostEntity, unsigned int corner,
169  RangeVector &y ) const
170  {
171  asImp().evaluate( hostEntity, corner, y );
172  }
173 
177  void adapt ()
178  {
179  asImp().adapt();
180  }
181 
182  protected:
183  const Implementation &asImp () const
184  {
185  return static_cast< const Implementation & >( *this );
186  }
187 
189  {
190  return static_cast< Implementation & >( *this );
191  }
192  };
193 
194 
195 
196  // DiscreteCoordFunction
197  // ---------------------
198  //
202  template< class ct, unsigned int dimR, class Impl >
203  class DiscreteCoordFunction
204  : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
205  {
207  typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > Base;
208 
209  public:
211 
212  protected:
214  {}
215 
216  void adapt ()
217  {}
218 
219  private:
220  DiscreteCoordFunction ( const This & );
221  This &operator= ( const This & );
222 
223  template< class HostEntity >
224  void evaluate ( const HostEntity &hostEntity, unsigned int corner,
225  RangeVector &y ) const;
226  };
227 
228 
229 
230  namespace GeoGrid
231  {
232 
233  // isCoordFunctionInterface
234  // ------------------------
235 
236  template< class CoordFunctionInterface >
238  {
239  static const bool value = false;
240  };
241 
242  template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
244  < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > >
245  {
246  static const bool value = true;
247  };
248 
249  template< class ct, unsigned int dimR, class Impl >
251  < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
252  {
253  static const bool value = true;
254  };
255 
256 
257 
258  // isDiscreteCoordFunctionInterface
259  // --------------------------------
260 
261  template< class CoordFunctionInterface >
263  {
264  static const bool value = false;
265  };
266 
267  template< class ct, unsigned int dimR, class Impl >
269  < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
270  {
271  static const bool value = true;
272  };
273 
274 
275 
276  // AdaptCoordFunction
277  // ------------------
278 
279  template< class CoordFunctionInterface >
281  {
282  static void adapt ( CoordFunctionInterface &coordFunction )
283  {}
284  };
285 
286  template< class ct, unsigned int dimR, class Impl >
288  {
290 
291  static void adapt ( CoordFunctionInterface &coordFunction )
292  {
293  coordFunction.adapt();
294  }
295  };
296 
297  } // namespace GeoGrid
298 
299 } // namespace Dune
300 
301 #endif // #ifndef DUNE_GEOGRID_COORDFUNCTION_HH