DUNE PDELab (2.8)

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:
208 template< class HostEntity >
209 void evaluate ( const HostEntity &hostEntity, unsigned int corner,
210 RangeVector &y ) const
211 {
212 asImp().evaluate( hostEntity, corner, y );
213 }
214
218 void adapt ()
219 {
220 asImp().adapt();
221 }
222
223 protected:
224 const Implementation &asImp () const
225 {
226 return static_cast< const Implementation & >( *this );
227 }
228
229 Implementation &asImp ()
230 {
231 return static_cast< Implementation & >( *this );
232 }
233 };
234
235
236
237 // DiscreteCoordFunction
238 // ---------------------
239 //
243 template< class ct, unsigned int dimR, class Impl >
245 : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
246 {
249
250 public:
251 typedef typename Base :: RangeVector RangeVector;
252
253 protected:
254 DiscreteCoordFunction () = default;
255 DiscreteCoordFunction ( const This & ) = default;
256 DiscreteCoordFunction ( This && ) = default;
257 ~DiscreteCoordFunction () = default;
258 This &operator= ( const This & ) = default;
259 This &operator= ( This && ) = default;
260
261 void adapt ()
262 {}
263
264 private:
265 template< class HostEntity >
266 void evaluate ( const HostEntity &hostEntity, unsigned int corner,
267 RangeVector &y ) const;
268 };
269
270
271
272 namespace GeoGrid
273 {
274
275 // isCoordFunctionInterface
276 // ------------------------
277
278 template< class CoordFunctionInterface >
279 struct isCoordFunctionInterface
280 {
281 static const bool value = false;
282 };
283
284 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
285 struct isCoordFunctionInterface
286 < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > >
287 {
288 static const bool value = true;
289 };
290
291 template< class ct, unsigned int dimR, class Impl >
292 struct isCoordFunctionInterface
293 < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
294 {
295 static const bool value = true;
296 };
297
298
299
300 // isDiscreteCoordFunctionInterface
301 // --------------------------------
302
303 template< class CoordFunctionInterface >
304 struct isDiscreteCoordFunctionInterface
305 {
306 static const bool value = false;
307 };
308
309 template< class ct, unsigned int dimR, class Impl >
310 struct isDiscreteCoordFunctionInterface
311 < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
312 {
313 static const bool value = true;
314 };
315
316
317
318 // AdaptCoordFunction
319 // ------------------
320
321 template< class CoordFunctionInterface >
322 struct AdaptCoordFunction
323 {
324 static void adapt ( CoordFunctionInterface & )
325 {}
326 };
327
328 template< class ct, unsigned int dimR, class Impl >
329 struct AdaptCoordFunction< DiscreteCoordFunctionInterface< ct, dimR, Impl > >
330 {
331 typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > CoordFunctionInterface;
332
333 static void adapt ( CoordFunctionInterface &coordFunction )
334 {
335 coordFunction.adapt();
336 }
337 };
338
339 } // namespace GeoGrid
340
341} // namespace Dune
342
343#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:209
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:218
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:246
vector space out of a tensor product of fields.
Definition: fvector.hh:95
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:326
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)