Class CVodeIntegrator#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Class Documentation#

class CVodeIntegrator : public Karana::Math::Integrator#

The multistep CVode integrator from the SUNDIALS suite.

Public Types

enum class NLSOLVER#

the nonlinear solver type to use

Values:

enumerator FIXEDPOINT#
enumerator NEWTON#
enum class METHOD#

the solver type to use

Values:

enumerator ADAMS#
enumerator BDF#

Public Functions

CVodeIntegrator(size_t nstates, DerivativeFunction f, const IntegratorType &integrator_type, const IntegratorOptions *options = nullptr)#

Constructor

~CVodeIntegrator()#
inline virtual const std::string &typeString() const override#

Return the integrator type as a string.

Returns:

the integrator type

virtual void hardReset(size_t nstates) override#

Reset the state size.

Parameters:

nstates – the new state size

virtual void softReset(const Ktime &new_t, const Vec &new_x) override#

Reset the cached time and state and to the new values going forward.

Parameters:
  • new_t – the new time

  • new_x – the new state

virtual Ktime advanceTo(const Ktime &t_end) override#

Method to advance the sytem state to a specified time.

Parameters:

to_t – the desired end time

Returns:

the actual end time

virtual void updateJacobian(const Mat &mat) override#

Update the stored Jacobian matrix with the provided one.

This is currently an experimental feature - and not all integrators support the use of Jacobians.

Parameters:

mat – the new Jacobian matrix

virtual std::unique_ptr<Integrator::IntegratorOptions> getOptions() override#

Get the options associated with the integrator.

Returns:

The options associated with the integrator.

virtual IntegratorType getIntegratorType() const override#

Get the IntegratorType for this integrator.

Returns:

The IntegratorType for this integrator.

Vec getErrorContributions() const#

Protected Attributes

SUNContext _sunctx = nullptr#
N_Vector _y = nullptr#
SUNMatrix _A = nullptr#

Matrix used in the linear solver.

Mat _jacobian_buffer#
SUNLinearSolver _ls = nullptr#

Linear solver.

SUNNonlinearSolver _nls = nullptr#

nonLinear solver

void *_cvode_mem#
Vec _dx#
IntegratorType _integrator_type#

The integrator type.

Protected Static Functions

static int _cvode_f(realtype t, N_Vector y, N_Vector ydot, void *user_data)#
static int _cvode_jacobian(realtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)#

type CVLsJacFn. Invoked by the integrator to get the Jacobian matrix (experimental)

struct IntegratorOptions : public Karana::Math::Integrator::IntegratorOptions#

Struct with options for this integrator

Public Functions

IntegratorOptions() = default#
inline IntegratorOptions(const IntegratorOptions &p)#
inline IntegratorOptions &operator=(const IntegratorOptions &p)#
inline virtual ~IntegratorOptions()#

Public Members

double rtol = 1e-4#
double atol = 1e-8#
Vec atol_vec#
long max_num_steps = 1e6#
unsigned int anderson_accel = 0#

Anderson acceleration used with the FixedPoint solver.

NLSOLVER nlsolver = NLSOLVER::FIXEDPOINT#
METHOD method = METHOD::ADAMS#
bool use_jacobian = false#

set to true to have the integrator use Jacobians (experimental)