Chaste  Release::2024.1
OdeSolution Class Reference

#include <OdeSolution.hpp>

+ Collaboration diagram for OdeSolution:

Public Member Functions

 OdeSolution ()
 
unsigned GetNumberOfTimeSteps () const
 
void SetNumberOfTimeSteps (unsigned numTimeSteps)
 
void SetOdeSystemInformation (boost::shared_ptr< const AbstractOdeSystemInformation > pOdeSystemInfo)
 
std::vector< doubleGetVariableAtIndex (unsigned index) const
 
std::vector< doubleGetAnyVariable (const std::string &rName) const
 
std::vector< double > & rGetTimes ()
 
const std::vector< double > & rGetTimes () const
 
std::vector< std::vector< double > > & rGetSolutions ()
 
const std::vector< std::vector< double > > & rGetSolutions () const
 
void SetSolverName (std::string solverName)
 
std::string GetSolverName ()
 
template<typename VECTOR >
void CalculateDerivedQuantitiesAndParameters (AbstractParameterisedSystem< VECTOR > *pOdeSystem)
 
std::vector< std::vector< double > > & rGetDerivedQuantities (AbstractParameterisedSystem< std::vector< double > > *pOdeSystem)
 
std::vector< std::vector< double > > & rGetDerivedQuantities (AbstractParameterisedSystem< N_Vector > *pOdeSystem)
 
template<typename VECTOR >
std::vector< double > & rGetParameters (AbstractParameterisedSystem< VECTOR > *pOdeSystem)
 
void WriteToFile (std::string directoryName, std::string baseResultsFilename, std::string timeUnits, unsigned stepsPerRow=1, bool cleanDirectory=true, unsigned precision=8, bool includeDerivedQuantities=false)
 

Private Attributes

unsigned mNumberOfTimeSteps
 
std::vector< doublemTimes
 
std::vector< std::vector< double > > mSolutions
 
std::vector< std::vector< double > > mDerivedQuantities
 
std::vector< doublemParameters
 
std::string mSolverName
 
boost::shared_ptr< const AbstractOdeSystemInformationmpOdeSystemInformation
 

Detailed Description

A class that that stores the output data from solving a system of ODEs, and allows us to save it to file.

Definition at line 58 of file OdeSolution.hpp.

Constructor & Destructor Documentation

◆ OdeSolution()

OdeSolution::OdeSolution ( )

Public constructor - ensures data is empty to start with.

Definition at line 45 of file OdeSolution.cpp.

Member Function Documentation

◆ CalculateDerivedQuantitiesAndParameters()

template<typename VECTOR >
void OdeSolution::CalculateDerivedQuantitiesAndParameters ( AbstractParameterisedSystem< VECTOR > *  pOdeSystem)

Calculate the derived quantities and store them and the current parameters for printing/accessing.

Parameters
pOdeSystemthe ODE system which was solved to generate this solution object

Definition at line 134 of file OdeSolution.cpp.

References AbstractUntemplatedParameterisedSystem::GetSystemInformation(), mpOdeSystemInformation, rGetDerivedQuantities(), and rGetParameters().

Referenced by GetSolverName().

◆ GetAnyVariable()

std::vector< double > OdeSolution::GetAnyVariable ( const std::string &  rName) const
Returns
the values of a state variable, parameter or derived quantity with a given name in the ODE system for each output timestep.
Parameters
rNamethe name of the variable to extract

Definition at line 107 of file OdeSolution.cpp.

References GetVariableAtIndex(), and mpOdeSystemInformation.

◆ GetNumberOfTimeSteps()

unsigned OdeSolution::GetNumberOfTimeSteps ( ) const

Get the number of timesteps.

Returns
mNumberOfTimeSteps

Definition at line 52 of file OdeSolution.cpp.

References mNumberOfTimeSteps.

◆ GetSolverName()

std::string OdeSolution::GetSolverName ( )
inline
Returns
the ODE solver used to create these results

Definition at line 169 of file OdeSolution.hpp.

References CalculateDerivedQuantitiesAndParameters(), mSolverName, rGetDerivedQuantities(), rGetParameters(), and WriteToFile().

◆ GetVariableAtIndex()

