36 #include "OdeSolution.hpp"
40 #include "ColumnDataWriter.hpp"
46 : mNumberOfTimeSteps(0u),
47 mpOdeSystemInformation()
61 mTimes.reserve(numTimeSteps+1);
73 std::vector<double> answer;
74 answer.reserve(
mTimes.size());
76 for (
unsigned i=0; i<
mTimes.size(); ++i)
98 EXCEPTION(
"Invalid index passed to ""GetVariableAtIndex()"".");
102 answer.push_back(temp_number);
133 template<
typename VECTOR>
142 template<
typename VECTOR>
150 for (
unsigned i=0; i<num_params; ++i)
161 assert(pOdeSystem !=
nullptr);
166 for (
unsigned i=0; i<
mTimes.size(); i++)
177 assert(pOdeSystem !=
nullptr);
180 const unsigned num_solutions =
mSolutions.size();
181 assert(
mTimes.size() == num_solutions);
183 N_Vector state_vars = num_solutions > 0 ? N_VNew_Serial(
mSolutions[0].size()) :
nullptr;
184 for (
unsigned i=0; i<num_solutions; i++)
196 #endif // CHASTE_CVODE
200 std::string baseResultsFilename,
201 std::string timeUnits,
202 unsigned stepsPerRow,
205 bool includeDerivedQuantities)
207 assert(stepsPerRow > 0);
208 assert(
mTimes.size() > 0);
213 includeDerivedQuantities =
false;
216 if (includeDerivedQuantities)
220 EXCEPTION(
"You must first call ""CalculateDerivedQuantitiesAndParameters()"" in order to write derived quantities.");
225 ColumnDataWriter writer(directoryName, baseResultsFilename, cleanDirectory, precision);
244 std::vector<int> var_ids;
245 var_ids.reserve(num_vars);
248 for (
unsigned i=0; i<num_vars; i++)
256 for (
unsigned i=0; i<num_vars; i++)
258 std::stringstream string_stream;
259 string_stream <<
"var_" << i;
260 var_ids.push_back(writer.
DefineVariable(string_stream.str(),
""));
264 if (includeDerivedQuantities)
266 var_ids.reserve(num_vars + num_params + num_derived_quantities);
267 for (
unsigned i=0; i<num_params; ++i)
272 for (
unsigned i=0; i<num_derived_quantities; i++)
286 for (
unsigned i=0; i<
mSolutions.size(); i+=stepsPerRow)
289 for (
unsigned j=0; j<num_vars; j++)
293 if (includeDerivedQuantities)
295 for (
unsigned j=0; j<num_params; ++j)
299 for (
unsigned j=0; j<num_derived_quantities; j++)
321 #endif // CHASTE_CVODE
boost::shared_ptr< const AbstractOdeSystemInformation > mpOdeSystemInformation
unsigned mNumberOfTimeSteps
unsigned GetNumberOfTimeSteps() const
unsigned GetNumberOfParameters() const
std::vector< std::vector< double > > & rGetSolutions()
virtual void PutVariable(int variableID, double variableValue, long dimensionPosition=-1)
std::vector< std::vector< double > > & rGetDerivedQuantities(AbstractParameterisedSystem< std::vector< double > > *pOdeSystem)
std::vector< std::vector< double > > mDerivedQuantities
int DefineUnlimitedDimension(const std::string &rDimensionName, const std::string &rDimensionUnits)
#define EXCEPTION(message)
virtual void AdvanceAlongUnlimitedDimension()
std::vector< double > mParameters
virtual void EndDefineMode()
double GetParameter(unsigned index) const
std::vector< double > & rGetParameters(AbstractParameterisedSystem< VECTOR > *pOdeSystem)
void SetOdeSystemInformation(boost::shared_ptr< const AbstractOdeSystemInformation > pOdeSystemInfo)
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)
void CalculateDerivedQuantitiesAndParameters(AbstractParameterisedSystem< VECTOR > *pOdeSystem)
boost::shared_ptr< const AbstractOdeSystemInformation > GetSystemInformation() const
int DefineVariable(const std::string &rVariableName, const std::string &rVariableUnits)
std::vector< std::vector< double > > mSolutions
std::vector< double > & rGetTimes()
std::vector< double > mTimes
void SetCommentForInfoFile(std::string comment)
virtual VECTOR ComputeDerivedQuantities(double time, const VECTOR &rState)
void CopyFromStdVector(const std::vector< double > &rSrc, VECTOR &rDest)
void CopyToStdVector(const VECTOR &rSrc, std::vector< double > &rDest)
std::vector< double > GetAnyVariable(const std::string &rName) const
void SetNumberOfTimeSteps(unsigned numTimeSteps)
void DeleteVector(VECTOR &rVec)
unsigned GetNumberOfDerivedQuantities() const