00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2006, 2007, 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 00024 #ifndef O2SCL_ADAPT_STEP_H 00025 #define O2SCL_ADAPT_STEP_H 00026 00027 #include <o2scl/odestep.h> 00028 #include <o2scl/gsl_rkck.h> 00029 #include <o2scl/ode_funct.h> 00030 00031 #ifndef DOXYGENP 00032 namespace o2scl { 00033 #endif 00034 00035 /** 00036 \brief Adaptive stepper [abstract base] 00037 00038 The adaptive stepper routines are based on several applications 00039 of ordinary ODE steppers (implemented in \ref odestep). Each 00040 adaptive stepper (gsl_astep or nonadapt_step) can be used with 00041 any of the ODE stepper classes (e.g. gsl_rkck). By default, 00042 gsl_rkck is used. To modify the ODE stepper which is used, use 00043 the member function set_step() documented below. 00044 00045 \note If you use gsl_rkck_fast or gsl_rk8pd_fast, you'll 00046 need to make sure that the argument \c n to astep() or 00047 astep_derivs() below matches the template size parameter 00048 given in the ODE stepper. 00049 */ 00050 template<class param_t, class func_t=ode_funct<param_t>, 00051 class vec_t=ovector_base, class alloc_vec_t=ovector, 00052 class alloc_t=ovector_alloc> class adapt_step { 00053 00054 public: 00055 00056 adapt_step() { 00057 stepp=&def_step; 00058 verbose=0; 00059 } 00060 00061 virtual ~adapt_step() {} 00062 00063 /** 00064 \brief Make an adaptive integration step of the system 00065 \c derivs 00066 00067 This attempts to take a step of size \c h from the point \c 00068 x of an \c n-dimensional system \c derivs starting with \c 00069 y. On exit, \c x and \c y contain the new values at the end 00070 of the step, \c h contains the size of the step, \c dydx_out 00071 contains the derivative at the end of the step, and \c yerr 00072 contains the estimated error at the end of the step. 00073 */ 00074 virtual int astep(double &x, double &h, double xmax, 00075 size_t n, vec_t &y, vec_t &dydx_out, 00076 vec_t &yerr, param_t &pa, 00077 func_t &derivs)=0; 00078 00079 /** 00080 \brief Make an adaptive integration step of the system 00081 \c derivs with derivatives 00082 00083 This attempts to take a step of size \c h from the point \c 00084 x of an \c n-dimensional system \c derivs starting with \c y 00085 and given the initial derivatives \c dydx. On exit, \c x, \c 00086 y and \c dydx contain the new values at the end of the step, 00087 \c h contains the size of the step, \c dydx contains the 00088 derivative at the end of the step, and \c yerr contains the 00089 estimated error at the end of the step. 00090 */ 00091 virtual int astep_derivs(double &x, double &h, double xmax, 00092 size_t n, vec_t &y, vec_t &dydx, 00093 vec_t &yerr, param_t &pa, 00094 func_t &derivs)=0; 00095 00096 /// Set output level 00097 int verbose; 00098 00099 /** 00100 \brief Set stepper 00101 00102 This sets the stepper for use in the adaptive step 00103 routine. If no stepper is specified, then the default 00104 (gsl_rkck) is used. 00105 */ 00106 int set_step(odestep<param_t,func_t,vec_t> &step) { 00107 stepp=&step; 00108 return 0; 00109 } 00110 00111 /// The default stepper 00112 gsl_rkck<param_t,func_t,vec_t,alloc_vec_t,alloc_t> def_step; 00113 00114 #ifndef DOXYGEN_INTERNAL 00115 00116 protected: 00117 00118 /// Pointer to the stepper being used 00119 odestep<param_t,func_t,vec_t> *stepp; 00120 00121 #endif 00122 00123 }; 00124 00125 #ifndef DOXYGENP 00126 } 00127 #endif 00128 00129 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page