26 #ifndef CASADI_CVODES_INTERFACE_HPP
27 #define CASADI_CVODES_INTERFACE_HPP
29 #include <casadi/interfaces/sundials/casadi_integrator_cvodes_export.h>
30 #include "sundials_interface.hpp"
31 #include <cvodes/cvodes.h>
32 #include <cvodes/cvodes_dense.h>
33 #include <cvodes/cvodes_band.h>
34 #include <cvodes/cvodes_spgmr.h>
35 #include <cvodes/cvodes_spbcgs.h>
36 #include <cvodes/cvodes_sptfqmr.h>
37 #include <cvodes/cvodes_impl.h>
58 class CvodesInterface;
91 const std::vector<double>& tout);
95 double t0,
const std::vector<double>& tout) {
106 std::string
class_name()
const override {
return "CvodesInterface";}
118 void init(
const Dict& opts)
override;
124 int init_mem(
void* mem)
const override;
137 const double* adj_x,
const double* adj_z,
const double* adj_q)
const override;
141 double* adj_x,
double* adj_p,
double* adj_u)
const override;
146 casadi_assert_dev(m);
156 static void ehfun(
int error_code,
const char *module,
const char *
function,
char *msg,
158 static int rhsF(
double t, N_Vector x, N_Vector xdot,
void *user_data);
159 static int rhsB(
double t, N_Vector x, N_Vector xB, N_Vector xdotB,
void *user_data);
160 static int rhsQF(
double t, N_Vector x, N_Vector qdot,
void *user_data);
161 static int rhsQB(
double t, N_Vector x, N_Vector rx, N_Vector ruqdot,
void *user_data);
162 static int jtimesF(N_Vector v, N_Vector Jv,
double t, N_Vector x, N_Vector xdot,
163 void *user_data, N_Vector tmp);
164 static int jtimesB(N_Vector vB, N_Vector JvB,
double t, N_Vector x, N_Vector xB,
165 N_Vector xdotB,
void *user_data , N_Vector tmpB);
166 static int psolveF(
double t, N_Vector x, N_Vector xdot, N_Vector r, N_Vector z,
167 double gamma,
double delta,
int lr,
void *user_data, N_Vector tmp);
168 static int psolveB(
double t, N_Vector x, N_Vector xB, N_Vector xdotB, N_Vector rvecB,
169 N_Vector zvecB,
double gammaB,
double deltaB,
170 int lr,
void *user_data, N_Vector tmpB);
171 static int psetupF(
double t, N_Vector x, N_Vector xdot, booleantype jok,
172 booleantype *jcurPtr,
double gamma,
void *user_data,
173 N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
174 static int psetupB(
double t, N_Vector x, N_Vector xB, N_Vector xdotB,
175 booleantype jokB, booleantype *jcurPtrB,
double gammaB,
176 void *user_data, N_Vector tmp1B, N_Vector tmp2B, N_Vector tmp3B);
177 static int lsetupF(CVodeMem cv_mem,
int convfail, N_Vector x, N_Vector xdot,
178 booleantype *jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
179 static int lsolveF(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector x, N_Vector xdot);
180 static int lsetupB(CVodeMem cv_mem,
int convfail, N_Vector x, N_Vector xdot,
181 booleantype *jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3);
182 static int lsolveB(CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector x, N_Vector xdot);
185 static void cvodes_error(
const char* module,
int flag);
'cvodes' plugin for Integrator
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize into MX.
const char * plugin_name() const override
static CvodesMemory * to_mem(void *mem)
Cast to memory object.
void * alloc_mem() const override
Create memory block.
const Options & get_options() const override
Options.
static const std::string meta_doc
A documentation string.
static Integrator * creator(const std::string &name, const Function &dae, double t0, const std::vector< double > &tout)
Create a new integrator.
static const Options options_
Options.
bool always_recalculate_jacobian_
Options.
void free_mem(void *mem) const override
Free memory block.
std::string class_name() const override
Readable name of the internal class.
double min_step_size_
Options.
Helper class for Serialization.
Internal storage for integrator related data.
Base class for FunctionInternal and LinsolInternal.
Helper class for Serialization.
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
Options metadata for a class.