std::vector< double > OdeSolution::GetVariableAtIndex ( unsigned  index) const
Returns
the values of a state variable, parameter or derived quantity with a given index in the ODE system at each output timestep. The index is that given by AbstractOdeSystemInformation::GetAnyVariableIndex, which for state variables (the most common case) is equal to their index within the state variable vector.
Parameters
indexthe index of the variable in the system

Definition at line 71 of file OdeSolution.cpp.

Referenced by GetAnyVariable().

◆ rGetDerivedQuantities() [1/2]

std::vector< std::vector< double > > & OdeSolution::rGetDerivedQuantities ( AbstractParameterisedSystem< std::vector< double > > *  pOdeSystem)
Returns
the derived quantities for this ODE system at each timestep.
Parameters
pOdeSystemthe ODE system which was solved to generate this solution object
Returns
A vector of vectors of derived quantities for each time step.

Definition at line 159 of file OdeSolution.cpp.

References mDerivedQuantities, mSolutions, and mTimes.

Referenced by CalculateDerivedQuantitiesAndParameters(), and GetSolverName().

◆ rGetDerivedQuantities() [2/2]

std::vector< std::vector< double > > & OdeSolution::rGetDerivedQuantities ( AbstractParameterisedSystem< N_Vector > *  pOdeSystem)
Returns
the derived quantities for this ODE system at each timestep.
Parameters
pOdeSystemthe ODE system which was solved to generate this solution object
Returns
A std::vector of vectors of derived quantities for each time step.

Definition at line 175 of file OdeSolution.cpp.

References AbstractUntemplatedParameterisedSystem::GetNumberOfDerivedQuantities(), mDerivedQuantities, mSolutions, and mTimes.

◆ rGetParameters()

template<typename VECTOR >
std::vector< double > & OdeSolution::rGetParameters ( AbstractParameterisedSystem< VECTOR > *  pOdeSystem)

This method currently assumes that mParameters is constant through time. This may not be the case when using modifiers.

Parameters
pOdeSystemThe ODE system which was solved to generate this solution object.
Returns
A vector of the current system parameters.

Definition at line 143 of file OdeSolution.cpp.

References AbstractUntemplatedParameterisedSystem::GetNumberOfParameters(), and mParameters.

Referenced by CalculateDerivedQuantitiesAndParameters(), and GetSolverName().

◆ rGetSolutions() [1/2]

std::vector< std::vector< double > > & OdeSolution::rGetSolutions ( )
Returns
the values of the solution to the ODE system at each timestep.
mSolutions.

Definition at line 122 of file OdeSolution.cpp.

References mSolutions.

Referenced by RungeKuttaFehlbergIvpOdeSolver::InternalSolve(), AbstractOneStepIvpOdeSolver::Solve(), CvodeAdaptor::Solve(), and AbstractCvodeSystem::Solve().

◆ rGetSolutions() [2/2]

const std::vector< std::vector< double > > & OdeSolution::rGetSolutions ( ) const
Returns
the values of the solution to the ODE system at each timestep.
mSolutions.

Definition at line 127 of file OdeSolution.cpp.

References mSolutions.

◆ rGetTimes() [1/2]

std::vector< double > & OdeSolution::rGetTimes ( )
Returns
the times at which the solution to the ODE system is stored.
mTimes.

Definition at line 112 of file OdeSolution.cpp.

References mTimes.

Referenced by RungeKuttaFehlbergIvpOdeSolver::InternalSolve(), AbstractOneStepIvpOdeSolver::Solve(), CvodeAdaptor::Solve(), and AbstractCvodeSystem::Solve().

◆ rGetTimes() [2/2]

const std::vector< double > & OdeSolution::rGetTimes ( ) const
Returns
the times at which the solution to the ODE system is stored.
mTimes.

Definition at line 117 of file OdeSolution.cpp.

References mTimes.

◆ SetNumberOfTimeSteps()

void OdeSolution::SetNumberOfTimeSteps ( unsigned  numTimeSteps)

Set the number of timesteps.

Parameters
numTimeStepsthe number of timesteps to use

Definition at line 58 of file OdeSolution.cpp.

References mNumberOfTimeSteps, mSolutions, and mTimes.

