37 #ifndef _ABSTRACTCVODESYSTEM_HPP_ 38 #define _ABSTRACTCVODESYSTEM_HPP_ 48 #include "AbstractParameterisedSystem.hpp" 50 #include "OdeSolution.hpp" 54 #include <boost/serialization/split_member.hpp> 55 #include <boost/serialization/vector.hpp> 60 #include <nvector/nvector_serial.h> 62 #if CHASTE_SUNDIALS_VERSION >= 30000 63 #include <cvode/cvode_direct.h> 64 #include <sundials/sundials_types.h> 65 #include <sunlinsol/sunlinsol_dense.h> 66 #include <sunmatrix/sunmatrix_dense.h> 68 #include <sundials/sundials_dense.h> 72 #if CHASTE_SUNDIALS_VERSION >= 30000 73 #define CHASTE_CVODE_DENSE_MATRIX SUNMatrix 74 #elif CHASTE_SUNDIALS_VERSION >= 20400 75 #define CHASTE_CVODE_DENSE_MATRIX DlsMat 77 #define CHASTE_CVODE_DENSE_MATRIX DenseMat 81 #if CHASTE_SUNDIALS_VERSION >= 30000 82 #define IJth(A, i, j) SM_ELEMENT_D(A, i, j) 84 #define IJth(A, i, j) DENSE_ELEM(A, i, j) 144 friend class TestAbstractCvodeSystem;
146 friend class boost::serialization::access;
153 template <
class Archive>
154 void save(Archive& archive,
const unsigned int version)
const 195 template <
class Archive>
196 void load(Archive& archive,
const unsigned int version)
208 std::vector<double> state_vars;
212 std::vector<double> parameters;
215 std::vector<std::string> param_names;
216 archive& param_names;
231 BOOST_SERIALIZATION_SPLIT_MEMBER()
263 void CvodeError(
int flag,
const char* msg,
const double& rTime,
264 const double& rStartTime,
const double& rEndTime);
278 #if CHASTE_SUNDIALS_VERSION >= 30000 280 SUNMatrix mpSundialsDenseMatrix;
282 SUNLinearSolver mpSundialsLinearSolver;
357 CHASTE_CVODE_DENSE_MATRIX jacobian,
360 EXCEPTION(
"No analytic Jacobian has been defined for this system.");
452 void Solve(realtype tStart,
477 void SetTolerances(
double relTol = 1e-5,
double absTol = 1e-7);
546 #endif //_ABSTRACTCVODESYSTEM_HPP_ 547 #endif // CHASTE_CVODE double GetAbsoluteTolerance()
const std::vector< std::string > & rGetParameterNames() const
void SetMinimalReset(bool minimalReset)
void SetTolerances(double relTol=1e-5, double absTol=1e-7)
std::vector< double > MakeStdVec(N_Vector v)
void CvodeError(int flag, const char *msg, const double &rTime, const double &rStartTime, const double &rEndTime)
#define CLASS_IS_ABSTRACT(T)
void RecordStoppingPoint(double stopTime)
#define EXCEPTION(message)
double mLastInternalStepSize
void SetupCvode(N_Vector initialConditions, realtype tStart, realtype maxDt)
bool HasAnalyticJacobian() const
void load(Archive &archive, const unsigned int version)
void save(Archive &archive, const unsigned int version) const
virtual void EvaluateAnalyticJacobian(realtype time, N_Vector y, N_Vector ydot, CHASTE_CVODE_DENSE_MATRIX jacobian, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
bool mUseAnalyticJacobian
bool GetForceReset()
Get whether we will force a solver reset on every call to Solve()
bool GetUseAnalyticJacobian() const
void SetForceReset(bool autoReset)
virtual void EvaluateYDerivatives(realtype time, const N_Vector y, N_Vector ydot)=0
void SetMaxSteps(long int numSteps)
virtual ~AbstractCvodeSystem()
bool GetMinimalReset()
Get whether we want to run with minimal reset or not (no reinitialisation of the solver if variables ...
double GetRelativeTolerance()
OdeSolution Solve(realtype tStart, realtype tEnd, realtype maxDt, realtype tSamp)
N_Vector mLastSolutionState
void CopyFromStdVector(const std::vector< double > &rSrc, VECTOR &rDest)
void CheckParametersOnLoad(const std::vector< double > &rParameters, const std::vector< std::string > &rParameterNames)
unsigned mNumberOfStateVariables
void ForceUseOfNumericalJacobian(bool useNumericalJacobian=true)
AbstractCvodeSystem(unsigned numberOfStateVariables)
bool mHasAnalyticJacobian