This source file includes following definitions.
- identity
- logistic_growth
- dalquist
- mcf_sphere
- set_timeProvider
- evaluate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <cmath>
22 #include <numeric>
23 #include "grid.h"
24 #include "grid_GridAndTime_impl.h"
25
26 using namespace std;
27 using Esfem::Grid::Deformation;
28
29 using Domain = Esfem::Grid::Deformation::Domain;
30
31 using Range = Esfem::Grid::Deformation::Range;
32
33 static_assert(Esfem::Grid::Deformation::Domain::dimension == 3,
34 "Bad domain dimension.");
35 static_assert(Esfem::Grid::Deformation::Range::dimension == 3,
36 "Bad range dimension.");
37
38
39 static inline void identity(const Domain& x, Range& y) noexcept{
40 y[0] = x[0];
41 y[1] = x[1];
42 y[2] = x[2];
43 }
44
45
46
47
48
49
50
51
52 static inline void logistic_growth(const double t, const Domain& x, Range& y) noexcept{
53 const double r_end = 2., r0 = 1., k = .5;
54 const double r = r_end * r0 / (r_end*exp(-k*t) + r0*(1-exp(-k*t)));
55 y = x;
56 y *= r;
57 }
58
59
60 static inline void dalquist(const double t, const Domain& x, Range& y){
61 const double factor = exp(-t);
62 y = x;
63 y *= factor;
64 }
65
66
67 static inline void mcf_sphere(const double t, const Domain& x, Range& y){
68 const double norm_square
69
70
71 = std::inner_product(&x[0], &x[0] + Domain::dimension, &x[0], 0.);
72 const double factor = sqrt( norm_square - 2 * Esfem::Grid::grid_dim() * t);
73 y = x;
74 y *= factor;
75 }
76
77
78
79
80 struct Esfem::Grid::Deformation::Data{
81
82
83
84 Impl::hash::grid hg;
85
86 const Dune::Fem::TimeProviderBase* tp_ptr {nullptr};
87
88 Data() = default;
89
90 Data(const std::string& fname) :hg {fname} {}
91 };
92
93 Esfem::Grid::Deformation::Deformation() :d_ptr {std::make_unique<Data>()} {}
94 Esfem::Grid::Deformation::Deformation(const std::string& fname)
95 :d_ptr {std::make_unique<Data>(fname)} {}
96 Esfem::Grid::Deformation::~Deformation() = default;
97
98 void Esfem::Grid::Deformation::
99 set_timeProvider(const Dune::Fem::TimeProviderBase& tp){
100 d_ptr -> tp_ptr = &tp;
101 }
102 void Esfem::Grid::Deformation::evaluate(const Domain& x, Range& y) const{
103
104
105
106
107
108
109
110
111
112
113 y = d_ptr->hg[x];
114
115
116
117 }
118 Deformation& Deformation::operator=(const Vec_FEfun& rhs){
119 d_ptr->hg = rhs;
120 return *this;
121 }