Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
OdeSolution.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36
37#ifndef _ODESOLUTION_HPP_
38#define _ODESOLUTION_HPP_
39
40#include <vector>
41#include <string>
42#include <cassert>
43#include <boost/shared_ptr.hpp>
44
45#include "AbstractOdeSystemInformation.hpp"
46#include "AbstractParameterisedSystem.hpp"
47
48#ifdef CHASTE_CVODE
49// CVODE headers
50#include <nvector/nvector_serial.h>
51#endif // CHASTE_CVODE
52
53class AbstractOdeSystem; // Avoid cyclic include issues
54
59{
60private:
63
65 std::vector<double> mTimes;
66
68 std::vector<std::vector<double> > mSolutions;
69
71 std::vector<std::vector<double> > mDerivedQuantities;
72
74 std::vector<double> mParameters;
75
77 std::string mSolverName;
78
84 boost::shared_ptr<const AbstractOdeSystemInformation> mpOdeSystemInformation;
85
86public:
91
97 unsigned GetNumberOfTimeSteps() const;
98
104 void SetNumberOfTimeSteps(unsigned numTimeSteps);
105
111 void SetOdeSystemInformation(boost::shared_ptr<const AbstractOdeSystemInformation> pOdeSystemInfo);
112
121 std::vector<double> GetVariableAtIndex(unsigned index) const;
122
129 std::vector<double> GetAnyVariable(const std::string& rName) const;
130
136 std::vector<double>& rGetTimes();
137
143 const std::vector<double>& rGetTimes() const;
144
150 std::vector<std::vector<double> >& rGetSolutions();
151
157 const std::vector<std::vector<double> >& rGetSolutions() const;
158
159
163 void SetSolverName(std::string solverName)
164 {
165 mSolverName = solverName;
166 }
167
169 std::string GetSolverName()
170 {
171 return mSolverName;
172 }
173
179 template<typename VECTOR>
181
188 std::vector<std::vector<double> >& rGetDerivedQuantities(AbstractParameterisedSystem<std::vector<double> >* pOdeSystem);
189
190#ifdef CHASTE_CVODE
197 std::vector<std::vector<double> >& rGetDerivedQuantities(AbstractParameterisedSystem<N_Vector>* pOdeSystem);
198#endif //CHASTE_CVODE
199
207 template<typename VECTOR>
208 std::vector<double>& rGetParameters(AbstractParameterisedSystem<VECTOR>* pOdeSystem);
209
224 void WriteToFile(std::string directoryName,
225 std::string baseResultsFilename,
226 std::string timeUnits,
227 unsigned stepsPerRow=1,
228 bool cleanDirectory=true,
229 unsigned precision=8,
230 bool includeDerivedQuantities=false);
231};
232
233
234#endif //_ODESOLUTION_HPP_
std::vector< double > mParameters
boost::shared_ptr< const AbstractOdeSystemInformation > mpOdeSystemInformation
std::vector< double > GetAnyVariable(const std::string &rName) const
std::vector< double > & rGetParameters(AbstractParameterisedSystem< VECTOR > *pOdeSystem)
void SetNumberOfTimeSteps(unsigned numTimeSteps)
std::vector< double > mTimes
void CalculateDerivedQuantitiesAndParameters(AbstractParameterisedSystem< VECTOR > *pOdeSystem)
unsigned GetNumberOfTimeSteps() const
std::string mSolverName
std::vector< std::vector< double > > & rGetSolutions()
unsigned mNumberOfTimeSteps
std::vector< double > GetVariableAtIndex(unsigned index) const
void WriteToFile(std::string directoryName, std::string baseResultsFilename, std::string timeUnits, unsigned stepsPerRow=1, bool cleanDirectory=true, unsigned precision=8, bool includeDerivedQuantities=false)
std::vector< double > & rGetTimes()
void SetSolverName(std::string solverName)
void SetOdeSystemInformation(boost::shared_ptr< const AbstractOdeSystemInformation > pOdeSystemInfo)
std::vector< std::vector< double > > & rGetDerivedQuantities(AbstractParameterisedSystem< std::vector< double > > *pOdeSystem)
std::string GetSolverName()
std::vector< std::vector< double > > mSolutions
std::vector< std::vector< double > > mDerivedQuantities