This source file includes following definitions.
- grid
- error_log
- paraview
- start_time
- global_timeStep
- max_timeSteps
- prePattern_timeSteps
- pattern_timeSteps
- last_step
- eps
- bdf_alphas
- bdf_gammas
- tg_a
- tg_b
- tg_Dc
- tg_gamma
- velocity_regularization
- surface_growthFactor
- mcf_regularization
- u_hom_value
- w_hom_value
- u_pertubation
- w_pertubation
- u_init_dof
- w_init_dof
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include <config.h>
17 #include <sstream>
18 #include <dune/fem/io/parameter.hh>
19 #include <dune/fem/io/file/dataoutput.hh>
20 #include <bdf.h>
21 #include <dassert.h>
22 #include "esfem_error.h"
23 #include "io_parameter.h"
24 #include "io_parameter_impl.h"
25
26 using namespace std;
27
28 using Esfem::Io::Parameter;
29
30
31
32 struct Parameter::Data{
33 const double t_0;
34 const double t_end;
35 const double t_end_pattern;
36 const double dT;
37 const std::string grid_dgf;
38 const std::string error_log;
39 const std::string paraview;
40 const double eps;
41 const std::vector<double> bdf_alphas;
42 const std::vector<double> bdf_gammas;
43
44 const double tg_a;
45 const double tg_b;
46 const double tg_Dc;
47 const double tg_gamma;
48 const double velocity_regularization;
49 const double surface_growthFactor;
50 const double mcf_regularization;
51 const double u_hom_value;
52 const double w_hom_value;
53 const double u_pertubation;
54 const double w_pertubation;
55 const std::string u_init_dof;
56 const std::string w_init_dof;
57 Data();
58 };
59
60 Esfem::Io::Parameter::Data::Data()
61 : t_0 {Dune::Fem::Parameter::getValue<double>("heat.starttime", 0.0)},
62 t_end {Dune::Fem::Parameter::getValue<double>("heat.endtime", 0.6)},
63 t_end_pattern {Dune::Fem::Parameter::getValue<double>("heat.pattern.endtime", t_end)},
64 dT {Dune::Fem::Parameter::getValue<double>("heat.timestep",0.1)},
65 grid_dgf {Esfem::Impl::get_macroGrid()},
66 error_log {Dune::Fem::Parameter::getValue<std::string>
67 ("fem.io.errorFile", Esfem::Impl::project_dir() + "output/l2h1error")},
68 paraview {Dune::Fem::Parameter::getValue<std::string>
69 ("fem.io.outputName", Esfem::Impl::project_dir() +
70 "output/ALE_LiteratureExample-")},
71 eps {Dune::Fem::Parameter::getValue<double>("heat.solvereps", 1e-8)},
72 bdf_alphas {NUMERIK::bdf_alpha_coeff
73 (Dune::Fem::Parameter::getValue<int>("heat.bdf", 1))},
74 bdf_gammas {NUMERIK::bdf_gamma_coeff
75 (Dune::Fem::Parameter::getValue<int>("heat.bdf", 1))},
76 tg_a {Dune::Fem::Parameter::getValue<double>("tumor_growth.heat.a", .1)},
77 tg_b {Dune::Fem::Parameter::getValue<double>("tumor_growth.heat.b", .9)},
78 tg_Dc {Dune::Fem::Parameter::getValue<double>("tumor_growth.heat.Dc", 10.)},
79 tg_gamma {Dune::Fem::Parameter::getValue<double>("tumor_growth.heat.gamma", 30.)},
80 velocity_regularization
81 {Dune::Fem::Parameter::getValue<double>("tumor_growth.surface.alpha", 1e-3)},
82 surface_growthFactor
83 {Dune::Fem::Parameter::getValue<double>("tumor_growth.surface.delta", .4)},
84 mcf_regularization
85 {Dune::Fem::Parameter::getValue<double>("tumor_growth.surface.epsilon", .01)},
86 u_hom_value {Dune::Fem::Parameter::getValue<double>
87 ("tumor_growth.heat.u_hom", tg_a + tg_b)},
88 w_hom_value {Dune::Fem::Parameter::getValue<double>
89 ("tumor_growth.heat.w_hom", tg_b / ( u_hom_value * u_hom_value ) )},
90 u_pertubation {Dune::Fem::Parameter::getValue<double>("tumor_growth.heat.u_pertubation", .01)},
91 w_pertubation {Dune::Fem::Parameter::getValue<double>("tumor_growth.heat.w_pertubation", .01)},
92 u_init_dof {Dune::Fem::Parameter::getValue<std::string>
93 ("tumor_growth.io.u_init_dof", Esfem::Impl::project_dir() + "output/u_dof.log")},
94 w_init_dof {Dune::Fem::Parameter::getValue<std::string>
95 ("tumor_growth.io.w_init_dof", Esfem::Impl::project_dir() + "output/w_dof.log")}
96 {
97 Assert::dynamic<Assert::level(1), Esfem::Parameter_error>
98 (eps > 0, Assert::compose(__FILE__, __LINE__, "Non positive tolerance."));
99 Assert::dynamic<Assert::level(1), Esfem::Parameter_error>
100 ( dT > eps, Assert::compose(__FILE__, __LINE__, "Time step too small."));
101 Assert::dynamic<Assert::level(1), Esfem::Parameter_error>
102 ((t_0 <= t_end_pattern) && (t_end_pattern <= t_end),
103 Assert::compose
104 (__FILE__, __LINE__, "Something is wrong with heat.starttime, "
105 "heat.endtime or heat.pattern.starttime."));
106 Esfem::Impl::file_check({grid_dgf, error_log, u_init_dof, w_init_dof});
107 }
108
109 Esfem::Io::Parameter::Parameter(int argc, char** argv,
110 const std::string& parameter_file_name){
111 Esfem::Impl::dune_fem_parameter_append(argc, argv, parameter_file_name);
112 d_ptr = make_unique<Data>();
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 }
159 Esfem::Io::Parameter::~Parameter() = default;
160 const std::string& Esfem::Io::Parameter::grid() const noexcept{
161 return d_ptr -> grid_dgf;
162 }
163 const std::string& Esfem::Io::Parameter::error_log() const noexcept{
164 return d_ptr -> error_log;
165 }
166 const std::string& Esfem::Io::Parameter::paraview() const noexcept{
167 return d_ptr -> paraview;
168 }
169 double Esfem::Io::Parameter::start_time() const noexcept{
170 return d_ptr -> t_0;
171 }
172 double Esfem::Io::Parameter::global_timeStep() const noexcept{
173 return d_ptr -> dT;
174 }
175 long Esfem::Io::Parameter::max_timeSteps() const{
176 const auto t_n = d_ptr->t_end;
177 const auto t_0 = d_ptr->t_0;
178 return (t_n - t_0)/d_ptr->dT + .1;
179 }
180 long Esfem::Io::Parameter::prePattern_timeSteps() const{
181 const auto t_n = d_ptr->t_end_pattern;
182 const auto t_0 = d_ptr->t_0;
183 return (t_n - t_0)/d_ptr->dT + .1;
184 }
185 long Esfem::Io::Parameter::pattern_timeSteps() const{
186 const auto t_n = d_ptr->t_end;
187 const auto t_0 = d_ptr->t_end_pattern;
188 return (t_n - t_0)/d_ptr->dT;
189 }
190 double Esfem::Io::Parameter::last_step() const{
191 const double rv = d_ptr->t_end - global_timeStep() * max_timeSteps();
192 return rv > 0 ? rv : 0;
193 }
194 double Esfem::Io::Parameter::eps() const noexcept{
195 return d_ptr -> eps;
196 }
197 const std::vector<double>& Esfem::Io::Parameter::bdf_alphas() const noexcept{
198 return d_ptr -> bdf_alphas;
199 }
200 const std::vector<double>& Esfem::Io::Parameter::bdf_gammas() const noexcept{
201 return d_ptr -> bdf_gammas;
202 }
203 double Esfem::Io::Parameter::tg_a() const noexcept{
204 return d_ptr -> tg_a;
205 }
206 double Esfem::Io::Parameter::tg_b() const noexcept{
207 return d_ptr -> tg_b;
208 }
209 double Esfem::Io::Parameter::tg_Dc() const noexcept{
210 return d_ptr -> tg_Dc;
211 }
212 double Esfem::Io::Parameter::tg_gamma() const noexcept{
213 return d_ptr -> tg_gamma;
214 }
215 double Parameter::velocity_regularization() const noexcept{
216 return d_ptr -> velocity_regularization;
217 }
218 double Parameter::surface_growthFactor() const noexcept{
219 return d_ptr -> surface_growthFactor;
220 }
221 double Parameter::mcf_regularization() const noexcept{
222 return d_ptr -> mcf_regularization;
223 }
224 double Esfem::Io::Parameter::u_hom_value() const noexcept{
225 return d_ptr -> u_hom_value;
226 }
227 double Esfem::Io::Parameter::w_hom_value() const noexcept{
228 return d_ptr -> w_hom_value;
229 }
230 double Esfem::Io::Parameter::u_pertubation() const noexcept{
231 return d_ptr -> u_pertubation;
232 }
233 double Esfem::Io::Parameter::w_pertubation() const noexcept{
234 return d_ptr -> w_pertubation;
235 }
236 const std::string& Esfem::Io::Parameter::u_init_dof() const noexcept{
237 return d_ptr -> u_init_dof;
238 }
239 const std::string& Esfem::Io::Parameter::w_init_dof() const noexcept{
240 return d_ptr -> w_init_dof;
241 }
242
243 std::ostream& Esfem::Io::operator<<(std::ostream& os, const Parameter& d){
244 using Dune::Fem::Parameter;
245 const auto& p = d.d_ptr;
246 os << "t_0: " << p->t_0 << '\n'
247 << "dT: " << p->dT << '\n'
248 << "t_end_pattern: " << p-> t_end_pattern << '\n'
249 << "t_end: " << p->t_end << '\n'
250 << "grid_dgf: " << p->grid_dgf << '\n'
251 << "error_log: " << p->error_log << '\n'
252 << "paraview: " << p->paraview << '\n'
253 << "eps: " << p->eps << '\n'
254 << "bdf_alphas: " << Esfem::Impl::doubleVector_to_string(p->bdf_alphas) << '\n'
255 << "bdf_gammas: " << Esfem::Impl::doubleVector_to_string(p->bdf_gammas) << '\n'
256 << "tg_a: " << p->tg_a << '\n'
257 << "tg_b: " << p->tg_b << '\n'
258 << "tg_Dc: " << p->tg_Dc << '\n'
259 << "tg_gamma: " << p->tg_gamma << '\n'
260 << "velocity_regularization: " << p->velocity_regularization << '\n'
261 << "surface_growthFactor: " << p->surface_growthFactor << '\n'
262 << "mcf_regularization: " << p->mcf_regularization << '\n'
263 << "u_hom_value: " << p -> u_hom_value << '\n'
264 << "w_hom_value: " << p -> w_hom_value << '\n'
265 << "u_pertubation: " << p -> u_pertubation << '\n'
266 << "w_pertubation: " << p -> w_pertubation << '\n'
267 << "u_init_dof: " << p -> u_init_dof << '\n'
268 << "w_init_dof: " << p -> w_init_dof << '\n'
269 << "logistic_growth.r_start: "
270 << Parameter::getValue<double>("logistic_growth.r_start", 1.) << '\n'
271 << "logistic_growth.r_end: "
272 << Parameter::getValue<double>("logistic_growth.r_end", 2.) << '\n'
273 << "logistic_growth.steepness: "
274 << Parameter::getValue<double>("logistic_growth.steepness", .5)
275 ;
276 return os;
277 }