Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
timestep_control.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2010 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_time_step_control_h
18 #define dealii_time_step_control_h
19 
20 #include <deal.II/base/smartpointer.h>
21 #include <deal.II/base/subscriptor.h>
22 
23 #include <deal.II/lac/vector_memory.h>
24 
25 #include <cstdio>
26 
27 DEAL_II_NAMESPACE_OPEN
28 
29 class ParameterHandler;
30 
31 namespace Algorithms
32 {
53  {
54  public:
59  enum Strategy
60  {
74  };
75 
79  TimestepControl(double start = 0.,
80  double final = 1.,
81  double tolerance = 1.e-2,
82  double start_step = 1.e-2,
83  double print_step = -1.,
84  double max_step = 1.);
85 
89  static void
94  void
96 
100  double
101  start() const;
106  double
107  final() const;
111  double
112  tolerance() const;
116  double
117  step() const;
118 
122  double
123  now() const;
124 
129  bool
130  advance();
131 
135  void
136  start(double);
140  void
141  final(double);
145  void
146  tolerance(double);
150  void strategy(Strategy);
151 
159  void
160  start_step(const double step);
161 
165  void
166  max_step(double);
167 
172  void
173  restart();
177  bool
178  print();
182  void
183  file_name_format(const char *);
184  const char *
185  file_name_format();
186 
187  private:
188  double start_val;
189  double final_val;
190  double tolerance_val;
191  Strategy strategy_val;
192  double start_step_val;
193  double max_step_val;
194  double min_step_val;
200  double step_val;
201 
202  double now_val;
203  double print_step;
204  double next_print_val;
205 
206  char format[30];
207  };
208 
209 
210  inline double
212  {
213  return start_val;
214  }
215 
216 
217  inline double
219  {
220  return final_val;
221  }
222 
223 
224  inline double
226  {
227  return current_step_val;
228  }
229 
230 
231  inline double
233  {
234  return tolerance_val;
235  }
236 
237 
238  inline double
240  {
241  return now_val;
242  }
243 
244 
245  inline void
247  {
248  start_val = t;
249  }
250 
251 
252  inline void
254  {
255  final_val = t;
256  }
257 
258 
259  inline void
261  {
262  tolerance_val = t;
263  }
264 
265 
266  inline void
268  {
269  strategy_val = t;
270  }
271 
272 
273  inline void
275  {
276  start_step_val = t;
277  }
278 
279 
280  inline void
282  {
283  max_step_val = t;
284  }
285 
286 
287  inline void
289  {
290  now_val = start_val;
291  step_val = start_step_val;
292  current_step_val = step_val;
293  if (print_step > 0.)
294  next_print_val = now_val + print_step;
295  else
296  next_print_val = now_val - 1.;
297  }
298 
299 
300  inline void
301  TimestepControl::file_name_format(const char *fmt)
302  {
303  strcpy(format, fmt);
304  }
305 
306 
307  inline const char *
308  TimestepControl::file_name_format()
309  {
310  return format;
311  }
312 } // namespace Algorithms
313 
314 DEAL_II_NAMESPACE_CLOSE
315 
316 #endif
TimestepControl(double start=0., double final=1., double tolerance=1.e-2, double start_step=1.e-2, double print_step=-1., double max_step=1.)
void start_step(const double step)
static void declare_parameters(ParameterHandler &param)
void parse_parameters(ParameterHandler &param)