Reference documentation for deal.II version 8.1.0
timestep_control.h
1 // ---------------------------------------------------------------------
2 // @f$Id: timestep_control.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 2010 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 
18 #ifndef __deal2__time_step_control_h
19 #define __deal2__time_step_control_h
20 
21 #include <deal.II/base/subscriptor.h>
22 #include <deal.II/base/smartpointer.h>
23 #include <deal.II/lac/vector_memory.h>
24 #include <cstdio>
25 
27 
28 class ParameterHandler;
29 
30 namespace Algorithms
31 {
54  {
55  public:
62  enum Strategy
63  {
87  };
88 
93  TimestepControl (double start = 0.,
94  double final = 1.,
95  double tolerance = 1.e-2,
96  double start_step = 1.e-2,
97  double print_step = -1.,
98  double max_step = 1.);
99 
105  static void declare_parameters (ParameterHandler &param);
110  void parse_parameters (ParameterHandler &param);
111 
115  double start () const;
123  double final () const;
128  double tolerance () const;
133  double step () const;
134 
138  double now () const;
139 
148  bool advance ();
149 
153  void start (double);
157  void final (double);
161  void tolerance (double);
165  void strategy (Strategy);
166 
172  void start_step (double);
173 
178  void max_step (double);
179 
186  void restart ();
191  bool print ();
195  void file_name_format (const char *);
196  const char *file_name_format ();
197  private:
198 
199  double start_val;
200  double final_val;
201  double tolerance_val;
202  Strategy strategy_val;
203  double start_step_val;
204  double max_step_val;
205  double min_step_val;
212  double step_val;
213 
214  double now_val;
215  double print_step;
216  double next_print_val;
217 
218  char format[30];
219  };
220 
221 
222  inline double
224  {
225  return start_val;
226  }
227 
228 
229  inline double
231  {
232  return final_val;
233  }
234 
235 
236  inline double
238  {
239  return current_step_val;
240  }
241 
242 
243  inline double
245  {
246  return tolerance_val;
247  }
248 
249 
250  inline double
252  {
253  return now_val;
254  }
255 
256 
257  inline void
259  {
260  start_val = t;
261  }
262 
263 
264  inline void
266  {
267  final_val = t;
268  }
269 
270 
271  inline void
273  {
274  tolerance_val = t;
275  }
276 
277 
278  inline void
280  {
281  strategy_val = t;
282  }
283 
284 
285  inline void
287  {
288  start_step_val = t;
289  }
290 
291 
292  inline void
294  {
295  max_step_val = t;
296  }
297 
298 
299  inline void
301  {
302  now_val = start_val;
303  step_val = start_step_val;
304  current_step_val = step_val;
305  if (print_step > 0.)
306  next_print_val = now_val + print_step;
307  else
308  next_print_val = now_val - 1.;
309  }
310 
311 
312  inline void
313  TimestepControl::file_name_format (const char *fmt)
314  {
315  strcpy(format, fmt);
316  }
317 
318 
319  inline const char *
320  TimestepControl::file_name_format ()
321  {
322  return format;
323  }
324 }
325 
326 DEAL_II_NAMESPACE_CLOSE
327 
328 #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 parse_parameters(ParameterHandler &param)
static void declare_parameters(ParameterHandler &param)