15#include <arkode/arkode.h>
16#include <arkode/arkode_direct.h>
17#include <nvector/nvector_serial.h>
18#include <sunlinsol/sunlinsol_dense.h>
19#include <sunmatrix/sunmatrix_dense.h>
45 SUNLinearSolver
LS{
nullptr};
66 int StateSpace(realtype t, N_Vector y, N_Vector ydot);
68 static int JacobianWrapper(realtype t, N_Vector y, N_Vector fy, SUNMatrix J,
69 void *user_data, N_Vector tmp1, N_Vector tmp2,
71 int Jacobian(realtype t, N_Vector y, N_Vector fy, SUNMatrix J, N_Vector tmp1,
72 N_Vector tmp2, N_Vector tmp3);
74 int check_flag(
void *flagvalue,
const std::string &funcname,
int opt);
79 bool implicit_integration,
Real timestep);
86 :
Task(solver.
mName +
".Solve"), mSolver(solver) {
std::function< void(double, const double *, double *)> StSpFn
Use this to pass the individual components StateSpace implementation to the ODESolver class.
std::function< void(double, const double *, double *, double *, double *, double *, double *)> JacFn
std::shared_ptr< ODEInterface > Ptr
Tasks to be defined by every component.
std::vector< AttributeBase::Ptr > mModifiedAttributes
std::vector< AttributeBase::Ptr > mAttributeDependencies
SolveTask(ODESolver &solver)
void execute(Real time, Int timeStepCount)
int StateSpace(realtype t, N_Vector y, N_Vector ydot)
ODESolver(String name, const CPS::ODEInterface::Ptr &comp, bool implicit_integration, Real timestep)
Create solve object with corresponding component and information on the integration type.
virtual CPS::Task::List getTasks()
Get tasks for scheduler.
CPS::ODEInterface::Ptr mComponent
Component to simulate, possible specialized component needed.
Real step(Real initial_time)
Solve system for the current time.
void * mArkode_mem
Memory block allocated by ARKode.
int mFlag
Reusable error-checking flag.
realtype abstol
Scalar absolute tolerance.
CPS::ODEInterface::JacFn mJacFunction
SUNLinearSolver LS
Empty linear solver object.
int check_flag(void *flagvalue, const std::string &funcname, int opt)
ARKode- standard error detection function; in DAE-solver not detection function is used -> for effici...
N_Vector mStates
State vector.
void initialize()
Initialize ARKode-solve_environment.
bool mImplicitIntegration
Indicates whether the ODE shall be solved using an implicit scheme.
~ODESolver()
Deallocate all memory.
Real mTimestep
Constant time step.
SUNMatrix A
Empty matrix for linear solve in each Newton step while solving the Jacobian Matrix.
Int mProbDim
Number of differential Variables (states)
static int JacobianWrapper(realtype t, N_Vector y, N_Vector fy, SUNMatrix J, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
realtype reltol
Relative tolerance.
CPS::ODEInterface::StSpFn mStSpFunction
int Jacobian(realtype t, N_Vector y, N_Vector fy, SUNMatrix J, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
static int StateSpaceWrapper(realtype t, N_Vector y, N_Vector ydot, void *user_data)
Use wrappers similar to DAE_Solver.
Solver(String name, CPS::Logger::Level logLevel)