include/deal.II/algorithms/timestep_control.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: timestep_control.h 25460 2012-04-27 09:19:06Z bangerth @f$
00003 //
00004 //    Copyright (C) 2010, 2012 by Guido Kanschat
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 
00013 #ifndef __deal2__time_step_control_h
00014 #define __deal2__time_step_control_h
00015 
00016 #include <deal.II/base/subscriptor.h>
00017 #include <deal.II/base/smartpointer.h>
00018 #include <deal.II/lac/vector_memory.h>
00019 #include <cstdio>
00020 
00021 DEAL_II_NAMESPACE_OPEN
00022 
00023 class ParameterHandler;
00024 
00025 namespace Algorithms
00026 {
00048   class TimestepControl : public Subscriptor
00049   {
00050     public:
00057       enum Strategy
00058       {
00066             uniform,
00081             doubling
00082       };
00083 
00088       TimestepControl (double start = 0.,
00089                        double final = 1.,
00090                        double tolerance = 1.e-2,
00091                        double start_step = 1.e-2,
00092                        double print_step = -1.,
00093                        double max_step = 1.);
00094 
00100       static void declare_parameters (ParameterHandler& param);
00105       void parse_parameters (ParameterHandler& param);
00106 
00110       double start () const;
00118       double final () const;
00123       double tolerance () const;
00128       double step () const;
00129 
00133       double now () const;
00134 
00143       bool advance ();
00144 
00148       void start (double);
00152       void final (double);
00156       void tolerance (double);
00160       void strategy (Strategy);
00161 
00167       void start_step (double);
00168 
00173       void max_step (double);
00174 
00181       void restart ();
00186       bool print ();
00190       void file_name_format (const char*);
00191       const char* file_name_format ();
00192     private:
00193 
00194       double start_val;
00195       double final_val;
00196       double tolerance_val;
00197       Strategy strategy_val;
00198       double start_step_val;
00199       double max_step_val;
00200       double min_step_val;
00206       double current_step_val;
00207       double step_val;
00208 
00209       double now_val;
00210       double print_step;
00211       double next_print_val;
00212 
00213       char format[30];
00214   };
00215 
00216 
00217   inline double
00218   TimestepControl::start () const
00219   {
00220     return start_val;
00221   }
00222 
00223 
00224   inline double
00225   TimestepControl::final () const
00226   {
00227     return final_val;
00228   }
00229 
00230 
00231   inline double
00232   TimestepControl::step () const
00233   {
00234     return current_step_val;
00235   }
00236 
00237 
00238   inline double
00239   TimestepControl::tolerance () const
00240   {
00241     return tolerance_val;
00242   }
00243 
00244 
00245   inline double
00246   TimestepControl::now () const
00247   {
00248     return now_val;
00249   }
00250 
00251 
00252   inline void
00253   TimestepControl::start (double t)
00254   {
00255     start_val = t;
00256   }
00257 
00258 
00259   inline void
00260   TimestepControl::final (double t)
00261   {
00262     final_val = t;
00263   }
00264 
00265 
00266   inline void
00267   TimestepControl::tolerance (double t)
00268   {
00269     tolerance_val = t;
00270   }
00271 
00272 
00273   inline void
00274   TimestepControl::strategy (Strategy t)
00275   {
00276     strategy_val = t;
00277   }
00278 
00279 
00280   inline void
00281   TimestepControl::start_step (double t)
00282   {
00283     start_step_val = t;
00284   }
00285 
00286 
00287   inline void
00288   TimestepControl::max_step (double t)
00289   {
00290     max_step_val = t;
00291   }
00292 
00293 
00294   inline void
00295   TimestepControl::restart ()
00296   {
00297     now_val = start_val;
00298     step_val = start_step_val;
00299     current_step_val = step_val;
00300     if (print_step > 0.)
00301       next_print_val = now_val + print_step;
00302     else
00303       next_print_val = now_val - 1.;
00304   }
00305 
00306 
00307   inline void
00308   TimestepControl::file_name_format (const char* fmt)
00309   {
00310     strcpy(format, fmt);
00311   }
00312 
00313 
00314   inline const char*
00315   TimestepControl::file_name_format ()
00316   {
00317     return format;
00318   }
00319 }
00320 
00321 DEAL_II_NAMESPACE_CLOSE
00322 
00323 #endif
00324 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Thu May 17 2012 20:04:34 by doxygen 1.7.3