Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
BackwardEulerIvpOdeSolver Class Reference

#include <BackwardEulerIvpOdeSolver.hpp>

+ Inheritance diagram for BackwardEulerIvpOdeSolver:
+ Collaboration diagram for BackwardEulerIvpOdeSolver:

Public Member Functions

 BackwardEulerIvpOdeSolver (unsigned sizeOfOdeSystem)
 
 ~BackwardEulerIvpOdeSolver ()
 
void SetEpsilonForNumericalJacobian (double epsilon)
 
void ForceUseOfNumericalJacobian ()
 
unsigned GetSystemSize () const
 
- Public Member Functions inherited from AbstractOneStepIvpOdeSolver
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

void CalculateNextYValue (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rNextYValues)
 
- Protected Member Functions inherited from AbstractOneStepIvpOdeSolver
virtual void InternalSolve (AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rCurrentYValues, std::vector< double > &rWorkingMemory, double startTime, double endTime, double timeStep)
 

Private Member Functions

template<class Archive >
void serialize (Archive &archive, const unsigned int version)
 
void ComputeResidual (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rCurrentGuess)
 
void ComputeJacobian (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rCurrentGuess)
 
void SolveLinearSystem ()
 
double ComputeNorm (double *pVector)
 
void ComputeNumericalJacobian (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rCurrentGuess)
 

Private Attributes

unsigned mSizeOfOdeSystem
 
double mNumericalJacobianEpsilon
 
bool mForceUseOfNumericalJacobian
 
doublemResidual
 
double ** mJacobian
 
doublemUpdate
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Protected Attributes inherited from AbstractIvpOdeSolver
bool mStoppingEventOccurred
 
double mStoppingTime
 

Detailed Description

A concrete one step ODE solver class that employs the backward Euler method. This numerical method is implicit and hence unconditionally stable.

Definition at line 51 of file BackwardEulerIvpOdeSolver.hpp.

Constructor & Destructor Documentation

◆ BackwardEulerIvpOdeSolver()

BackwardEulerIvpOdeSolver::BackwardEulerIvpOdeSolver ( unsigned  sizeOfOdeSystem)

Constructor.

Parameters
sizeOfOdeSystemthe number of state variables in the ODE system

Definition at line 211 of file BackwardEulerIvpOdeSolver.cpp.

References mForceUseOfNumericalJacobian, mJacobian, mNumericalJacobianEpsilon, mResidual, mSizeOfOdeSystem, and mUpdate.

◆ ~BackwardEulerIvpOdeSolver()

BackwardEulerIvpOdeSolver::~BackwardEulerIvpOdeSolver ( )

Destructor.

Definition at line 230 of file BackwardEulerIvpOdeSolver.cpp.

References mJacobian, mResidual, mSizeOfOdeSystem, and mUpdate.

Member Function Documentation

◆ CalculateNextYValue()

void BackwardEulerIvpOdeSolver::CalculateNextYValue ( AbstractOdeSystem pAbstractOdeSystem,
double  timeStep,
double  time,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rNextYValues 
)
protectedvirtual

Calculate the solution to the ODE system at the next timestep.

A usage example: BackwardEulerIvpOdeSolver mySolver; OdeSolution solution = mySolver.Solve(pMyOdeSystem, yInit, StartTime, EndTime, TimeStep, SamplingTime);

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

Implements AbstractOneStepIvpOdeSolver.

Definition at line 167 of file BackwardEulerIvpOdeSolver.cpp.

References ComputeJacobian(), ComputeNorm(), ComputeResidual(), AbstractUntemplatedParameterisedSystem::GetNumberOfStateVariables(), mSizeOfOdeSystem, mUpdate, and SolveLinearSystem().

◆ ComputeJacobian()

void BackwardEulerIvpOdeSolver::ComputeJacobian ( AbstractOdeSystem pAbstractOdeSystem,
double  timeStep,
double  time,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rCurrentGuess 
)
private

Compute the Jacobian of the ODE system.

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

Definition at line 54 of file BackwardEulerIvpOdeSolver.cpp.

References AbstractOdeSystemWithAnalyticJacobian::AnalyticJacobian(), ComputeNumericalJacobian(), AbstractOdeSystem::GetUseAnalyticJacobian(), mForceUseOfNumericalJacobian, mJacobian, and mSizeOfOdeSystem.

Referenced by CalculateNextYValue().

◆ ComputeNorm()

double BackwardEulerIvpOdeSolver::ComputeNorm ( double pVector)
private

Compute the infinity/maximum norm of a vector. Used by the method CalculateNextYValue.

Parameters
pVectora pointer to a vector
Returns
the vector's norm.

