5#include <cvode/cvode.h>
6#include <nvector/nvector_serial.h>
7#include <sunmatrix/sunmatrix_dense.h>
8#include <sunlinsol/sunlinsol_dense.h>
47 int (*Func)(sunrealtype, N_Vector, N_Vector,
void*),
51 const std::vector<double> &_atol) :
55 rv = SUNContext_Create(SUN_COMM_NULL, &
sun);
59 for(
int k=0; k<
nvar; ++k)
60 NV_Ith_S(
atol, k) = _atol[k];
62 cmem = CVodeCreate(CV_BDF,
sun);
63 rv = CVodeSetUserData(
cmem, _user_data);
66 rv = CVodeSetMaxNumSteps(
cmem, 5000);
83int integrate(std::vector<double> &y,
const sunrealtype dt) {
85 for(
int k=0; k<
nvar; ++k)
86 NV_Ith_S(
vars, k) = y[k];
93 for(
int k=0; k<
nvar; ++k)
94 y[k] = NV_Ith_S(
vars,k);
112 SUNContext_Free(&
sun);
unsigned nvar
number of equations being solved
N_Vector atol
vector atol (for each variable)
int integrate(std::vector< double > &y, const sunrealtype dt)
SUNContext sun
sundials object
N_Vector vars
vector of variables being solved
SUNMatrix J
matrix for linear solver
SUNLinearSolver LS
linear solver
integrator_cvode(int(*Func)(sunrealtype, N_Vector, N_Vector, void *), void *_user_data, const int _nvar, const double _rtol, const std::vector< double > &_atol)
int rv
return value: checking status of calls
sunrealtype rtol
scalar rtol