CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 #ifndef _AdaptiveRKStepper_h_ 00002 #define _AdaptiveRKStepper_h_ 00003 #include "CLHEP/GenericFunctions/RKIntegrator.hh" 00004 // 00005 // This is the default RKStepper routine, used within the RKIntegrator 00006 // when no other stepper is provided. 00007 // 00008 namespace Genfun { 00009 00010 class AdaptiveRKStepper:public RKIntegrator::RKStepper { 00011 00012 public: 00013 00014 class EEStepper; 00015 00016 // Constructor. A default stepper is created if none 00017 // is specified--it is an Embedded Runge Kutta stepper 00018 // using a Cash-Karp extended Butcher Tableau, which 00019 // is fourth-order. 00020 AdaptiveRKStepper(const EEStepper *eeStepper=NULL); 00021 00022 // Copy constructor: 00023 AdaptiveRKStepper(const AdaptiveRKStepper & right); 00024 00025 // Destructor: 00026 virtual ~AdaptiveRKStepper(); 00027 00028 // Takes *multiple* steps if needed up to or exceeding the 00029 // specified time. This called from the RKFunction and not 00030 // by users. If a time limit is specified, only one step 00031 // is taken--this mode is used to interpolate between cached 00032 // meshpoints. 00033 00034 // Input: data contains diffEqn information and cache: 00035 // sData a summary of starting point information 00036 // timeLimit (if nonzero) time limit for step 00037 // Output dData a summary of into at the ending point. 00038 // 00039 00040 virtual void step (const RKIntegrator::RKData * data, 00041 const RKIntegrator::RKData::Data & sdata, 00042 RKIntegrator::RKData::Data & ddata, 00043 double timeLimit) const ; 00044 // Clone 00045 virtual AdaptiveRKStepper *clone() const; 00046 00047 // Accessors and modifiers to algorithmic parameters. Roughly 00048 // speaking these are ordered according to importance: the user 00049 // will often wish to modify the tolerance and the starting 00050 // stepsize, but rarely should need to touch any of the others. 00051 00052 // The tolerance: 00053 double & tolerance(); 00054 const double & tolerance() const; 00055 00056 // The starting stepsize: 00057 double & startingStepsize(); 00058 const double & startingStepsize() const; 00059 00060 // The safety factor. Step size increases are moderated by this 00061 // factor: 00062 double & safetyFactor(); 00063 const double & safetyFactor() const; 00064 00065 // The minimum amount by which a step size is decreased: 00066 double & rmin(); 00067 const double & rmin() const; 00068 00069 // The maximum amount by which a step size is increased: 00070 double & rmax(); 00071 const double & rmax() const; 00072 00073 00074 private: 00075 00076 // It is illegal to assign an AdaptiveRKStepper: 00077 AdaptiveRKStepper & operator=(const AdaptiveRKStepper & right); 00078 00079 const EEStepper *eeStepper; 00080 double T; 00081 double sStepsize; 00082 double S; 00083 double Rmin; 00084 double Rmax; 00085 mutable double stepsize; 00086 }; 00087 00088 00089 // 00090 // An abstract base class for steppers that return an error 00091 // estimate at each step: 00092 // 00093 class AdaptiveRKStepper::EEStepper { 00094 public: 00095 00096 virtual ~EEStepper(); 00097 virtual void step (const RKIntegrator::RKData * data, 00098 const RKIntegrator::RKData::Data & sdata, 00099 RKIntegrator::RKData::Data & ddata, 00100 std::vector<double> & errors) const = 0; 00101 virtual EEStepper *clone() const=0; 00102 virtual unsigned int order() const=0; 00103 }; 00104 } 00105 00106 #endif