Definition at line 112 of file BackwardEulerIvpOdeSolver.cpp.

References mSizeOfOdeSystem.

Referenced by CalculateNextYValue().

◆ ComputeNumericalJacobian()

void BackwardEulerIvpOdeSolver::ComputeNumericalJacobian ( AbstractOdeSystem pAbstractOdeSystem,
double  timeStep,
double  time,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rCurrentGuess 
)
private

Compute the Jacobian of the ODE system numerically.

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

Definition at line 125 of file BackwardEulerIvpOdeSolver.cpp.

References ComputeResidual(), mJacobian, mNumericalJacobianEpsilon, mResidual, and mSizeOfOdeSystem.

Referenced by ComputeJacobian().

◆ ComputeResidual()

void BackwardEulerIvpOdeSolver::ComputeResidual ( AbstractOdeSystem pAbstractOdeSystem,
double  timeStep,
double  time,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rCurrentGuess 
)
private

Compute the current residual.

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

Definition at line 40 of file BackwardEulerIvpOdeSolver.cpp.

References AbstractOdeSystem::EvaluateYDerivatives(), mResidual, and mSizeOfOdeSystem.

Referenced by CalculateNextYValue(), and ComputeNumericalJacobian().

◆ ForceUseOfNumericalJacobian()

void BackwardEulerIvpOdeSolver::ForceUseOfNumericalJacobian ( )

Force the solver to use the numerical Jacobian even if the ODE system object provides an analytical Jacobian.

Definition at line 249 of file BackwardEulerIvpOdeSolver.cpp.

References mForceUseOfNumericalJacobian.

◆ GetSystemSize()

unsigned BackwardEulerIvpOdeSolver::GetSystemSize ( ) const
inline

Public method used in archiving.

Returns
the size of the system

Definition at line 215 of file BackwardEulerIvpOdeSolver.hpp.

References mSizeOfOdeSystem.

◆ serialize()

template<class Archive >
void BackwardEulerIvpOdeSolver::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 BackwardEulerIvpOdeSolver.hpp.

References mForceUseOfNumericalJacobian, and mNumericalJacobianEpsilon.

◆ SetEpsilonForNumericalJacobian()

void BackwardEulerIvpOdeSolver::SetEpsilonForNumericalJacobian ( double  epsilon)

Set the epsilon to use in calculating the numerical Jacobian of the ODE system.

Parameters
epsilon

Definition at line 243 of file BackwardEulerIvpOdeSolver.cpp.

References mNumericalJacobianEpsilon.

◆ SolveLinearSystem()

void BackwardEulerIvpOdeSolver::SolveLinearSystem ( )
private

Solve a linear system of equations to update the current guess for the solution to the ODE system at the next timestep. Used by the method CalculateNextYValue.

Definition at line 85 of file BackwardEulerIvpOdeSolver.cpp.

References mJacobian, mResidual, mSizeOfOdeSystem, and mUpdate.

Referenced by CalculateNextYValue().

Friends And Related Symbol Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Needed for serialization.

Definition at line 55 of file BackwardEulerIvpOdeSolver.hpp.

Member Data Documentation

◆ mForceUseOfNumericalJacobian

bool BackwardEulerIvpOdeSolver::mForceUseOfNumericalJacobian
private

Whether to force the solver to use the numerical Jacobian even if the ODE system object provides an analytical Jacobian.

Definition at line 82 of file BackwardEulerIvpOdeSolver.hpp.

Referenced by BackwardEulerIvpOdeSolver(), ComputeJacobian(), ForceUseOfNumericalJacobian(), and serialize().

◆ mJacobian

double** BackwardEulerIvpOdeSolver::mJacobian
private

◆ mNumericalJacobianEpsilon

double BackwardEulerIvpOdeSolver::mNumericalJacobianEpsilon
private

The epsilon to use in calculating the numerical Jacobian of the ODE system.

Definition at line 76 of file BackwardEulerIvpOdeSolver.hpp.

Referenced by BackwardEulerIvpOdeSolver(), ComputeNumericalJacobian(), serialize(), and SetEpsilonForNumericalJacobian().

◆ mResidual

double* BackwardEulerIvpOdeSolver::mResidual
private

◆ mSizeOfOdeSystem

unsigned BackwardEulerIvpOdeSolver::mSizeOfOdeSystem
private

◆ mUpdate

double* BackwardEulerIvpOdeSolver::mUpdate
private

Working memory : update vector

Definition at line 97 of file BackwardEulerIvpOdeSolver.hpp.

Referenced by BackwardEulerIvpOdeSolver(), ~BackwardEulerIvpOdeSolver(), CalculateNextYValue(), and SolveLinearSystem().


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