Dune Core Modules (2.5.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
7
8namespace 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
60
61 private:
63 AnalyticalCoordFunctionInterface ( const This & ) = default;
66 This &operator= ( const This & ) = default;
67 This &operator= ( This && ) = default;
68
69 public:
71 void evaluate ( const DomainVector &x, RangeVector &y ) const
72 {
73 return asImp().evaluate( x, y );
74 }
75
76 protected:
77 const Implementation &asImp () const
78 {
79 return static_cast< const Implementation & >( *this );
80 }
81
82 Implementation &asImp ()
83 {
84 return static_cast< Implementation & >( *this );
85 }
86 };
87
88
89
90 // AnalyticalCoordFunction
91 // -----------------------
95 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
97 : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl >
98 {
101
102 public:
103 typedef typename Base :: DomainVector DomainVector;
104 typedef typename Base :: RangeVector RangeVector;
105
106 protected:
107 AnalyticalCoordFunction () = default;
108 AnalyticalCoordFunction ( const This & ) = default;
109 AnalyticalCoordFunction ( This && ) = default;
110 ~AnalyticalCoordFunction () = default;
111 This &operator= ( const This & ) = default;
112 This &operator= ( This && ) = default;
113
114 private:
115 void evaluate ( const DomainVector &x, RangeVector &y ) const;
116 };
117
118
119
120 // DiscreteCoordFunctionInterface
121 // ------------------------------
122
137 template< class ct, unsigned int dimR, class Impl >
139 {
141
142 friend class DiscreteCoordFunction< ct, dimR, Impl >;
143
144 public:
145 typedef This Interface;
146 typedef Impl Implementation;
147
149 typedef ct ctype;
150
152 static const unsigned int dimRange = dimR;
153
156
157 private:
159 DiscreteCoordFunctionInterface ( const This & ) = default;
160 DiscreteCoordFunctionInterface ( This && ) = default;
162 This &operator= ( const This & ) = default;
163 This &operator= ( This && ) = default;
164
165 public:
171 template< class HostEntity >
172 void evaluate ( const HostEntity &hostEntity, unsigned int corner,
173 RangeVector &y ) const
174 {
175 asImp().evaluate( hostEntity, corner, y );
176 }
177
181 void adapt ()
182 {
183 asImp().adapt();
184 }
185
186 protected:
187 const Implementation &asImp () const
188 {
189 return static_cast< const Implementation & >( *this );
190 }
191
192 Implementation &asImp ()
193 {
194 return static_cast< Implementation & >( *this );
195 }
196 };
197
198
199
200 // DiscreteCoordFunction
201 // ---------------------
202 //
206 template< class ct, unsigned int dimR, class Impl >
208 : public DiscreteCoordFunctionInterface< ct, dimR, Impl >
209 {
212
213 public:
214 typedef typename Base :: RangeVector RangeVector;
215
216 protected:
217 DiscreteCoordFunction () = default;
218 DiscreteCoordFunction ( const This & ) = default;
219 DiscreteCoordFunction ( This && ) = default;
220 ~DiscreteCoordFunction () = default;
221 This &operator= ( const This & ) = default;
222 This &operator= ( This && ) = default;
223
224 void adapt ()
225 {}
226
227 private:
228 template< class HostEntity >
229 void evaluate ( const HostEntity &hostEntity, unsigned int corner,
230 RangeVector &y ) const;
231 };
232
233
234
235 namespace GeoGrid
236 {
237
238 // isCoordFunctionInterface
239 // ------------------------
240
241 template< class CoordFunctionInterface >
242 struct isCoordFunctionInterface
243 {
244 static const bool value = false;
245 };
246
247 template< class ct, unsigned int dimD, unsigned int dimR, class Impl >
248 struct isCoordFunctionInterface
249 < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > >
250 {
251 static const bool value = true;
252 };
253
254 template< class ct, unsigned int dimR, class Impl >
255 struct isCoordFunctionInterface
256 < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
257 {
258 static const bool value = true;
259 };
260
261
262
263 // isDiscreteCoordFunctionInterface
264 // --------------------------------
265
266 template< class CoordFunctionInterface >
267 struct isDiscreteCoordFunctionInterface
268 {
269 static const bool value = false;
270 };
271
272 template< class ct, unsigned int dimR, class Impl >
273 struct isDiscreteCoordFunctionInterface
274 < DiscreteCoordFunctionInterface< ct, dimR, Impl > >
275 {
276 static const bool value = true;
277 };
278
279
280
281 // AdaptCoordFunction
282 // ------------------
283
284 template< class CoordFunctionInterface >
285 struct AdaptCoordFunction
286 {
287 static void adapt ( CoordFunctionInterface &coordFunction )
288 {}
289 };
290
291 template< class ct, unsigned int dimR, class Impl >
292 struct AdaptCoordFunction< DiscreteCoordFunctionInterface< ct, dimR, Impl > >
293 {
294 typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > CoordFunctionInterface;
295
296 static void adapt ( CoordFunctionInterface &coordFunction )
297 {
298 coordFunction.adapt();
299 }
300 };
301
302 } // namespace GeoGrid
303
304} // namespace Dune
305
306#endif // #ifndef DUNE_GEOGRID_COORDFUNCTION_HH
Interface class for using an analytical function to define the geometry of a Dune::GeometryGrid....
Definition: coordfunction.hh:39
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:59
void evaluate(const DomainVector &x, RangeVector &y) const
evaluate method for global mapping
Definition: coordfunction.hh:71
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:54
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:49
static const unsigned int dimDomain
dimension of the range vector (dimensionworld of host grid)
Definition: coordfunction.hh:52
FieldVector< ctype, dimDomain > DomainVector
domain vector for the evaluate method
Definition: coordfunction.hh:57
Derive an implementation of an analytical coordinate function from this class.
Definition: coordfunction.hh:98
Interface class for using a discrete function to define the geometry of a Dune::GeometryGrid....
Definition: coordfunction.hh:139
static const unsigned int dimRange
dimension of the range vector
Definition: coordfunction.hh:152
void evaluate(const HostEntity &hostEntity, unsigned int corner, RangeVector &y) const
evaluate method
Definition: coordfunction.hh:172
ct ctype
field type of the coordinate vector
Definition: coordfunction.hh:149
void adapt()
method called from grid.adapt() method to allow adaptation of the discrete coordinate function
Definition: coordfunction.hh:181
FieldVector< ctype, dimRange > RangeVector
range vector for the evaluate method
Definition: coordfunction.hh:155
Derive an implementation of a discrete coordinate function from this class.
Definition: coordfunction.hh:209
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.
Dune namespace.
Definition: alignment.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)