Dune Core Modules (2.6.0)

coordfunction.hh
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 <cassert>
7
9#include <dune/common/std/type_traits.hh>
10
11namespace Dune
12{
13
14 // Internal Forward Declarations
15 // -----------------------------
16
17 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
18 class AnalyticalCoordFunction;
19
20 template< class ct, unsigned int dimR, class Impl >
21 class DiscreteCoordFunction;
22
23
24
25 // AnalyticalCoordFunctionInterface
26 // --------------------------------
27
40 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
42 {
44
45 friend class AnalyticalCoordFunction< ct, dimD, dimR, Impl >;
46
47 public:
48 typedef This Interface;
49 typedef Impl Implementation;
50
52 typedef ct ctype;
53
55 static const unsigned int dimDomain = dimD;
57 static const unsigned int dimRange = dimR;
58
63
64 private:
66 AnalyticalCoordFunctionInterface ( const This & ) = default;
69 This &operator= ( const This & ) = default;
70 This &operator= ( This && ) = default;
71
72 // helper for picking the correct version of evaluate further down
73 template<typename F, typename DV>
74 using has_operator_parentheses = decltype(std::declval<F>()(std::declval<DV>()));
75
76 public:
77
78#ifdef DOXYGEN
79
81 void evaluate ( const DomainVector &x, RangeVector &y ) const;
82
83#else
84
85 template<typename DV>
86 std::enable_if_t<
88 >
89 evaluate ( const DV &x, RangeVector &y ) const
90 {
91 y = asImp()(x);
92 }
93
94 template<typename DV>
95 std::enable_if_t<
97 >
98 evaluate ( const DV &x, RangeVector &y ) const
99 {
100 assert(
101 static_cast<void(This::*)(const DomainVector&, RangeVector&) const>(&This::evaluate) !=
102 static_cast<void(Impl::*)(const DomainVector&, RangeVector&) const>(&Impl::evaluate) &&
103 "You need to implement either operator() or evaluate() in your coordinate function!");
104 asImp().evaluate( x, y );
105 }
106
107#endif // DOXYGEN
108
109 protected:
110
111 const Implementation &asImp () const
112 {
113 return static_cast< const Implementation & >( *this );
114 }
115
116 Implementation &asImp ()
117 {
118 return static_cast< Implementation & >( *this );
119 }
120 };
121
122
123
124 // AnalyticalCoordFunction
125 // -----------------------
129 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
131 : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl >
132 {
135
136 public:
137 typedef typename Base :: DomainVector DomainVector;
138 typedef typename Base :: RangeVector RangeVector;
139
140 protected:
141 AnalyticalCoordFunction () = default;
142 AnalyticalCoordFunction ( const This & ) = default;
143 AnalyticalCoordFunction ( This && ) = default;
144 ~AnalyticalCoordFunction () = default;
145 This &operator= ( const This & ) = default;
146 This &operator= ( This && ) = default;
147
148 private:
149
150 };
151
152
153
154 // DiscreteCoordFunctionInterface
155 // ------------------------------
156
171 template< class ct, unsigned int dimR, class Impl >
173 {
175
176 friend class DiscreteCoordFunction< ct, dimR, Impl >;
177
178 public:
179 typedef This Interface;
180 typedef Impl Implementation;
181
183 typedef ct ctype;
184
186 static const unsigned int dimRange = dimR;
187
190
191 private:
193 DiscreteCoordFunctionInterface ( const This & ) = default;
194 DiscreteCoordFunctionInterface ( This && ) = default;
196 This &operator= ( const This & ) = default;
197 This &operator= ( This && ) = default;
198
199 public:
205 template< class HostEntity >
206 void evaluate ( const HostEntity &hostEntity, unsigned int corner,
207 RangeVector &y ) const
208 {
209 asImp().evaluate( hostEntity, corner, y );
210 }
211
215 void adapt ()
216 {
217 asImp().adapt();
218 }
219
220 protected:
221 const Implementation &asImp () const
222 {
223 return static_cast< const Implementation & >( *this );
224 }
225
226 Implementation &asImp ()
227 {
228 return static_cast< Implementation & >( *this );
229 }
230 };
231
232
233
234 // DiscreteCoordFunction
235 // ---------------------
236 //
240 template< class ct, unsigned int dimR, class Impl >
242 : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
243 {
246
247 public:
248 typedef typename Base :: RangeVector RangeVector;
249
250 protected:
251 DiscreteCoordFunction () = default;
252 DiscreteCoordFunction ( const This & ) = default;
253 DiscreteCoordFunction ( This && ) = default;
254 ~DiscreteCoordFunction () = default;
255 This &operator= ( const This & ) = default;
256 This &operator= ( This && ) = default;
257
258 void adapt ()
259 {}
260
261 private:
262 template< class HostEntity >
263 void evaluate ( const HostEntity &hostEntity, unsigned int corner,
264 RangeVector &y ) const;
265 };
266
267
268
269 namespace GeoGrid
270 {
271
272 // isCoordFunctionInterface
273 // ------------------------
274
275 template< class CoordFunctionInterface >
276 struct isCoordFunctionInterface
277 {
278 static const bool value = false;
279 };
280
281 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
282 struct isCoordFunctionInterface
283 < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > >
284 {
285 static const bool value = true;
286 };
287
288 template< class ct, unsigned int dimR, class Impl >
289 struct isCoordFunctionInterface
290 < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
291 {
292 static const bool value = true;
293 };
294
295
296
297 // isDiscreteCoordFunctionInterface
298 // --------------------------------
299
300 template< class CoordFunctionInterface >
301 struct isDiscreteCoordFunctionInterface
302 {
303 static const bool value = false;
304 };
305
306 template< class ct, unsigned int dimR, class Impl >
307 struct isDiscreteCoordFunctionInterface
308 < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
309 {
310 static const bool value = true;
311 };
312
313
314
315 // AdaptCoordFunction
316 // ------------------
317
318 template< class CoordFunctionInterface >
319 struct AdaptCoordFunction
320 {
321 static void adapt ( CoordFunctionInterface &coordFunction )
322 {}
323 };
324
325 template< class ct, unsigned int dimR, class Impl >
326 struct AdaptCoordFunction< DiscreteCoordFunctionInterface< ct, dimR, Impl > >
327 {
328 typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > CoordFunctionInterface;
329
330 static void adapt ( CoordFunctionInterface &coordFunction )
331 {
332 coordFunction.adapt();
333 }
334 };
335
336 } // namespace GeoGrid
337
338} // namespace Dune
339
340#endif // #ifndef DUNE_GEOGRID_COORDFUNCTION_HH
Interface class for using an analytical function to define the geometry of a Dune::GeometryGrid....
Definition: coordfunction.hh:42
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:62
void evaluate(const DomainVector &x, RangeVector &y) const
evaluate method for global mapping
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:57
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:52
static const unsigned int dimDomain
dimension of the range vector (dimensionworld of host grid)
Definition: coordfunction.hh:55
FieldVector< ctype, dimDomain > DomainVector
domain vector for the evaluate method
Definition: coordfunction.hh:60
Derive an implementation of an analytical coordinate function from this class.
Definition: coordfunction.hh:132
Interface class for using a discrete function to define the geometry of a Dune::GeometryGrid....
Definition: coordfunction.hh:173
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:186
void evaluate(const HostEntity &hostEntity, unsigned int corner, RangeVector &y) const
evaluate method
Definition: coordfunction.hh:206
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:183
void adapt()
method called from grid.adapt() method to allow adaptation of the discrete coordinate function
Definition: coordfunction.hh:215
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:189
Derive an implementation of a discrete coordinate function from this class.
Definition: coordfunction.hh:243
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Implements a vector constructed from a given type representing a field and a compile-time given size.
typename detected_or< nonesuch, Op, Args... >::value_t is_detected
Detects whether Op<Args...> is valid.
Definition: type_traits.hh:340
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)