1 /* ----------------------------------------------------------------- 2 * Programmer(s): Radu Serban @ LLNL 3 * ----------------------------------------------------------------- 4 * SUNDIALS Copyright Start 5 * Copyright (c) 2002-2021, Lawrence Livermore National Security 6 * and Southern Methodist University. 7 * All rights reserved. 8 * 9 * See the top-level LICENSE and NOTICE files for details. 10 * 11 * SPDX-License-Identifier: BSD-3-Clause 12 * SUNDIALS Copyright End 13 * ----------------------------------------------------------------- 14 * This is the header file for the main CVODES integrator. 15 * -----------------------------------------------------------------*/ 16 17 #ifndef _CVODES_H 18 #define _CVODES_H 19 20 #include <stdio.h> 21 #include <sundials/sundials_nvector.h> 22 #include <sundials/sundials_nonlinearsolver.h> 23 #include <cvodes/cvodes_ls.h> 24 25 #ifdef __cplusplus /* wrapper to enable C++ usage */ 26 extern "C" { 27 #endif 28 29 /* ----------------- 30 * CVODES Constants 31 * ----------------- */ 32 33 /* lmm */ 34 #define CV_ADAMS 1 35 #define CV_BDF 2 36 37 /* itask */ 38 #define CV_NORMAL 1 39 #define CV_ONE_STEP 2 40 41 /* ism */ 42 #define CV_SIMULTANEOUS 1 43 #define CV_STAGGERED 2 44 #define CV_STAGGERED1 3 45 46 /* DQtype */ 47 #define CV_CENTERED 1 48 #define CV_FORWARD 2 49 50 /* interp */ 51 #define CV_HERMITE 1 52 #define CV_POLYNOMIAL 2 53 54 /* return values */ 55 56 #define CV_SUCCESS 0 57 #define CV_TSTOP_RETURN 1 58 #define CV_ROOT_RETURN 2 59 60 #define CV_WARNING 99 61 62 #define CV_TOO_MUCH_WORK -1 63 #define CV_TOO_MUCH_ACC -2 64 #define CV_ERR_FAILURE -3 65 #define CV_CONV_FAILURE -4 66 67 #define CV_LINIT_FAIL -5 68 #define CV_LSETUP_FAIL -6 69 #define CV_LSOLVE_FAIL -7 70 #define CV_RHSFUNC_FAIL -8 71 #define CV_FIRST_RHSFUNC_ERR -9 72 #define CV_REPTD_RHSFUNC_ERR -10 73 #define CV_UNREC_RHSFUNC_ERR -11 74 #define CV_RTFUNC_FAIL -12 75 #define CV_NLS_INIT_FAIL -13 76 #define CV_NLS_SETUP_FAIL -14 77 #define CV_CONSTR_FAIL -15 78 #define CV_NLS_FAIL -16 79 80 #define CV_MEM_FAIL -20 81 #define CV_MEM_NULL -21 82 #define CV_ILL_INPUT -22 83 #define CV_NO_MALLOC -23 84 #define CV_BAD_K -24 85 #define CV_BAD_T -25 86 #define CV_BAD_DKY -26 87 #define CV_TOO_CLOSE -27 88 #define CV_VECTOROP_ERR -28 89 90 #define CV_NO_QUAD -30 91 #define CV_QRHSFUNC_FAIL -31 92 #define CV_FIRST_QRHSFUNC_ERR -32 93 #define CV_REPTD_QRHSFUNC_ERR -33 94 #define CV_UNREC_QRHSFUNC_ERR -34 95 96 #define CV_NO_SENS -40 97 #define CV_SRHSFUNC_FAIL -41 98 #define CV_FIRST_SRHSFUNC_ERR -42 99 #define CV_REPTD_SRHSFUNC_ERR -43 100 #define CV_UNREC_SRHSFUNC_ERR -44 101 102 #define CV_BAD_IS -45 103 104 #define CV_NO_QUADSENS -50 105 #define CV_QSRHSFUNC_FAIL -51 106 #define CV_FIRST_QSRHSFUNC_ERR -52 107 #define CV_REPTD_QSRHSFUNC_ERR -53 108 #define CV_UNREC_QSRHSFUNC_ERR -54 109 110 111 #define CV_UNRECOGNIZED_ERR -99 112 113 /* adjoint return values */ 114 115 #define CV_NO_ADJ -101 116 #define CV_NO_FWD -102 117 #define CV_NO_BCK -103 118 #define CV_BAD_TB0 -104 119 #define CV_REIFWD_FAIL -105 120 #define CV_FWD_FAIL -106 121 #define CV_GETY_BADT -107 122 123 /* ------------------------------ 124 * User-Supplied Function Types 125 * ------------------------------ */ 126 127 typedef int (*CVRhsFn)(realtype t, N_Vector y, 128 N_Vector ydot, void *user_data); 129 130 typedef int (*CVRootFn)(realtype t, N_Vector y, realtype *gout, 131 void *user_data); 132 133 typedef int (*CVEwtFn)(N_Vector y, N_Vector ewt, void *user_data); 134 135 typedef void (*CVErrHandlerFn)(int error_code, 136 const char *module, const char *function, 137 char *msg, void *user_data); 138 139 typedef int (*CVQuadRhsFn)(realtype t, N_Vector y, 140 N_Vector yQdot, void *user_data); 141 142 typedef int (*CVSensRhsFn)(int Ns, realtype t, 143 N_Vector y, N_Vector ydot, 144 N_Vector *yS, N_Vector *ySdot, 145 void *user_data, 146 N_Vector tmp1, N_Vector tmp2); 147 148 typedef int (*CVSensRhs1Fn)(int Ns, realtype t, 149 N_Vector y, N_Vector ydot, 150 int iS, N_Vector yS, N_Vector ySdot, 151 void *user_data, 152 N_Vector tmp1, N_Vector tmp2); 153 154 typedef int (*CVQuadSensRhsFn)(int Ns, realtype t, 155 N_Vector y, N_Vector *yS, 156 N_Vector yQdot, N_Vector *yQSdot, 157 void *user_data, 158 N_Vector tmp, N_Vector tmpQ); 159 160 typedef int (*CVRhsFnB)(realtype t, N_Vector y, N_Vector yB, N_Vector yBdot, 161 void *user_dataB); 162 163 typedef int (*CVRhsFnBS)(realtype t, N_Vector y, N_Vector *yS, 164 N_Vector yB, N_Vector yBdot, void *user_dataB); 165 166 167 typedef int (*CVQuadRhsFnB)(realtype t, N_Vector y, N_Vector yB, N_Vector qBdot, 168 void *user_dataB); 169 170 typedef int (*CVQuadRhsFnBS)(realtype t, N_Vector y, N_Vector *yS, 171 N_Vector yB, N_Vector qBdot, void *user_dataB); 172 173 174 /* --------------------------------------- 175 * Exported Functions -- Forward Problems 176 * --------------------------------------- */ 177 178 /* Initialization functions */ 179 SUNDIALS_EXPORT void *CVodeCreate(int lmm); 180 181 SUNDIALS_EXPORT int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0, 182 N_Vector y0); 183 SUNDIALS_EXPORT int CVodeReInit(void *cvode_mem, realtype t0, N_Vector y0); 184 185 /* Tolerance input functions */ 186 SUNDIALS_EXPORT int CVodeSStolerances(void *cvode_mem, realtype reltol, 187 realtype abstol); 188 SUNDIALS_EXPORT int CVodeSVtolerances(void *cvode_mem, realtype reltol, 189 N_Vector abstol); 190 SUNDIALS_EXPORT int CVodeWFtolerances(void *cvode_mem, CVEwtFn efun); 191 192 /* Optional input functions */ 193 SUNDIALS_EXPORT int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun, 194 void *eh_data); 195 SUNDIALS_EXPORT int CVodeSetErrFile(void *cvode_mem, FILE *errfp); 196 SUNDIALS_EXPORT int CVodeSetUserData(void *cvode_mem, void *user_data); 197 SUNDIALS_EXPORT int CVodeSetMaxOrd(void *cvode_mem, int maxord); 198 SUNDIALS_EXPORT int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps); 199 SUNDIALS_EXPORT int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil); 200 SUNDIALS_EXPORT int CVodeSetStabLimDet(void *cvode_mem, booleantype stldet); 201 SUNDIALS_EXPORT int CVodeSetInitStep(void *cvode_mem, realtype hin); 202 SUNDIALS_EXPORT int CVodeSetMinStep(void *cvode_mem, realtype hmin); 203 SUNDIALS_EXPORT int CVodeSetMaxStep(void *cvode_mem, realtype hmax); 204 SUNDIALS_EXPORT int CVodeSetStopTime(void *cvode_mem, realtype tstop); 205 SUNDIALS_EXPORT int CVodeSetMaxErrTestFails(void *cvode_mem, int maxnef); 206 SUNDIALS_EXPORT int CVodeSetMaxNonlinIters(void *cvode_mem, int maxcor); 207 SUNDIALS_EXPORT int CVodeSetMaxConvFails(void *cvode_mem, int maxncf); 208 SUNDIALS_EXPORT int CVodeSetNonlinConvCoef(void *cvode_mem, realtype nlscoef); 209 SUNDIALS_EXPORT int CVodeSetLSetupFrequency(void *cvode_mem, long int msbp); 210 SUNDIALS_EXPORT int CVodeSetConstraints(void *cvode_mem, N_Vector constraints); 211 212 SUNDIALS_EXPORT int CVodeSetNonlinearSolver(void *cvode_mem, 213 SUNNonlinearSolver NLS); 214 215 /* Rootfinding initialization function */ 216 SUNDIALS_EXPORT int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g); 217 218 /* Rootfinding optional input functions */ 219 SUNDIALS_EXPORT int CVodeSetRootDirection(void *cvode_mem, int *rootdir); 220 SUNDIALS_EXPORT int CVodeSetNoInactiveRootWarn(void *cvode_mem); 221 222 /* Solver function */ 223 SUNDIALS_EXPORT int CVode(void *cvode_mem, realtype tout, N_Vector yout, 224 realtype *tret, int itask); 225 226 /* Dense output function */ 227 SUNDIALS_EXPORT int CVodeGetDky(void *cvode_mem, realtype t, int k, 228 N_Vector dky); 229 230 /* Utility functions to update/compute y based on ycor */ 231 SUNDIALS_EXPORT int CVodeComputeState(void *cvode_mem, N_Vector ycor, 232 N_Vector y); 233 SUNDIALS_EXPORT int CVodeComputeStateSens(void *cvode_mem, N_Vector *yScor, 234 N_Vector *yS); 235 SUNDIALS_EXPORT int CVodeComputeStateSens1(void *cvode_mem, int idx, 236 N_Vector yScor1, N_Vector yS1); 237 238 /* Optional output functions */ 239 SUNDIALS_EXPORT int CVodeGetWorkSpace(void *cvode_mem, long int *lenrw, 240 long int *leniw); 241 SUNDIALS_EXPORT int CVodeGetNumSteps(void *cvode_mem, long int *nsteps); 242 SUNDIALS_EXPORT int CVodeGetNumRhsEvals(void *cvode_mem, long int *nfevals); 243 SUNDIALS_EXPORT int CVodeGetNumLinSolvSetups(void *cvode_mem, 244 long int *nlinsetups); 245 SUNDIALS_EXPORT int CVodeGetNumErrTestFails(void *cvode_mem, 246 long int *netfails); 247 SUNDIALS_EXPORT int CVodeGetLastOrder(void *cvode_mem, int *qlast); 248 SUNDIALS_EXPORT int CVodeGetCurrentOrder(void *cvode_mem, int *qcur); 249 SUNDIALS_EXPORT int CVodeGetCurrentGamma(void *cvode_mem, realtype *gamma); 250 SUNDIALS_EXPORT int CVodeGetNumStabLimOrderReds(void *cvode_mem, 251 long int *nslred); 252 SUNDIALS_EXPORT int CVodeGetActualInitStep(void *cvode_mem, realtype *hinused); 253 SUNDIALS_EXPORT int CVodeGetLastStep(void *cvode_mem, realtype *hlast); 254 SUNDIALS_EXPORT int CVodeGetCurrentStep(void *cvode_mem, realtype *hcur); 255 SUNDIALS_EXPORT int CVodeGetCurrentState(void *cvode_mem, N_Vector *y); 256 SUNDIALS_EXPORT int CVodeGetCurrentStateSens(void *cvode_mem, N_Vector **yS); 257 SUNDIALS_EXPORT int CVodeGetCurrentSensSolveIndex(void *cvode_mem, int *index); 258 SUNDIALS_EXPORT int CVodeGetCurrentTime(void *cvode_mem, realtype *tcur); 259 SUNDIALS_EXPORT int CVodeGetTolScaleFactor(void *cvode_mem, realtype *tolsfac); 260 SUNDIALS_EXPORT int CVodeGetErrWeights(void *cvode_mem, N_Vector eweight); 261 SUNDIALS_EXPORT int CVodeGetEstLocalErrors(void *cvode_mem, N_Vector ele); 262 SUNDIALS_EXPORT int CVodeGetNumGEvals(void *cvode_mem, long int *ngevals); 263 SUNDIALS_EXPORT int CVodeGetRootInfo(void *cvode_mem, int *rootsfound); 264 SUNDIALS_EXPORT int CVodeGetIntegratorStats(void *cvode_mem, long int *nsteps, 265 long int *nfevals, 266 long int *nlinsetups, 267 long int *netfails, 268 int *qlast, int *qcur, 269 realtype *hinused, realtype *hlast, 270 realtype *hcur, realtype *tcur); 271 SUNDIALS_EXPORT int CVodeGetNonlinearSystemData(void *cvode_mem, realtype *tcur, 272 N_Vector *ypred, N_Vector *yn, 273 N_Vector *fn, realtype *gamma, 274 realtype *rl1, N_Vector *zn1, 275 void **user_data); 276 SUNDIALS_EXPORT int CVodeGetNonlinearSystemDataSens(void *cvode_mem, 277 realtype *tcur, 278 N_Vector **ySpred, 279 N_Vector **ySn, 280 realtype *gamma, 281 realtype *rl1, 282 N_Vector **zn1, 283 void **user_data); 284 SUNDIALS_EXPORT int CVodeGetNumNonlinSolvIters(void *cvode_mem, 285 long int *nniters); 286 SUNDIALS_EXPORT int CVodeGetNumNonlinSolvConvFails(void *cvode_mem, 287 long int *nncfails); 288 SUNDIALS_EXPORT int CVodeGetNonlinSolvStats(void *cvode_mem, long int *nniters, 289 long int *nncfails); 290 SUNDIALS_EXPORT char *CVodeGetReturnFlagName(long int flag); 291 292 /* Free function */ 293 SUNDIALS_EXPORT void CVodeFree(void **cvode_mem); 294 295 /* CVLS interface function that depends on CVRhsFn */ 296 SUNDIALS_EXPORT int CVodeSetJacTimesRhsFn(void *cvode_mem, 297 CVRhsFn jtimesRhsFn); 298 299 300 /* --------------------------------- 301 * Exported Functions -- Quadrature 302 * --------------------------------- */ 303 304 /* Initialization functions */ 305 SUNDIALS_EXPORT int CVodeQuadInit(void *cvode_mem, CVQuadRhsFn fQ, 306 N_Vector yQ0); 307 SUNDIALS_EXPORT int CVodeQuadReInit(void *cvode_mem, N_Vector yQ0); 308 309 /* Tolerance input functions */ 310 SUNDIALS_EXPORT int CVodeQuadSStolerances(void *cvode_mem, realtype reltolQ, 311 realtype abstolQ); 312 SUNDIALS_EXPORT int CVodeQuadSVtolerances(void *cvode_mem, realtype reltolQ, 313 N_Vector abstolQ); 314 315 /* Optional input specification functions */ 316 SUNDIALS_EXPORT int CVodeSetQuadErrCon(void *cvode_mem, booleantype errconQ); 317 318 /* Extraction and Dense Output Functions for Forward Problems */ 319 SUNDIALS_EXPORT int CVodeGetQuad(void *cvode_mem, realtype *tret, 320 N_Vector yQout); 321 SUNDIALS_EXPORT int CVodeGetQuadDky(void *cvode_mem, realtype t, int k, 322 N_Vector dky); 323 324 /* Optional output specification functions */ 325 SUNDIALS_EXPORT int CVodeGetQuadNumRhsEvals(void *cvode_mem, 326 long int *nfQevals); 327 SUNDIALS_EXPORT int CVodeGetQuadNumErrTestFails(void *cvode_mem, 328 long int *nQetfails); 329 SUNDIALS_EXPORT int CVodeGetQuadErrWeights(void *cvode_mem, N_Vector eQweight); 330 SUNDIALS_EXPORT int CVodeGetQuadStats(void *cvode_mem, long int *nfQevals, 331 long int *nQetfails); 332 333 /* Free function */ 334 SUNDIALS_EXPORT void CVodeQuadFree(void *cvode_mem); 335 336 337 /* ------------------------------------ 338 * Exported Functions -- Sensitivities 339 * ------------------------------------ */ 340 341 /* Initialization functions */ 342 SUNDIALS_EXPORT int CVodeSensInit(void *cvode_mem, int Ns, int ism, 343 CVSensRhsFn fS, N_Vector *yS0); 344 SUNDIALS_EXPORT int CVodeSensInit1(void *cvode_mem, int Ns, int ism, 345 CVSensRhs1Fn fS1, N_Vector *yS0); 346 SUNDIALS_EXPORT int CVodeSensReInit(void *cvode_mem, int ism, N_Vector *yS0); 347 348 /* Tolerance input functions */ 349 SUNDIALS_EXPORT int CVodeSensSStolerances(void *cvode_mem, realtype reltolS, 350 realtype *abstolS); 351 SUNDIALS_EXPORT int CVodeSensSVtolerances(void *cvode_mem, realtype reltolS, 352 N_Vector *abstolS); 353 SUNDIALS_EXPORT int CVodeSensEEtolerances(void *cvode_mem); 354 355 /* Optional input specification functions */ 356 SUNDIALS_EXPORT int CVodeSetSensDQMethod(void *cvode_mem, int DQtype, 357 realtype DQrhomax); 358 SUNDIALS_EXPORT int CVodeSetSensErrCon(void *cvode_mem, booleantype errconS); 359 SUNDIALS_EXPORT int CVodeSetSensMaxNonlinIters(void *cvode_mem, int maxcorS); 360 SUNDIALS_EXPORT int CVodeSetSensParams(void *cvode_mem, realtype *p, 361 realtype *pbar, int *plist); 362 363 /* Integrator nonlinear solver specification functions */ 364 SUNDIALS_EXPORT int CVodeSetNonlinearSolverSensSim(void *cvode_mem, 365 SUNNonlinearSolver NLS); 366 SUNDIALS_EXPORT int CVodeSetNonlinearSolverSensStg(void *cvode_mem, 367 SUNNonlinearSolver NLS); 368 SUNDIALS_EXPORT int CVodeSetNonlinearSolverSensStg1(void *cvode_mem, 369 SUNNonlinearSolver NLS); 370 371 /* Enable/disable sensitivities */ 372 SUNDIALS_EXPORT int CVodeSensToggleOff(void *cvode_mem); 373 374 /* Extraction and dense output functions */ 375 SUNDIALS_EXPORT int CVodeGetSens(void *cvode_mem, realtype *tret, 376 N_Vector *ySout); 377 SUNDIALS_EXPORT int CVodeGetSens1(void *cvode_mem, realtype *tret, int is, 378 N_Vector ySout); 379 380 SUNDIALS_EXPORT int CVodeGetSensDky(void *cvode_mem, realtype t, int k, 381 N_Vector *dkyA); 382 SUNDIALS_EXPORT int CVodeGetSensDky1(void *cvode_mem, realtype t, int k, int is, 383 N_Vector dky); 384 385 /* Optional output specification functions */ 386 SUNDIALS_EXPORT int CVodeGetSensNumRhsEvals(void *cvode_mem, 387 long int *nfSevals); 388 SUNDIALS_EXPORT int CVodeGetNumRhsEvalsSens(void *cvode_mem, 389 long int *nfevalsS); 390 SUNDIALS_EXPORT int CVodeGetSensNumErrTestFails(void *cvode_mem, 391 long int *nSetfails); 392 SUNDIALS_EXPORT int CVodeGetSensNumLinSolvSetups(void *cvode_mem, 393 long int *nlinsetupsS); 394 SUNDIALS_EXPORT int CVodeGetSensErrWeights(void *cvode_mem, N_Vector *eSweight); 395 SUNDIALS_EXPORT int CVodeGetSensStats(void *cvode_mem, long int *nfSevals, 396 long int *nfevalsS, long int *nSetfails, 397 long int *nlinsetupsS); 398 SUNDIALS_EXPORT int CVodeGetSensNumNonlinSolvIters(void *cvode_mem, 399 long int *nSniters); 400 SUNDIALS_EXPORT int CVodeGetSensNumNonlinSolvConvFails(void *cvode_mem, 401 long int *nSncfails); 402 SUNDIALS_EXPORT int CVodeGetSensNonlinSolvStats(void *cvode_mem, 403 long int *nSniters, 404 long int *nSncfails); 405 SUNDIALS_EXPORT int CVodeGetStgrSensNumNonlinSolvIters(void *cvode_mem, 406 long int *nSTGR1niters); 407 SUNDIALS_EXPORT int CVodeGetStgrSensNumNonlinSolvConvFails(void *cvode_mem, 408 long int *nSTGR1ncfails); 409 SUNDIALS_EXPORT int CVodeGetStgrSensNonlinSolvStats(void *cvode_mem, 410 long int *nSTGR1niters, 411 long int *nSTGR1ncfails); 412 413 /* Free function */ 414 SUNDIALS_EXPORT void CVodeSensFree(void *cvode_mem); 415 416 417 /* ------------------------------------------------------- 418 * Exported Functions -- Sensitivity dependent quadrature 419 * ------------------------------------------------------- */ 420 421 /* Initialization functions */ 422 SUNDIALS_EXPORT int CVodeQuadSensInit(void *cvode_mem, CVQuadSensRhsFn fQS, 423 N_Vector *yQS0); 424 SUNDIALS_EXPORT int CVodeQuadSensReInit(void *cvode_mem, N_Vector *yQS0); 425 426 /* Tolerance input functions */ 427 SUNDIALS_EXPORT int CVodeQuadSensSStolerances(void *cvode_mem, 428 realtype reltolQS, 429 realtype *abstolQS); 430 SUNDIALS_EXPORT int CVodeQuadSensSVtolerances(void *cvode_mem, 431 realtype reltolQS, 432 N_Vector *abstolQS); 433 SUNDIALS_EXPORT int CVodeQuadSensEEtolerances(void *cvode_mem); 434 435 /* Optional input specification functions */ 436 SUNDIALS_EXPORT int CVodeSetQuadSensErrCon(void *cvode_mem, 437 booleantype errconQS); 438 439 /* Extraction and dense output functions */ 440 SUNDIALS_EXPORT int CVodeGetQuadSens(void *cvode_mem, realtype *tret, 441 N_Vector *yQSout); 442 SUNDIALS_EXPORT int CVodeGetQuadSens1(void *cvode_mem, realtype *tret, int is, 443 N_Vector yQSout); 444 445 SUNDIALS_EXPORT int CVodeGetQuadSensDky(void *cvode_mem, realtype t, int k, 446 N_Vector *dkyQS_all); 447 SUNDIALS_EXPORT int CVodeGetQuadSensDky1(void *cvode_mem, realtype t, int k, 448 int is, N_Vector dkyQS); 449 450 /* Optional output specification functions */ 451 SUNDIALS_EXPORT int CVodeGetQuadSensNumRhsEvals(void *cvode_mem, 452 long int *nfQSevals); 453 SUNDIALS_EXPORT int CVodeGetQuadSensNumErrTestFails(void *cvode_mem, 454 long int *nQSetfails); 455 SUNDIALS_EXPORT int CVodeGetQuadSensErrWeights(void *cvode_mem, 456 N_Vector *eQSweight); 457 SUNDIALS_EXPORT int CVodeGetQuadSensStats(void *cvode_mem, 458 long int *nfQSevals, 459 long int *nQSetfails); 460 461 /* Free function */ 462 SUNDIALS_EXPORT void CVodeQuadSensFree(void *cvode_mem); 463 464 465 /* ---------------------------------------- 466 * Exported Functions -- Backward Problems 467 * ---------------------------------------- */ 468 469 /* Initialization functions */ 470 471 SUNDIALS_EXPORT int CVodeAdjInit(void *cvode_mem, long int steps, int interp); 472 473 SUNDIALS_EXPORT int CVodeAdjReInit(void *cvode_mem); 474 475 SUNDIALS_EXPORT void CVodeAdjFree(void *cvode_mem); 476 477 /* Backward Problem Setup Functions */ 478 479 SUNDIALS_EXPORT int CVodeCreateB(void *cvode_mem, int lmmB, int *which); 480 481 SUNDIALS_EXPORT int CVodeInitB(void *cvode_mem, int which, 482 CVRhsFnB fB, 483 realtype tB0, N_Vector yB0); 484 SUNDIALS_EXPORT int CVodeInitBS(void *cvode_mem, int which, 485 CVRhsFnBS fBs, 486 realtype tB0, N_Vector yB0); 487 SUNDIALS_EXPORT int CVodeReInitB(void *cvode_mem, int which, 488 realtype tB0, N_Vector yB0); 489 490 SUNDIALS_EXPORT int CVodeSStolerancesB(void *cvode_mem, int which, 491 realtype reltolB, realtype abstolB); 492 SUNDIALS_EXPORT int CVodeSVtolerancesB(void *cvode_mem, int which, 493 realtype reltolB, N_Vector abstolB); 494 495 SUNDIALS_EXPORT int CVodeQuadInitB(void *cvode_mem, int which, 496 CVQuadRhsFnB fQB, N_Vector yQB0); 497 SUNDIALS_EXPORT int CVodeQuadInitBS(void *cvode_mem, int which, 498 CVQuadRhsFnBS fQBs, N_Vector yQB0); 499 SUNDIALS_EXPORT int CVodeQuadReInitB(void *cvode_mem, int which, N_Vector yQB0); 500 501 SUNDIALS_EXPORT int CVodeQuadSStolerancesB(void *cvode_mem, int which, 502 realtype reltolQB, 503 realtype abstolQB); 504 SUNDIALS_EXPORT int CVodeQuadSVtolerancesB(void *cvode_mem, int which, 505 realtype reltolQB, 506 N_Vector abstolQB); 507 508 /* Solver Function For Forward Problems */ 509 510 SUNDIALS_EXPORT int CVodeF(void *cvode_mem, realtype tout, N_Vector yout, 511 realtype *tret, int itask, int *ncheckPtr); 512 513 514 /* Solver Function For Backward Problems */ 515 516 SUNDIALS_EXPORT int CVodeB(void *cvode_mem, realtype tBout, int itaskB); 517 518 /* Optional Input Functions For Adjoint Problems */ 519 520 SUNDIALS_EXPORT int CVodeSetAdjNoSensi(void *cvode_mem); 521 522 SUNDIALS_EXPORT int CVodeSetUserDataB(void *cvode_mem, int which, 523 void *user_dataB); 524 SUNDIALS_EXPORT int CVodeSetMaxOrdB(void *cvode_mem, int which, int maxordB); 525 SUNDIALS_EXPORT int CVodeSetMaxNumStepsB(void *cvode_mem, int which, 526 long int mxstepsB); 527 SUNDIALS_EXPORT int CVodeSetStabLimDetB(void *cvode_mem, int which, 528 booleantype stldetB); 529 SUNDIALS_EXPORT int CVodeSetInitStepB(void *cvode_mem, int which, 530 realtype hinB); 531 SUNDIALS_EXPORT int CVodeSetMinStepB(void *cvode_mem, int which, 532 realtype hminB); 533 SUNDIALS_EXPORT int CVodeSetMaxStepB(void *cvode_mem, int which, 534 realtype hmaxB); 535 SUNDIALS_EXPORT int CVodeSetConstraintsB(void *cvode_mem, int which, 536 N_Vector constraintsB); 537 SUNDIALS_EXPORT int CVodeSetQuadErrConB(void *cvode_mem, int which, 538 booleantype errconQB); 539 540 SUNDIALS_EXPORT int CVodeSetNonlinearSolverB(void *cvode_mem, int which, 541 SUNNonlinearSolver NLS); 542 543 /* Extraction And Dense Output Functions For Backward Problems */ 544 545 SUNDIALS_EXPORT int CVodeGetB(void *cvode_mem, int which, 546 realtype *tBret, N_Vector yB); 547 SUNDIALS_EXPORT int CVodeGetQuadB(void *cvode_mem, int which, 548 realtype *tBret, N_Vector qB); 549 550 /* Optional Output Functions For Backward Problems */ 551 552 SUNDIALS_EXPORT void *CVodeGetAdjCVodeBmem(void *cvode_mem, int which); 553 554 SUNDIALS_EXPORT int CVodeGetAdjY(void *cvode_mem, realtype t, N_Vector y); 555 556 typedef struct { 557 void *my_addr; 558 void *next_addr; 559 realtype t0; 560 realtype t1; 561 long int nstep; 562 int order; 563 realtype step; 564 } CVadjCheckPointRec; 565 566 SUNDIALS_EXPORT int CVodeGetAdjCheckPointsInfo(void *cvode_mem, 567 CVadjCheckPointRec *ckpnt); 568 569 /* CVLS interface function that depends on CVRhsFn */ 570 int CVodeSetJacTimesRhsFnB(void *cvode_mem, int which, CVRhsFn jtimesRhsFn); 571 572 573 /* Undocumented Optional Output Functions For Backward Problems */ 574 575 /* ----------------------------------------------------------------- 576 * CVodeGetAdjDataPointHermite 577 * ----------------------------------------------------------------- 578 * Returns the 2 vectors stored for cubic Hermite interpolation 579 * at the data point 'which'. The user must allocate space for 580 * y and yd. Returns CV_MEM_NULL if cvode_mem is NULL, 581 * CV_ILL_INPUT if the interpolation type previously specified 582 * is not CV_HERMITE, or CV_SUCCESS otherwise. 583 * ----------------------------------------------------------------- 584 * CVodeGetAdjDataPointPolynomial 585 * ----------------------------------------------------------------- 586 * Returns the vector stored for polynomial interpolation 587 * at the data point 'which'. The user must allocate space for 588 * y. Returns CV_MEM_NULL if cvode_mem is NULL, CV_ILL_INPUT if 589 * the interpolation type previously specified is not 590 * CV_POLYNOMIAL, or CV_SUCCESS otherwise. 591 * ----------------------------------------------------------------- */ 592 593 SUNDIALS_EXPORT int CVodeGetAdjDataPointHermite(void *cvode_mem, int which, 594 realtype *t, N_Vector y, 595 N_Vector yd); 596 597 SUNDIALS_EXPORT int CVodeGetAdjDataPointPolynomial(void *cvode_mem, int which, 598 realtype *t, int *order, 599 N_Vector y); 600 601 /* ----------------------------------------------------------------- 602 * CVodeGetAdjCurrentCheckPoint 603 * Returns the address of the 'active' check point. 604 * ----------------------------------------------------------------- */ 605 606 SUNDIALS_EXPORT int CVodeGetAdjCurrentCheckPoint(void *cvode_mem, void **addr); 607 608 609 #ifdef __cplusplus 610 } 611 #endif 612 613 #endif 614