Chaste  Release::2018.1
AbstractOneStepIvpOdeSolver Class Referenceabstract

#include <AbstractOneStepIvpOdeSolver.hpp>

+ Inheritance diagram for AbstractOneStepIvpOdeSolver:
+ Collaboration diagram for AbstractOneStepIvpOdeSolver:

Public Member Functions

virtual OdeSolution Solve (AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rYValues, double startTime, double endTime, double timeStep, double timeSampling)
 
virtual void Solve (AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rYValues, double startTime, double endTime, double timeStep)
 
virtual ~AbstractOneStepIvpOdeSolver ()
 
- Public Member Functions inherited from AbstractIvpOdeSolver
virtual void SolveAndUpdateStateVariable (AbstractOdeSystem *pAbstractOdeSystem, double startTime, double endTime, double timeStep)
 
bool StoppingEventOccurred ()
 
double GetStoppingTime ()
 
 AbstractIvpOdeSolver ()
 
virtual ~AbstractIvpOdeSolver ()
 
- Public Member Functions inherited from Identifiable
virtual ~Identifiable ()
 
std::string GetIdentifier () const
 

Protected Member Functions

virtual void InternalSolve (AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rCurrentYValues, std::vector< double > &rWorkingMemory, double startTime, double endTime, double timeStep)
 
virtual void CalculateNextYValue (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rNextYValues)=0
 

Private Member Functions

template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 

Private Attributes

std::vector< doublemWorkingMemory
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Protected Attributes inherited from AbstractIvpOdeSolver
bool mStoppingEventOccurred
 
double mStoppingTime
 

Detailed Description

Abstract one-step initial value problem ODE solver class. Sets up variables and functions for all the ODE solvers that only have one timestep.

Definition at line 49 of file AbstractOneStepIvpOdeSolver.hpp.

Constructor & Destructor Documentation

virtual AbstractOneStepIvpOdeSolver::~AbstractOneStepIvpOdeSolver ( )
inlinevirtual

Virtual destructor since we have virtual methods.

Definition at line 176 of file AbstractOneStepIvpOdeSolver.hpp.

Member Function Documentation

virtual void AbstractOneStepIvpOdeSolver::CalculateNextYValue ( AbstractOdeSystem pAbstractOdeSystem,
double  timeStep,
double  time,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rNextYValues 
)
protectedpure virtual

Calculate the solution to the ODE system at the next timestep. Concrete subclasses should provide this method.

Parameters
pAbstractOdeSystemthe ODE system to solve
timeStepdt
timethe current time
rCurrentYValuesthe current (initial) state
rNextYValuesthe state at the next timestep

Implemented in BackwardEulerIvpOdeSolver, GRL2IvpOdeSolver, GRL1IvpOdeSolver, EulerIvpOdeSolver, RKC21IvpOdeSolver, HeunIvpOdeSolver, RungeKutta2IvpOdeSolver, and RungeKutta4IvpOdeSolver.

Referenced by InternalSolve().

void AbstractOneStepIvpOdeSolver::InternalSolve ( AbstractOdeSystem pAbstractOdeSystem,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rWorkingMemory,
double  startTime,
double  endTime,
double  timeStep 
)
protectedvirtual

Method that actually performs the solving on behalf of the public Solve methods.

Parameters
pAbstractOdeSystemthe ODE system to solve
rCurrentYValuesthe current (initial) state; results will also be returned in here
rWorkingMemoryworking memory; same size as rCurrentYValues
startTimeinitial time
endTimetime to solve to
timeStepdt

Reimplemented in MockEulerIvpOdeSolver.

Definition at line 115 of file AbstractOneStepIvpOdeSolver.cpp.

References TimeStepper::AdvanceOneTimeStep(), CalculateNextYValue(), AbstractOdeSystem::CalculateStoppingEvent(), TimeStepper::GetNextTimeStep(), TimeStepper::GetTime(), TimeStepper::IsTimeAtEnd(), AbstractIvpOdeSolver::mStoppingEventOccurred, and AbstractIvpOdeSolver::mStoppingTime.

Referenced by MockEulerIvpOdeSolver::InternalSolve(), and Solve().

template<class Archive >
void AbstractOneStepIvpOdeSolver::serialize ( Archive &  archive,
const unsigned int  version 
)
inlineprivate

