OGS
MathLib::ODE::ODESolver< NumEquations > Class Template Referenceabstract

Detailed Description

template<unsigned NumEquations>
class MathLib::ODE::ODESolver< NumEquations >

ODE solver Interface.

This class provides an abstract interface for ODE solvers. It provides type-safe and array-bounds checked access to external ODE solver libraries. However, it is agnostic to the specific solver used.

The ODEs solved using this class are first-order ODEs that are given in explicit form, i.e.

\[ \dot y = f(t, y). \]

Template Parameters
NumEquationsnumber of equations in the ODE system.

Definition at line 37 of file ODESolver.h.

#include <ODESolver.h>

Inheritance diagram for MathLib::ODE::ODESolver< NumEquations >:
[legend]

Public Member Functions

virtual void setFunction (Function< NumEquations > f, JacobianFunction< NumEquations > df)=0
 
virtual void setTolerance (const double abstol, const double reltol)=0
 
virtual void setTolerance (const std::array< double, NumEquations > &abstol, const double reltol)=0
 
virtual void setIC (const double t0, std::initializer_list< double > const &y0)=0
 
virtual void setIC (const double t0, Eigen::Matrix< double, NumEquations, 1, Eigen::ColMajor > const &y0)=0
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
virtual void preSolve ()=0
 
virtual bool solve (const double t)=0
 
virtual unsigned getNumberOfEquations () const
 Returns the number of equations.
 
virtual MappedConstVector< NumEquations > getSolution () const =0
 Returns the solution vector y.
 
virtual double getTime () const =0
 
virtual Eigen::Matrix< double, NumEquations, 1, Eigen::ColMajor > getYDot (const double t, const MappedConstVector< NumEquations > &y) const =0
 
virtual ~ODESolver ()=default
 

Constructor & Destructor Documentation

◆ ~ODESolver()

template<unsigned NumEquations>
virtual MathLib::ODE::ODESolver< NumEquations >::~ODESolver ( )
virtualdefault

Member Function Documentation

◆ getNumberOfEquations()

template<unsigned NumEquations>
virtual unsigned MathLib::ODE::ODESolver< NumEquations >::getNumberOfEquations ( ) const
inlinevirtual

Returns the number of equations.

Definition at line 114 of file ODESolver.h.

114{ return NumEquations; }

◆ getSolution()

template<unsigned NumEquations>
virtual MappedConstVector< NumEquations > MathLib::ODE::ODESolver< NumEquations >::getSolution ( ) const
pure virtual

Returns the solution vector y.

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ getTime()

template<unsigned NumEquations>
virtual double MathLib::ODE::ODESolver< NumEquations >::getTime ( ) const
pure virtual

Returns the time that the solver has reached.

The return value should be equal to the time t passed to solve() if everything went fine.

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ getYDot()

template<unsigned NumEquations>
virtual Eigen::Matrix< double, NumEquations, 1, Eigen::ColMajor > MathLib::ODE::ODESolver< NumEquations >::getYDot ( const double t,
const MappedConstVector< NumEquations > & y ) const
pure virtual

Computes \( \dot y = f(t,y) \).

This method is provided for convenience only.

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ preSolve()

template<unsigned NumEquations>
virtual void MathLib::ODE::ODESolver< NumEquations >::preSolve ( )
pure virtual

Finishes setting up the ODE solver, makes it ready to solve the provided ODE.

This method applies settings to the ODE solver, hence it has to be called after calling setters.

Note
preSolve() has to be called once before calling solve, it is not necessary to call it after each setter.

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ setFunction()

template<unsigned NumEquations>
virtual void MathLib::ODE::ODESolver< NumEquations >::setFunction ( Function< NumEquations > f,
JacobianFunction< NumEquations > df )
pure virtual

Sets functions that compute \(\dot y\) and the Jacobian \(\partial \dot y/\partial y\).

If no Jacobian function shall be set, nullptr can be passed for df.

Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ setIC() [1/2]

template<unsigned NumEquations>
virtual void MathLib::ODE::ODESolver< NumEquations >::setIC ( const double t0,
Eigen::Matrix< double, NumEquations, 1, Eigen::ColMajor > const & y0 )
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ setIC() [2/2]

template<unsigned NumEquations>
virtual void MathLib::ODE::ODESolver< NumEquations >::setIC ( const double t0,
std::initializer_list< double > const & y0 )
pure virtual

Sets the conditions.

Parameters
t0initial time.
y0initial values.
Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ setTolerance() [1/2]

template<unsigned NumEquations>
virtual void MathLib::ODE::ODESolver< NumEquations >::setTolerance ( const double abstol,
const double reltol )
pure virtual

Sets the tolerances for the ODE solver.

Parameters
abstolabsolute tolerance, one value for all equations.
reltolrelative tolerance.
Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ setTolerance() [2/2]

template<unsigned NumEquations>
virtual void MathLib::ODE::ODESolver< NumEquations >::setTolerance ( const std::array< double, NumEquations > & abstol,
const double reltol )
pure virtual

Sets the tolerances for the ODE solver.

Parameters
abstolabsolute tolerance, one value each equation.
reltolrelative tolerance.
Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.

◆ solve()

template<unsigned NumEquations>
virtual bool MathLib::ODE::ODESolver< NumEquations >::solve ( const double t)
pure virtual

Solves the ODE from the set initial condition to time t.

Returns
true or false indicating whether solving succeeded.
Precondition
preSolve() has to be called before this method.

Implemented in MathLib::ODE::ConcreteODESolver< Implementation, NumEquations >.


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