RungeKuttaFehlbergIvpOdeSolver.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #ifndef _RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_
00030 #define _RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_
00031 
00032 #include <boost/serialization/access.hpp>
00033 #include <boost/serialization/base_object.hpp>
00034 
00035 #include "AbstractOneStepIvpOdeSolver.hpp"
00036 
00037 // Needs to be included last
00038 #include <boost/serialization/export.hpp>
00039 
00052 class RungeKuttaFehlbergIvpOdeSolver : public AbstractIvpOdeSolver
00053 {
00054 friend class TestRungeKuttaFehlbergIvpOdeSolver;
00055 
00056 private:
00058     friend class boost::serialization::access;
00065     template<class Archive>
00066     void serialize(Archive & archive, const unsigned int version)
00067     {
00068         // This calls serialize on the base class - all member variables instantiated on construction or temporary.
00069         archive & boost::serialization::base_object<AbstractIvpOdeSolver>(*this);
00070     }
00071 
00072     /*
00073      * All these are here for more efficient memory allocation, rather than
00074      * because they need to be member variables.
00075      */
00076 
00077     double m1932o2197;  
00078     double m7200o2197;  
00079     double m7296o2197;  
00080     double m12o13;      
00081     double m439o216;    
00082     double m3680o513;   
00083     double m845o4104;   
00084     double m8o27;       
00085     double m3544o2565;  
00086     double m1859o4104;  
00087     double m1o360;      
00088     double m128o4275;   
00089     double m2197o75240; 
00090     double m2o55;       
00091     double m25o216;     
00092     double m1408o2565;  
00093     double m2197o4104;  
00095     std::vector<double> mError; 
00097     std::vector<double> mk1;  
00098     std::vector<double> mk2;  
00099     std::vector<double> mk3;  
00100     std::vector<double> mk4;  
00101     std::vector<double> mk5;  
00102     std::vector<double> mk6;  
00103     std::vector<double> myk2; 
00104     std::vector<double> myk3; 
00105     std::vector<double> myk4; 
00106     std::vector<double> myk5; 
00107     std::vector<double> myk6; 
00109 protected:
00110 
00125     void InternalSolve(OdeSolution& rSolution,
00126                        AbstractOdeSystem* pAbstractOdeSystem,
00127                        std::vector<double>& rCurrentYValues,
00128                        std::vector<double>& rWorkingMemory,
00129                        double startTime,
00130                        double endTime,
00131                        double maxTimeStep,
00132                        double minTimeStep,
00133                        double tolerance,
00134                        bool outputSolution);
00135 
00146     void CalculateNextYValue(AbstractOdeSystem* pAbstractOdeSystem,
00147                              double timeStep,
00148                              double time,
00149                              std::vector<double>& rCurrentYValues,
00150                              std::vector<double>& rNextYValues);
00151 
00162     void AdjustStepSize(double& rCurrentStepSize,
00163                         const double& rError,
00164                         const double& rTolerance,
00165                         const double& rMaxTimeStep,
00166                         const double& rMinTimeStep);
00167 
00168 public:
00169 
00173     RungeKuttaFehlbergIvpOdeSolver();
00174 
00195     OdeSolution Solve(AbstractOdeSystem* pAbstractOdeSystem,
00196                       std::vector<double>& rYValues,
00197                       double startTime,
00198                       double endTime,
00199                       double timeStep,
00200                       double ignoredSamplingTime);
00201 
00217     void Solve(AbstractOdeSystem* pAbstractOdeSystem,
00218                std::vector<double>& rYValues,
00219                double startTime,
00220                double endTime,
00221                double timeStep);
00222 
00223 };
00224 
00225 BOOST_CLASS_EXPORT(RungeKuttaFehlbergIvpOdeSolver);
00226 
00227 #endif //_RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_

Generated on Tue Aug 4 16:10:24 2009 for Chaste by  doxygen 1.5.5