OdeSolution.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 
00030 #ifndef _ODESOLUTION_HPP_
00031 #define _ODESOLUTION_HPP_
00032 
00033 #include <vector>
00034 #include <string>
00035 #include <cassert>
00036 #include <boost/shared_ptr.hpp>
00037 
00038 #include "AbstractOdeSystemInformation.hpp"
00039 #include "AbstractParameterisedSystem.hpp"
00040 
00041 #ifdef CHASTE_CVODE
00042 // CVODE headers
00043 #include <nvector/nvector_serial.h>
00044 #endif // CHASTE_CVODE
00045 
00046 class AbstractOdeSystem; // Avoid cyclic include issues
00047 
00051 class OdeSolution
00052 {
00053 private:
00055     unsigned mNumberOfTimeSteps;
00056 
00058     std::vector<double> mTimes;
00059 
00061     std::vector<std::vector<double> > mSolutions;
00062 
00064     std::vector<std::vector<double> > mDerivedQuantities;
00065 
00067     std::vector<double> mParameters;
00068     
00070     std::string mSolverName;
00071 
00077     boost::shared_ptr<const AbstractOdeSystemInformation> mpOdeSystemInformation;
00078 
00079 public:
00083     OdeSolution();
00084 
00090     unsigned GetNumberOfTimeSteps() const;
00091 
00097     void SetNumberOfTimeSteps(unsigned numTimeSteps);
00098 
00104     void SetOdeSystemInformation(boost::shared_ptr<const AbstractOdeSystemInformation> pOdeSystemInfo);
00105 
00114     std::vector<double> GetVariableAtIndex(unsigned index) const;
00115 
00122     std::vector<double> GetAnyVariable(const std::string& rName) const;
00123 
00129     std::vector<double>& rGetTimes();
00130 
00136     const std::vector<double>& rGetTimes() const;
00137 
00143     std::vector<std::vector<double> >& rGetSolutions();
00144 
00150     const std::vector<std::vector<double> >& rGetSolutions() const;
00151 
00152 
00156     void SetSolverName(std::string solverName)
00157     {
00158         mSolverName = solverName;
00159     }
00160 
00162     std::string GetSolverName()
00163     {
00164         return mSolverName;
00165     }
00166 
00172     template<typename VECTOR>
00173     void CalculateDerivedQuantitiesAndParameters(AbstractParameterisedSystem<VECTOR>* pOdeSystem);
00174 
00181     std::vector<std::vector<double> >& rGetDerivedQuantities(AbstractParameterisedSystem<std::vector<double> >* pOdeSystem);
00182 
00183 #ifdef CHASTE_CVODE
00184 
00190     std::vector<std::vector<double> >& rGetDerivedQuantities(AbstractParameterisedSystem<N_Vector>* pOdeSystem);
00191 #endif //CHASTE_CVODE
00192 
00200     template<typename VECTOR>
00201     std::vector<double>& rGetParameters(AbstractParameterisedSystem<VECTOR>* pOdeSystem);
00202 
00217     void WriteToFile(std::string directoryName,
00218                      std::string baseResultsFilename,
00219                      std::string timeUnits,
00220                      unsigned stepsPerRow=1,
00221                      bool cleanDirectory=true,
00222                      unsigned precision=8,
00223                      bool includeDerivedQuantities=false);
00224 };
00225 
00226 
00227 #endif //_ODESOLUTION_HPP_

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