Referenced by AbstractOneStepIvpOdeSolver::Solve(), CvodeAdaptor::Solve(), and AbstractCvodeSystem::Solve().

◆ SetOdeSystemInformation()

void OdeSolution::SetOdeSystemInformation ( boost::shared_ptr< const AbstractOdeSystemInformation pOdeSystemInfo)

Set the ODE system information

Parameters
pOdeSystemInfoODE system information (used to get the names and units of variables).

Definition at line 66 of file OdeSolution.cpp.

References mpOdeSystemInformation.

Referenced by AbstractOneStepIvpOdeSolver::Solve(), CvodeAdaptor::Solve(), and AbstractCvodeSystem::Solve().

◆ SetSolverName()

void OdeSolution::SetSolverName ( std::string  solverName)
inline

Set the ODE solver used to create these results

Parameters
solverNamesolver used

Definition at line 163 of file OdeSolution.hpp.

Referenced by AbstractOneStepIvpOdeSolver::Solve().

◆ WriteToFile()

void OdeSolution::WriteToFile ( std::string  directoryName,
std::string  baseResultsFilename,
std::string  timeUnits,
unsigned  stepsPerRow = 1,
bool  cleanDirectory = true,
unsigned  precision = 8,
bool  includeDerivedQuantities = false 
)

Write the data to a file.

Parameters
directoryNamethe directory in which to write the data to file
baseResultsFilenamethe name of the file in which to write the data
timeUnitsname of the units of time used
stepsPerRowthe solution to the ODE system is written to file every this number of timesteps (defaults to 1)
cleanDirectorywhether to clean the directory (defaults to true)
precisionthe precision with which to write the data (i.e. exactly how many digits to display after the decimal point). Defaults to 8. Must be between 2 and 20 (inclusive).
includeDerivedQuantitieswhether to include parameters and derived quantities in the output.

Definition at line 199 of file OdeSolution.cpp.

References PetscTools::AmMaster(), ColumnDataWriter::DefineUnlimitedDimension(), EXCEPTION, mDerivedQuantities, mParameters, mpOdeSystemInformation, mSolutions, and mTimes.

Referenced by GetSolverName().

Member Data Documentation

◆ mDerivedQuantities

std::vector<std::vector<double> > OdeSolution::mDerivedQuantities
private

Derived quantities at each timestep.

Definition at line 71 of file OdeSolution.hpp.

Referenced by rGetDerivedQuantities(), and WriteToFile().

◆ mNumberOfTimeSteps

unsigned OdeSolution::mNumberOfTimeSteps
private

Variable for the number of timesteps.

Definition at line 62 of file OdeSolution.hpp.

Referenced by GetNumberOfTimeSteps(), and SetNumberOfTimeSteps().

◆ mParameters

std::vector<double> OdeSolution::mParameters
private

Parameters - these are currently assumed constant across all time

Definition at line 74 of file OdeSolution.hpp.

Referenced by rGetParameters(), and WriteToFile().

◆ mpOdeSystemInformation

boost::shared_ptr<const AbstractOdeSystemInformation> OdeSolution::mpOdeSystemInformation
private

Information about the concrete ODE system class.

Used to get names and units into the file output.

Definition at line 84 of file OdeSolution.hpp.

Referenced by CalculateDerivedQuantitiesAndParameters(), GetAnyVariable(), SetOdeSystemInformation(), and WriteToFile().

◆ mSolutions

std::vector<std::vector<double> > OdeSolution::mSolutions
private

Solutions for each variable at each timestep.

Definition at line 68 of file OdeSolution.hpp.

Referenced by rGetDerivedQuantities(), rGetSolutions(), SetNumberOfTimeSteps(), and WriteToFile().

◆ mSolverName

std::string OdeSolution::mSolverName
private

The ODE solver used to create these results

Definition at line 77 of file OdeSolution.hpp.

Referenced by GetSolverName().

◆ mTimes

std::vector<double> OdeSolution::mTimes
private

A vector of times at each timestep.

Definition at line 65 of file OdeSolution.hpp.

Referenced by rGetDerivedQuantities(), rGetTimes(), SetNumberOfTimeSteps(), and WriteToFile().


The documentation for this class was generated from the following files: