Reference documentation for deal.II version 8.5.1
timestep_control.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2010 - 2016 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii__time_step_control_h
18 #define dealii__time_step_control_h
19 
20 #include <deal.II/base/subscriptor.h>
21 #include <deal.II/base/smartpointer.h>
22 #include <deal.II/lac/vector_memory.h>
23 #include <cstdio>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 class ParameterHandler;
28 
29 namespace Algorithms
30 {
51  {
52  public:
57  enum Strategy
58  {
72  };
73 
77  TimestepControl (double start = 0.,
78  double final = 1.,
79  double tolerance = 1.e-2,
80  double start_step = 1.e-2,
81  double print_step = -1.,
82  double max_step = 1.);
83 
87  static void declare_parameters (ParameterHandler &param);
91  void parse_parameters (ParameterHandler &param);
92 
96  double start () const;
101  double final () const;
105  double tolerance () const;
109  double step () const;
110 
114  double now () const;
115 
120  bool advance ();
121 
125  void start (double);
129  void final (double);
133  void tolerance (double);
137  void strategy (Strategy);
138 
146  void start_step (const double step);
147 
151  void max_step (double);
152 
157  void restart ();
161  bool print ();
165  void file_name_format (const char *);
166  const char *file_name_format ();
167  private:
168 
169  double start_val;
170  double final_val;
171  double tolerance_val;
172  Strategy strategy_val;
173  double start_step_val;
174  double max_step_val;
175  double min_step_val;
181  double step_val;
182 
183  double now_val;
184  double print_step;
185  double next_print_val;
186 
187  char format[30];
188  };
189 
190 
191  inline double
193  {
194  return start_val;
195  }
196 
197 
198  inline double
200  {
201  return final_val;
202  }
203 
204 
205  inline double
207  {
208  return current_step_val;
209  }
210 
211 
212  inline double
214  {
215  return tolerance_val;
216  }
217 
218 
219  inline double
221  {
222  return now_val;
223  }
224 
225 
226  inline void
228  {
229  start_val = t;
230  }
231 
232 
233  inline void
235  {
236  final_val = t;
237  }
238 
239 
240  inline void
242  {
243  tolerance_val = t;
244  }
245 
246 
247  inline void
249  {
250  strategy_val = t;
251  }
252 
253 
254  inline void
256  {
257  start_step_val = t;
258  }
259 
260 
261  inline void
263  {
264  max_step_val = t;
265  }
266 
267 
268  inline void
270  {
271  now_val = start_val;
272  step_val = start_step_val;
273  current_step_val = step_val;
274  if (print_step > 0.)
275  next_print_val = now_val + print_step;
276  else
277  next_print_val = now_val - 1.;
278  }
279 
280 
281  inline void
282  TimestepControl::file_name_format (const char *fmt)
283  {
284  strcpy(format, fmt);
285  }
286 
287 
288  inline const char *
289  TimestepControl::file_name_format ()
290  {
291  return format;
292  }
293 }
294 
295 DEAL_II_NAMESPACE_CLOSE
296 
297 #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)