From 606a761ef1ad8f5965d6e5a6706cc1560feebe12 Mon Sep 17 00:00:00 2001 From: Satyaprakash Nayak Date: Sat, 14 Dec 2024 18:19:37 -0500 Subject: [PATCH] Updated sundials to ver 7.2.0 --- DESCRIPTION | 2 +- LICENSE | 3 +- README.md | 13 +- cran-comments.md | 16 +- inst/include/arkode/arkode.h | 37 +++++ inst/include/arkode/arkode_arkstep.h | 13 +- inst/include/arkode/arkode_bandpre.h | 2 +- inst/include/arkode/arkode_erkstep.h | 33 +++-- inst/include/arkode/arkode_forcingstep.h | 43 ++++++ inst/include/arkode/arkode_lsrkstep.h | 99 +++++++++++++ inst/include/arkode/arkode_mristep.h | 83 ++++++++--- inst/include/arkode/arkode_splittingstep.h | 115 +++++++++++++++ inst/include/arkode/arkode_sprkstep.h | 4 +- inst/include/cvode/cvode_bandpre.h | 2 +- inst/include/cvodes/cvodes_bandpre.h | 2 +- .../sunadaptcontroller_mrihtol.h | 88 +++++++++++ .../sundials/priv/sundials_errors_impl.h | 22 +-- .../sundials/sundials_adaptcontroller.h | 39 ++++- inst/include/sundials/sundials_base.hpp | 2 +- inst/include/sundials/sundials_config.h | 15 +- .../sundials/sundials_convertibleto.hpp | 2 +- inst/include/sundials/sundials_errors.h | 2 +- inst/include/sundials/sundials_math.h | 40 +++++ inst/include/sundials/sundials_memory.h | 4 +- inst/include/sundials/sundials_nvector.h | 2 +- inst/include/sundials/sundials_stepper.h | 139 ++++++++++++++++++ .../sunnonlinsol/sunnonlinsol_fixedpoint.h | 2 +- src/scripts/sundials_download.sh | 6 +- 28 files changed, 741 insertions(+), 89 deletions(-) create mode 100644 inst/include/arkode/arkode_forcingstep.h create mode 100644 inst/include/arkode/arkode_lsrkstep.h create mode 100644 inst/include/arkode/arkode_splittingstep.h create mode 100644 inst/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h create mode 100644 inst/include/sundials/sundials_stepper.h diff --git a/DESCRIPTION b/DESCRIPTION index e5b1f31..bb73fe8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: sundialr Type: Package Title: An Interface to 'SUNDIALS' Ordinary Differential Equation (ODE) Solvers -Version: 0.1.5 +Version: 0.1.6 Authors@R: c( person("Satyaprakash", "Nayak", "", "satyaprakash.nayak@gmail.com", c("aut", "cre","cph"), comment = c(ORCID = "0000-0001-7225-1317")), person("Lawrence Livermore National Security", role = c("cph")), diff --git a/LICENSE b/LICENSE index d5f4d64..d0bdc89 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,3 @@ -YEAR: 2020 +YEAR: 2024 COPYRIGHT HOLDER: Satyaprakash Nayak ORGANIZATION: Satyaprakash Nayak - diff --git a/README.md b/README.md index 8c1e60f..da1524b 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,23 @@ information about `SUNDIALS` can be found [here](https://computing.llnl.gov/proj Currently `sundialr` provides an interface to the `serial` versions of `cvode` (for solving ODES), `cvodes` (for solving ODE with sensitivity equations) and `ida` (for solving differential-algebraic equations) using the Linear Solver (dense version). A convenience function `cvsolve` is provided which allows solving a system of equations with -multiple discontinutities in solution. An application of such a system of equations would be +multiple discontinuities in solution. An application of such a system of equations would be to simulate the effect of multiple bolus doses of a drug in clinical pharmacokinetics. See the vignette for more details. ## What's new? -### Release 0.1.5 +## Comments for version 0.1.6 ++ Updated the upstream `SUNDIALS` to version 7.2.0 ++ Complete overall of the build system to use `cmake` based installation + +### Comments for version 0.1.5 + Updated the upstream `SUNDIALS` to version 7.1.1. + Fixed the `pkgdown` website -+ There was a bug is assigning absolute tolerance in equations. Fixed now. ++ There was a bug in assigning absolute tolerance in equations. Fixed now. + +## Comments for version 0.1.4.1.2 +* Fixed the issue with forwarded email address. ### Release 0.1.4.1 + Fixed the linking bug due to multiple defined symbols. No other change. diff --git a/cran-comments.md b/cran-comments.md index 1b52c03..75c7b9d 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,12 @@ +## Comments for version 0.1.6 ++ Updated the upstream `SUNDIALS` to version 7.2.0 ++ Complete overall of the build system to use `cmake` based installation + +## Comments for 0.1.5 ++ Updated the upstream `SUNDIALS` to version 7.1.1. ++ Fixed the `pkgdown` website ++ There was a bug in assigning absolute tolerance in equations. Fixed now. + ## Comments for version 0.1.4.1.2 * Fixed the issue with forwarded email address. @@ -19,10 +28,3 @@ There were no ERRORs or WARNINGs or NOTEs. ## Downstream dependencies There are currently one downstream dependency for this package (CausalKinetiX) which should be unaffected. - - - - - - - diff --git a/inst/include/arkode/arkode.h b/inst/include/arkode/arkode.h index f4e0667..2bd9560 100644 --- a/inst/include/arkode/arkode.h +++ b/inst/include/arkode/arkode.h @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -140,6 +141,13 @@ extern "C" { #define ARK_STEPPER_UNSUPPORTED -48 +#define ARK_DOMEIG_FAIL -49 +#define ARK_MAX_STAGE_LIMIT_FAIL -50 + +#define ARK_SUNSTEPPER_ERR -51 + +#define ARK_STEP_DIRECTION_ERR -52 + #define ARK_UNRECOGNIZED_ERROR -99 /* ------------------------------ @@ -190,6 +198,18 @@ typedef enum ARK_RELAX_NEWTON } ARKRelaxSolver; +/* -------------------------- + * Error Accumulation Options + * -------------------------- */ + +typedef enum +{ + ARK_ACCUMERROR_NONE, + ARK_ACCUMERROR_MAX, + ARK_ACCUMERROR_SUM, + ARK_ACCUMERROR_AVG +} ARKAccumError; + /* -------------------------- * Shared API routines * -------------------------- */ @@ -200,6 +220,10 @@ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, ARKVecResizeFn resize, void* resize_data); SUNDIALS_EXPORT int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR); +/* Utility to wrap ARKODE as an MRIStepInnerStepper */ +SUNDIALS_EXPORT int ARKodeCreateMRIStepInnerStepper(void* arkode_mem, + MRIStepInnerStepper* stepper); + /* Tolerance input functions */ SUNDIALS_EXPORT int ARKodeSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol); @@ -228,6 +252,7 @@ SUNDIALS_EXPORT int ARKodeSetInterpolateStopTime(void* arkode_mem, SUNDIALS_EXPORT int ARKodeSetStopTime(void* arkode_mem, sunrealtype tstop); SUNDIALS_EXPORT int ARKodeClearStopTime(void* arkode_mem); SUNDIALS_EXPORT int ARKodeSetFixedStep(void* arkode_mem, sunrealtype hfixed); +SUNDIALS_EXPORT int ARKodeSetStepDirection(void* arkode_mem, sunrealtype stepdir); SUNDIALS_EXPORT int ARKodeSetUserData(void* arkode_mem, void* user_data); SUNDIALS_EXPORT int ARKodeSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); @@ -280,6 +305,9 @@ SUNDIALS_EXPORT int ARKodeSetInitStep(void* arkode_mem, sunrealtype hin); SUNDIALS_EXPORT int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin); SUNDIALS_EXPORT int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax); SUNDIALS_EXPORT int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails); +SUNDIALS_EXPORT int ARKodeSetAccumulatedErrorType(void* arkode_mem, + ARKAccumError accum_type); +SUNDIALS_EXPORT int ARKodeResetAccumulatedError(void* arkode_mem); /* Integrate the ODE over an interval in t */ SUNDIALS_EXPORT int ARKodeEvolve(void* arkode_mem, sunrealtype tout, @@ -294,6 +322,8 @@ SUNDIALS_EXPORT int ARKodeComputeState(void* arkode_mem, N_Vector zcor, N_Vector z); /* Optional output functions (general) */ +SUNDIALS_EXPORT int ARKodeGetNumRhsEvals(void* arkode_mem, int partition_index, + long int* num_rhs_evals); SUNDIALS_EXPORT int ARKodeGetNumStepAttempts(void* arkode_mem, long int* step_attempts); SUNDIALS_EXPORT int ARKodeGetWorkSpace(void* arkode_mem, long int* lenrw, @@ -301,6 +331,8 @@ SUNDIALS_EXPORT int ARKodeGetWorkSpace(void* arkode_mem, long int* lenrw, SUNDIALS_EXPORT int ARKodeGetNumSteps(void* arkode_mem, long int* nsteps); SUNDIALS_EXPORT int ARKodeGetLastStep(void* arkode_mem, sunrealtype* hlast); SUNDIALS_EXPORT int ARKodeGetCurrentStep(void* arkode_mem, sunrealtype* hcur); +SUNDIALS_EXPORT int ARKodeGetStepDirection(void* arkode_mem, + sunrealtype* stepdir); SUNDIALS_EXPORT int ARKodeGetErrWeights(void* arkode_mem, N_Vector eweight); SUNDIALS_EXPORT int ARKodeGetNumGEvals(void* arkode_mem, long int* ngevals); SUNDIALS_EXPORT int ARKodeGetRootInfo(void* arkode_mem, int* rootsfound); @@ -325,6 +357,8 @@ SUNDIALS_EXPORT int ARKodeGetNumConstrFails(void* arkode_mem, SUNDIALS_EXPORT int ARKodeGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur); +SUNDIALS_EXPORT int ARKodeGetAccumulatedError(void* arkode_mem, + sunrealtype* accum_error); /* Optional output functions (implicit solver) */ SUNDIALS_EXPORT int ARKodeGetNumLinSolvSetups(void* arkode_mem, @@ -412,6 +446,9 @@ SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveFails(void* arkode_mem, SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveIters(void* arkode_mem, long int* iters); +/* SUNStepper functions */ +SUNDIALS_EXPORT int ARKodeCreateSUNStepper(void* arkode_mem, SUNStepper* stepper); + #ifdef __cplusplus } #endif diff --git a/inst/include/arkode/arkode_arkstep.h b/inst/include/arkode/arkode_arkstep.h index f7a6f11..777663d 100644 --- a/inst/include/arkode/arkode_arkstep.h +++ b/inst/include/arkode/arkode_arkstep.h @@ -86,8 +86,6 @@ SUNDIALS_EXPORT int ARKStepSetTableName(void* arkode_mem, const char* itable, const char* etable); /* Optional output functions */ -SUNDIALS_EXPORT int ARKStepGetNumRhsEvals(void* arkode_mem, long int* nfe_evals, - long int* nfi_evals); SUNDIALS_EXPORT int ARKStepGetCurrentButcherTables(void* arkode_mem, ARKodeButcherTable* Bi, ARKodeButcherTable* Be); @@ -96,14 +94,13 @@ SUNDIALS_EXPORT int ARKStepGetTimestepperStats( long int* step_attempts, long int* nfe_evals, long int* nfi_evals, long int* nlinsetups, long int* netfails); -/* MRIStep interface functions */ -SUNDIALS_EXPORT int ARKStepCreateMRIStepInnerStepper(void* arkode_mem, - MRIStepInnerStepper* stepper); - /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines * -------------------------------------------------------------------------- */ +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeCreateMRIStepInnerStepper instead") +int ARKStepCreateMRIStepInnerStepper(void* arkode_mem, + MRIStepInnerStepper* stepper); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResize instead") int ARKStepResize(void* arkode_mem, N_Vector ynew, sunrealtype hscale, sunrealtype t0, ARKVecResizeFn resize, void* resize_data); @@ -430,7 +427,9 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveFails instead") int ARKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveIters instead") int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters); - +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRhsEvals instead") +int ARKStepGetNumRhsEvals(void* arkode_mem, long int* nfe_evals, + long int* nfi_evals); #ifdef __cplusplus } #endif diff --git a/inst/include/arkode/arkode_bandpre.h b/inst/include/arkode/arkode_bandpre.h index 526c657..88c4c7c 100644 --- a/inst/include/arkode/arkode_bandpre.h +++ b/inst/include/arkode/arkode_bandpre.h @@ -24,7 +24,7 @@ extern "C" { #endif -/* BandPrec inititialization function */ +/* BandPrec initialization function */ SUNDIALS_EXPORT int ARKBandPrecInit(void* arkode_mem, sunindextype N, sunindextype mu, sunindextype ml); diff --git a/inst/include/arkode/arkode_erkstep.h b/inst/include/arkode/arkode_erkstep.h index ed93a24..ea5ad62 100644 --- a/inst/include/arkode/arkode_erkstep.h +++ b/inst/include/arkode/arkode_erkstep.h @@ -59,7 +59,6 @@ SUNDIALS_EXPORT int ERKStepSetTableNum(void* arkode_mem, SUNDIALS_EXPORT int ERKStepSetTableName(void* arkode_mem, const char* etable); /* Optional output functions */ -SUNDIALS_EXPORT int ERKStepGetNumRhsEvals(void* arkode_mem, long int* nfevals); SUNDIALS_EXPORT int ERKStepGetCurrentButcherTable(void* arkode_mem, ARKodeButcherTable* B); @@ -109,7 +108,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxGrowth instead") int ERKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMinReduction instead") int ERKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetFiARKodeBounds instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStepBounds instead") int ERKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub); SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") int ERKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, @@ -128,15 +127,15 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxErrTestFails instead") int ERKStepSetMaxErrTestFails(void* arkode_mem, int maxnef); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetConstraints instead") int ERKStepSetConstraints(void* arkode_mem, N_Vector constraints); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetMaxARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumSteps instead") int ERKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxHnilWarns instead") int ERKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetIARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInitStep instead") int ERKStepSetInitStep(void* arkode_mem, sunrealtype hin); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMinStep instead") int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxStep instead") int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolateStopTime instead") int ERKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp); @@ -144,7 +143,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStopTime instead") int ERKStepSetStopTime(void* arkode_mem, sunrealtype tstop); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeClearStopTime instead") int ERKStepClearStopTime(void* arkode_mem); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetFiARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStep instead") int ERKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumConstrFails instead") int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails); @@ -154,7 +153,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNoInactiveRootWarn instead") int ERKStepSetNoInactiveRootWarn(void* arkode_mem); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetUserData instead") int ERKStepSetUserData(void* arkode_mem, void* user_data); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetPostprocARKodeFn instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStepFn instead") int ERKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead") int ERKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage); @@ -163,11 +162,11 @@ int ERKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype* tret, int itask); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetDky instead") int ERKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetNumARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumExpSteps instead") int ERKStepGetNumExpSteps(void* arkode_mem, long int* expsteps); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetNumARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumAccSteps instead") int ERKStepGetNumAccSteps(void* arkode_mem, long int* accsteps); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetARKodeAttempts instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumStepAttempts instead") int ERKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumErrTestFails instead") int ERKStepGetNumErrTestFails(void* arkode_mem, long int* netfails); @@ -175,13 +174,13 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetEstLocalErrors instead") int ERKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetWorkSpace instead") int ERKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumSteps instead") int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetActualIARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetActualInitStep instead") int ERKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetLARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastStep instead") int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetCurrARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentStep instead") int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead") int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); @@ -206,7 +205,7 @@ int ERKStepWriteParameters(void* arkode_mem, FILE* fp); SUNDIALS_DEPRECATED_EXPORT_MSG( "use ERKStepGetCurrentButcherTable and ARKodeButcherTable_Write instead") int ERKStepWriteButcher(void* arkode_mem, FILE* fp); -SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepARKodeStats instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetStepStats instead") int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead") @@ -244,6 +243,8 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveFails instead") int ERKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveIters instead") int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRhsEvals instead") +int ERKStepGetNumRhsEvals(void* arkode_mem, long int* nfevals); #ifdef __cplusplus } diff --git a/inst/include/arkode/arkode_forcingstep.h b/inst/include/arkode/arkode_forcingstep.h new file mode 100644 index 0000000..4c1eecb --- /dev/null +++ b/inst/include/arkode/arkode_forcingstep.h @@ -0,0 +1,43 @@ +/*--------------------------------------------------------------- + * Programmer(s): Steven B. Roberts @ LLNL + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This is the header file for the ARKODE ForcingStep module. + *--------------------------------------------------------------*/ + +#ifndef ARKODE_FORCINGINGSTEP_H_ +#define ARKODE_FORCINGINGSTEP_H_ + +#include +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +SUNDIALS_EXPORT void* ForcingStepCreate(SUNStepper stepper1, + SUNStepper stepper2, sunrealtype t0, + N_Vector y0, SUNContext sunctx); + +SUNDIALS_EXPORT int ForcingStepReInit(void* arkode_mem, SUNStepper stepper1, + SUNStepper stepper2, sunrealtype t0, + N_Vector y0); + +SUNDIALS_EXPORT int ForcingStepGetNumEvolves(void* arkode_mem, int partition, + long int* evolves); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inst/include/arkode/arkode_lsrkstep.h b/inst/include/arkode/arkode_lsrkstep.h new file mode 100644 index 0000000..6b88fa6 --- /dev/null +++ b/inst/include/arkode/arkode_lsrkstep.h @@ -0,0 +1,99 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds and Mustafa Aggul @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the ARKODE LSRKStep module. + * -----------------------------------------------------------------*/ + +#ifndef _LSRKSTEP_H +#define _LSRKSTEP_H + +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +typedef int (*ARKDomEigFn)(sunrealtype t, N_Vector y, N_Vector fn, + sunrealtype* lambdaR, sunrealtype* lambdaI, + void* user_data, N_Vector temp1, N_Vector temp2, + N_Vector temp3); + +/* ------------------ + * LSRKStep Constants + * ------------------ */ + +typedef enum +{ + ARKODE_LSRK_RKC_2, + ARKODE_LSRK_RKL_2, + ARKODE_LSRK_SSP_S_2, + ARKODE_LSRK_SSP_S_3, + ARKODE_LSRK_SSP_10_4 +} ARKODE_LSRKMethodType; + +/* ------------------- + * Exported Functions + * ------------------- */ + +/* Creation and Reinitialization functions */ + +SUNDIALS_EXPORT void* LSRKStepCreateSTS(ARKRhsFn rhs, sunrealtype t0, + N_Vector y0, SUNContext sunctx); + +SUNDIALS_EXPORT void* LSRKStepCreateSSP(ARKRhsFn rhs, sunrealtype t0, + N_Vector y0, SUNContext sunctx); + +SUNDIALS_EXPORT int LSRKStepReInitSTS(void* arkode_mem, ARKRhsFn rhs, + sunrealtype t0, N_Vector y0); + +SUNDIALS_EXPORT int LSRKStepReInitSSP(void* arkode_mem, ARKRhsFn rhs, + sunrealtype t0, N_Vector y0); + +/* Optional input functions -- must be called AFTER a creation routine above */ + +SUNDIALS_EXPORT int LSRKStepSetSTSMethod(void* arkode_mem, + ARKODE_LSRKMethodType method); + +SUNDIALS_EXPORT int LSRKStepSetSSPMethod(void* arkode_mem, + ARKODE_LSRKMethodType method); + +SUNDIALS_EXPORT int LSRKStepSetSTSMethodByName(void* arkode_mem, + const char* emethod); + +SUNDIALS_EXPORT int LSRKStepSetSSPMethodByName(void* arkode_mem, + const char* emethod); + +SUNDIALS_EXPORT int LSRKStepSetDomEigFn(void* arkode_mem, ARKDomEigFn dom_eig); + +SUNDIALS_EXPORT int LSRKStepSetDomEigFrequency(void* arkode_mem, long int nsteps); + +SUNDIALS_EXPORT int LSRKStepSetMaxNumStages(void* arkode_mem, + int stage_max_limit); + +SUNDIALS_EXPORT int LSRKStepSetDomEigSafetyFactor(void* arkode_mem, + sunrealtype dom_eig_safety); + +SUNDIALS_EXPORT int LSRKStepSetNumSSPStages(void* arkode_mem, int num_of_stages); + +/* Optional output functions */ + +SUNDIALS_EXPORT int LSRKStepGetNumDomEigUpdates(void* arkode_mem, + long int* dom_eig_num_evals); + +SUNDIALS_EXPORT int LSRKStepGetMaxNumStages(void* arkode_mem, int* stage_max); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inst/include/arkode/arkode_mristep.h b/inst/include/arkode/arkode_mristep.h index 000bae1..6b8fcda 100644 --- a/inst/include/arkode/arkode_mristep.h +++ b/inst/include/arkode/arkode_mristep.h @@ -22,6 +22,8 @@ #include #include #include +#include +#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -36,9 +38,12 @@ typedef enum { MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, - MRISTEP_IMEX + MRISTEP_IMEX, + MRISTEP_MERK, + MRISTEP_SR } MRISTEP_METHOD_TYPE; +/* MRI coupling table IDs */ typedef enum { ARKODE_MRI_NONE = -1, /* ensure enum is signed int */ @@ -62,15 +67,27 @@ typedef enum ARKODE_IMEX_MRI_GARK_EULER, ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL, ARKODE_IMEX_MRI_GARK_MIDPOINT, - ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_GARK_MIDPOINT, + ARKODE_MERK21, + ARKODE_MERK32, + ARKODE_MERK43, + ARKODE_MERK54, + ARKODE_IMEX_MRI_SR21, + ARKODE_IMEX_MRI_SR32, + ARKODE_IMEX_MRI_SR43, + ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_SR43 } ARKODE_MRITableID; -/* Default MRI coupling tables for each order */ +/* Default MRI coupling tables for each order and type */ static const int MRISTEP_DEFAULT_EXPL_1 = ARKODE_MRI_GARK_FORWARD_EULER; static const int MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22b; static const int MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3; static const int MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a; +static const int MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22b; +static const int MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a; +static const int MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a; +static const int MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54; + static const int MRISTEP_DEFAULT_IMPL_SD_1 = ARKODE_MRI_GARK_BACKWARD_EULER; static const int MRISTEP_DEFAULT_IMPL_SD_2 = ARKODE_MRI_GARK_IRK21a; static const int MRISTEP_DEFAULT_IMPL_SD_3 = ARKODE_MRI_GARK_ESDIRK34a; @@ -81,6 +98,10 @@ static const int MRISTEP_DEFAULT_IMEX_SD_2 = ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL; static const int MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b; static const int MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4; +static const int MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21; +static const int MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32; +static const int MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43; + /* ------------------------------------ * MRIStep Inner Stepper Function Types * ------------------------------------ */ @@ -94,18 +115,29 @@ typedef int (*MRIStepInnerFullRhsFn)(MRIStepInnerStepper stepper, sunrealtype t, typedef int (*MRIStepInnerResetFn)(MRIStepInnerStepper stepper, sunrealtype tR, N_Vector yR); +typedef int (*MRIStepInnerGetAccumulatedError)(MRIStepInnerStepper stepper, + sunrealtype* accum_error); + +typedef int (*MRIStepInnerResetAccumulatedError)(MRIStepInnerStepper stepper); + +typedef int (*MRIStepInnerSetRTol)(MRIStepInnerStepper stepper, sunrealtype rtol); + /*--------------------------------------------------------------- MRI coupling data structure and associated utility routines ---------------------------------------------------------------*/ struct MRIStepCouplingMem { - int nmat; /* number of MRI coupling matrices */ - int stages; /* size of coupling matrices (stages * stages) */ - int q; /* method order of accuracy */ - int p; /* embedding order of accuracy */ - sunrealtype* c; /* stage abscissae */ - sunrealtype*** W; /* explicit coupling matrices [nmat][stages][stages] */ - sunrealtype*** G; /* implicit coupling matrices [nmat][stages][stages] */ + MRISTEP_METHOD_TYPE type; /* flag to encode the MRI method type */ + int nmat; /* number of MRI coupling matrices */ + int stages; /* size of coupling matrices ((stages+1) * stages) */ + int q; /* method order of accuracy */ + int p; /* embedding order of accuracy */ + sunrealtype* c; /* stage abscissae */ + sunrealtype*** W; /* explicit coupling matrices [nmat][stages+1][stages] */ + sunrealtype*** G; /* implicit coupling matrices [nmat][stages+1][stages] */ + + int ngroup; /* number of stage groups (MERK-specific) */ + int** group; /* stages to integrate together (MERK-specific) */ }; typedef _SUNDIALS_STRUCT_ MRIStepCouplingMem* MRIStepCoupling; @@ -160,15 +192,19 @@ SUNDIALS_EXPORT int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn); /* Optional output functions */ -SUNDIALS_EXPORT int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, - long int* nfsi_evals); SUNDIALS_EXPORT int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC); SUNDIALS_EXPORT int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag); +SUNDIALS_EXPORT int MRIStepGetNumInnerStepperFails(void* arkode_mem, + long int* inner_fails); /* Custom inner stepper functions */ SUNDIALS_EXPORT int MRIStepInnerStepper_Create(SUNContext sunctx, MRIStepInnerStepper* stepper); + +SUNDIALS_EXPORT int MRIStepInnerStepper_CreateFromSUNStepper( + SUNStepper sunstepper, MRIStepInnerStepper* stepper); + SUNDIALS_EXPORT int MRIStepInnerStepper_Free(MRIStepInnerStepper* stepper); SUNDIALS_EXPORT int MRIStepInnerStepper_SetContent(MRIStepInnerStepper stepper, void* content); @@ -180,6 +216,12 @@ SUNDIALS_EXPORT int MRIStepInnerStepper_SetFullRhsFn(MRIStepInnerStepper stepper MRIStepInnerFullRhsFn fn); SUNDIALS_EXPORT int MRIStepInnerStepper_SetResetFn(MRIStepInnerStepper stepper, MRIStepInnerResetFn fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetAccumulatedErrorGetFn( + MRIStepInnerStepper stepper, MRIStepInnerGetAccumulatedError fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetAccumulatedErrorResetFn( + MRIStepInnerStepper stepper, MRIStepInnerResetAccumulatedError fn); +SUNDIALS_EXPORT int MRIStepInnerStepper_SetRTolFn(MRIStepInnerStepper stepper, + MRIStepInnerSetRTol fn); SUNDIALS_EXPORT int MRIStepInnerStepper_AddForcing(MRIStepInnerStepper stepper, sunrealtype t, N_Vector f); SUNDIALS_EXPORT int MRIStepInnerStepper_GetForcingData( @@ -223,7 +265,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinear instead") int MRIStepSetLinear(void* arkode_mem, int timedepend); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinear instead") int MRIStepSetNonlinear(void* arkode_mem); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepSetMaxARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumSteps instead") int MRIStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinCRDown instead") int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown); @@ -247,7 +289,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStopTime instead") int MRIStepSetStopTime(void* arkode_mem, sunrealtype tstop); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeClearStopTime instead") int MRIStepClearStopTime(void* arkode_mem); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepSetFiARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStep instead") int MRIStepSetFixedStep(void* arkode_mem, sunrealtype hsfixed); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRootDirection instead") int MRIStepSetRootDirection(void* arkode_mem, int* rootdir); @@ -255,7 +297,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNoInactiveRootWarn instead") int MRIStepSetNoInactiveRootWarn(void* arkode_mem); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetUserData instead") int MRIStepSetUserData(void* arkode_mem, void* user_data); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepSetPostprocARKodeFn instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStepFn instead") int MRIStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead") int MRIStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage); @@ -294,9 +336,9 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinSolvSetups instead") int MRIStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetWorkSpace instead") int MRIStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepGetARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumSteps instead") int MRIStepGetNumSteps(void* arkode_mem, long int* nssteps); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepGetLARKode instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastStep instead") int MRIStepGetLastStep(void* arkode_mem, sunrealtype* hlast); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead") int MRIStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); @@ -335,13 +377,13 @@ int MRIStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNonlinSolvStats instead") int MRIStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, long int* nnfails); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepGetARKodeSolveFails instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumStepSolveFails instead") int MRIStepGetNumStepSolveFails(void* arkode_mem, long int* nncfails); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetJac instead") int MRIStepGetJac(void* arkode_mem, SUNMatrix* J); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetJacTime instead") int MRIStepGetJacTime(void* arkode_mem, sunrealtype* t_J); -SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepGetJacARKodes instead") +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetJacNumSteps instead") int MRIStepGetJacNumSteps(void* arkode_mem, long* nst_J); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLinWorkSpace instead") int MRIStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, @@ -370,6 +412,9 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead") void MRIStepFree(void** arkode_mem); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintMem instead") void MRIStepPrintMem(void* arkode_mem, FILE* outfile); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRhsEvals instead") +int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, + long int* nfsi_evals); #ifdef __cplusplus } diff --git a/inst/include/arkode/arkode_splittingstep.h b/inst/include/arkode/arkode_splittingstep.h new file mode 100644 index 0000000..b052389 --- /dev/null +++ b/inst/include/arkode/arkode_splittingstep.h @@ -0,0 +1,115 @@ +/*--------------------------------------------------------------- + * Programmer(s): Steven B. Roberts @ LLNL + *--------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + *--------------------------------------------------------------- + * This is the header file for the ARKODE SplittingStep module. + *--------------------------------------------------------------*/ + +#ifndef ARKODE_SPLITTINGSTEP_H_ +#define ARKODE_SPLITTINGSTEP_H_ + +#include +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/*--------------------------------------------------------------- + Types : struct SplittingStepCoefficientsMem, SplittingStepCoefficients + ---------------------------------------------------------------*/ +struct SplittingStepCoefficientsMem +{ + sunrealtype* alpha; /* weights for sum over sequential splitting methods */ + sunrealtype*** beta; /* subintegration nodes, indexed by the sequential method, stage, and partition */ + int sequential_methods; /* number of sequential splitting methods */ + int stages; /* number of stages within each sequential splitting method */ + int partitions; /* number of RHS partitions */ + int order; /* order of convergence */ +}; + +typedef _SUNDIALS_STRUCT_ SplittingStepCoefficientsMem* SplittingStepCoefficients; + +/* Splitting names use the convention + * ARKODE_SPLITTING____ */ +typedef enum +{ + ARKODE_SPLITTING_NONE = -1, /* ensure enum is signed int */ + ARKODE_MIN_SPLITTING_NUM = 0, + ARKODE_SPLITTING_LIE_TROTTER_1_1_2 = ARKODE_MIN_SPLITTING_NUM, + ARKODE_SPLITTING_STRANG_2_2_2, + ARKODE_SPLITTING_BEST_2_2_2, + ARKODE_SPLITTING_SUZUKI_3_3_2, + ARKODE_SPLITTING_RUTH_3_3_2, + ARKODE_SPLITTING_YOSHIDA_4_4_2, + ARKODE_SPLITTING_YOSHIDA_8_6_2, + ARKODE_MAX_SPLITTING_NUM = ARKODE_SPLITTING_YOSHIDA_8_6_2 +} ARKODE_SplittingCoefficientsID; + +/* Coefficient memory management */ +SUNDIALS_EXPORT SplittingStepCoefficients SplittingStepCoefficients_Alloc( + int sequential_methods, int stages, int partitions); +SUNDIALS_EXPORT SplittingStepCoefficients SplittingStepCoefficients_Create( + int sequential_methods, int stages, int partitions, int order, + sunrealtype* alpha, sunrealtype* beta); +SUNDIALS_EXPORT void SplittingStepCoefficients_Destroy( + SplittingStepCoefficients* coefficients); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_Copy(SplittingStepCoefficients coefficients); +SUNDIALS_EXPORT void SplittingStepCoefficients_Write( + SplittingStepCoefficients coefficients, FILE* outfile); + +/* Load splitting coefficients */ +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_LoadCoefficients(ARKODE_SplittingCoefficientsID id); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_LoadCoefficientsByName(const char* name); +SUNDIALS_EXPORT const char* SplittingStepCoefficients_IDToName( + ARKODE_SplittingCoefficientsID id); + +/* Constructors for splitting coefficients */ +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_LieTrotter(int partitions); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_Strang(int partitions); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_Parallel(int partitions); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_SymmetricParallel(int partitions); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_ThirdOrderSuzuki(int partitions); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_TripleJump(int partitions, int order); +SUNDIALS_EXPORT SplittingStepCoefficients +SplittingStepCoefficients_SuzukiFractal(int partitions, int order); + +/* Functions for SplittingStep integrator */ +SUNDIALS_EXPORT void* SplittingStepCreate(SUNStepper* steppers, int partitions, + sunrealtype t0, N_Vector y0, + SUNContext sunctx); + +SUNDIALS_EXPORT int SplittingStepReInit(void* arkode_mem, SUNStepper* steppers, + int partitions, sunrealtype t0, + N_Vector y0); + +SUNDIALS_EXPORT int SplittingStepSetCoefficients( + void* arkode_mem, SplittingStepCoefficients coefficients); + +SUNDIALS_EXPORT int SplittingStepGetNumEvolves(void* arkode_mem, int partition, + long int* evolves); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/inst/include/arkode/arkode_sprkstep.h b/inst/include/arkode/arkode_sprkstep.h index 3e4519c..e4ed573 100644 --- a/inst/include/arkode/arkode_sprkstep.h +++ b/inst/include/arkode/arkode_sprkstep.h @@ -57,8 +57,6 @@ SUNDIALS_EXPORT int SPRKStepSetMethodName(void* arkode_mem, const char* method); /* Optional output functions */ SUNDIALS_EXPORT int SPRKStepGetCurrentMethod(void* arkode_mem, ARKodeSPRKTable* sprk_storage); -SUNDIALS_EXPORT int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, - long int* nf2); /* -------------------------------------------------------------------------- * Deprecated Functions -- all are superseded by shared ARKODE-level routines @@ -126,6 +124,8 @@ int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hcur, sunrealtype* tcur); SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead") void SPRKStepFree(void** arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRhsEvals instead") +int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2); #ifdef __cplusplus } diff --git a/inst/include/cvode/cvode_bandpre.h b/inst/include/cvode/cvode_bandpre.h index bde2d10..93dc658 100644 --- a/inst/include/cvode/cvode_bandpre.h +++ b/inst/include/cvode/cvode_bandpre.h @@ -25,7 +25,7 @@ extern "C" { #endif -/* BandPrec inititialization function */ +/* BandPrec initialization function */ SUNDIALS_EXPORT int CVBandPrecInit(void* cvode_mem, sunindextype N, sunindextype mu, sunindextype ml); diff --git a/inst/include/cvodes/cvodes_bandpre.h b/inst/include/cvodes/cvodes_bandpre.h index fe58698..426e3f6 100644 --- a/inst/include/cvodes/cvodes_bandpre.h +++ b/inst/include/cvodes/cvodes_bandpre.h @@ -29,7 +29,7 @@ extern "C" { FORWARD PROBLEMS -----------------*/ -/* BandPrec inititialization function */ +/* BandPrec initialization function */ SUNDIALS_EXPORT int CVBandPrecInit(void* cvode_mem, sunindextype N, sunindextype mu, sunindextype ml); diff --git a/inst/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h b/inst/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h new file mode 100644 index 0000000..baeffe7 --- /dev/null +++ b/inst/include/sunadaptcontroller/sunadaptcontroller_mrihtol.h @@ -0,0 +1,88 @@ +/* ----------------------------------------------------------------- + * Programmer(s): Daniel R. Reynolds @ SMU + * ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * ----------------------------------------------------------------- + * This is the header file for the SUNAdaptController_MRIHTol module. + * -----------------------------------------------------------------*/ + +#ifndef _SUNADAPTCONTROLLER_MRIHTOL_H +#define _SUNADAPTCONTROLLER_MRIHTOL_H + +#include +#include + +#ifdef __cplusplus /* wrapper to enable C++ usage */ +extern "C" { +#endif + +/* ---------------------------------------------------- + * MRI H+tolerance implementation of SUNAdaptController + * ---------------------------------------------------- */ + +struct SUNAdaptControllerContent_MRIHTol_ +{ + SUNAdaptController HControl; + SUNAdaptController TolControl; + sunrealtype inner_max_relch; + sunrealtype inner_min_tolfac; + sunrealtype inner_max_tolfac; +}; + +typedef struct SUNAdaptControllerContent_MRIHTol_* SUNAdaptControllerContent_MRIHTol; + +/* ------------------ + * Exported Functions + * ------------------ */ + +SUNDIALS_EXPORT +SUNAdaptController SUNAdaptController_MRIHTol(SUNAdaptController HControl, + SUNAdaptController TolControl, + SUNContext sunctx); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_SetParams_MRIHTol(SUNAdaptController C, + sunrealtype inner_max_relch, + sunrealtype inner_min_tolfac, + sunrealtype inner_max_tolfac); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_GetSlowController_MRIHTol(SUNAdaptController C, + SUNAdaptController* Cslow); +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_GetFastController_MRIHTol(SUNAdaptController C, + SUNAdaptController* Cfast); +SUNDIALS_EXPORT +SUNAdaptController_Type SUNAdaptController_GetType_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_EstimateStepTol_MRIHTol( + SUNAdaptController C, sunrealtype H, sunrealtype tolfac, int P, + sunrealtype DSM, sunrealtype dsm, sunrealtype* Hnew, sunrealtype* tolfacnew); +SUNDIALS_EXPORT +int SUNAdaptController_Reset_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_SetDefaults_MRIHTol(SUNAdaptController C); +SUNDIALS_EXPORT +int SUNAdaptController_Write_MRIHTol(SUNAdaptController C, FILE* fptr); +SUNDIALS_EXPORT +int SUNAdaptController_SetErrorBias_MRIHTol(SUNAdaptController C, + sunrealtype bias); +SUNDIALS_EXPORT +int SUNAdaptController_UpdateMRIHTol_MRIHTol(SUNAdaptController C, + sunrealtype H, sunrealtype tolfac, + sunrealtype DSM, sunrealtype dsm); +SUNDIALS_EXPORT +int SUNAdaptController_Space_MRIHTol(SUNAdaptController C, long int* lenrw, + long int* leniw); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNADAPTCONTROLLER_MRIHTOL_H */ diff --git a/inst/include/sundials/priv/sundials_errors_impl.h b/inst/include/sundials/priv/sundials_errors_impl.h index 115b5ee..eea844c 100644 --- a/inst/include/sundials/priv/sundials_errors_impl.h +++ b/inst/include/sundials/priv/sundials_errors_impl.h @@ -186,10 +186,12 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, msglen = (size_t)vsnprintf(NULL, (size_t)0, msgfmt, values); /* determine size of buffer needed */ - msg = (char*)malloc(msglen + 1); + va_end(values); + msg = (char*)malloc(msglen + 1); + va_start(values, sunctx); vsnprintf(msg, msglen + 1, msgfmt, values); - SUNHandleErrWithMsg(line, func, file, msg, code, sunctx); va_end(values); + SUNHandleErrWithMsg(line, func, file, msg, code, sunctx); free(msg); } @@ -328,7 +330,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckCallMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, call the error handler, **and then return the error code**. :param call: the function call @@ -352,7 +354,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckCallNoRetMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, and call the error handler. **It does not return**. :param call: the function call @@ -375,7 +377,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckCallNullMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, call the error handler, **and then returns NULL**. :param call: the function call @@ -399,7 +401,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckCallNullMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, call the error handler, **and then returns void**. :param call: the function call @@ -429,7 +431,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, #define SUNCheckCallVoid(call) SUNCheckCallVoidMsg(call, NULL) /* SUNCheckLastErrMsg checks the last_err value in the SUNContext. - If an error occured, then it will log the error, set the last_err + If an error occurred, then it will log the error, set the last_err value, and call the error handler, **and then returns the code**. */ #if defined(SUNDIALS_ENABLE_ERROR_CHECKS) #define SUNCheckLastErrMsg(msg) \ @@ -440,7 +442,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckLastErrNoRetMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, call the error handler. **It does not return.** :param msg: an error message @@ -453,7 +455,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckLastErrNullMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, call the error handler, **and then returns NULL**. :param msg: an error message @@ -466,7 +468,7 @@ static inline void SUNHandleErrWithFmtMsg(int line, const char* func, /* SUNCheckLastErrVoidMsg performs the SUNDIALS function call, and checks the - returned error code. If an error occured, then it will log the error, set the + returned error code. If an error occurred, then it will log the error, set the last_err value, call the error handler, **and then returns void**. :param msg: an error message diff --git a/inst/include/sundials/sundials_adaptcontroller.h b/inst/include/sundials/sundials_adaptcontroller.h index b27d7c7..4d5c9bf 100644 --- a/inst/include/sundials/sundials_adaptcontroller.h +++ b/inst/include/sundials/sundials_adaptcontroller.h @@ -31,16 +31,17 @@ extern "C" { #endif /* ----------------------------------------------------------------- - * SUNAdaptController types (currently, only "H" is implemented; - * others are planned): + * SUNAdaptController types: * NONE - empty controller (does nothing) * H - controls a single-rate step size + * MRI_H_TOL - controls slow step and fast relative tolerances * ----------------------------------------------------------------- */ typedef enum { SUN_ADAPTCONTROLLER_NONE, - SUN_ADAPTCONTROLLER_H + SUN_ADAPTCONTROLLER_H, + SUN_ADAPTCONTROLLER_MRI_H_TOL } SUNAdaptController_Type; /* ----------------------------------------------------------------- @@ -63,6 +64,12 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*estimatestep)(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); + /* REQUIRED for controllers of SUN_ADAPTCONTROLLER_MRI_H_TOL type. */ + SUNErrCode (*estimatesteptol)(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* tolfacnew); + /* OPTIONAL for all SUNAdaptController implementations. */ SUNErrCode (*destroy)(SUNAdaptController C); SUNErrCode (*reset)(SUNAdaptController C); @@ -70,6 +77,9 @@ struct _generic_SUNAdaptController_Ops SUNErrCode (*write)(SUNAdaptController C, FILE* fptr); SUNErrCode (*seterrorbias)(SUNAdaptController C, sunrealtype bias); SUNErrCode (*updateh)(SUNAdaptController C, sunrealtype h, sunrealtype dsm); + SUNErrCode (*updatemrihtol)(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); SUNErrCode (*space)(SUNAdaptController C, long int* lenrw, long int* leniw); }; @@ -118,6 +128,20 @@ SUNErrCode SUNAdaptController_EstimateStep(SUNAdaptController C, sunrealtype h, int p, sunrealtype dsm, sunrealtype* hnew); +/* Combined slow step/fast tolerance multirate controller function. + This is called following a slow multirate time step with size 'H' + and fast/slow relative tolerance ratio 'tolfac', and error factors + 'DSM' and 'dsm' (slow and fast, resp.). The controller should + estimate slow stepsize 'Hnew' and updated relative tolerance ratio + 'tolfacnew', so that the ensuing step will have 'DSM' and 'dsm' + values JUST BELOW 1 with minimal computational effort. */ +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_EstimateStepTol(SUNAdaptController C, + sunrealtype H, sunrealtype tolfac, + int P, sunrealtype DSM, + sunrealtype dsm, sunrealtype* Hnew, + sunrealtype* tolfacnew); + /* Function to reset the controller to its initial state, e.g., if it stores a small number of previous dsm or step size values. */ SUNDIALS_EXPORT @@ -145,6 +169,15 @@ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_UpdateH(SUNAdaptController C, sunrealtype h, sunrealtype dsm); +/* Function to notify the controller of a successful multirate time step + with size H and fast tolerance factor tolfac, and local error factors + DSM and dsm, indicating that the step size, tolerance factor, or local + error factors can be saved for subsequent controller functions. */ +SUNDIALS_EXPORT +SUNErrCode SUNAdaptController_UpdateMRIHTol(SUNAdaptController C, sunrealtype H, + sunrealtype tolfac, sunrealtype DSM, + sunrealtype dsm); + /* Function to return the memory requirements of the controller object. */ SUNDIALS_EXPORT SUNErrCode SUNAdaptController_Space(SUNAdaptController C, long int* lenrw, diff --git a/inst/include/sundials/sundials_base.hpp b/inst/include/sundials/sundials_base.hpp index 9a43da9..cc6cc1b 100644 --- a/inst/include/sundials/sundials_base.hpp +++ b/inst/include/sundials/sundials_base.hpp @@ -90,7 +90,7 @@ class BaseObject return *this; } - // We have a pure virtual destructor to make this an asbtract class + // We have a pure virtual destructor to make this an abstract class virtual ~BaseObject() = 0; // Getters diff --git a/inst/include/sundials/sundials_config.h b/inst/include/sundials/sundials_config.h index 44da57b..d6c66fa 100644 --- a/inst/include/sundials/sundials_config.h +++ b/inst/include/sundials/sundials_config.h @@ -44,10 +44,10 @@ * -----------------------------------------------------------------*/ -#define SUNDIALS_VERSION "7.1.1" +#define SUNDIALS_VERSION "7.2.0" #define SUNDIALS_VERSION_MAJOR 7 -#define SUNDIALS_VERSION_MINOR 1 -#define SUNDIALS_VERSION_PATCH 1 +#define SUNDIALS_VERSION_MINOR 2 +#define SUNDIALS_VERSION_PATCH 0 #define SUNDIALS_VERSION_LABEL "" #define SUNDIALS_GIT_VERSION "" @@ -119,8 +119,8 @@ #define SUN_BUILD_TYPE "Release" -#define SUN_JOB_ID "20241214113940" -#define SUN_JOB_START_TIME "20241214113940" +#define SUN_JOB_ID "20241214164049" +#define SUN_JOB_START_TIME "20241214164049" #define SUN_TPL_LIST "" #define SUN_TPL_LIST_SIZE "" @@ -144,6 +144,9 @@ /* HYPRE */ /* #undef SUNDIALS_HYPRE_ENABLED */ #define SUN_HYPRE_VERSION "" +#define SUN_HYPRE_VERSION_MAJOR +#define SUN_HYPRE_VERSION_MINOR +#define SUN_HYPRE_VERSION_PATCH /* KLU */ /* #undef SUNDIALS_KLU_ENABLED */ @@ -239,7 +242,7 @@ /* #undef SUNDIALS_ONEMKL_USE_GETRS_LOOP */ /* SUPERLUMT threading type */ -#define SUNDIALS_SUPERLUMT_THREAD_TYPE "" +#define SUNDIALS_SUPERLUMT_THREAD_TYPE "PTHREAD" /* Trilinos with MPI is available, then * #define SUNDIALS_TRILINOS_HAVE_MPI diff --git a/inst/include/sundials/sundials_convertibleto.hpp b/inst/include/sundials/sundials_convertibleto.hpp index 7443ed4..4afe7bf 100644 --- a/inst/include/sundials/sundials_convertibleto.hpp +++ b/inst/include/sundials/sundials_convertibleto.hpp @@ -11,7 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------------------- - * Base class for converting C++ wappers (views) to SUNDIALS objects + * Base class for converting C++ wrappers (views) to SUNDIALS objects * ---------------------------------------------------------------------------*/ #ifndef _SUNDIALS_CONVERTIBLETO_HPP diff --git a/inst/include/sundials/sundials_errors.h b/inst/include/sundials/sundials_errors.h index b132b0f..3aefc0e 100644 --- a/inst/include/sundials/sundials_errors.h +++ b/inst/include/sundials/sundials_errors.h @@ -64,7 +64,7 @@ ENTRY(SUN_ERR_UNREACHABLE, \ "Reached code that should be unreachable: open an issue at: " \ "https://github.com/LLNL/sundials") \ - ENTRY(SUN_ERR_UNKNOWN, "Unknown error occured: open an issue at " \ + ENTRY(SUN_ERR_UNKNOWN, "Unknown error occurred: open an issue at " \ "https://github.com/LLNL/sundials") /* Expand SUN_ERR_CODE_LIST to enum */ diff --git a/inst/include/sundials/sundials_math.h b/inst/include/sundials/sundials_math.h index 4585c7c..b12798c 100644 --- a/inst/include/sundials/sundials_math.h +++ b/inst/include/sundials/sundials_math.h @@ -46,6 +46,8 @@ extern "C" { * SUNRexp calls the appropriate version of exp * * SUNRceil calls the appropriate version of ceil + * + * SUNRround calls the appropriate version of round * ----------------------------------------------------------------- */ @@ -158,6 +160,44 @@ extern "C" { #endif #endif +/* + * ----------------------------------------------------------------- + * Function : SUNRround + * ----------------------------------------------------------------- + * Usage : sunrealtype round_x; + * round_x = SUNRround(x); + * ----------------------------------------------------------------- + * SUNRround(x) returns the smallest integer value not less than x. + * ----------------------------------------------------------------- + */ + +#ifndef SUNRround +#if defined(SUNDIALS_DOUBLE_PRECISION) +#define SUNRround(x) (round((x))) +#elif defined(SUNDIALS_SINGLE_PRECISION) +#define SUNRround(x) (roundf((x))) +#elif defined(SUNDIALS_EXTENDED_PRECISION) +#define SUNRround(x) (roundl((x))) +#else +#error \ + "SUNDIALS precision not defined, report to github.com/LLNL/sundials/issues" +#endif +#endif + +/* + * ----------------------------------------------------------------- + * Function : SUNIpowerI + * ----------------------------------------------------------------- + * Usage : int exponent, base, ans; + * ans = SUNIpowerI(base,exponent); + * ----------------------------------------------------------------- + * SUNIpowerI returns the value of base^exponent, where base and + * exponent are of type int and exponent is nonnegative. + * ----------------------------------------------------------------- + */ + +SUNDIALS_EXPORT int SUNIpowerI(int base, int exponent); + /* * ----------------------------------------------------------------- * Function : SUNRpowerI diff --git a/inst/include/sundials/sundials_memory.h b/inst/include/sundials/sundials_memory.h index b2ac7c6..53b01f6 100644 --- a/inst/include/sundials/sundials_memory.h +++ b/inst/include/sundials/sundials_memory.h @@ -28,14 +28,14 @@ extern "C" { typedef enum { SUNMEMTYPE_HOST, /* pageable memory accessible on the host */ - SUNMEMTYPE_PINNED, /* page-locked memory accesible on the host */ + SUNMEMTYPE_PINNED, /* page-locked memory accessible on the host */ SUNMEMTYPE_DEVICE, /* memory accessible from the device */ SUNMEMTYPE_UVM /* memory accessible from the host or device */ } SUNMemoryType; /* * SUNMemory is a simple abstraction of a pointer to some - * contiguos memory, so that we can keep track of its type + * contiguous memory, so that we can keep track of its type * and its ownership. */ diff --git a/inst/include/sundials/sundials_nvector.h b/inst/include/sundials/sundials_nvector.h index 68ea934..1af6aef 100644 --- a/inst/include/sundials/sundials_nvector.h +++ b/inst/include/sundials/sundials_nvector.h @@ -140,7 +140,7 @@ struct _generic_N_Vector_Ops /* * OPTIONAL operations. * - * These operations provide default implementations that may be overriden. + * These operations provide default implementations that may be overridden. */ /* OPTIONAL fused vector operations */ diff --git a/inst/include/sundials/sundials_stepper.h b/inst/include/sundials/sundials_stepper.h new file mode 100644 index 0000000..8a356df --- /dev/null +++ b/inst/include/sundials/sundials_stepper.h @@ -0,0 +1,139 @@ +/* ----------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2024, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -----------------------------------------------------------------*/ + +#ifndef _SUNDIALS_STEPPER_H +#define _SUNDIALS_STEPPER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + SUN_FULLRHS_START, + SUN_FULLRHS_END, + SUN_FULLRHS_OTHER +} SUNFullRhsMode; + +typedef int (*SUNRhsJacFn)(sunrealtype t, N_Vector y, N_Vector fy, + SUNMatrix Jac, void* user_data, N_Vector tmp1, + N_Vector tmp2, N_Vector tmp3); + +typedef int (*SUNRhsJacTimesFn)(N_Vector v, N_Vector Jv, sunrealtype t, + N_Vector y, N_Vector fy, void* user_data, + N_Vector tmp); + +typedef _SUNDIALS_STRUCT_ SUNStepper_* SUNStepper; + +typedef SUNErrCode (*SUNStepperEvolveFn)(SUNStepper stepper, sunrealtype tout, + N_Vector vret, sunrealtype* tret); + +typedef SUNErrCode (*SUNStepperOneStepFn)(SUNStepper stepper, sunrealtype tout, + N_Vector vret, sunrealtype* tret); + +typedef SUNErrCode (*SUNStepperFullRhsFn)(SUNStepper stepper, sunrealtype t, + N_Vector v, N_Vector f, + SUNFullRhsMode mode); + +typedef SUNErrCode (*SUNStepperResetFn)(SUNStepper stepper, sunrealtype tR, + N_Vector vR); + +typedef SUNErrCode (*SUNStepperSetStopTimeFn)(SUNStepper stepper, + sunrealtype tstop); + +typedef SUNErrCode (*SUNStepperSetStepDirectionFn)(SUNStepper stepper, + sunrealtype stepdir); + +typedef SUNErrCode (*SUNStepperSetForcingFn)(SUNStepper stepper, + sunrealtype tshift, + sunrealtype tscale, + N_Vector* forcing, int nforcing); + +typedef SUNErrCode (*SUNStepperDestroyFn)(SUNStepper stepper); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_Create(SUNContext sunctx, SUNStepper* stepper); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_Destroy(SUNStepper* stepper); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_Evolve(SUNStepper stepper, sunrealtype tout, + N_Vector vret, sunrealtype* tret); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_OneStep(SUNStepper stepper, sunrealtype tout, + N_Vector vret, sunrealtype* tret); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_FullRhs(SUNStepper stepper, sunrealtype t, N_Vector v, + N_Vector f, SUNFullRhsMode mode); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_Reset(SUNStepper stepper, sunrealtype tR, N_Vector vR); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetStopTime(SUNStepper stepper, sunrealtype tstop); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetStepDirection(SUNStepper stepper, sunrealtype stepdir); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetForcing(SUNStepper stepper, sunrealtype tshift, + sunrealtype tscale, N_Vector* forcing, + int nforcing); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetContent(SUNStepper stepper, void* content); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_GetContent(SUNStepper stepper, void** content); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetLastFlag(SUNStepper stepper, int last_flag); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_GetLastFlag(SUNStepper stepper, int* last_flag); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetEvolveFn(SUNStepper stepper, SUNStepperEvolveFn fn); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetOneStepFn(SUNStepper stepper, SUNStepperOneStepFn fn); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetFullRhsFn(SUNStepper stepper, SUNStepperFullRhsFn fn); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetResetFn(SUNStepper stepper, SUNStepperResetFn fn); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetStopTimeFn(SUNStepper stepper, + SUNStepperSetStopTimeFn fn); + +SUNDIALS_EXPORT +SUNErrCode SUNStepper_SetStepDirectionFn(SUNStepper stepper, + SUNStepperSetStepDirectionFn fn); + +SUNDIALS_EXPORT SUNErrCode SUNStepper_SetForcingFn(SUNStepper stepper, + SUNStepperSetForcingFn fn); + +SUNDIALS_EXPORT SUNErrCode SUNStepper_SetDestroyFn(SUNStepper stepper, + SUNStepperDestroyFn fn); + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNDIALS_STEPPER_H */ diff --git a/inst/include/sunnonlinsol/sunnonlinsol_fixedpoint.h b/inst/include/sunnonlinsol/sunnonlinsol_fixedpoint.h index 779538a..cb368d4 100644 --- a/inst/include/sunnonlinsol/sunnonlinsol_fixedpoint.h +++ b/inst/include/sunnonlinsol/sunnonlinsol_fixedpoint.h @@ -44,7 +44,7 @@ struct _SUNNonlinearSolverContent_FixedPoint int m; /* number of acceleration vectors to use */ int* imap; /* array of length m */ sunbooleantype damping; /* flag to apply dampling in acceleration */ - sunrealtype beta; /* damping paramter */ + sunrealtype beta; /* damping parameter */ sunrealtype* R; /* array of length m*m */ sunrealtype* gamma; /* array of length m */ sunrealtype* cvals; /* array of length m+1 for fused vector op */ diff --git a/src/scripts/sundials_download.sh b/src/scripts/sundials_download.sh index 24a100b..834aca8 100755 --- a/src/scripts/sundials_download.sh +++ b/src/scripts/sundials_download.sh @@ -3,6 +3,6 @@ RSCRIPT_BIN=$1 ## Uncompress sundials source -${RSCRIPT_BIN} -e "download.file(url = 'https://github.com/LLNL/sundials/releases/download/v7.1.1/sundials-7.1.1.tar.gz', destfile = 'sundials-7.1.1.tar.gz')" -${RSCRIPT_BIN} -e "utils::untar(tarfile = 'sundials-7.1.1.tar.gz')" -mv sundials-7.1.1 sundials-src +${RSCRIPT_BIN} -e "download.file(url = 'https://github.com/LLNL/sundials/releases/download/v7.2.0/sundials-7.2.0.tar.gz', destfile = 'sundials-7.2.0.tar.gz')" +${RSCRIPT_BIN} -e "utils::untar(tarfile = 'sundials-7.2.0.tar.gz')" +mv sundials-7.2.0 sundials-src