RungeKuttaFehlbergIvpOdeSolver.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
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 "ChasteSerialization.hpp"
00033 #include <boost/serialization/base_object.hpp>
00034 
00035 #include "AbstractOneStepIvpOdeSolver.hpp"
00036 
00049 class RungeKuttaFehlbergIvpOdeSolver : public AbstractIvpOdeSolver
00050 {
00051 friend class TestRungeKuttaFehlbergIvpOdeSolver;
00052 
00053 private:
00055     friend class boost::serialization::access;
00062     template<class Archive>
00063     void serialize(Archive & archive, const unsigned int version)
00064     {
00065         // This calls serialize on the base class - all member variables instantiated on construction or temporary.
00066         archive & boost::serialization::base_object<AbstractIvpOdeSolver>(*this);
00067     }
00068 
00069     /*
00070      * All these are here for more efficient memory allocation, rather than
00071      * because they need to be member variables.
00072      */
00073 
00074     double m1932o2197;  
00075     double m7200o2197;  
00076     double m7296o2197;  
00077     double m12o13;      
00078     double m439o216;    
00079     double m3680o513;   
00080     double m845o4104;   
00081     double m8o27;       
00082     double m3544o2565;  
00083     double m1859o4104;  
00084     double m1o360;      
00085     double m128o4275;   
00086     double m2197o75240; 
00087     double m2o55;       
00088     double m25o216;     
00089     double m1408o2565;  
00090     double m2197o4104;  
00092     std::vector<double> mError; 
00094     std::vector<double> mk1;  
00095     std::vector<double> mk2;  
00096     std::vector<double> mk3;  
00097     std::vector<double> mk4;  
00098     std::vector<double> mk5;  
00099     std::vector<double> mk6;  
00100     std::vector<double> myk2; 
00101     std::vector<double> myk3; 
00102     std::vector<double> myk4; 
00103     std::vector<double> myk5; 
00104     std::vector<double> myk6; 
00106 protected:
00107 
00122     void InternalSolve(OdeSolution& rSolution,
00123                        AbstractOdeSystem* pAbstractOdeSystem,
00124                        std::vector<double>& rCurrentYValues,
00125                        std::vector<double>& rWorkingMemory,
00126                        double startTime,
00127                        double endTime,
00128                        double maxTimeStep,
00129                        double minTimeStep,
00130                        double tolerance,
00131                        bool outputSolution);
00132 
00143     void CalculateNextYValue(AbstractOdeSystem* pAbstractOdeSystem,
00144                              double timeStep,
00145                              double time,
00146                              std::vector<double>& rCurrentYValues,
00147                              std::vector<double>& rNextYValues);
00148 
00159     void AdjustStepSize(double& rCurrentStepSize,
00160                         const double& rError,
00161                         const double& rTolerance,
00162                         const double& rMaxTimeStep,
00163                         const double& rMinTimeStep);
00164 
00165 public:
00166 
00170     RungeKuttaFehlbergIvpOdeSolver();
00171 
00192     OdeSolution Solve(AbstractOdeSystem* pAbstractOdeSystem,
00193                       std::vector<double>& rYValues,
00194                       double startTime,
00195                       double endTime,
00196                       double timeStep,
00197                       double ignoredSamplingTime);
00198 
00214     void Solve(AbstractOdeSystem* pAbstractOdeSystem,
00215                std::vector<double>& rYValues,
00216                double startTime,
00217                double endTime,
00218                double timeStep);
00219 
00220 };
00221 
00222 #include "SerializationExportWrapper.hpp"
00223 CHASTE_CLASS_EXPORT(RungeKuttaFehlbergIvpOdeSolver)
00224 
00225 #endif //_RUNGEKUTTAFEHLBERGIVPODESOLVER_HPP_

Generated on Mon Apr 18 11:35:36 2011 for Chaste by  doxygen 1.5.5