Archive the abstract IVP Solver, never used directly - boost uses this.

Parameters
archivethe archive
versionthe current version of this class

Definition at line 63 of file AbstractOneStepIvpOdeSolver.hpp.

OdeSolution AbstractOneStepIvpOdeSolver::Solve ( AbstractOdeSystem pAbstractOdeSystem,
std::vector< double > &  rYValues,
double  startTime,
double  endTime,
double  timeStep,
double  timeSampling 
)
virtual

Solves a system of ODEs using a specified one-step ODE solver and returns the solution as an OdeSolution object.

An example, which returns the solution every 0.1 seconds using dt=0.01:

MyOdeSystem ode; std::vector<double> init_cond = ode_system.GetInitialConditions(); OdeSolution solution = solver.Solve(&ode, init_cond, 0, 1, 0.01, 0.1);

Parameters
pAbstractOdeSystempointer to the concrete ODE system to be solved
rYValuesa standard vector specifying the intial condition of each solution variable in the system (this can be the initial conditions vector stored in the ODE system)
startTimethe time at which the initial conditions are specified
endTimethe time to which the system should be solved and the solution returned
timeStepthe time interval to be used by the solver
timeSamplingthe interval at which to sample the solution to the ODE system
Returns
OdeSolution is an object containing an integer of the number of equations, a stdAbstractOdeSystem::vector of times and a std::vector of std::vectors where each of those vectors contains the solution for one variable of the ODE system at those times.

Implements AbstractIvpOdeSolver.

Definition at line 41 of file AbstractOneStepIvpOdeSolver.cpp.

References TimeStepper::AdvanceOneTimeStep(), AbstractOdeSystem::CalculateStoppingEvent(), TimeStepper::EstimateTimeSteps(), EXCEPTION, Identifiable::GetIdentifier(), TimeStepper::GetNextTime(), AbstractUntemplatedParameterisedSystem::GetNumberOfStateVariables(), AbstractUntemplatedParameterisedSystem::GetSystemInformation(), TimeStepper::GetTime(), TimeStepper::GetTotalTimeStepsTaken(), InternalSolve(), TimeStepper::IsTimeAtEnd(), AbstractIvpOdeSolver::mStoppingEventOccurred, AbstractIvpOdeSolver::mStoppingTime, mWorkingMemory, OdeSolution::rGetSolutions(), OdeSolution::rGetTimes(), OdeSolution::SetNumberOfTimeSteps(), OdeSolution::SetOdeSystemInformation(), and OdeSolution::SetSolverName().

void AbstractOneStepIvpOdeSolver::Solve ( AbstractOdeSystem pAbstractOdeSystem,
std::vector< double > &  rYValues,
double  startTime,
double  endTime,
double  timeStep 
)
virtual

Second version of Solve. Solves a system of ODEs using a specified one-step ODE solver. This method does not return the solution and therefore does not take in a sampling time. Instead, the mStateVariables component in the ODE system object is updated.

An example:

std::vector<double> init_cond = ode_system.GetInitialConditions(); solver.Solve(&ode, init_cond, 0, 1, 0.01); state_variables = ode_system.rGetStateVariables(); // solution at t=1 found here

Parameters
pAbstractOdeSystempointer to the concrete ODE system to be solved
rYValuesa standard vector specifying the intial condition of each solution variable in the system (this can be the initial conditions vector stored in the ODE system)
startTimethe time at which the initial conditions are specified
endTimethe time to which the system should be solved and the solution returned
timeStepthe time interval to be used by the solver

Implements AbstractIvpOdeSolver.

Definition at line 93 of file AbstractOneStepIvpOdeSolver.cpp.

References AbstractOdeSystem::CalculateStoppingEvent(), EXCEPTION, AbstractUntemplatedParameterisedSystem::GetNumberOfStateVariables(), InternalSolve(), AbstractIvpOdeSolver::mStoppingEventOccurred, and mWorkingMemory.

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Needed for serialization.

Definition at line 55 of file AbstractOneStepIvpOdeSolver.hpp.

Member Data Documentation

std::vector<double> AbstractOneStepIvpOdeSolver::mWorkingMemory
private

Working memory

Definition at line 72 of file AbstractOneStepIvpOdeSolver.hpp.

Referenced by Solve().


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