OGS 6.2.2-87-g988ee9c30.dirty.20200123122242
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.

Template Parameters
 NumEquations number of equations in the ODE system.

Definition at line 37 of file ODESolver.h.

#include <ODESolver.h>

Inheritance diagram for MathLib::ODE::ODESolver< NumEquations >:

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

virtual void preSolve ()=0

virtual bool solve (const double t)=0

virtual unsigned getNumberOfEquations () const
Returns the number of equations. More...

virtual MappedConstVector< NumEquations > getSolution () const =0
Returns the solution vector y. More...

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

◆ ~ODESolver()

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

◆ 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 MathLib::ODE::ODESolver< NumEquations >::getSolution ( ) const
pure virtual

Returns the solution vector y.

◆ 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.

◆ getYDot()

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

Computes .

This method is provided for convenience only.

◆ 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.

◆ setFunction()

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

Sets functions that compute and the Jacobian .

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

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

◆ setIC() [1/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
 t0 initial time. y0 initial values.
Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

◆ setIC() [2/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.

◆ 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
 abstol absolute tolerance, one value for all equations. reltol relative tolerance.
Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

◆ 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
 abstol absolute tolerance, one value each equation. reltol relative tolerance.
Remarks
solve() cannot be directly called after this method, rather preSolve() has to be called first!

◆ 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.

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