This source file includes following definitions.
- clone
- clone
- clone
- evaluate
- evaluate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #ifndef SECORD_OP_INITDATA_IMPL_H
23 #define SECORD_OP_INITDATA_IMPL_H
24
25 #include <random>
26 #include <functional>
27 #include <string>
28 #include <config.h>
29 #include <dune/fem/operator/lagrangeinterpolation.hh>
30 #include "secOrd_op_initData.h"
31 #include "grid.h"
32
33 namespace Esfem{
34 namespace Impl{
35
36 class Explicit_initial_data
37 : public Dune::Fem::Function<Esfem::Grid::Grid_and_time::Function_space,
38 Explicit_initial_data>
39 {
40 public:
41
42 using Fun_space = Esfem::Grid::Grid_and_time::Function_space;
43
44 using Domain = Fun_space::DomainType;
45
46 using Range = Fun_space::RangeType;
47
48 static_assert(Domain::dimension == 3, "Bad Domain dimension");
49 static_assert(Range::dimension == 1, "Bad Range dimension");
50
51
52
53
54
55
56 Explicit_initial_data(const Esfem::Grid::Grid_and_time&,
57 const Esfem::Growth);
58
59 Explicit_initial_data(const Explicit_initial_data&) = delete;
60
61 Explicit_initial_data& operator=(const Explicit_initial_data&) = delete;
62
63
64 void evaluate(const Domain&, Range&) const;
65 private:
66
67 const Dune::Fem::TimeProviderBase& tp;
68
69 std::function<void(const Domain&,Range&)> fun_impl;
70 };
71
72
73 class Random_initial_data
74 : public Dune::Fem::Function<Esfem::Grid::Grid_and_time::Function_space,
75 Random_initial_data>
76 {
77 public:
78
79 using Fun_space = Esfem::Grid::Grid_and_time::Function_space;
80
81 using Domain = typename Fun_space::DomainType;
82
83 using Range = typename Fun_space::RangeType;
84
85 static_assert(Domain::dimension == 3, "Bad Domain dimension");
86 static_assert(Range::dimension == 1, "Bad Range dimension");
87
88
89 Random_initial_data(const Esfem::Io::Parameter&,
90 const Esfem::Growth);
91
92
93 void evaluate(const Domain&, Range&) const;
94 private:
95
96 using Random_dist = std::uniform_real_distribution<>;
97
98 using Random_engine = std::default_random_engine;
99
100
101 std::function<double()> random_fun;
102
103
104 Random_initial_data(const double hom_value, const double pertubation);
105 };
106
107
108
109 struct sphere_1EF
110 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Function_space,
111 sphere_1EF>,
112 SecOrd_op::sIdata{
113
114 using fspace = Esfem::Grid::Grid_and_time::Function_space;
115
116 using domain = typename fspace::DomainType;
117
118 using range = typename fspace::RangeType;
119 static_assert(domain::dimension == 3, "Bad Domain dimension");
120 static_assert(range::dimension == 1, "Bad Range dimension");
121
122 sphere_1EF(const Grid::Grid_and_time&);
123 sphere_1EF* clone() override;
124 void interpolate(Grid::Scal_FEfun&) const override;
125
126 void evaluate(const domain&, range&) const;
127 private:
128
129 const Dune::Fem::TimeProviderBase& tp;
130 };
131
132
133 struct sphere_2EF
134 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Function_space,
135 sphere_2EF>,
136 SecOrd_op::sIdata{
137
138 using fspace = Esfem::Grid::Grid_and_time::Function_space;
139
140 using domain = typename fspace::DomainType;
141
142 using range = typename fspace::RangeType;
143 static_assert(domain::dimension == 3, "Bad Domain dimension");
144 static_assert(range::dimension == 1, "Bad Range dimension");
145
146 sphere_2EF(const Grid::Grid_and_time&);
147 sphere_2EF* clone() override;
148 void interpolate(Grid::Scal_FEfun&) const override;
149
150 void evaluate(const domain&, range&) const;
151 private:
152
153 const Dune::Fem::TimeProviderBase& tp;
154 };
155
156
157 struct sphere_3EF
158 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Function_space,
159 sphere_3EF>,
160 SecOrd_op::sIdata{
161
162 using fspace = Esfem::Grid::Grid_and_time::Function_space;
163
164 using domain = typename fspace::DomainType;
165
166 using range = typename fspace::RangeType;
167 static_assert(domain::dimension == 3, "Bad Domain dimension");
168 static_assert(range::dimension == 1, "Bad Range dimension");
169
170 sphere_3EF(const Grid::Grid_and_time&);
171 sphere_3EF* clone() override;
172 void interpolate(Grid::Scal_FEfun&) const override;
173
174 void evaluate(const domain&, range&) const;
175 private:
176
177 const Dune::Fem::TimeProviderBase& tp;
178 };
179
180
181
182 struct sphere_eigenFun
183 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Vec_Function_space,
184 sphere_eigenFun>,
185 SecOrd_op::vIdata{
186
187 using Fun_space = Esfem::Grid::Grid_and_time::Vec_Function_space;
188
189 using Domain = typename Fun_space::DomainType;
190
191 using Range = typename Fun_space::RangeType;
192
193 static_assert(Domain::dimension == 3, "Bad Domain dimension");
194 static_assert(Range::dimension == 3, "Bad Range dimension");
195
196 sphere_eigenFun(const Grid::Grid_and_time&);
197 sphere_eigenFun* clone() override;
198 void interpolate(Grid::Vec_FEfun&) const override;
199
200 void evaluate(const Domain&, Range&) const;
201 private:
202
203 const Dune::Fem::TimeProviderBase& tp;
204 };
205
206
207
208 struct sphere_mcf_sol
209 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Vec_Function_space,
210 sphere_mcf_sol>,
211 SecOrd_op::vIdata{
212
213 using Fun_space = Esfem::Grid::Grid_and_time::Vec_Function_space;
214
215 using Domain = typename Fun_space::DomainType;
216
217 using Range = typename Fun_space::RangeType;
218
219 static_assert(Domain::dimension == 3, "Bad Domain dimension");
220 static_assert(Range::dimension == 3, "Bad Range dimension");
221
222 sphere_mcf_sol(const Grid::Grid_and_time&);
223 sphere_mcf_sol* clone() override;
224 void interpolate(Grid::Vec_FEfun&) const override;
225
226 void evaluate(const Domain&, Range&) const;
227 private:
228
229 const Dune::Fem::TimeProviderBase& tp;
230 };
231
232
233
234
235 struct sls_iData
236 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Vec_Function_space,
237 sls_iData>,
238 SecOrd_op::vIdata{
239
240 using Fun_space = Esfem::Grid::Grid_and_time::Vec_Function_space;
241
242 using Domain = typename Fun_space::DomainType;
243
244 using Range = typename Fun_space::RangeType;
245
246 static_assert(Domain::dimension == 3, "Bad Domain dimension");
247 static_assert(Range::dimension == 3, "Bad Range dimension");
248
249 sls_iData(const Grid::Grid_and_time&);
250 sls_iData* clone() override{ return new sls_iData {*this}; }
251 void interpolate(Grid::Vec_FEfun&) const override;
252
253 void evaluate(const Domain&, Range&) const;
254 private:
255
256 const Dune::Fem::TimeProviderBase& tp;
257
258 double rA;
259
260 double rE;
261
262 double k;
263 };
264
265
266
267 struct sls_v_iData
268 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Vec_Function_space,
269 sls_v_iData>,
270 SecOrd_op::vIdata{
271
272 using Fun_space = Esfem::Grid::Grid_and_time::Vec_Function_space;
273
274 using Domain = typename Fun_space::DomainType;
275
276 using Range = typename Fun_space::RangeType;
277
278 static_assert(Domain::dimension == 3, "Bad Domain dimension");
279 static_assert(Range::dimension == 3, "Bad Range dimension");
280
281 sls_v_iData(const Grid::Grid_and_time&);
282 sls_v_iData* clone() override{ return new sls_v_iData {*this}; }
283 void interpolate(Grid::Vec_FEfun&) const override;
284
285 void evaluate(const Domain&, Range&) const;
286 private:
287
288 const Dune::Fem::TimeProviderBase& tp;
289
290 double rA;
291
292 double rE;
293
294 double k;
295 };
296
297
298
299
300 struct sd_iData
301 : Dune::Fem::Function<Esfem::Grid::Grid_and_time::Vec_Function_space,
302 sd_iData>,
303 SecOrd_op::vIdata{
304
305 using Fun_space = Esfem::Grid::Grid_and_time::Vec_Function_space;
306
307 using Domain = typename Fun_space::DomainType;
308
309 using Range = typename Fun_space::RangeType;
310
311 static_assert(Domain::dimension == 3, "Bad Domain dimension");
312 static_assert(Range::dimension == 3, "Bad Range dimension");
313
314
315 sd_iData(const Grid::Grid_and_time&);
316 sd_iData* clone() override{ return new sd_iData {*this}; }
317 void interpolate(Grid::Vec_FEfun&) const override;
318
319 void evaluate(const Domain&, Range&) const;
320 private:
321
322 const Dune::Fem::TimeProviderBase& tp;
323 };
324
325
326 class Analytic_velocity
327 : public Dune::Fem::Function<Esfem::Grid::Grid_and_time::Vec_Function_space,
328 Analytic_velocity>
329 {
330 public:
331
332 using Fun_space = Esfem::Grid::Grid_and_time::Vec_Function_space;
333
334 using Domain = typename Fun_space::DomainType;
335
336 using Range = typename Fun_space::RangeType;
337
338 static_assert(Domain::dimension == 3, "Bad Domain dimension");
339 static_assert(Range::dimension == 3, "Bad Range dimension");
340
341
342 Analytic_velocity(const Esfem::Grid::Grid_and_time&);
343
344 Analytic_velocity(const Analytic_velocity&) = delete;
345
346 Analytic_velocity& operator=(const Analytic_velocity&) = delete;
347
348
349 void evaluate(const Domain&, Range&) const;
350 private:
351
352 const Dune::Fem::TimeProviderBase& tp;
353 };
354
355
356
357
358
359
360 double hom_value(const Esfem::Io::Parameter&, const Esfem::Growth);
361 double pertubation(const Esfem::Io::Parameter&, const Esfem::Growth);
362 std::string print_configuration(const Esfem::Io::Parameter&, const Esfem::Growth);
363
364
365
366 std::string dof_filename(const Io::Parameter&, const Growth);
367 }
368
369
370
371 struct SecOrd_op::Init_data::Data{
372
373 const std::string dof_io_filename {};
374
375 std::unique_ptr<Impl::Explicit_initial_data> eid_ptr;
376
377 std::unique_ptr<Impl::Random_initial_data> rid_ptr;
378
379
380
381 Data(const Grid::Grid_and_time&, const Growth);
382
383 Data(const Io::Parameter&, const Growth);
384 };
385
386
387 struct SecOrd_op::Exact_velocity::Data{
388
389 Impl::Analytic_velocity v_fun;
390
391
392 Data(const Grid::Grid_and_time&);
393 };
394 }
395
396
397
398
399 inline void Esfem::Impl::Explicit_initial_data::
400 evaluate(const Domain& d, Range& r) const{
401 fun_impl(d,r);
402 }
403 inline void Esfem::Impl::Random_initial_data::
404 evaluate(const Domain&, Range& q) const{
405 q = random_fun();
406 }
407
408 #endif