diff --git a/CHANGELOG.md b/CHANGELOG.md index b67f12cad8..13b4a1b3f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,18 @@ estimate over multiple time steps. See the routines `ARKStepSetAccumulatedError `ERKStepSetAccumulatedErrorType`, `ERKStepResetAccumulatedError`, and `ERKStepGetAccumulatedError` for details. +Created shared user interface for ARKODE user-callable routines, to allow more +uniform control over time-stepping algorithms, improved extensibility, and +simplified code maintenance. Marked the corresponding stepper-specific +user-callable routines as deprecated; these will be removed in a future major +release. + +Added "Resize" capability, as well as missing `SetRootDirection` and +`SetNoInactiveRootWarn` functions, to ARKODE's SPRKStep time-stepping module. + +Deprecated `ARKStepSetOptimalParams` function; added instructions to user guide +for users who wish to retain the current functionality. + Updated the CMake variable `HIP_PLATFORM` default to `amd` as the previous default, `hcc`, is no longer recognized in ROCm 5.7.0 or newer. The new default is also valid in older version of ROCm (at least back to version 4.3.1). @@ -37,6 +49,10 @@ Added support for Kokkos Kernels v4. Fixed a bug that caused error messages to be cut off in some cases. Fixes [GitHub Issue #461](https://github.com/LLNL/sundials/issues/461). +Fixed a memory leak when an error handler was added to a `SUNContext`. Fixes [GitHub Issue #466](https://github.com/LLNL/sundials/issues/466). + +Fixed a CMake bug that caused an MPI linking error for our C++ examples in some instances. Fixes [GitHub Issue #464](https://github.com/LLNL/sundials/issues/464). + ## Changes to SUNDIALS in release v7.0.0 ### Major Feature diff --git a/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp b/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp index 0acdc8625e..49dcc6d8cf 100644 --- a/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp +++ b/benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp @@ -71,26 +71,20 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Select the method order */ - retval = ARKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ARKStepSetOrder", 1, udata->myid)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1, udata->myid)) { return 1; } /* Attach user data */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData*", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData*", 1, udata->myid)) { return 1; } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ARKStepSStolerances", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1, udata->myid)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1, udata->myid)) + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1, udata->myid)) { return 1; } @@ -106,8 +100,8 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -121,15 +115,15 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach linear solver */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1, udata->myid)) + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1, udata->myid)) { return 1; } /* Attach preconditioner */ - retval = ARKStepSetPreconditioner(arkode_mem, NULL, PSolve); - if (check_retval(&retval, "ARKStepSetPreconditioner", 1, udata->myid)) + retval = ARKodeSetPreconditioner(arkode_mem, NULL, PSolve); + if (check_retval(&retval, "ARKodeSetPreconditioner", 1, udata->myid)) { return 1; } @@ -144,8 +138,8 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -177,8 +171,8 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) do { /* Integrate to output time */ - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1, udata->myid)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1, udata->myid)) { break; } /* Output state */ if (uopt->nout > 0) { WriteOutput(t, y, udata, uopt); } @@ -192,24 +186,24 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) while (iout < uopt->nout); /* Get final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1, udata->myid); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1, udata->myid); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1, udata->myid); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1, udata->myid); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1, udata->myid); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncnf); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1, udata->myid); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncnf); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1, udata->myid); if (uopt->nls == "newton") { - retval = ARKStepGetNumLinIters(arkode_mem, &nli); - check_retval(&retval, "ARKStepGetNumLinIters", 1, udata->myid); - retval = ARKStepGetNumPrecSolves(arkode_mem, &npsol); - check_retval(&retval, "ARKStepGetNumPrecSolves", 1, udata->myid); + retval = ARKodeGetNumLinIters(arkode_mem, &nli); + check_retval(&retval, "ARKodeGetNumLinIters", 1, udata->myid); + retval = ARKodeGetNumPrecSolves(arkode_mem, &npsol); + check_retval(&retval, "ARKodeGetNumPrecSolves", 1, udata->myid); } /* Print final statistics */ @@ -230,7 +224,7 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Clean up */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNNonlinSolFree(NLS); if (LS) { SUNLinSolFree(LS); } @@ -265,26 +259,20 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Select the method order */ - retval = ARKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ARKStepSetOrder", 1, udata->myid)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1, udata->myid)) { return 1; } /* Attach user data */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData*", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData*", 1, udata->myid)) { return 1; } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ARKStepSStolerances", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1, udata->myid)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1, udata->myid)) + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1, udata->myid)) { return 1; } @@ -300,8 +288,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -314,15 +302,15 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach linear solver */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1, udata->myid)) + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1, udata->myid)) { return 1; } /* Attach preconditioner */ - retval = ARKStepSetPreconditioner(arkode_mem, NULL, PSolve); - if (check_retval(&retval, "ARKStepSetPreconditioner", 1, udata->myid)) + retval = ARKodeSetPreconditioner(arkode_mem, NULL, PSolve); + if (check_retval(&retval, "ARKodeSetPreconditioner", 1, udata->myid)) { return 1; } @@ -338,8 +326,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -354,8 +342,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -387,8 +375,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) do { /* Integrate to output time */ - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1, udata->myid)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1, udata->myid)) { break; } /* Output state */ if (uopt->nout > 0) { WriteOutput(t, y, udata, uopt); } @@ -402,24 +390,24 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) while (iout < uopt->nout); /* Get final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1, udata->myid); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1, udata->myid); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1, udata->myid); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1, udata->myid); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1, udata->myid); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncnf); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1, udata->myid); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncnf); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1, udata->myid); if (uopt->nls == "newton") { - retval = ARKStepGetNumLinIters(arkode_mem, &nli); - check_retval(&retval, "ARKStepGetNumLinIters", 1, udata->myid); - retval = ARKStepGetNumPrecSolves(arkode_mem, &npsol); - check_retval(&retval, "ARKStepGetNumPrecSolves", 1, udata->myid); + retval = ARKodeGetNumLinIters(arkode_mem, &nli); + check_retval(&retval, "ARKodeGetNumLinIters", 1, udata->myid); + retval = ARKodeGetNumPrecSolves(arkode_mem, &npsol); + check_retval(&retval, "ARKodeGetNumPrecSolves", 1, udata->myid); } /* Print final statistics */ @@ -440,7 +428,7 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Clean up */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); if (NLS) { SUNNonlinSolFree(NLS); } if (LS) { SUNLinSolFree(LS); } @@ -470,33 +458,27 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) } /* Select the method order */ - retval = ERKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ERKStepSetOrder", 1, udata->myid)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1, udata->myid)) { return 1; } /* Attach user data */ - retval = ERKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ERKStepSetUserData", 1, udata->myid)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1, udata->myid)) { return 1; } /* Specify tolerances */ - retval = ERKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ERKStepSStolerances", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1, udata->myid)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1, udata->myid)) + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1, udata->myid)) { return 1; } /* Set fixed step size */ - retval = ERKStepSetFixedStep(arkode_mem, 1e-5); - if (check_retval(&retval, "ERKStepSetFixedStep", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSetFixedStep(arkode_mem, 1e-5); + if (check_retval(&retval, "ARKodeSetFixedStep", 1, udata->myid)) { return 1; } /* Output initial condition */ if (uopt->nout > 0) @@ -518,8 +500,8 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) do { /* Integrate to output time */ - retval = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1, udata->myid)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1, udata->myid)) { break; } /* Output state */ if (uopt->nout > 0) { WriteOutput(t, y, udata, uopt); } @@ -533,14 +515,14 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) while (iout < uopt->nout); /* Get final statistics */ - retval = ERKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ERKStepGetNumSteps", 1, udata->myid); - retval = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ERKStepGetNumStepAttempts", 1, udata->myid); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1, udata->myid); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1, udata->myid); retval = ERKStepGetNumRhsEvals(arkode_mem, &nfe); check_retval(&retval, "ERKStepGetNumRhsEvals", 1, udata->myid); - retval = ERKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ERKStepGetNumErrTestFails", 1, udata->myid); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1, udata->myid); /* Print final statistics */ if (udata->myid == 0) @@ -552,7 +534,7 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) } /* Clean up */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* Return success */ return (0); @@ -575,8 +557,8 @@ int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) sunrealtype tcur, gamma; void* user_data; - ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, - &sdata, &user_data); + ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, + &sdata, &user_data); udata = (UserData*)user_data; /* update 'z' value as stored predictor + current corrector */ @@ -615,8 +597,8 @@ int TaskLocalLSolve(N_Vector delta, void* arkode_mem) sunrealtype tcur, gamma; void* user_data = NULL; - ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, - &sdata, &user_data); + ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, + &sdata, &user_data); udata = (UserData*)user_data; SUNDIALS_CXX_MARK_FUNCTION(udata->prof); diff --git a/benchmarks/advection_reaction_3D/raja/arkode_driver.cpp b/benchmarks/advection_reaction_3D/raja/arkode_driver.cpp index 0acdc8625e..49dcc6d8cf 100644 --- a/benchmarks/advection_reaction_3D/raja/arkode_driver.cpp +++ b/benchmarks/advection_reaction_3D/raja/arkode_driver.cpp @@ -71,26 +71,20 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Select the method order */ - retval = ARKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ARKStepSetOrder", 1, udata->myid)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1, udata->myid)) { return 1; } /* Attach user data */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData*", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData*", 1, udata->myid)) { return 1; } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ARKStepSStolerances", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1, udata->myid)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1, udata->myid)) + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1, udata->myid)) { return 1; } @@ -106,8 +100,8 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -121,15 +115,15 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach linear solver */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1, udata->myid)) + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1, udata->myid)) { return 1; } /* Attach preconditioner */ - retval = ARKStepSetPreconditioner(arkode_mem, NULL, PSolve); - if (check_retval(&retval, "ARKStepSetPreconditioner", 1, udata->myid)) + retval = ARKodeSetPreconditioner(arkode_mem, NULL, PSolve); + if (check_retval(&retval, "ARKodeSetPreconditioner", 1, udata->myid)) { return 1; } @@ -144,8 +138,8 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -177,8 +171,8 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) do { /* Integrate to output time */ - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1, udata->myid)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1, udata->myid)) { break; } /* Output state */ if (uopt->nout > 0) { WriteOutput(t, y, udata, uopt); } @@ -192,24 +186,24 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) while (iout < uopt->nout); /* Get final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1, udata->myid); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1, udata->myid); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1, udata->myid); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1, udata->myid); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1, udata->myid); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncnf); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1, udata->myid); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncnf); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1, udata->myid); if (uopt->nls == "newton") { - retval = ARKStepGetNumLinIters(arkode_mem, &nli); - check_retval(&retval, "ARKStepGetNumLinIters", 1, udata->myid); - retval = ARKStepGetNumPrecSolves(arkode_mem, &npsol); - check_retval(&retval, "ARKStepGetNumPrecSolves", 1, udata->myid); + retval = ARKodeGetNumLinIters(arkode_mem, &nli); + check_retval(&retval, "ARKodeGetNumLinIters", 1, udata->myid); + retval = ARKodeGetNumPrecSolves(arkode_mem, &npsol); + check_retval(&retval, "ARKodeGetNumPrecSolves", 1, udata->myid); } /* Print final statistics */ @@ -230,7 +224,7 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt) } /* Clean up */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNNonlinSolFree(NLS); if (LS) { SUNLinSolFree(LS); } @@ -265,26 +259,20 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Select the method order */ - retval = ARKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ARKStepSetOrder", 1, udata->myid)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1, udata->myid)) { return 1; } /* Attach user data */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData*", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData*", 1, udata->myid)) { return 1; } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ARKStepSStolerances", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1, udata->myid)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1, udata->myid)) + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1, udata->myid)) { return 1; } @@ -300,8 +288,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -314,15 +302,15 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach linear solver */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1, udata->myid)) + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1, udata->myid)) { return 1; } /* Attach preconditioner */ - retval = ARKStepSetPreconditioner(arkode_mem, NULL, PSolve); - if (check_retval(&retval, "ARKStepSetPreconditioner", 1, udata->myid)) + retval = ARKodeSetPreconditioner(arkode_mem, NULL, PSolve); + if (check_retval(&retval, "ARKodeSetPreconditioner", 1, udata->myid)) { return 1; } @@ -338,8 +326,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -354,8 +342,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1, udata->myid)) + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1, udata->myid)) { return 1; } @@ -387,8 +375,8 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) do { /* Integrate to output time */ - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1, udata->myid)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1, udata->myid)) { break; } /* Output state */ if (uopt->nout > 0) { WriteOutput(t, y, udata, uopt); } @@ -402,24 +390,24 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) while (iout < uopt->nout); /* Get final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1, udata->myid); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1, udata->myid); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1, udata->myid); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1, udata->myid); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1, udata->myid); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1, udata->myid); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncnf); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1, udata->myid); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1, udata->myid); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncnf); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1, udata->myid); if (uopt->nls == "newton") { - retval = ARKStepGetNumLinIters(arkode_mem, &nli); - check_retval(&retval, "ARKStepGetNumLinIters", 1, udata->myid); - retval = ARKStepGetNumPrecSolves(arkode_mem, &npsol); - check_retval(&retval, "ARKStepGetNumPrecSolves", 1, udata->myid); + retval = ARKodeGetNumLinIters(arkode_mem, &nli); + check_retval(&retval, "ARKodeGetNumLinIters", 1, udata->myid); + retval = ARKodeGetNumPrecSolves(arkode_mem, &npsol); + check_retval(&retval, "ARKodeGetNumPrecSolves", 1, udata->myid); } /* Print final statistics */ @@ -440,7 +428,7 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt) } /* Clean up */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); if (NLS) { SUNNonlinSolFree(NLS); } if (LS) { SUNLinSolFree(LS); } @@ -470,33 +458,27 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) } /* Select the method order */ - retval = ERKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ERKStepSetOrder", 1, udata->myid)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1, udata->myid)) { return 1; } /* Attach user data */ - retval = ERKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ERKStepSetUserData", 1, udata->myid)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1, udata->myid)) { return 1; } /* Specify tolerances */ - retval = ERKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ERKStepSStolerances", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1, udata->myid)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1, udata->myid)) + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1, udata->myid)) { return 1; } /* Set fixed step size */ - retval = ERKStepSetFixedStep(arkode_mem, 1e-5); - if (check_retval(&retval, "ERKStepSetFixedStep", 1, udata->myid)) - { - return 1; - } + retval = ARKodeSetFixedStep(arkode_mem, 1e-5); + if (check_retval(&retval, "ARKodeSetFixedStep", 1, udata->myid)) { return 1; } /* Output initial condition */ if (uopt->nout > 0) @@ -518,8 +500,8 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) do { /* Integrate to output time */ - retval = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1, udata->myid)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1, udata->myid)) { break; } /* Output state */ if (uopt->nout > 0) { WriteOutput(t, y, udata, uopt); } @@ -533,14 +515,14 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) while (iout < uopt->nout); /* Get final statistics */ - retval = ERKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ERKStepGetNumSteps", 1, udata->myid); - retval = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ERKStepGetNumStepAttempts", 1, udata->myid); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1, udata->myid); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1, udata->myid); retval = ERKStepGetNumRhsEvals(arkode_mem, &nfe); check_retval(&retval, "ERKStepGetNumRhsEvals", 1, udata->myid); - retval = ERKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ERKStepGetNumErrTestFails", 1, udata->myid); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1, udata->myid); /* Print final statistics */ if (udata->myid == 0) @@ -552,7 +534,7 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt) } /* Clean up */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* Return success */ return (0); @@ -575,8 +557,8 @@ int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) sunrealtype tcur, gamma; void* user_data; - ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, - &sdata, &user_data); + ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, + &sdata, &user_data); udata = (UserData*)user_data; /* update 'z' value as stored predictor + current corrector */ @@ -615,8 +597,8 @@ int TaskLocalLSolve(N_Vector delta, void* arkode_mem) sunrealtype tcur, gamma; void* user_data = NULL; - ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, - &sdata, &user_data); + ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, &gamma, + &sdata, &user_data); udata = (UserData*)user_data; SUNDIALS_CXX_MARK_FUNCTION(udata->prof); diff --git a/benchmarks/diffusion_2D/main_arkode.cpp b/benchmarks/diffusion_2D/main_arkode.cpp index e3f8962ad8..c35bf9e9c7 100644 --- a/benchmarks/diffusion_2D/main_arkode.cpp +++ b/benchmarks/diffusion_2D/main_arkode.cpp @@ -245,49 +245,49 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, uopts.rtol, uopts.atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, uopts.rtol, uopts.atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)&udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } #if defined(USE_SUPERLU_DIST) if (uopts.ls == "sludist") { - ARKStepSetJacFn(arkode_mem, diffusion_jac); - if (check_flag(&flag, "ARKStepSetJacFn", 1)) return 1; + ARKodeSetJacFn(arkode_mem, diffusion_jac); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) return 1; } #endif if (uopts.preconditioning) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, uopts.msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, uopts.msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, uopts.epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, uopts.epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order - flag = ARKStepSetOrder(arkode_mem, uopts.order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, uopts.order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } // Set fixed step size or adaptivity method if (uopts.hfixed > ZERO) { - flag = ARKStepSetFixedStep(arkode_mem, uopts.hfixed); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, uopts.hfixed); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -299,17 +299,17 @@ int main(int argc, char* argv[]) // Specify linearly implicit non-time-dependent RHS if (uopts.linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(arkode_mem, uopts.maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, uopts.maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(arkode_mem, udata.tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata.tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -341,8 +341,8 @@ int main(int argc, char* argv[]) SUNDIALS_MARK_BEGIN(prof, "Evolve"); // Evolve in time - flag = ARKStepEvolve(arkode_mem, tout, u, &t, stepmode); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, stepmode); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } SUNDIALS_MARK_END(prof, "Evolve"); @@ -367,8 +367,8 @@ int main(int argc, char* argv[]) if (outproc) { cout << "Final integrator statistics:" << endl; - flag = ARKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); - if (check_flag(&flag, "ARKStepPrintAllStats", 1)) { return 1; } + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + if (check_flag(&flag, "ARKodePrintAllStats", 1)) { return 1; } } // --------- @@ -378,7 +378,7 @@ int main(int argc, char* argv[]) // Free MPI Cartesian communicator MPI_Comm_free(&(udata.comm_c)); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); // Free the SuperLU_DIST structures (also frees user allocated arrays diff --git a/doc/arkode/guide/source/Constants.rst b/doc/arkode/guide/source/Constants.rst index 06dd31d9da..daa4e9a82e 100644 --- a/doc/arkode/guide/source/Constants.rst +++ b/doc/arkode/guide/source/Constants.rst @@ -480,6 +480,9 @@ contains the ARKODE output constants. +-------------------------------------+------+------------------------------------------------------------+ | :index:`ARK_CONTROLLER_ERR` | -47 | An error with a SUNAdaptController object was encountered. | +-------------------------------------+------+------------------------------------------------------------+ + | :index:`ARK_STEPPER_UNSUPPORTED` | -48 | An operation was not supported by the current | + | | | time-stepping module. | + +-------------------------------------+------+------------------------------------------------------------+ | :index:`ARK_UNRECOGNIZED_ERROR` | -99 | An unknown error was encountered. | +-------------------------------------+------+------------------------------------------------------------+ | | diff --git a/doc/arkode/guide/source/Introduction.rst b/doc/arkode/guide/source/Introduction.rst index 6461cbf0d6..a8e4d53d20 100644 --- a/doc/arkode/guide/source/Introduction.rst +++ b/doc/arkode/guide/source/Introduction.rst @@ -153,12 +153,12 @@ The structure of this document is as follows: ARKODE is :ref:`organized `. * The largest section follows, providing a full account of how to use - ARKODE's time-stepping modules, :ref:`ARKStep `, - :ref:`ERKStep `, and :ref:`MRIStep `, - within C and C++ applications. This section then includes additional - information on how to use ARKODE from applications written in - :ref:`Fortran `, as well as information on how to - leverage :ref:`GPU accelerators within ARKODE `. + ARKODE within C and C++ applications, including any instructions that are + specific to a given time-stepping modules, :ref:`ARKStep `, + :ref:`ERKStep `, or :ref:`MRIStep `. + This section then includes additional information on how to use ARKODE from + applications written in :ref:`Fortran `, as well as information + on how to leverage :ref:`GPU accelerators within ARKODE `. * A much smaller section follows, describing ARKODE's :ref:`Butcher table structure `, that is used by diff --git a/doc/arkode/guide/source/Mathematics.rst b/doc/arkode/guide/source/Mathematics.rst index e7ca138464..cff1b5d7bc 100644 --- a/doc/arkode/guide/source/Mathematics.rst +++ b/doc/arkode/guide/source/Mathematics.rst @@ -70,8 +70,8 @@ discussion of our choice of norms for measuring errors within various components of the solver. We then discuss the nonlinear and linear solver strategies used by -ARKODE's time-stepping modules for solving implicit algebraic systems -that arise in computing each stage and/or step: +ARKODE for solving implicit algebraic systems that arise in computing each +stage and/or step: :ref:`nonlinear solvers `, :ref:`linear solvers `, :ref:`preconditioners `, @@ -109,7 +109,7 @@ The choice of step size :math:`h_n` is determined by the time-stepping method (based on user-provided inputs, typically accuracy requirements). However, users may place minimum/maximum bounds on :math:`h_n` if desired. -ARKODE's time stepping modules may be run in a variety of "modes": +ARKODE may be run in a variety of "modes": * **NORMAL** -- The solver will take internal steps until it has just overtaken a user-specified output time, :math:`t_\text{out}`, in the @@ -151,7 +151,7 @@ may be used. Interpolation =============== -As mentioned above, the time-stepping modules in ARKODE support +As mentioned above, the ARKODE supports interpolation of solutions :math:`y(t_\text{out})` and derivatives :math:`y^{(d)}(t_\text{out})`, where :math:`t_\text{out}` occurs within a completed time step from :math:`t_{n-1} \to t_n`. @@ -162,13 +162,12 @@ ARKODE currently supports construction of polynomial interpolants :math:`p_q(t)` of polynomial degree up to :math:`q=5`, although users may select interpolants of lower degree. -ARKODE provides two complementary interpolation approaches, -both of which are accessible from any of the -time-stepping modules: "Hermite" and "Lagrange". The former approach +ARKODE provides two complementary interpolation approaches: +"Hermite" and "Lagrange". The former approach has been included with ARKODE since its inception, and is more -suitable for non-stiff problems; the latter is a new approach that is -designed to provide increased accuracy when integrating stiff problems. -Both are described in detail below. +suitable for non-stiff problems; the latter is a more recent approach +that is designed to provide increased accuracy when integrating stiff +problems. Both are described in detail below. .. _ARKODE.Mathematics.Interpolation.Hermite: @@ -565,7 +564,8 @@ form is used to compute a time step: #. Using compensated summation, set :math:`p_n = p_{n-1} + \Delta p_n, q_n = q_{n-1} + \Delta q_n` Since temporal error based adaptive time-stepping is known to ruin the -conservation property :cite:p:`HaWa:06`, SPRKStep employs a fixed time-step size. +conservation property :cite:p:`HaWa:06`, SPRKStep requires that ARKODE be run +using a fixed time-step size. .. However, it is possible for a user to provide a .. problem-specific adaptivity controller such as the one described in :cite:p:`HaSo:05`. @@ -1014,11 +1014,8 @@ information. In this mode, all internal time step adaptivity is disabled: Fixed-step mode is currently required for the slow time scale in the MRIStep module. -Additional information on this mode is provided in the sections -:ref:`ARKStep Optional Inputs `, -:ref:`ERKStep Optional Inputs `, -:ref:`SPRKStep Optional Inputs `, and -:ref:`MRIStep Optional Inputs `. +Additional information on this mode is provided in the section +:ref:`ARKODE Optional Inputs `. .. _ARKODE.Mathematics.AlgebraicSolvers: @@ -1140,8 +1137,7 @@ Consider, for example, :eq:`ARKODE_Residual_MeqI` which implies :label: ARKODE_Implicit_Stage_Eval when :math:`z_i` is the exact root, and similar relations hold for non-identity -mass matrices. This optimization can be enabled by -:c:func:`ARKStepSetDeduceImplicitRhs` and :c:func:`MRIStepSetDeduceImplicitRhs` +mass matrices. This optimization can be enabled by :c:func:`ARKodeSetDeduceImplicitRhs` with the second argument in either function set to SUNTRUE. Another factor to consider when using this option is the amplification of errors from the nonlinear solver to the stages. In :eq:`ARKODE_Implicit_Stage_Eval`, nonlinear @@ -1948,10 +1944,9 @@ step (but zero linear solves with the system Jacobian). Rootfinding =============== -All of the time-stepping modules in ARKODE also support a rootfinding -feature. This means that, while integrating the IVP :eq:`ARKODE_IVP`, these -can also find the roots of a set of user-defined functions -:math:`g_i(t,y)` that depend on :math:`t` and the solution vector +ARKODE also supports a rootfinding feature, in that while integrating the +IVP :eq:`ARKODE_IVP`, these can also find the roots of a set of user-defined +functions :math:`g_i(t,y)` that depend on :math:`t` and the solution vector :math:`y = y(t)`. The number of these root functions is arbitrary, and if more than one :math:`g_i` is found to have a root in any given interval, the various root locations are found and reported in the @@ -2065,8 +2060,8 @@ factor of 0.9 to cover the strict inequality case). If a step fails to satisfy the constraints 10 times (a value which may be modified by the user) within a step attempt, or fails with the minimum step size, then the integration is halted and an error is returned. In this case the user may need to employ other -strategies as discussed in :numref:`ARKODE.Usage.ARKStep.Tolerances` and -:numref:`ARKODE.Usage.ERKStep.Tolerances` to satisfy the inequality constraints. +strategies as discussed in :numref:`ARKODE.Usage.Tolerances` to satisfy the +inequality constraints. .. _ARKODE.Mathematics.Relaxation: @@ -2130,5 +2125,4 @@ relaxation application and the step will is repeated with the step size reduced by :math:`\eta_\text{rf}`. For more information on utilizing relaxation Runge--Kutta methods, see -:numref:`ARKODE.Usage.ERKStep.Relaxation` and -:numref:`ARKODE.Usage.ARKStep.Relaxation`. +:numref:`ARKODE.Usage.Relaxation`. diff --git a/doc/arkode/guide/source/Organization.rst b/doc/arkode/guide/source/Organization.rst index 8ab599ff2d..204ed9a999 100644 --- a/doc/arkode/guide/source/Organization.rst +++ b/doc/arkode/guide/source/Organization.rst @@ -25,29 +25,29 @@ knowledge of this structure is not necessary for its use. The overall organization of the ARKODE package is shown in :numref:`ARKODE.Organization.ARKODE.Figure`. The central integration modules, implemented in the files ``arkode.h``, ``arkode_impl.h``, ``arkode_butcher.h``, -``arkode.c``, ``arkode_arkstep.c`` , ``arkode_erkstep.c``, ``arkode_mristep.h``, -and ``arkode_butcher.c``, deal with the evaluation of integration stages, the -nonlinear solvers, estimation of the local truncation error, selection of step -size, and interpolation to user output points, among other issues. ARKODE -supports SUNNonlinearSolver modules in either root-finding or fixed-point form -(see section :numref:`SUNNonlinSol`) for any nonlinearly implicit problems that -arise in computing each internal stage. When using Newton-based nonlinear -solvers, or when using a non-identity mass matrix :math:`M\ne I`, ARKODE has -flexibility in the choice of method used to solve the linear sub-systems that -arise. Therefore, for any user problem invoking the Newton solvers, or any user -problem with :math:`M\ne I`, one (or more) of the linear system solver modules -should be specified by the user; this/these are then invoked as needed during -the integration process. +``arkode.c``, ``arkode_arkstep.c`` , ``arkode_erkstep.c``, ``arkode_mristep.c``, +``arkode_sprkstep.c``, and ``arkode_butcher.c``, deal with the evaluation of +integration stages, the nonlinear solvers, estimation of the local truncation +error, selection of step size, and interpolation to user output points, among +other issues. ARKODE supports SUNNonlinearSolver modules in either root-finding +or fixed-point form (see section :numref:`SUNNonlinSol`) for any nonlinearly +implicit problems that arise in computing each internal stage. When using +Newton-based nonlinear solvers, or when using a non-identity mass matrix +:math:`M\ne I`, ARKODE has flexibility in the choice of method used to solve the +linear sub-systems that arise. Therefore, for any user problem invoking the +Newton solvers, or any user problem with :math:`M\ne I`, one (or more) of the +linear system solver modules should be specified by the user; this/these are +then invoked as needed during the integration process. .. _ARKODE.Organization.ARKODE.Figure: .. figure:: /figs/arkode/arkorg.png :align: center *ARKODE organization*: Overall structure of the ARKODE package. - Modules specific to ARKODE are the timesteppers (ARKODE), linear solver - interfaces (ARKLS), nonlinear solver interfaces (ARKNLS), and preconditioners - (ARKBANDPRE and ARKBBDPRE); all other items correspond to generic SUNDIALS - vector, matrix, and solver modules. + Modules specific to ARKODE are the core infrastructure and timesteppers + (ARKODE), linear solver interfaces (ARKLS), nonlinear solver interfaces + (ARKNLS), and preconditioners (ARKBANDPRE and ARKBBDPRE); all other items + correspond to generic SUNDIALS vector, matrix, and solver modules. For solving these linear systems, ARKODE's linear solver interface supports both direct and iterative linear solvers adhering to the diff --git a/doc/arkode/guide/source/Usage/ARKStep_c_interface/Relaxation.rst b/doc/arkode/guide/source/Usage/ARKStep_c_interface/Relaxation.rst index 38e66f0e36..3a2d7611db 100644 --- a/doc/arkode/guide/source/Usage/ARKStep_c_interface/Relaxation.rst +++ b/doc/arkode/guide/source/Usage/ARKStep_c_interface/Relaxation.rst @@ -17,15 +17,12 @@ Relaxation Methods ================== -This section describes user-callable functions for applying relaxation methods -with ARKStep. For more information on relaxation Runge--Kutta methods see -:numref:`ARKODE.Mathematics.Relaxation`. +This section describes ARKStep-specific user-callable functions for applying +relaxation methods with ARKStep. All of these routines have been deprecated in +favor of :ref:`shared ARKODE-level routines `, but +this documentation will be retained for as long as these functions are present +in the library. -.. note:: - - Relaxation support as not been evaluated with non-identity mass matrices. - While this usage mode is supported, feedback from users who explore this - combination would be appreciated. Enabling or Disabling Relaxation -------------------------------- @@ -72,6 +69,11 @@ Enabling or Disabling Relaxation .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxFn` instead. + + Optional Input Functions ------------------------ @@ -96,6 +98,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxEtaFail` instead. + + .. c:function:: int ARKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) Sets the smallest acceptable value for the relaxation parameter. @@ -117,6 +124,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxLowerBound` instead. + + .. c:function:: int ARKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) Sets the largest acceptable value for the relaxation parameter. @@ -138,6 +150,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxUpperBound` instead. + + .. c:function:: int ARKStepSetRelaxMaxFails(void* arkode_mem, int max_fails) Sets the maximum number of times applying relaxation can fail within a step @@ -157,6 +174,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxMaxFails` instead. + + .. c:function:: int ARKStepSetRelaxMaxIters(void* arkode_mem, int max_iters) Sets the maximum number of nonlinear iterations allowed when solving for the @@ -180,6 +202,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxMaxIters` instead. + + .. c:function:: int ARKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) Sets the nonlinear solver method used to compute the relaxation parameter. @@ -198,6 +225,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxSolver` instead. + + .. c:function:: int ARKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) Sets the nonlinear solver residual tolerance to use when solving @@ -223,6 +255,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxResTol` instead. + + .. c:function:: int ARKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) Sets the nonlinear solver relative and absolute tolerance on changes in @@ -249,6 +286,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxTol` instead. + + Optional Output Functions ------------------------- @@ -269,6 +311,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxFnEvals` instead. + + .. c:function:: int ARKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) Get the number of times the user's relaxation Jacobian was evaluated. @@ -283,6 +330,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxJacEvals` instead. + + .. c:function:: int ARKStepGetNumRelaxFails(void* arkode_mem, long int* fails) Get the total number of times applying relaxation failed. @@ -302,6 +354,10 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxFails` instead. + .. c:function:: int ARKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails) @@ -318,6 +374,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxBoundFails` instead. + + .. c:function:: int ARKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails) Get the number of times the relaxation parameter nonlinear solver failed. @@ -332,6 +393,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxSolveFails` instead. + + .. c:function:: int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) Get the number of relaxation parameter nonlinear solver iterations. @@ -345,3 +411,7 @@ about the performance of the relaxation method. ``NULL`` .. versionadded:: 5.6.0 + + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxSolveIters` instead. diff --git a/doc/arkode/guide/source/Usage/ARKStep_c_interface/User_callable.rst b/doc/arkode/guide/source/Usage/ARKStep_c_interface/User_callable.rst index c1057e86f1..2a1e11cde8 100644 --- a/doc/arkode/guide/source/Usage/ARKStep_c_interface/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ARKStep_c_interface/User_callable.rst @@ -17,22 +17,23 @@ ARKStep User-callable functions ================================ -This section describes the functions that are called by the user to -setup and then solve an IVP using the ARKStep time-stepping -module. Some of these are required; however, starting with -:numref:`ARKODE.Usage.ARKStep.OptionalInputs`, the functions listed involve -optional inputs/outputs or restarting, and those paragraphs may be -skipped for a casual use of ARKODE's ARKStep module. In any case, -refer to the preceding section, :numref:`ARKODE.Usage.ARKStep.Skeleton`, -for the correct order of these calls. +This section describes the ARKStep-specific functions that may be called +by the user to setup and then solve an IVP using the ARKStep time-stepping +module. The large majority of these routines merely wrap :ref:`underlying +ARKODE functions `, and are now deprecated +-- each of these are clearly marked. However, some +of these user-callable functions are specific to ARKStep, as explained +below. -On an error, each user-callable function returns a negative value (or -``NULL`` if the function returns a pointer) and sends an error message -to the error handler routine, which prints the message to ``stderr`` -by default. However, the user can set a file as error output or can -provide their own error handler function (see -:numref:`ARKODE.Usage.ARKStep.OptionalInputs` for details). +As discussed in the main :ref:`ARKODE user-callable function introduction +`, each of ARKODE's time-stepping modules +clarifies the categories of user-callable functions that it supports. +ARKStep supports *all categories*: +* temporal adaptivity +* implicit nonlinear and/or linear solvers +* non-identity mass matrices +* relaxation Runge--Kutta methods .. _ARKODE.Usage.ARKStep.Initialization: @@ -73,6 +74,9 @@ ARKStep initialization and deallocation functions **Return value:** None + .. deprecated:: x.y.z + + Use :c:func:`ARKodeFree` instead. .. _ARKODE.Usage.ARKStep.Tolerances: @@ -80,39 +84,6 @@ ARKStep initialization and deallocation functions ARKStep tolerance specification functions ------------------------------------------------------ -These functions specify the integration tolerances. One of them -**should** be called before the first call to -:c:func:`ARKStepEvolve()`; otherwise default values of ``reltol = -1e-4`` and ``abstol = 1e-9`` will be used, which may be entirely -incorrect for a specific problem. - -The integration tolerances ``reltol`` and ``abstol`` define a vector -of error weights, ``ewt``. In the case of -:c:func:`ARKStepSStolerances()`, this vector has components - -.. code-block:: c - - ewt[i] = 1.0/(reltol*abs(y[i]) + abstol); - -whereas in the case of :c:func:`ARKStepSVtolerances()` the vector components -are given by - -.. code-block:: c - - ewt[i] = 1.0/(reltol*abs(y[i]) + abstol[i]); - -This vector is used in all error and convergence tests, which use a -weighted RMS norm on all error-like vectors :math:`v`: - -.. math:: - \|v\|_{WRMS} = \left( \frac{1}{N} \sum_{i=1}^N (v_i\; ewt_i)^2 \right)^{1/2}, - -where :math:`N` is the problem dimension. - -Alternatively, the user may supply a custom function to supply the -``ewt`` vector, through a call to :c:func:`ARKStepWFtolerances()`. - - .. c:function:: int ARKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) @@ -129,6 +100,9 @@ Alternatively, the user may supply a custom function to supply the * *ARK_NO_MALLOC* if the ARKStep memory was not allocated by the time-stepping module * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSStolerances` instead. .. c:function:: int ARKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) @@ -149,6 +123,9 @@ Alternatively, the user may supply a custom function to supply the * *ARK_NO_MALLOC* if the ARKStep memory was not allocated by the time-stepping module * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSVtolerances` instead. .. c:function:: int ARKStepWFtolerances(void* arkode_mem, ARKEwtFn efun) @@ -166,44 +143,9 @@ Alternatively, the user may supply a custom function to supply the * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` * *ARK_NO_MALLOC* if the ARKStep memory was not allocated by the time-stepping module + .. deprecated:: x.y.z - -Moreover, for problems involving a non-identity mass matrix -:math:`M \ne I`, the units of the solution vector :math:`y` may differ -from the units of the IVP, posed for the vector :math:`My`. When this -occurs, iterative solvers for the Newton linear systems and the mass -matrix linear systems may require a different set of tolerances. -Since the relative tolerance is dimensionless, but the absolute -tolerance encodes a measure of what is "small" in the units of the -respective quantity, a user may optionally define absolute tolerances -in the equation units. In this case, ARKStep defines a vector of residual -weights, ``rwt`` for measuring convergence of these iterative solvers. -In the case of :c:func:`ARKStepResStolerance()`, this vector has components - -.. code-block:: c - - rwt[i] = 1.0/(reltol*abs(My[i]) + rabstol); - -whereas in the case of :c:func:`ARKStepResVtolerance()` the vector components -are given by - -.. code-block:: c - - rwt[i] = 1.0/(reltol*abs(My[i]) + rabstol[i]); - -This residual weight vector is used in all iterative solver -convergence tests, which similarly use a weighted RMS norm on all -residual-like vectors :math:`v`: - -.. math:: - \|v\|_{WRMS} = \left( \frac{1}{N} \sum_{i=1}^N (v_i\; rwt_i)^2 \right)^{1/2}, - -where :math:`N` is the problem dimension. - -As with the error weight vector, the user may supply a custom function -to supply the ``rwt`` vector, through a call to -:c:func:`ARKStepResFtolerance()`. Further information on all three of -these functions is provided below. + Use :c:func:`ARKodeWFtolerances` instead. @@ -221,6 +163,9 @@ these functions is provided below. * *ARK_NO_MALLOC* if the ARKStep memory was not allocated by the time-stepping module * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeResStolerance` instead. .. c:function:: int ARKStepResVtolerance(void* arkode_mem, N_Vector rabstol) @@ -238,6 +183,9 @@ these functions is provided below. * *ARK_NO_MALLOC* if the ARKStep memory was not allocated by the time-stepping module * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeResVtolerance` instead. .. c:function:: int ARKStepResFtolerance(void* arkode_mem, ARKRwtFn rfun) @@ -255,117 +203,9 @@ these functions is provided below. * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` * *ARK_NO_MALLOC* if the ARKStep memory was not allocated by the time-stepping module + .. deprecated:: x.y.z - -General advice on the choice of tolerances -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For many users, the appropriate choices for tolerance values in -``reltol``, ``abstol``, and ``rabstol`` are a concern. The following pieces -of advice are relevant. - -(1) The scalar relative tolerance ``reltol`` is to be set to control - relative errors. So a value of :math:`10^{-4}` means that errors - are controlled to .01%. We do not recommend using ``reltol`` larger - than :math:`10^{-3}`. On the other hand, ``reltol`` should not be so - small that it is comparable to the unit roundoff of the machine - arithmetic (generally around :math:`10^{-15}` for double-precision). - -(2) The absolute tolerances ``abstol`` (whether scalar or vector) need - to be set to control absolute errors when any components of the - solution vector :math:`y` may be so small that pure relative error - control is meaningless. For example, if :math:`y_i` starts at some - nonzero value, but in time decays to zero, then pure relative - error control on :math:`y_i` makes no sense (and is overly costly) - after :math:`y_i` is below some noise level. Then ``abstol`` (if - scalar) or ``abstol[i]`` (if a vector) needs to be set to that - noise level. If the different components have different noise - levels, then ``abstol`` should be a vector. For example, see the - example problem ``ark_robertson.c``, and the discussion - of it in the ARKODE Examples Documentation :cite:p:`arkode_ex`. In that - problem, the three components vary between 0 and 1, and have - different noise levels; hence the ``atols`` vector therein. It is - impossible to give any general advice on ``abstol`` values, - because the appropriate noise levels are completely - problem-dependent. The user or modeler hopefully has some idea as - to what those noise levels are. - -(3) The residual absolute tolerances ``rabstol`` (whether scalar or - vector) follow a similar explanation as for ``abstol``, except - that these should be set to the noise level of the equation - components, i.e. the noise level of :math:`My`. For problems in - which :math:`M=I`, it is recommended that ``rabstol`` be left - unset, which will default to the already-supplied ``abstol`` - values. - -(4) Finally, it is important to pick all the tolerance values - conservatively, because they control the error committed on each - individual step. The final (global) errors are an accumulation of - those per-step errors, where that accumulation factor is - problem-dependent. A general rule of thumb is to reduce the - tolerances by a factor of 10 from the actual desired limits on - errors. So if you want .01% relative accuracy (globally), a good - choice for ``reltol`` is :math:`10^{-5}`. In any case, it is - a good idea to do a few experiments with the tolerances to see how - the computed solution values vary as tolerances are reduced. - - - -Advice on controlling nonphysical negative values -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In many applications, some components in the true solution are always -positive or non-negative, though at times very small. In the -numerical solution, however, small negative (nonphysical) values -can then occur. In most cases, these values are harmless, and simply -need to be controlled, not eliminated, but in other cases any value -that violates a constraint may cause a simulation to halt. For both of -these scenarios the following pieces of advice are relevant. - -(1) The best way to control the size of unwanted negative computed - values is with tighter absolute tolerances. Again this requires - some knowledge of the noise level of these components, which may - or may not be different for different components. Some - experimentation may be needed. - -(2) If output plots or tables are being generated, and it is important - to avoid having negative numbers appear there (for the sake of - avoiding a long explanation of them, if nothing else), then - eliminate them, but only in the context of the output medium. Then - the internal values carried by the solver are unaffected. Remember - that a small negative value in :math:`y` returned by ARKStep, with - magnitude comparable to ``abstol`` or less, is equivalent to zero - as far as the computation is concerned. - -(3) The user's right-hand side routines :math:`f^E` and :math:`f^I` - should never change a negative value in the solution vector :math:`y` - to a non-negative value in attempt to "fix" this problem, - since this can lead to numerical instability. If the :math:`f^E` - or :math:`f^I` routines cannot tolerate a zero or negative value - (e.g. because there is a square root or log), then the offending - value should be changed to zero or a tiny positive number in a - temporary variable (not in the input :math:`y` vector) for the - purposes of computing :math:`f^E(t, y)` or :math:`f^I(t, y)`. - -(4) ARKStep supports component-wise constraints on solution components, - :math:`y_i < 0`, :math:`y_i \le 0`, , :math:`y_i > 0`, or - :math:`y_i \ge 0`, through the user-callable function - :c:func:`ARKStepSetConstraints`. At each internal time step, if any - constraint is violated then ARKStep will attempt a smaller time step - that should not violate this constraint. This reduced step size is - chosen such that the step size is the largest possible but where the - solution component satisfies the constraint. - -(5) Positivity and non-negativity constraints on components can also be - enforced by use of the recoverable error return feature in the - user-supplied right-hand side functions, :math:`f^E` and - :math:`f^I`. When a recoverable error is encountered, ARKStep will - retry the step with a smaller step size, which typically - alleviates the problem. However, since this reduced step size is - chosen without knowledge of the solution constraint, it may be - overly conservative. Thus this option involves some additional - overhead cost, and should only be exercised if the above recommendations - are unsuccessful. + Use :c:func:`ARKodeResFtolerance` instead. @@ -374,74 +214,6 @@ these scenarios the following pieces of advice are relevant. Linear solver interface functions ------------------------------------------- -As previously explained, the Newton iterations used in solving -implicit systems within ARKStep require the solution of linear -systems of the form - -.. math:: - \mathcal{A}\left(z_i^{(m)}\right) \delta^{(m+1)} = -G\left(z_i^{(m)}\right) - -where - -.. math:: - \mathcal{A} \approx M - \gamma J, \qquad J = \frac{\partial f^I}{\partial y}. - -ARKODE's ARKLS linear solver interface supports all valid -``SUNLinearSolver`` modules for this task. - -Matrix-based ``SUNLinearSolver`` modules utilize ``SUNMatrix`` objects -to store the approximate Jacobian matrix :math:`J`, the Newton matrix -:math:`\mathcal{A}`, the mass matrix :math:`M`, and, when using direct -solvers, the factorizations used throughout the solution process. - -Matrix-free ``SUNLinearSolver`` modules instead use iterative methods -to solve the Newton systems of equations, and only require the -*action* of the matrix on a vector, :math:`\mathcal{A}v`. With most -of these methods, preconditioning can be done on the left only, on the -right only, on both the left and the right, or not at all. The -exceptions to this rule are SPFGMR that supports right preconditioning -only and PCG that performs symmetric preconditioning. For the -specification of a preconditioner, see the iterative linear solver -portions of :numref:`ARKODE.Usage.ARKStep.OptionalInputs` and -:numref:`ARKODE.Usage.UserSupplied`. - -If preconditioning is done, user-supplied functions should be used to -define left and right preconditioner matrices :math:`P_1` and -:math:`P_2` (either of which could be the identity matrix), such that -the product :math:`P_{1}P_{2}` approximates the Newton matrix -:math:`\mathcal{A} = M - \gamma J`. - -To specify a generic linear solver for ARKStep to use for the Newton -systems, after the call to :c:func:`ARKStepCreate` but before any -calls to :c:func:`ARKStepEvolve()`, the user's program must create the -appropriate ``SUNLinearSolver`` object and call the function -:c:func:`ARKStepSetLinearSolver()`, as documented below. To create -the ``SUNLinearSolver`` object, the user may call one of the -SUNDIALS-packaged SUNLinSol module constructor routines via a call of -the form - -.. code:: c - - SUNLinearSolver LS = SUNLinSol_*(...); - -The current list of SUNDIALS-packaged SUNLinSol modules, and their -constructor routines, may be found in chapter :numref:`SUNLinSol`. -Alternately, a user-supplied ``SUNLinearSolver`` module may be created -and used. Specific information on how to create such user-provided -modules may be found in :numref:`SUNLinSol.API.Custom`. - -Once this solver object has been constructed, the user should attach -it to ARKStep via a call to :c:func:`ARKStepSetLinearSolver()`. The -first argument passed to this function is the ARKStep memory pointer -returned by :c:func:`ARKStepCreate`; the second argument is the -``SUNLinearSolver`` object created above. The third argument is an -optional ``SUNMatrix`` object to accompany matrix-based -``SUNLinearSolver`` inputs (for matrix-free linear solvers, the third -argument should be ``NULL``). A call to this function initializes the -ARKLS linear solver interface, linking it to the ARKStep integrator, -and allows the user to specify additional parameters and routines -pertinent to their choice of linear solver. - .. c:function:: int ARKStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix J) This function specifies the ``SUNLinearSolver`` object that ARKStep @@ -484,8 +256,9 @@ pertinent to their choice of linear solver. insufficient to store :math:`\mathcal{A}` then it will need to be resized internally by ARKStep. + .. deprecated:: x.y.z - + Use :c:func:`ARKodeSetLinearSolver` instead. @@ -494,57 +267,6 @@ pertinent to their choice of linear solver. Mass matrix solver specification functions ------------------------------------------- -As discussed in :numref:`ARKODE.Mathematics.MassSolve`, if the ODE -system involves a non-identity mass matrix :math:`M\ne I`, then ARKStep -must solve linear systems of the form - -.. math:: - M x = b. - -ARKODE's ARKLS mass-matrix linear solver interface supports all valid -``SUNLinearSolver`` modules for this task. For iterative linear -solvers, user-supplied preconditioning can be applied. For the -specification of a preconditioner, see the iterative linear solver -portions of :numref:`ARKODE.Usage.ARKStep.OptionalInputs` and -:numref:`ARKODE.Usage.UserSupplied`. If preconditioning is to be -performed, user-supplied functions should be used to define left and -right preconditioner matrices :math:`P_1` and :math:`P_2` (either of -which could be the identity matrix), such that the product -:math:`P_{1}P_{2}` approximates the mass matrix :math:`M`. - -To specify a generic linear solver for ARKStep to use for mass matrix -systems, after the call to :c:func:`ARKStepCreate` but before any -calls to :c:func:`ARKStepEvolve()`, the user's program must create the -appropriate ``SUNLinearSolver`` object and call the function -:c:func:`ARKStepSetMassLinearSolver()`, as documented below. The -first argument passed to this function is the ARKStep memory -pointer returned by :c:func:`ARKStepCreate`; the second argument is -the desired ``SUNLinearSolver`` object to use for solving mass matrix -systems. The third object is a template ``SUNMatrix`` to use with the -provided ``SUNLinearSolver`` (if applicable). The fourth input is a -flag to indicate whether the mass matrix is time-dependent, -i.e. :math:`M = M(t)`, or not. A call to this function initializes the -ARKLS mass matrix linear solver interface, linking this to the main -ARKStep integrator, and allows the user to specify additional -parameters and routines pertinent to their choice of linear solver. - -Note: if the user program includes linear solvers for *both* the -Newton and mass matrix systems, these must have the same type: - -* If both are matrix-based, then they must utilize the same - ``SUNMatrix`` type, since these will be added when forming the - Newton system matrix :math:`\mathcal{A}`. In this case, both the - Newton and mass matrix linear solver interfaces can use the same - ``SUNLinearSolver`` object, although different solver objects - (e.g. with different solver parameters) are also allowed. - -* If both are matrix-free, then the Newton and mass matrix - ``SUNLinearSolver`` objects must be different. These may even use - different solver algorithms (SPGMR, SPBCGS, etc.), if desired. - For example, if the mass matrix is symmetric but the Jacobian is not, - then PCG may be used for the mass matrix systems and SPGMR for the - Newton systems. - .. c:function:: int ARKStepSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, sunbooleantype time_dep) @@ -596,7 +318,9 @@ Newton and mass matrix systems, these must have the same type: mass-matrix-times-vector product routine (see :c:type:`ARKLsMassTimesVecFn` and :c:func:`ARKStepSetMassTimes()`). + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetMassLinearSolver` instead. .. _ARKODE.Usage.ARKStep.NonlinearSolvers: @@ -604,23 +328,6 @@ Newton and mass matrix systems, these must have the same type: Nonlinear solver interface functions ------------------------------------------- -When changing the nonlinear solver in ARKStep, after the -call to :c:func:`ARKStepCreate` but before any calls to -:c:func:`ARKStepEvolve()`, the user's program must create the -appropriate ``SUNNonlinearSolver`` object and call -:c:func:`ARKStepSetNonlinearSolver()`, as documented below. If any -calls to :c:func:`ARKStepEvolve()` have been made, then ARKStep will -need to be reinitialized by calling :c:func:`ARKStepReInit()` to -ensure that the nonlinear solver is initialized correctly before any -subsequent calls to :c:func:`ARKStepEvolve()`. - -The first argument passed to the routine -:c:func:`ARKStepSetNonlinearSolver()` is the ARKStep memory pointer -returned by :c:func:`ARKStepCreate`; the second argument passed -to this function is the desired ``SUNNonlinearSolver`` object to use for -solving the nonlinear system for each implicit stage. A call to this -function attaches the nonlinear solver to the main ARKStep integrator. - .. c:function:: int ARKStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) @@ -643,7 +350,9 @@ function attaches the nonlinear solver to the main ARKStep integrator. default; a call to this routine replaces that module with the supplied *NLS* object. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetNonlinearSolver` instead. .. _ARKODE.Usage.ARKStep.RootFinding: @@ -651,15 +360,6 @@ function attaches the nonlinear solver to the main ARKStep integrator. Rootfinding initialization function -------------------------------------- -As described in :numref:`ARKODE.Mathematics.Rootfinding`, while -solving the IVP, ARKODE's time-stepping modules have the capability to -find the roots of a set of user-defined functions. To activate the -root-finding algorithm, call the following function. This is normally -called only once, prior to the first call to -:c:func:`ARKStepEvolve()`, but if the rootfinding problem is to be -changed during the solution, :c:func:`ARKStepRootInit()` can also be -called prior to a continuation call to :c:func:`ARKStepEvolve()`. - .. c:function:: int ARKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) @@ -689,7 +389,9 @@ called prior to a continuation call to :c:func:`ARKStepEvolve()`. problem but the prior one did, then call *ARKStepRootInit* with *nrtfn = 0*. + .. deprecated:: x.y.z + Use :c:func:`ARKodeRootInit` instead. .. _ARKODE.Usage.ARKStep.Integration: @@ -697,12 +399,6 @@ called prior to a continuation call to :c:func:`ARKStepEvolve()`. ARKStep solver function ------------------------- -This is the central step in the solution process -- the call to perform -the integration of the IVP. The input argument *itask* specifies one of two -modes as to where ARKStep is to return a solution. These modes are modified if -the user has set a stop time (with a call to the optional input function -:c:func:`ARKStepSetStopTime()`) or has requested rootfinding. - .. c:function:: int ARKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype *tret, int itask) @@ -812,7 +508,9 @@ the user has set a stop time (with a call to the optional input function On all other error returns, *tret* and *yout* are left unchanged from those provided to the routine. + .. deprecated:: x.y.z + Use :c:func:`ARKodeEvolve` instead. .. _ARKODE.Usage.ARKStep.OptionalInputs: @@ -820,68 +518,12 @@ the user has set a stop time (with a call to the optional input function Optional input functions ------------------------- -There are numerous optional input parameters that control the behavior -of ARKStep, each of which may be modified from its default value through -calling an appropriate input function. The following tables list all -optional input functions, grouped by which aspect of ARKStep they control. -Detailed information on the calling syntax and arguments for each -function are then provided following each table. - -The optional inputs are grouped into the following categories: - -* General ARKStep options (:ref:`ARKODE.Usage.ARKStep.ARKStepInputTable`), -* IVP method solver options (:ref:`ARKODE.Usage.ARKStep.ARKStepMethodInputTable`), -* Step adaptivity solver options (:ref:`ARKODE.Usage.ARKStep.ARKStepAdaptivityInputTable`), -* Implicit stage solver options (:ref:`ARKODE.Usage.ARKStep.ARKStepSolverInputTable`), -* Linear solver interface options (:ref:`ARKODE.Usage.ARKStep.ARKLsInputs`), and -* Rootfinding options (:ref:`ARKODE.Usage.ARKStep.ARKStepRootfindingInputTable`). - -For the most casual use of ARKStep, relying on the default set of -solver parameters, the reader can skip to section on user-supplied -functions, :numref:`ARKODE.Usage.UserSupplied`. - -We note that, on an error return, all of the optional input functions send an -error message to the error handler function. All error return values are -negative, so a test on the return arguments for negative values will catch all -errors. Finally, a call to an ``ARKStepSet***`` function can generally be made -from the user's calling program at any time and, if successful, takes effect -immediately. ``ARKStepSet***`` functions that cannot be called at any time note -this in the "**Notes**:" section of the function documentation. - - .. _ARKODE.Usage.ARKStep.ARKStepInputTable: Optional inputs for ARKStep ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. cssclass:: table-bordered - -================================================ ======================================= ======================= -Optional input Function name Default -================================================ ======================================= ======================= -Return ARKStep parameters to their defaults :c:func:`ARKStepSetDefaults` internal -Set dense output interpolation type :c:func:`ARKStepSetInterpolantType` ``ARK_INTERP_HERMITE`` -Set dense output polynomial degree :c:func:`ARKStepSetInterpolantDegree` 5 -Supply a pointer to a diagnostics output file :c:func:`ARKStepSetDiagnostics` ``NULL`` -Disable time step adaptivity (fixed-step mode) :c:func:`ARKStepSetFixedStep` disabled -Supply an initial step size to attempt :c:func:`ARKStepSetInitStep` estimated -Maximum no. of warnings for :math:`t_n+h = t_n` :c:func:`ARKStepSetMaxHnilWarns` 10 -Maximum no. of internal steps before *tout* :c:func:`ARKStepSetMaxNumSteps` 500 -Maximum absolute step size :c:func:`ARKStepSetMaxStep` :math:`\infty` -Minimum absolute step size :c:func:`ARKStepSetMinStep` 0.0 -Set a value for :math:`t_{stop}` :c:func:`ARKStepSetStopTime` undefined -Interpolate at :math:`t_{stop}` :c:func:`ARKStepSetInterpolateStopTime` ``SUNFALSE`` -Disable the stop time :c:func:`ARKStepClearStopTime` N/A -Supply a pointer for user data :c:func:`ARKStepSetUserData` ``NULL`` -Maximum no. of ARKStep error test failures :c:func:`ARKStepSetMaxErrTestFails` 7 -Set 'optimal' adaptivity params. for a method :c:func:`ARKStepSetOptimalParams` internal -Set inequality constraints on solution :c:func:`ARKStepSetConstraints` ``NULL`` -Set max number of constraint failures :c:func:`ARKStepSetMaxNumConstrFails` 10 -================================================ ======================================= ======================= - - - .. c:function:: int ARKStepSetDefaults(void* arkode_mem) @@ -903,6 +545,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst Also leaves alone any data structures or options related to root-finding (those can be reset using :c:func:`ARKStepRootInit()`). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDefaults` instead. .. c:function:: int ARKStepSetInterpolantType(void* arkode_mem, int itype) @@ -937,6 +582,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst If this routine is not called, the Hermite interpolation module will be used. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantType` instead. .. c:function:: int ARKStepSetInterpolantDegree(void* arkode_mem, int degree) @@ -979,14 +627,16 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst obtained by the integrator are returned at the ends of the time interval. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantDegree` instead. .. c:function:: int ARKStepSetDenseOrder(void* arkode_mem, int dord) - *This function is deprecated, and will be removed in a future release. - Users should transition to calling* :c:func:`ARKStepSetInterpolantDegree()` - *instead.* + .. deprecated:: 5.2.0 + Use :c:func:`ARKodeSetInterpolantDegree` instead. .. c:function:: int ARKStepSetDiagnostics(void* arkode_mem, FILE* diagfp) @@ -1073,7 +723,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst routines will provide no useful information to the solver, and at worst they may interfere with the desired fixed step size. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetFixedStep` instead. @@ -1101,7 +753,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst This routine will also reset the step size and error history. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetInitStep` instead. .. c:function:: int ARKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) @@ -1125,7 +779,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst A negative value indicates that no warning messages should be issued. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetMaxHnilWarns` instead. .. c:function:: int ARKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) @@ -1149,6 +805,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst Passing *mxsteps* < 0 disables the test (not recommended). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNumSteps` instead. .. c:function:: int ARKStepSetMaxStep(void* arkode_mem, sunrealtype hmax) @@ -1167,6 +826,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst **Notes:** Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxStep` instead. .. c:function:: int ARKStepSetMinStep(void* arkode_mem, sunrealtype hmin) @@ -1185,6 +847,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst **Notes:** Pass *hmin* :math:`\le 0.0` to set the default value of 0. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMinStep` instead. .. c:function:: int ARKStepSetStopTime(void* arkode_mem, sunrealtype tstop) @@ -1212,6 +877,10 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst :c:func:`ARKStepReset` will remain active but can be disabled by calling :c:func:`ARKStepClearStopTime`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStopTime` instead. + .. c:function:: int ARKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) @@ -1229,6 +898,10 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolateStopTime` instead. + .. c:function:: int ARKStepClearStopTime(void* arkode_mem) @@ -1247,6 +920,10 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst .. versionadded:: 5.5.1 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeClearStopTime` instead. + .. c:function:: int ARKStepSetUserData(void* arkode_mem, void* user_data) @@ -1271,6 +948,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst this function must be made *before* any calls to :c:func:`ARKStepSetLinearSolver()` and/or :c:func:`ARKStepSetMassLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetUserData` instead. .. c:function:: int ARKStepSetMaxErrTestFails(void* arkode_mem, int maxnef) @@ -1291,6 +971,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst The default value is 7; set *maxnef* :math:`\le 0` to specify this default. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxErrTestFails` instead. .. c:function:: int ARKStepSetOptimalParams(void* arkode_mem) @@ -1314,6 +997,148 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst all problems are different, so these values may not be optimal for all users. + .. deprecated:: x.y.z + + Adjust solver parameters individually instead. For reference, this routine + sets the following non-default parameters: + + * Explicit methods: + + * :c:func:`SUNAdaptController_PI` with :c:func:`SUNAdaptController_SetErrorBias` of 1.2 and :c:func:`SUNAdaptController_SetParams_PI` of :math:`k_1=0.8` and :math:`k_2=-0.31` + + * :c:func:`ARKodeSetSafetyFactor` of 0.99 + + * :c:func:`ARKodeSetMaxGrowth` of 25.0 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.3 + + * Implicit methods: + + * Order 3: + + * :c:func:`SUNAdaptController_I` with :c:func:`SUNAdaptController_SetErrorBias` of 1.9 + + * :c:func:`ARKodeSetSafetyFactor` of 0.957 + + * :c:func:`ARKodeSetMaxGrowth` of 17.6 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.45 + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.22 + + * :c:func:`ARKodeSetNonlinCRDown` of 0.17 + + * :c:func:`ARKodeSetNonlinRDiv` of 2.3 + + * :c:func:`ARKodeSetDeltaGammaMax` of 0.19 + + * Order 4: + + * :c:func:`SUNAdaptController_PID` with :c:func:`SUNAdaptController_SetErrorBias` of 1.2 and :c:func:`SUNAdaptController_SetParams_PID` of :math:`k_1=0.535`, :math:`k_2=-0.209`, and :math:`k_3=0.148` + + * :c:func:`ARKodeSetSafetyFactor` of 0.988 + + * :c:func:`ARKodeSetMaxGrowth` of 31.5 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.33 + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.24 + + * :c:func:`ARKodeSetNonlinCRDown` of 0.26 + + * :c:func:`ARKodeSetNonlinRDiv` of 2.3 + + * :c:func:`ARKodeSetDeltaGammaMax` of 0.16 + + * :c:func:`ARKodeSetLSetupFrequency` of 31 + + * Order 5: + + * :c:func:`SUNAdaptController_PID` with :c:func:`SUNAdaptController_SetErrorBias` of 3.3 and :c:func:`SUNAdaptController_SetParams_PID` of :math:`k_1=0.56`, :math:`k_2=-0.338`, and :math:`k_3=0.14` + + * :c:func:`ARKodeSetSafetyFactor` of 0.937 + + * :c:func:`ARKodeSetMaxGrowth` of 22.0 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.44 + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.25 + + * :c:func:`ARKodeSetNonlinCRDown` of 0.4 + + * :c:func:`ARKodeSetNonlinRDiv` of 2.3 + + * :c:func:`ARKodeSetDeltaGammaMax` of 0.32 + + * :c:func:`ARKodeSetLSetupFrequency` of 31 + + * ImEx methods: + + * Order 2: + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.001 + + * :c:func:`ARKodeSetMaxNonlinIters` of 5 + + * Order 3: + + * :c:func:`SUNAdaptController_PID` with :c:func:`SUNAdaptController_SetErrorBias` of 1.42 and :c:func:`SUNAdaptController_SetParams_PID` of :math:`k_1=0.54`, :math:`k_2=-0.36`, and :math:`k_3=0.14` + + * :c:func:`ARKodeSetSafetyFactor` of 0.965 + + * :c:func:`ARKodeSetMaxGrowth` of 28.7 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.46 + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.22 + + * :c:func:`ARKodeSetNonlinCRDown` of 0.17 + + * :c:func:`ARKodeSetNonlinRDiv` of 2.3 + + * :c:func:`ARKodeSetDeltaGammaMax` of 0.19 + + * :c:func:`ARKodeSetLSetupFrequency` of 60 + + * Order 4: + + * :c:func:`SUNAdaptController_PID` with :c:func:`SUNAdaptController_SetErrorBias` of 1.35 and :c:func:`SUNAdaptController_SetParams_PID` of :math:`k_1=0.543`, :math:`k_2=-0.297`, and :math:`k_3=0.14` + + * :c:func:`ARKodeSetSafetyFactor` of 0.97 + + * :c:func:`ARKodeSetMaxGrowth` of 25.0 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.47 + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.24 + + * :c:func:`ARKodeSetNonlinCRDown` of 0.26 + + * :c:func:`ARKodeSetNonlinRDiv` of 2.3 + + * :c:func:`ARKodeSetDeltaGammaMax` of 0.16 + + * :c:func:`ARKodeSetLSetupFrequency` of 31 + + * Order 5: + + * :c:func:`SUNAdaptController_PI` with :c:func:`SUNAdaptController_SetErrorBias` of 1.15 and :c:func:`SUNAdaptController_SetParams_PI` of :math:`k_1=0.8` and :math:`k_2=-0.35` + + * :c:func:`ARKodeSetSafetyFactor` of 0.993 + + * :c:func:`ARKodeSetMaxGrowth` of 28.5 + + * :c:func:`ARKodeSetMaxEFailGrowth` of 0.3 + + * :c:func:`ARKodeSetNonlinConvCoef` of 0.25 + + * :c:func:`ARKodeSetNonlinCRDown` of 0.4 + + * :c:func:`ARKodeSetNonlinRDiv` of 2.3 + + * :c:func:`ARKodeSetDeltaGammaMax` of 0.32 + + * :c:func:`ARKodeSetLSetupFrequency` of 31 .. c:function:: int ARKStepSetConstraints(void* arkode_mem, N_Vector constraints) @@ -1358,6 +1183,10 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst and :c:func:`ARKStepSetFixedStep()` are incompatible, and should not be used simultaneously. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetConstraints` instead. + .. c:function:: int ARKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) @@ -1376,6 +1205,9 @@ Set max number of constraint failures :c:func:`ARKStepSetMaxNumConst Passing *maxfails* <= 0 results in ARKStep using the default value (10). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNumConstrFails` instead. .. _ARKODE.Usage.ARKStep.ARKStepMethodInputTable: @@ -1424,6 +1256,9 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int ARKStep memory block, it cannot be changed after the first call to :c:func:`ARKStepEvolve()`, unless :c:func:`ARKStepReInit()` is called. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetOrder` instead. .. c:function:: int ARKStepSetImEx(void* arkode_mem) @@ -1542,6 +1377,8 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int :c:func:`ARKStepSetFixedStep()` to enable fixed-step mode and set the desired time step size. + **Warning:** + This should not be used with :c:func:`ARKodeSetOrder`. @@ -1581,6 +1418,9 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int In all cases, error-checking is performed to ensure that the tables exist. + **Warning:** + This should not be used with :c:func:`ARKodeSetOrder`. + @@ -1621,6 +1461,9 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int In all cases, error-checking is performed to ensure that the tables exist. + **Warning:** + This should not be used with :c:func:`ARKodeSetOrder`. + @@ -1629,34 +1472,6 @@ Set additive RK tables via their names :c:func:`ARKStepSetTableName()` int Optional inputs for time step adaptivity ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The mathematical explanation of ARKODE's time step adaptivity -algorithm, including how each of the parameters below is used within -the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. - - -.. cssclass:: table-bordered - -========================================================= ========================================== ======== -Optional input Function name Default -========================================================= ========================================== ======== -Provide a :c:type:`SUNAdaptController` for ARKStep to use :c:func:`ARKStepSetAdaptController()` PID -Set a custom time step adaptivity function :c:func:`ARKStepSetAdaptivityFn()` internal -Choose an existing time step adaptivity method :c:func:`ARKStepSetAdaptivityMethod()` 0 -Adjust the method order used in the controller :c:func:`ERKStepSetAdaptivityAdjustment()` -1 -Explicit stability safety factor :c:func:`ARKStepSetCFLFraction()` 0.5 -Time step error bias factor :c:func:`ARKStepSetErrorBias()` 1.5 -Bounds determining no change in step size :c:func:`ARKStepSetFixedStepBounds()` 1.0 1.5 -Maximum step growth factor on convergence fail :c:func:`ARKStepSetMaxCFailGrowth()` 0.25 -Maximum step growth factor on error test fail :c:func:`ARKStepSetMaxEFailGrowth()` 0.3 -Maximum first step growth factor :c:func:`ARKStepSetMaxFirstGrowth()` 10000.0 -Maximum allowed general step growth factor :c:func:`ARKStepSetMaxGrowth()` 20.0 -Minimum allowed step reduction factor on error test fail :c:func:`ARKStepSetMinReduction()` 0.1 -Time step safety factor :c:func:`ARKStepSetSafetyFactor()` 0.96 -Error fails before MaxEFailGrowth takes effect :c:func:`ARKStepSetSmallNumEFails()` 2 -Explicit stability function :c:func:`ARKStepSetStabilityFn()` none -========================================================= ========================================== ======== - - .. c:function:: int ARKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) @@ -1673,6 +1488,10 @@ Explicit stability function :c:func:`ARKStepSetS .. versionadded:: 5.7.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetAdaptController` instead. + .. c:function:: int ARKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) @@ -1767,6 +1586,12 @@ Explicit stability function :c:func:`ARKStepSetS .. versionadded:: 5.7.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetAdaptivityAdjustment` instead. + + + .. c:function:: int ARKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) Specifies the fraction of the estimated explicitly stable step to use. @@ -1784,6 +1609,9 @@ Explicit stability function :c:func:`ARKStepSetS Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetCFLFraction` instead. .. c:function:: int ARKStepSetErrorBias(void* arkode_mem, sunrealtype bias) @@ -1830,6 +1658,9 @@ Explicit stability function :c:func:`ARKStepSetS **Notes:** Any interval *not* containing 1.0 will imply a reset to the default values. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetFixedStepBounds` instead. .. c:function:: int ARKStepSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) @@ -1851,6 +1682,9 @@ Explicit stability function :c:func:`ARKStepSetS **Notes:** Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxCFailGrowth` instead. .. c:function:: int ARKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) @@ -1870,6 +1704,9 @@ Explicit stability function :c:func:`ARKStepSetS **Notes:** Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxEFailGrowth` instead. .. c:function:: int ARKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) @@ -1890,6 +1727,9 @@ Explicit stability function :c:func:`ARKStepSetS **Notes:** Any value :math:`\le 1.0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxFirstGrowth` instead. .. c:function:: int ARKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) @@ -1910,6 +1750,9 @@ Explicit stability function :c:func:`ARKStepSetS Any value :math:`\le 1.0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxGrowth` instead. .. c:function:: int ARKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min) @@ -1932,6 +1775,9 @@ Explicit stability function :c:func:`ARKStepSetS Any value outside the interval :math:`(0,1)` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMinReduction` instead. .. c:function:: int ARKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety) @@ -1952,6 +1798,9 @@ Explicit stability function :c:func:`ARKStepSetS Any value :math:`\le 0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetSafetyFactor` instead. .. c:function:: int ARKStepSetSmallNumEFails(void* arkode_mem, int small_nef) @@ -1972,6 +1821,9 @@ Explicit stability function :c:func:`ARKStepSetS **Notes:** Any value :math:`\le 0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetSmallNumEFails` instead. .. c:function:: int ARKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) @@ -1998,6 +1850,9 @@ Explicit stability function :c:func:`ARKStepSetS be quite useful for problems where the explicit right-hand side function :math:`f^E(t,y)` contains stiff terms. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStabilityFn` instead. @@ -2006,32 +1861,6 @@ Explicit stability function :c:func:`ARKStepSetS Optional inputs for implicit stage solves ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The mathematical explanation for the nonlinear solver strategies used -by ARKStep, including how each of the parameters below is used within -the code, is provided in :numref:`ARKODE.Mathematics.Nonlinear`. - - -.. cssclass:: table-bordered - -========================================================= ========================================= ============ -Optional input Function name Default -========================================================= ========================================= ============ -Specify that :math:`f^I` is linearly implicit :c:func:`ARKStepSetLinear()` ``SUNFALSE`` -Specify that :math:`f^I` is nonlinearly implicit :c:func:`ARKStepSetNonlinear()` ``SUNTRUE`` -Implicit predictor method :c:func:`ARKStepSetPredictorMethod()` 0 -User-provided implicit stage predictor :c:func:`ARKStepSetStagePredictFn()` ``NULL`` -RHS function for nonlinear system evaluations :c:func:`ARKStepSetNlsRhsFn()` ``NULL`` -Maximum number of nonlinear iterations :c:func:`ARKStepSetMaxNonlinIters()` 3 -Coefficient in the nonlinear convergence test :c:func:`ARKStepSetNonlinConvCoef()` 0.1 -Nonlinear convergence rate constant :c:func:`ARKStepSetNonlinCRDown()` 0.3 -Nonlinear residual divergence ratio :c:func:`ARKStepSetNonlinRDiv()` 2.3 -Maximum number of convergence failures :c:func:`ARKStepSetMaxConvFails()` 10 -Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDeduceImplicitRhs` ``SUNFALSE`` -========================================================= ========================================= ============ - - - - .. c:function:: int ARKStepSetLinear(void* arkode_mem, int timedepend) @@ -2061,6 +1890,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe stage. Thus one must balance the relative costs of such recomputation against the benefits of requiring only a single Newton linear solve. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinear` instead. .. c:function:: int ARKStepSetNonlinear(void* arkode_mem) @@ -2082,6 +1914,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe :c:func:`ARKStepSetDeltaGammaMax()` to reset the step size ratio threshold to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinear` instead. .. c:function:: int ARKStepSetPredictorMethod(void* arkode_mem, int method) @@ -2127,6 +1962,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe instead default to the trivial predictor (*method* 0). **Both of these options have been deprecated, and will be removed from a future release.** + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetPredictorMethod` instead. .. c:function:: int ARKStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) @@ -2147,6 +1985,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe See :numref:`ARKODE.Usage.StagePredictFn` for more information on this user-supplied routine. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStagePredictFn` instead. .. c:function:: int ARKStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) @@ -2172,6 +2013,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe When using a non-default nonlinear solver, this function must be called *after* :c:func:`ARKStepSetNonlinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNlsRhsFn` instead. .. c:function:: int ARKStepSetMaxNonlinIters(void* arkode_mem, int maxcor) @@ -2193,6 +2037,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe The default value is 3; set *maxcor* :math:`\le 0` to specify this default. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNonlinIters` instead. .. c:function:: int ARKStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) @@ -2213,6 +2060,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe The default value is 0.1; set *nlscoef* :math:`\le 0` to specify this default. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinConvCoef` instead. .. c:function:: int ARKStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) @@ -2231,6 +2081,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe **Notes:** Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinCRDown` instead. .. c:function:: int ARKStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) @@ -2251,6 +2104,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe **Notes:** Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinRDiv` instead. .. c:function:: int ARKStepSetMaxConvFails(void* arkode_mem, int maxncf) @@ -2279,6 +2135,9 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe convergence failure still occurs, the time step size is reduced by the factor *etacf* (set within :c:func:`ARKStepSetMaxCFailGrowth()`). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxConvFails` instead. .. c:function:: int ARKStepSetDeduceImplicitRhs(void *arkode_mem, sunbooleantype deduce) @@ -2299,6 +2158,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe .. versionadded:: 5.2.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDeduceImplicitRhs` instead. + .. _ARKODE.Usage.ARKStep.ARKLsInputs: @@ -2306,81 +2169,13 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`ARKStepSetDe Linear solver interface optional input functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The mathematical explanation of the linear solver methods -available to ARKStep is provided in :numref:`ARKODE.Mathematics.Linear`. We group -the user-callable routines into four categories: general routines concerning -the update frequency for matrices and/or preconditioners, optional inputs for -matrix-based linear solvers, optional inputs for matrix-free linear solvers, -and optional inputs for iterative linear solvers. We note that the -matrix-based and matrix-free groups are mutually exclusive, whereas the -"iterative" tag can apply to either case. - - .. _ARKODE.Usage.ARKStep.ARKLsInputs.General: -.. index:: - single: optional input; generic linear solver interface (ARKStep) Optional inputs for the ARKLS linear solver interface """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -As discussed in :numref:`ARKODE.Mathematics.Linear.Setup`, ARKODE -strives to reuse matrix and preconditioner data for as many solves as -possible to amortize the high costs of matrix construction and -factorization. To that end, ARKStep provides user-callable -routines to modify this behavior. Recall that the -Newton system matrices that arise within an implicit stage solve are -:math:`\mathcal{A}(t,z) \approx M(t) - \gamma J(t,z)`, where the -implicit right-hand side function has Jacobian matrix -:math:`J(t,z) = \frac{\partial f^I(t,z)}{\partial z}`. - -The matrix or preconditioner for :math:`\mathcal{A}` can only be -updated within a call to the linear solver "setup" routine. In -general, the frequency with which the linear solver setup routine is -called may be controlled with the *msbp* argument to -:c:func:`ARKStepSetLSetupFrequency()`. When this occurs, the -validity of :math:`\mathcal{A}` for successive time steps -intimately depends on whether the corresponding :math:`\gamma` and -:math:`J` inputs remain valid. - -At each call to the linear solver setup routine the decision to update -:math:`\mathcal{A}` with a new value of :math:`\gamma`, and to reuse -or reevaluate Jacobian information, depends on several factors including: - -* the success or failure of previous solve attempts, -* the success or failure of the previous time step attempts, -* the change in :math:`\gamma` from the value used when constructing :math:`\mathcal{A}`, and -* the number of steps since Jacobian information was last evaluated. - -Jacobian information is considered out-of-date when :math:`msbj` or more steps -have been completed since the last update, in which case it will be recomputed during the next -linear solver setup call. The value of :math:`msbj` is controlled with the -``msbj`` argument to :c:func:`ARKStepSetJacEvalFrequency()`. - -For linear-solvers with user-supplied preconditioning the above factors are used -to determine whether to recommend updating the Jacobian information in the -preconditioner (i.e., whether to set *jok* to ``SUNFALSE`` in calling the -user-supplied :c:type:`ARKLsPrecSetupFn()`). For matrix-based linear solvers -these factors determine whether the matrix :math:`J(t,y) = \frac{\partial f^I(t,y)}{\partial y}` -should be updated (either with an internal finite difference approximation or -a call to the user-supplied :c:type:`ARKLsJacFn`); if not then the previous -value is reused and the system matrix :math:`\mathcal{A}(t,y) \approx M(t) - \gamma J(t,y)` -is recomputed using the current :math:`\gamma` value. - - - -.. _ARKODE.Usage.ARKStep.ARKLsInputs.General.Table: -.. table:: Optional inputs for the ARKLS linear solver interface - - ============================================= ========================================= ============ - Optional input Function name Default - ============================================= ========================================= ============ - Max change in step signaling new :math:`J` :c:func:`ARKStepSetDeltaGammaMax()` 0.2 - Linear solver setup frequency :c:func:`ARKStepSetLSetupFrequency()` 20 - Jacobian / preconditioner update frequency :c:func:`ARKStepSetJacEvalFrequency()` 51 - ============================================= ========================================= ============ - .. c:function:: int ARKStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) @@ -2401,9 +2196,11 @@ is recomputed using the current :math:`\gamma` value. **Notes:** Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDeltaGammaMax` instead. + -.. index:: - single: optional input; linear solver setup frequency (ARKStep) .. c:function:: int ARKStepSetLSetupFrequency(void* arkode_mem, int msbp) @@ -2425,10 +2222,10 @@ is recomputed using the current :math:`\gamma` value. step. If **msbp** is 0, the default value of 20 will be used. A negative value forces a linear solver step at each implicit stage. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLSetupFrequency` instead. -.. index:: - single: optional input; Jacobian update frequency (ARKStep) - single: optional input; preconditioner update frequency (ARKStep) .. c:function:: int ARKStepSetJacEvalFrequency(void* arkode_mem, long int msbj) @@ -2462,7 +2259,9 @@ is recomputed using the current :math:`\gamma` value. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKStepSetLinearSolver()`. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetJacEvalFrequency` instead. @@ -2473,59 +2272,6 @@ is recomputed using the current :math:`\gamma` value. Optional inputs for matrix-based ``SUNLinearSolver`` modules """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.. cssclass:: table-bordered - -========================================= =========================================== ============= -Optional input Function name Default -========================================= =========================================== ============= -Jacobian function :c:func:`ARKStepSetJacFn()` ``DQ`` -Linear system function :c:func:`ARKStepSetLinSysFn()` internal -Mass matrix function :c:func:`ARKStepSetMassFn()` none -Enable or disable linear solution scaling :c:func:`ARKStepSetLinearSolutionScaling()` on -========================================= =========================================== ============= - -When using matrix-based linear solver modules, the ARKLS solver interface needs -a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or -the linear system :math:`\mathcal{A}(t,y) = M(t) - \gamma J(t,y)`. - -For :math:`J(t,y)`, the ARKLS interface is packaged with a routine that can approximate -:math:`J` if the user has selected either the :ref:`SUNMATRIX_DENSE ` or -:ref:`SUNMATRIX_BAND ` objects. Alternatively, -the user can supply a custom Jacobian function of type :c:func:`ARKLsJacFn()` -- this is -*required* when the user selects other matrix formats. To specify a user-supplied -Jacobian function, ARKStep provides the function :c:func:`ARKStepSetJacFn()`. - -Alternatively, a function of type :c:func:`ARKLsLinSysFn()` can be provided to -evaluate the matrix :math:`\mathcal{A}(t,y)`. By default, ARKLS uses an -internal linear system function leveraging the SUNMATRIX API to form the matrix -:math:`\mathcal{A}(t,y)` by combining the matrices :math:`M(t)` and :math:`J(t,y)`. -To specify a user-supplied linear system function instead, ARKStep provides the function -:c:func:`ARKStepSetLinSysFn()`. - -If the ODE system involves a non-identity mass matrix, :math:`M\ne I`, matrix-based linear -solver modules require a function to compute an approximation to the mass matrix :math:`M(t)`. -There is no default difference quotient approximation (for any matrix type), so this -routine must be supplied by the user. This function must be of type -:c:func:`ARKLsMassFn()`, and should be set using the function -:c:func:`ARKStepSetMassFn()`. - -In either case (:math:`J(t,y)` versus :math:`\mathcal{A}(t,y)` is supplied) the matrix -information will be updated infrequently to reduce matrix construction and, with direct -solvers, factorization costs. As a result the value of :math:`\gamma` may not be current -and a scaling factor is applied to the solution of the linear system to account for -the lagged value of :math:`\gamma`. See :numref:`SUNLinSol.Lagged_matrix` for more details. -The function :c:func:`ARKStepSetLinearSolutionScaling()` can be used to disable this -scaling when necessary, e.g., when providing a custom linear solver that updates the -matrix using the current :math:`\gamma` as part of the solve. - -The ARKLS interface passes the user data pointer to the Jacobian, linear -system, and mass matrix functions. This allows the user to create an arbitrary -structure with relevant problem data and access it during the execution of the -user-supplied Jacobian, linear system or mass matrix functions, without using global -data in the program. The user data pointer may be specified through -:c:func:`ARKStepSetUserData()`. - - .. c:function:: int ARKStepSetJacFn(void* arkode_mem, ARKLsJacFn jac) @@ -2555,6 +2301,10 @@ data in the program. The user data pointer may be specified through The function type :c:func:`ARKLsJacFn()` is described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetJacFn` instead. + .. c:function:: int ARKStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) @@ -2582,6 +2332,10 @@ data in the program. The user data pointer may be specified through The function type :c:func:`ARKLsLinSysFn()` is described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinSysFn` instead. + .. c:function:: int ARKStepSetMassFn(void* arkode_mem, ARKLsMassFn mass) @@ -2609,6 +2363,10 @@ data in the program. The user data pointer may be specified through The function type :c:func:`ARKLsMassFn()` is described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMassFn` instead. + .. c:function:: int ARKStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) @@ -2630,47 +2388,16 @@ data in the program. The user data pointer may be specified through Linear solution scaling is enabled by default when a matrix-based linear solver is attached. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinearSolutionScaling` instead. + .. _ARKODE.Usage.ARKStep.ARKLsInputs.MatrixFree: Optional inputs for matrix-free ``SUNLinearSolver`` modules """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.. cssclass:: table-bordered - -================================================== ========================================= ================== -Optional input Function name Default -================================================== ========================================= ================== -:math:`Jv` functions (*jtimes* and *jtsetup*) :c:func:`ARKStepSetJacTimes()` DQ, none -:math:`Jv` DQ rhs function (*jtimesRhsFn*) :c:func:`ARKStepSetJacTimesRhsFn()` fi -:math:`Mv` functions (*mtimes* and *mtsetup*) :c:func:`ARKStepSetMassTimes()` none, none -================================================== ========================================= ================== - - -As described in :numref:`ARKODE.Mathematics.Linear`, when solving -the Newton linear systems with matrix-free methods, the ARKLS -interface requires a *jtimes* function to compute an approximation to -the product between the Jacobian matrix -:math:`J(t,y)` and a vector :math:`v`. The user can supply a custom -Jacobian-times-vector approximation function, or use the default -internal difference quotient function that comes with the ARKLS -interface. - -A user-defined Jacobian-vector function must be of type -:c:type:`ARKLsJacTimesVecFn` and can be specified through a call -to :c:func:`ARKStepSetJacTimes()` (see :numref:`ARKODE.Usage.UserSupplied` -for specification details). As with the -user-supplied preconditioner functions, the evaluation and -processing of any Jacobian-related data needed by the user's -Jacobian-times-vector function is done in the optional user-supplied -function of type :c:type:`ARKLsJacTimesSetupFn` (see -:numref:`ARKODE.Usage.UserSupplied` for specification details). As with -the preconditioner functions, a pointer to the user-defined -data structure, *user_data*, specified through -:c:func:`ARKStepSetUserData()` (or a ``NULL`` pointer otherwise) is -passed to the Jacobian-times-vector setup and product functions each -time they are called. - .. c:function:: int ARKStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, ARKLsJacTimesVecFn jtimes) @@ -2705,19 +2432,10 @@ time they are called. :c:type:`ARKLsJacTimesVecFn` are described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetJacTimes` instead. -When using the internal difference quotient the user may optionally supply -an alternative implicit right-hand side function for use in the Jacobian-vector -product approximation by calling :c:func:`ARKStepSetJacTimesRhsFn()`. The -alternative implicit right-hand side function should compute a suitable (and -differentiable) approximation to the :math:`f^I` function provided to -:c:func:`ARKStepCreate`. For example, as done in :cite:p:`dorr2010numerical`, -the alternative function may use lagged values when evaluating a nonlinearity -in :math:`f^I` to avoid differencing a potentially non-differentiable factor. -We note that in many instances this same :math:`f^I` routine would also have -been desirable for the nonlinear solver, in which case the user should specify -this through calls to *both* :c:func:`ARKStepSetJacTimesRhsFn()` and -:c:func:`ARKStepSetNlsRhsFn()`. .. c:function:: int ARKStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) @@ -2744,21 +2462,9 @@ this through calls to *both* :c:func:`ARKStepSetJacTimesRhsFn()` and This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKStepSetLinearSolver()`. + .. deprecated:: x.y.z - -Similarly, if a problem involves a non-identity mass matrix, -:math:`M\ne I`, then matrix-free solvers require a *mtimes* function -to compute an approximation to the product between the mass matrix -:math:`M(t)` and a vector :math:`v`. This function must be -user-supplied since there is no default value, it must be -of type :c:func:`ARKLsMassTimesVecFn()`, and can be specified -through a call to the :c:func:`ARKStepSetMassTimes()` routine. -Similarly to the user-supplied preconditioner functions, any evaluation -and processing of any mass matrix-related data needed by the user's -mass-matrix-times-vector function may be done in an optional user-supplied -function of type :c:type:`ARKLsMassTimesSetupFn` (see -:numref:`ARKODE.Usage.UserSupplied` for specification details). - + Use :c:func:`ARKodeSetJacTimesRhsFn` instead. .. c:function:: int ARKStepSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, ARKLsMassTimesVecFn mtimes, void* mtimes_data) @@ -2797,6 +2503,9 @@ function of type :c:type:`ARKLsMassTimesSetupFn` (see :c:type:`ARKLsMassTimesVecFn` are described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMassTimes` instead. @@ -2805,51 +2514,6 @@ function of type :c:type:`ARKLsMassTimesSetupFn` (see Optional inputs for iterative ``SUNLinearSolver`` modules """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.. cssclass:: table-bordered - -==================================================== ========================================= ================== -Optional input Function name Default -==================================================== ========================================= ================== -Newton preconditioning functions :c:func:`ARKStepSetPreconditioner()` ``NULL``, ``NULL`` -Mass matrix preconditioning functions :c:func:`ARKStepSetMassPreconditioner()` ``NULL``, ``NULL`` -Newton linear and nonlinear tolerance ratio :c:func:`ARKStepSetEpsLin()` 0.05 -Mass matrix linear and nonlinear tolerance ratio :c:func:`ARKStepSetMassEpsLin()` 0.05 -Newton linear solve tolerance conversion factor :c:func:`ARKStepSetLSNormFactor()` vector length -Mass matrix linear solve tolerance conversion factor :c:func:`ARKStepSetMassLSNormFactor()` vector length -==================================================== ========================================= ================== - - -As described in :numref:`ARKODE.Mathematics.Linear`, when using -an iterative linear solver the user may supply a preconditioning -operator to aid in solution of the system. This operator consists of -two user-supplied functions, *psetup* and *psolve*, that are supplied -to ARKStep using either the function -:c:func:`ARKStepSetPreconditioner()` (for preconditioning the -Newton system), or the function -:c:func:`ARKStepSetMassPreconditioner()` (for preconditioning the -mass matrix system). The *psetup* function supplied to these routines -should handle evaluation and preprocessing of any Jacobian or -mass-matrix data needed by the user's preconditioner solve function, -*psolve*. The user data pointer received through -:c:func:`ARKStepSetUserData()` (or a pointer to ``NULL`` if user data -was not specified) is passed to the *psetup* and *psolve* functions. -This allows the user to create an arbitrary -structure with relevant problem data and access it during the -execution of the user-supplied preconditioner functions without using -global data in the program. If preconditioning is supplied for both -the Newton and mass matrix linear systems, it is expected that the -user will supply different *psetup* and *psolve* function for each. - -Also, as described in :numref:`ARKODE.Mathematics.Error.Linear`, the -ARKLS interface requires that iterative linear solvers stop when -the norm of the preconditioned residual satisfies - -.. math:: - \|r\| \le \frac{\epsilon_L \epsilon}{10} - -where the default :math:`\epsilon_L = 0.05` may be modified by -the user through the :c:func:`ARKStepSetEpsLin()` function. - .. c:function:: int ARKStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, ARKLsPrecSolveFn psolve) @@ -2882,6 +2546,10 @@ the user through the :c:func:`ARKStepSetEpsLin()` function. :c:func:`ARKLsPrecSolveFn()` are described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetPreconditioner` instead. + .. c:function:: int ARKStepSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, ARKLsMassPrecSolveFn psolve) @@ -2914,6 +2582,9 @@ the user through the :c:func:`ARKStepSetEpsLin()` function. :c:func:`ARKLsMassPrecSolveFn()` are described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMassPreconditioner` instead. .. c:function:: int ARKStepSetEpsLin(void* arkode_mem, sunrealtype eplifac) @@ -2940,6 +2611,9 @@ the user through the :c:func:`ARKStepSetEpsLin()` function. interface has been initialized through a call to :c:func:`ARKStepSetLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetEpsLin` instead. .. c:function:: int ARKStepSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) @@ -2966,20 +2640,9 @@ the user through the :c:func:`ARKStepSetEpsLin()` function. Passing a value *eplifac* :math:`\le 0` indicates to use the default value of 0.05. + .. deprecated:: x.y.z -Since iterative linear solver libraries typically consider linear residual -tolerances using the :math:`L_2` norm, whereas ARKODE focuses on errors -measured in the WRMS norm :eq:`ARKODE_WRMS_NORM`, the ARKLS interface internally -converts between these quantities when interfacing with linear solvers, - -.. math:: - \text{tol}_{L2} = \text{\em nrmfac}\; \text{tol}_{WRMS}. - :label: ARKODE_NRMFAC - -Prior to the introduction of :c:func:`N_VGetLength` in SUNDIALS v5.0.0 the -value of :math:`nrmfac` was computed using the vector dot product. Now, the -functions :c:func:`ARKStepSetLSNormFactor()` and :c:func:`ARKStepSetMassLSNormFactor()` -allow for additional user control over these conversion factors. + Use :c:func:`ARKodeSetMassEpsLin` instead. .. c:function:: int ARKStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) @@ -3009,6 +2672,9 @@ allow for additional user control over these conversion factors. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`ARKStepSetLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLSNormFactor` instead. .. c:function:: int ARKStepSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac) @@ -3038,31 +2704,15 @@ allow for additional user control over these conversion factors. This function must be called *after* the ARKLS mass matrix solver interface has been initialized through a call to :c:func:`ARKStepSetMassLinearSolver()`. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetMassLSNormFactor` instead. -.. _ARKODE.Usage.ARKStep.ARKStepRootfindingInputTable: - Rootfinding optional input functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following functions can be called to set optional inputs to -control the rootfinding algorithm, the mathematics of which are -described in :numref:`ARKODE.Mathematics.Rootfinding`. - - -.. cssclass:: table-bordered - -====================================== ======================================== ================== -Optional input Function name Default -====================================== ======================================== ================== -Direction of zero-crossings to monitor :c:func:`ARKStepSetRootDirection()` both -Disable inactive root warnings :c:func:`ARKStepSetNoInactiveRootWarn()` enabled -====================================== ======================================== ================== - - - .. c:function:: int ARKStepSetRootDirection(void* arkode_mem, int* rootdir) Specifies the direction of zero-crossings to be located and returned. @@ -3085,6 +2735,9 @@ Disable inactive root warnings :c:func:`ARKStepSetNoInactiveRootWarn()` **Notes:** The default behavior is to monitor for both zero-crossing directions. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRootDirection` instead. .. c:function:: int ARKStepSetNoInactiveRootWarn(void* arkode_mem) @@ -3108,7 +2761,9 @@ Disable inactive root warnings :c:func:`ARKStepSetNoInactiveRootWarn()` first step), ARKStep will issue a warning which can be disabled with this optional input function. + .. deprecated:: x.y.z + Use :c:func:`ARKodeSetNoInactiveRootWarn` instead. @@ -3117,19 +2772,6 @@ Disable inactive root warnings :c:func:`ARKStepSetNoInactiveRootWarn()` Interpolated output function -------------------------------- -An optional function :c:func:`ARKStepGetDky()` is available to obtain -additional values of solution-related quantities. This function -should only be called after a successful return from -:c:func:`ARKStepEvolve()`, as it provides interpolated values either of -:math:`y` or of its derivatives (up to the 5th derivative) -interpolated to any value of :math:`t` in the last internal step taken -by :c:func:`ARKStepEvolve()`. Internally, this "dense output" or -"continuous extension" algorithm is identical to the algorithm used for -the maximum order implicit predictors, described in -:numref:`ARKODE.Mathematics.Predictors.Max`, except that derivatives of the -polynomial model may be evaluated upon request. - - .. c:function:: int ARKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) @@ -3168,6 +2810,9 @@ polynomial model may be evaluated upon request. functions :c:func:`ARKStepGetCurrentTime()` and :c:func:`ARKStepGetLastStep()`, respectively. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetDky` instead. @@ -3176,104 +2821,11 @@ polynomial model may be evaluated upon request. Optional output functions ------------------------------ -ARKStep provides an extensive set of functions that can be used to -obtain solver performance information. We organize these into groups: - -#. General ARKStep output routines are in - :numref:`ARKODE.Usage.ARKStep.ARKStepMainOutputs`, -#. ARKStep implicit solver output routines are in - :numref:`ARKODE.Usage.ARKStep.ARKStepImplicitSolverOutputs`, -#. Output routines regarding root-finding results are in - :numref:`ARKODE.Usage.ARKStep.ARKStepRootOutputs`, -#. Linear solver output routines are in - :numref:`ARKODE.Usage.ARKStep.ARKLsOutputs` and -#. General usability routines (e.g. to print the current ARKStep - parameters, or output the current Butcher table(s)) are in - :numref:`ARKODE.Usage.ARKStep.ARKStepExtraOutputs`. - -Following each table, we elaborate on each function. - -Some of the optional outputs, especially the various counters, can be -very useful in determining the efficiency of various methods inside -ARKStep. For example: - -* The counters *nsteps*, *nfe_evals* and *nfi_evals* - provide a rough measure of the overall cost of a given run, and can - be compared between runs with different solver options to suggest - which set of options is the most efficient. - -* The ratio *nniters/nsteps* measures the performance of the - nonlinear iteration in solving the nonlinear systems at each stage, - providing a measure of the degree of nonlinearity in the problem. - Typical values of this for a Newton solver on a general problem - range from 1.1 to 1.8. - -* When using a Newton nonlinear solver, the ratio *njevals/nniters* - (when using a direct linear solver), and the ratio - *nliters/nniters* (when using an iterative linear solver) can - indicate the quality of the approximate Jacobian or preconditioner being - used. For example, if this ratio is larger for a user-supplied - Jacobian or Jacobian-vector product routine than for the - difference-quotient routine, it can indicate that the user-supplied - Jacobian is inaccurate. - -* The ratio *expsteps/accsteps* can measure the quality of the ImEx - splitting used, since a higher-quality splitting will be dominated - by accuracy-limited steps, and hence a lower ratio. - -* The ratio *nsteps/step_attempts* can measure the quality of the - time step adaptivity algorithm, since a poor algorithm will result - in more failed steps, and hence a lower ratio. - -It is therefore recommended that users retrieve and output these -statistics following each run, and take some time to investigate -alternate solver options that will be more optimal for their -particular problem of interest. - - - .. _ARKODE.Usage.ARKStep.ARKStepMainOutputs: Main solver optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. cssclass:: table-bordered - -===================================================== ============================================ -Optional output Function name -===================================================== ============================================ -Size of ARKStep real and integer workspaces :c:func:`ARKStepGetWorkSpace()` -Cumulative number of internal steps :c:func:`ARKStepGetNumSteps()` -Actual initial time step size used :c:func:`ARKStepGetActualInitStep()` -Step size used for the last successful step :c:func:`ARKStepGetLastStep()` -Step size to be attempted on the next step :c:func:`ARKStepGetCurrentStep()` -Current internal time reached by the solver :c:func:`ARKStepGetCurrentTime()` -Current internal solution reached by the solver :c:func:`ARKStepGetCurrentState()` -Current :math:`\gamma` value used by the solver :c:func:`ARKStepGetCurrentGamma()` -Suggested factor for tolerance scaling :c:func:`ARKStepGetTolScaleFactor()` -Error weight vector for state variables :c:func:`ARKStepGetErrWeights()` -Residual weight vector :c:func:`ARKStepGetResWeights()` -Single accessor to many statistics at once :c:func:`ARKStepGetStepStats()` -Print all statistics :c:func:`ARKStepPrintAllStats` -Name of constant associated with a return flag :c:func:`ARKStepGetReturnFlagName()` -No. of explicit stability-limited steps :c:func:`ARKStepGetNumExpSteps()` -No. of accuracy-limited steps :c:func:`ARKStepGetNumAccSteps()` -No. of attempted steps :c:func:`ARKStepGetNumStepAttempts()` -No. of calls to *fe* and *fi* functions :c:func:`ARKStepGetNumRhsEvals()` -No. of local error test failures that have occurred :c:func:`ARKStepGetNumErrTestFails()` -No. of failed steps due to a nonlinear solver failure :c:func:`ARKStepGetNumStepSolveFails()` -Current ERK and DIRK Butcher tables :c:func:`ARKStepGetCurrentButcherTables()` -Estimated local truncation error vector :c:func:`ARKStepGetEstLocalErrors()` -Accumulated temporal error estimation strategy :c:func:`ARKStepSetAccumulatedErrorType()` -Reset accumulated temporal error estimate :c:func:`ARKStepResetAccumulatedError()` -Get accumulated temporal error estimate :c:func:`ARKStepGetAccumulatedError()` -Single accessor to many statistics at once :c:func:`ARKStepGetTimestepperStats()` -Number of constraint test failures :c:func:`ARKStepGetNumConstrFails()` -Retrieve a pointer for user data :c:func:`ARKStepGetUserData` -===================================================== ============================================ - - - .. c:function:: int ARKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) @@ -3288,6 +2840,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetWorkSpace` instead. .. c:function:: int ARKStepGetNumSteps(void* arkode_mem, long int* nsteps) @@ -3303,6 +2858,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumSteps` instead. .. c:function:: int ARKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) @@ -3326,6 +2884,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa local error test condition, or to ensure convergence of the nonlinear solver. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetActualInitStep` instead. .. c:function:: int ARKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) @@ -3341,6 +2902,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLastStep` instead. .. c:function:: int ARKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) @@ -3355,6 +2919,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentStep` instead. .. c:function:: int ARKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) @@ -3369,6 +2936,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentTime` instead. .. c:function:: int ARKStepGetCurrentState(void *arkode_mem, N_Vector *ycur) @@ -3388,6 +2958,10 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa as altering values of *ycur* may lead to undesirable behavior, depending on the particular use case and on when this routine is called. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentState` instead. + .. c:function:: int ARKStepGetCurrentGamma(void *arkode_mem, sunrealtype *gamma) @@ -3402,6 +2976,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentGamma` instead. .. c:function:: int ARKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac) @@ -3418,6 +2995,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetTolScaleFactor` instead. .. c:function:: int ARKStepGetErrWeights(void* arkode_mem, N_Vector eweight) @@ -3436,6 +3016,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa The user must allocate space for *eweight*, that will be filled in by this function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetErrWeights` instead. .. c:function:: int ARKStepGetResWeights(void* arkode_mem, N_Vector rweight) @@ -3454,6 +3037,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa The user must allocate space for *rweight*, that will be filled in by this function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetResWeights` instead. .. c:function:: int ARKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) @@ -3472,6 +3058,10 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetStepStats` instead. + .. c:function:: int ARKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) @@ -3500,8 +3090,12 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa .. versionadded:: 5.2.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodePrintAllStats` instead. + -.. c:function:: char *ARKStepGetReturnFlagName(long int flag) +.. c:function:: char* ARKStepGetReturnFlagName(long int flag) Returns the name of the ARKStep constant corresponding to *flag*. See :ref:`ARKODE.Constants`. @@ -3513,7 +3107,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa The return value is a string containing the name of the corresponding constant. + .. deprecated:: x.y.z + Use :c:func:`ARKodeGetReturnFlagName` instead. @@ -3530,6 +3126,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumExpSteps` instead. .. c:function:: int ARKStepGetNumAccSteps(void* arkode_mem, long int* accsteps) @@ -3545,6 +3144,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumAccSteps` instead. .. c:function:: int ARKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts) @@ -3559,6 +3161,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumStepAttempts` instead. .. c:function:: int ARKStepGetNumRhsEvals(void* arkode_mem, long int* nfe_evals, long int* nfi_evals) @@ -3594,6 +3199,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumErrTestFails` instead. .. c:function:: int ARKStepGetNumStepSolveFails(void* arkode_mem, long int* ncnf) @@ -3608,6 +3216,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumStepSolveFails` instead. .. c:function:: int ARKStepGetCurrentButcherTables(void* arkode_mem, ARKodeButcherTable *Bi, ARKodeButcherTable *Be) @@ -3673,81 +3284,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa failures, the components causing the failures are those with largest values for the products, denoted loosely as ``eweight[i]*ele[i]``. + .. deprecated:: x.y.z - -.. c:function:: int ARKStepSetAccumulatedErrorType(void* arkode_mem, int accum_type) - - Sets the strategy to use for accumulating a temporal error estimate - over multiple time steps. - - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *accum_type* -- accumulation strategy: - - * ``-1`` -- no accumulation (default). - * ``0`` -- maximum accumulation. - * ``1`` -- additive accumulation. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` - - **Notes:** - At each internal step, ARKStep can compute both a solution and embedding - (if coefficients are available), :math:`y_n` and :math:`\tilde{y}_n`, - resulting in a vector-valued local temporal error estimate, :math:`y_n - \tilde{y}_n`. - By default, ARKStep will not accumulate these local error estimates, but - accumulation can be triggered by setting one of two options: - - * ``0`` computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` - - * ``1`` computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`, - - In both cases, the sum or maximum is taken over all steps :math:`n\in N` since the most - recent call to either :c:func:`ARKStepSetAccumulatedErrorType` or - :c:func:`ARKStepResetAccumulatedError`. The norm is taken using the tolerance-informed - error-weight vector (see :c:func:`ARKStepGetErrWeights`), and ``reltol`` is the - user-specified relative solution tolerance. - - Error accumulation can be disabled by calling :c:func:`ARKStepSetAccumulatedErrorType` - with the argument ``-1``. - - .. versionadded:: v.v.v - - -.. c:function:: int ARKStepResetAccumulatedError(void* arkode_mem) - - Resets the accumulated temporal error estimate. - - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` - - .. versionadded:: v.v.v - - -.. c:function:: int ARKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) - - Gets the accumulated temporal error estimate. - - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *accum_error* -- pointer to accumulated error estimate. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` - - **Notes:** - This routine is only useful if a Runge--Kutta method with an embedding is used - by ARKStep. If a non-embedded method is used then this routine will always return - ``*accum_error = 0.0``. - - .. versionadded:: v.v.v - + Use :c:func:`ARKodeGetEstLocalErrors` instead. .. c:function:: int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nfe_evals, long int* nfi_evals, long int* nlinsetups, long int* netfails) @@ -3782,6 +3321,9 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumConstrFails` instead. .. c:function:: int ARKStepGetUserData(void* arkode_mem, void** user_data) @@ -3799,26 +3341,16 @@ Retrieve a pointer for user data :c:func:`ARKStepGetUserDa .. versionadded:: 5.3.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetUserData` instead. + .. _ARKODE.Usage.ARKStep.ARKStepImplicitSolverOutputs: Implicit solver optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. cssclass:: table-bordered - -=================================================== ============================================ -Optional output Function name -=================================================== ============================================ -No. of calls to linear solver setup function :c:func:`ARKStepGetNumLinSolvSetups()` -No. of nonlinear solver iterations :c:func:`ARKStepGetNumNonlinSolvIters()` -No. of nonlinear solver convergence failures :c:func:`ARKStepGetNumNonlinSolvConvFails()` -Single accessor to all nonlinear solver statistics :c:func:`ARKStepGetNonlinSolvStats()` -=================================================== ============================================ - - - - .. c:function:: int ARKStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) Returns the number of calls made to the linear solver's @@ -3836,6 +3368,10 @@ Single accessor to all nonlinear solver statistics :c:func:`ARKStepGetNonlinSo solver object; the counter is reset whenever a new nonlinear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinSolvSetups` instead. + .. c:function:: int ARKStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) @@ -3855,6 +3391,9 @@ Single accessor to all nonlinear solver statistics :c:func:`ARKStepGetNonlinSo solver object; the counter is reset whenever a new nonlinear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumNonlinSolvIters` instead. .. c:function:: int ARKStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nncfails) @@ -3874,6 +3413,9 @@ Single accessor to all nonlinear solver statistics :c:func:`ARKStepGetNonlinSo solver object; the counter is reset whenever a new nonlinear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumNonlinSolvConvFails` instead. .. c:function:: int ARKStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, long int* nncfails) @@ -3894,6 +3436,9 @@ Single accessor to all nonlinear solver statistics :c:func:`ARKStepGetNonlinSo solver object; the counters are reset whenever a new nonlinear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNonlinSolvStats` instead. @@ -3902,17 +3447,6 @@ Single accessor to all nonlinear solver statistics :c:func:`ARKStepGetNonlinSo Rootfinding optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. cssclass:: table-bordered - -=================================================== ========================================== -Optional output Function name -=================================================== ========================================== -Array showing roots found :c:func:`ARKStepGetRootInfo()` -No. of calls to user root function :c:func:`ARKStepGetNumGEvals()` -=================================================== ========================================== - - - .. c:function:: int ARKStepGetRootInfo(void* arkode_mem, int* rootsfound) Returns an array showing which functions were found to @@ -3940,6 +3474,9 @@ No. of calls to user root function :c:func:`ARKStepGetNumGEval zero-crossing. A value of +1 indicates that :math:`g_i` is increasing, while a value of -1 indicates a decreasing :math:`g_i`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetRootInfo` instead. .. c:function:: int ARKStepGetNumGEvals(void* arkode_mem, long int* ngevals) @@ -3955,7 +3492,9 @@ No. of calls to user root function :c:func:`ARKStepGetNumGEval * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + Use :c:func:`ARKodeGetNumGEvals` instead. .. _ARKODE.Usage.ARKStep.ARKLsOutputs: @@ -3963,47 +3502,6 @@ No. of calls to user root function :c:func:`ARKStepGetNumGEval Linear solver interface optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A variety of optional outputs are available from the ARKLS interface, -as listed in the following table and elaborated below. We note that -where the name of an output would otherwise conflict with the -name of an optional output from the main solver, a suffix LS (for -Linear Solver) or MLS (for Mass Linear Solver) has been added here -(e.g. *lenrwLS*). - - - -.. cssclass:: table-bordered - -================================================================= ======================================== -Optional output Function name -================================================================= ======================================== -Stored Jacobian of the ODE RHS function :c:func:`ARKStepGetJac` -Time at which the Jacobian was evaluated :c:func:`ARKStepGetJacTime` -Step number at which the Jacobian was evaluated :c:func:`ARKStepGetJacNumSteps` -Size of real and integer workspaces :c:func:`ARKStepGetLinWorkSpace()` -No. of Jacobian evaluations :c:func:`ARKStepGetNumJacEvals()` -No. of preconditioner evaluations :c:func:`ARKStepGetNumPrecEvals()` -No. of preconditioner solves :c:func:`ARKStepGetNumPrecSolves()` -No. of linear iterations :c:func:`ARKStepGetNumLinIters()` -No. of linear convergence failures :c:func:`ARKStepGetNumLinConvFails()` -No. of Jacobian-vector setup evaluations :c:func:`ARKStepGetNumJTSetupEvals()` -No. of Jacobian-vector product evaluations :c:func:`ARKStepGetNumJtimesEvals()` -No. of *fi* calls for finite diff. :math:`J` or :math:`Jv` evals. :c:func:`ARKStepGetNumLinRhsEvals()` -Last return from a linear solver function :c:func:`ARKStepGetLastLinFlag()` -Name of constant associated with a return flag :c:func:`ARKStepGetLinReturnFlagName()` -Size of real and integer mass matrix solver workspaces :c:func:`ARKStepGetMassWorkSpace()` -No. of mass matrix solver setups (incl. :math:`M` evals.) :c:func:`ARKStepGetNumMassSetups()` -No. of mass matrix multiply setups :c:func:`ARKStepGetNumMassMultSetups()` -No. of mass matrix multiplies :c:func:`ARKStepGetNumMassMult()` -No. of mass matrix solves :c:func:`ARKStepGetNumMassSolves()` -No. of mass matrix preconditioner evaluations :c:func:`ARKStepGetNumMassPrecEvals()` -No. of mass matrix preconditioner solves :c:func:`ARKStepGetNumMassPrecSolves()` -No. of mass matrix linear iterations :c:func:`ARKStepGetNumMassIters()` -No. of mass matrix solver convergence failures :c:func:`ARKStepGetNumMassConvFails()` -No. of mass-matrix-vector setup evaluations :c:func:`ARKStepGetNumMTSetups()` -Last return from a mass matrix solver function :c:func:`ARKStepGetLastMassFlag()` -================================================================= ======================================== - .. c:function:: int ARKStepGetJac(void* arkode_mem, SUNMatrix* J) Returns the internally stored copy of the Jacobian matrix of the ODE @@ -4021,6 +3519,11 @@ Last return from a mass matrix solver function :c:func:`ARKS This function is provided for debugging purposes and the values in the returned matrix should not be altered. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetJac` instead. + + .. c:function:: int ARKStepGetJacTime(void* arkode_mem, sunrealtype* t_J) Returns the time at which the internally stored copy of the Jacobian matrix @@ -4033,6 +3536,11 @@ Last return from a mass matrix solver function :c:func:`ARKS :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL`` :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetJacTime` instead. + + .. c:function:: int ARKStepGetJacNumSteps(void* arkode_mem, long int* nst_J) Returns the value of the internal step counter at which the internally stored copy of the @@ -4045,6 +3553,11 @@ Last return from a mass matrix solver function :c:func:`ARKS :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL`` :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetJacNumSteps` instead. + + .. c:function:: int ARKStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) Returns the real and integer workspace used by the ARKLS linear solver interface. @@ -4069,6 +3582,10 @@ Last return from a mass matrix solver function :c:func:`ARKS In a parallel setting, the above values are global (i.e. summed over all processors). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLinWorkSpace` instead. + .. c:function:: int ARKStepGetNumJacEvals(void* arkode_mem, long int* njevals) @@ -4087,6 +3604,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumJacEvals` instead. + .. c:function:: int ARKStepGetNumPrecEvals(void* arkode_mem, long int* npevals) @@ -4107,6 +3628,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumPrecEvals` instead. + .. c:function:: int ARKStepGetNumPrecSolves(void* arkode_mem, long int* npsolves) @@ -4126,6 +3651,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumPrecSolves` instead. + .. c:function:: int ARKStepGetNumLinIters(void* arkode_mem, long int* nliters) @@ -4144,6 +3673,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinIters` instead. + .. c:function:: int ARKStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails) @@ -4162,6 +3695,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinConvFails` instead. + .. c:function:: int ARKStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetup) @@ -4181,6 +3718,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumJTSetupEvals` instead. + .. c:function:: int ARKStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals) @@ -4200,6 +3741,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumJtimesEvals` instead. + .. c:function:: int ARKStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) @@ -4225,6 +3770,10 @@ Last return from a mass matrix solver function :c:func:`ARKS solver object; the counter is reset whenever a new linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinRhsEvals` instead. + .. c:function:: int ARKStepGetLastLinFlag(void* arkode_mem, long int* lsflag) @@ -4276,8 +3825,12 @@ Last return from a mass matrix solver function :c:func:`ARKS *SUN_ERR_EXT_FAIL*, indicating an unrecoverable failure in an external iterative linear solver package. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLastLinFlag` instead. + -.. c:function:: char *ARKStepGetLinReturnFlagName(long int lsflag) +.. c:function:: char* ARKStepGetLinReturnFlagName(long int lsflag) Returns the name of the ARKLS constant corresponding to *lsflag*. @@ -4289,6 +3842,9 @@ Last return from a mass matrix solver function :c:func:`ARKS ``SUNLINSOL_BAND`` modules, then if 1 :math:`\le` `lsflag` :math:`\le n` (LU factorization failed), this routine returns "NONE". + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLinReturnFlagName` instead. @@ -4316,6 +3872,10 @@ Last return from a mass matrix solver function :c:func:`ARKS In a parallel setting, the above values are global (i.e. summed over all processors). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetMassWorkSpace` instead. + .. c:function:: int ARKStepGetNumMassSetups(void* arkode_mem, long int* nmsetups) @@ -4337,6 +3897,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassSetups` instead. + .. c:function:: int ARKStepGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups) @@ -4357,6 +3921,11 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassMultSetups` instead. + + .. c:function:: int ARKStepGetNumMassMult(void* arkode_mem, long int* nmmults) Returns the number of calls made to the ARKLS mass matrix 'matvec' @@ -4377,6 +3946,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassMult` instead. + .. c:function:: int ARKStepGetNumMassSolves(void* arkode_mem, long int* nmsolves) @@ -4396,6 +3969,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassSolves` instead. + .. c:function:: int ARKStepGetNumMassPrecEvals(void* arkode_mem, long int* nmpevals) @@ -4416,6 +3993,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassPrecEvals` instead. + .. c:function:: int ARKStepGetNumMassPrecSolves(void* arkode_mem, long int* nmpsolves) @@ -4436,6 +4017,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassPrecSolves` instead. + .. c:function:: int ARKStepGetNumMassIters(void* arkode_mem, long int* nmiters) @@ -4455,6 +4040,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassIters` instead. + .. c:function:: int ARKStepGetNumMassConvFails(void* arkode_mem, long int* nmcfails) @@ -4474,6 +4063,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMassConvFails` instead. + .. c:function:: int ARKStepGetNumMTSetups(void* arkode_mem, long int* nmtsetup) @@ -4494,6 +4087,10 @@ Last return from a mass matrix solver function :c:func:`ARKS linear solver module is "attached" to ARKStep, or when ARKStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumMTSetups` instead. + .. c:function:: int ARKStepGetLastMassFlag(void* arkode_mem, long int* mlsflag) @@ -4514,7 +4111,9 @@ Last return from a mass matrix solver function :c:func:`ARKS will match those described above for the function :c:func:`ARKStepGetLastLinFlag()`. + .. deprecated:: x.y.z + Use :c:func:`ARKodeGetLastMassFlag` instead. @@ -4523,24 +4122,6 @@ Last return from a mass matrix solver function :c:func:`ARKS General usability functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following optional routines may be called by a user to inquire -about existing solver parameters or write the current Butcher table(s). While -neither of these would typically be called during the course of solving an -initial value problem, they may be useful for users wishing to better -understand ARKStep and/or specific Runge--Kutta methods. - - -.. cssclass:: table-bordered - -===================================== =================================== -Optional routine Function name -===================================== =================================== -Output all ARKStep solver parameters :c:func:`ARKStepWriteParameters()` -Output the current Butcher table(s) :c:func:`ARKStepWriteButcher()` -===================================== =================================== - - - .. c:function:: int ARKStepWriteParameters(void* arkode_mem, FILE *fp) @@ -4562,6 +4143,10 @@ Output the current Butcher table(s) :c:func:`ARKStepWriteButcher()` for this pointer, since parameters for all processes would be identical. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeWriteParameters` instead. + .. c:function:: int ARKStepWriteButcher(void* arkode_mem, FILE *fp) @@ -4587,8 +4172,10 @@ Output the current Butcher table(s) :c:func:`ARKStepWriteButcher()` for this pointer, since tables for all processes would be identical. + .. deprecated:: x.y.z - + Use :c:func:`ARKStepGetCurrentButcherTables` and :c:func:`ARKodeButcherTable_Write` + instead. @@ -4682,44 +4269,6 @@ vector. ARKStep reset function ---------------------- -To reset the ARKStep module to a particular state :math:`(t_R,y(t_R))` for the -continued solution of a problem, where a prior -call to :c:func:`ARKStepCreate` has been made, the user must call the function -:c:func:`ARKStepReset()`. Like :c:func:`ARKStepReInit()` this routine retains -the current settings for all ARKStep module options and performs no memory -allocations but, unlike :c:func:`ARKStepReInit()`, this routine performs only a -*subset* of the input checking and initializations that are done in -:c:func:`ARKStepCreate`. In particular this routine retains all internal -counter values and the step size/error history and does not reinitialize the -linear and/or nonlinear solver but it does indicate that a linear solver setup -is necessary in the next step. Like :c:func:`ARKStepReInit()`, a call to -:c:func:`ARKStepReset()` will delete any previously-set *tstop* value specified -via a call to :c:func:`ARKStepSetStopTime()`. Following a successful call to -:c:func:`ARKStepReset()`, call :c:func:`ARKStepEvolve()` again to continue -solving the problem. By default the next call to :c:func:`ARKStepEvolve()` will -use the step size computed by ARKStep prior to calling :c:func:`ARKStepReset()`. -To set a different step size or have ARKStep estimate a new step size use -:c:func:`ARKStepSetInitStep()`. - -One important use of the :c:func:`ARKStepReset()` function is in the -treating of jump discontinuities in the RHS functions. Except in cases -of fairly small jumps, it is usually more efficient to stop at each -point of discontinuity and restart the integrator with a readjusted -ODE model, using a call to :c:func:`ARKStepReset()`. To stop when -the location of the discontinuity is known, simply make that location -a value of ``tout``. To stop when the location of the discontinuity -is determined by the solution, use the rootfinding feature. In either -case, it is critical that the RHS functions *not* incorporate the -discontinuity, but rather have a smooth extension over the -discontinuity, so that the step across it (and subsequent rootfinding, -if used) can be done efficiently. Then use a switch within the RHS -functions (communicated through ``user_data``) that can be flipped -between the stopping of the integration and the restart, so that the -restarted problem uses the new values (which have jumped). Similar -comments apply if there is to be a jump in the dependent variable -vector. - - .. c:function:: int ARKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) Resets the current ARKStep time-stepper module state to the provided @@ -4748,6 +4297,9 @@ vector. If an error occurred, :c:func:`ARKStepReset()` also sends an error message to the error handler function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeReset` instead. @@ -4756,36 +4308,6 @@ vector. ARKStep system resize function ------------------------------------- -For simulations involving changes to the number of equations and -unknowns in the ODE system (e.g. when using spatially-adaptive -PDE simulations under a method-of-lines approach), the ARKStep -integrator may be "resized" between integration steps, through calls -to the :c:func:`ARKStepResize()` function. This function modifies -ARKStep's internal memory structures to use the new problem size, -without destruction of the temporal adaptivity heuristics. It is -assumed that the dynamical time scales before and after the vector -resize will be comparable, so that all time-stepping heuristics prior -to calling :c:func:`ARKStepResize()` remain valid after the call. If -instead the dynamics should be recomputed from scratch, the ARKStep -memory structure should be deleted with a call to -:c:func:`ARKStepFree()`, and recreated with a calls to -:c:func:`ARKStepCreate`. - -To aid in the vector resize operation, the user can supply a vector -resize function that will take as input a vector with the previous -size, and transform it in-place to return a corresponding vector of -the new size. If this function (of type :c:func:`ARKVecResizeFn()`) -is not supplied (i.e., is set to ``NULL``), then all existing vectors -internal to ARKStep will be destroyed and re-cloned from the new input -vector. - -In the case that the dynamical time scale should be modified slightly -from the previous time scale, an input *hscale* is allowed, that will -rescale the upcoming time step by the specified factor. If a value -*hscale* :math:`\le 0` is specified, the default of 1.0 will be used. - - - .. c:function:: int ARKStepResize(void* arkode_mem, N_Vector yR, sunrealtype hscale, sunrealtype tR, ARKVecResizeFn resize, void* resize_data) Re-sizes ARKStep with a different state vector but with comparable @@ -4853,6 +4375,10 @@ rescale the upcoming time step by the specified factor. If a value **Example codes:** * ``examples/arkode/C_serial/ark_heat1D_adapt.c`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeResize` instead. + .. _ARKStep_CInterface.MRIStepInterface: diff --git a/doc/arkode/guide/source/Usage/ARKStep_c_interface/XBraid.rst b/doc/arkode/guide/source/Usage/ARKStep_c_interface/XBraid.rst index ffc80e5901..24633e9fb4 100644 --- a/doc/arkode/guide/source/Usage/ARKStep_c_interface/XBraid.rst +++ b/doc/arkode/guide/source/Usage/ARKStep_c_interface/XBraid.rst @@ -17,13 +17,13 @@ Multigrid Reduction in Time with XBraid ======================================= -The prior sections discuss using ARKStep in a traditional sequential +The prior sections discuss using ARKODE in a traditional sequential time integration setting i.e., the solution is advanced from one time to the next where all parallelism resides within the evaluation of a step e.g., the computation of the right-hand side, (non)linear solves, vector operations etc. For example, when discretizing a partial differential equation using a method of lines approach the spatially-discretized equations comprise a large set -of ordinary differential equations that can be evolved with ARKStep. In this +of ordinary differential equations that can be evolved with ARKODE. In this case the parallelization lies in decomposing the spatial domain unknowns across distributed computational nodes. Considering the strong scaling case at a given spatial resolution, as the problem is spread across greater numbers of @@ -54,9 +54,9 @@ multilevel algorithm. The XBraid library :cite:p:`xbraid` implements the MGRIT algorithm in a non-intrusive manner, enabling the reuse of existing software for sequential -time integration. The following sections describe the ARKStep + XBraid interface -and the steps necessary to modify an existing code that already uses ARKStep to -also use XBraid. +time integration. The following sections describe the ARKODE + XBraid interface +and the steps necessary to modify an existing code that already uses ARKODE's +ARKStep time-stepping module to also use XBraid. @@ -65,7 +65,7 @@ also use XBraid. SUNBraid Interface ------------------ -Interfacing ARKStep with XBraid requires defining two data structures. The +Interfacing ARKODE with XBraid requires defining two data structures. The first is the XBraid application data structure that contains the data necessary for carrying out a time step and is passed to every interface function (much like the user data pointer in SUNDIALS packages). For this structure the @@ -79,9 +79,9 @@ operations (e.g., computing vector sums or norms) as well as functions to initialize the problem state, access the current solution, and take a time step. The ARKBraid interface, built on the SUNBraidApp and SUNBraidVector structures, -provides all the functionaly needed combine ARKStep and XBraid for +provides all the functionaly needed combine ARKODE and XBraid for parallel-in-time integration. As such, only a minimal number of changes are -necessary to update an exsting code that uses ARKStep to also use XBraid. +necessary to update an exsting code that uses ARKODE to also use XBraid. @@ -156,25 +156,21 @@ example usage of the function. This function returns a vector to use as a template for creating new vectors with :c:func:`N_VClone()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *y* -- output, the template vector. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param y: output, the template vector. - **Return value:** - If this function is not implemented by the SUNBraidApp - implementation (i.e., the function pointer is ``NULL``) then this function - will return *SUNBRAID_OPNULL*. Otherwise the return value depends on the - particular SUNBraidApp implementation. Users are encouraged to utilize the - return codes defined in ``sundials/sundials_xbraid.h`` and listed in - :numref:`ARKODE.Usage.ARKStep.SUNBraidReturnCodes.Table`. + :return: If this function is not implemented by the SUNBraidApp + implementation (i.e., the function pointer is ``NULL``) then this function + will return *SUNBRAID_OPNULL*. Otherwise the return value depends on the + particular SUNBraidApp implementation. Users are encouraged to utilize the + return codes defined in ``sundials/sundials_xbraid.h`` and listed in + :numref:`ARKODE.Usage.ARKStep.SUNBraidReturnCodes.Table`. - **Usage:** + .. code-block:: C - .. code-block:: C - - /* Get template vector */ - flag = SUNBraidApp_GetVecTmpl(app, y_ptr); - if (flag != SUNBRAID_SUCCESS) return flag; + /* Get template vector */ + flag = SUNBraidApp_GetVecTmpl(app, y_ptr); + if (flag != SUNBRAID_SUCCESS) return flag; @@ -192,20 +188,16 @@ instance. This function creates a new SUNBraidApp instance with the content and operations initialized to ``NULL``. - **Arguments:** - * *app* -- output, an empty SUNBraidApp instance (XBraid app structure). - - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ALLOCFAIL* if a memory allocation failed. + :param app: output, an empty SUNBraidApp instance (XBraid app structure). - **Usage:** + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ALLOCFAIL: if a memory allocation failed. - .. code-block:: C + .. code-block:: C - /* Create empty XBraid interface object */ - flag = SUNBraidApp_NewEmpty(app_ptr); - if (flag != SUNBRAID_SUCCESS) return flag; + /* Create empty XBraid interface object */ + flag = SUNBraidApp_NewEmpty(app_ptr); + if (flag != SUNBRAID_SUCCESS) return flag; @@ -213,18 +205,14 @@ instance. This function destroys an empty SUNBraidApp instance. - **Arguments:** - * *app* -- input, an empty SUNBraidApp instance (XBraid app structure). + :param app: input, an empty SUNBraidApp instance (XBraid app structure). - **Return value:** - * *SUNBRAID_SUCCESS* if successful. + :retval SUNBRAID_SUCCESS: if successful. - **Usage:** + .. code-block:: C - .. code-block:: C - - /* Free empty XBraid interface object */ - flag = SUNBraidApp_FreeEmpty(app_ptr); + /* Free empty XBraid interface object */ + flag = SUNBraidApp_FreeEmpty(app_ptr); .. warning:: @@ -263,22 +251,18 @@ utility functions are provided. This function creates a new SUNBraidVector wrapping the N_Vector y. - **Arguments:** - * *y* -- input, the N_Vector to wrap. - * *u* -- output, the SUNBraidVector wrapping *y*. - - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *y* is ``NULL``. - * *SUNBRAID_ALLOCFAIL* if a memory allocation fails. + :param y: input, the N_Vector to wrap. + :param u: output, the SUNBraidVector wrapping *y*. - **Usage:** + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *y* is ``NULL``. + :retval SUNBRAID_ALLOCFAIL: if a memory allocation fails. - .. code-block:: C + .. code-block:: C - /* Create new vector wrapper */ - flag = SUNBraidVector_New(y, u_ptr); - if (flag != SUNBRAID_SUCCESS) return flag; + /* Create new vector wrapper */ + flag = SUNBraidVector_New(y, u_ptr); + if (flag != SUNBRAID_SUCCESS) return flag; .. warning:: @@ -292,22 +276,18 @@ utility functions are provided. This function retrieves the wrapped N_Vector from the SUNBraidVector. - **Arguments:** - * *u* -- input, the SUNBraidVector wrapping *y*. - * *y* -- output, the wrapped N_Vector. + :param u: input, the SUNBraidVector wrapping *y*. + :param y: output, the wrapped N_Vector. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *u* is ``NULL``. - * *SUNBRAID_MEMFAIL* if *y* is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *u* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if *y* is ``NULL``. - **Usage:** + .. code-block:: C - .. code-block:: C - - /* Create new vector wrapper */ - flag = SUNBraidVector_GetNVector(u, y_ptr); - if (flag != SUNBRAID_SUCCESS) return flag; + /* Create new vector wrapper */ + flag = SUNBraidVector_GetNVector(u, y_ptr); + if (flag != SUNBRAID_SUCCESS) return flag; @@ -321,16 +301,14 @@ N_Vector operations. values of the input vector *u* into the output vector *v_ptr* using :c:func:`N_VClone()` and :c:func:`N_VScale()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *u* -- input, the SUNBraidVector to clone. - * *v_ptr* -- output, the new SUNBraidVector. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param u: input, the SUNBraidVector to clone. + :param v_ptr: output, the new SUNBraidVector. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *u* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the N_Vector *y* wrapped by *u* is ``NULL``. - * *SUNBRAID_ALLOCFAIL* if a memory allocation fails. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *u* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the N_Vector *y* wrapped by *u* is ``NULL``. + :retval SUNBRAID_ALLOCFAIL: if a memory allocation fails. @@ -339,12 +317,10 @@ N_Vector operations. This function destroys the SUNBraidVector and the wrapped N_Vector using :c:func:`N_VDestroy()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *u* -- input, the SUNBraidVector to destroy. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param u: input, the SUNBraidVector to destroy. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. + :retval SUNBRAID_SUCCESS: if successful. @@ -353,17 +329,15 @@ N_Vector operations. This function computes the vector sum :math:`\alpha x + \beta y \rightarrow y` using :c:func:`N_VLinearSum()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *alpha* -- input, the constant :math:`\alpha`. - * *x* -- input, the vector :math:`x`. - * *beta* -- input, the constant :math:`\beta`. - * *y* -- input/output, the vector :math:`y`. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param alpha: input, the constant :math:`\alpha`. + :param x: input, the vector :math:`x`. + :param beta: input, the constant :math:`\beta`. + :param y: input/output, the vector :math:`y`. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *x* or *y* is ``NULL``. - * *SUNBRAID_MEMFAIL* if either of the wrapped N_Vectors are ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *x* or *y* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if either of the wrapped N_Vectors are ``NULL``. @@ -372,15 +346,13 @@ N_Vector operations. This function computes the 2-norm of the vector *u* using :c:func:`N_VDotProd()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *u* -- input, the vector *u*. - * *norm_ptr* -- output, the L2 norm of *u*. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param u: input, the vector *u*. + :param norm_ptr: output, the L2 norm of *u*. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *u* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the wrapped N_Vector is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *u* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the wrapped N_Vector is ``NULL``. @@ -389,16 +361,14 @@ N_Vector operations. This function returns the buffer size for messages to exchange vector data using :c:func:`SUNBraidApp_GetVecTmpl` and :c:func:`N_VBufSize()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *size_ptr* -- output, the buffer size. - * *bstatus* -- input, a status object to query for information on the message - type. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param size_ptr: output, the buffer size. + :param bstatus: input, a status object to query for information on the message + type. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * An error flag from :c:func:`SUNBraidApp_GetVecTmpl` or - :c:func:`N_VBufSize()`. + :retval SUNBRAID_SUCCESS: if successful + :retval otherwise: an error flag from :c:func:`SUNBraidApp_GetVecTmpl` + or :c:func:`N_VBufSize()`. @@ -407,17 +377,15 @@ N_Vector operations. This function packs the message buffer for exchanging vector data using :c:func:`N_VBufPack()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *u* -- input, the vector to pack into the exchange buffer. - * *buffer* -- output, the packed exchange buffer to pack. - * *bstatus* -- input, a status object to query for information on the message - type. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param u: input, the vector to pack into the exchange buffer. + :param buffer: output, the packed exchange buffer to pack. + :param bstatus: input, a status object to query for information on the message + type. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *u* is ``NULL``. - * An error flag from :c:func:`N_VBufPack()`. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *u* is ``NULL``. + :retval otherwise: An error flag from :c:func:`N_VBufPack()`. @@ -427,19 +395,17 @@ N_Vector operations. SUNBraidVector with the buffer data using :c:func:`N_VBufUnpack()`, :c:func:`SUNBraidApp_GetVecTmpl`, and :c:func:`N_VClone()`. - **Arguments:** - * *app* -- input, a SUNBraidApp instance (XBraid app structure). - * *buffer* -- input, the exchange buffer to unpack. - * *u_ptr* -- output, a new SUNBraidVector containing the buffer data. - * *bstatus* -- input, a status object to query for information on the message - type. + :param app: input, a SUNBraidApp instance (XBraid app structure). + :param buffer: input, the exchange buffer to unpack. + :param u_ptr: output, a new SUNBraidVector containing the buffer data. + :param bstatus: input, a status object to query for information on the message + type. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *buffer* is ``NULL``. - * *SUNBRAID_ALLOCFAIL* if a memory allocation fails. - * An error flag from :c:func:`SUNBraidApp_GetVecTmpl` and - :c:func:`N_VBufUnpack()`. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *buffer* is ``NULL``. + :retval SUNBRAID_ALLOCFAIL: if a memory allocation fails. + :retval otherwise: an error flag from :c:func:`SUNBraidApp_GetVecTmpl` and + :c:func:`N_VBufUnpack()`. @@ -480,9 +446,9 @@ ARKBraid Interface ------------------ This section describes the ARKBraid implementation of a SUNBraidApp for using -the ARKStep integration module with XBraid. The following section +the ARKODE's ARKStep time-stepping module with XBraid. The following section :numref:`ARKODE.Usage.ARKStep.ARKBraid_InitDealloc` describes routines for creating, -initializing, and destroying the ARKStep + XBraid interface, routines for +initializing, and destroying the ARKODE + XBraid interface, routines for setting optional inputs, and routines for retrieving data from an ARKBraid instance. As noted above, interfacing with XBraid requires providing functions to initialize the problem state, access the current solution, and take a time @@ -490,7 +456,7 @@ step. The default ARKBraid functions for each of these actions are defined in :n user-defined if desired. A skeleton of the user's main or calling program for using the ARKBraid interface is given in :numref:`ARKODE.Usage.ARKStep.ARKBraid_Skeleton`. Finally, for advanced users that -wish to create their own SUNBraidApp implementation using ARKStep, +wish to create their own SUNBraidApp implementation using ARKODE, :numref:`ARKODE.Usage.ARKStep.ARKBraid_Utility` describes some helpful functions available to the user. @@ -515,20 +481,19 @@ if an error occurred. The possible return codes are given in private ARKBraid interface structure, and attaches the necessary SUNBraidOps implementations. - **Arguments:** - * *arkode_mem* -- input, a pointer to an ARKStep memory structure. - * *app* -- output, an ARKBraid instance (XBraid app structure). + :param arkode_mem: input, a pointer to an ARKODE memory structure. + :param app: output, an ARKBraid instance (XBraid app structure). - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* *arkode_mem* is ``NULL``. - * *SUNBRAID_ALLOCFAIL* if a memory allocation failed. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: *arkode_mem* is ``NULL``. + :retval SUNBRAID_ALLOCFAIL: if a memory allocation failed. .. warning:: The ARKBraid interface is ARKStep-specific. Although one could eventually - construct an XBraid interface to either ERKStep or MRIStep, those are not - supported by this implementation. + construct an XBraid interface to other of ARKODE time-stepping modules + (e.g., ERKStep or MRIStep), those are not currently supported by this + implementation. @@ -538,21 +503,19 @@ if an error occurred. The possible return codes are given in XBraid core memory structure and initializes XBraid with the ARKBraid and SUNBraidVector interface functions. - **Arguments:** - * *comm_w* -- input, the global MPI communicator for space and time. - * *comm_t* -- input, the MPI communicator for the time dimension. - * *tstart* -- input, the initial time value. - * *tstop* -- input, the final time value. - * *ntime* -- input, the initial number of grid points in time. - * *app* -- input, an ARKBraid instance. - * *core* -- output, the XBraid core memory structure. - - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if either MPI communicator is ``MPI_COMM_NULL``, - if *ntime* < 2, or if *app* or its content is ``NULL``. - * *SUNBRAID_BRAIDFAIL* if the ``braid_Init()`` call fails. The XBraid return - value can be retrieved with :c:func:`ARKBraid_GetLastBraidFlag()`. + :param comm_w: input, the global MPI communicator for space and time. + :param comm_t: input, the MPI communicator for the time dimension. + :param tstart: input, the initial time value. + :param tstop: input, the final time value. + :param ntime: input, the initial number of grid points in time. + :param app: input, an ARKBraid instance. + :param core: output, the XBraid core memory structure. + + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if either MPI communicator is ``MPI_COMM_NULL``, + if *ntime* < 2, or if *app* or its content is ``NULL``. + :retval SUNBRAID_BRAIDFAIL: if the ``braid_Init()`` call fails. The XBraid return + value can be retrieved with :c:func:`ARKBraid_GetLastBraidFlag()`. .. note:: @@ -572,11 +535,9 @@ if an error occurred. The possible return codes are given in This function deallocates an ARKBraid instance. - **Arguments:** - * *app* -- input, a pointer to an ARKBraid instance. + :param app: input, a pointer to an ARKBraid instance. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. + :retval SUNBRAID_SUCCESS: if successful. @@ -599,15 +560,13 @@ error occurred. The possible return codes are given in This function sets the step function provided to XBraid (default :c:func:`ARKBraid_Step()`). - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *step* -- input, an XBraid step function. If *step* is ``NULL``, the - default function will be used. + :param app: input, an ARKBraid instance. + :param step: input, an XBraid step function. If *step* is ``NULL``, the + default function will be used. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. .. note:: @@ -620,15 +579,13 @@ error occurred. The possible return codes are given in This function sets the vector initialization function provided to XBraid (default :c:func:`ARKBraid_Init()`). - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *init* -- input, an XBraid vector initialization function. If *init* is - ``NULL``, the default function will be used. + :param app: input, an ARKBraid instance. + :param init: input, an XBraid vector initialization function. If *init* is + ``NULL``, the default function will be used. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. .. note:: @@ -641,15 +598,13 @@ error occurred. The possible return codes are given in This function sets the spatial norm function provided to XBraid (default :c:func:`SUNBraidVector_SpatialNorm()`). - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *snorm* -- input, an XBraid spatial norm function. If *snorm* is ``NULL``, - the default function will be used. + :param app: input, an ARKBraid instance. + :param snorm: input, an XBraid spatial norm function. If *snorm* is ``NULL``, + the default function will be used. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. .. note:: @@ -662,15 +617,13 @@ error occurred. The possible return codes are given in This function sets the user access function provided to XBraid (default :c:func:`ARKBraid_Access()`). - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *init* -- input, an XBraid user access function. If *access* is ``NULL``, - the default function will be used. + :param app: input, an ARKBraid instance. + :param init: input, an XBraid user access function. If *access* is ``NULL``, + the default function will be used. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. .. note:: @@ -693,18 +646,30 @@ error occurred. The possible return codes are given in .. c:function:: int ARKBraid_GetVecTmpl(braid_App app, N_Vector *tmpl) - This function returns a vector from the ARKStep memory to use as a template + This function returns a vector from the ARKODE memory to use as a template for creating new vectors with :c:func:`N_VClone()` i.e., this is the ARKBraid implementation of :c:func:`SUNBraidApp_GetVecTmpl()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *tmpl* -- output, a template vector. + :param app: input, an ARKBraid instance. + :param tmpl: output, a template vector. + + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or ARKODE memory is ``NULL``. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content or ARKStep memory is ``NULL``. + + +.. c:function:: int ARKBraid_GetARKodeMem(braid_App app, void **arkode_mem) + + This function returns the ARKODE memory structure pointer attached with + :c:func:`ARKBraid_Create()`. + + :param app: input, an ARKBraid instance. + :param arkode_mem: output, a pointer to the ARKODE memory structure. + + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or ARKODE memory is ``NULL``. @@ -713,30 +678,29 @@ error occurred. The possible return codes are given in This function returns the ARKStep memory structure pointer attached with :c:func:`ARKBraid_Create()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *arkode_mem* -- output, a pointer to the ARKStep memory structure. + :param app: input, an ARKBraid instance. + :param arkode_mem: output, a pointer to the ARKStep memory structure. + + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or ARKStep memory is ``NULL``. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content or ARKStep memory is ``NULL``. + .. deprecated:: x.y.z + Use :c:func:`ARKBraid_GetARKodeMem` instead. .. c:function:: int ARKBraid_GetUserData(braid_App app, void **user_data) This function returns the user data pointer attached with - :c:func:`ARKStepSetUserData()`. + :c:func:`ARKodeSetUserData()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *user_data* -- output, a pointer to the user data structure. + :param app: input, an ARKBraid instance. + :param user_data: output, a pointer to the user data structure. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content or ARKStep memory is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or ARKODE memory is ``NULL``. @@ -745,14 +709,26 @@ error occurred. The possible return codes are given in This function returns the return value from the most recent XBraid function call. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *last_flag* -- output, the XBraid return value. + :param app: input, an ARKBraid instance. + :param last_flag: output, the XBraid return value. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. + + + +.. c:function:: int ARKBraid_GetLastARKodeFlag(braid_App app, int *last_flag) + + This function returns the return value from the most recent ARKODE function + call. + + :param app: input, an ARKBraid instance. + :param last_flag: output, the ARKODE return value. + + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. @@ -761,14 +737,16 @@ error occurred. The possible return codes are given in This function returns the return value from the most recent ARKStep function call. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *last_flag* -- output, the ARKStep return value. + :param app: input, an ARKBraid instance. + :param last_flag: output, the ARKStep return value. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content is ``NULL``. + + .. deprecated:: x.y.z + + Use :c:func:`ARKBraid_GetLastARKodeFlag` instead. .. c:function:: int ARKBraid_GetSolution(braid_App app, sunrealtype *tout, N_Vector yout) @@ -776,22 +754,20 @@ error occurred. The possible return codes are given in This function returns final time and state stored with the default access function :c:func:`ARKBraid_Access()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *last_flag* -- output, the ARKStep return value. + :param app: input, an ARKBraid instance. + :param last_flag: output, the ARKODE return value. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content or the stored vector is ``NULL``. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or the stored vector is ``NULL``. .. warning:: If providing a non-default access function the final time and state are not stored within the ARKBraid structure and this function will return an error. In this case the user should allocate space to store any desired - output within the user data pointer attached to ARKStep with - :c:func:`ARKStepSetUserData()`. This user data pointer can be retrieved + output within the user data pointer attached to ARKODE with + :c:func:`ARKodeSetUserData()`. This user data pointer can be retrieved from the ARKBraid structure with :c:func:`ARKBraid_GetUserData()`. @@ -819,23 +795,21 @@ in :numref:`ARKODE.Usage.ARKStep.SUNBraidReturnCodes.Table`. the ARStep memory structure provided to :c:func:`ARKBraid_Create()`. A user-defined step function may be set with :c:func:`ARKBraid_SetStepFn()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *ustop* -- input, *u* vector at the new time *tstop*. - * *fstop* -- input, the right-hand side vector at the new time *tstop*. - * *u* - input/output, on input the vector at the start time and on return the - vector at the new time. - * *status* -- input, a status object to query for information about *u* and - to steer XBraid e.g., for temporal refinement. - - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content or ARKStep memory is ``NULL``. - * *SUNBRAID_BRAIDFAIL* if an XBraid function fails. The return value can be - retrieved with :c:func:`ARKBraid_GetLastBraidFlag()`. - * *SUNBRAID_SUNFAIL* if a SUNDIALS function fails. The return value can be - retrieved with :c:func:`ARKBraid_GetLastARKStepFlag()`. + :param app: input, an ARKBraid instance. + :param ustop: input, *u* vector at the new time *tstop*. + :param fstop: input, the right-hand side vector at the new time *tstop*. + :param u: input/output, on input the vector at the start time and on return the + vector at the new time. + :param status: input, a status object to query for information about *u* and + to steer XBraid e.g., for temporal refinement. + + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or ARKODE memory is ``NULL``. + :retval SUNBRAID_BRAIDFAIL: if an XBraid function fails. The return value can be + retrieved with :c:func:`ARKBraid_GetLastBraidFlag()`. + :retval SUNBRAID_SUNFAIL: if a SUNDIALS function fails. The return value can be + retrieved with :c:func:`ARKBraid_GetLastARKStepFlag()`. .. note:: @@ -854,16 +828,14 @@ in :numref:`ARKODE.Usage.ARKStep.SUNBraidReturnCodes.Table`. provided to :c:func:`ARKStepCreate`. A user-defined init function may be set with :c:func:`ARKBraid_SetInitFn()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *t* -- input, the initialization time for the output vector. - * *u_ptr* -- output, the new and initialized SUNBraidVector. + :param app: input, an ARKBraid instance. + :param t: input, the initialization time for the output vector. + :param u_ptr: output, the new and initialized SUNBraidVector. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if *app* is ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content or ARKStep memory is ``NULL``. - * *SUNBRAID_ALLOCFAIL* if a memory allocation failed. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if *app* is ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content or ARKODE memory is ``NULL``. + :retval SUNBRAID_ALLOCFAIL: if a memory allocation failed. .. note:: @@ -883,19 +855,17 @@ in :numref:`ARKODE.Usage.ARKStep.SUNBraidReturnCodes.Table`. :c:func:`ARKBraid_GetSolution()`. A user-defined access function may be set with :c:func:`ARKBraid_SetAccessFn()`. - **Arguments:** - * *app* -- input, an ARKBraid instance. - * *u* -- input, the vector to be accessed. - * *status* -- input, a status object to query for information about *u*. + :param app: input, an ARKBraid instance. + :param u: input, the vector to be accessed. + :param status: input, a status object to query for information about *u*. - **Return value:** - * *SUNBRAID_SUCCESS* if successful. - * *SUNBRAID_ILLINPUT* if any of the inputs are ``NULL``. - * *SUNBRAID_MEMFAIL* if the *app* content, the wrapped N_Vector, or the - ARKStep memory is ``NULL``. - * *SUNBRAID_ALLOCFAIL* if allocating storage for the final solution fails. - * *SUNBRAID_BRAIDFAIL* if an XBraid function fails. The return value can be - retrieved with :c:func:`ARKBraid_GetLastBraidFlag()`. + :retval SUNBRAID_SUCCESS: if successful. + :retval SUNBRAID_ILLINPUT: if any of the inputs are ``NULL``. + :retval SUNBRAID_MEMFAIL: if the *app* content, the wrapped N_Vector, or the + ARKODE memory is ``NULL``. + :retval SUNBRAID_ALLOCFAIL: if allocating storage for the final solution fails. + :retval SUNBRAID_BRAIDFAIL: if an XBraid function fails. The return value can be + retrieved with :c:func:`ARKBraid_GetLastBraidFlag()`. @@ -910,9 +880,10 @@ interace, the user's program must include the header file ``arkode/arkode_xbraid.h`` which declares the needed function prototypes. The following is a skeleton of the user's main program (or calling program) for -the integration of an ODE IVP using ARKStep with XBraid for parallel-in-time -integration. Most steps are unchanged from the skeleton program presented in -:numref:`ARKODE.Usage.ARKStep.Skeleton`. New or updated steps are **bold**. +the integration of an ODE IVP using ARKODE's ARKStep time-stepping module with +XBraid for parallel-in-time integration. Most steps are unchanged from the +skeleton program presented in :numref:`ARKODE.Usage.Skeleton`. New or updated +steps are **bold**. #. **Initialize MPI** @@ -991,7 +962,7 @@ integration. Most steps are unchanged from the skeleton program presented in Advanced ARKBraid Utility Functions ----------------------------------- -This section describes utility functions utilized in the ARKStep + XBraid +This section describes utility functions utilized in the ARKODE + XBraid interfacing. These functions are used internally by the above ARKBraid interface functions but are exposed to the user to assist in advanced usage of ARKODE and XBraid that requries defining a custom SUNBraidApp implementation. @@ -1001,27 +972,25 @@ ARKODE and XBraid that requries defining a custom SUNBraidApp implementation. .. c:function:: int ARKBraid_TakeStep(void *arkode_mem, sunrealtype tstart, sunrealtype tstop, N_Vector y, int *ark_flag) This function advances the vector *y* from *tstart* to *tstop* using a - single ARKStep time step with step size *h = tstop - start*. - - **Arguments:** - * *arkode_mem* -- input, the ARKStep memory structure pointer. - * *tstart* -- input, the step start time. - * *tstop* -- input, the step stop time. - * *y* -- input/output, on input the solution a *tstop* and on return, the - solution at time *tstop* if the step was successful (*ark_flag* - :math:`\geq 0`) or the solution at time *tstart* if the step failed - (*ark_flag* < 0). - * *ark_flag* -- output, the step status flag. If *ark_flag* is: - - :math:`= 0` then the step succeeded and, if applicable, met the - requested temporal accuracy. - - :math:`> 0` then the step succeeded but failed to meet the requested - temporal accuracy. - - :math:`< 0` then the step failed e.g., a solver failure occurred. - - **Return value:** - If all ARKStep function calls are successful the return - value is *ARK_SUCCESS*, otherwise the return value is the error flag - returned from the function that failed. + single ARKODE time step with step size *h = tstop - start*. + + :param arkode_mem: input, the ARKODE memory structure pointer. + :param tstart: input, the step start time. + :param tstop: input, the step stop time. + :param y: input/output, on input the solution a *tstop* and on return, the + solution at time *tstop* if the step was successful (*ark_flag* + :math:`\geq 0`) or the solution at time *tstart* if the step failed + (*ark_flag* < 0). + :param ark_flag: output, the step status flag. If *ark_flag* is: + + :math:`= 0` then the step succeeded and, if applicable, met the + requested temporal accuracy. + + :math:`> 0` then the step succeeded but failed to meet the requested + temporal accuracy. + + :math:`< 0` then the step failed e.g., a solver failure occurred. + + :return: If all ARKODE function calls are successful the return + value is *ARK_SUCCESS*, otherwise the return value is the error flag + returned from the function that failed. diff --git a/doc/arkode/guide/source/Usage/ARKStep_c_interface/index.rst b/doc/arkode/guide/source/Usage/ARKStep_c_interface/index.rst index b7ba4f3b02..3edc8baf51 100644 --- a/doc/arkode/guide/source/Usage/ARKStep_c_interface/index.rst +++ b/doc/arkode/guide/source/Usage/ARKStep_c_interface/index.rst @@ -18,47 +18,15 @@ Using the ARKStep time-stepping module ====================================== -This chapter is concerned with the use of the ARKStep time-stepping +This section is concerned with the use of the ARKStep time-stepping module for the solution of initial value problems (IVPs) in a C or C++ -language setting. The following sections discuss the header files and -the layout of the user's main program, and provide descriptions of the -ARKStep user-callable functions and user-supplied functions. - -The example programs located in the source code ``examples/arkode`` -folder, including those described in the companion document :cite:p:`arkode_ex`, -may be helpful as templates for new codes. - -Users with applications written in Fortran should see the chapter -:numref:`SUNDIALS.Fortran`, which describes the Fortran/C interface -module for ARKStep, and may look to the Fortran example programs also -provided in the ARKODE ``examples`` directory. - -The user should be aware that not all SUNLINSOL, SUNMATRIX, and -preconditioning modules are compatible with all NVECTOR -implementations. Details on compatibility are given in the -documentation for each SUNMATRIX (see :numref:`SUNMatrix`) and each -SUNLINSOL module (see :numref:`SUNLinSol`). For example, NVECTOR_PARALLEL -is not compatible with the dense, banded, or sparse SUNMATRIX types, -or with the corresponding dense, banded, or sparse SUNLINSOL modules. -Please check :numref:`SUNMatrix` and :numref:`SUNLinSol` to -verify compatibility between these modules. In addition to that -documentation, we note that the ARKBANDPRE preconditioning module is -only compatible with the NVECTOR_SERIAL, NVECTOR_OPENMP or -NVECTOR_PTHREADS vector implementations, and the preconditioner module -ARKBBDPRE can only be used with NVECTOR_PARALLEL. - -ARKStep uses various input and output constants from the shared ARKODE -infrastructure. These are defined as needed in this chapter, but for -convenience the full list is provided separately in :numref:`ARKODE.Constants`. - -The relevant information on using ARKStep's C and C++ interfaces is -detailed in the following subsections. +language setting. Usage of ARKStep follows that of the rest of ARKODE, +and so in this section we primarily focus on those usage aspects that +are specific to ARKStep. .. toctree:: :maxdepth: 1 - Skeleton User_callable Relaxation - Preconditioners XBraid diff --git a/doc/arkode/guide/source/Usage/ERKStep_c_interface/Relaxation.rst b/doc/arkode/guide/source/Usage/ERKStep_c_interface/Relaxation.rst index 605a5493ea..72af9b9c82 100644 --- a/doc/arkode/guide/source/Usage/ERKStep_c_interface/Relaxation.rst +++ b/doc/arkode/guide/source/Usage/ERKStep_c_interface/Relaxation.rst @@ -17,9 +17,11 @@ Relaxation Methods ================== -This section describes user-callable functions for applying relaxation methods -with ERKStep. For more information on relaxation Runge--Kutta methods see -:numref:`ARKODE.Mathematics.Relaxation`. +This section describes ERKStep-specific user-callable functions for applying +relaxation methods with ERKStep. All of these routines have been deprecated in +favor of :ref:`shared ARKODE-level routines `, but +this documentation will be retained for as long as these functions are present + Enabling or Disabling Relaxation -------------------------------- @@ -61,6 +63,11 @@ Enabling or Disabling Relaxation .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxFn` instead. + + Optional Input Functions ------------------------ @@ -85,6 +92,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxEtaFail` instead. + + .. c:function:: int ERKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) Sets the smallest acceptable value for the relaxation parameter. @@ -106,6 +118,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxLowerBound` instead. + + .. c:function:: int ERKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) Sets the largest acceptable value for the relaxation parameter. @@ -127,6 +144,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxUpperBound` instead. + + .. c:function:: int ERKStepSetRelaxMaxFails(void* arkode_mem, int max_fails) Sets the maximum number of times applying relaxation can fail within a step @@ -146,6 +168,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxMaxFails` instead. + + .. c:function:: int ERKStepSetRelaxMaxIters(void* arkode_mem, int max_iters) Sets the maximum number of nonlinear iterations allowed when solving for the @@ -169,6 +196,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxMaxIters` instead. + + .. c:function:: int ERKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) Sets the nonlinear solver method used to compute the relaxation parameter. @@ -187,6 +219,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxSolver` instead. + + .. c:function:: int ERKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) Sets the nonlinear solver residual tolerance to use when solving @@ -211,6 +248,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxResTol` instead. + + .. c:function:: int ERKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) Sets the nonlinear solver relative and absolute tolerance on changes in @@ -238,6 +280,11 @@ relaxation. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRelaxTol` instead. + + Optional Output Functions ------------------------- @@ -258,6 +305,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxFnEvals` instead. + + .. c:function:: int ERKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) Get the number of times the user's relaxation Jacobian was evaluated. @@ -272,6 +324,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxJacEvals` instead. + + .. c:function:: int ERKStepGetNumRelaxFails(void* arkode_mem, long int* fails) Get the total number of times applying relaxation failed. @@ -291,6 +348,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxFails` instead. + + .. c:function:: int ERKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails) @@ -307,6 +369,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxBoundFails` instead. + + .. c:function:: int ERKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails) Get the number of times the relaxation parameter nonlinear solver failed. @@ -321,6 +388,11 @@ about the performance of the relaxation method. .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxSolveFails` instead. + + .. c:function:: int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) Get the number of relaxation parameter nonlinear solver iterations. @@ -334,3 +406,8 @@ about the performance of the relaxation method. ``NULL`` .. versionadded:: 5.6.0 + + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumRelaxSolveIters` instead. + diff --git a/doc/arkode/guide/source/Usage/ERKStep_c_interface/Skeleton.rst b/doc/arkode/guide/source/Usage/ERKStep_c_interface/Skeleton.rst deleted file mode 100644 index 308cff4b50..0000000000 --- a/doc/arkode/guide/source/Usage/ERKStep_c_interface/Skeleton.rst +++ /dev/null @@ -1,146 +0,0 @@ -.. ---------------------------------------------------------------- - 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 - ---------------------------------------------------------------- - -.. _ARKODE.Usage.ERKStep.Skeleton: - -A skeleton of the user's main program -============================================ - -The following is a skeleton of the user's main program (or calling -program) for the integration of an ODE IVP using the ERKStep module. -Most of the steps are independent of the NVECTOR implementation used. -For the steps that are not, refer to :numref:`NVectors` for -the specific name of the function to be called or macro to be -referenced. - -.. index:: User main program - -#. Initialize parallel or multi-threaded environment, if appropriate. - - For example, call ``MPI_Init`` to initialize MPI if used, or set - ``num_threads``, the number of threads to use within the threaded - vector functions, if used. - -#. Create the SUNDIALS simulation context object. - - Call :c:func:`SUNContext_Create` to allocate the ``SUNContext`` object. - -#. Set problem dimensions, etc. - - This generally includes the problem size, ``N``, and may include - the local vector length ``Nlocal``. - - .. note:: - - The variables ``N`` and ``Nlocal`` should be of type - ``sunindextype``. - -#. Set vector of initial values - - To set the vector ``y0`` of initial values, use the appropriate - functions defined by the particular NVECTOR implementation. - - For native SUNDIALS vector implementations (except the CUDA and - RAJA based ones), use a call of the form - - .. code-block:: c - - y0 = N_VMake_***(..., ydata); - - if the ``sunrealtype`` array ``ydata`` containing the initial values of - :math:`y` already exists. Otherwise, create a new vector by making - a call of the form - - .. code-block:: c - - y0 = N_VNew_***(...); - - and then set its elements by accessing the underlying data where it - is located with a call of the form - - .. code-block:: c - - ydata = N_VGetArrayPointer_***(y0); - - For details on each of SUNDIALS' provided vector implementations, see - the corresponding sections in :numref:`NVectors` for details. - -#. Create ERKStep object - - Call ``arkode_mem = ERKStepCreate(...)`` to create the ERKStep memory - block. :c:func:`ERKStepCreate` returns a ``void*`` pointer to - this memory structure. See :numref:`ARKODE.Usage.ERKStep.Initialization` for - details. - -#. Specify integration tolerances - - Call :c:func:`ERKStepSStolerances()` or - :c:func:`ERKStepSVtolerances()` to specify either a scalar relative - tolerance and scalar absolute tolerance, or a scalar relative - tolerance and a vector of absolute tolerances, - respectively. Alternatively, call :c:func:`ERKStepWFtolerances()` - to specify a function which sets directly the weights used in - evaluating WRMS vector norms. See :numref:`ARKODE.Usage.ERKStep.Tolerances` - for details. - -#. Set optional inputs - - Call ``ERKStepSet*`` functions to change any optional inputs that - control the behavior of ERKStep from their default values. See - :numref:`ARKODE.Usage.ERKStep.OptionalInputs` for details. - -#. Specify rootfinding problem - - Optionally, call :c:func:`ERKStepRootInit()` to initialize a rootfinding - problem to be solved during the integration of the ODE system. See - :numref:`ARKODE.Usage.ERKStep.RootFinding` for general details, and - :numref:`ARKODE.Usage.ERKStep.OptionalInputs` for relevant optional - input calls. - -#. Advance solution in time - - For each point at which output is desired, call - - .. code-block:: c - - ier = ERKStepEvolve(arkode_mem, tout, yout, &tret, itask); - - Here, ``itask`` specifies the return mode. The vector ``yout`` - (which can be the same as the vector ``y0`` above) will contain - :math:`y(t_\text{out})`. See :numref:`ARKODE.Usage.ERKStep.Integration` - for details. - -#. Get optional outputs - - Call ``ERKStepGet*`` functions to obtain optional output. See - :numref:`ARKODE.Usage.ERKStep.OptionalOutputs` for details. - -#. Deallocate memory for solution vector - - Upon completion of the integration, deallocate memory for the - vector ``y`` (or ``yout``) by calling the NVECTOR destructor - function: - - .. code-block:: c - - N_VDestroy(y); - -#. Free solver memory - - Call :c:func:`ERKStepFree()` to free the memory allocated for - the ERKStep module. - -#. Finalize MPI, if used - - Call ``MPI_Finalize`` to terminate MPI. diff --git a/doc/arkode/guide/source/Usage/ERKStep_c_interface/User_callable.rst b/doc/arkode/guide/source/Usage/ERKStep_c_interface/User_callable.rst index 2b08a5597f..ee3c28f138 100644 --- a/doc/arkode/guide/source/Usage/ERKStep_c_interface/User_callable.rst +++ b/doc/arkode/guide/source/Usage/ERKStep_c_interface/User_callable.rst @@ -17,21 +17,21 @@ ERKStep User-callable functions ================================== -This section describes the functions that are called by the -user to setup and then solve an IVP using the ERKStep time-stepping -module. Some of these are required; however, starting with -:numref:`ARKODE.Usage.ERKStep.OptionalInputs`, the functions listed involve -optional inputs/outputs or restarting, and those paragraphs may be -skipped for a casual use of ARKODE's ERKStep module. In any case, -refer to the preceding section, :numref:`ARKODE.Usage.ERKStep.Skeleton`, -for the correct order of these calls. +This section describes the ERKStep-specific functions that may be called +by the user to setup and then solve an IVP using the ERKStep time-stepping +module. The large majority of these routines merely wrap :ref:`underlying +ARKODE functions `, and are now deprecated +-- each of these are clearly marked. However, some +of these user-callable functions are specific to ERKStep, as explained +below. -On an error, each user-callable function returns a negative value (or -``NULL`` if the function returns a pointer) and sends an error message -to the error handler routine, which prints the message to ``stderr`` -by default. However, the user can set a file as error output or can -provide their own error handler function (see -:numref:`ARKODE.Usage.ERKStep.OptionalInputs` for details). +As discussed in the main :ref:`ARKODE user-callable function introduction +`, each of ARKODE's time-stepping modules +clarifies the categories of user-callable functions that it supports. +ERKStep supports the following categories: + +* temporal adaptivity +* relaxation Runge--Kutta methods @@ -71,6 +71,10 @@ ERKStep initialization and deallocation functions **Return value:** None + .. deprecated:: x.y.z + + Use :c:func:`ARKodeFree` instead. + .. _ARKODE.Usage.ERKStep.Tolerances: @@ -78,40 +82,6 @@ ERKStep initialization and deallocation functions ERKStep tolerance specification functions ------------------------------------------------------ -These functions specify the integration tolerances. One of them -**should** be called before the first call to -:c:func:`ERKStepEvolve()`; otherwise default values of ``reltol = -1e-4`` and ``abstol = 1e-9`` will be used, which may be entirely -incorrect for a specific problem. - -The integration tolerances ``reltol`` and ``abstol`` define a vector -of error weights, ``ewt``. In the case of -:c:func:`ERKStepSStolerances()`, this vector has components - -.. code-block:: c - - ewt[i] = 1.0/(reltol*abs(y[i]) + abstol); - -whereas in the case of :c:func:`ERKStepSVtolerances()` the vector components -are given by - -.. code-block:: c - - ewt[i] = 1.0/(reltol*abs(y[i]) + abstol[i]); - -This vector is used in all error tests, which use a weighted RMS norm -on all error-like vectors v: - -.. math:: - \|v\|_{WRMS} = \left( \frac{1}{N} \sum_{i=1}^N (v_i\; ewt_i)^2 \right)^{1/2}, - -where :math:`N` is the problem dimension. - -Alternatively, the user may supply a custom function to supply the -``ewt`` vector, through a call to :c:func:`ERKStepWFtolerances()`. - - - .. c:function:: int ERKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) This function specifies scalar relative and absolute tolerances. @@ -127,6 +97,10 @@ Alternatively, the user may supply a custom function to supply the * *ARK_NO_MALLOC* if the ERKStep memory was not allocated by the time-stepping module * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSStolerances` instead. + .. c:function:: int ERKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) @@ -147,6 +121,10 @@ Alternatively, the user may supply a custom function to supply the * *ARK_NO_MALLOC* if the ERKStep memory was not allocated by the time-stepping module * *ARK_ILL_INPUT* if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSVtolerances` instead. + .. c:function:: int ERKStepWFtolerances(void* arkode_mem, ARKEwtFn efun) @@ -164,108 +142,9 @@ Alternatively, the user may supply a custom function to supply the * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` * *ARK_NO_MALLOC* if the ERKStep memory was not allocated by the time-stepping module + .. deprecated:: x.y.z - - -General advice on the choice of tolerances -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For many users, the appropriate choices for tolerance values in -``reltol`` and ``abstol`` are a concern. The following pieces -of advice are relevant. - -(1) The scalar relative tolerance ``reltol`` is to be set to control - relative errors. So a value of :math:`10^{-4}` means that errors - are controlled to .01%. We do not recommend using ``reltol`` larger - than :math:`10^{-3}`. On the other hand, ``reltol`` should not be so - small that it is comparable to the unit roundoff of the machine - arithmetic (generally around :math:`10^{-15}` for double-precision). - -(2) The absolute tolerances ``abstol`` (whether scalar or vector) need - to be set to control absolute errors when any components of the - solution vector :math:`y` may be so small that pure relative error - control is meaningless. For example, if :math:`y_i` starts at some - nonzero value, but in time decays to zero, then pure relative - error control on :math:`y_i` makes no sense (and is overly costly) - after :math:`y_i` is below some noise level. Then ``abstol`` (if - scalar) or ``abstol[i]`` (if a vector) needs to be set to that - noise level. If the different components have different noise - levels, then ``abstol`` should be a vector. For example, see the - example problem ``ark_robertson.c``, and the discussion - of it in the ARKODE Examples Documentation :cite:p:`arkode_ex`. In that - problem, the three components vary between 0 and 1, and have - different noise levels; hence the ``atols`` vector therein. It is - impossible to give any general advice on ``abstol`` values, - because the appropriate noise levels are completely - problem-dependent. The user or modeler hopefully has some idea as - to what those noise levels are. - -(3) Finally, it is important to pick all the tolerance values - conservatively, because they control the error committed on each - individual step. The final (global) errors are an accumulation of - those per-step errors, where that accumulation factor is - problem-dependent. A general rule of thumb is to reduce the - tolerances by a factor of 10 from the actual desired limits on - errors. So if you want .01% relative accuracy (globally), a good - choice for ``reltol`` is :math:`10^{-5}`. In any case, it is - a good idea to do a few experiments with the tolerances to see how - the computed solution values vary as tolerances are reduced. - - - -Advice on controlling nonphysical negative values -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In many applications, some components in the true solution are always -positive or non-negative, though at times very small. In the -numerical solution, however, small negative (nonphysical) values -can then occur. In most cases, these values are harmless, and simply -need to be controlled, not eliminated, but in other cases any value -that violates a constraint may cause a simulation to halt. For both of -these scenarios the following pieces of advice are relevant. - -(1) The best way to control the size of unwanted negative computed - values is with tighter absolute tolerances. Again this requires - some knowledge of the noise level of these components, which may - or may not be different for different components. Some - experimentation may be needed. - -(2) If output plots or tables are being generated, and it is important - to avoid having negative numbers appear there (for the sake of - avoiding a long explanation of them, if nothing else), then - eliminate them, but only in the context of the output medium. Then - the internal values carried by the solver are unaffected. Remember - that a small negative value in :math:`y` returned by ERKStep, with - magnitude comparable to ``abstol`` or less, is equivalent to zero - as far as the computation is concerned. - -(3) The user's right-hand side routine :math:`f` - should never change a negative value in the solution vector :math:`y` - to a non-negative value in attempt to "fix" this problem, - since this can lead to numerical instability. If the :math:`f` - routine cannot tolerate a zero or negative value (e.g. because - there is a square root or log), then the offending value should be - changed to zero or a tiny positive number in a temporary variable - (not in the input :math:`y` vector) for the purposes of computing - :math:`f(t, y)`. - -(4) ERKStep supports component-wise constraints on solution components, - :math:`y_i < 0`, :math:`y_i \le 0`, , :math:`y_i > 0`, or - :math:`y_i \ge 0`, through the user-callable function - :c:func:`ERKStepSetConstraints`. At each internal time step, if any - constraint is violated then ERKStep will attempt a smaller time step - that should not violate this constraint. This reduced step size is - chosen such that the step size is the largest possible but where the - solution component satisfies the constraint. - -(5) Positivity and non-negativity constraints on components can be - enforced by use of the recoverable error return feature in the - user-supplied right-hand side function, :math:`f`. When a - recoverable error is encountered, ERKStep will retry the step with - a smaller step size, which typically alleviates the problem. - However, because this option involves some additional overhead - cost, it should only be exercised if the use of absolute - tolerances to control the computed values is unsuccessful. + Use :c:func:`ARKodeWFtolerances` instead. @@ -274,16 +153,6 @@ these scenarios the following pieces of advice are relevant. Rootfinding initialization function -------------------------------------- -As described in :numref:`ARKODE.Mathematics.Rootfinding`, while -solving the IVP, ARKODE's time-stepping modules have the capability to -find the roots of a set of user-defined functions. To activate the -root-finding algorithm, call the following function. This is normally -called only once, prior to the first call to -:c:func:`ERKStepEvolve()`, but if the rootfinding problem is to be -changed during the solution, :c:func:`ERKStepRootInit()` can also be -called prior to a continuation call to :c:func:`ERKStepEvolve()`. - - .. c:function:: int ERKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) Initializes a rootfinding problem to be solved during the @@ -312,6 +181,10 @@ called prior to a continuation call to :c:func:`ERKStepEvolve()`. problem but the prior one did, then call *ERKStepRootInit* with *nrtfn = 0*. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeRootInit` instead. + @@ -320,15 +193,6 @@ called prior to a continuation call to :c:func:`ERKStepEvolve()`. ERKStep solver function ------------------------- -This is the central step in the solution process -- the call to perform -the integration of the IVP. One of the input arguments (*itask*) -specifies one of two modes as to where ERKStep is to return a -solution. These modes are modified if the user has set a stop time -(with a call to the optional input function :c:func:`ERKStepSetStopTime()`) or -has requested rootfinding. - - - .. c:function:: int ERKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype *tret, int itask) Integrates the ODE over an interval in :math:`t`. @@ -419,6 +283,10 @@ has requested rootfinding. On all other error returns, *tret* and *yout* are left unchanged from those provided to the routine. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeEvolve` instead. + @@ -427,85 +295,12 @@ has requested rootfinding. Optional input functions ------------------------- -There are numerous optional input parameters that control the behavior -of ERKStep, each of which may be modified from its default value through -calling an appropriate input function. The following tables list all -optional input functions, grouped by which aspect of ERKStep they control. -Detailed information on the calling syntax and arguments for each -function are then provided following each table. - -The optional inputs are grouped into the following categories: - -* General ERKStep options (:numref:`ARKODE.Usage.ERKStep.ERKStepInputTable`), - -* IVP method solver options (:numref:`ARKODE.Usage.ERKStep.ERKStepMethodInputTable`), - -* Step adaptivity solver options (:numref:`ARKODE.Usage.ERKStep.ERKStepAdaptivityInputTable`), and - -* Rootfinding options (:numref:`ARKODE.Usage.ERKStep.ERKStepRootfindingInputTable`). - -For the most casual use of ERKStep, relying on the default set of -solver parameters, the reader can skip to section on user-supplied -functions, :numref:`ARKODE.Usage.UserSupplied`. - -We note that, on an error return, all of the optional input functions send an -error message to the error handler function. All error return values are -negative, so a test on the return arguments for negative values will catch all -errors. Finally, a call to an ``ERKStepSet***`` function can generally be made -from the user's calling program at any time and, if successful, takes effect -immediately. ``ERKStepSet***`` functions that cannot be called at any time note -this in the "**Notes**:" section of the function documentation. - - .. _ARKODE.Usage.ERKStep.ERKStepInput: Optional inputs for ERKStep ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. _ARKODE.Usage.ERKStep.ERKStepInputTable: -.. table:: Optional inputs for ERKStep - - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Optional input | Function name | Default | - +====================================================+===========================================+========================+ - | Return ERKStep solver parameters to their defaults | :c:func:`ERKStepSetDefaults()` | internal | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Set dense output interpolation type | :c:func:`ERKStepSetInterpolantType()` | ``ARK_INTERP_HERMITE`` | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Set dense output polynomial degree | :c:func:`ERKStepSetInterpolantDegree()` | 5 | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Supply a pointer to a diagnostics output file | :c:func:`ERKStepSetDiagnostics()` | ``NULL`` | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Disable time step adaptivity (fixed-step mode) | :c:func:`ERKStepSetFixedStep()` | disabled | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Supply an initial step size to attempt | :c:func:`ERKStepSetInitStep()` | estimated | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Maximum no. of warnings for :math:`t_n+h = t_n` | :c:func:`ERKStepSetMaxHnilWarns()` | 10 | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Maximum no. of internal steps before *tout* | :c:func:`ERKStepSetMaxNumSteps()` | 500 | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Maximum absolute step size | :c:func:`ERKStepSetMaxStep()` | :math:`\infty` | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Minimum absolute step size | :c:func:`ERKStepSetMinStep()` | 0.0 | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Set a value for :math:`t_{stop}` | :c:func:`ERKStepSetStopTime()` | undefined | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Interpolate at :math:`t_{stop}` | :c:func:`ERKStepSetInterpolateStopTime()` | ``SUNFALSE`` | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Disable the stop time | :c:func:`ERKStepClearStopTime` | N/A | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Supply a pointer for user data | :c:func:`ERKStepSetUserData()` | ``NULL`` | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Maximum no. of ERKStep error test failures | :c:func:`ERKStepSetMaxErrTestFails()` | 7 | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Set inequality constraints on solution | :c:func:`ERKStepSetConstraints()` | ``NULL`` | - +----------------------------------------------------+-------------------------------------------+------------------------+ - | Set max number of constraint failures | :c:func:`ERKStepSetMaxNumConstrFails()` | 10 | - +----------------------------------------------------+-------------------------------------------+------------------------+ - - - .. c:function:: int ERKStepSetDefaults(void* arkode_mem) Resets all optional input parameters to ERKStep's original @@ -526,6 +321,10 @@ Optional inputs for ERKStep Also leaves alone any data structures or options related to root-finding (those can be reset using :c:func:`ERKStepRootInit()`). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDefaults` instead. + .. c:function:: int ERKStepSetInterpolantType(void* arkode_mem, int itype) @@ -560,6 +359,10 @@ Optional inputs for ERKStep If this routine is not called, the Hermite interpolation module will be used. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantType` instead. + .. c:function:: int ERKStepSetInterpolantDegree(void* arkode_mem, int degree) @@ -602,13 +405,17 @@ Optional inputs for ERKStep obtained by the integrator are returned at the ends of the time interval. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantDegree` instead. + .. c:function:: int ERKStepSetDenseOrder(void* arkode_mem, int dord) - *This function is deprecated, and will be removed in a future release. - Users should transition to calling* :c:func:`ERKStepSetInterpolantDegree()` - *instead.* + .. deprecated:: 5.2.0 + + Use :c:func:`ARKodeSetInterpolantDegree` instead. @@ -695,6 +502,9 @@ Optional inputs for ERKStep routines will provide no useful information to the solver, and at worst they may interfere with the desired fixed step size. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetFixedStep` instead. @@ -722,6 +532,10 @@ Optional inputs for ERKStep This routine will also reset the step size and error history. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInitStep` instead. + .. c:function:: int ERKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) @@ -745,6 +559,9 @@ Optional inputs for ERKStep A negative value indicates that no warning messages should be issued. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxHnilWarns` instead. @@ -769,6 +586,10 @@ Optional inputs for ERKStep Passing *mxsteps* < 0 disables the test (not recommended). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNumSteps` instead. + .. c:function:: int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax) @@ -787,6 +608,10 @@ Optional inputs for ERKStep **Notes:** Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxStep` instead. + .. c:function:: int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin) @@ -805,6 +630,10 @@ Optional inputs for ERKStep **Notes:** Pass *hmin* :math:`\le 0.0` to set the default value of 0. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMinStep` instead. + .. c:function:: int ERKStepSetStopTime(void* arkode_mem, sunrealtype tstop) @@ -832,6 +661,11 @@ Optional inputs for ERKStep :c:func:`ERKStepReset` will remain active but can be disabled by calling :c:func:`ERKStepClearStopTime`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStopTime` instead. + + .. c:function:: int ERKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) @@ -849,6 +683,11 @@ Optional inputs for ERKStep .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolateStopTime` instead. + + .. c:function:: int ERKStepClearStopTime(void* arkode_mem) @@ -867,6 +706,11 @@ Optional inputs for ERKStep .. versionadded:: 5.5.1 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeClearStopTime` instead. + + .. c:function:: int ERKStepSetUserData(void* arkode_mem, void* user_data) @@ -887,6 +731,9 @@ Optional inputs for ERKStep user-supplied functions for which it is an argument; otherwise ``NULL`` is passed. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetUserData` instead. @@ -908,6 +755,10 @@ Optional inputs for ERKStep The default value is 7; set *maxnef* :math:`\le 0` to specify this default. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxErrTestFails` instead. + .. c:function:: int ERKStepSetConstraints(void* arkode_mem, N_Vector constraints) @@ -952,6 +803,11 @@ Optional inputs for ERKStep and :c:func:`ERKStepSetFixedStep()` are incompatible, and should not be used simultaneously. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetConstraints` instead. + + .. c:function:: int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) @@ -970,6 +826,10 @@ Optional inputs for ERKStep Passing *maxfails* <= 0 results in ERKStep using the default value (10). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNumConstrFails` instead. + .. _ARKODE.Usage.ERKStep.ERKStepMethodInput: @@ -1015,6 +875,10 @@ Optional inputs for IVP method selection ERKStep memory block, it cannot be changed after the first call to :c:func:`ERKStepEvolve()`, unless :c:func:`ERKStepReInit()` is called. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetOrder` instead. + .. c:function:: int ERKStepSetTable(void* arkode_mem, ARKodeButcherTable B) @@ -1046,6 +910,8 @@ Optional inputs for IVP method selection :c:func:`ERKStepSetFixedStep()` to enable fixed-step mode and set the desired time step size. + **Warning:** + This should not be used with :c:func:`ARKodeSetOrder`. .. c:function:: int ERKStepSetTableNum(void* arkode_mem, ARKODE_ERKTableID etable) @@ -1066,6 +932,9 @@ Optional inputs for IVP method selection :numref:`Butcher.explicit`. Error-checking is performed to ensure that the table exists, and is not implicit. + **Warning:** + This should not be used with :c:func:`ARKodeSetOrder`. + .. c:function:: int ERKStepSetTableName(void* arkode_mem, const char *etable) @@ -1087,6 +956,8 @@ Optional inputs for IVP method selection to ensure that the table exists, and is not implicit. This function is case sensitive. + **Warning:** + This should not be used with :c:func:`ARKodeSetOrder`. @@ -1101,43 +972,6 @@ algorithm, including how each of the parameters below is used within the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. -.. _ARKODE.Usage.ERKStep.ERKStepAdaptivityInputTable: -.. table:: Optional inputs for time step adaptivity - - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Optional input | Function name | Default | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Provide a :c:type:`SUNAdaptController` for ERKStep to use | :c:func:`ERKStepSetAdaptController()` | PI | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Set a custom time step adaptivity function | :c:func:`ERKStepSetAdaptivityFn()` | internal | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Choose an existing time step adaptivity method | :c:func:`ERKStepSetAdaptivityMethod()` | 0 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Adjust the method order used in the controller | :c:func:`ERKStepSetAdaptivityAdjustment()` | -1 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Explicit stability safety factor | :c:func:`ERKStepSetCFLFraction()` | 0.5 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Time step error bias factor | :c:func:`ERKStepSetErrorBias()` | 1.5 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Bounds determining no change in step size | :c:func:`ERKStepSetFixedStepBounds()` | 1.0 1.5 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Maximum step growth factor on error test fail | :c:func:`ERKStepSetMaxEFailGrowth()` | 0.3 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Maximum first step growth factor | :c:func:`ERKStepSetMaxFirstGrowth()` | 10000.0 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Maximum allowed general step growth factor | :c:func:`ERKStepSetMaxGrowth()` | 20.0 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Minimum allowed step reduction factor on error test fail | :c:func:`ERKStepSetMinReduction()` | 0.1 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Time step safety factor | :c:func:`ERKStepSetSafetyFactor()` | 0.96 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Error fails before MaxEFailGrowth takes effect | :c:func:`ERKStepSetSmallNumEFails()` | 2 | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - | Explicit stability function | :c:func:`ERKStepSetStabilityFn()` | none | - +-----------------------------------------------------------+--------------------------------------------+-----------+ - - - .. c:function:: int ERKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) Sets a user-supplied time-step controller object. @@ -1158,6 +992,11 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. .. versionadded:: 5.7.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetAdaptController` instead. + + .. c:function:: int ERKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) @@ -1249,6 +1088,12 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. .. versionadded:: 5.7.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetAdaptivityAdjustment` instead. + + + .. c:function:: int ERKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) Specifies the fraction of the estimated explicitly stable step to use. @@ -1266,6 +1111,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetCFLFraction` instead. + .. c:function:: int ERKStepSetErrorBias(void* arkode_mem, sunrealtype bias) @@ -1313,6 +1162,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any interval *not* containing 1.0 will imply a reset to the default values. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetFixedStepBounds` instead. + .. c:function:: int ERKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) @@ -1332,6 +1185,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxEFailGrowth` instead. + .. c:function:: int ERKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) @@ -1352,6 +1209,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any value :math:`\le 1.0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxFirstGrowth` instead. + .. c:function:: int ERKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) @@ -1372,6 +1233,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any value :math:`\le 1.0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxGrowth` instead. + .. c:function:: int ERKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min) @@ -1394,6 +1259,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any value :math:`\ge 1.0` or :math:`\le 0.0` will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMinReduction` instead. + .. c:function:: int ERKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety) @@ -1414,6 +1283,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetSafetyFactor` instead. + .. c:function:: int ERKStepSetSmallNumEFails(void* arkode_mem, int small_nef) @@ -1434,6 +1307,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. **Notes:** Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetSmallNumEFails` instead. + .. c:function:: int ERKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) @@ -1460,6 +1337,10 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. where the right-hand side function :math:`f(t,y)` contains stiff terms. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStabilityFn` instead. + @@ -1469,24 +1350,6 @@ the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. Rootfinding optional input functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following functions can be called to set optional inputs to -control the rootfinding algorithm, the mathematics of which are -described in :numref:`ARKODE.Mathematics.Rootfinding`. - - -.. _ARKODE.Usage.ERKStep.ERKStepRootfindingInputTable: -.. table:: Rootfinding optional input functions - - +-----------------------------------------+------------------------------------------+----------+ - | Optional input | Function name | Default | - +-----------------------------------------+------------------------------------------+----------+ - | Direction of zero-crossings to monitor | :c:func:`ERKStepSetRootDirection()` | both | - +-----------------------------------------+------------------------------------------+----------+ - | Disable inactive root warnings | :c:func:`ERKStepSetNoInactiveRootWarn()` | enabled | - +-----------------------------------------+------------------------------------------+----------+ - - - .. c:function:: int ERKStepSetRootDirection(void* arkode_mem, int* rootdir) Specifies the direction of zero-crossings to be located and returned. @@ -1509,6 +1372,10 @@ described in :numref:`ARKODE.Mathematics.Rootfinding`. **Notes:** The default behavior is to monitor for both zero-crossing directions. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRootDirection` instead. + .. c:function:: int ERKStepSetNoInactiveRootWarn(void* arkode_mem) @@ -1532,6 +1399,9 @@ described in :numref:`ARKODE.Mathematics.Rootfinding`. first step), ERKStep will issue a warning which can be disabled with this optional input function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNoInactiveRootWarn` instead. @@ -1541,20 +1411,6 @@ described in :numref:`ARKODE.Mathematics.Rootfinding`. Interpolated output function -------------------------------- -An optional function :c:func:`ERKStepGetDky()` is available to obtain -additional values of solution-related quantities. This function -should only be called after a successful return from -:c:func:`ERKStepEvolve()`, as it provides interpolated values either of -:math:`y` or of its derivatives (up to the 5th derivative) -interpolated to any value of :math:`t` in the last internal step taken -by :c:func:`ERKStepEvolve()`. Internally, this "dense output" or -"continuous extension" algorithm is identical to the algorithm used for -the maximum order implicit predictors, described in -:numref:`ARKODE.Mathematics.Predictors.Max`, except that -derivatives of the polynomial model may be evaluated upon request. - - - .. c:function:: int ERKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) Computes the *k*-th derivative of the function @@ -1592,6 +1448,9 @@ derivatives of the polynomial model may be evaluated upon request. functions :c:func:`ERKStepGetCurrentTime()` and :c:func:`ERKStepGetLastStep()`, respectively. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetDky` instead. @@ -1600,102 +1459,12 @@ derivatives of the polynomial model may be evaluated upon request. Optional output functions ------------------------------ -ERKStep provides an extensive set of functions that can be used to -obtain solver performance information. We organize these into groups: - -#. General ERKStep output routines are in - :numref:`ARKODE.Usage.ERKStep.ERKStepMainOutputs`, - -#. Output routines regarding root-finding results are in - :numref:`ARKODE.Usage.ERKStep.ERKStepRootOutputs`, - -#. General usability routines (e.g. to print the current ERKStep - parameters, or output the current Butcher table) are in - :numref:`ARKODE.Usage.ERKStep.ERKStepExtraOutputs`. - -Following each table, we elaborate on each function. - -Some of the optional outputs, especially the various counters, can be -very useful in determining the efficiency of various methods inside -ERKStep. For example: - -* The counters *nsteps* and *nf_evals* provide a rough measure of the - overall cost of a given run, and can be compared between runs with - different solver options to suggest which set of options is the most - efficient. - -* The ratio *nsteps/step_attempts* can measure the quality of the - time step adaptivity algorithm, since a poor algorithm will result - in more failed steps, and hence a lower ratio. - -It is therefore recommended that users retrieve and output these -statistics following each run, and take some time to investigate -alternate solver options that will be more optimal for their -particular problem of interest. - - .. _ARKODE.Usage.ERKStep.ERKStepMainOutputs: Main solver optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. _ARKODE.Usage.ERKStep.ERKStepMainOutputsTable: -.. table:: Main solver optional output functions - - +------------------------------------------------------+--------------------------------------------+ - | Optional output | Function name | - +------------------------------------------------------+--------------------------------------------+ - | Size of ERKStep real and integer workspaces | :c:func:`ERKStepGetWorkSpace()` | - +------------------------------------------------------+--------------------------------------------+ - | Cumulative number of internal steps | :c:func:`ERKStepGetNumSteps()` | - +------------------------------------------------------+--------------------------------------------+ - | Actual initial time step size used | :c:func:`ERKStepGetActualInitStep()` | - +------------------------------------------------------+--------------------------------------------+ - | Step size used for the last successful step | :c:func:`ERKStepGetLastStep()` | - +------------------------------------------------------+--------------------------------------------+ - | Step size to be attempted on the next step | :c:func:`ERKStepGetCurrentStep()` | - +------------------------------------------------------+--------------------------------------------+ - | Current internal time reached by the solver | :c:func:`ERKStepGetCurrentTime()` | - +------------------------------------------------------+--------------------------------------------+ - | Suggested factor for tolerance scaling | :c:func:`ERKStepGetTolScaleFactor()` | - +------------------------------------------------------+--------------------------------------------+ - | Error weight vector for state variables | :c:func:`ERKStepGetErrWeights()` | - +------------------------------------------------------+--------------------------------------------+ - | Single accessor to many statistics at once | :c:func:`ERKStepGetStepStats()` | - +------------------------------------------------------+--------------------------------------------+ - | Print all statistics | :c:func:`ERKStepPrintAllStats()` | - +------------------------------------------------------+--------------------------------------------+ - | Name of constant associated with a return flag | :c:func:`ERKStepGetReturnFlagName()` | - +------------------------------------------------------+--------------------------------------------+ - | No. of explicit stability-limited steps | :c:func:`ERKStepGetNumExpSteps()` | - +------------------------------------------------------+--------------------------------------------+ - | No. of accuracy-limited steps | :c:func:`ERKStepGetNumAccSteps()` | - +------------------------------------------------------+--------------------------------------------+ - | No. of attempted steps | :c:func:`ERKStepGetNumStepAttempts()` | - +------------------------------------------------------+--------------------------------------------+ - | No. of calls to *f* function | :c:func:`ERKStepGetNumRhsEvals()` | - +------------------------------------------------------+--------------------------------------------+ - | No. of local error test failures that have occurred | :c:func:`ERKStepGetNumErrTestFails()` | - +------------------------------------------------------+--------------------------------------------+ - | Current ERK Butcher table | :c:func:`ERKStepGetCurrentButcherTable()` | - +------------------------------------------------------+--------------------------------------------+ - | Estimated local truncation error vector | :c:func:`ERKStepGetEstLocalErrors()` | - +------------------------------------------------------+--------------------------------------------+ - | Accumulated temporal error estimation strategy | :c:func:`ERKStepSetAccumulatedErrorType()` | - +------------------------------------------------------+--------------------------------------------+ - | Reset acumulated temporal error estimate | :c:func:`ERKStepResetAccumulatedError()` | - +------------------------------------------------------+--------------------------------------------+ - | Get accumulated temporal error estimate | :c:func:`ERKStepGetAccumulatedError()` | - +------------------------------------------------------+--------------------------------------------+ - | Single accessor to many statistics at once | :c:func:`ERKStepGetTimestepperStats()` | - +------------------------------------------------------+--------------------------------------------+ - | Number of constraint test failures | :c:func:`ERKStepGetNumConstrFails()` | - +------------------------------------------------------+--------------------------------------------+ - | Retrieve a pointer for user data | :c:func:`ERKStepGetUserData` | - +------------------------------------------------------+--------------------------------------------+ - - .. c:function:: int ERKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) @@ -1710,6 +1479,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetWorkSpace` instead. + .. c:function:: int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps) @@ -1725,6 +1498,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumSteps` instead. + .. c:function:: int ERKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) @@ -1747,6 +1524,10 @@ Main solver optional output functions bounds :math:`(h_{min} \le h_0 \le h_{max})`, or to satisfy the local error test condition. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetActualInitStep` instead. + .. c:function:: int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) @@ -1762,6 +1543,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLastStep` instead. + .. c:function:: int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) @@ -1776,6 +1561,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentStep` instead. + .. c:function:: int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) @@ -1790,6 +1579,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentTime` instead. + .. c:function:: int ERKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac) @@ -1806,6 +1599,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetTolScaleFactor` instead. + .. c:function:: int ERKStepGetErrWeights(void* arkode_mem, N_Vector eweight) @@ -1824,6 +1621,10 @@ Main solver optional output functions The user must allocate space for *eweight*, that will be filled in by this function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetErrWeights` instead. + .. c:function:: int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) @@ -1842,6 +1643,11 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetStepStats` instead. + + .. c:function:: int ERKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) @@ -1869,9 +1675,13 @@ Main solver optional output functions .. versionadded:: 5.2.0 + .. deprecated:: x.y.z + Use :c:func:`ARKodePrintAllStats` instead. -.. c:function:: char *ERKStepGetReturnFlagName(long int flag) + + +.. c:function:: char* ERKStepGetReturnFlagName(long int flag) Returns the name of the ERKStep constant corresponding to *flag*. See :ref:`ARKODE.Constants`. @@ -1883,6 +1693,10 @@ Main solver optional output functions The return value is a string containing the name of the corresponding constant. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetReturnFlagName` instead. + .. c:function:: int ERKStepGetNumExpSteps(void* arkode_mem, long int* expsteps) @@ -1898,6 +1712,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumExpSteps` instead. + .. c:function:: int ERKStepGetNumAccSteps(void* arkode_mem, long int* accsteps) @@ -1913,6 +1731,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumAccSteps` instead. + .. c:function:: int ERKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts) @@ -1927,6 +1749,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumStepAttempts` instead. + .. c:function:: int ERKStepGetNumRhsEvals(void* arkode_mem, long int* nf_evals) @@ -1957,6 +1783,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumErrTestFails` instead. + .. c:function:: int ERKStepGetCurrentButcherTable(void* arkode_mem, ARKodeButcherTable *B) @@ -2020,80 +1850,9 @@ Main solver optional output functions failures, the components causing the failures are those with largest values for the products, denoted loosely as ``eweight[i]*ele[i]``. + .. deprecated:: x.y.z -.. c:function:: int ERKStepSetAccumulatedErrorType(void* arkode_mem, int accum_type) - - Sets the strategy to use for accumulating a temporal error estimate - over multiple time steps. - - **Arguments:** - * *arkode_mem* -- pointer to the ERKStep memory block. - * *accum_type* -- accumulation strategy: - - * ``-1`` -- no accumulation (default). - * ``0`` -- maximum accumulation. - * ``1`` -- additive accumulation. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` - - **Notes:** - At each internal step, ERKStep computes both a solution and embedding, - (if coefficients are available), :math:`y_n` and :math:`\tilde{y}_n`, - resulting in a vector-valued local temporal error estimate, :math:`y_n - \tilde{y}_n`. - By default, ERKStep will not accumulate these local error estimates, but - accumulation can be triggered by setting one of two options: - - * ``0`` computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` - - * ``1`` computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`, - - In both cases, the sum or maximum is taken over all steps :math:`n\in N` since the most - recent call to either :c:func:`ERKStepSetAccumulatedErrorType` or - :c:func:`ERKStepResetAccumulatedError`. The norm is taken using the tolerance-informed - error-weight vector (see :c:func:`ERKStepGetErrWeights`), and ``reltol`` is the - user-specified relative solution tolerance. - - Error accumulation can be disabled by calling :c:func:`ERKStepSetAccumulatedErrorType` - with the argument ``-1``. - - .. versionadded:: v.v.v - - -.. c:function:: int ERKStepResetAccumulatedError(void* arkode_mem) - - Resets the accumulated temporal error estimate. - - **Arguments:** - * *arkode_mem* -- pointer to the ERKStep memory block. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` - - .. versionadded:: v.v.v - - -.. c:function:: int ERKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) - - Gets the accumulated temporal error estimate. - - **Arguments:** - * *arkode_mem* -- pointer to the ERKStep memory block. - * *accum_error* -- pointer to accumulated error estimate. - - **Return value:** - * *ARK_SUCCESS* if successful - * *ARK_MEM_NULL* if the ARKStep memory was ``NULL`` - - **Notes:** - This routine is only useful if a Runge--Kutta method with an embedding is used - by ERKStep. If a non-embedded method is used then this routine will always return - ``*accum_error = 0.0``. - - .. versionadded:: v.v.v - + Use :c:func:`ARKodeGetEstLocalErrors` instead. .. c:function:: int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nf_evals, long int* netfails) @@ -2126,6 +1885,10 @@ Main solver optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumConstrFails` instead. + .. c:function:: int ERKStepGetUserData(void* arkode_mem, void** user_data) @@ -2143,25 +1906,16 @@ Main solver optional output functions .. versionadded:: 5.3.0 + .. deprecated:: x.y.z -.. _ARKODE.Usage.ERKStep.ERKStepRootOutputs: + Use :c:func:`ARKodeGetUserData` instead. -Rootfinding optional output functions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. _ARKODE.Usage.ERKStep.ERKStepRootOutputsTable: -.. table:: Rootfinding optional output functions - - +--------------------------------------------------+---------------------------------+ - | Optional output | Function name | - +--------------------------------------------------+---------------------------------+ - | Array showing roots found | :c:func:`ERKStepGetRootInfo()` | - +--------------------------------------------------+---------------------------------+ - | No. of calls to user root function | :c:func:`ERKStepGetNumGEvals()` | - +--------------------------------------------------+---------------------------------+ - +.. _ARKODE.Usage.ERKStep.ERKStepRootOutputs: +Rootfinding optional output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. c:function:: int ERKStepGetRootInfo(void* arkode_mem, int* rootsfound) @@ -2190,6 +1944,10 @@ Rootfinding optional output functions zero-crossing. A value of +1 indicates that :math:`g_i` is increasing, while a value of -1 indicates a decreasing :math:`g_i`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetRootInfo` instead. + .. c:function:: int ERKStepGetNumGEvals(void* arkode_mem, long int* ngevals) @@ -2205,6 +1963,9 @@ Rootfinding optional output functions * *ARK_SUCCESS* if successful * *ARK_MEM_NULL* if the ERKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumGEvals` instead. @@ -2213,28 +1974,6 @@ Rootfinding optional output functions General usability functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following optional routines may be called by a user to inquire -about existing solver parameters, to retrieve stored Butcher tables, -write the current Butcher table, or even to test a provided Butcher -table to determine its analytical order of accuracy. While none of -these would typically be called during the course of solving an -initial value problem, these may be useful for users wishing to better -understand ERKStep and/or specific Runge--Kutta methods. - - -.. _ARKODE.Usage.ERKStep.ERKStepExtraOutputsTable: -.. table:: General usability functions - - +----------------------------------------+------------------------------------+ - | Optional routine | Function name | - +----------------------------------------+------------------------------------+ - | Output all ERKStep solver parameters | :c:func:`ERKStepWriteParameters()` | - +----------------------------------------+------------------------------------+ - | Output the current Butcher table | :c:func:`ERKStepWriteButcher()` | - +----------------------------------------+------------------------------------+ - - - .. c:function:: int ERKStepWriteParameters(void* arkode_mem, FILE *fp) @@ -2256,6 +1995,11 @@ understand ERKStep and/or specific Runge--Kutta methods. for this pointer, since parameters for all processes would be identical. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeWriteParameters` instead. + + .. c:function:: int ERKStepWriteButcher(void* arkode_mem, FILE *fp) @@ -2277,6 +2021,10 @@ understand ERKStep and/or specific Runge--Kutta methods. for this pointer, since tables for all processes would be identical. + .. deprecated:: x.y.z + + Use :c:func:`ERKStepGetCurrentButcherTable` and :c:func:`ARKodeButcherTable_Write` + instead. @@ -2359,40 +2107,6 @@ vector. ERKStep reset function ---------------------- -To reset the ERKStep module to a particular state :math:`(t_R,y(t_R))` for the -continued solution of a problem, where a prior -call to :c:func:`ERKStepCreate` has been made, the user must call the function -:c:func:`ERKStepReset()`. Like :c:func:`ERKStepReInit()` this routine retains -the current settings for all ERKStep module options and performs no memory -allocations but, unlike :c:func:`ERKStepReInit()`, this routine performs only a -*subset* of the input checking and initializations that are done in -:c:func:`ERKStepCreate`. In particular this routine retains all internal -counter values and the step size/error history. Like :c:func:`ERKStepReInit()`, a call to -:c:func:`ERKStepReset()` will delete any previously-set *tstop* value specified -via a call to :c:func:`ERKStepSetStopTime()`. Following a successful call to -:c:func:`ERKStepReset()`, call :c:func:`ERKStepEvolve()` again to continue -solving the problem. By default the next call to :c:func:`ERKStepEvolve()` will -use the step size computed by ERKStep prior to calling :c:func:`ERKStepReset()`. -To set a different step size or have ERKStep estimate a new step size use -:c:func:`ERKStepSetInitStep()`. - -One important use of the :c:func:`ERKStepReset()` function is in the -treating of jump discontinuities in the RHS functions. Except in cases -of fairly small jumps, it is usually more efficient to stop at each -point of discontinuity and restart the integrator with a readjusted -ODE model, using a call to :c:func:`ERKStepReset()`. To stop when -the location of the discontinuity is known, simply make that location -a value of ``tout``. To stop when the location of the discontinuity -is determined by the solution, use the rootfinding feature. In either -case, it is critical that the RHS functions *not* incorporate the -discontinuity, but rather have a smooth extension over the -discontinuity, so that the step across it (and subsequent rootfinding, -if used) can be done efficiently. Then use a switch within the RHS -functions (communicated through ``user_data``) that can be flipped -between the stopping of the integration and the restart, so that the -restarted problem uses the new values (which have jumped). Similar -comments apply if there is to be a jump in the dependent variable -vector. .. c:function:: int ERKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) @@ -2422,6 +2136,10 @@ vector. If an error occurred, :c:func:`ERKStepReset()` also sends an error message to the error handler function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeReset` instead. + @@ -2430,35 +2148,6 @@ vector. ERKStep system resize function ------------------------------------- -For simulations involving changes to the number of equations and -unknowns in the ODE system (e.g. when using spatially-adaptive -PDE simulations under a method-of-lines approach), the ERKStep -integrator may be "resized" between integration steps, through calls -to the :c:func:`ERKStepResize()` function. This function modifies -ERKStep's internal memory structures to use the new problem size, -without destruction of the temporal adaptivity heuristics. It is -assumed that the dynamical time scales before and after the vector -resize will be comparable, so that all time-stepping heuristics prior -to calling :c:func:`ERKStepResize()` remain valid after the call. If -instead the dynamics should be recomputed from scratch, the ERKStep -memory structure should be deleted with a call to -:c:func:`ERKStepFree()`, and recreated with a call to -:c:func:`ERKStepCreate`. - -To aid in the vector resize operation, the user can supply a vector -resize function that will take as input a vector with the previous -size, and transform it in-place to return a corresponding vector of -the new size. If this function (of type :c:func:`ARKVecResizeFn()`) -is not supplied (i.e., is set to ``NULL``), then all existing vectors -internal to ERKStep will be destroyed and re-cloned from the new input -vector. - -In the case that the dynamical time scale should be modified slightly -from the previous time scale, an input *hscale* is allowed, that will -rescale the upcoming time step by the specified factor. If a value -*hscale* :math:`\le 0` is specified, the default of 1.0 will be used. - - .. c:function:: int ERKStepResize(void* arkode_mem, N_Vector yR, sunrealtype hscale, sunrealtype tR, ARKVecResizeFn resize, void* resize_data) @@ -2493,22 +2182,6 @@ rescale the upcoming time step by the specified factor. If a value to :c:func:`ERKStepSetConstraints()` is required to re-enable constraint checking. + .. deprecated:: x.y.z -Resizing the absolute tolerance array -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If using array-valued absolute tolerances, the absolute tolerance -vector will be invalid after the call to :c:func:`ERKStepResize()`, so -the new absolute tolerance vector should be re-set **following** each -call to :c:func:`ERKStepResize()` through a new call to -:c:func:`ERKStepSVtolerances()`. - -If scalar-valued tolerances or a tolerance function was specified -through either :c:func:`ERKStepSStolerances()` or -:c:func:`ERKStepWFtolerances()`, then these will remain valid and no -further action is necessary. - - -.. note:: For an example showing usage of the similar - :c:func:`ARKStepResize()` routine, see the supplied serial C - example problem, ``ark_heat1D_adapt.c``. + Use :c:func:`ARKodeResize` instead. diff --git a/doc/arkode/guide/source/Usage/ERKStep_c_interface/index.rst b/doc/arkode/guide/source/Usage/ERKStep_c_interface/index.rst index d4b2498243..d799e0bc86 100644 --- a/doc/arkode/guide/source/Usage/ERKStep_c_interface/index.rst +++ b/doc/arkode/guide/source/Usage/ERKStep_c_interface/index.rst @@ -18,28 +18,14 @@ Using the ERKStep time-stepping module ====================================== -This chapter is concerned with the use of the ERKStep time-stepping -module for the solution of nonstiff initial value problems (IVPs) in a -C or C++ language setting. The following sections discuss the header -files and the layout of the user's main program, and provide -descriptions of the ERKStep user-callable functions and user-supplied -functions. - -The example programs described in the companion document :cite:p:`arkode_ex` may -be helpful. Those codes may be used as templates for new codes and are -included in the ARKODE package ``examples`` subdirectory. - -ERKStep uses the input and output constants from the shared ARKODE -infrastructure. These are defined as needed in this chapter, but for -convenience the full list is provided separately in -:numref:`ARKODE.Constants`. - -The relevant information on using ERKStep's C and C++ interfaces is -detailed in the following sub-sections. +This section is concerned with the use of the ERKStep time-stepping +module for the solution of initial value problems (IVPs) in a C or C++ +language setting. Usage of ERKStep follows that of the rest of ARKODE, +and so in this section we primarily focus on those usage aspects that +are specific to ERKStep. .. toctree:: :maxdepth: 1 - Skeleton User_callable Relaxation diff --git a/doc/arkode/guide/source/Usage/MRIStep_c_interface/Skeleton.rst b/doc/arkode/guide/source/Usage/MRIStep_c_interface/Skeleton.rst index a4a079570b..f1275b0ae3 100644 --- a/doc/arkode/guide/source/Usage/MRIStep_c_interface/Skeleton.rst +++ b/doc/arkode/guide/source/Usage/MRIStep_c_interface/Skeleton.rst @@ -20,71 +20,30 @@ A skeleton of the user's main program ============================================ -The following is a skeleton of the user's main program (or calling program) for -the integration of an ODE IVP using the MRIStep module. Most of the steps are -independent of the NVECTOR, SUNMATRIX, SUNLINSOL and SUNNONLINSOL -implementations used. For the steps that are not, refer to :numref:`NVectors`, -:numref:`SUNMatrix`, :numref:`SUNLinSol`, and :numref:`SUNNonlinSol` for the -specific name of the function to be called or macro to be referenced. +While MRIStep usage generally follows the same pattern as the rest of +ARKODE, since it involves the solution of both MRIStep for the slow +time scale and another time integrator for the fast time scale, we +summarize the differences in using MRIStep here. Steps that are +unchanged from the skeleton program presented in +:numref:`ARKODE.Usage.Skeleton` are *italicized*. -.. index:: User main program +.. index:: MRIStep user main program -#. Initialize parallel or multi-threaded environment, if appropriate. +#. *Initialize parallel or multi-threaded environment, if appropriate.* - For example, call ``MPI_Init`` to initialize MPI if used, or set - ``num_threads``, the number of threads to use within the threaded - vector functions, if used. +#. *Create the SUNDIALS simulation context object* -#. Create the SUNDIALS context object +#. *Set problem dimensions, etc.* - Call :c:func:`SUNContext_Create` to allocate the ``SUNContext`` object. - -#. Set problem dimensions, etc. - - This generally includes the problem size, ``N``, and may include - the local vector length ``Nlocal``. - - .. note:: - - The variables ``N`` and ``Nlocal`` should be of type - ``sunindextype``. - -#. Set vector of initial values - - To set the vector ``y0`` of initial values, use the appropriate - functions defined by the particular NVECTOR implementation. - - For native SUNDIALS vector implementations (except the CUDA and - RAJA based ones), use a call of the form - - .. code-block:: c - - y0 = N_VMake_***(..., ydata); - - if the ``sunrealtype`` array ``ydata`` containing the initial values of - :math:`y` already exists. Otherwise, create a new vector by making - a call of the form - - .. code-block:: c - - y0 = N_VNew_***(...); - - and then set its elements by accessing the underlying data where it - is located with a call of the form - - .. code-block:: c - - ydata = N_VGetArrayPointer_***(y0); - - For details on each of SUNDIALS' provided vector implementations, see - the corresponding sections in :numref:`NVectors` for details. +#. *Set vector of initial values* #. Create an inner stepper object to solve the fast (inner) IVP * If using ARKStep as the fast (inner) integrator, create the ARKStep object with :c:func:`ARKStepCreate` and configure the integrator as desired for - evolving the fast time scale. See sections :numref:`ARKODE.Usage.ARKStep.Skeleton` - and :numref:`ARKODE.Usage.ARKStep.OptionalInputs` for details on configuring + evolving the fast time scale. See sections :numref:`ARKODE.Usage.Skeleton`, + :numref:`ARKODE.Usage.OptionalInputs`, and + :numref:`ARKODE.Usage.ARKStep.OptionalInputs` for details on configuring ARKStep. Once the ARKStep object is setup, create an ``MRIStepInnerStepper`` object @@ -109,18 +68,18 @@ specific name of the function to be called or macro to be referenced. If a *user_data* pointer needs to be passed to user functions called by the fast (inner) integrator then it should be attached here by calling - :c:func:`ARKStepSetUserData()`. This *user_data* pointer will only be + :c:func:`ARKodeSetUserData()`. This *user_data* pointer will only be passed to user-supplied functions that are attached to the fast (inner) integrator. To supply a *user_data* pointer to user-supplied functions called by the slow (outer) integrator the desired pointer should be - attached by calling :c:func:`MRIStepSetUserData()` after creating the + attached by calling :c:func:`ARKodeSetUserData()` after creating the MRIStep memory below. The *user_data* pointers attached to the inner and outer integrators may be the same or different depending on what is required by the user code. Specifying a rootfinding problem for the fast integration is not supported. Rootfinding problems should be created and initialized with - the slow integrator. See the steps below and :c:func:`MRIStepRootInit()` + the slow integrator. See the steps below and :c:func:`ARKodeRootInit()` for more details. #. Create an MRIStep object for the slow (outer) integration @@ -131,192 +90,57 @@ specific name of the function to be called or macro to be referenced. #. Set the slow step size - Call :c:func:`MRIStepSetFixedStep()` to specify the slow time step - size. + Call :c:func:`ARKodeSetFixedStep()` on the MRIStep object to specify the + slow time step size. #. Create and configure implicit solvers (*as appropriate*) Specifically, if MRIStep is configured with an implicit slow right-hand side function in the prior step, then the following steps are recommended: - #. Specify integration tolerances - - Call :c:func:`MRIStepSStolerances()` or :c:func:`MRIStepSVtolerances()` to - specify either a scalar relative tolerance and scalar absolute tolerance, - or a scalar relative tolerance and a vector of absolute tolerances, - respectively. Alternatively, call :c:func:`MRIStepWFtolerances()` - to specify a function which sets directly the weights used in - evaluating WRMS vector norms. See :numref:`ARKODE.Usage.MRIStep.Tolerances` for - details. - - #. Create nonlinear solver object - - If a non-default nonlinear solver object is desired for implicit - MRI stage solves (see :numref:`ARKODE.Usage.MRIStep.NonlinearSolvers`), - then that nonlinear solver object must be created by using - the appropriate functions defined by the particular SUNNONLINSOL - implementation (e.g., ``NLS = SUNNonlinSol_***(...);`` where - ``***`` is the name of the nonlinear solver (see - :numref:`SUNNonlinSol` for details). - - For the SUNDIALS-supplied SUNNONLINSOL implementations, the - nonlinear solver object may be created using a call of the form - - .. code-block:: c - - SUNNonlinearSolver NLS = SUNNonlinSol_*(...); - - where ``*`` can be replaced with "Newton", "FixedPoint", or other - options, as discussed in the sections - :numref:`ARKODE.Usage.ARKStep.NonlinearSolvers` and :numref:`SUNNonlinSol`. - - Note: by default, MRIStep will use the Newton nonlinear solver - (see section :numref:`SUNNonlinSol.Newton`), so a custom nonlinear solver - object is only needed when using a *different* solver, or for the user - to exercise additional controls over the Newton solver. - - #. Attach nonlinear solver module - - If a nonlinear solver object was created above, then it must be - attached to MRIStep using the call (for details see - :numref:`ARKODE.Usage.MRIStep.NonlinearSolvers`): - - .. code-block:: c + #. *Specify integration tolerances* - ier = MRIStepSetNonlinearSolver(...); + #. *Create matrix object* - #. Set nonlinear solver optional inputs + #. *Create linear solver object* - Call the appropriate set functions for the selected nonlinear - solver module to change optional inputs specific to that nonlinear - solver. These *must* be called after attaching the nonlinear - solver to MRIStep, otherwise the optional inputs will be - overridden by MRIStep defaults. See :numref:`SUNNonlinSol` for more - information on optional inputs. + #. *Set linear solver optional inputs* - #. Create matrix object + #. *Attach linear solver module* - If a nonlinear solver requiring a linear solver will be used (e.g., - a Newton iteration) and if that linear solver will be matrix-based, - then a template Jacobian matrix must be created by using the - appropriate functions defined by the particular SUNMATRIX - implementation. + #. *Create nonlinear solver object* - For the SUNDIALS-supplied SUNMATRIX implementations, the - matrix object may be created using a call of the form + #. *Attach nonlinear solver module* - .. code-block:: c + #. *Set nonlinear solver optional inputs* - SUNMatrix A = SUNBandMatrix(...); +#. *Set optional inputs* - or similar for other matrix modules (see :numref:`SUNMatrix` for - further information). +#. *Specify rootfinding problem* - #. Create linear solver object +#. *Advance solution in time* - If a nonlinear solver requiring a linear solver will be used (e.g., - a Newton iteration), then the desired linear solver object(s) must be - created by using the appropriate functions defined by the particular - SUNLINSOL implementation. +#. *Get optional outputs* - For any of the SUNDIALS-supplied SUNLINSOL implementations, the - linear solver object may be created using a call of the form - - .. code-block:: c - - SUNLinearSolver LS = SUNLinSol_*(...); - - where ``*`` can be replaced with "Dense", "SPGMR", or other - options, as discussed in :numref:`SUNLinSol`. - - #. Set linear solver optional inputs - - Call ``*Set*`` functions from the selected linear solver module - to change optional inputs specific to that linear solver. See the - documentation for each SUNLINSOL module in :numref:`SUNLinSol` for details. - - #. Attach linear solver module - - If a linear solver was created above for implicit MRI stage solves, - initialize the ARKLS linear solver interface by attaching the - linear solver object (and Jacobian matrix object, if applicable) - with the call (for details see :numref:`ARKODE.Usage.MRIStep.LinearSolvers`): - - .. code-block:: c - - ier = MRIStepSetLinearSolver(...); - -#. Set optional inputs - - Call ``MRIStepSet*`` functions to change any optional inputs that - control the behavior of MRIStep from their default values. See - :numref:`ARKODE.Usage.MRIStep.OptionalInputs` for details. - -#. Specify rootfinding problem - - Optionally, call :c:func:`MRIStepRootInit()` to initialize a rootfinding - problem to be solved during the integration of the ODE system. See - :numref:`ARKODE.Usage.MRIStep.RootFinding` for general details, and - :numref:`ARKODE.Usage.MRIStep.OptionalInputs` for relevant optional input calls. - -#. Advance solution in time - - For each point at which output is desired, call - - .. code-block:: c - - ier = MRIStepEvolve(arkode_mem, tout, yout, &tret, itask); - - Here, ``itask`` specifies the return mode. The vector ``yout`` - (which can be the same as the vector ``y0`` above) will contain - :math:`y(t_\text{out})`. See :numref:`ARKODE.Usage.MRIStep.Integration` for details. - -#. Get optional outputs - - Call ``MRIStepGet*`` and/or ``ARKStepGet*`` functions to obtain optional - output from the slow or fast integrators respectively. See - :numref:`ARKODE.Usage.MRIStep.OptionalOutputs` and - :numref:`ARKODE.Usage.ARKStep.OptionalOutputs` for details. - -#. Deallocate memory for solution vector - - Upon completion of the integration, deallocate memory for the - vector ``y`` (or ``yout``) by calling the NVECTOR destructor - function: - - .. code-block:: c - - N_VDestroy(y); +#. *Deallocate memory for solution vector* #. Free solver memory * If ARKStep was used as the fast (inner) IVP integrator, call - :c:func:`MRIStepInnerStepper_Free` and :c:func:`ARKStepFree` to free the + :c:func:`MRIStepInnerStepper_Free` and :c:func:`ARKodeFree` to free the memory allocated for the fast (inner) integrator. * If a user-defined fast (inner) integrator was supplied, free the integrator content and call :c:func:`MRIStepInnerStepper_Free` to free the ``MRIStepInnerStepper`` object. - * Call :c:func:`MRIStepFree` to free the memory allocated for the slow - integration object. - -#. Free linear solver and matrix memory (*as appropriate*) - - Call :c:func:`SUNLinSolFree()` and (possibly) - :c:func:`SUNMatDestroy()` to free any memory allocated for any - linear solver and/or matrix objects created above for either the fast or - slow integrators. - -#. Free nonlinear solver memory (*as appropriate*) + * Call :c:func:`ARKodeFree` to free the memory allocated for the MRIStep + slow integration object. - If a user-supplied ``SUNNonlinearSolver`` was provided to MRIStep, - then call :c:func:`SUNNonlinSolFree()` to free any memory allocated - for the nonlinear solver object created above. +#. *Free linear solver and matrix memory (as appropriate)* -#. **Free the SUNContext object** - Call :c:func:`SUNContext_Free` to free the memory allocated for the ``SUNContext`` object. +#. *Free nonlinear solver memory (as appropriate)* - #. Finalize MPI, if used +#. *Free the SUNContext object* - Call ``MPI_Finalize`` to terminate MPI. +#. *Finalize MPI, if used* diff --git a/doc/arkode/guide/source/Usage/MRIStep_c_interface/User_callable.rst b/doc/arkode/guide/source/Usage/MRIStep_c_interface/User_callable.rst index c5948c5838..052cf6024f 100644 --- a/doc/arkode/guide/source/Usage/MRIStep_c_interface/User_callable.rst +++ b/doc/arkode/guide/source/Usage/MRIStep_c_interface/User_callable.rst @@ -18,21 +18,20 @@ MRIStep User-callable functions ================================== -This section describes the functions that are called by the -user to setup and then solve an IVP using the MRIStep time-stepping -module. Some of these are required; however, starting with -:numref:`ARKODE.Usage.MRIStep.OptionalInputs`, the functions listed involve -optional inputs/outputs or restarting, and those paragraphs may be -skipped for a casual use of ARKODE's MRIStep module. In any case, -refer to the preceding section, :numref:`ARKODE.Usage.MRIStep.Skeleton`, -for the correct order of these calls. +This section describes the MRIStep-specific functions that may be called +by the user to setup and then solve an IVP using the MRIStep time-stepping +module. The large majority of these routines merely wrap :ref:`underlying +ARKODE functions `, and are now deprecated +-- each of these are clearly marked. However, some +of these user-callable functions are specific to ERKStep, as explained +below. -On an error, each user-callable function returns a negative value (or -``NULL`` if the function returns a pointer) and sends an error message -to the error handler routine, which prints the message to ``stderr`` -by default. However, the user can set a file as error output or can -provide their own error handler function (see -:numref:`ARKODE.Usage.MRIStep.OptionalInputs` for details). +As discussed in the main :ref:`ARKODE user-callable function introduction +`, each of ARKODE's time-stepping modules +clarifies the categories of user-callable functions that it supports. +MRIStep supports the following categories: + +* implicit nonlinear and/or linear solvers @@ -108,6 +107,10 @@ MRIStep initialization and deallocation functions :return value: None + .. deprecated:: x.y.z + + Use :c:func:`ARKodeFree` instead. + .. _ARKODE.Usage.MRIStep.Tolerances: @@ -115,40 +118,6 @@ MRIStep initialization and deallocation functions MRIStep tolerance specification functions ------------------------------------------------------ -These functions specify the integration tolerances. One of them -**should** be called before the first call to -:c:func:`MRIStepEvolve()`; otherwise default values of ``reltol = -1e-4`` and ``abstol = 1e-9`` will be used, which may be entirely -incorrect for a specific problem. - -The integration tolerances ``reltol`` and ``abstol`` define a vector -of error weights, ``ewt``. In the case of -:c:func:`MRIStepSStolerances()`, this vector has components - -.. code-block:: c - - ewt[i] = 1.0/(reltol*abs(y[i]) + abstol); - -whereas in the case of :c:func:`MRIStepSVtolerances()` the vector components -are given by - -.. code-block:: c - - ewt[i] = 1.0/(reltol*abs(y[i]) + abstol[i]); - -This vector is used in all error tests, which use a weighted RMS norm -on all error-like vectors :math:`v`: - -.. math:: - \|v\|_{WRMS} = \left( \frac{1}{N} \sum_{i=1}^N (v_i\; ewt_i)^2 \right)^{1/2}, - -where :math:`N` is the problem dimension. - -Alternatively, the user may supply a custom function to supply the -``ewt`` vector, through a call to :c:func:`MRIStepWFtolerances()`. - - - .. c:function:: int MRIStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) This function specifies scalar relative and absolute tolerances. @@ -162,6 +131,10 @@ Alternatively, the user may supply a custom function to supply the :retval ARK_NO_MALLOC: if the MRIStep memory was not allocated by the time-stepping module :retval ARK_ILL_INPUT: if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSStolerances` instead. + .. c:function:: int MRIStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) @@ -180,6 +153,10 @@ Alternatively, the user may supply a custom function to supply the :retval ARK_NO_MALLOC: if the MRIStep memory was not allocated by the time-stepping module :retval ARK_ILL_INPUT: if an argument has an illegal value (e.g. a negative tolerance). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSVtolerances` instead. + .. c:function:: int MRIStepWFtolerances(void* arkode_mem, ARKEwtFn efun) @@ -195,100 +172,9 @@ Alternatively, the user may supply a custom function to supply the :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` :retval ARK_NO_MALLOC: if the MRIStep memory was not allocated by the time-stepping module + .. deprecated:: x.y.z - - -General advice on the choice of tolerances -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For many users, the appropriate choices for tolerance values in -``reltol`` and ``abstol`` are a concern. The following pieces -of advice are relevant. - -(1) The scalar relative tolerance ``reltol`` is to be set to control - relative errors. So a value of :math:`10^{-4}` means that errors - are controlled to .01%. We do not recommend using ``reltol`` larger - than :math:`10^{-3}`. On the other hand, ``reltol`` should not be so - small that it is comparable to the unit roundoff of the machine - arithmetic (generally around :math:`10^{-15}` for double-precision). - -(2) The absolute tolerances ``abstol`` (whether scalar or vector) need - to be set to control absolute errors when any components of the - solution vector :math:`y` may be so small that pure relative error - control is meaningless. For example, if :math:`y_i` starts at some - nonzero value, but in time decays to zero, then pure relative - error control on :math:`y_i` makes no sense (and is overly costly) - after :math:`y_i` is below some noise level. Then ``abstol`` (if - scalar) or ``abstol[i]`` (if a vector) needs to be set to that - noise level. If the different components have different noise - levels, then ``abstol`` should be a vector. For example, see the - example problem ``ark_robertson.c``, and the discussion - of it in the ARKODE Examples Documentation :cite:p:`arkode_ex`. In that - problem, the three components vary between 0 and 1, and have - different noise levels; hence the ``atols`` vector therein. It is - impossible to give any general advice on ``abstol`` values, - because the appropriate noise levels are completely - problem-dependent. The user or modeler hopefully has some idea as - to what those noise levels are. - -(3) Finally, it is important to pick all the tolerance values - conservatively, because they control the error committed on each - individual step. The final (global) errors are an accumulation of - those per-step errors, where that accumulation factor is - problem-dependent. A general rule of thumb is to reduce the - tolerances by a factor of 10 from the actual desired limits on - errors. So if you want .01% relative accuracy (globally), a good - choice for ``reltol`` is :math:`10^{-5}`. In any case, it is - a good idea to do a few experiments with the tolerances to see how - the computed solution values vary as tolerances are reduced. - - - -Advice on controlling nonphysical negative values -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In many applications, some components in the true solution are always -positive or non-negative, though at times very small. In the -numerical solution, however, small negative (nonphysical) values -can then occur. In most cases, these values are harmless, and simply -need to be controlled, not eliminated, but in other cases any value -that violates a constraint may cause a simulation to halt. For both of -these scenarios the following pieces of advice are relevant. - -(1) The best way to control the size of unwanted negative computed - values is with tighter absolute tolerances. Again this requires - some knowledge of the noise level of these components, which may - or may not be different for different components. Some - experimentation may be needed. - -(2) If output plots or tables are being generated, and it is important - to avoid having negative numbers appear there (for the sake of - avoiding a long explanation of them, if nothing else), then - eliminate them, but only in the context of the output medium. Then - the internal values carried by the solver are unaffected. Remember - that a small negative value in :math:`y` returned by MRIStep, with - magnitude comparable to ``abstol`` or less, is equivalent to zero - as far as the computation is concerned. - -(3) The user's right-hand side routine :math:`f^I` - should never change a negative value in the solution vector :math:`y` - to a non-negative value in attempt to "fix" this problem, - since this can lead to numerical instability. If the :math:`f^I` - routine cannot tolerate a zero or negative value (e.g. because - there is a square root or log), then the offending value should be - changed to zero or a tiny positive number in a temporary variable - (not in the input :math:`y` vector) for the purposes of computing - :math:`f^I(t, y)`. - -.. - (4) Positivity and non-negativity constraints on components can be - enforced by use of the recoverable error return feature in the - user-supplied right-hand side function, :math:`f^I`. When a - recoverable error is encountered, MRIStep will retry the step with - a smaller step size, which typically alleviates the problem. - However, because this option involves some additional overhead - cost, it should only be exercised if the use of absolute - tolerances to control the computed values is unsuccessful. + Use :c:func:`ARKodeWFtolerances` instead. @@ -297,74 +183,6 @@ these scenarios the following pieces of advice are relevant. Linear solver interface functions ------------------------------------------- -As previously explained, the Newton iterations used in solving -implicit systems within MRIStep require the solution of linear -systems of the form - -.. math:: - \mathcal{A}\left(z_i^{(m)}\right) \delta^{(m+1)} = -G\left(z_i^{(m)}\right) - -where - -.. math:: - \mathcal{A} \approx I - \gamma J, \qquad J = \frac{\partial f^I}{\partial y}. - -ARKODE's ARKLS linear solver interface supports all valid -``SUNLinearSolver`` modules for this task. - -Matrix-based ``SUNLinearSolver`` modules utilize ``SUNMatrix`` objects -to store the approximate Jacobian matrix :math:`J`, the Newton matrix -:math:`\mathcal{A}`, and, when using direct solvers, the factorizations -used throughout the solution process. - -Matrix-free ``SUNLinearSolver`` modules instead use iterative methods -to solve the Newton systems of equations, and only require the -*action* of the matrix on a vector, :math:`\mathcal{A}v`. With most -of these methods, preconditioning can be done on the left only, on the -right only, on both the left and the right, or not at all. The -exceptions to this rule are SPFGMR that supports right preconditioning -only and PCG that performs symmetric preconditioning. For the -specification of a preconditioner, see the iterative linear solver -portions of :numref:`ARKODE.Usage.MRIStep.OptionalInputs` and -:numref:`ARKODE.Usage.UserSupplied`. - -If preconditioning is done, user-supplied functions should be used to -define left and right preconditioner matrices :math:`P_1` and -:math:`P_2` (either of which could be the identity matrix), such that -the product :math:`P_{1}P_{2}` approximates the Newton matrix -:math:`\mathcal{A} = I - \gamma J`. - -To specify a generic linear solver for MRIStep to use for the Newton -systems, after the call to :c:func:`MRIStepCreate()` but before any -calls to :c:func:`MRIStepEvolve()`, the user's program must create the -appropriate ``SUNLinearSolver`` object and call the function -:c:func:`MRIStepSetLinearSolver()`, as documented below. To create -the ``SUNLinearSolver`` object, the user may call one of the -SUNDIALS-packaged SUNLinSol module constructor routines via a call of -the form - -.. code:: c - - SUNLinearSolver LS = SUNLinSol_*(...); - -The current list of SUNDIALS-packaged SUNLinSol modules, and their -constructor routines, may be found in chapter :numref:`SUNLinSol`. -Alternately, a user-supplied ``SUNLinearSolver`` module may be created -and used. Specific information on how to create such user-provided -modules may be found in :numref:`SUNLinSol.API.Custom`. - -Once this solver object has been constructed, the user should attach -it to MRIStep via a call to :c:func:`MRIStepSetLinearSolver()`. The -first argument passed to this function is the MRIStep memory pointer -returned by :c:func:`MRIStepCreate()`; the second argument is the -``SUNLinearSolver`` object created above. The third argument is an -optional ``SUNMatrix`` object to accompany matrix-based -``SUNLinearSolver`` inputs (for matrix-free linear solvers, the third -argument should be ``NULL``). A call to this function initializes the -ARKLS linear solver interface, linking it to the MRIStep integrator, -and allows the user to specify additional parameters and routines -pertinent to their choice of linear solver. - .. c:function:: int MRIStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix J) This function specifies the ``SUNLinearSolver`` object that MRIStep @@ -406,6 +224,10 @@ pertinent to their choice of linear solver. insufficient to store :math:`\mathcal{A}` then it will need to be resized internally by MRIStep. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinearSolver` instead. + .. _ARKODE.Usage.MRIStep.NonlinearSolvers: @@ -413,24 +235,6 @@ pertinent to their choice of linear solver. Nonlinear solver interface functions ------------------------------------------- -When changing the nonlinear solver in MRIStep, after the -call to :c:func:`MRIStepCreate()` but before any calls to -:c:func:`MRIStepEvolve()`, the user's program must create the -appropriate SUNNonlinSol object and call -:c:func:`MRIStepSetNonlinearSolver()`, as documented below. If any -calls to :c:func:`MRIStepEvolve()` have been made, then MRIStep will -need to be reinitialized by calling :c:func:`MRIStepReInit()` to -ensure that the nonlinear solver is initialized correctly before any -subsequent calls to :c:func:`MRIStepEvolve()`. - -The first argument passed to the routine -:c:func:`MRIStepSetNonlinearSolver()` is the MRIStep memory pointer -returned by :c:func:`MRIStepCreate()`; the second argument passed -to this function is the desired ``SUNNonlinearSolver`` object to use for -solving the nonlinear system for each implicit stage. A call to this -function attaches the nonlinear solver to the main MRIStep integrator. - - .. c:function:: int MRIStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) This function specifies the ``SUNNonlinearSolver`` object @@ -451,6 +255,10 @@ function attaches the nonlinear solver to the main MRIStep integrator. default; a call to this routine replaces that module with the supplied *NLS* object. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinearSolver` instead. + .. _ARKODE.Usage.MRIStep.RootFinding: @@ -458,18 +266,6 @@ function attaches the nonlinear solver to the main MRIStep integrator. Rootfinding initialization function -------------------------------------- -As described in the section :numref:`ARKODE.Mathematics.Rootfinding`, while -solving the IVP, ARKODE's time-stepping modules have the capability to -find the roots of a set of user-defined functions. In the MRIStep module root -finding is performed between slow solution time steps only (i.e., it is not -performed within the sub-stepping a fast time scales). To activate the -root-finding algorithm, call the following function. This is normally -called only once, prior to the first call to -:c:func:`MRIStepEvolve()`, but if the rootfinding problem is to be -changed during the solution, :c:func:`MRIStepRootInit()` can also be -called prior to a continuation call to :c:func:`MRIStepEvolve()`. - - .. c:function:: int MRIStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) Initializes a rootfinding problem to be solved during the @@ -500,6 +296,10 @@ called prior to a continuation call to :c:func:`MRIStepEvolve()`. Rootfinding is only supported for the slow (outer) integrator and should not be actived for the fast (inner) integrator. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeRootInit` instead. + .. _ARKODE.Usage.MRIStep.Integration: @@ -507,13 +307,6 @@ called prior to a continuation call to :c:func:`MRIStepEvolve()`. MRIStep solver function ------------------------- -This is the central step in the solution process -- the call to perform -the integration of the IVP. The input argument *itask* specifies one of two -modes as to where MRIStep is to return a solution. These modes are modified if -the user has set a stop time (with a call to the optional input function -:c:func:`MRIStepSetStopTime()`) or has requested rootfinding. - - .. c:function:: int MRIStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype *tret, int itask) Integrates the ODE over an interval in :math:`t`. @@ -613,6 +406,10 @@ the user has set a stop time (with a call to the optional input function On all other error returns, *tret* and *yout* are left unchanged from those provided to the routine. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeEvolve` instead. + .. _ARKODE.Usage.MRIStep.OptionalInputs: @@ -620,76 +417,36 @@ the user has set a stop time (with a call to the optional input function Optional input functions ------------------------- -There are numerous optional input parameters that control the behavior -of MRIStep, each of which may be modified from its default value through -calling an appropriate input function. The following tables list all -optional input functions, grouped by which aspect of MRIStep they control. -Detailed information on the calling syntax and arguments for each -function are then provided following each table. -The optional inputs are grouped into the following categories: - -* General MRIStep options (:numref:`ARKODE.Usage.MRIStep.MRIStepInput`), - -* IVP method solver options (:numref:`ARKODE.Usage.MRIStep.MRIStepMethodInput`), - -* Implicit stage solver options (:numref:`ARKODE.Usage.MRIStep.MRIStepSolverInput`), +.. _ARKODE.Usage.MRIStep.MRIStepInput: -* Linear solver interface options (:numref:`ARKODE.Usage.MRIStep.ARKLsInputs`), and +Optional inputs for MRIStep +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* Rootfinding options (:numref:`ARKODE.Usage.MRIStep.MRIStepRootfindingInput`). -For the most casual use of MRIStep, relying on the default set of -solver parameters, the reader can skip to the section on user-supplied -functions, :numref:`ARKODE.Usage.UserSupplied`. +.. c:function:: int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) -We note that, on an error return, all of the optional input functions send an -error message to the error handler function. All error return values are -negative, so a test on the return arguments for negative values will catch all -errors. Finally, a call to an ``MRIStepSet***`` function can generally be made -from the user's calling program at any time and, if successful, takes effect -immediately. ``MRIStepSet***`` functions that cannot be called at any time note -this in the "**Notes**:" section of the function documentation. + Sets a user-supplied multirate time-step controller object. + :param arkode_mem: pointer to the ARKODE memory block. + :param C: user-supplied time adaptivity controller. If ``NULL`` then this routine + will just call :c:func:`ARKodeSetAdaptController` to specify that the + default ARKODE controller should be created. + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: *C* was ``NULL`` and the PID controller could not be allocated. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. -.. _ARKODE.Usage.MRIStep.MRIStepInput: + .. note:: -Optional inputs for MRIStep -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + This routine should only be called directly when using a "multirate" + :c:type:`SUNAdaptController`, i.e., one with type ``SUN_ADAPTCONTROLLER_MRI_H`` + or ``SUN_ADAPTCONTROLLER_MRI_TOL``. Otherwise, it is more efficient to call + :c:func:`ARKodeSetAdaptController` directly. -.. _ARKODE.Usage.MRIStep.MRIStepInput.Table: -.. table:: Optional inputs for MRIStep - - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Optional input | Function name | Default | - +===============================================================+===========================================+========================+ - | Return MRIStep solver parameters to their defaults | :c:func:`MRIStepSetDefaults()` | internal | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Set dense output interpolation type | :c:func:`MRIStepSetInterpolantType()` | ``ARK_INTERP_HERMITE`` | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Set dense output polynomial degree | :c:func:`MRIStepSetInterpolantDegree()` | 5 | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Supply a pointer to a diagnostics output file | :c:func:`MRIStepSetDiagnostics()` | ``NULL`` | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Run with fixed-step sizes | :c:func:`MRIStepSetFixedStep()` | required | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Maximum no. of warnings for :math:`t_n+h = t_n` | :c:func:`MRIStepSetMaxHnilWarns()` | 10 | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Maximum no. of internal steps before *tout* | :c:func:`MRIStepSetMaxNumSteps()` | 500 | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Set a value for :math:`t_{stop}` | :c:func:`MRIStepSetStopTime()` | undefined | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Interpolate at :math:`t_{stop}` | :c:func:`MRIStepSetInterpolateStopTime()` | ``SUNFALSE`` | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Disable the stop time | :c:func:`MRIStepClearStopTime` | N/A | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Supply a pointer for user data | :c:func:`MRIStepSetUserData()` | ``NULL`` | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Supply a function to be called prior to the inner integration | :c:func:`MRIStepSetPreInnerFn()` | ``NULL`` | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ - | Supply a function to be called after the inner integration | :c:func:`MRIStepSetPostInnerFn()` | ``NULL`` | - +---------------------------------------------------------------+-------------------------------------------+------------------------+ + .. versionadded:: x.y.z @@ -707,11 +464,16 @@ Optional inputs for MRIStep .. note:: + This function does not change problem-defining function pointers *fs* and *ff* or the *user_data* pointer. It also does not affect any data structures or options related to root-finding (those can be reset using :c:func:`MRIStepRootInit()`). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDefaults` instead. + .. c:function:: int MRIStepSetInterpolantType(void* arkode_mem, int itype) @@ -745,6 +507,10 @@ Optional inputs for MRIStep If this routine is not called, the Hermite interpolation module will be used. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantType` instead. + .. c:function:: int MRIStepSetInterpolantDegree(void* arkode_mem, int degree) @@ -785,14 +551,17 @@ Optional inputs for MRIStep When :math:`q=1`, a linear interpolant is the default to ensure values obtained by the integrator are returned at the ends of the time interval. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantDegree` instead. + .. c:function:: int MRIStepSetDenseOrder(void* arkode_mem, int dord) - *This function is deprecated, and will be removed in a future release. - Users should transition to calling* :c:func:`MRIStepSetInterpolantDegree()` - *instead.* + .. deprecated:: 5.2.0 + Use :c:func:`ARKodeSetInterpolantDegree` instead. .. c:function:: int MRIStepSetDiagnostics(void* arkode_mem, FILE* diagfp) @@ -840,29 +609,9 @@ Optional inputs for MRIStep The step sizes used by the inner (fast) stepper may be controlled through calling the appropriate "Set" routines on the inner integrator. + .. deprecated:: x.y.z -.. - .. c:function:: int MRIStepSetInitStep(void* arkode_mem, sunrealtype hin) - - Specifies the initial time step size MRIStep should use after - initialization or re-initialization. - - :param arkode_mem: pointer to the MRIStep memory block. - :param hin: value of the initial step to be attempted :math:`(\ne 0)`. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - :retval ARK_ILL_INPUT: if an argument has an illegal value - - .. note:: - - Pass 0.0 to use the default value. - - By default, MRIStep estimates the initial step size to be the - solution :math:`h` of the equation :math:`\left\| \frac{h^2 - \ddot{y}}{2}\right\| = 1`, where :math:`\ddot{y}` is an estimated - value of the second derivative of the solution at *t0*. - + Use :c:func:`ARKodeSetFixedStep` instead. @@ -885,6 +634,9 @@ Optional inputs for MRIStep A negative value indicates that no warning messages should be issued. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxHnilWarns` instead. @@ -908,40 +660,9 @@ Optional inputs for MRIStep Passing *mxsteps* < 0 disables the test (not recommended). + .. deprecated:: x.y.z - -.. - .. c:function:: int MRIStepSetMaxStep(void* arkode_mem, sunrealtype hmax) - - Specifies the upper bound on the magnitude of the time step size. - - :param arkode_mem: pointer to the MRIStep memory block. - :param hmax: maximum absolute value of the time step size :math:`(\ge 0)`. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - :retval ARK_ILL_INPUT: if an argument has an illegal value - - .. note:: - - Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. - - -.. - .. c:function:: int MRIStepSetMinStep(void* arkode_mem, sunrealtype hmin) - - Specifies the lower bound on the magnitude of the time step size. - - :param arkode_mem: pointer to the MRIStep memory block. - :param hmin: minimum absolute value of the time step size :math:`(\ge 0)`. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - :retval ARK_ILL_INPUT: if an argument has an illegal value - - .. note:: - - Pass *hmin* :math:`\le 0.0` to set the default value of 0. + Use :c:func:`ARKodeSetMaxNumSteps` instead. @@ -969,6 +690,11 @@ Optional inputs for MRIStep :c:func:`MRIStepReset` will remain active but can be disabled by calling :c:func:`MRIStepClearStopTime`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStopTime` instead. + + .. c:function:: int MRIStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) @@ -986,6 +712,11 @@ Optional inputs for MRIStep .. versionadded:: 5.6.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolateStopTime` instead. + + .. c:function:: int MRIStepClearStopTime(void* arkode_mem) @@ -1003,6 +734,11 @@ Optional inputs for MRIStep .. versionadded:: 5.5.1 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeClearStopTime` instead. + + .. c:function:: int MRIStepSetUserData(void* arkode_mem, void* user_data) @@ -1028,6 +764,11 @@ Optional inputs for MRIStep may be the same as or different from the pointer attached to the outer integrator depending on what is required by the user code. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetUserData` instead. + + .. c:function:: int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn) @@ -1041,6 +782,7 @@ Optional inputs for MRIStep :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + .. c:function:: int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) Specifies the function called *after* each inner integration. @@ -1053,22 +795,6 @@ Optional inputs for MRIStep :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` -.. - .. c:function:: int MRIStepSetMaxErrTestFails(void* arkode_mem, int maxnef) - - Specifies the maximum number of error test failures - permitted in attempting one step, before returning with an error. - - :param arkode_mem: pointer to the MRIStep memory block. - :param maxnef: maximum allowed number of error test failures :math:`(>0)`. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` - :retval ARK_ILL_INPUT: if an argument has an illegal value - - .. note:: - - The default value is 7; set *maxnef* :math:`\le 0` to specify this default. @@ -1103,6 +829,11 @@ Optional inputs for IVP method selection :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory is ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetOrder` instead. + + .. c:function:: int MRIStepSetCoupling(void* arkode_mem, MRIStepCoupling C) @@ -1120,6 +851,10 @@ Optional inputs for IVP method selection For a description of the :c:type:`MRIStepCoupling` type and related functions for creating Butcher tables see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. + .. warning:: + + This should not be used with :c:func:`ARKodeSetOrder`. + .. _ARKODE.Usage.MRIStep.MRIStepSolverInput: @@ -1127,31 +862,6 @@ Optional inputs for IVP method selection Optional inputs for implicit stage solves ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The mathematical explanation for the nonlinear solver strategies used -by MRIStep, including how each of the parameters below is used within -the code, is provided in :numref:`ARKODE.Mathematics.Nonlinear`. - - -.. cssclass:: table-bordered - -========================================================= ========================================= ============ -Optional input Function name Default -========================================================= ========================================= ============ -Specify linearly implicit :math:`f^I` :c:func:`MRIStepSetLinear()` ``SUNFALSE`` -Specify nonlinearly implicit :math:`f^I` :c:func:`MRIStepSetNonlinear()` ``SUNTRUE`` -Implicit predictor method :c:func:`MRIStepSetPredictorMethod()` 0 -Maximum number of nonlinear iterations :c:func:`MRIStepSetMaxNonlinIters()` 3 -Coefficient in the nonlinear convergence test :c:func:`MRIStepSetNonlinConvCoef()` 0.1 -Nonlinear convergence rate constant :c:func:`MRIStepSetNonlinCRDown()` 0.3 -Nonlinear residual divergence ratio :c:func:`MRIStepSetNonlinRDiv()` 2.3 -User-provided implicit stage predictor :c:func:`MRIStepSetStagePredictFn()` ``NULL`` -RHS function for nonlinear system evaluations :c:func:`MRIStepSetNlsRhsFn()` ``NULL`` -Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDeduceImplicitRhs` ``SUNFALSE`` -========================================================= ========================================= ============ - - - - .. c:function:: int MRIStepSetLinear(void* arkode_mem, int timedepend) Specifies that the implicit slow right-hand side function, :math:`f^I(t,y)` @@ -1180,6 +890,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe The only SUNDIALS-provided SUNNonlinearSolver module that is compatible with the :c:func:`MRIStepSetLinear()` option is the Newton solver. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinear` instead. + .. c:function:: int MRIStepSetNonlinear(void* arkode_mem) @@ -1201,6 +915,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe :c:func:`MRIStepSetDeltaGammaMax()` to reset the step size ratio threshold to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinear` instead. + .. c:function:: int MRIStepSetPredictorMethod(void* arkode_mem, int method) @@ -1239,6 +957,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe The "bootstrap" predictor (option 4 above) has been deprecated, and will be removed from a future release. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetPredictorMethod` instead. + .. c:function:: int MRIStepSetMaxNonlinIters(void* arkode_mem, int maxcor) @@ -1258,6 +980,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe The default value is 3; set *maxcor* :math:`\le 0` to specify this default. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNonlinIters` instead. + .. c:function:: int MRIStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) @@ -1275,6 +1001,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe The default value is 0.1; set *nlscoef* :math:`\le 0` to specify this default. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinConvCoef` instead. + .. c:function:: int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) @@ -1292,6 +1022,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinCRDown` instead. + .. c:function:: int MRIStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) @@ -1311,6 +1045,10 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNonlinRDiv` instead. + .. c:function:: int MRIStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) @@ -1330,6 +1068,11 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe See :numref:`ARKODE.Usage.StagePredictFn` for more information on this user-supplied routine. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStagePredictFn` instead. + + .. c:function:: int MRIStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fs) @@ -1353,6 +1096,11 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe When using a non-default nonlinear solver, this function must be called *after* :c:func:`MRIStepSetNonlinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNlsRhsFn` instead. + + .. c:function:: int MRIStepSetDeduceImplicitRhs(void *arkode_mem, sunbooleantype deduce) @@ -1370,87 +1118,23 @@ Specify if :math:`f^I` is deduced after a nonlinear solve :c:func:`MRIStepSetDe .. versionadded:: 5.2.0 + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDeduceImplicitRhs` instead. + + .. _ARKODE.Usage.MRIStep.ARKLsInputs: Linear solver interface optional input functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The mathematical explanation of the linear solver methods -available to MRIStep is provided in :numref:`ARKODE.Mathematics.Linear`. We -group the user-callable routines into -four categories: general routines concerning the update frequency for -matrices and/or preconditioners, optional inputs for matrix-based -linear solvers, optional inputs for matrix-free linear solvers, and -optional inputs for iterative linear solvers. We note that the -matrix-based and matrix-free groups are mutually exclusive, whereas the -"iterative" tag can apply to either case. - - .. _ARKODE.Usage.MRIStep.ARKLsInputs.General: -.. index:: - single: optional input; generic linear solver interface (MRIStep) - Optional inputs for the ARKLS linear solver interface """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -As discussed in :numref:`ARKODE.Mathematics.Linear.Setup`, ARKODE -strives to reuse matrix and preconditioner data for as many solves as -possible to amortize the high costs of matrix construction and -factorization. To that end, MRIStep provides user-callable -routines to modify this behavior. Recall that the -Newton system matrices that arise within an implicit stage solve are -:math:`{\mathcal A}(t,z) \approx I - \gamma J(t,z)`, where the -implicit right-hand side function has Jacobian matrix -:math:`J(t,z) = \frac{\partial f^I(t,z)}{\partial z}`. - -The matrix or preconditioner for :math:`{\mathcal A}` can only be -updated within a call to the linear solver 'setup' routine. In -general, the frequency with which the linear solver setup routine is -called may be controlled with the *msbp* argument to -:c:func:`MRIStepSetLSetupFrequency()`. When this occurs, the -validity of :math:`{\mathcal A}` for successive time steps -intimately depends on whether the corresponding :math:`\gamma` and -:math:`J` inputs remain valid. - -At each call to the linear solver setup routine the decision to update -:math:`\mathcal{A}` with a new value of :math:`\gamma`, and to reuse -or reevaluate Jacobian information, depends on several factors including: - -* the success or failure of previous solve attempts, -* the success or failure of the previous time step attempts, -* the change in :math:`\gamma` from the value used when constructing :math:`\mathcal{A}`, and -* the number of steps since Jacobian information was last evaluated. - -The frequency with which to update Jacobian information can be controlled -with the *msbj* argument to :c:func:`MRIStepSetJacEvalFrequency()`. -We note that this is only checked *within* calls to the linear solver setup -routine, so values *msbj* :math:`<` *msbp* do not make sense. For -linear-solvers with user-supplied preconditioning the above factors are used -to determine whether to recommend updating the Jacobian information in the -preconditioner (i.e., whether to set *jok* to ``SUNFALSE`` in calling the -user-supplied :c:type:`ARKLsPrecSetupFn()`). For matrix-based linear solvers -these factors determine whether the matrix :math:`J(t,y) = \frac{\partial f^I(t,y)}{\partial y}` -should be updated (either with an internal finite difference approximation or -a call to the user-supplied :c:type:`ARKLsJacFn`); if not then the previous -value is reused and the system matrix :math:`{\mathcal A}(t,y) \approx I - \gamma J(t,y)` -is recomputed using the current :math:`\gamma` value. - - - -.. cssclass:: table-bordered - -============================================= ========================================= ============ -Optional input Function name Default -============================================= ========================================= ============ -Max change in step signaling new :math:`J` :c:func:`MRIStepSetDeltaGammaMax()` 0.2 -Linear solver setup frequency :c:func:`MRIStepSetLSetupFrequency()` 20 -Jacobian / preconditioner update frequency :c:func:`MRIStepSetJacEvalFrequency()` 51 -============================================= ========================================= ============ - - .. c:function:: int MRIStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) Specifies a scaled step size ratio tolerance, beyond which the @@ -1468,9 +1152,11 @@ Jacobian / preconditioner update frequency :c:func:`MRIStepSetJacEvalFrequen Any non-positive parameter will imply a reset to the default value. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDeltaGammaMax` instead. + -.. index:: - single: optional input; linear solver setup frequency (MRIStep) .. c:function:: int MRIStepSetLSetupFrequency(void* arkode_mem, int msbp) @@ -1491,10 +1177,11 @@ Jacobian / preconditioner update frequency :c:func:`MRIStepSetJacEvalFrequen step. If **msbp** is 0, the default value of 20 will be used. A negative value forces a linear solver step at each implicit stage. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLSetupFrequency` instead. + -.. index:: - single: optional input; Jacobian update frequency (MRIStep) - single: optional input; preconditioner update frequency (MRIStep) .. c:function:: int MRIStepSetJacEvalFrequency(void* arkode_mem, long int msbj) @@ -1522,6 +1209,9 @@ Jacobian / preconditioner update frequency :c:func:`MRIStepSetJacEvalFrequen This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetJacEvalFrequency` instead. @@ -1531,48 +1221,6 @@ Jacobian / preconditioner update frequency :c:func:`MRIStepSetJacEvalFrequen Optional inputs for matrix-based ``SUNLinearSolver`` modules """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.. cssclass:: table-bordered - -========================================= =========================================== ============= -Optional input Function name Default -========================================= =========================================== ============= -Jacobian function :c:func:`MRIStepSetJacFn()` ``DQ`` -Linear system function :c:func:`MRIStepSetLinSysFn()` internal -Enable or disable linear solution scaling :c:func:`MRIStepSetLinearSolutionScaling()` on -========================================= =========================================== ============= - -When using matrix-based linear solver modules, the ARKLS solver interface needs -a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or -the linear system :math:`I - \gamma J`. The function to evaluate the Jacobian -must be of type :c:func:`ARKLsJacFn()`. The user can supply a custom Jacobian -function, or if using a dense or banded :math:`J` can use the default internal -difference quotient approximation that comes with the ARKLS interface. At -present, we do not supply a corresponding routine to approximate Jacobian -entries in sparse matrices :math:`J`. To specify a user-supplied Jacobian -function *jac*, MRIStep provides the function :c:func:`MRIStepSetJacFn()`. -Alternatively, a function of type :c:func:`ARKLsLinSysFn()` can be provided to -evaluate the matrix :math:`I - \gamma J`. By default, ARKLS uses an -internal linear system function leveraging the SUNMATRIX API to form the matrix -:math:`I - \gamma J`. To specify a user-supplied linear system function -*linsys*, MRIStep provides the function :c:func:`MRIStepSetLinSysFn()`. In -either case the matrix information will be updated infrequently to reduce matrix -construction and, with direct solvers, factorization costs. As a result the -value of :math:`\gamma` may not be current and a scaling factor is applied to the -solution of the linear system to account for lagged value of :math:`\gamma`. See -:numref:`SUNLinSol.Lagged_matrix` for more details. The function -:c:func:`MRIStepSetLinearSolutionScaling()` can be used to disable this scaling -when necessary, e.g., when providing a custom linear solver that updates the -matrix using the current :math:`\gamma` as part of the solve. - -The ARKLS interface passes the user data pointer to the Jacobian and linear -system functions. This allows the user to create an arbitrary structure with -relevant problem data and access it during the execution of the user-supplied -Jacobian or linear system functions, without using global data in the -program. The user data pointer may be specified through -:c:func:`MRIStepSetUserData()`. - - - .. c:function:: int MRIStepSetJacFn(void* arkode_mem, ARKLsJacFn jac) Specifies the Jacobian approximation routine to @@ -1599,6 +1247,11 @@ program. The user data pointer may be specified through The function type :c:func:`ARKLsJacFn()` is described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetJacFn` instead. + + .. c:function:: int MRIStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) @@ -1625,6 +1278,11 @@ program. The user data pointer may be specified through The function type :c:func:`ARKLsLinSysFn()` is described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinSysFn` instead. + + .. c:function:: int MRIStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) @@ -1645,47 +1303,17 @@ program. The user data pointer may be specified through Linear solution scaling is enabled by default when a matrix-based linear solver is attached. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLinearSolutionScaling` instead. + + .. _ARKODE.Usage.MRIStep.ARKLsInputs.MatrixFree: Optional inputs for matrix-free ``SUNLinearSolver`` modules """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.. cssclass:: table-bordered - -================================================== ========================================= ================== -Optional input Function name Default -================================================== ========================================= ================== -:math:`Jv` functions (*jtimes* and *jtsetup*) :c:func:`MRIStepSetJacTimes()` DQ, none -:math:`Jv` DQ rhs function (*jtimesRhsFn*) :c:func:`MRIStepSetJacTimesRhsFn()` fs -================================================== ========================================= ================== - - -As described in :numref:`ARKODE.Mathematics.Linear`, when solving -the Newton linear systems with matrix-free methods, the ARKLS -interface requires a *jtimes* function to compute an approximation to -the product between the Jacobian matrix -:math:`J(t,y)` and a vector :math:`v`. The user can supply a custom -Jacobian-times-vector approximation function, or use the default -internal difference quotient function that comes with the ARKLS -interface. - -A user-defined Jacobian-vector function must be of type -:c:type:`ARKLsJacTimesVecFn` and can be specified through a call -to :c:func:`MRIStepSetJacTimes()` (see -:numref:`ARKODE.Usage.UserSupplied` for specification details). As with the -user-supplied preconditioner functions, the evaluation and -processing of any Jacobian-related data needed by the user's -Jacobian-times-vector function is done in the optional user-supplied -function of type :c:type:`ARKLsJacTimesSetupFn` (see -:numref:`ARKODE.Usage.UserSupplied` for specification details). As with -the preconditioner functions, a pointer to the user-defined -data structure, *user_data*, specified through -:c:func:`MRIStepSetUserData()` (or a ``NULL`` pointer otherwise) is -passed to the Jacobian-times-vector setup and product functions each -time they are called. - - .. c:function:: int MRIStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, ARKLsJacTimesVecFn jtimes) Specifies the Jacobian-times-vector setup and product functions. @@ -1718,15 +1346,9 @@ time they are called. :c:type:`ARKLsJacTimesVecFn` are described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z -When using the internal difference quotient the user may optionally supply -an alternative implicit right-hand side function for use in the Jacobian-vector -product approximation by calling :c:func:`MRIStepSetJacTimesRhsFn()`. The -alternative implicit right-hand side function should compute a suitable (and -differentiable) approximation to the :math:`f^I` function provided to -:c:func:`MRIStepCreate()`. For example, as done in :cite:p:`dorr2010numerical`, -the alternative function may use lagged values when evaluating a nonlinearity in -:math:`f^I` to avoid differencing a potentially non-differentiable factor. + Use :c:func:`ARKodeSetJacTimes` instead. .. c:function:: int MRIStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) @@ -1752,6 +1374,10 @@ the alternative function may use lagged values when evaluating a nonlinearity in This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetJacTimesRhsFn` instead. + @@ -1761,44 +1387,6 @@ the alternative function may use lagged values when evaluating a nonlinearity in Optional inputs for iterative ``SUNLinearSolver`` modules """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -.. cssclass:: table-bordered - -=============================================== ========================================= ================== -Optional input Function name Default -=============================================== ========================================= ================== -Newton preconditioning functions :c:func:`MRIStepSetPreconditioner()` ``NULL``, ``NULL`` -Newton linear and nonlinear tolerance ratio :c:func:`MRIStepSetEpsLin()` 0.05 -Newton linear solve tolerance conversion factor :c:func:`MRIStepSetLSNormFactor()` vector length -=============================================== ========================================= ================== - - -As described in :numref:`ARKODE.Mathematics.Linear`, when using -an iterative linear solver the user may supply a preconditioning -operator to aid in solution of the system. This operator consists of -two user-supplied functions, *psetup* and *psolve*, that are supplied -to MRIStep using the function :c:func:`MRIStepSetPreconditioner()`. -The *psetup* function supplied to these routines -should handle evaluation and preprocessing of any Jacobian data -needed by the user's preconditioner solve function, -*psolve*. The user data pointer received through -:c:func:`MRIStepSetUserData()` (or a pointer to ``NULL`` if user data -was not specified) is passed to the *psetup* and *psolve* functions. -This allows the user to create an arbitrary -structure with relevant problem data and access it during the -execution of the user-supplied preconditioner functions without using -global data in the program. - -Also, as described in :numref:`ARKODE.Mathematics.Error.Linear`, the -ARKLS interface requires that iterative linear solvers stop when -the norm of the preconditioned residual satisfies - -.. math:: - \|r\| \le \frac{\epsilon_L \epsilon}{10} - -where the default :math:`\epsilon_L = 0.05`, which may be modified by -the user through the :c:func:`MRIStepSetEpsLin()` function. - - .. c:function:: int MRIStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, ARKLsPrecSolveFn psolve) Specifies the user-supplied preconditioner setup and solve functions. @@ -1829,6 +1417,11 @@ the user through the :c:func:`MRIStepSetEpsLin()` function. :c:func:`ARKLsPrecSolveFn()` are described in :numref:`ARKODE.Usage.UserSupplied`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetPreconditioner` instead. + + .. c:function:: int MRIStepSetEpsLin(void* arkode_mem, sunrealtype eplifac) @@ -1853,6 +1446,11 @@ the user through the :c:func:`MRIStepSetEpsLin()` function. interface has been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetEpsLin` instead. + + .. c:function:: int MRIStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) @@ -1880,6 +1478,10 @@ the user through the :c:func:`MRIStepSetEpsLin()` function. This function must be called *after* the ARKLS system solver interface has been initialized through a call to :c:func:`MRIStepSetLinearSolver()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetLSNormFactor` instead. + .. _ARKODE.Usage.MRIStep.MRIStepRootfindingInput: @@ -1887,22 +1489,6 @@ the user through the :c:func:`MRIStepSetEpsLin()` function. Rootfinding optional input functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following functions can be called to set optional inputs to -control the rootfinding algorithm, the mathematics of which are -described in the section :numref:`ARKODE.Mathematics.Rootfinding`. - - -.. cssclass:: table-bordered - -====================================== ======================================== ================== -Optional input Function name Default -====================================== ======================================== ================== -Direction of zero-crossings to monitor :c:func:`MRIStepSetRootDirection()` both -Disable inactive root warnings :c:func:`MRIStepSetNoInactiveRootWarn()` enabled -====================================== ======================================== ================== - - - .. c:function:: int MRIStepSetRootDirection(void* arkode_mem, int* rootdir) Specifies the direction of zero-crossings to be located and returned. @@ -1924,6 +1510,10 @@ Disable inactive root warnings :c:func:`MRIStepSetNoInactiveRootWarn()` The default behavior is to monitor for both zero-crossing directions. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRootDirection` instead. + .. c:function:: int MRIStepSetNoInactiveRootWarn(void* arkode_mem) @@ -1946,6 +1536,10 @@ Disable inactive root warnings :c:func:`MRIStepSetNoInactiveRootWarn()` first step), MRIStep will issue a warning which can be disabled with this optional input function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNoInactiveRootWarn` instead. + .. _ARKODE.Usage.MRIStep.InterpolatedOutput: @@ -1953,20 +1547,6 @@ Disable inactive root warnings :c:func:`MRIStepSetNoInactiveRootWarn()` Interpolated output function -------------------------------- -An optional function :c:func:`MRIStepGetDky()` is available to obtain -additional values of solution-related quantities. This function -should only be called after a successful return from -:c:func:`MRIStepEvolve()`, as it provides interpolated values either of -:math:`y` or of its derivatives (up to the 3rd derivative) -interpolated to any value of :math:`t` in the last internal step taken -by :c:func:`MRIStepEvolve()`. Internally, this "dense output" or -"continuous extension" algorithm is identical to the algorithm used for -the maximum order implicit predictors, described in -:numref:`ARKODE.Mathematics.Predictors.Max`, except that derivatives of the -polynomial model may be evaluated upon request. - - - .. c:function:: int MRIStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) Computes the *k*-th derivative of the function @@ -2003,6 +1583,10 @@ polynomial model may be evaluated upon request. functions :c:func:`MRIStepGetCurrentTime()` and :c:func:`MRIStepGetLastStep()`, respectively. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetDky` instead. + .. _ARKODE.Usage.MRIStep.OptionalOutputs: @@ -2010,57 +1594,6 @@ polynomial model may be evaluated upon request. Optional output functions ------------------------------ -MRIStep provides an extensive set of functions that can be used to -obtain solver performance information. We organize these into groups: - -#. General MRIStep output routines are in - :numref:`ARKODE.Usage.MRIStep.MRIStepMainOutputs`, - -#. MRIStep implicit solver output routines are in - :numref:`ARKODE.Usage.MRIStep.MRIStepImplicitSolverOutputs`, - -#. Linear solver output routines are in - :numref:`ARKODE.Usage.MRIStep.ARKLsOutputs` and - -#. General usability routines (e.g. to print the current MRIStep - parameters, or output the current coupling table) are in - :numref:`ARKODE.Usage.MRIStep.MRIStepExtraOutputs`. - -#. Output routines regarding root-finding results are in - :numref:`ARKODE.Usage.MRIStep.MRIStepRootOutputs`, - -Following each table, we elaborate on each function. - -Some of the optional outputs, especially the various counters, can be -very useful in determining the efficiency of various methods inside -MRIStep. For example: - -* The number of steps and right-hand side evaluations at both the slow and fast - time scales provide a rough measure of the overall cost of a given run, and can - be compared between runs with different solver options to suggest which set of - options is the most efficient. - -* The ratio *nniters/nsteps* measures the performance of the - nonlinear iteration in solving the nonlinear systems at each implicit stage, - providing a measure of the degree of nonlinearity in the problem. - Typical values of this for a Newton solver on a general problem - range from 1.1 to 1.8. - -* When using a Newton nonlinear solver, the ratio *njevals/nniters* - (when using a direct linear solver), and the ratio - *nliters/nniters* (when using an iterative linear solver) can - indicate the quality of the approximate Jacobian or preconditioner being - used. For example, if this ratio is larger for a user-supplied - Jacobian or Jacobian-vector product routine than for the - difference-quotient routine, it can indicate that the user-supplied - Jacobian is inaccurate. - -It is therefore recommended that users retrieve and output these -statistics following each run, and take some time to investigate -alternate solver options that will be more optimal for their -particular problem of interest. - - .. _ARKODE.Usage.MRIStep.MRIStepMainOutputs: @@ -2068,56 +1601,6 @@ Main solver optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. _ARKODE.Usage.MRIStep.MRIStepMainOutputs.Table: -.. table:: Main solver optional output functions - - +------------------------------------------------------+-------------------------------------------+ - | Optional output | Function name | - +======================================================+===========================================+ - | Size of MRIStep real and integer workspaces | :c:func:`MRIStepGetWorkSpace()` | - +------------------------------------------------------+-------------------------------------------+ - | Cumulative number of internal steps | :c:func:`MRIStepGetNumSteps()` | - +------------------------------------------------------+-------------------------------------------+ - | Step size used for the last successful step | :c:func:`MRIStepGetLastStep()` | - +------------------------------------------------------+-------------------------------------------+ - | Current internal time reached by the solver | :c:func:`MRIStepGetCurrentTime()` | - +------------------------------------------------------+-------------------------------------------+ - | Current internal solution reached by the solver | :c:func:`MRIStepGetCurrentState()` | - +------------------------------------------------------+-------------------------------------------+ - | Current :math:`\gamma` value used by the solver | :c:func:`MRIStepGetCurrentGamma()` | - +------------------------------------------------------+-------------------------------------------+ - | Error weight vector for state variables | :c:func:`MRIStepGetErrWeights()` | - +------------------------------------------------------+-------------------------------------------+ - | Suggested factor for tolerance scaling | :c:func:`MRIStepGetTolScaleFactor()` | - +------------------------------------------------------+-------------------------------------------+ - | Print all statistics | :c:func:`MRIStepPrintAllStats` | - +------------------------------------------------------+-------------------------------------------+ - | Name of constant associated with a return flag | :c:func:`MRIStepGetReturnFlagName()` | - +------------------------------------------------------+-------------------------------------------+ - | No. of calls to the :math:`f^E` and :math:`f^I` | :c:func:`MRIStepGetNumRhsEvals()` | - +------------------------------------------------------+-------------------------------------------+ - | No. of failed steps due to a nonlinear solver | :c:func:`MRIStepGetNumStepSolveFails()` | - | failure | | - +------------------------------------------------------+-------------------------------------------+ - | Current MRI coupling tables | :c:func:`MRIStepGetCurrentCoupling()` | - +------------------------------------------------------+-------------------------------------------+ - | Last inner stepper return value | :c:func:`MRIStepGetLastInnerStepFlag()` | - +------------------------------------------------------+-------------------------------------------+ - | Retrieve a pointer for user data | :c:func:`MRIStepGetUserData` | - +------------------------------------------------------+-------------------------------------------+ - -.. Functions not currently provided by MRIStep -.. No. of explicit stability-limited steps :c:func:`MRIStepGetNumExpSteps()` -.. No. of accuracy-limited steps :c:func:`MRIStepGetNumAccSteps()` -.. No. of attempted steps :c:func:`MRIStepGetNumStepAttempts()` -.. No. of local error test failures that have occurred :c:func:`MRIStepGetNumErrTestFails()` -.. Estimated local truncation error vector :c:func:`MRIStepGetEstLocalErrors()` -.. Single accessor to many statistics at once :c:func:`MRIStepGetTimestepperStats()` -.. Actual initial time step size used :c:func:`MRIStepGetActualInitStep()` -.. Step size to be attempted on the next step :c:func:`MRIStepGetCurrentStep()` -.. Single accessor to many statistics at once :c:func:`MRIStepGetStepStats()` - - .. c:function:: int MRIStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) Returns the MRIStep real and integer workspace sizes. @@ -2129,6 +1612,11 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetWorkSpace` instead. + + .. c:function:: int MRIStepGetNumSteps(void* arkode_mem, long int* nssteps, long int* nfsteps) @@ -2142,17 +1630,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z -.. - .. c:function:: int MRIStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) - - Returns the value of the integration step size used on the first step. + Use :c:func:`ARKodeGetNumSteps` instead. - :param arkode_mem: pointer to the MRIStep memory block. - :param hinused: actual value of initial step size. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. c:function:: int MRIStepGetLastStep(void* arkode_mem, sunrealtype* hlast) @@ -2166,17 +1647,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z -.. - .. c:function:: int MRIStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) - - Returns the integration step size to be attempted on the next internal step. + Use :c:func:`ARKodeGetLastStep` instead. - :param arkode_mem: pointer to the MRIStep memory block. - :param hcur: step size to be attempted on the next internal step. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` .. c:function:: int MRIStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) @@ -2189,6 +1663,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentTime` instead. + .. c:function:: int MRIStepGetCurrentState(void *arkode_mem, N_Vector *ycur) @@ -2206,6 +1684,10 @@ Main solver optional output functions as altering values of *ycur* may lead to undesirable behavior, depending on the particular use case and on when this routine is called. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentState` instead. + .. c:function:: int MRIStepGetCurrentGamma(void *arkode_mem, sunrealtype *gamma) @@ -2218,6 +1700,9 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentGamma` instead. .. c:function:: int MRIStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac) @@ -2232,6 +1717,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetTolScaleFactor` instead. + .. c:function:: int MRIStepGetErrWeights(void* arkode_mem, N_Vector eweight) @@ -2248,20 +1737,9 @@ Main solver optional output functions The user must allocate space for *eweight*, that will be filled in by this function. + .. deprecated:: x.y.z -.. - .. c:function:: int MRIStepGetStepStats(void* arkode_mem, long int* nssteps, long int* nfsteps, sunrealtype* hlast, sunrealtype* tcur) - - Returns many of the most useful optional outputs in a single call. - - :param arkode_mem: pointer to the MRIStep memory block. - :param nssteps: number of slow steps taken in the solver. - :param nfsteps: number of fast steps taken in the solver. - :param hlast: step size taken on the last internal step. - :param tcur: current internal time reached. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + Use :c:func:`ARKodeGetErrWeights` instead. .. c:function:: int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) @@ -2290,8 +1768,12 @@ Main solver optional output functions .. versionadded:: 5.2.0 + .. deprecated:: x.y.z -.. c:function:: char *MRIStepGetReturnFlagName(long int flag) + Use :c:func:`ARKodePrintAllStats` instead. + + +.. c:function:: char* MRIStepGetReturnFlagName(long int flag) Returns the name of the MRIStep constant corresponding to *flag*. See :ref:`ARKODE.Constants`. @@ -2301,44 +1783,11 @@ Main solver optional output functions :return value: The return value is a string containing the name of the corresponding constant. + .. deprecated:: x.y.z -.. - .. c:function:: int MRIStepGetNumExpSteps(void* arkode_mem, long int* expsteps) - - Returns the cumulative number of stability-limited steps - taken by the solver (so far). - - :param arkode_mem: pointer to the MRIStep memory block. - :param expsteps: number of stability-limited steps taken in the solver. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + Use :c:func:`ARKodeGetReturnFlagName` instead. -.. - .. c:function:: int MRIStepGetNumAccSteps(void* arkode_mem, long int* accsteps) - - Returns the cumulative number of accuracy-limited steps - taken by the solver (so far). - - :param arkode_mem: pointer to the MRIStep memory block. - :param accsteps: number of accuracy-limited steps taken in the solver. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - - -.. - .. c:function:: int MRIStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts) - - Returns the cumulative number of steps attempted by the solver (so far). - - :param arkode_mem: pointer to the MRIStep memory block. - :param step_attempts: number of steps attempted by solver. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - .. c:function:: int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, long int* nfsi_evals) @@ -2353,18 +1802,6 @@ Main solver optional output functions :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` -.. - .. c:function:: int MRIStepGetNumErrTestFails(void* arkode_mem, long int* netfails) - - Returns the number of local error test failures that - have occurred (so far). - - :param arkode_mem: pointer to the MRIStep memory block. - :param netfails: number of error test failures. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - .. c:function:: int MRIStepGetNumStepSolveFails(void* arkode_mem, long int* ncnf) @@ -2376,6 +1813,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumStepSolveFails` instead. + .. c:function:: int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling *C) @@ -2410,52 +1851,6 @@ Main solver optional output functions For more details see :numref:`ARKODE.Usage.MRIStep.MRIStepCoupling`. -.. - .. c:function:: int MRIStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) - - Returns the vector of estimated local truncation errors - for the current step. - - :param arkode_mem: pointer to the MRIStep memory block. - :param ele: vector of estimated local truncation errors. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - - .. note:: - - The user must allocate space for *ele*, that will be - filled in by this function. - - The values returned in *ele* are valid only after a successful call - to :c:func:`MRIStepEvolve()` (i.e., it returned a non-negative value). - - The *ele* vector, together with the *eweight* vector from - :c:func:`MRIStepGetErrWeights()`, can be used to determine how the - various components of the system contributed to the estimated local - error test. Specifically, that error test uses the WRMS norm of a - vector whose components are the products of the components of these - two vectors. Thus, for example, if there were recent error test - failures, the components causing the failures are those with largest - values for the products, denoted loosely as ``eweight[i]*ele[i]``. - - -.. - .. c:function:: int MRIStepGetTimestepperStats(void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nf_evals, long int* netfails) - - Returns many of the most useful time-stepper statistics in a single call. - - :param arkode_mem: pointer to the MRIStep memory block. - :param expsteps: number of stability-limited steps taken in the solver. - :param accsteps: number of accuracy-limited steps taken in the solver. - :param step_attempts: number of steps attempted by the solver. - :param nf_evals: number of calls to the user's :math:`f(t,y)` function. - :param netfails: number of error test failures. - - :retval ARK_SUCCESS: if successful - :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` - - .. c:function:: int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) Returns the last return value from the inner stepper. @@ -2467,6 +1862,7 @@ Main solver optional output functions :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. c:function:: int MRIStepGetUserData(void* arkode_mem, void** user_data) Returns the user data pointer previously set with @@ -2480,29 +1876,16 @@ Main solver optional output functions .. versionadded:: 5.3.0 + .. deprecated:: x.y.z -.. _ARKODE.Usage.MRIStep.MRIStepImplicitSolverOutputs: - -Implicit solver optional output functions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. _ARKODE.Usage.MRIStep.MRIStepImplicitSolverOutputs.Table: -.. table:: Implicit solver optional output functions + Use :c:func:`ARKodeGetUserData` instead. - +------------------------------------------------------+----------------------------------------------+ - | Optional output | Function name | - +======================================================+==============================================+ - | No. of calls to linear solver setup function | :c:func:`MRIStepGetNumLinSolvSetups()` | - +------------------------------------------------------+----------------------------------------------+ - | No. of nonlinear solver iterations | :c:func:`MRIStepGetNumNonlinSolvIters()` | - +------------------------------------------------------+----------------------------------------------+ - | No. of nonlinear solver convergence failures | :c:func:`MRIStepGetNumNonlinSolvConvFails()` | - +------------------------------------------------------+----------------------------------------------+ - | Single accessor to all nonlinear solver statistics | :c:func:`MRIStepGetNonlinSolvStats()` | - +------------------------------------------------------+----------------------------------------------+ +.. _ARKODE.Usage.MRIStep.MRIStepImplicitSolverOutputs: +Implicit solver optional output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. c:function:: int MRIStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) @@ -2521,6 +1904,10 @@ Implicit solver optional output functions solver object; the counter is reset whenever a new nonlinear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinSolvSetups` instead. + .. c:function:: int MRIStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) @@ -2539,6 +1926,10 @@ Implicit solver optional output functions solver object; the counter is reset whenever a new nonlinear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumNonlinSolvIters` instead. + .. c:function:: int MRIStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nncfails) @@ -2558,6 +1949,10 @@ Implicit solver optional output functions solver object; the counter is reset whenever a new nonlinear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumNonlinSolvConvFails` instead. + .. c:function:: int MRIStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, long int* nncfails) @@ -2578,6 +1973,10 @@ Implicit solver optional output functions nonlinear solver object; the counters are reset whenever a new nonlinear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNonlinSolvStats` instead. + .. _ARKODE.Usage.MRIStep.MRIStepRootOutputs: @@ -2585,17 +1984,6 @@ Implicit solver optional output functions Rootfinding optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. cssclass:: table-bordered - -=================================================== ========================================== -Optional output Function name -=================================================== ========================================== -Array showing roots found :c:func:`MRIStepGetRootInfo()` -No. of calls to user root function :c:func:`MRIStepGetNumGEvals()` -=================================================== ========================================== - - - .. c:function:: int MRIStepGetRootInfo(void* arkode_mem, int* rootsfound) Returns an array showing which functions were found to @@ -2622,6 +2010,10 @@ No. of calls to user root function :c:func:`MRIStepGetNumGEval zero-crossing. A value of +1 indicates that :math:`g_i` is increasing, while a value of -1 indicates a decreasing :math:`g_i`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetRootInfo` instead. + .. c:function:: int MRIStepGetNumGEvals(void* arkode_mem, long int* ngevals) @@ -2635,6 +2027,10 @@ No. of calls to user root function :c:func:`MRIStepGetNumGEval :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the MRIStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumGEvals` instead. + .. _ARKODE.Usage.MRIStep.ARKLsOutputs: @@ -2642,48 +2038,6 @@ No. of calls to user root function :c:func:`MRIStepGetNumGEval Linear solver interface optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A variety of optional outputs are available from the ARKLS interface, as -listed in the following table and elaborated below. We note that where the -name of an output would otherwise conflict with the -name of an optional output from the main solver, a suffix LS (for -Linear Solver) has been added here (e.g. *lenrwLS*). - - -.. _ARKODE.Usage.MRIStep.ARKLsOutputs.Table: -.. table:: Linear solver interface optional output functions - - +--------------------------------------------------------------------+------------------------------------------+ - | Optional output | Function name | - +====================================================================+==========================================+ - | Stored Jacobian of the ODE RHS function | :c:func:`MRIStepGetJac` | - +--------------------------------------------------------------------+------------------------------------------+ - | Time at which the Jacobian was evaluated | :c:func:`MRIStepGetJacTime` | - +--------------------------------------------------------------------+------------------------------------------+ - | Step number at which the Jacobian was evaluated | :c:func:`MRIStepGetJacNumSteps` | - +--------------------------------------------------------------------+------------------------------------------+ - | Size of real and integer workspaces | :c:func:`MRIStepGetLinWorkSpace()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of Jacobian evaluations | :c:func:`MRIStepGetNumJacEvals()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of preconditioner evaluations | :c:func:`MRIStepGetNumPrecEvals()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of preconditioner solves | :c:func:`MRIStepGetNumPrecSolves()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of linear iterations | :c:func:`MRIStepGetNumLinIters()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of linear convergence failures | :c:func:`MRIStepGetNumLinConvFails()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of Jacobian-vector setup evaluations | :c:func:`MRIStepGetNumJTSetupEvals()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of Jacobian-vector product evaluations | :c:func:`MRIStepGetNumJtimesEvals()` | - +--------------------------------------------------------------------+------------------------------------------+ - | No. of *fs* calls for finite diff. :math:`J` or :math:`Jv` evals. | :c:func:`MRIStepGetNumLinRhsEvals()` | - +--------------------------------------------------------------------+------------------------------------------+ - | Last return from a linear solver function | :c:func:`MRIStepGetLastLinFlag()` | - +--------------------------------------------------------------------+------------------------------------------+ - | Name of constant associated with a return flag | :c:func:`MRIStepGetLinReturnFlagName()` | - +--------------------------------------------------------------------+------------------------------------------+ - .. c:function:: int MRIStepGetJac(void* arkode_mem, SUNMatrix* J) Returns the internally stored copy of the Jacobian matrix of the ODE @@ -2701,6 +2055,11 @@ Linear Solver) has been added here (e.g. *lenrwLS*). This function is provided for debugging purposes and the values in the returned matrix should not be altered. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetJac` instead. + + .. c:function:: int MRIStepGetJacTime(void* arkode_mem, sunrealtype* t_J) Returns the time at which the internally stored copy of the Jacobian matrix @@ -2713,6 +2072,11 @@ Linear Solver) has been added here (e.g. *lenrwLS*). :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL`` :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetJacTime` instead. + + .. c:function:: int MRIStepGetJacNumSteps(void* arkode_mem, long int* nst_J) Returns the value of the internal step counter at which the internally stored copy of the @@ -2726,6 +2090,11 @@ Linear Solver) has been added here (e.g. *lenrwLS*). :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL`` :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetJacNumSteps` instead. + + .. c:function:: int MRIStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) Returns the real and integer workspace used by the ARKLS linear solver interface. @@ -2749,6 +2118,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). In a parallel setting, the above values are global (i.e., summed over all processors). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLinWorkSpace` instead. + .. c:function:: int MRIStepGetNumJacEvals(void* arkode_mem, long int* njevals) @@ -2767,6 +2140,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumJacEvals` instead. + .. c:function:: int MRIStepGetNumPrecEvals(void* arkode_mem, long int* npevals) @@ -2787,6 +2164,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumPrecEvals` instead. + .. c:function:: int MRIStepGetNumPrecSolves(void* arkode_mem, long int* npsolves) @@ -2806,6 +2187,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumPrecSolves` instead. + .. c:function:: int MRIStepGetNumLinIters(void* arkode_mem, long int* nliters) @@ -2824,6 +2209,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinIters` instead. + .. c:function:: int MRIStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails) @@ -2842,6 +2231,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinConvFails` instead. + .. c:function:: int MRIStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetup) @@ -2861,6 +2254,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumJTSetupEvals` instead. + .. c:function:: int MRIStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals) @@ -2880,6 +2277,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumJtimesEvals` instead. + .. c:function:: int MRIStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) @@ -2904,6 +2305,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). solver object; the counter is reset whenever a new linear solver module is "attached" to MRIStep, or when MRIStep is resized. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumLinRhsEvals` instead. + .. c:function:: int MRIStepGetLastLinFlag(void* arkode_mem, long int* lsflag) @@ -2962,8 +2367,12 @@ Linear Solver) has been added here (e.g. *lenrwLS*). * *SUNLS_PACKAGE_FAIL_UNREC*, indicating an unrecoverable failure in an external iterative linear solver package. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLastLinFlag` instead. -.. c:function:: char *MRIStepGetLinReturnFlagName(long int lsflag) + +.. c:function:: char* MRIStepGetLinReturnFlagName(long int lsflag) Returns the name of the ARKLS constant corresponding to *lsflag*. @@ -2975,6 +2384,10 @@ Linear Solver) has been added here (e.g. *lenrwLS*). :math:`\le n` (LU factorization failed), this routine returns "NONE". + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLinReturnFlagName` instead. + @@ -2983,25 +2396,6 @@ Linear Solver) has been added here (e.g. *lenrwLS*). General usability functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following optional routines may be called by a user to inquire -about existing solver parameters or write the current MRI coupling table. While -neither of these would typically be called during the course of solving an -initial value problem, these may be useful for users wishing to better -understand MRIStep. - - -.. _ARKODE.Usage.MRIStep.MRIStepExtraOutputs.Table: -.. table:: General usability functions - - +-----------------------------------------------+-------------------------------------------+ - | Optional routine | Function name | - +===============================================+===========================================+ - | Output all MRIStep solver parameters | :c:func:`MRIStepWriteParameters()` | - +-----------------------------------------------+-------------------------------------------+ - | Output the current MRI coupling table | :c:func:`MRIStepWriteCoupling()` | - +-----------------------------------------------+-------------------------------------------+ - - .. c:function:: int MRIStepWriteParameters(void* arkode_mem, FILE *fp) Outputs all MRIStep solver parameters to the provided file pointer. @@ -3021,6 +2415,10 @@ understand MRIStep. for this pointer, since parameters for all processes would be identical. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeWriteParameters` instead. + .. c:function:: int MRIStepWriteCoupling(void* arkode_mem, FILE *fp) @@ -3041,6 +2439,10 @@ understand MRIStep. for this pointer, since tables for all processes would be identical. + .. deprecated:: x.y.z + + Use :c:func:`MRIStepGetCurrentCoupling` and :c:func:`MRIStepCoupling_Write` + instead. .. _ARKODE.Usage.MRIStep.Reinitialization: @@ -3125,47 +2527,6 @@ vector. MRIStep reset function ---------------------- -To reset the MRIStep module to a particular state :math:`(t_R,y(t_R))` for the -continued solution of a problem, where a prior -call to :c:func:`MRIStepCreate()` has been made, the user must call the function -:c:func:`MRIStepReset()`. Like :c:func:`MRIStepReInit()` this routine retains -the current settings for all MRIStep module options and performs no memory -allocations but, unlike :c:func:`MRIStepReInit()`, this routine performs only a -*subset* of the input checking and initializations that are done in -:c:func:`MRIStepCreate()`. In particular this routine retains all internal -counter values and the step size/error history and does not reinitialize the -linear and/or nonlinear solver but it does indicate that a linear solver setup -is necessary in the next step. Like :c:func:`MRIStepReInit()`, a call to -:c:func:`MRIStepReset()` will delete any previously-set *tstop* value specified -via a call to :c:func:`MRIStepSetStopTime()`. Following a successful call to -:c:func:`MRIStepReset()`, call :c:func:`MRIStepEvolve()` again to continue -solving the problem. By default the next call to :c:func:`MRIStepEvolve()` will -use the step size computed by MRIStep prior to calling :c:func:`MRIStepReset()`. -To set a different step size use :c:func:`MRIStepSetFixedStep`. - -.. - To set a different step size or have MRIStep estimate a new step size use - :c:func:`MRIStepSetInitStep()`. - -One important use of the :c:func:`MRIStepReset()` function is in the -treating of jump discontinuities in the RHS functions. Except in cases -of fairly small jumps, it is usually more efficient to stop at each -point of discontinuity and restart the integrator with a readjusted -ODE model, using a call to :c:func:`MRIStepReset()`. To stop when -the location of the discontinuity is known, simply make that location -a value of ``tout``. To stop when the location of the discontinuity -is determined by the solution, use the rootfinding feature. In either -case, it is critical that the RHS functions *not* incorporate the -discontinuity, but rather have a smooth extension over the -discontinuity, so that the step across it (and subsequent rootfinding, -if used) can be done efficiently. Then use a switch within the RHS -functions (communicated through ``user_data``) that can be flipped -between the stopping of the integration and the restart, so that the -restarted problem uses the new values (which have jumped). Similar -comments apply if there is to be a jump in the dependent variable -vector. - - .. c:function:: int MRIStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) Resets the current MRIStep outer (slow) time-stepper module state to the @@ -3197,6 +2558,10 @@ vector. (*tR*, *yR*) arguments for the :c:type:`MRIStepInnerStepper` object that is used to evolve the MRI "fast" time scale subproblems. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeReset` instead. + @@ -3205,22 +2570,6 @@ vector. MRIStep system resize function ------------------------------------- -For simulations involving changes to the number of equations and -unknowns in the ODE system (e.g. when using spatially-adaptive -PDE simulations under a method-of-lines approach), the MRIStep -integrator may be "resized" between *slow* integration steps, through calls -to the :c:func:`MRIStepResize()` function. This function modifies -MRIStep's internal memory structures to use the new problem size. - -To aid in the vector resize operation, the user can supply a vector -resize function that will take as input a vector with the previous -size, and transform it in-place to return a corresponding vector of -the new size. If this function (of type :c:func:`ARKVecResizeFn()`) -is not supplied (i.e., is set to ``NULL``), then all existing vectors -internal to MRIStep will be destroyed and re-cloned from the new input -vector. - - .. c:function:: int MRIStepResize(void* arkode_mem, N_Vector yR, sunrealtype tR, ARKVecResizeFn resize, void* resize_data) Re-initializes MRIStep with a different state vector. @@ -3274,7 +2623,11 @@ vector. :c:func:`MRIStepWFtolerances()`, then these will remain valid and no further action is necessary. - **Example codes:** + **Example codes:** For an example showing usage of the similar :c:func:`ARKStepResize()` routine, see the supplied serial C example problem, ``ark_heat1D_adapt.c``. + + .. deprecated:: x.y.z + + Use :c:func:`ARKodeResize` instead. diff --git a/doc/arkode/guide/source/Usage/MRIStep_c_interface/index.rst b/doc/arkode/guide/source/Usage/MRIStep_c_interface/index.rst index d22e91746f..a1d91c144b 100644 --- a/doc/arkode/guide/source/Usage/MRIStep_c_interface/index.rst +++ b/doc/arkode/guide/source/Usage/MRIStep_c_interface/index.rst @@ -19,23 +19,11 @@ Using the MRIStep time-stepping module ========================================== -This chapter is concerned with the use of the MRIStep time-stepping module for -the solution of multirate initial value problems (IVPs) of the form -:eq:`ARKODE_IVP_two_rate` in a C or C++ language setting. The following sections -discuss the header files and the layout of the user's main program, and provide -descriptions of the MRIStep user-callable functions and user-supplied functions. - -The example programs located in the source code ``examples/arkode`` -folder, including those described in the companion document :cite:p:`arkode_ex`, -may be helpful as templates for new codes. - -MRIStep uses the input and output constants from the shared ARKODE -infrastructure. These are defined as needed in this chapter, but for -convenience the full list is provided separately in -:numref:`ARKODE.Constants`. - -The relevant information on using MRIStep's C and C++ interfaces is -detailed in the following subsections. +This section is concerned with the use of the MRIStep time-stepping +module for the solution of initial value problems (IVPs) in a C or C++ +language setting. Usage of MRIStep follows that of the rest of ARKODE, +and so in this section we primarily focus on those usage aspects that +are specific to MRIStep. .. toctree:: :maxdepth: 1 diff --git a/doc/arkode/guide/source/Usage/ARKStep_c_interface/Preconditioners.rst b/doc/arkode/guide/source/Usage/Preconditioners.rst similarity index 61% rename from doc/arkode/guide/source/Usage/ARKStep_c_interface/Preconditioners.rst rename to doc/arkode/guide/source/Usage/Preconditioners.rst index d772f5ad4a..62bdb966b0 100644 --- a/doc/arkode/guide/source/Usage/ARKStep_c_interface/Preconditioners.rst +++ b/doc/arkode/guide/source/Usage/Preconditioners.rst @@ -12,7 +12,7 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. _ARKODE.Usage.ARKStep.PreconditionerModules: +.. _ARKODE.Usage.PreconditionerModules: Preconditioner modules ============================ @@ -20,13 +20,12 @@ Preconditioner modules The efficiency of Krylov iterative methods for the solution of linear systems can be greatly enhanced through preconditioning. For problems in which the user cannot define a more effective, problem-specific -preconditioner, ARKODE provides two internal preconditioner modules -that may be used by ARKStep: a banded preconditioner for serial and -threaded problems (ARKBANDPRE) and a band-block-diagonal -preconditioner for parallel problems (ARKBBDPRE). +preconditioner, ARKODE provides two internal preconditioner modules: +a banded preconditioner for serial and threaded problems (ARKBANDPRE) +and a band-block-diagonal preconditioner for parallel problems (ARKBBDPRE). -.. _ARKODE.Usage.ARKStep.BandPre: +.. _ARKODE.Usage.BandPre: A serial banded preconditioner module ------------------------------------------- @@ -63,66 +62,70 @@ for the integration of the ODE problem (see program must include the header file ``arkode_bandpre.h`` which declares the needed function prototypes. The following is a summary of the usage of this module. Steps that are unchanged from the -skeleton program presented in :numref:`ARKODE.Usage.ARKStep.Skeleton` are +skeleton program presented in :numref:`ARKODE.Usage.Skeleton` are *italicized*. -1. *Initialize multi-threaded environment (if appropriate)* +#. *Initialize multi-threaded environment (if appropriate)* -2. *Set problem dimensions* +#. *Create the SUNDIALS simulation context object.* -3. *Set vector of initial values* +#. *Set problem dimensions* -4. *Create ARKStep object* +#. *Set vector of initial values* -5. *Specify integration tolerances* +#. *Create ARKODE object* -6. Create iterative linear solver object +#. *Specify integration tolerances* + +#. Create iterative linear solver object When creating the iterative linear solver object, specify the type of preconditioning (``SUN_PREC_LEFT`` or ``SUN_PREC_RIGHT``) to use. -7. *Set linear solver optional inputs* +#. *Set linear solver optional inputs* + +#. *Attach linear solver module* -8. *Attach linear solver module* +#. Initialize the ARKBANDPRE preconditioner module -9. Initialize the ARKBANDPRE preconditioner module + Specify the upper and lower half-bandwidths (``mu`` and ``ml``, + respectively) and call - Specify the upper and lower half-bandwidths (``mu`` and ``ml``, - respectively) and call + ``ier = ARKBandPrecInit(arkode_mem, N, mu, ml);`` - ``ier = ARKBandPrecInit(arkode_mem, N, mu, ml);`` + to allocate memory and initialize the internal preconditioner + data. - to allocate memory and initialize the internal preconditioner - data. +#. *Create nonlinear solver object* -10. *Set optional inputs* +#. *Attach nonlinear solver module* - Note that the user should not call - :c:func:`ARKStepSetPreconditioner()` as it will overwrite the - preconditioner setup and solve functions. +#. *Set nonlinear solver optional inputs* -11. *Create nonlinear solver object* +#. *Set optional inputs* -12. *Attach nonlinear solver module* + Note that the user should not call + :c:func:`ARKodeSetPreconditioner()` as it will overwrite the + preconditioner setup and solve functions. -13. *Set nonlinear solver optional inputs* +#. *Specify rootfinding problem* -14. *Specify rootfinding problem* +#. *Advance solution in time* -15. *Advance solution in time* +#. Get optional outputs -16. Get optional outputs + Additional optional outputs associated with ARKBANDPRE are + available by way of the two routines described below, + :c:func:`ARKBandPrecGetWorkSpace()` and + :c:func:`ARKBandPrecGetNumRhsEvals()`. - Additional optional outputs associated with ARKBANDPRE are - available by way of the two routines described below, - :c:func:`ARKBandPrecGetWorkSpace()` and - :c:func:`ARKBandPrecGetNumRhsEvals()`. +#. *Deallocate memory for solution vector* -17. *Deallocate memory for solution vector* +#. *Free solver memory* -18. *Free solver memory* +#. *Free linear solver memory* -19. *Free linear solver memory* +#. *Free nonlinear solver memory* @@ -141,20 +144,19 @@ by calling the following function: Initializes the ARKBANDPRE preconditioner and allocates required (internal) memory for it. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *N* -- problem dimension (size of ODE system). - * *mu* -- upper half-bandwidth of the Jacobian approximation. - * *ml* -- lower half-bandwidth of the Jacobian approximation. + :param arkode_mem: pointer to the ARKODE memory block. + :param N: problem dimension (size of ODE system). + :param mu: upper half-bandwidth of the Jacobian approximation. + :param ml: lower half-bandwidth of the Jacobian approximation. - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_ILL_INPUT* if an input has an illegal value - * *ARKLS_MEM_FAIL* if a memory allocation request failed + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARKLS_MEM_FAIL: a memory allocation request failed. + + .. note:: - **Notes:** The banded approximate Jacobian will have nonzero elements only in locations :math:`(i,j)` with *ml* :math:`\le j-i \le` *mu*. @@ -170,26 +172,25 @@ the ARKBANDPRE module: Returns the sizes of the ARKBANDPRE real and integer workspaces. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *lenrwLS* -- the number of ``sunrealtype`` values in the - ARKBANDPRE workspace. - * *leniwLS* -- the number of integer values in the ARKBANDPRE workspace. + :param arkode_mem: pointer to the ARKODE memory block. + :param lenrwLS: the number of ``sunrealtype`` values in the + ARKBANDPRE workspace. + :param leniwLS: the number of integer values in the ARKBANDPRE workspace. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_PMEM_NULL: the preconditioner memory was ``NULL``. - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_PMEM_NULL* if the preconditioner memory is ``NULL`` + .. note:: - **Notes:** The workspace requirements reported by this routine correspond only to memory allocated within the ARKBANDPRE module (the banded matrix approximation, banded ``SUNLinearSolver`` object, and temporary vectors). The workspaces referred to here exist in addition to those given by - the corresponding function :c:func:`ARKStepGetLinWorkSpace()`. + the corresponding function :c:func:`ARKodeGetLinWorkSpace()`. @@ -200,30 +201,29 @@ the ARKBANDPRE module: finite-difference banded Jacobian approximation used within the preconditioner setup function. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *nfevalsBP* -- number of calls to :math:`f^I`. + :param arkode_mem: pointer to the ARKODE memory block. + :param nfevalsBP: number of calls to :math:`f^I`. - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_PMEM_NULL* if the preconditioner memory is ``NULL`` + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_PMEM_NULL: the preconditioner memory was ``NULL``. + + .. note:: - **Notes:** The counter *nfevalsBP* is distinct from the counter *nfevalsLS* returned by the corresponding function - :c:func:`ARKStepGetNumLinRhsEvals()` and also from *nfi_evals* returned by - :c:func:`ARKStepGetNumRhsEvals()`. The total number of right-hand - side function evaluations is the sum of all three of these - counters, plus the *nfe_evals* counter for :math:`f^E` calls - returned by :c:func:`ARKStepGetNumRhsEvals()`. + :c:func:`ARKodeGetNumLinRhsEvals()` and also from the number of + evaluations returned by the time-stepping module (e.g., *nfi_evals* + returned by :c:func:`ARKStepGetNumRhsEvals()`). The total number of + right-hand side function evaluations is the sum of all three of these + counters. -.. _ARKODE.Usage.ARKStep.BBDPre: +.. _ARKODE.Usage.BBDPre: A parallel band-block-diagonal preconditioner module --------------------------------------------------------- @@ -242,9 +242,8 @@ preconditioner must be problem-specific. However, we have developed one type of preconditioner that treats a rather broad class of PDE-based problems. It has been successfully -used with CVODE for several realistic, large-scale problems :cite:p:`HiTa:98`. -It is included in a software module within the ARKODE package, and is -accessible within the ARKStep time stepping module. This +used with CVODE for several realistic, large-scale problems :cite:p:`HiTa:98`, +and is included in a software module within the ARKODE package. This preconditioning module works with the parallel vector module NVECTOR_PARALLEL and is usable with any of the Krylov iterative linear solvers through the ARKLS interface. It generates a preconditioner @@ -339,7 +338,7 @@ communication necessary to evaluate the approximate right-hand side :math:`g`. These are in addition to the user-supplied right-hand side function :math:`f^I`. Both functions take as input the same pointer *user_data* that is passed by the user to -:c:func:`ARKStepSetUserData()` and that was passed to the user's +:c:func:`ARKodeSetUserData()` and that was passed to the user's function :math:`f^I`. The user is responsible for providing space (presumably within *user_data*) for components of :math:`y` that are communicated between processes by *cfn*, and that are then used by @@ -352,22 +351,21 @@ communicated between processes by *cfn*, and that are then used by This *gloc* function computes :math:`g(t,y)`. It fills the vector *glocal* as a function of *t* and *y*. - **Arguments:** - * *Nlocal* -- the local vector length. - * *t* -- the value of the independent variable. - * *y* -- the value of the dependent variable vector on this process. - * *glocal* -- the output vector of :math:`g(t,y)` on this process. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter passed to :c:func:`ARKStepSetUserData()`. - - **Return value:** - An *ARKLocalFn* should return 0 if successful, a positive value if - a recoverable error occurred (in which case ARKStep will attempt to - correct), or a negative value if it failed unrecoverably (in which - case the integration is halted and :c:func:`ARKStepEvolve()` will return - *ARK_LSETUP_FAIL*). - - **Notes:** + :param Nlocal: the local vector length. + :param t: the value of the independent variable. + :param y: the value of the dependent variable vector on this process. + :param glocal: the output vector of :math:`g(t,y)` on this process. + :param user_data: a pointer to user data, the same as the + *user_data* parameter passed to :c:func:`ARKodeSetUserData()`. + + :return: An *ARKLocalFn* should return 0 if successful, a positive value if + a recoverable error occurred (in which case ARKODE will attempt to + correct), or a negative value if it failed unrecoverably (in which + case the integration is halted and :c:func:`ARKodeEvolve()` will return + *ARK_LSETUP_FAIL*). + + .. note:: + This function should assume that all inter-process communication of data needed to calculate *glocal* has already been done, and that this data is accessible within user data. @@ -383,21 +381,20 @@ communicated between processes by *cfn*, and that are then used by communication necessary for the execution of the *gloc* function above, using the input vector *y*. - **Arguments:** - * *Nlocal* -- the local vector length. - * *t* -- the value of the independent variable. - * *y* -- the value of the dependent variable vector on this process. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter passed to :c:func:`ARKStepSetUserData()`. - - **Return value:** - An *ARKCommFn* should return 0 if successful, a positive value if a - recoverable error occurred (in which case ARKStep will attempt to - correct), or a negative value if it failed unrecoverably (in which - case the integration is halted and :c:func:`ARKStepEvolve()` will return - *ARK_LSETUP_FAIL*). - - **Notes:** + :param Nlocal: the local vector length. + :param t: the value of the independent variable. + :param y: the value of the dependent variable vector on this process. + :param user_data: a pointer to user data, the same as the + *user_data* parameter passed to :c:func:`ARKodeSetUserData()`. + + :return: An *ARKCommFn* should return 0 if successful, a positive value if a + recoverable error occurred (in which case ARKODE will attempt to + correct), or a negative value if it failed unrecoverably (in which + case the integration is halted and :c:func:`ARKodeEvolve()` will return + *ARK_LSETUP_FAIL*). + + .. note:: + The *cfn* function is expected to save communicated data in space defined within the data structure *user_data*. @@ -422,28 +419,30 @@ ARKBBDPRE module, the user's program must include the header file The following is a summary of the proper usage of this module. Steps that are unchanged from the skeleton program presented in -:numref:`ARKODE.Usage.ARKStep.Skeleton` are *italicized*. +:numref:`ARKODE.Usage.Skeleton` are *italicized*. + +#. *Initialize MPI* -1. *Initialize MPI* +#. *Create the SUNDIALS simulation context object* -2. *Set problem dimensions* +#. *Set problem dimensions* -3. *Set vector of initial values* +#. *Set vector of initial values* -4. *Create ARKStep object* +#. *Create ARKODE object* -5. *Specify integration tolerances* +#. *Specify integration tolerances* -6. Create iterative linear solver object +#. Create iterative linear solver object When creating the iterative linear solver object, specify the type of preconditioning (``SUN_PREC_LEFT`` or ``SUN_PREC_RIGHT``) to use. -7. *Set linear solver optional inputs* +#. *Set linear solver optional inputs* -8. *Attach linear solver module* +#. *Attach linear solver module* -9. Initialize the ARKBBDPRE preconditioner module +#. Initialize the ARKBBDPRE preconditioner module Specify the upper and lower half-bandwidths for computation ``mudq`` and ``mldq``, the upper and lower half-bandwidths for @@ -456,36 +455,38 @@ that are unchanged from the skeleton program presented in two user-supplied functions of type :c:func:`ARKLocalFn()` and :c:func:`ARKCommFn()` described above, respectively. -10. *Set optional inputs* +#. *Create nonlinear solver object* - Note that the user should not call - :c:func:`ARKStepSetPreconditioner()` as it will overwrite the - preconditioner setup and solve functions. +#. *Attach nonlinear solver module* -11. *Create nonlinear solver object* +#. *Set nonlinear solver optional inputs* -12. *Attach nonlinear solver module* +#. *Set optional inputs* -13. *Set nonlinear solver optional inputs* + Note that the user should not call + :c:func:`ARKodeSetPreconditioner()` as it will overwrite the + preconditioner setup and solve functions. -14. *Specify rootfinding problem* +#. *Specify rootfinding problem* -15. *Advance solution in time* +#. *Advance solution in time* -16. *Get optional outputs* +#. *Get optional outputs* - Additional optional outputs associated with ARKBBDPRE are - available through the routines - :c:func:`ARKBBDPrecGetWorkSpace()` and - :c:func:`ARKBBDPrecGetNumGfnEvals()`. + Additional optional outputs associated with ARKBBDPRE are + available through the routines + :c:func:`ARKBBDPrecGetWorkSpace()` and + :c:func:`ARKBBDPrecGetNumGfnEvals()`. -17. *Deallocate memory for solution vector* +#. *Deallocate memory for solution vector* -18. *Free solver memory* +#. *Free solver memory* -19. *Free linear solver memory* +#. *Free linear solver memory* -20. *Finalize MPI* +#. *Free nonlinear solver memory* + +#. *Finalize MPI* @@ -502,35 +503,34 @@ and attached to the integrator by calling the following functions: Initializes and allocates (internal) memory for the ARKBBDPRE preconditioner. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *Nlocal* -- local vector length. - * *mudq* -- upper half-bandwidth to be used in the difference - quotient Jacobian approximation. - * *mldq* -- lower half-bandwidth to be used in the difference - quotient Jacobian approximation. - * *mukeep* -- upper half-bandwidth of the retained banded - approximate Jacobian block. - * *mlkeep* -- lower half-bandwidth of the retained banded - approximate Jacobian block. - * *dqrely* -- the relative increment in components of *y* used in - the difference quotient approximations. The default is *dqrely* - = :math:`\sqrt{\text{unit roundoff}}`, which can be specified by - passing *dqrely* = 0.0. - * *gloc* -- the name of the C function (of type :c:func:`ARKLocalFn()`) - which computes the approximation :math:`g(t,y) \approx f^I(t,y)`. - * *cfn* -- the name of the C function (of type :c:func:`ARKCommFn()`) which - performs all inter-process communication required for the - computation of :math:`g(t,y)`. - - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_ILL_INPUT* if an input has an illegal value - * *ARKLS_MEM_FAIL* if a memory allocation request failed - - **Notes:** + :param arkode_mem: pointer to the ARKODE memory block. + :param Nlocal: local vector length. + :param mudq: upper half-bandwidth to be used in the difference + quotient Jacobian approximation. + :param mldq: lower half-bandwidth to be used in the difference + quotient Jacobian approximation. + :param mukeep: upper half-bandwidth of the retained banded + approximate Jacobian block. + :param mlkeep: lower half-bandwidth of the retained banded + approximate Jacobian block. + :param dqrely: the relative increment in components of *y* used in + the difference quotient approximations. The default is *dqrely* + = :math:`\sqrt{\text{unit roundoff}}`, which can be specified by + passing *dqrely* = 0.0. + :param gloc: the name of the C function (of type :c:func:`ARKLocalFn()`) + which computes the approximation :math:`g(t,y) \approx f^I(t,y)`. + :param cfn: the name of the C function (of type :c:func:`ARKCommFn()`) which + performs all inter-process communication required for the + computation of :math:`g(t,y)`. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARKLS_MEM_FAIL: a memory allocation request failed. + + .. note:: + If one of the half-bandwidths *mudq* or *mldq* to be used in the difference quotient calculation of the approximate Jacobian is negative or exceeds the value *Nlocal*-1, it is replaced by 0 or @@ -554,7 +554,7 @@ The ARKBBDPRE module also provides a re-initialization function to allow solving a sequence of problems of the same size, with the same linear solver choice, provided there is no change in *Nlocal*, *mukeep*, or *mlkeep*. After solving one problem, and after -calling :c:func:`ARKStepReInit()` to re-initialize ARKStep for a +calling ``*StepReInit`` to re-initialize ARKODE for a subsequent problem, a call to :c:func:`ARKBBDPrecReInit()` can be made to change any of the following: the half-bandwidths *mudq* and *mldq* used in the difference-quotient Jacobian approximations, the @@ -562,31 +562,30 @@ relative increment *dqrely*, or one of the user-supplied functions *gloc* and *cfn*. If there is a change in any of the linear solver inputs, an additional call to the "Set" routines provided by the SUNLINSOL module, and/or one or more of the corresponding -``ARKStepSet***`` functions, must also be made (in the proper order). +``ARKodeSet***`` functions, must also be made (in the proper order). .. c:function:: int ARKBBDPrecReInit(void* arkode_mem, sunindextype mudq, sunindextype mldq, sunrealtype dqrely) Re-initializes the ARKBBDPRE preconditioner module. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *mudq* -- upper half-bandwidth to be used in the difference - quotient Jacobian approximation. - * *mldq* -- lower half-bandwidth to be used in the difference - quotient Jacobian approximation. - * *dqrely* -- the relative increment in components of *y* used in - the difference quotient approximations. The default is *dqrely* - = :math:`\sqrt{\text{unit roundoff}}`, which can be specified by - passing *dqrely* = 0.0. - - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_PMEM_NULL* if the preconditioner memory is ``NULL`` - - **Notes:** + :param arkode_mem: pointer to the ARKODE memory block. + :param mudq: upper half-bandwidth to be used in the difference + quotient Jacobian approximation. + :param mldq: lower half-bandwidth to be used in the difference + quotient Jacobian approximation. + :param dqrely: the relative increment in components of *y* used in + the difference quotient approximations. The default is *dqrely* + = :math:`\sqrt{\text{unit roundoff}}`, which can be specified by + passing *dqrely* = 0.0. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_PMEM_NULL: the preconditioner memory was ``NULL``. + + .. note:: + If one of the half-bandwidths *mudq* or *mldq* is negative or exceeds the value *Nlocal*-1, it is replaced by 0 or *Nlocal*-1 accordingly. @@ -601,26 +600,25 @@ the ARKBBDPRE module: Returns the processor-local ARKBBDPRE real and integer workspace sizes. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *lenrwBBDP* -- the number of ``sunrealtype`` values in the - ARKBBDPRE workspace. - * *leniwBBDP* -- the number of integer values in the ARKBBDPRE workspace. + :param arkode_mem: pointer to the ARKODE memory block. + :param lenrwBBDP: the number of ``sunrealtype`` values in the + ARKBBDPRE workspace. + :param leniwBBDP: the number of integer values in the ARKBBDPRE workspace. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_PMEM_NULL: the preconditioner memory was ``NULL``. - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_PMEM_NULL* if the preconditioner memory is ``NULL`` + .. note:: - **Notes:** The workspace requirements reported by this routine correspond only to memory allocated within the ARKBBDPRE module (the banded matrix approximation, banded ``SUNLinearSolver`` object, temporary vectors). These values are local to each process. The workspaces referred to here exist in addition to those given by - the corresponding function :c:func:`ARKStepGetLinWorkSpace()`. + the corresponding function :c:func:`ARKodeGetLinWorkSpace()`. @@ -631,22 +629,20 @@ the ARKBBDPRE module: difference approximation of the Jacobian blocks used within the preconditioner setup function. - **Arguments:** - * *arkode_mem* -- pointer to the ARKStep memory block. - * *ngevalsBBDP* -- the number of calls made to the user-supplied - *gloc* function. + :param arkode_mem: pointer to the ARKODE memory block. + :param ngevalsBBDP: the number of calls made to the user-supplied + *gloc* function. - **Return value:** - * *ARKLS_SUCCESS* if no errors occurred - * *ARKLS_MEM_NULL* if the ARKStep memory is ``NULL`` - * *ARKLS_LMEM_NULL* if the linear solver memory is ``NULL`` - * *ARKLS_PMEM_NULL* if the preconditioner memory is ``NULL`` + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_PMEM_NULL: the preconditioner memory was ``NULL``. In addition to the *ngevalsBBDP* *gloc* evaluations, the costs associated with ARKBBDPRE also include *nlinsetups* LU factorizations, *nlinsetups* calls to *cfn*, *npsolves* banded backsolve calls, and *nfevalsLS* right-hand side function -evaluations, where *nlinsetups* is an optional ARKStep output and +evaluations, where *nlinsetups* is an optional ARKODE output and *npsolves* and *nfevalsLS* are linear solver optional outputs (see -the table :numref:`ARKODE.Usage.ARKStep.ARKLsOutputs`). +the table :numref:`ARKODE.Usage.ARKLsOutputs`). diff --git a/doc/arkode/guide/source/Usage/Relaxation.rst b/doc/arkode/guide/source/Usage/Relaxation.rst new file mode 100644 index 0000000000..f69c60e392 --- /dev/null +++ b/doc/arkode/guide/source/Usage/Relaxation.rst @@ -0,0 +1,359 @@ +.. ----------------------------------------------------------------------------- + Programmer(s): David J. Gardner @ 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 + ----------------------------------------------------------------------------- + +.. _ARKODE.Usage.Relaxation: + +Relaxation Methods +================== + +This section describes user-callable functions for applying relaxation methods +with ARKODE. For more information on relaxation Runge--Kutta methods see +:numref:`ARKODE.Mathematics.Relaxation`. + +.. warning:: + + Relaxation support as not been evaluated with non-identity mass matrices. + While this usage mode is supported, feedback from users who explore this + combination would be appreciated. + +Enabling or Disabling Relaxation +-------------------------------- + +.. c:function:: int ARKodeSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) + + Attaches the user supplied functions for evaluating the relaxation function + (``rfn``) and its Jacobian (``rjac``). + + Both ``rfn`` and ``rjac`` are required and an error will be returned if only + one of the functions is ``NULL``. If both ``rfn`` and ``rjac`` are ``NULL``, + relaxation is disabled. + + With DIRK and IMEX-ARK methods or when a fixed mass matrix is present, + applying relaxation requires allocating :math:`s` additional state vectors + (where :math:`s` is the number of stages in the method). + + :param arkode_mem: the ARKODE memory structure + :param rfn: the user-defined function to compute the relaxation function + :math:`\xi(y)` + :param rjac: the user-defined function to compute the relaxation Jacobian + :math:`\xi'(y)` + + :retval ARK_SUCCESS: the function exited successfully + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_ILL_INPUT: an invalid input combination was provided (see the + output error message for more details) + :retval ARK_MEM_FAIL: a memory allocation failed + + .. warning:: + + Applying relaxation requires using a method of at least second order with + :math:`b^E_i \geq 0` and :math:`b^I_i \geq 0`. If these conditions are not + satisfied, :c:func:`ARKodeEvolve` will return with an error during + initialization. + + .. note:: + + When combined with fixed time step sizes, ARKODE will attempt each step + using the specified step size. If the step is successful, relaxation will + be applied, effectively modifying the step size for the current step. If + the step fails or applying relaxation fails, :c:func:`ARKodeEvolve` will + return with an error. + + .. versionadded:: x.y.z + +Optional Input Functions +------------------------ + +This section describes optional input functions used to control applying +relaxation. + +.. c:function:: int ARKodeSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf) + + Sets the step size reduction factor applied after a failed relaxation + application. + + The default value is 0.25. Input values :math:`\leq 0` or :math:`\geq 1` will + result in the default value being used. + + :param arkode_mem: the ARKODE memory structure + :param eta_rf: the step size reduction factor + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) + + Sets the smallest acceptable value for the relaxation parameter. + + Values smaller than the lower bound will result in a failed relaxation + application and the step will be repeated with a smaller step size + (determined by :c:func:`ARKodeSetRelaxEtaFail`). + + The default value is 0.8. Input values :math:`\leq 0` or :math:`\geq 1` will + result in the default value being used. + + :param arkode_mem: the ARKODE memory structure + :param lower: the relaxation parameter lower bound + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) + + Sets the largest acceptable value for the relaxation parameter. + + Values larger than the upper bound will result in a failed relaxation + application and the step will be repeated with a smaller step size + (determined by :c:func:`ARKodeSetRelaxEtaFail`). + + The default value is 1.2. Input values :math:`\leq 1` will result in the + default value being used. + + :param arkode_mem: the ARKODE memory structure + :param upper: the relaxation parameter upper bound + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxMaxFails(void* arkode_mem, int max_fails) + + Sets the maximum number of times applying relaxation can fail within a step + attempt before the integration is halted with an error. + + The default value is 10. Input values :math:`\leq 0` will result in the + default value being used. + + :param arkode_mem: the ARKODE memory structure + :param max_fails: the maximum number of failed relaxation applications + allowed in a step + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxMaxIters(void* arkode_mem, int max_iters) + + Sets the maximum number of nonlinear iterations allowed when solving for the + relaxation parameter. + + If the maximum number of iterations is reached before meeting the solve + tolerance (determined by :c:func:`ARKodeSetRelaxResTol` and + :c:func:`ARKodeSetRelaxTol`), the step will be repeated with a smaller + step size (determined by :c:func:`ARKodeSetRelaxEtaFail`). + + The default value is 10. Input values :math:`\leq 0` will result in the + default value being used. + + :param arkode_mem: the ARKODE memory structure + :param max_iters: the maximum number of solver iterations allowed + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) + + Sets the nonlinear solver method used to compute the relaxation parameter. + + The default value is ``ARK_RELAX_NEWTON``. + + :param arkode_mem: the ARKODE memory structure + :param solver: the nonlinear solver to use: ``ARK_RELAX_BRENT`` or + ``ARK_RELAX_NEWTON`` + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + :retval ARK_ILL_INPUT: an invalid solver option was provided + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) + + Sets the nonlinear solver residual tolerance to use when solving + :eq:`ARKODE_RELAX_NLS`. + + If the residual or iteration update tolerance (see + :c:func:`ARKodeSetRelaxMaxIters`) is not reached within the maximum number of + iterations (determined by :c:func:`ARKodeSetRelaxMaxIters`), the step will + be repeated with a smaller step size (determined by + :c:func:`ARKodeSetRelaxEtaFail`). + + The default value is :math:`4 \epsilon` where :math:`\epsilon` is + floating-point precision. Input values :math:`\leq 0` will result in the + default value being used. + + :param arkode_mem: the ARKODE memory structure + :param res_tol: the nonlinear solver residual tolerance to use + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) + + Sets the nonlinear solver relative and absolute tolerance on changes in + :math:`r` iterates when solving :eq:`ARKODE_RELAX_NLS`. + + If the residual (see :c:func:`ARKodeSetRelaxResTol`) or iterate update + tolerance is not reached within the maximum number of iterations (determined + by :c:func:`ARKodeSetRelaxMaxIters`), the step will be repeated with a + smaller step size (determined by :c:func:`ARKodeSetRelaxEtaFail`). + + The default relative and absolute tolerances are :math:`4 \epsilon` and + :math:`10^{-14}`, respectively, where :math:`\epsilon` is floating-point + precision. Input values :math:`\leq 0` will result in the default value being + used. + + :param arkode_mem: the ARKODE memory structure + :param rel_tol: the nonlinear solver relative solution tolerance to use + :param abs_tol: the nonlinear solver absolute solution tolerance to use + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +Optional Output Functions +------------------------- + +This section describes optional output functions used to retrieve information +about the performance of the relaxation method. + +.. c:function:: int ARKodeGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) + + Get the number of times the user's relaxation function was evaluated. + + :param arkode_mem: the ARKODE memory structure + :param r_evals: the number of relaxation function evaluations + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) + + Get the number of times the user's relaxation Jacobian was evaluated. + + :param arkode_mem: the ARKODE memory structure + :param J_evals: the number of relaxation Jacobian evaluations + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumRelaxFails(void* arkode_mem, long int* fails) + + Get the total number of times applying relaxation failed. + + The counter includes the sum of the number of nonlinear solver failures + (see :c:func:`ARKodeGetNumRelaxSolveFails`) and the number of failures due + an unacceptable relaxation value (see :c:func:`ARKodeSetRelaxLowerBound` and + :c:func:`ARKodeSetRelaxUpperBound`). + + :param arkode_mem: the ARKODE memory structure + :param fails: the total number of failed relaxation attempts + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumRelaxBoundFails(void* arkode_mem, long int* fails) + + Get the number of times the relaxation parameter was deemed unacceptable. + + :param arkode_mem: the ARKODE memory structure + :param fails: the number of failures due to an unacceptable relaxation + parameter value + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumRelaxSolveFails(void* arkode_mem, long int* fails) + + Get the number of times the relaxation parameter nonlinear solver failed. + + :param arkode_mem: the ARKODE memory structure + :param fails: the number of relaxation nonlinear solver failures + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumRelaxSolveIters(void* arkode_mem, long int* iters) + + Get the number of relaxation parameter nonlinear solver iterations. + + :param arkode_mem: the ARKODE memory structure + :param iters: the number of relaxation nonlinear solver iterations + + :retval ARK_SUCCESS: the value was successfully set + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_RELAX_MEM_NULL: the internal relaxation memory structure was + ``NULL`` + + .. versionadded:: x.y.z diff --git a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/Skeleton.rst b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/Skeleton.rst deleted file mode 100644 index 2cf457359c..0000000000 --- a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/Skeleton.rst +++ /dev/null @@ -1,143 +0,0 @@ -.. ---------------------------------------------------------------- - 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 - ---------------------------------------------------------------- - -.. _ARKODE.Usage.SPRKStep.Skeleton: - -A skeleton of the user's main program -============================================ - -The following is a skeleton of the user's main program (or calling -program) for the integration of an ODE IVP using the SPRKStep module. -Most of the steps are independent of the NVECTOR implementation used. -For the steps that are not, refer to :numref:`NVectors` for -the specific name of the function to be called or macro to be -referenced. - -.. index:: User main program - -#. Initialize parallel or multi-threaded environment, if appropriate. - - For example, call ``MPI_Init`` to initialize MPI if used, or set - ``num_threads``, the number of threads to use within the threaded - vector functions, if used. - -#. Create the SUNDIALS simulation context object. - - Call :c:func:`SUNContext_Create` to allocate the ``SUNContext`` object. - -#. Set problem dimensions, etc. - - This generally includes the problem size, ``N``, and may include - the local vector length ``Nlocal``. The problem size ``N`` is the - size including both the ``q`` and ``p`` variables. - - .. note:: - - The variables ``N`` and ``Nlocal`` should be of type - ``sunindextype``. - -#. Set vector of initial values - - To set the vector ``y0`` of initial values, use the appropriate - functions defined by the particular NVECTOR implementation. - The vector should include both the ``q`` and ``p`` variables. - - For most native SUNDIALS vector implementations, use a call of the form - - .. code-block:: c - - y0 = N_VMake_***(..., ydata); - - if the ``sunrealtype`` array ``ydata`` containing the initial values of - :math:`y` already exists. For some GPU-enabled vectors, a similar constructor - can be used to provide host and device data pointers. If the data array - does not already exist, create a new vector by making a call of the form - - .. code-block:: c - - y0 = N_VNew_***(...); - - and then set its elements by accessing the underlying data where it - is located with a call of the form - - .. code-block:: c - - ydata = N_VGetArrayPointer_***(y0); - - For details on each of SUNDIALS' provided vector implementations, see - the corresponding sections in :numref:`NVectors` for details. - -#. Create SPRKStep object - - Call ``arkode_mem = SPRKStepCreate(...)`` to create the SPRKStep memory - block. :c:func:`SPRKStepCreate` returns a ``void*`` pointer to - this memory structure. See :numref:`ARKODE.Usage.SPRKStep.Initialization` for - details. - -#. Specify time step size - - Call :c:func:`SPRKStepSetFixedStep()` to set the fixed time step size. - .. or :c:func:`SPRKStepAdaptivityFn()` to specify either a fixed time-step - .. size or a callback function that adapts the time-step size. SPRKStep - .. does not support error-based adaptivity like other ARKODE time-stepper - .. modules due to the incompatibility with symplectic methods. - -#. Set optional inputs - - Call ``SPRKStepSet*`` functions to change any optional inputs that - control the behavior of SPRKStep from their default values. See - :numref:`ARKODE.Usage.SPRKStep.OptionalInputs` for details. - -#. Specify rootfinding problem - - Optionally, call :c:func:`SPRKStepRootInit()` to initialize a rootfinding - problem to be solved during the integration of the ODE system. See - :numref:`ARKODE.Usage.SPRKStep.RootFinding` for general details, and - :numref:`ARKODE.Usage.SPRKStep.OptionalInputs` for relevant optional - input calls. - -#. Advance solution in time - - For each point at which output is desired, call - - .. code-block:: c - - ier = SPRKStepEvolve(arkode_mem, tout, yout, &tret, itask); - - Here, ``itask`` specifies the return mode. The vector ``yout`` - (which can be the same as the vector ``y0`` above) will contain - :math:`y(t_\text{out})`. See :numref:`ARKODE.Usage.SPRKStep.Integration` - for details. - -#. Get optional outputs - - Call ``SPRKStepGet*`` functions to obtain optional output. See - :numref:`ARKODE.Usage.SPRKStep.OptionalOutputs` for details. - -#. Deallocate memory for solution vector - - Upon completion of the integration, deallocate memory for the - vector ``y`` (or ``yout``) by calling the NVECTOR destructor - function: - - .. code-block:: c - - N_VDestroy(y); - -#. Free solver memory - - Call :c:func:`SPRKStepFree()` to free the memory allocated for - the SPRKStep module. - -#. Finalize MPI, if used - - Call ``MPI_Finalize`` to terminate MPI. diff --git a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst index 9dc6d5f359..45996860cf 100644 --- a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst +++ b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/User_callable.rst @@ -15,22 +15,20 @@ SPRKStep User-callable functions ================================== -This section describes the functions that are called by the -user to setup and then solve an IVP using the SPRKStep time-stepping -module. Some of these are required; however, starting with -:numref:`ARKODE.Usage.SPRKStep.OptionalInputs`, the functions listed involve -optional inputs/outputs or restarting, and those paragraphs may be -skipped for a casual use of ARKODE's SPRKStep module. In any case, -refer to the preceding section, :numref:`ARKODE.Usage.SPRKStep.Skeleton`, -for the correct order of these calls. - -On an error, each user-callable function returns a negative value (or -``NULL`` if the function returns a pointer) and sends an error message -to the error handler routine, which prints the message to ``stderr`` -by default. However, the user can set a file as error output or can -provide their own error handler function (see -:numref:`ARKODE.Usage.SPRKStep.OptionalInputs` for details). - +This section describes the SPRKStep-specific functions that may be called +by the user to setup and then solve an IVP using the SPRKStep time-stepping +module. The large majority of these routines merely wrap :ref:`underlying +ARKODE functions `, and are now deprecated +-- each of these are clearly marked. However, some +of these user-callable functions are specific to ERKStep, as explained +below. + +As discussed in the main :ref:`ARKODE user-callable function introduction +`, each of ARKODE's time-stepping modules +clarifies the categories of user-callable functions that it supports. +SPRKStep supports only the basic set of user-callable functions, and +does not support any of the restricted groups (time adaptivity, implicit +solvers, etc.). .. _ARKODE.Usage.SPRKStep.Initialization: @@ -72,26 +70,16 @@ SPRKStep initialization and deallocation functions :param arkode_mem: pointer to the SPRKStep memory block. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeFree` instead. + .. _ARKODE.Usage.SPRKStep.RootFinding: Rootfinding initialization function -------------------------------------- -As described in :numref:`ARKODE.Mathematics.Rootfinding`, while -solving the IVP, ARKODE's time-stepping modules have the capability to -find the roots of a set of user-defined functions. To activate the -root-finding algorithm, call the following function. This is normally -called only once, prior to the first call to -:c:func:`SPRKStepEvolve()`, but if the rootfinding problem is to be -changed during the solution, :c:func:`SPRKStepRootInit()` can also be -called prior to a continuation call to :c:func:`SPRKStepEvolve()`. - -.. note:: - - The solution is interpolated to the times at which roots are found. - - .. c:function:: int SPRKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) Initializes a rootfinding problem to be solved during the @@ -116,20 +104,16 @@ called prior to a continuation call to :c:func:`SPRKStepEvolve()`. :retval ARK_MEM_FAIL: if there was a memory allocation failure :retval ARK_ILL_INPUT: if *nrtfn* is greater than zero but *g* = ``NULL``. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeRootInit` instead. + .. _ARKODE.Usage.SPRKStep.Integration: SPRKStep solver function ------------------------- -This is the central step in the solution process -- the call to perform -the integration of the IVP. One of the input arguments (*itask*) -specifies one of two modes as to where SPRKStep is to return a -solution. These modes are modified if the user has set a stop time -(with a call to the optional input function :c:func:`SPRKStepSetStopTime()`) or -has requested rootfinding. - - .. c:function:: int SPRKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype *tret, int itask) @@ -215,6 +199,10 @@ has requested rootfinding. On all other error returns, *tret* and *yout* are left unchanged from those provided to the routine. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeEvolve` instead. + @@ -223,63 +211,12 @@ has requested rootfinding. Optional input functions ------------------------- -There are numerous optional input parameters that control the behavior -of SPRKStep, each of which may be modified from its default value through -calling an appropriate input function. The following tables list all -optional input functions, grouped by which aspect of SPRKStep they control. -Detailed information on the calling syntax and arguments for each -function are then provided following each table. - -The optional inputs are grouped into the following categories: - -* General SPRKStep options (:numref:`ARKODE.Usage.SPRKStep.SPRKStepInputTable`), - -* IVP method solver options (:numref:`ARKODE.Usage.SPRKStep.SPRKStepMethodInputTable`), - -* Rootfinding options (:numref:`ARKODE.Usage.SPRKStep.SPRKStepRootfindingInputTable`). - -For the most casual use of SPRKStep, relying on the default set of -solver parameters, the reader can skip to section on user-supplied -functions, :numref:`ARKODE.Usage.UserSupplied`. - -We note that, on an error return, all of the optional input functions send an -error message to the error handler function. All error return values are -negative, so a test on the return arguments for negative values will catch all -errors. Finally, a call to a ``SPRKStepSet***`` function can generally be made -from the user's calling program at any time and, if successful, takes effect -immediately. For ``SPRKStepSet***`` functions that cannot be called at any time, -this is explicitly noted in the function documentation. - - .. _ARKODE.Usage.SPRKStep.SPRKStepInput: Optional inputs for SPRKStep ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. _ARKODE.Usage.SPRKStep.SPRKStepInputTable: -.. table:: Optional inputs for SPRKStep - - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Optional input | Function name | Default | - +=====================================================+==========================================+========================+ - | Return SPRKStep solver parameters to their defaults | :c:func:`SPRKStepSetDefaults()` | internal | - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Set dense output interpolation type | :c:func:`SPRKStepSetInterpolantType()` | ``ARK_INTERP_LAGRANGE``| - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Set dense output polynomial degree | :c:func:`SPRKStepSetInterpolantDegree()` | 5 | - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Set fixed step size (required user input) | :c:func:`SPRKStepSetFixedStep()` | user defined | - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Maximum no. of internal steps before *tout* | :c:func:`SPRKStepSetMaxNumSteps()` | 500 | - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Set a value for :math:`t_{stop}` | :c:func:`SPRKStepSetStopTime()` | undefined | - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Disable the stop time | :c:func:`SPRKStepClearStopTime` | N/A | - +-----------------------------------------------------+------------------------------------------+------------------------+ - | Supply a pointer for user data | :c:func:`SPRKStepSetUserData()` | ``NULL`` | - +-----------------------------------------------------+------------------------------------------+------------------------+ - .. c:function:: int SPRKStepSetDefaults(void* arkode_mem) @@ -300,6 +237,10 @@ Optional inputs for SPRKStep Also leaves alone any data structures or options related to root-finding (those can be reset using :c:func:`SPRKStepRootInit()`). + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetDefaults` instead. + .. c:function:: int SPRKStepSetInterpolantType(void* arkode_mem, int itype) @@ -336,6 +277,9 @@ Optional inputs for SPRKStep has shown that Lagrange interpolation typically performs well in this regard, while Hermite interpolation does not. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantType` instead. .. c:function:: int SPRKStepSetInterpolantDegree(void* arkode_mem, int degree) @@ -372,6 +316,10 @@ Optional inputs for SPRKStep When `q = 1`, a linear interpolant is the default to ensure values obtained by the integrator are returned at the ends of the time interval. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetInterpolantDegree` instead. + .. c:function:: int SPRKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) @@ -384,6 +332,10 @@ Optional inputs for SPRKStep :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetFixedStep` instead. + .. c:function:: int SPRKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) @@ -403,6 +355,10 @@ Optional inputs for SPRKStep :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetMaxNumSteps` instead. + .. c:function:: int SPRKStepSetStopTime(void* arkode_mem, sunrealtype tstop) @@ -426,6 +382,10 @@ Optional inputs for SPRKStep :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetStopTime` instead. + .. c:function:: int SPRKStepClearStopTime(void* arkode_mem) @@ -439,6 +399,10 @@ Optional inputs for SPRKStep :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeClearStopTime` instead. + .. c:function:: int SPRKStepSetUserData(void* arkode_mem, void* user_data) @@ -456,6 +420,10 @@ Optional inputs for SPRKStep :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetUserData` instead. + .. _ARKODE.Usage.SPRKStep.SPRKStepMethodInput: @@ -501,6 +469,10 @@ Optional inputs for IVP method selection This overrides any previously set method so it should not be used with :c:func:`SPRKStepSetMethod` or :c:func:`SPRKStepSetMethodName`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetOrder` instead. + .. c:function:: int SPRKStepSetMethod(void* arkode_mem, ARKodeSPRKTable sprk_table) @@ -518,6 +490,10 @@ Optional inputs for IVP method selection No error checking is performed on the coefficients contained in the table to ensure its declared order of accuracy. + .. warning:: + + This should not be used with :c:func:`ARKodeSetOrder`. + .. c:function:: int SPRKStepSetMethodName(void* arkode_mem, const char* method) @@ -530,6 +506,10 @@ Optional inputs for IVP method selection :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value + .. warning:: + + This should not be used with :c:func:`ARKodeSetOrder`. + .. c:function:: int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) @@ -549,29 +529,13 @@ Optional inputs for IVP method selection :retval ARK_ILL_INPUT: if an argument has an illegal value + .. _ARKODE.Usage.SPRKStep.SPRKStepRootfindingInput: Rootfinding optional input functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following functions can be called to set optional inputs to -control the rootfinding algorithm, the mathematics of which are -described in :numref:`ARKODE.Mathematics.Rootfinding`. - - -.. _ARKODE.Usage.SPRKStep.SPRKStepRootfindingInputTable: -.. table:: Rootfinding optional input functions - - +-----------------------------------------+-------------------------------------------+----------+ - | Optional input | Function name | Default | - +=========================================+===========================================+==========+ - | Direction of zero-crossings to monitor | :c:func:`SPRKStepSetRootDirection()` | both | - +-----------------------------------------+-------------------------------------------+----------+ - | Disable inactive root warnings | :c:func:`SPRKStepSetNoInactiveRootWarn()` | enabled | - +-----------------------------------------+-------------------------------------------+----------+ - - .. c:function:: int SPRKStepSetRootDirection(void* arkode_mem, int* rootdir) @@ -592,6 +556,10 @@ described in :numref:`ARKODE.Mathematics.Rootfinding`. :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` :retval ARK_ILL_INPUT: if an argument has an illegal value + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetRootDirection` instead. + .. c:function:: int SPRKStepSetNoInactiveRootWarn(void* arkode_mem) @@ -610,22 +578,16 @@ described in :numref:`ARKODE.Mathematics.Rootfinding`. :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeSetNoInactiveRootWarn` instead. + .. _ARKODE.Usage.SPRKStep.InterpolatedOutput: Interpolated output function -------------------------------- -An optional function :c:func:`SPRKStepGetDky()` is available to obtain -additional values of solution-related quantities. This function -should only be called after a successful return from -:c:func:`SPRKStepEvolve()`, as it provides interpolated values either of -:math:`y` or of its derivatives. -interpolated to any value of :math:`t` in the last internal step taken -by :c:func:`SPRKStepEvolve()`. - - - .. c:function:: int SPRKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) Computes the *k*-th derivative of the function :math:`y` at the time *t*, @@ -666,84 +628,22 @@ by :c:func:`SPRKStepEvolve()`. It is only legal to call this function after a successful return from :c:func:`SPRKStepEvolve()`. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetDky` instead. + .. _ARKODE.Usage.SPRKStep.OptionalOutputs: Optional output functions ------------------------------ -SPRKStep provides an extensive set of functions that can be used to -obtain solver performance information. We organize these into groups: - -#. General SPRKStep output routines are in - :numref:`ARKODE.Usage.SPRKStep.SPRKStepMainOutputs`, - -#. Output routines regarding root-finding results are in - :numref:`ARKODE.Usage.SPRKStep.SPRKStepRootOutputs`, - -#. General usability routines (e.g. to print the current SPRKStep - parameters, or output the current Butcher tables) are in - :numref:`ARKODE.Usage.SPRKStep.SPRKStepExtraOutputs`. - -Following each table, we elaborate on each function. - -Some of the optional outputs, especially the various counters, can be -very useful in determining the efficiency of various methods inside -SPRKStep. For example: - -* The counters *nsteps* and *nf_evals* provide a rough measure of the - overall cost of a given run, and can be compared between runs with - different solver options to suggest which set of options is the most - efficient. - -.. * The ratio *nsteps/step_attempts* can measure the quality of the -.. time step adaptivity algorithm, since a poor algorithm will result -.. in more failed steps, and hence a lower ratio. - -It is therefore recommended that users retrieve and output these -statistics following each run, and take some time to investigate -alternate solver options that will be more optimal for their -particular problem of interest. - - .. _ARKODE.Usage.SPRKStep.SPRKStepMainOutputs: Main solver optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. _ARKODE.Usage.SPRKStep.SPRKStepMainOutputsTable: -.. table:: Main solver optional output functions - - +-----------------------------------------------------+--------------------------------------------+ - | Optional output | Function name | - +=====================================================+============================================+ - | Cumulative number of internal steps | :c:func:`SPRKStepGetNumSteps` | - +-----------------------------------------------------+--------------------------------------------+ - | Step size used for the last successful step | :c:func:`SPRKStepGetLastStep` | - +-----------------------------------------------------+--------------------------------------------+ - | Step size to be attempted on the next step | :c:func:`SPRKStepGetCurrentStep` | - +-----------------------------------------------------+--------------------------------------------+ - | Current internal time reached by the solver | :c:func:`SPRKStepGetCurrentTime` | - +-----------------------------------------------------+--------------------------------------------+ - | Current internal state reached by the solver | :c:func:`SPRKStepGetCurrentState` | - +-----------------------------------------------------+--------------------------------------------+ - | Single accessor to many statistics at once | :c:func:`SPRKStepGetStepStats` | - +-----------------------------------------------------+--------------------------------------------+ - | Print all statistics | :c:func:`SPRKStepPrintAllStats` | - +-----------------------------------------------------+--------------------------------------------+ - | Name of constant associated with a return flag | :c:func:`SPRKStepGetReturnFlagName` | - +-----------------------------------------------------+--------------------------------------------+ - | No. of attempted steps | :c:func:`SPRKStepGetNumStepAttempts` | - +-----------------------------------------------------+--------------------------------------------+ - | No. of calls to right-hand side functions | :c:func:`SPRKStepGetNumRhsEvals` | - +-----------------------------------------------------+--------------------------------------------+ - | Current method table | :c:func:`SPRKStepGetCurrentMethod` | - +-----------------------------------------------------+--------------------------------------------+ - | Retrieve a pointer for user data | :c:func:`SPRKStepGetUserData` | - +-----------------------------------------------------+--------------------------------------------+ - - .. c:function:: int SPRKStepGetNumSteps(void* arkode_mem, long int* nsteps) @@ -756,6 +656,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumSteps` instead. + .. c:function:: int SPRKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) @@ -768,6 +672,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetLastStep` instead. + .. c:function:: int SPRKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) @@ -779,6 +687,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentStep` instead. + .. c:function:: int SPRKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) @@ -790,6 +702,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentTime` instead. + .. c:function:: int SPRKStepGetCurrentState(void *arkode_mem, N_Vector *ycur) @@ -807,6 +723,10 @@ Main solver optional output functions as altering values of *ycur* may lead to undesirable behavior, depending on the particular use case and on when this routine is called. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentState` instead. + .. c:function:: int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) @@ -822,6 +742,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetStepStats` instead. + .. c:function:: int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) @@ -845,6 +769,9 @@ Main solver optional output functions read and output the data from a SUNDIALS CSV output file using the key and value pair format. + .. deprecated:: x.y.z + + Use :c:func:`ARKodePrintAllStats` instead. .. c:function:: char *SPRKStepGetReturnFlagName(long int flag) @@ -857,6 +784,10 @@ Main solver optional output functions :returns: The return value is a string containing the name of the corresponding constant. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetReturnFlagName` instead. + .. c:function:: int SPRKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts) @@ -868,6 +799,10 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumStepAttempts` instead. + .. c:function:: int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) @@ -905,26 +840,16 @@ Main solver optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the ARKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetUserData` instead. + .. _ARKODE.Usage.SPRKStep.SPRKStepRootOutputs: Rootfinding optional output functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. _ARKODE.Usage.SPRKStep.SPRKStepRootOutputsTable: -.. table:: Rootfinding optional output functions - - +--------------------------------------------------+---------------------------------+ - | Optional output | Function name | - +==================================================+=================================+ - | Array showing roots found | :c:func:`SPRKStepGetRootInfo()` | - +--------------------------------------------------+---------------------------------+ - | No. of calls to user root function | :c:func:`SPRKStepGetNumGEvals()`| - +--------------------------------------------------+---------------------------------+ - - - .. c:function:: int SPRKStepGetRootInfo(void* arkode_mem, int* rootsfound) Returns an array showing which functions were found to have a root. @@ -947,6 +872,10 @@ Rootfinding optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetRootInfo` instead. + .. c:function:: int SPRKStepGetNumGEvals(void* arkode_mem, long int* ngevals) @@ -959,28 +888,16 @@ Rootfinding optional output functions :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNumGEvals` instead. + .. _ARKODE.Usage.SPRKStep.SPRKStepExtraOutputs: General usability functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The following optional routine may be called by a user to inquire -about existing solver parameters. While it would not typically be called -during the course of solving an initial value problem, it may be useful -for users wishing to better understand SPRKStep. - - -.. _ARKODE.Usage.SPRKStep.SPRKStepExtraOutputsTable: -.. table:: General usability functions - - +----------------------------------------+--------------------------------------+ - | Optional routine | Function name | - +----------------------------------------+--------------------------------------+ - | Output all SPRKStep solver parameters | :c:func:`SPRKStepWriteParameters()` | - +----------------------------------------+--------------------------------------+ - - .. c:function:: int SPRKStepWriteParameters(void* arkode_mem, FILE *fp) Outputs all SPRKStep solver parameters to the provided file pointer. @@ -997,6 +914,10 @@ for users wishing to better understand SPRKStep. :retval ARK_SUCCESS: if successful :retval ARK_MEM_NULL: if the SPRKStep memory was ``NULL`` + .. deprecated:: x.y.z + + Use :c:func:`ARKodeWriteParameters` instead. + .. _ARKODE.Usage.SPRKStep.Reinitialization: @@ -1061,22 +982,6 @@ the RHS function should not incorporate the discontinuity. SPRKStep reset function ----------------------- -To reset the SPRKStep module to a particular state :math:`(t_R,y(t_R))` for the -continued solution of a problem, where a prior -call to :c:func:`SPRKStepCreate` has been made, the user must call the function -:c:func:`SPRKStepReset()`. Like :c:func:`SPRKStepReInit()` this routine retains -the current settings for all SPRKStep module options and performs no memory -allocations but, unlike :c:func:`SPRKStepReInit()`, this routine performs only a -*subset* of the input checking and initializations that are done in -:c:func:`SPRKStepCreate`. In particular this routine retains all internal -counter values. Like :c:func:`SPRKStepReInit()`, a call to -:c:func:`SPRKStepReset()` will delete any previously-set *tstop* value specified -via a call to :c:func:`SPRKStepSetStopTime()`. Following a successful call to -:c:func:`SPRKStepReset()`, call :c:func:`SPRKStepEvolve()` again to continue -solving the problem. By default the next call to :c:func:`SPRKStepEvolve()` will -use the step size computed by SPRKStep prior to calling :c:func:`SPRKStepReset()`. - - .. c:function:: int SPRKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) Resets the current SPRKStep time-stepper module state to the provided @@ -1101,3 +1006,7 @@ use the step size computed by SPRKStep prior to calling :c:func:`SPRKStepReset() By default the next call to :c:func:`SPRKStepEvolve()` will use the step size computed by SPRKStep prior to calling :c:func:`SPRKStepReset()`. + + .. deprecated:: x.y.z + + Use :c:func:`ARKodeReset` instead. diff --git a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/index.rst b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/index.rst index 536d94391c..ec3dbdc935 100644 --- a/doc/arkode/guide/source/Usage/SPRKStep_c_interface/index.rst +++ b/doc/arkode/guide/source/Usage/SPRKStep_c_interface/index.rst @@ -16,30 +16,20 @@ Using the SPRKStep time-stepping module ========================================== -This chapter is concerned with the use of the SPRKStep time-stepping module for -the solution of initial value problems (IVPs) of the form -:eq:`ARKODE_IVP_SPRK` in a C or C++ language setting. The following sections -discuss the header files and the layout of the user's main program, and provide -descriptions of the SPRKStep user-callable functions and user-supplied functions. +This section is concerned with the use of the SPRKStep time-stepping +module for the solution of initial value problems (IVPs) in a C or C++ +language setting. Usage of SPRKStep follows that of the rest of ARKODE, +and so in this section we primarily focus on those usage aspects that +are specific to SPRKStep. -The example programs located in the source code ``examples/arkode`` folder, may -be helpful as templates for new codes. In particular, +We note that of the ARKODE example programs located in the source code +``examples/arkode`` folder, the following demonstrate ``SPRKStep`` usage: * ``examples/arkode/C_serial/ark_harmonic_symplectic.c`` * ``examples/arkode/C_serial/ark_damped_harmonic_symplectic.c``, and * ``examples/arkode/C_serial/ark_kepler.c`` -demonstrate ``SPRKStep`` usage. - -SPRKStep uses the input and output constants from the shared ARKODE infrastructure. -These are defined as needed in this chapter, but for convenience the full list is -provided separately in :numref:`ARKODE.Constants`. - -The relevant information on using SPRKStep's C and C++ interfaces is -detailed in the following subsections. - .. toctree:: :maxdepth: 1 - Skeleton User_callable diff --git a/doc/arkode/guide/source/Usage/ARKStep_c_interface/Skeleton.rst b/doc/arkode/guide/source/Usage/Skeleton.rst similarity index 73% rename from doc/arkode/guide/source/Usage/ARKStep_c_interface/Skeleton.rst rename to doc/arkode/guide/source/Usage/Skeleton.rst index daa3586143..5909007646 100644 --- a/doc/arkode/guide/source/Usage/ARKStep_c_interface/Skeleton.rst +++ b/doc/arkode/guide/source/Usage/Skeleton.rst @@ -12,13 +12,13 @@ SUNDIALS Copyright End ---------------------------------------------------------------- -.. _ARKODE.Usage.ARKStep.Skeleton: +.. _ARKODE.Usage.Skeleton: A skeleton of the user's main program ============================================ The following is a skeleton of the user's main program (or calling -program) for the integration of an ODE IVP using the ARKStep module. +program) for the integration of an ODE IVP using ARKODE. Most of the steps are independent of the NVECTOR, SUNMATRIX, SUNLINSOL and SUNNONLINSOL implementations used. For the steps that are not, refer to :numref:`NVectors`, :numref:`SUNMatrix`, @@ -77,30 +77,32 @@ the function to be called or macro to be referenced. For details on each of SUNDIALS' provided vector implementations, see the corresponding sections in :numref:`NVectors` for details. -#. Create ARKStep object +#. Create ARKODE object - Call ``arkode_mem = ARKStepCreate(...)`` to create the - ARKStep memory block. :c:func:`ARKStepCreate` returns a ``void*`` pointer to - this memory structure. See :numref:`ARKODE.Usage.ARKStep.Initialization` for - details. + Call a stepper-specific constructor, ``arkode_mem = *StepCreate(...)``, to + create the ARKODE memory block. These routines return a ``void*`` pointer to + this memory structure. See :numref:`ARKODE.Usage.ARKStep.Initialization`, + :numref:`ARKODE.Usage.ERKStep.Initialization`, + :numref:`ARKODE.Usage.MRIStep.Initialization`, or + :numref:`ARKODE.Usage.SPRKStep.Initialization` for details. #. Specify integration tolerances - Call :c:func:`ARKStepSStolerances()` or - :c:func:`ARKStepSVtolerances()` to specify either a scalar relative + Call :c:func:`ARKodeSStolerances()` or + :c:func:`ARKodeSVtolerances()` to specify either a scalar relative tolerance and scalar absolute tolerance, or a scalar relative tolerance and a vector of absolute tolerances, - respectively. Alternatively, call :c:func:`ARKStepWFtolerances()` + respectively. Alternatively, call :c:func:`ARKodeWFtolerances()` to specify a function which sets directly the weights used in evaluating WRMS vector norms. See - :numref:`ARKODE.Usage.ARKStep.Tolerances` for details. + :numref:`ARKODE.Usage.Tolerances` for details. If a problem with non-identity mass matrix is used, and the solution units differ considerably from the equation units, absolute tolerances for the equation residuals (nonlinear and linear) may be specified separately through calls to - :c:func:`ARKStepResStolerance()`, :c:func:`ARKStepResVtolerance()`, or - :c:func:`ARKStepResFtolerance()`. + :c:func:`ARKodeResStolerance()`, :c:func:`ARKodeResVtolerance()`, or + :c:func:`ARKodeResFtolerance()`. #. Create matrix object @@ -156,27 +158,27 @@ the function to be called or macro to be referenced. If a linear solver was created above for implicit stage solves, initialize the ARKLS linear solver interface by attaching the linear solver object (and Jacobian matrix object, if applicable) - with the call (for details see :numref:`ARKODE.Usage.ARKStep.LinearSolvers`): + with the call (for details see :numref:`ARKODE.Usage.LinearSolvers`): .. code-block:: c - ier = ARKStepSetLinearSolver(...); + ier = ARKodeSetLinearSolver(...); Similarly, if the problem involves a non-identity mass matrix, initialize the ARKLS mass matrix linear solver interface by attaching the mass linear solver object (and mass matrix object, if applicable) with the call (for details see - :numref:`ARKODE.Usage.ARKStep.LinearSolvers`): + :numref:`ARKODE.Usage.LinearSolvers`): .. code-block:: c - ier = ARKStepSetMassLinearSolver(...); + ier = ARKodeSetMassLinearSolver(...); #. Create nonlinear solver object If the problem involves an implicit component, and if a non-default nonlinear solver object will be used for implicit stage solves - (see :numref:`ARKODE.Usage.ARKStep.NonlinearSolvers`), + (see :numref:`ARKODE.Usage.NonlinearSolvers`), then the desired nonlinear solver object must be created by using the appropriate functions defined by the particular SUNNONLINSOL implementation (e.g., ``NLS = SUNNonlinSol_***(...);`` where @@ -196,34 +198,41 @@ the function to be called or macro to be referenced. #. Attach nonlinear solver module If a nonlinear solver object was created above, then it must be - attached to ARKStep using the call (for details see - :numref:`ARKODE.Usage.ARKStep.NonlinearSolvers`): + attached to ARKODE using the call (for details see + :numref:`ARKODE.Usage.NonlinearSolvers`): .. code-block:: c - ier = ARKStepSetNonlinearSolver(...); + ier = ARKodeSetNonlinearSolver(...); #. Set nonlinear solver optional inputs Call the appropriate set functions for the selected nonlinear solver module to change optional inputs specific to that nonlinear solver. These *must* be called after attaching the nonlinear - solver to ARKStep, otherwise the optional inputs will be - overridden by ARKStep defaults. See + solver to ARKODE, otherwise the optional inputs will be + overridden by ARKODE defaults. See :numref:`SUNNonlinSol` for more information on optional inputs. #. Set optional inputs - Call ``ARKStepSet*`` functions to change any optional inputs that - control the behavior of ARKStep from their default values. See - :numref:`ARKODE.Usage.ARKStep.OptionalInputs` for details. + Call ``ARKodeSet*`` functions to change any optional inputs that + control the behavior of ARKODE from their default values. See + :numref:`ARKODE.Usage.OptionalInputs` for details. + + Additionally, call ``*StepSet*`` routines to change any + stepper-specific optional inputs from their default values. See + :numref:`ARKODE.Usage.ARKStep.OptionalInputs`, + :numref:`ARKODE.Usage.ERKStep.OptionalInputs`, + :numref:`ARKODE.Usage.MRIStep.OptionalInputs`, or + :numref:`ARKODE.Usage.SPRKStep.OptionalInputs` for details. #. Specify rootfinding problem - Optionally, call :c:func:`ARKStepRootInit()` to initialize a rootfinding + Optionally, call :c:func:`ARKodeRootInit()` to initialize a rootfinding problem to be solved during the integration of the ODE system. See - :numref:`ARKODE.Usage.ARKStep.RootFinding` for general details, and - :numref:`ARKODE.Usage.ARKStep.OptionalInputs` for relevant optional + :numref:`ARKODE.Usage.RootFinding` for general details, and + :numref:`ARKODE.Usage.OptionalInputs` for relevant optional input calls. #. Advance solution in time @@ -232,17 +241,24 @@ the function to be called or macro to be referenced. .. code-block:: c - ier = ARKStepEvolve(arkode_mem, tout, yout, &tret, itask); + ier = ARKodeEvolve(arkode_mem, tout, yout, &tret, itask); Here, ``itask`` specifies the return mode. The vector ``yout`` (which can be the same as the vector ``y0`` above) will contain :math:`y(t_\text{out})`. See - :numref:`ARKODE.Usage.ARKStep.Integration` for details. + :numref:`ARKODE.Usage.Integration` for details. #. Get optional outputs - Call ``ARKStepGet*`` functions to obtain optional output. See - :numref:`ARKODE.Usage.ARKStep.OptionalOutputs` for details. + Call ``ARKodeGet*`` functions to obtain optional output. See + :numref:`ARKODE.Usage.OptionalOutputs` for details. + + Additionally, call ``*StepGet*`` routines to retrieve any + stepper-specific optional outputs. See + :numref:`ARKODE.Usage.ARKStep.OptionalOutputs`, + :numref:`ARKODE.Usage.ERKStep.OptionalOutputs`, + :numref:`ARKODE.Usage.MRIStep.OptionalOutputs`, or + :numref:`ARKODE.Usage.SPRKStep.OptionalOutputs` for details. #. Deallocate memory for solution vector @@ -255,8 +271,8 @@ the function to be called or macro to be referenced. #. Free solver memory - Call :c:func:`ARKStepFree()` to free the memory allocated for - the ARKStep module (and any nonlinear solver module). + Call :c:func:`ARKodeFree()` to free the memory allocated for + the ARKODE module (and any nonlinear solver module). #. Free linear solver and matrix memory @@ -266,10 +282,14 @@ the function to be called or macro to be referenced. #. Free nonlinear solver memory - If a user-supplied ``SUNNonlinearSolver`` was provided to ARKStep, + If a user-supplied ``SUNNonlinearSolver`` was provided to ARKODE, then call :c:func:`SUNNonlinSolFree()` to free any memory allocated for the nonlinear solver object created above. +#. Free the SUNContext object + + Call :c:func:`SUNContext_Free` to free the memory allocated for the ``SUNContext`` object. + #. Finalize MPI, if used Call ``MPI_Finalize`` to terminate MPI. diff --git a/doc/arkode/guide/source/Usage/User_callable.rst b/doc/arkode/guide/source/Usage/User_callable.rst new file mode 100644 index 0000000000..9ee7aa309b --- /dev/null +++ b/doc/arkode/guide/source/Usage/User_callable.rst @@ -0,0 +1,4670 @@ +.. ---------------------------------------------------------------- + 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 + ---------------------------------------------------------------- + +.. _ARKODE.Usage.UserCallable: + +ARKODE User-callable functions +================================ + +This section describes the shared ARKODE functions that are called by +the user to setup and then solve an IVP. Some of these are required; +however, starting with :numref:`ARKODE.Usage.OptionalInputs`, +the functions listed involve optional inputs/outputs or restarting, +and those paragraphs may be skipped for a casual use of ARKODE. +In any case, refer to the preceding section, +:numref:`ARKODE.Usage.Skeleton`, for the correct order of these calls. + +On an error, each user-callable function returns a negative value (or +``NULL`` if the function returns a pointer) and sends an error message +to the error handler, which prints the message to ``stderr`` by default. +However, the user can set a file as error output or can +provide their own error handler (see :numref:`SUNDIALS.Errors` for details). + +We note that depending on the choice of time-stepping module, only a +subset of ARKODE's user-callable functions will be applicable/supported. +We thus categorize the functions below into five groups: + +A. functions that apply for all time-stepping modules, + +B. functions that apply for time-stepping modules that allow temporal adaptivity, + +C. functions that apply for time-stepping modules that utilize implicit solvers (nonlinear or linear), + +D. functions that apply for time-stepping modules that support non-identity mass matrices, and + +E. functions that apply for time-stepping modules that support relaxation Runge--Kutta methods. + +In the function descriptions below, we identify those that have any of the restrictions B-E above. +Then in the introduction for each of the stepper-specific documentation sections +(:numref:`ARKODE.Usage.ARKStep.UserCallable`, :numref:`ARKODE.Usage.ERKStep.UserCallable`, +:numref:`ARKODE.Usage.MRIStep.UserCallable`, and :numref:`ARKODE.Usage.SPRKStep.UserCallable`) +we clarify the categories of these functions that are supported. + + + +.. _ARKODE.Usage.Tolerances: + +ARKODE tolerance specification functions +------------------------------------------------------ + +These functions specify the integration tolerances. One of them +**should** be called before the first call to +:c:func:`ARKodeEvolve`; otherwise default values of ``reltol = +1e-4`` and ``abstol = 1e-9`` will be used, which may be entirely +incorrect for a specific problem. + +The integration tolerances ``reltol`` and ``abstol`` define a vector +of error weights, ``ewt``. In the case of +:c:func:`ARKodeSStolerances`, this vector has components + +.. code-block:: c + + ewt[i] = 1.0/(reltol*abs(y[i]) + abstol); + +whereas in the case of :c:func:`ARKodeSVtolerances` the vector components +are given by + +.. code-block:: c + + ewt[i] = 1.0/(reltol*abs(y[i]) + abstol[i]); + +This vector is used in all error and convergence tests, which use a +weighted RMS norm on all error-like vectors :math:`v`: + +.. math:: + \|v\|_{WRMS} = \left( \frac{1}{N} \sum_{i=1}^N (v_i\; ewt_i)^2 \right)^{1/2}, + +where :math:`N` is the problem dimension. + +Alternatively, the user may supply a custom function to supply the +``ewt`` vector, through a call to :c:func:`ARKodeWFtolerances`. + + + +.. c:function:: int ARKodeSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) + + This function specifies scalar relative and absolute tolerances. + + :param arkode_mem: pointer to the ARKODE memory block. + :param reltol: scalar relative tolerance. + :param abstol: scalar absolute tolerance. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + :retval ARK_ILL_INPUT: an argument had an illegal value (e.g. a negative tolerance). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) + + This function specifies a scalar relative tolerance and a vector + absolute tolerance (a potentially different absolute tolerance for + each vector component). + + :param arkode_mem: pointer to the ARKODE memory block. + :param reltol: scalar relative tolerance. + :param abstol: vector containing the absolute tolerances for each + solution component. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + :retval ARK_ILL_INPUT: an argument had an illegal value (e.g. a negative tolerance). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeWFtolerances(void* arkode_mem, ARKEwtFn efun) + + This function specifies a user-supplied function *efun* to compute + the error weight vector ``ewt``. + + :param arkode_mem: pointer to the ARKODE memory block. + :param efun: the name of the function (of type :c:func:`ARKEwtFn`) + that implements the error weight vector computation. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + + .. versionadded:: x.y.z + + +Moreover, for problems involving a non-identity mass matrix +:math:`M \ne I`, the units of the solution vector :math:`y` may differ +from the units of the IVP, posed for the vector :math:`My`. When this +occurs, iterative solvers for the Newton linear systems and the mass +matrix linear systems may require a different set of tolerances. +Since the relative tolerance is dimensionless, but the absolute +tolerance encodes a measure of what is "small" in the units of the +respective quantity, a user may optionally define absolute tolerances +in the equation units. In this case, ARKODE defines a vector of residual +weights, ``rwt`` for measuring convergence of these iterative solvers. +In the case of :c:func:`ARKodeResStolerance`, this vector has components + +.. code-block:: c + + rwt[i] = 1.0/(reltol*abs(My[i]) + rabstol); + +whereas in the case of :c:func:`ARKodeResVtolerance` the vector components +are given by + +.. code-block:: c + + rwt[i] = 1.0/(reltol*abs(My[i]) + rabstol[i]); + +This residual weight vector is used in all iterative solver +convergence tests, which similarly use a weighted RMS norm on all +residual-like vectors :math:`v`: + +.. math:: + \|v\|_{WRMS} = \left( \frac{1}{N} \sum_{i=1}^N (v_i\; rwt_i)^2 \right)^{1/2}, + +where :math:`N` is the problem dimension. + +As with the error weight vector, the user may supply a custom function +to supply the ``rwt`` vector, through a call to +:c:func:`ARKodeResFtolerance`. Further information on all three of +these functions is provided below. + + + +.. c:function:: int ARKodeResStolerance(void* arkode_mem, sunrealtype rabstol) + + This function specifies a scalar absolute residual tolerance. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rabstol: scalar absolute residual tolerance. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + :retval ARK_ILL_INPUT: an argument had an illegal value (e.g. a negative tolerance). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeResVtolerance(void* arkode_mem, N_Vector rabstol) + + This function specifies a vector of absolute residual tolerances. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rabstol: vector containing the absolute residual + tolerances for each solution component. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + :retval ARK_ILL_INPUT: an argument had an illegal value (e.g. a negative tolerance). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeResFtolerance(void* arkode_mem, ARKRwtFn rfun) + + This function specifies a user-supplied function *rfun* to compute + the residual weight vector ``rwt``. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rfun: the name of the function (of type :c:func:`ARKRwtFn`) + that implements the residual weight vector computation. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + + .. versionadded:: x.y.z + + +General advice on the choice of tolerances +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For many users, the appropriate choices for tolerance values in +``reltol``, ``abstol``, and ``rabstol`` are a concern. The following pieces +of advice are relevant. + +(1) The scalar relative tolerance ``reltol`` is to be set to control + relative errors. So a value of :math:`10^{-4}` means that errors + are controlled to .01%. We do not recommend using ``reltol`` larger + than :math:`10^{-3}`. On the other hand, ``reltol`` should not be so + small that it is comparable to the unit roundoff of the machine + arithmetic (generally around :math:`10^{-15}` for double-precision). + +(2) The absolute tolerances ``abstol`` (whether scalar or vector) need + to be set to control absolute errors when any components of the + solution vector :math:`y` may be so small that pure relative error + control is meaningless. For example, if :math:`y_i` starts at some + nonzero value, but in time decays to zero, then pure relative + error control on :math:`y_i` makes no sense (and is overly costly) + after :math:`y_i` is below some noise level. Then ``abstol`` (if + scalar) or ``abstol[i]`` (if a vector) needs to be set to that + noise level. If the different components have different noise + levels, then ``abstol`` should be a vector. For example, see the + example problem ``ark_robertson.c``, and the discussion + of it in the ARKODE Examples Documentation :cite:p:`arkode_ex`. In that + problem, the three components vary between 0 and 1, and have + different noise levels; hence the ``atols`` vector therein. It is + impossible to give any general advice on ``abstol`` values, + because the appropriate noise levels are completely + problem-dependent. The user or modeler hopefully has some idea as + to what those noise levels are. + +(3) The residual absolute tolerances ``rabstol`` (whether scalar or + vector) follow a similar explanation as for ``abstol``, except + that these should be set to the noise level of the equation + components, i.e. the noise level of :math:`My`. For problems in + which :math:`M=I`, it is recommended that ``rabstol`` be left + unset, which will default to the already-supplied ``abstol`` + values. + +(4) Finally, it is important to pick all the tolerance values + conservatively, because they control the error committed on each + individual step. The final (global) errors are an accumulation of + those per-step errors, where that accumulation factor is + problem-dependent. A general rule of thumb is to reduce the + tolerances by a factor of 10 from the actual desired limits on + errors. So if you want .01% relative accuracy (globally), a good + choice for ``reltol`` is :math:`10^{-5}`. In any case, it is + a good idea to do a few experiments with the tolerances to see how + the computed solution values vary as tolerances are reduced. + + + +Advice on controlling nonphysical negative values +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In many applications, some components in the true solution are always +positive or non-negative, though at times very small. In the +numerical solution, however, small negative (nonphysical) values +can then occur. In most cases, these values are harmless, and simply +need to be controlled, not eliminated, but in other cases any value +that violates a constraint may cause a simulation to halt. For both of +these scenarios the following pieces of advice are relevant. + +(1) The best way to control the size of unwanted negative computed + values is with tighter absolute tolerances. Again this requires + some knowledge of the noise level of these components, which may + or may not be different for different components. Some + experimentation may be needed. + +(2) If output plots or tables are being generated, and it is important + to avoid having negative numbers appear there (for the sake of + avoiding a long explanation of them, if nothing else), then + eliminate them, but only in the context of the output medium. Then + the internal values carried by the solver are unaffected. Remember + that a small negative value in :math:`y` returned by ARKODE, with + magnitude comparable to ``abstol`` or less, is equivalent to zero + as far as the computation is concerned. + +(3) The user's right-hand side routines :math:`f^E` and :math:`f^I` + should never change a negative value in the solution vector :math:`y` + to a non-negative value in attempt to "fix" this problem, + since this can lead to numerical instability. If the :math:`f^E` + or :math:`f^I` routines cannot tolerate a zero or negative value + (e.g. because there is a square root or log), then the offending + value should be changed to zero or a tiny positive number in a + temporary variable (not in the input :math:`y` vector) for the + purposes of computing :math:`f^E(t, y)` or :math:`f^I(t, y)`. + +(4) Some of ARKODE's time stepping modules support component-wise + constraints on solution components, :math:`y_i < 0`, + :math:`y_i \le 0`, :math:`y_i > 0`, or :math:`y_i \ge 0`, through + the user-callable function :c:func:`ARKodeSetConstraints`. At each + internal time step, if any constraint is violated then ARKODE will + attempt a smaller time step that should not violate this constraint. + This reduced step size is chosen such that the step size is the + largest possible but where the solution component satisfies the + constraint. + +(5) For time-stepping modules that support temporal adaptivity, + positivity and non-negativity constraints on components can also be + enforced by use of the recoverable error return feature in the + user-supplied right-hand side function(s). When a recoverable error + is encountered, ARKODE will retry the step with a smaller step size, + which typically alleviates the problem. However, since this reduced + step size is chosen without knowledge of the solution constraint, it + may be overly conservative. Thus this option involves some additional + overhead cost, and should only be exercised if the above recommendations + are unsuccessful. + + + +.. _ARKODE.Usage.LinearSolvers: + +Linear solver interface functions +------------------------------------------- + +As previously explained, the Newton iterations used in solving +implicit systems within ARKODE require the solution of linear +systems of the form + +.. math:: + \mathcal{A}\left(z_i^{(m)}\right) \delta^{(m+1)} = -G\left(z_i^{(m)}\right) + +where + +.. math:: + \mathcal{A} \approx M - \gamma J, \qquad J = \frac{\partial f^I}{\partial y}. + +ARKODE's ARKLS linear solver interface supports all valid +``SUNLinearSolver`` modules for this task. + +Matrix-based ``SUNLinearSolver`` modules utilize ``SUNMatrix`` objects +to store the approximate Jacobian matrix :math:`J`, the Newton matrix +:math:`\mathcal{A}`, the mass matrix :math:`M`, and, when using direct +solvers, the factorizations used throughout the solution process. + +Matrix-free ``SUNLinearSolver`` modules instead use iterative methods +to solve the Newton systems of equations, and only require the +*action* of the matrix on a vector, :math:`\mathcal{A}v`. With most +of these methods, preconditioning can be done on the left only, on the +right only, on both the left and the right, or not at all. The +exceptions to this rule are SPFGMR that supports right preconditioning +only and PCG that performs symmetric preconditioning. For the +specification of a preconditioner, see the iterative linear solver +portions of :numref:`ARKODE.Usage.OptionalInputs` and +:numref:`ARKODE.Usage.UserSupplied`. + +If preconditioning is done, user-supplied functions should be used to +define left and right preconditioner matrices :math:`P_1` and +:math:`P_2` (either of which could be the identity matrix), such that +the product :math:`P_{1}P_{2}` approximates the Newton matrix +:math:`\mathcal{A} = M - \gamma J`. + +To specify a generic linear solver for ARKODE to use for the Newton +systems, after the call to ``*StepCreate`` but before any +calls to :c:func:`ARKodeEvolve`, the user's program must create the +appropriate ``SUNLinearSolver`` object and call the function +:c:func:`ARKodeSetLinearSolver`, as documented below. To create +the ``SUNLinearSolver`` object, the user may call one of the +SUNDIALS-packaged SUNLinSol module constructor routines via a call of +the form + +.. code:: c + + SUNLinearSolver LS = SUNLinSol_*(...); + +The current list of SUNDIALS-packaged SUNLinSol modules, and their +constructor routines, may be found in chapter :numref:`SUNLinSol`. +Alternately, a user-supplied ``SUNLinearSolver`` module may be created +and used. Specific information on how to create such user-provided +modules may be found in :numref:`SUNLinSol.API.Custom`. + +Once this solver object has been constructed, the user should attach +it to ARKODE via a call to :c:func:`ARKodeSetLinearSolver`. The +first argument passed to this function is the ARKODE memory pointer +returned by ``*StepCreate``; the second argument is the +``SUNLinearSolver`` object created above. The third argument is an +optional ``SUNMatrix`` object to accompany matrix-based +``SUNLinearSolver`` inputs (for matrix-free linear solvers, the third +argument should be ``NULL``). A call to this function initializes the +ARKLS linear solver interface, linking it to the ARKODE integrator, +and allows the user to specify additional parameters and routines +pertinent to their choice of linear solver. + +.. c:function:: int ARKodeSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix J) + + This function specifies the ``SUNLinearSolver`` object that ARKODE + should use, as well as a template Jacobian ``SUNMatrix`` object (if + applicable). + + :param arkode_mem: pointer to the ARKODE memory block. + :param LS: the ``SUNLinearSolver`` object to use. + :param J: the template Jacobian ``SUNMatrix`` object to use (or + ``NULL`` if not applicable). + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_MEM_FAIL: there was a memory allocation failure. + :retval ARKLS_ILL_INPUT: ARKLS is incompatible with the + provided *LS* or *J* input objects, or the current + ``N_Vector`` module. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + If *LS* is a matrix-free linear solver, then the *J* + argument should be ``NULL``. + + If *LS* is a matrix-based linear solver, then the template Jacobian + matrix *J* will be used in the solve process, so if additional + storage is required within the ``SUNMatrix`` object (e.g. for + factorization of a banded matrix), ensure that the input object is + allocated with sufficient size (see the documentation of + the particular SUNMATRIX type in the :numref:`SUNMatrix` for + further information). + + When using sparse linear solvers, it is typically much more + efficient to supply *J* so that it includes the full sparsity + pattern of the Newton system matrices :math:`\mathcal{A} = + M-\gamma J`, even if *J* itself has zeros in nonzero + locations of :math:`M`. The reasoning for this is + that :math:`\mathcal{A}` is constructed in-place, on top of the + user-specified values of *J*, so if the sparsity pattern in *J* is + insufficient to store :math:`\mathcal{A}` then it will need to be + resized internally by ARKODE. + + .. versionadded:: x.y.z + + + + + +.. _ARKODE.Usage.MassMatrixSolvers: + +Mass matrix solver specification functions +------------------------------------------- + +As discussed in :numref:`ARKODE.Mathematics.MassSolve`, if the ODE +system involves a non-identity mass matrix :math:`M\ne I`, then ARKODE +must solve linear systems of the form + +.. math:: + M x = b. + +ARKODE's ARKLS mass-matrix linear solver interface supports all valid +``SUNLinearSolver`` modules for this task. For iterative linear +solvers, user-supplied preconditioning can be applied. For the +specification of a preconditioner, see the iterative linear solver +portions of :numref:`ARKODE.Usage.OptionalInputs` and +:numref:`ARKODE.Usage.UserSupplied`. If preconditioning is to be +performed, user-supplied functions should be used to define left and +right preconditioner matrices :math:`P_1` and :math:`P_2` (either of +which could be the identity matrix), such that the product +:math:`P_{1}P_{2}` approximates the mass matrix :math:`M`. + +To specify a generic linear solver for ARKODE to use for mass matrix +systems, after the call to ``*StepCreate`` but before any +calls to :c:func:`ARKodeEvolve`, the user's program must create the +appropriate ``SUNLinearSolver`` object and call the function +:c:func:`ARKodeSetMassLinearSolver`, as documented below. The +first argument passed to this function is the ARKODE memory +pointer returned by ``*StepCreate``; the second argument is +the desired ``SUNLinearSolver`` object to use for solving mass matrix +systems. The third object is a template ``SUNMatrix`` to use with the +provided ``SUNLinearSolver`` (if applicable). The fourth input is a +flag to indicate whether the mass matrix is time-dependent, +i.e. :math:`M = M(t)`, or not. A call to this function initializes the +ARKLS mass matrix linear solver interface, linking this to the main +ARKODE integrator, and allows the user to specify additional +parameters and routines pertinent to their choice of linear solver. + +Note: if the user program includes linear solvers for *both* the +Newton and mass matrix systems, these must have the same type: + +* If both are matrix-based, then they must utilize the same + ``SUNMatrix`` type, since these will be added when forming the + Newton system matrix :math:`\mathcal{A}`. In this case, both the + Newton and mass matrix linear solver interfaces can use the same + ``SUNLinearSolver`` object, although different solver objects + (e.g. with different solver parameters) are also allowed. + +* If both are matrix-free, then the Newton and mass matrix + ``SUNLinearSolver`` objects must be different. These may even use + different solver algorithms (SPGMR, SPBCGS, etc.), if desired. + For example, if the mass matrix is symmetric but the Jacobian is not, + then PCG may be used for the mass matrix systems and SPGMR for the + Newton systems. + + +.. c:function:: int ARKodeSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, sunbooleantype time_dep) + + This function specifies the ``SUNLinearSolver`` object + that ARKODE should use for mass matrix systems, as well as a + template ``SUNMatrix`` object. + + :param arkode_mem: pointer to the ARKODE memory block. + :param LS: the ``SUNLinearSolver`` object to use. + :param M: the template mass ``SUNMatrix`` object to use. + :param time_dep: flag denoting whether the mass matrix depends on + the independent variable (:math:`M = M(t)`) or not (:math:`M + \ne M(t)`). ``SUNTRUE`` indicates time-dependence of the + mass matrix. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_MEM_FAIL: there was a memory allocation failure. + :retval ARKLS_ILL_INPUT: ARKLS is incompatible with the + provided *LS* or *M* input objects, or the current + ``N_Vector`` module. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + If *LS* is a matrix-free linear solver, then the *M* + argument should be ``NULL``. + + If *LS* is a matrix-based linear solver, then the template mass + matrix *M* will be used in the solve process, so if additional + storage is required within the ``SUNMatrix`` object (e.g. for + factorization of a banded matrix), ensure that the input object is + allocated with sufficient size. + + If called with *time_dep* set to ``SUNFALSE``, then the mass matrix is + only computed and factored once (or when either ``*StepReInit`` + or :c:func:`ARKodeResize` are called), with the results reused + throughout the entire ARKODE simulation. + + Unlike the system Jacobian, the system mass matrix is not approximated + using finite-differences of any functions provided to ARKODE. Hence, + use of the a matrix-based *LS* requires the user to provide a + mass-matrix constructor routine (see :c:type:`ARKLsMassFn` and + :c:func:`ARKodeSetMassFn`). + + Similarly, the system mass matrix-vector-product is not approximated + using finite-differences of any functions provided to ARKODE. Hence, + use of a matrix-free *LS* requires the user to provide a + mass-matrix-times-vector product routine (see + :c:type:`ARKLsMassTimesVecFn` and :c:func:`ARKodeSetMassTimes`). + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.NonlinearSolvers: + +Nonlinear solver interface functions +------------------------------------------- + +When changing the nonlinear solver in ARKODE, after the +call to ``*StepCreate`` but before any calls to +:c:func:`ARKodeEvolve`, the user's program must create the +appropriate ``SUNNonlinearSolver`` object and call +:c:func:`ARKodeSetNonlinearSolver`, as documented below. If any +calls to :c:func:`ARKodeEvolve` have been made, then ARKODE will +need to be reinitialized by calling ``*StepReInit`` to +ensure that the nonlinear solver is initialized correctly before any +subsequent calls to :c:func:`ARKodeEvolve`. + +The first argument passed to the routine +:c:func:`ARKodeSetNonlinearSolver` is the ARKODE memory pointer +returned by ``*StepCreate``; the second argument passed +to this function is the desired ``SUNNonlinearSolver`` object to use for +solving the nonlinear system for each implicit stage. A call to this +function attaches the nonlinear solver to the main ARKODE integrator. + + +.. c:function:: int ARKodeSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) + + This function specifies the ``SUNNonlinearSolver`` object + that ARKODE should use for implicit stage solves. + + :param arkode_mem: pointer to the ARKODE memory block. + :param NLS: the ``SUNNonlinearSolver`` object to use. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: there was a memory allocation failure. + :retval ARK_ILL_INPUT: ARKODE is incompatible with the + provided *NLS* input object. + :retval ARK_STEPPER_UNSUPPORTED: nonlinear solvers are not supported by + the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + ARKODE will use the Newton ``SUNNonlinearSolver`` module by + default; a call to this routine replaces that module with the + supplied *NLS* object. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.RootFinding: + +Rootfinding initialization function +-------------------------------------- + +As described in :numref:`ARKODE.Mathematics.Rootfinding`, while +solving the IVP, ARKODE's time-stepping modules have the capability to +find the roots of a set of user-defined functions. To activate the +root-finding algorithm, call the following function. This is normally +called only once, prior to the first call to +:c:func:`ARKodeEvolve`, but if the rootfinding problem is to be +changed during the solution, :c:func:`ARKodeRootInit` can also be +called prior to a continuation call to :c:func:`ARKodeEvolve`. + +.. note:: + + The solution is interpolated to the times at which roots are found. + + +.. c:function:: int ARKodeRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) + + Initializes a rootfinding problem to be solved during the + integration of the ODE system. It must be called after + ``*StepCreate``, and before :c:func:`ARKodeEvolve`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nrtfn: number of functions :math:`g_i`, an integer :math:`\ge` 0. + :param g: name of user-supplied function, of type :c:func:`ARKRootFn`, + defining the functions :math:`g_i` whose roots are sought. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: there was a memory allocation failure. + :retval ARK_ILL_INPUT: *nrtfn* is greater than zero but *g* is ``NULL``. + + .. note:: + + To disable the rootfinding feature after it has already + been initialized, or to free memory associated with ARKODE's + rootfinding module, call *ARKodeRootInit* with *nrtfn = 0*. + + Similarly, if a new IVP is to be solved with a call to + ``*StepReInit``, where the new IVP has no rootfinding + problem but the prior one did, then call *ARKodeRootInit* with + *nrtfn = 0*. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.Integration: + +ARKODE solver function +------------------------- + +This is the central step in the solution process -- the call to perform +the integration of the IVP. The input argument *itask* specifies one of two +modes as to where ARKODE is to return a solution. These modes are modified if +the user has set a stop time (with a call to the optional input function +:c:func:`ARKodeSetStopTime`) or has requested rootfinding. + + +.. c:function:: int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, sunrealtype *tret, int itask) + + Integrates the ODE over an interval in :math:`t`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param tout: the next time at which a computed solution is desired. + :param yout: the computed solution vector. + :param tret: the time corresponding to *yout* (output). + :param itask: a flag indicating the job of the solver for the next + user step. + + The *ARK_NORMAL* option causes the solver to take internal + steps until it has just overtaken a user-specified output + time, *tout*, in the direction of integration, + i.e. :math:`t_{n-1} <` *tout* :math:`\le t_{n}` for forward + integration, or :math:`t_{n} \le` *tout* :math:`< t_{n-1}` for + backward integration. It will then compute an approximation + to the solution :math:`y(tout)` by interpolation (as described + in :numref:`ARKODE.Mathematics.Interpolation`). + + The *ARK_ONE_STEP* option tells the solver to only take a + single internal step, :math:`y_{n-1} \to y_{n}`, and return the solution + at that point, :math:`y_{n}`, in the vector *yout*. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_ROOT_RETURN: :c:func:`ARKodeEvolve` succeeded, and + found one or more roots. If the number of root functions, + *nrtfn*, is greater than 1, call + :c:func:`ARKodeGetRootInfo` to see which :math:`g_i` were + found to have a root at (*\*tret*). + :retval ARK_TSTOP_RETURN: :c:func:`ARKodeEvolve` succeeded and + returned at *tstop*. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + :retval ARK_ILL_INPUT: one of the inputs to :c:func:`ARKodeEvolve` + is illegal, or some other input to the solver was + either illegal or missing. Details will be + provided in the error message. Typical causes of + this failure: + + (a) A component of the error weight vector became + zero during internal time-stepping. + + (b) The linear solver initialization function (called + by the user after calling ``*StepCreate``) failed + to set the linear solver-specific *lsolve* field in + ``arkode_mem``. + + (c) A root of one of the root functions was found both at a + point :math:`t` and also very near :math:`t`. + + (d) The initial condition violates the inequality constraints. + + :retval ARK_TOO_MUCH_WORK: the solver took *mxstep* internal steps + but could not reach *tout*. The default value for + *mxstep* is *MXSTEP_DEFAULT = 500*. + :retval ARK_TOO_MUCH_ACC: the solver could not satisfy the accuracy + demanded by the user for some internal step. + :retval ARK_ERR_FAILURE: error test failures occurred either too many + times (*ark_maxnef*) during one internal time step + or occurred with :math:`|h| = h_{min}`. + :retval ARK_CONV_FAILURE: either convergence test failures occurred too many + times (*ark_maxncf*) during one internal time step + or occurred with :math:`|h| = h_{min}`. + :retval ARK_LINIT_FAIL: the linear solver's initialization function failed. + :retval ARK_LSETUP_FAIL: the linear solver's setup routine failed in + an unrecoverable manner. + :retval ARK_LSOLVE_FAIL: the linear solver's solve routine failed in + an unrecoverable manner. + :retval ARK_MASSINIT_FAIL: the mass matrix solver's + initialization function failed. + :retval ARK_MASSSETUP_FAIL: the mass matrix solver's setup routine failed. + :retval ARK_MASSSOLVE_FAIL: the mass matrix solver's solve routine failed. + :retval ARK_VECTOROP_ERR: a vector operation error occurred. + + .. note:: + + The input vector *yout* can use the same memory as the + vector *y0* of initial conditions that was passed to + ``*StepCreate``. + + In *ARK_ONE_STEP* mode, *tout* is used only on the first call, and + only to get the direction and a rough scale of the independent + variable. + + All failure return values are negative and so testing the return argument + for negative values will trap all :c:func:`ARKodeEvolve` failures. + + Since interpolation may reduce the accuracy in the reported + solution, if full method accuracy is desired the user should issue + a call to :c:func:`ARKodeSetStopTime` before the call to + :c:func:`ARKodeEvolve` to specify a fixed stop time to + end the time step and return to the user. Upon return from + :c:func:`ARKodeEvolve`, a copy of the internal solution + :math:`y_{n}` will be returned in the vector *yout*. Once the + integrator returns at a *tstop* time, any future testing for + *tstop* is disabled (and can be re-enabled only though a new call + to :c:func:`ARKodeSetStopTime`). + + On any error return in which one or more internal steps were taken + by :c:func:`ARKodeEvolve`, the returned values of *tret* and + *yout* correspond to the farthest point reached in the integration. + On all other error returns, *tret* and *yout* are left unchanged + from those provided to the routine. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.OptionalInputs: + +Optional input functions +------------------------- + +There are numerous optional input parameters that control the behavior +of ARKODE, each of which may be modified from its default value through +calling an appropriate input function. The following tables list all +optional input functions, grouped by which aspect of ARKODE they control. +Detailed information on the calling syntax and arguments for each +function are then provided following each table. + +The optional inputs are grouped into the following categories: + +* General ARKODE options (:ref:`ARKODE.Usage.ARKodeInputTable`), +* Step adaptivity solver options (:ref:`ARKODE.Usage.ARKodeAdaptivityInputTable`), +* Implicit stage solver options (:ref:`ARKODE.Usage.ARKodeSolverInputTable`), +* Linear solver interface options (:ref:`ARKODE.Usage.ARKLsInputs`), and +* Rootfinding options (:ref:`ARKODE.Usage.ARKodeRootfindingInputTable`). + +For the most casual use of ARKODE, relying on the default set of +solver parameters, the reader can skip to section on user-supplied +functions, :numref:`ARKODE.Usage.UserSupplied`. + +We note that, on an error return, all of the optional input functions send an +error message to the error handler function. All error return values are +negative, so a test on the return arguments for negative values will catch all +errors. Finally, a call to an ``ARKodeSet***`` function can generally be made +from the user's calling program at any time *after* creation of the ARKODE +solver via ``*StepCreate``, and, the function exited successfully, takes effect immediately. +``ARKodeSet***`` functions that cannot be called at any time note +this in the "notes" section of the function documentation. + + + +.. _ARKODE.Usage.ARKodeInputTable: + +Optional inputs for ARKODE +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. cssclass:: table-bordered + +================================================ ======================================= ======================= +Optional input Function name Default +================================================ ======================================= ======================= +Return ARKODE parameters to their defaults :c:func:`ARKodeSetDefaults` internal +Set integrator method order :c:func:`ARKodeSetOrder` 4 +Set dense output interpolation type (SPRKStep) :c:func:`ARKodeSetInterpolantType` ``ARK_INTERP_LAGRANGE`` +Set dense output interpolation type (others) :c:func:`ARKodeSetInterpolantType` ``ARK_INTERP_HERMITE`` +Set dense output polynomial degree :c:func:`ARKodeSetInterpolantDegree` 5 +Supply a pointer to a diagnostics output file :c:func:`ARKodeSetDiagnostics` ``NULL`` +Disable time step adaptivity (fixed-step mode) :c:func:`ARKodeSetFixedStep` disabled +Supply an initial step size to attempt :c:func:`ARKodeSetInitStep` estimated +Maximum no. of warnings for :math:`t_n+h = t_n` :c:func:`ARKodeSetMaxHnilWarns` 10 +Maximum no. of internal steps before *tout* :c:func:`ARKodeSetMaxNumSteps` 500 +Maximum absolute step size :c:func:`ARKodeSetMaxStep` :math:`\infty` +Minimum absolute step size :c:func:`ARKodeSetMinStep` 0.0 +Set a value for :math:`t_{stop}` :c:func:`ARKodeSetStopTime` undefined +Interpolate at :math:`t_{stop}` :c:func:`ARKodeSetInterpolateStopTime` ``SUNFALSE`` +Disable the stop time :c:func:`ARKodeClearStopTime` N/A +Supply a pointer for user data :c:func:`ARKodeSetUserData` ``NULL`` +Maximum no. of ARKODE error test failures :c:func:`ARKodeSetMaxErrTestFails` 7 +Set inequality constraints on solution :c:func:`ARKodeSetConstraints` ``NULL`` +Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstrFails` 10 +================================================ ======================================= ======================= + + + + +.. c:function:: int ARKodeSetDefaults(void* arkode_mem) + + Resets all optional input parameters to ARKODE's original + default values. + + :param arkode_mem: pointer to the ARKODE memory block. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + Does not change the *user_data* pointer or any + parameters within the specified time-stepping module. + + Also leaves alone any data structures or options related to + root-finding (those can be reset using :c:func:`ARKodeRootInit`). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetOrder(void* arkode_mem, int ord) + + Specifies the order of accuracy for the IVP integration method. + + :param arkode_mem: pointer to the ARKODE memory block. + :param ord: requested order of accuracy. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: this option is not supported by the time-stepping module. + + .. note:: + + For explicit methods, the allowed values are :math:`2 \le` + *ord* :math:`\le 8`. For implicit methods, the allowed values are + :math:`2\le` *ord* :math:`\le 5`, and for ImEx methods the allowed + values are :math:`2 \le` *ord* :math:`\le 5`. Any illegal input + will result in the default value of 4. + + Since *ord* affects the memory requirements for the internal + ARKODE memory block, it cannot be changed after the first call to + :c:func:`ARKodeEvolve`, unless ``*StepReInit`` is called. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetInterpolantType(void* arkode_mem, int itype) + + Specifies use of the Lagrange or Hermite interpolation modules (used for + dense output -- interpolation of solution output values and implicit + method predictors). + + :param arkode_mem: pointer to the ARKODE memory block. + :param itype: requested interpolant type (``ARK_INTERP_HERMITE`` or ``ARK_INTERP_LAGRANGE``). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: the interpolation module could not be allocated. + :retval ARK_ILL_INPUT: the *itype* argument is not recognized or the + interpolation module has already been initialized. + + .. note:: + + The Hermite interpolation module is described in + :numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange interpolation module + is described in :numref:`ARKODE.Mathematics.Interpolation.Lagrange`. + + This routine frees any previously-allocated interpolation module, and re-creates + one according to the specified argument. Thus any previous calls to + :c:func:`ARKodeSetInterpolantDegree` will be nullified. + + After the first call to :c:func:`ARKodeEvolve` the interpolation type may + not be changed without first calling ``*StepReInit``. + + If this routine is not called, the Hermite interpolation module will be used. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetInterpolantDegree(void* arkode_mem, int degree) + + Specifies the degree of the polynomial interpolant + used for dense output (i.e. interpolation of solution output values + and implicit method predictors). + + :param arkode_mem: pointer to the ARKODE memory block. + :param degree: requested polynomial degree. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` or the interpolation module are ``NULL``. + :retval ARK_INTERP_FAIL: this was called after :c:func:`ARKodeEvolve`. + :retval ARK_ILL_INPUT: an argument had an illegal value or the + interpolation module has already been initialized. + + .. note:: + + Allowed values are between 0 and 5. + + This routine should be called *before* :c:func:`ARKodeEvolve`. After the + first call to :c:func:`ARKodeEvolve` the interpolation degree may not be + changed without first calling ``*StepReInit``. + + If a user calls both this routine and :c:func:`ARKodeSetInterpolantType`, then + :c:func:`ARKodeSetInterpolantType` must be called first. + + Since the accuracy of any polynomial interpolant is limited by the + accuracy of the time-step solutions on which it is based, the *actual* + polynomial degree that is used by ARKODE will be the minimum of + :math:`q-1` and the input *degree*, for :math:`q > 1` where :math:`q` is + the order of accuracy for the time integration method. + + When :math:`q=1`, a linear interpolant is the default to ensure values + obtained by the integrator are returned at the ends of the time + interval. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetFixedStep(void* arkode_mem, sunrealtype hfixed) + + Disables time step adaptivity within ARKODE, and specifies the + fixed time step size to use for the following internal step(s). + + :param arkode_mem: pointer to the ARKODE memory block. + :param hfixed: value of the fixed step size to use. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + Pass 0.0 to return ARKODE to the default (adaptive-step) mode -- this is only + allowed when using a time-stepping module that supports temporal adaptivity. + + Use of this function is not generally recommended, since it gives no + assurance of the validity of the computed solutions. It is + primarily provided for code-to-code verification testing purposes. + + When using :c:func:`ARKodeSetFixedStep`, any values provided to + the functions + :c:func:`ARKodeSetInitStep`, + :c:func:`ARKodeSetMaxErrTestFails`, + :c:func:`ARKodeSetCFLFraction`, + :c:func:`ARKodeSetErrorBias`, + :c:func:`ARKodeSetFixedStepBounds`, + :c:func:`ARKodeSetMaxCFailGrowth`, + :c:func:`ARKodeSetMaxEFailGrowth`, + :c:func:`ARKodeSetMaxFirstGrowth`, + :c:func:`ARKodeSetMaxGrowth`, + :c:func:`ARKodeSetMinReduction`, + :c:func:`ARKodeSetSafetyFactor`, + :c:func:`ARKodeSetSmallNumEFails`, + :c:func:`ARKodeSetStabilityFn`, and + :c:func:`ARKodeSetAdaptController` + will be ignored, since temporal adaptivity is disabled. + + If both :c:func:`ARKodeSetFixedStep` and + :c:func:`ARKodeSetStopTime` are used, then the fixed step size + will be used for all steps until the final step preceding the + provided stop time (which may be shorter). To resume use of the + previous fixed step size, another call to + :c:func:`ARKodeSetFixedStep` must be made prior to calling + :c:func:`ARKodeEvolve` to resume integration. + + It is *not* recommended that :c:func:`ARKodeSetFixedStep` be used + in concert with :c:func:`ARKodeSetMaxStep` or + :c:func:`ARKodeSetMinStep`, since at best those latter two + routines will provide no useful information to the solver, and at + worst they may interfere with the desired fixed step size. + + .. versionadded:: x.y.z + + + +.. c:function:: int ARKodeSetInitStep(void* arkode_mem, sunrealtype hin) + + Specifies the initial time step size ARKODE should use after + initialization, re-initialization, or resetting. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hin: value of the initial step to be attempted :math:`(\ne 0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + Pass 0.0 to use the default value -- this is only + allowed when using a time-stepping module that supports temporal adaptivity. + + By default, ARKODE estimates the initial step size to be + :math:`h = \sqrt{\dfrac{2}{\left\| \ddot{y}\right\|}}`, where + :math:`\ddot{y}` is estimate of the second derivative of the solution + at :math:`t_0`. + + This routine will also reset the step size and error history. + + .. versionadded:: x.y.z + + + +.. c:function:: int ARKodeSetMaxHnilWarns(void* arkode_mem, int mxhnil) + + Specifies the maximum number of messages issued by the + solver to warn that :math:`t+h=t` on the next internal step, before + ARKODE will instead return with an error. + + :param arkode_mem: pointer to the ARKODE memory block. + :param mxhnil: maximum allowed number of warning messages :math:`(>0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + The default value is 10; set *mxhnil* to zero to specify + this default. + + A negative value indicates that no warning messages should be issued. + + .. versionadded:: x.y.z + + + +.. c:function:: int ARKodeSetMaxNumSteps(void* arkode_mem, long int mxsteps) + + Specifies the maximum number of steps to be taken by the + solver in its attempt to reach the next output time, before ARKODE + will return with an error. + + :param arkode_mem: pointer to the ARKODE memory block. + :param mxsteps: maximum allowed number of internal steps. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + Passing *mxsteps* = 0 results in ARKODE using the + default value (500). + + Passing *mxsteps* < 0 disables the test (not recommended). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax) + + Specifies the upper bound on the magnitude of the time step size. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hmax: maximum absolute value of the time step size :math:`(\ge 0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Pass *hmax* :math:`\le 0.0` to set the default value of :math:`\infty`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin) + + Specifies the lower bound on the magnitude of the time step size. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hmin: minimum absolute value of the time step size :math:`(\ge 0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Pass *hmin* :math:`\le 0.0` to set the default value of 0. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetStopTime(void* arkode_mem, sunrealtype tstop) + + Specifies the value of the independent variable + :math:`t` past which the solution is not to proceed. + + :param arkode_mem: pointer to the ARKODE memory block. + :param tstop: stopping time for the integrator. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + The default is that no stop time is imposed. + + Once the integrator returns at a stop time, any future testing for + ``tstop`` is disabled (and can be reenabled only though a new call to + :c:func:`ARKodeSetStopTime`). + + A stop time not reached before a call to ``*StepReInit`` or + :c:func:`ARKodeReset` will remain active but can be disabled by calling + :c:func:`ARKodeClearStopTime`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) + + Specifies that the output solution should be interpolated when the current + :math:`t` equals the specified ``tstop`` (instead of merely copying the + internal solution :math:`y_n`). + + :param arkode_mem: pointer to the ARKODE memory block. + :param interp: flag indicating to use interpolation (1) or copy (0). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeClearStopTime(void* arkode_mem) + + Disables the stop time set with :c:func:`ARKodeSetStopTime`. + + :param arkode_mem: pointer to the ARKODE memory block. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + The stop time can be reenabled though a new call to + :c:func:`ARKodeSetStopTime`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetUserData(void* arkode_mem, void* user_data) + + Specifies the user data block *user_data* and + attaches it to the main ARKODE memory block. + + :param arkode_mem: pointer to the ARKODE memory block. + :param user_data: pointer to the user data. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + If specified, the pointer to *user_data* is passed to all + user-supplied functions for which it is an argument; otherwise + ``NULL`` is passed. + + If *user_data* is needed in user preconditioner functions, the call to + this function must be made *before* any calls to + :c:func:`ARKodeSetLinearSolver` and/or :c:func:`ARKodeSetMassLinearSolver`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxErrTestFails(void* arkode_mem, int maxnef) + + Specifies the maximum number of error test failures + permitted in attempting one step, before returning with an error. + + :param arkode_mem: pointer to the ARKODE memory block. + :param maxnef: maximum allowed number of error test failures :math:`(>0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + The default value is 7; set *maxnef* :math:`\le 0` + to specify this default. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetConstraints(void* arkode_mem, N_Vector constraints) + + Specifies a vector defining inequality constraints for each component of the + solution vector :math:`y`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param constraints: vector of constraint flags. Each component specifies + the type of solution constraint: + + .. math:: + + \texttt{constraints[i]} = \left\{ \begin{array}{rcl} + 0.0 &\Rightarrow\;& \text{no constraint is imposed on}\; y_i,\\ + 1.0 &\Rightarrow\;& y_i \geq 0,\\ + -1.0 &\Rightarrow\;& y_i \leq 0,\\ + 2.0 &\Rightarrow\;& y_i > 0,\\ + -2.0 &\Rightarrow\;& y_i < 0.\\ + \end{array}\right. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: the constraints vector contains illegal values. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + The presence of a non-``NULL`` constraints vector that is not 0.0 + in all components will cause constraint checking to be performed. However, a + call with 0.0 in all components of ``constraints`` will result in an illegal + input return. A ``NULL`` constraints vector will disable constraint checking. + + After a call to :c:func:`ARKodeResize` inequality constraint checking + will be disabled and a call to :c:func:`ARKodeSetConstraints` is + required to re-enable constraint checking. + + Since constraint-handling is performed through cutting time steps that would + violate the constraints, it is possible that this feature will cause some + problems to fail due to an inability to enforce constraints even at the + minimum time step size. Additionally, the features :c:func:`ARKodeSetConstraints` + and :c:func:`ARKodeSetFixedStep` are incompatible, and should not be used + simultaneously. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails) + + Specifies the maximum number of constraint failures in a step before ARKODE + will return with an error. + + :param arkode_mem: pointer to the ARKODE memory block. + :param maxfails: maximum allowed number of constrain failures. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Passing *maxfails* <= 0 results in ARKODE using the + default value (10). + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.ARKodeAdaptivityInputTable: + +Optional inputs for time step adaptivity +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The mathematical explanation of ARKODE's time step adaptivity +algorithm, including how each of the parameters below is used within +the code, is provided in :numref:`ARKODE.Mathematics.Adaptivity`. + + +.. cssclass:: table-bordered + +========================================================= ========================================== ======== +Optional input Function name Default +========================================================= ========================================== ======== +Provide a :c:type:`SUNAdaptController` for ARKODE to use :c:func:`ARKodeSetAdaptController` PID +Adjust the method order used in the controller :c:func:`ERKStepSetAdaptivityAdjustment` -1 +Explicit stability safety factor :c:func:`ARKodeSetCFLFraction` 0.5 +Time step error bias factor :c:func:`ARKodeSetErrorBias` 1.5 +Bounds determining no change in step size :c:func:`ARKodeSetFixedStepBounds` 1.0 1.5 +Maximum step growth factor on convergence fail :c:func:`ARKodeSetMaxCFailGrowth` 0.25 +Maximum step growth factor on error test fail :c:func:`ARKodeSetMaxEFailGrowth` 0.3 +Maximum first step growth factor :c:func:`ARKodeSetMaxFirstGrowth` 10000.0 +Maximum allowed general step growth factor :c:func:`ARKodeSetMaxGrowth` 20.0 +Minimum allowed step reduction factor on error test fail :c:func:`ARKodeSetMinReduction` 0.1 +Time step safety factor :c:func:`ARKodeSetSafetyFactor` 0.96 +Error fails before MaxEFailGrowth takes effect :c:func:`ARKodeSetSmallNumEFails` 2 +Explicit stability function :c:func:`ARKodeSetStabilityFn` none +Set accumulated error estimation type :c:func:`ARKodeSetAccumulatedErrorType` none +Reset accumulated error :c:func:`ARKodeResetAccumulatedError` +========================================================= ========================================== ======== + + + +.. c:function:: int ARKodeSetAdaptController(void* arkode_mem, SUNAdaptController C) + + Sets a user-supplied time-step controller object. + + :param arkode_mem: pointer to the ARKODE memory block. + :param C: user-supplied time adaptivity controller. If ``NULL`` then the PID controller + will be created (see :numref:`SUNAdaptController.Soderlind`). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: *C* was ``NULL`` and the PID controller could not be allocated. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetAdaptivityAdjustment(void* arkode_mem, int adjust) + + Called by a user to adjust the method order supplied to the temporal adaptivity + controller. For example, if the user expects order reduction due to problem stiffness, + they may request that the controller assume a reduced order of accuracy for the method + by specifying a value :math:`adjust < 0`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param adjust: adjustment factor (default is -1). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + This should be called prior to calling :c:func:`ARKodeEvolve`, and can only be + reset following a call to ``*StepReInit``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) + + Specifies the fraction of the estimated explicitly stable step to use. + + :param arkode_mem: pointer to the ARKODE memory block. + :param cfl_frac: maximum allowed fraction of explicitly stable step (default is 0.5). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any non-positive parameter will imply a reset to the default + value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetErrorBias(void* arkode_mem, sunrealtype bias) + + Specifies the bias to be applied to the error estimates within + accuracy-based adaptivity strategies. + + :param arkode_mem: pointer to the ARKODE memory block. + :param bias: bias applied to error in accuracy-based time + step estimation (default is 1.5). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value below 1.0 will imply a reset to the default value. + + If both this and one of :c:func:`ARKodeSetAdaptivityMethod` or + :c:func:`ARKodeSetAdaptController` will be called, then this routine must be called + *second*. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) + + Specifies the step growth interval in which the step size will remain unchanged. + + :param arkode_mem: pointer to the ARKODE memory block. + :param lb: lower bound on window to leave step size fixed (default is 1.0). + :param ub: upper bound on window to leave step size fixed (default is 1.5). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any interval *not* containing 1.0 will imply a reset to the default values. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) + + Specifies the maximum step size growth factor upon an algebraic + solver convergence failure on a stage solve within a step, :math:`\eta_{cf}` from + :numref:`ARKODE.Mathematics.Error.Nonlinear`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param etacf: time step reduction factor on a nonlinear solver + convergence failure (default is 0.25). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) + + Specifies the maximum step size growth factor upon multiple successive + accuracy-based error failures in the solver. + + :param arkode_mem: pointer to the ARKODE memory block. + :param etamxf: time step reduction factor on multiple error fails (default is 0.3). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value outside the interval :math:`(0,1]` will imply a reset to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) + + Specifies the maximum allowed growth factor in step size following the very + first integration step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param etamx1: maximum allowed growth factor after the first time + step (default is 10000.0). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value :math:`\le 1.0` will imply a reset to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) + + Specifies the maximum allowed growth factor in step size between + consecutive steps in the integration process. + + :param arkode_mem: pointer to the ARKODE memory block. + :param mx_growth: maximum allowed growth factor between consecutive time steps (default is 20.0). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value :math:`\le 1.0` will imply a reset to the default + value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMinReduction(void* arkode_mem, sunrealtype eta_min) + + Specifies the minimum allowed reduction factor in step size between + step attempts, resulting from a temporal error failure in the integration + process. + + :param arkode_mem: pointer to the ARKODE memory block. + :param eta_min: minimum allowed reduction factor in time step after an error + test failure (default is 0.1). + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value outside the interval :math:`(0,1)` will imply a reset to + the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetSafetyFactor(void* arkode_mem, sunrealtype safety) + + Specifies the safety factor to be applied to the accuracy-based + estimated step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param safety: safety factor applied to accuracy-based time step (default is 0.96). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value :math:`\le 0` will imply a reset to the default + value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetSmallNumEFails(void* arkode_mem, int small_nef) + + Specifies the threshold for "multiple" successive error failures + before the *etamxf* parameter from + :c:func:`ARKodeSetMaxEFailGrowth` is applied. + + :param arkode_mem: pointer to the ARKODE memory block. + :param small_nef: bound to determine 'multiple' for *etamxf* (default is 2). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + Any value :math:`\le 0` will imply a reset to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) + + Sets the problem-dependent function to estimate a stable + time step size for the explicit portion of the ODE system. + + :param arkode_mem: pointer to the ARKODE memory block. + :param EStab: name of user-supplied stability function. + :param estab_data: pointer to user data passed to *EStab* every time + it is called. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + This function should return an estimate of the absolute + value of the maximum stable time step for the explicit portion of + the ODE system. It is not required, since accuracy-based + adaptivity may be sufficient for retaining stability, but this can + be quite useful for problems where the explicit right-hand side + function :math:`f^E(t,y)` contains stiff terms. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) + + Sets the strategy to use for accumulating a temporal error estimate + over multiple time steps. + + :param arkode_mem: pointer to the ARKODE memory block. + :param accum_type: accumulation strategy: + + * ``-1`` -- no accumulation (default). + * ``0`` -- maximum accumulation. + * ``1`` -- additive accumulation. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported + by the current time-stepping module. + + .. note:: + + Multiple of ARKODE's time-stepping modules compute both a solution and embedding, + :math:`y_n` and :math:`\tilde{y}_n`, that may be combined to create a vector-valued + local temporal error estimate, :math:`y_n - \tilde{y}_n`. By default, ARKODE will + not accumulate these local error estimates, but accumulation can be triggered by + calling this function with one of two options: + + * ``0`` computes :math:`\text{reltol} \max_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}` + + * ``1`` computes :math:`\frac{\text{reltol}}{N} \sum_{n\in N} \|y_n - \tilde{y}_n\|_{WRMS}`, + + In both cases, the sum or maximum is taken over all steps :math:`n\in N` since the most + recent call to either :c:func:`ARKodeSetAccumulatedErrorType` or + :c:func:`ARKodeResetAccumulatedError`. The norm is taken using the tolerance-informed + error-weight vector (see :c:func:`ARKodeGetErrWeights`), and ``reltol`` is the + user-specified relative solution tolerance. + + Error accumulation can be disabled by calling :c:func:`ARKodeSetAccumulatedErrorType` + with the argument ``-1``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeResetAccumulatedError(void* arkode_mem) + + Resets the accumulated temporal error estimate, that was triggered by a previous call to + :c:func:`ARKodeSetAccumulatedErrorType`. + + :param arkode_mem: pointer to the ARKODE memory block. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL`` + :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported + by the current time-stepping module. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.ARKodeSolverInputTable: + +Optional inputs for implicit stage solves +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The mathematical explanation for the nonlinear solver strategies used +by ARKODE, including how each of the parameters below is used within +the code, is provided in :numref:`ARKODE.Mathematics.Nonlinear`. + + +.. cssclass:: table-bordered + +============================================================== ====================================== ============ +Optional input Function name Default +============================================================== ====================================== ============ +Specify that the implicit RHS is linear :c:func:`ARKodeSetLinear` ``SUNFALSE`` +Specify that the implicit RHS nonlinear :c:func:`ARKodeSetNonlinear` ``SUNTRUE`` +Implicit predictor method :c:func:`ARKodeSetPredictorMethod` 0 +User-provided implicit stage predictor :c:func:`ARKodeSetStagePredictFn` ``NULL`` +RHS function for nonlinear system evaluations :c:func:`ARKodeSetNlsRhsFn` ``NULL`` +Maximum number of nonlinear iterations :c:func:`ARKodeSetMaxNonlinIters` 3 +Coefficient in the nonlinear convergence test :c:func:`ARKodeSetNonlinConvCoef` 0.1 +Nonlinear convergence rate constant :c:func:`ARKodeSetNonlinCRDown` 0.3 +Nonlinear residual divergence ratio :c:func:`ARKodeSetNonlinRDiv` 2.3 +Maximum number of convergence failures :c:func:`ARKodeSetMaxConvFails` 10 +Specify if the implicit RHS is deduced after a nonlinear solve :c:func:`ARKodeSetDeduceImplicitRhs` ``SUNFALSE`` +============================================================== ====================================== ============ + + + + + +.. c:function:: int ARKodeSetLinear(void* arkode_mem, int timedepend) + + Specifies that the implicit portion of the problem is linear. + + :param arkode_mem: pointer to the ARKODE memory block. + :param timedepend: flag denoting whether the Jacobian of + :math:`f^I(t,y)` is time-dependent (1) or not (0). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Tightens the linear solver tolerances and takes only a + single Newton iteration. Calls :c:func:`ARKodeSetDeltaGammaMax` + to enforce Jacobian recomputation when the step size ratio changes + by more than 100 times the unit roundoff (since nonlinear + convergence is not tested). Only applicable when used in + combination with the modified or inexact Newton iteration (not the + fixed-point solver). + + When :math:`f^I(t,y)` is time-dependent, all linear solver structures + (Jacobian, preconditioner) will be updated preceding *each* implicit + stage. Thus one must balance the relative costs of such recomputation + against the benefits of requiring only a single Newton linear solve. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetNonlinear(void* arkode_mem) + + Specifies that the implicit portion of the problem is nonlinear. + + :param arkode_mem: pointer to the ARKODE memory block. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is the default behavior of ARKODE, so the function + is primarily useful to undo a previous call to + :c:func:`ARKodeSetLinear`. Calls + :c:func:`ARKodeSetDeltaGammaMax` to reset the step size ratio + threshold to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetPredictorMethod(void* arkode_mem, int method) + + Specifies the method from :numref:`ARKODE.Mathematics.Predictors` to use + for predicting implicit solutions. + + :param arkode_mem: pointer to the ARKODE memory block. + :param method: method choice (0 :math:`\le` *method* :math:`\le` 4): + + * 0 is the trivial predictor, + + * 1 is the maximum order (dense output) predictor, + + * 2 is the variable order predictor, that decreases the + polynomial degree for more distant RK stages, + + * 3 is the cutoff order predictor, that uses the maximum order + for early RK stages, and a first-order predictor for distant + RK stages, + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default value is 0. If *method* is set to an + undefined value, this default predictor will be used. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) + + Sets the user-supplied function to update the implicit stage predictor prior to + execution of the nonlinear or linear solver algorithms that compute the implicit stage solution. + + :param arkode_mem: pointer to the ARKODE memory block. + :param PredictStage: name of user-supplied predictor function. If ``NULL``, then any + previously-provided stage prediction function will be disabled. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + See :numref:`ARKODE.Usage.StagePredictFn` for more information on + this user-supplied routine. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) + + Specifies an alternative implicit right-hand side function for evaluating + :math:`f^I(t,y)` within nonlinear system function evaluations + :eq:`ARKODE_Residual_MeqI` - :eq:`ARKODE_Residual_MTimeDep`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nls_fi: the alternative C function for computing the right-hand side + function :math:`f^I(t,y)` in the ODE. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default is to use the implicit right-hand side function + provided to :c:func:`ARKodeCreate` in nonlinear system functions. If the + input implicit right-hand side function is ``NULL``, the default is used. + + When using a non-default nonlinear solver, this function must be called + *after* :c:func:`ARKodeSetNonlinearSolver`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxNonlinIters(void* arkode_mem, int maxcor) + + Specifies the maximum number of nonlinear solver + iterations permitted per implicit stage solve within each time step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param maxcor: maximum allowed solver iterations per stage :math:`(>0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value or if the SUNNONLINSOL module is ``NULL``. + :retval ARK_NLS_OP_ERR: the SUNNONLINSOL object returned a failure flag. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default value is 3; set *maxcor* :math:`\le 0` + to specify this default. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) + + Specifies the safety factor :math:`\epsilon` used within the nonlinear + solver convergence test :eq:`ARKODE_NonlinearTolerance`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nlscoef: coefficient in nonlinear solver convergence test :math:`(>0.0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default value is 0.1; set *nlscoef* :math:`\le 0` + to specify this default. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) + + Specifies the constant :math:`c_r` used in estimating the nonlinear solver convergence rate :eq:`ARKODE_NonlinearCRate`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param crdown: nonlinear convergence rate estimation constant (default is 0.3). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Any non-positive parameter will imply a reset to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) + + Specifies the nonlinear correction threshold :math:`r_{div}` from + :eq:`ARKODE_NonlinearDivergence`, beyond which the iteration will be declared divergent. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rdiv: tolerance on nonlinear correction size ratio to + declare divergence (default is 2.3). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Any non-positive parameter will imply a reset to the default value. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) + + Specifies the maximum number of nonlinear solver convergence + failures permitted during one step, :math:`max_{ncf}` from + :numref:`ARKODE.Mathematics.Error.Nonlinear`, before ARKODE will return with + an error. + + :param arkode_mem: pointer to the ARKODE memory block. + :param maxncf: maximum allowed nonlinear solver convergence failures + per step :math:`(>0)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default value is 10; set *maxncf* :math:`\le 0` + to specify this default. + + Upon each convergence failure, ARKODE will first call the Jacobian + setup routine and try again (if a Newton method is used). If a + convergence failure still occurs, the time step size is reduced by + the factor *etacf* (set within :c:func:`ARKodeSetMaxCFailGrowth`). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetDeduceImplicitRhs(void *arkode_mem, sunbooleantype deduce) + + Specifies if implicit stage derivatives are deduced without evaluating + :math:`f^I`. See :numref:`ARKODE.Mathematics.Nonlinear` for more details. + + :param arkode_mem: pointer to the ARKODE memory block. + :param deduce: if ``SUNFALSE`` (default), the stage derivative is obtained + by evaluating :math:`f^I` with the stage solution returned from the + nonlinear solver. If ``SUNTRUE``, the stage derivative is deduced + without an additional evaluation of :math:`f^I`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + .. versionadded:: x.y.z + + +.. _ARKODE.Usage.ARKLsInputs: + + +Linear solver interface optional input functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The mathematical explanation of the linear solver methods +available to ARKODE is provided in :numref:`ARKODE.Mathematics.Linear`. We group +the user-callable routines into four categories: general routines concerning +the update frequency for matrices and/or preconditioners, optional inputs for +matrix-based linear solvers, optional inputs for matrix-free linear solvers, +and optional inputs for iterative linear solvers. We note that the +matrix-based and matrix-free groups are mutually exclusive, whereas the +"iterative" tag can apply to either case. + + + +.. _ARKODE.Usage.ARKLsInputs.General: + +.. index:: + single: optional input; generic linear solver interface (ARKODE) + +Optional inputs for the ARKLS linear solver interface +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +As discussed in :numref:`ARKODE.Mathematics.Linear.Setup`, ARKODE +strives to reuse matrix and preconditioner data for as many solves as +possible to amortize the high costs of matrix construction and +factorization. To that end, ARKODE provides user-callable +routines to modify this behavior. Recall that the +Newton system matrices that arise within an implicit stage solve are +:math:`\mathcal{A}(t,z) \approx M(t) - \gamma J(t,z)`, where the +implicit right-hand side function has Jacobian matrix +:math:`J(t,z) = \frac{\partial f^I(t,z)}{\partial z}`. + +The matrix or preconditioner for :math:`\mathcal{A}` can only be +updated within a call to the linear solver "setup" routine. In +general, the frequency with which the linear solver setup routine is +called may be controlled with the *msbp* argument to +:c:func:`ARKodeSetLSetupFrequency`. When this occurs, the +validity of :math:`\mathcal{A}` for successive time steps +intimately depends on whether the corresponding :math:`\gamma` and +:math:`J` inputs remain valid. + +At each call to the linear solver setup routine the decision to update +:math:`\mathcal{A}` with a new value of :math:`\gamma`, and to reuse +or reevaluate Jacobian information, depends on several factors including: + +* the success or failure of previous solve attempts, +* the success or failure of the previous time step attempts, +* the change in :math:`\gamma` from the value used when constructing :math:`\mathcal{A}`, and +* the number of steps since Jacobian information was last evaluated. + +Jacobian information is considered out-of-date when :math:`msbj` or more steps +have been completed since the last update, in which case it will be recomputed during the next +linear solver setup call. The value of :math:`msbj` is controlled with the +``msbj`` argument to :c:func:`ARKodeSetJacEvalFrequency`. + +For linear-solvers with user-supplied preconditioning the above factors are used +to determine whether to recommend updating the Jacobian information in the +preconditioner (i.e., whether to set *jok* to ``SUNFALSE`` in calling the +user-supplied :c:type:`ARKLsPrecSetupFn`). For matrix-based linear solvers +these factors determine whether the matrix :math:`J(t,y) = \frac{\partial f^I(t,y)}{\partial y}` +should be updated (either with an internal finite difference approximation or +a call to the user-supplied :c:type:`ARKLsJacFn`); if not then the previous +value is reused and the system matrix :math:`\mathcal{A}(t,y) \approx M(t) - \gamma J(t,y)` +is recomputed using the current :math:`\gamma` value. + + + +.. _ARKODE.Usage.ARKLsInputs.General.Table: +.. table:: Optional inputs for the ARKLS linear solver interface + + ============================================= ==================================== ============ + Optional input Function name Default + ============================================= ==================================== ============ + Max change in step signaling new :math:`J` :c:func:`ARKodeSetDeltaGammaMax` 0.2 + Linear solver setup frequency :c:func:`ARKodeSetLSetupFrequency` 20 + Jacobian / preconditioner update frequency :c:func:`ARKodeSetJacEvalFrequency` 51 + ============================================= ==================================== ============ + + +.. c:function:: int ARKodeSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) + + Specifies a scaled step size ratio tolerance, :math:`\Delta\gamma_{max}` from + :numref:`ARKODE.Mathematics.Linear.Setup`, beyond which the linear solver + setup routine will be signaled. + + :param arkode_mem: pointer to the ARKODE memory block. + :param dgmax: tolerance on step size ratio change before calling + linear solver setup routine (default is 0.2). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Any non-positive parameter will imply a reset to the default value. + + .. versionadded:: x.y.z + +.. index:: + single: optional input; linear solver setup frequency (ARKODE) + +.. c:function:: int ARKodeSetLSetupFrequency(void* arkode_mem, int msbp) + + Specifies the frequency of calls to the linear solver setup + routine, :math:`msbp` from :numref:`ARKODE.Mathematics.Linear.Setup`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param msbp: the linear solver setup frequency. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Positive values of **msbp** specify the linear solver setup frequency. For + example, an input of 1 means the setup function will be called every time + step while an input of 2 means it will be called called every other time + step. If **msbp** is 0, the default value of 20 will be used. A negative + value forces a linear solver step at each implicit stage. + + .. versionadded:: x.y.z + + +.. index:: + single: optional input; Jacobian update frequency (ARKODE) + single: optional input; preconditioner update frequency (ARKODE) + +.. c:function:: int ARKodeSetJacEvalFrequency(void* arkode_mem, long int msbj) + + Specifies the number of steps after which the Jacobian information is + considered out-of-date, :math:`msbj` from :numref:`ARKODE.Mathematics.Linear.Setup`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param msbj: the Jacobian re-computation or preconditioner update frequency. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + If ``nstlj`` is the step number at which the Jacobian information was + lasted updated and ``nst`` is the current step number, + ``nst - nstlj >= msbj`` indicates that the Jacobian information will be updated + during the next linear solver setup call. + + As the Jacobian update frequency is only checked *within* calls to the + linear solver setup routine, Jacobian information may be more than + ``msbj`` steps old when updated depending on when a linear solver setup + call occurs. See :numref:`ARKODE.Mathematics.Linear.Setup` + for more information on when linear solver setups are performed. + + Passing a value *msbj* :math:`\le 0` indicates to use the + default value of 51. + + This function must be called *after* the ARKLS system solver interface has + been initialized through a call to :c:func:`ARKodeSetLinearSolver`. + + .. versionadded:: x.y.z + + + + + + +.. _ARKODE.Usage.ARKLsInputs.MatrixBased: + +Optional inputs for matrix-based ``SUNLinearSolver`` modules +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +.. cssclass:: table-bordered + +========================================= ======================================== ============= +Optional input Function name Default +========================================= ======================================== ============= +Jacobian function :c:func:`ARKodeSetJacFn` ``DQ`` +Linear system function :c:func:`ARKodeSetLinSysFn` internal +Mass matrix function :c:func:`ARKodeSetMassFn` none +Enable or disable linear solution scaling :c:func:`ARKodeSetLinearSolutionScaling` on +========================================= ======================================== ============= + +When using matrix-based linear solver modules, the ARKLS solver interface needs +a function to compute an approximation to the Jacobian matrix :math:`J(t,y)` or +the linear system :math:`\mathcal{A}(t,y) = M(t) - \gamma J(t,y)`. + +For :math:`J(t,y)`, the ARKLS interface is packaged with a routine that can approximate +:math:`J` if the user has selected either the :ref:`SUNMATRIX_DENSE ` or +:ref:`SUNMATRIX_BAND ` objects. Alternatively, +the user can supply a custom Jacobian function of type :c:func:`ARKLsJacFn` -- this is +*required* when the user selects other matrix formats. To specify a user-supplied +Jacobian function, ARKODE provides the function :c:func:`ARKodeSetJacFn`. + +Alternatively, a function of type :c:func:`ARKLsLinSysFn` can be provided to +evaluate the matrix :math:`\mathcal{A}(t,y)`. By default, ARKLS uses an +internal linear system function leveraging the SUNMATRIX API to form the matrix +:math:`\mathcal{A}(t,y)` by combining the matrices :math:`M(t)` and :math:`J(t,y)`. +To specify a user-supplied linear system function instead, ARKODE provides the function +:c:func:`ARKodeSetLinSysFn`. + +If the ODE system involves a non-identity mass matrix, :math:`M\ne I`, matrix-based linear +solver modules require a function to compute an approximation to the mass matrix :math:`M(t)`. +There is no default difference quotient approximation (for any matrix type), so this +routine must be supplied by the user. This function must be of type +:c:func:`ARKLsMassFn`, and should be set using the function +:c:func:`ARKodeSetMassFn`. + +In either case (:math:`J(t,y)` versus :math:`\mathcal{A}(t,y)` is supplied) the matrix +information will be updated infrequently to reduce matrix construction and, with direct +solvers, factorization costs. As a result the value of :math:`\gamma` may not be current +and a scaling factor is applied to the solution of the linear system to account for +the lagged value of :math:`\gamma`. See :numref:`SUNLinSol.Lagged_matrix` for more details. +The function :c:func:`ARKodeSetLinearSolutionScaling` can be used to disable this +scaling when necessary, e.g., when providing a custom linear solver that updates the +matrix using the current :math:`\gamma` as part of the solve. + +The ARKLS interface passes the user data pointer to the Jacobian, linear +system, and mass matrix functions. This allows the user to create an arbitrary +structure with relevant problem data and access it during the execution of the +user-supplied Jacobian, linear system or mass matrix functions, without using global +data in the program. The user data pointer may be specified through +:c:func:`ARKodeSetUserData`. + + + +.. c:function:: int ARKodeSetJacFn(void* arkode_mem, ARKLsJacFn jac) + + Specifies the Jacobian approximation routine to + be used for the matrix-based solver with the ARKLS interface. + + :param arkode_mem: pointer to the ARKODE memory block. + :param jac: name of user-supplied Jacobian approximation function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This routine must be called after the ARKLS linear + solver interface has been initialized through a call to + :c:func:`ARKodeSetLinearSolver`. + + By default, ARKLS uses an internal difference quotient function for + the :ref:`SUNMATRIX_DENSE ` and + :ref:`SUNMATRIX_BAND ` modules. If ``NULL`` is passed + in for *jac*, this default is used. An error will occur if no *jac* is + supplied when using other matrix types. + + The function type :c:func:`ARKLsJacFn` is described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) + + Specifies the linear system approximation routine to be used for the + matrix-based solver with the ARKLS interface. + + :param arkode_mem: pointer to the ARKODE memory block. + :param linsys: name of user-supplied linear system approximation function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This routine must be called after the ARKLS linear + solver interface has been initialized through a call to + :c:func:`ARKodeSetLinearSolver`. + + By default, ARKLS uses an internal linear system function that leverages the + SUNMATRIX API to form the system :math:`M - \gamma J`. If ``NULL`` is passed + in for *linsys*, this default is used. + + The function type :c:func:`ARKLsLinSysFn` is described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMassFn(void* arkode_mem, ARKLsMassFn mass) + + Specifies the mass matrix approximation routine to be used for the + matrix-based solver with the ARKLS interface. + + :param arkode_mem: pointer to the ARKODE memory block. + :param mass: name of user-supplied mass matrix approximation function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_MASSMEM_NULL: the mass matrix solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an argument had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This routine must be called after the ARKLS mass matrix + solver interface has been initialized through a call to + :c:func:`ARKodeSetMassLinearSolver`. + + Since there is no default difference quotient function for mass + matrices, *mass* must be non-``NULL``. + + The function type :c:func:`ARKLsMassFn` is described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) + + Enables or disables scaling the linear system solution to account for a + change in :math:`\gamma` in the linear system. For more details see + :numref:`SUNLinSol.Lagged_matrix`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param onoff: flag to enable (``SUNTRUE``) or disable (``SUNFALSE``) + scaling. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_ILL_INPUT: the attached linear solver is not matrix-based. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Linear solution scaling is enabled by default when a matrix-based + linear solver is attached. + + .. versionadded:: x.y.z + + +.. _ARKODE.Usage.ARKLsInputs.MatrixFree: + +Optional inputs for matrix-free ``SUNLinearSolver`` modules +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +.. cssclass:: table-bordered + +================================================== ================================= ================== +Optional input Function name Default +================================================== ================================= ================== +:math:`Jv` functions (*jtimes* and *jtsetup*) :c:func:`ARKodeSetJacTimes` DQ, none +:math:`Jv` DQ rhs function (*jtimesRhsFn*) :c:func:`ARKodeSetJacTimesRhsFn` fi +:math:`Mv` functions (*mtimes* and *mtsetup*) :c:func:`ARKodeSetMassTimes` none, none +================================================== ================================= ================== + + +As described in :numref:`ARKODE.Mathematics.Linear`, when solving +the Newton linear systems with matrix-free methods, the ARKLS +interface requires a *jtimes* function to compute an approximation to +the product between the Jacobian matrix +:math:`J(t,y)` and a vector :math:`v`. The user can supply a custom +Jacobian-times-vector approximation function, or use the default +internal difference quotient function that comes with the ARKLS +interface. + +A user-defined Jacobian-vector function must be of type +:c:type:`ARKLsJacTimesVecFn` and can be specified through a call +to :c:func:`ARKodeSetJacTimes` (see :numref:`ARKODE.Usage.UserSupplied` +for specification details). As with the +user-supplied preconditioner functions, the evaluation and +processing of any Jacobian-related data needed by the user's +Jacobian-times-vector function is done in the optional user-supplied +function of type :c:type:`ARKLsJacTimesSetupFn` (see +:numref:`ARKODE.Usage.UserSupplied` for specification details). As with +the preconditioner functions, a pointer to the user-defined +data structure, *user_data*, specified through +:c:func:`ARKodeSetUserData` (or a ``NULL`` pointer otherwise) is +passed to the Jacobian-times-vector setup and product functions each +time they are called. + + +.. c:function:: int ARKodeSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, ARKLsJacTimesVecFn jtimes) + + Specifies the Jacobian-times-vector setup and product functions. + + :param arkode_mem: pointer to the ARKODE memory block. + :param jtsetup: user-defined Jacobian-vector setup function. + Pass ``NULL`` if no setup is necessary. + :param jtimes: user-defined Jacobian-vector product function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARKLS_SUNLS_FAIL: an error occurred when setting up + the Jacobian-vector product in the ``SUNLinearSolver`` + object used by the ARKLS interface. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default is to use an internal finite difference + quotient for *jtimes* and to leave out *jtsetup*. If ``NULL`` is + passed to *jtimes*, these defaults are used. A user may + specify non-``NULL`` *jtimes* and ``NULL`` *jtsetup* inputs. + + This function must be called *after* the ARKLS system solver + interface has been initialized through a call to + :c:func:`ARKodeSetLinearSolver`. + + The function types :c:type:`ARKLsJacTimesSetupFn` and + :c:type:`ARKLsJacTimesVecFn` are described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + +When using the internal difference quotient the user may optionally supply +an alternative implicit right-hand side function for use in the Jacobian-vector +product approximation by calling :c:func:`ARKodeSetJacTimesRhsFn`. The +alternative implicit right-hand side function should compute a suitable (and +differentiable) approximation to the :math:`f^I` function provided to +``*StepCreate``. For example, as done in :cite:p:`dorr2010numerical`, +the alternative function may use lagged values when evaluating a nonlinearity +in :math:`f^I` to avoid differencing a potentially non-differentiable factor. +We note that in many instances this same :math:`f^I` routine would also have +been desirable for the nonlinear solver, in which case the user should specify +this through calls to *both* :c:func:`ARKodeSetJacTimesRhsFn` and +:c:func:`ARKodeSetNlsRhsFn`. + + +.. c:function:: int ARKodeSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) + + Specifies an alternative implicit right-hand side function for use in the + internal Jacobian-vector product difference quotient approximation. + + :param arkode_mem: pointer to the ARKODE memory block. + :param jtimesRhsFn: the name of the C function (of type + :c:func:`ARKRhsFn`) defining the alternative right-hand side function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default is to use the implicit right-hand side function + provided to ``*StepCreate`` in the internal difference quotient. If + the input implicit right-hand side function is ``NULL``, the default is used. + + This function must be called *after* the ARKLS system solver interface has + been initialized through a call to :c:func:`ARKodeSetLinearSolver`. + + .. versionadded:: x.y.z + + +Similarly, if a problem involves a non-identity mass matrix, +:math:`M\ne I`, then matrix-free solvers require a *mtimes* function +to compute an approximation to the product between the mass matrix +:math:`M(t)` and a vector :math:`v`. This function must be +user-supplied since there is no default value, it must be +of type :c:func:`ARKLsMassTimesVecFn`, and can be specified +through a call to the :c:func:`ARKodeSetMassTimes` routine. +Similarly to the user-supplied preconditioner functions, any evaluation +and processing of any mass matrix-related data needed by the user's +mass-matrix-times-vector function may be done in an optional user-supplied +function of type :c:type:`ARKLsMassTimesSetupFn` (see +:numref:`ARKODE.Usage.UserSupplied` for specification details). + + + +.. c:function:: int ARKodeSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, ARKLsMassTimesVecFn mtimes, void* mtimes_data) + + Specifies the mass matrix-times-vector setup and product functions. + + :param arkode_mem: pointer to the ARKODE memory block. + :param mtsetup: user-defined mass matrix-vector setup function. + Pass ``NULL`` if no setup is necessary. + :param mtimes: user-defined mass matrix-vector product function. + :param mtimes_data: a pointer to user data, that will be supplied + to both the *mtsetup* and *mtimes* functions. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_MASSMEM_NULL: the mass matrix solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARKLS_SUNLS_FAIL: an error occurred when setting up + the mass-matrix-vector product in the ``SUNLinearSolver`` + object used by the ARKLS interface. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + There is no default finite difference quotient for + *mtimes*, so if using the ARKLS mass matrix solver interface with + NULL-valued SUNMATRIX input :math:`M`, and this routine is called + with NULL-valued *mtimes*, an error will occur. A user may + specify ``NULL`` for *mtsetup*. + + This function must be called *after* the ARKLS mass + matrix solver interface has been initialized through a call to + :c:func:`ARKodeSetMassLinearSolver`. + + The function types :c:type:`ARKLsMassTimesSetupFn` and + :c:type:`ARKLsMassTimesVecFn` are described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.ARKLsInputs.Iterative: + +Optional inputs for iterative ``SUNLinearSolver`` modules +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +.. cssclass:: table-bordered + +==================================================== ====================================== ================== +Optional input Function name Default +==================================================== ====================================== ================== +Newton preconditioning functions :c:func:`ARKodeSetPreconditioner` ``NULL``, ``NULL`` +Mass matrix preconditioning functions :c:func:`ARKodeSetMassPreconditioner` ``NULL``, ``NULL`` +Newton linear and nonlinear tolerance ratio :c:func:`ARKodeSetEpsLin` 0.05 +Mass matrix linear and nonlinear tolerance ratio :c:func:`ARKodeSetMassEpsLin` 0.05 +Newton linear solve tolerance conversion factor :c:func:`ARKodeSetLSNormFactor` vector length +Mass matrix linear solve tolerance conversion factor :c:func:`ARKodeSetMassLSNormFactor` vector length +==================================================== ====================================== ================== + + +As described in :numref:`ARKODE.Mathematics.Linear`, when using +an iterative linear solver the user may supply a preconditioning +operator to aid in solution of the system. This operator consists of +two user-supplied functions, *psetup* and *psolve*, that are supplied +to ARKODE using either the function +:c:func:`ARKodeSetPreconditioner` (for preconditioning the +Newton system), or the function +:c:func:`ARKodeSetMassPreconditioner` (for preconditioning the +mass matrix system). The *psetup* function supplied to these routines +should handle evaluation and preprocessing of any Jacobian or +mass-matrix data needed by the user's preconditioner solve function, +*psolve*. The user data pointer received through +:c:func:`ARKodeSetUserData` (or a pointer to ``NULL`` if user data +was not specified) is passed to the *psetup* and *psolve* functions. +This allows the user to create an arbitrary +structure with relevant problem data and access it during the +execution of the user-supplied preconditioner functions without using +global data in the program. If preconditioning is supplied for both +the Newton and mass matrix linear systems, it is expected that the +user will supply different *psetup* and *psolve* function for each. + +Also, as described in :numref:`ARKODE.Mathematics.Error.Linear`, the +ARKLS interface requires that iterative linear solvers stop when +the norm of the preconditioned residual satisfies + +.. math:: + \|r\| \le \frac{\epsilon_L \epsilon}{10} + +where the default :math:`\epsilon_L = 0.05` may be modified by +the user through the :c:func:`ARKodeSetEpsLin` function. + + +.. c:function:: int ARKodeSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, ARKLsPrecSolveFn psolve) + + Specifies the user-supplied preconditioner setup and solve functions. + + :param arkode_mem: pointer to the ARKODE memory block. + :param psetup: user defined preconditioner setup function. Pass + ``NULL`` if no setup is needed. + :param psolve: user-defined preconditioner solve function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARKLS_SUNLS_FAIL: an error occurred when setting up preconditioning + in the ``SUNLinearSolver`` object used + by the ARKLS interface. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The default is ``NULL`` for both arguments (i.e., no + preconditioning). + + This function must be called *after* the ARKLS system solver + interface has been initialized through a call to + :c:func:`ARKodeSetLinearSolver`. + + Both of the function types :c:func:`ARKLsPrecSetupFn` and + :c:func:`ARKLsPrecSolveFn` are described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, ARKLsMassPrecSolveFn psolve) + + Specifies the mass matrix preconditioner setup and solve functions. + + :param arkode_mem: pointer to the ARKODE memory block. + :param psetup: user defined preconditioner setup function. Pass + ``NULL`` if no setup is to be done. + :param psolve: user-defined preconditioner solve function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARKLS_SUNLS_FAIL: an error occurred when setting up preconditioning + in the ``SUNLinearSolver`` object used + by the ARKLS interface. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This function must be called *after* the ARKLS mass + matrix solver interface has been initialized through a call to + :c:func:`ARKodeSetMassLinearSolver`. + + The default is ``NULL`` for both arguments (i.e. no + preconditioning). + + Both of the function types :c:func:`ARKLsMassPrecSetupFn` and + :c:func:`ARKLsMassPrecSolveFn` are described in + :numref:`ARKODE.Usage.UserSupplied`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetEpsLin(void* arkode_mem, sunrealtype eplifac) + + Specifies the factor :math:`\epsilon_L` by which the tolerance on + the nonlinear iteration is multiplied to get a tolerance on the + linear iteration. + + :param arkode_mem: pointer to the ARKODE memory block. + :param eplifac: linear convergence safety factor. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + Passing a value *eplifac* :math:`\le 0` indicates to use the + default value of 0.05. + + This function must be called *after* the ARKLS system solver + interface has been initialized through a call to + :c:func:`ARKodeSetLinearSolver`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) + + Specifies the factor by which the tolerance on the nonlinear + iteration is multiplied to get a tolerance on the mass matrix + linear iteration. + + :param arkode_mem: pointer to the ARKODE memory block. + :param eplifac: linear convergence safety factor. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_MASSMEM_NULL: the mass matrix solver memory was ``NULL``. + :retval ARKLS_ILL_INPUT: an input had an illegal value. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This function must be called *after* the ARKLS mass + matrix solver interface has been initialized through a call to + :c:func:`ARKodeSetMassLinearSolver`. + + Passing a value *eplifac* :math:`\le 0` indicates to use the default value + of 0.05. + + .. versionadded:: x.y.z + + +Since iterative linear solver libraries typically consider linear residual +tolerances using the :math:`L_2` norm, whereas ARKODE focuses on errors +measured in the WRMS norm :eq:`ARKODE_WRMS_NORM`, the ARKLS interface internally +converts between these quantities when interfacing with linear solvers, + +.. math:: + \text{tol}_{L2} = \textit{nrmfac}\ \ \text{tol}_{WRMS}. + :label: ARKODE_NRMFAC + +Prior to the introduction of :c:func:`N_VGetLength` in SUNDIALS v5.0.0 the +value of :math:`nrmfac` was computed using the vector dot product. Now, the +functions :c:func:`ARKodeSetLSNormFactor` and :c:func:`ARKodeSetMassLSNormFactor` +allow for additional user control over these conversion factors. + + +.. c:function:: int ARKodeSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) + + Specifies the factor to use when converting from the integrator tolerance + (WRMS norm) to the linear solver tolerance (L2 norm) for Newton linear system + solves. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nrmfac: the norm conversion factor. If *nrmfac* is: + + :math:`> 0` then the provided value is used. + + :math:`= 0` then the conversion factor is computed using the vector + length i.e., ``nrmfac = sqrt(N_VGetLength(y))`` (*default*). + + :math:`< 0` then the conversion factor is computed using the vector dot + product i.e., ``nrmfac = sqrt(N_VDotProd(v,v))`` where all the entries + of ``v`` are one. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported by the + current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This function must be called *after* the ARKLS system solver interface has + been initialized through a call to :c:func:`ARKodeSetLinearSolver`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac) + + Specifies the factor to use when converting from the integrator tolerance + (WRMS norm) to the linear solver tolerance (L2 norm) for mass matrix linear + system solves. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nrmfac: the norm conversion factor. If *nrmfac* is: + + :math:`> 0` then the provided value is used. + + :math:`= 0` then the conversion factor is computed using the vector + length i.e., ``nrmfac = sqrt(N_VGetLength(y))`` (*default*). + + :math:`< 0` then the conversion factor is computed using the vector dot + product i.e., ``nrmfac = sqrt(N_VDotProd(v,v))`` where all the entries + of ``v`` are one. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This function must be called *after* the ARKLS mass matrix solver interface + has been initialized through a call to :c:func:`ARKodeSetMassLinearSolver`. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.ARKodeRootfindingInputTable: + + +Rootfinding optional input functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following functions can be called to set optional inputs to +control the rootfinding algorithm, the mathematics of which are +described in :numref:`ARKODE.Mathematics.Rootfinding`. + + +.. cssclass:: table-bordered + +====================================== ===================================== ================== +Optional input Function name Default +====================================== ===================================== ================== +Direction of zero-crossings to monitor :c:func:`ARKodeSetRootDirection` both +Disable inactive root warnings :c:func:`ARKodeSetNoInactiveRootWarn` enabled +====================================== ===================================== ================== + + + +.. c:function:: int ARKodeSetRootDirection(void* arkode_mem, int* rootdir) + + Specifies the direction of zero-crossings to be located and returned. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rootdir: state array of length *nrtfn*, the number of root + functions :math:`g_i` (the value of *nrtfn* was supplied in + the call to :c:func:`ARKodeRootInit`). If ``rootdir[i] == + 0`` then crossing in either direction for :math:`g_i` should be + reported. A value of +1 or -1 indicates that the solver + should report only zero-crossings where :math:`g_i` is + increasing or decreasing, respectively. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + The default behavior is to monitor for both zero-crossing directions. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeSetNoInactiveRootWarn(void* arkode_mem) + + Disables issuing a warning if some root function appears + to be identically zero at the beginning of the integration. + + :param arkode_mem: pointer to the ARKODE memory block. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + ARKODE will not report the initial conditions as a + possible zero-crossing (assuming that one or more components + :math:`g_i` are zero at the initial time). However, if it appears + that some :math:`g_i` is identically zero at the initial time + (i.e., :math:`g_i` is zero at the initial time *and* after the + first step), ARKODE will issue a warning which can be disabled with + this optional input function. + + .. versionadded:: x.y.z + + + + +.. _ARKODE.Usage.InterpolatedOutput: + +Interpolated output function +-------------------------------- + +An optional function :c:func:`ARKodeGetDky` is available to obtain +additional values of solution-related quantities. This function +should only be called after a successful return from +:c:func:`ARKodeEvolve`, as it provides interpolated values either of +:math:`y` or of its derivatives (up to the 5th derivative) +interpolated to any value of :math:`t` in the last internal step taken +by :c:func:`ARKodeEvolve`. Internally, this "dense output" or +"continuous extension" algorithm is identical to the algorithm used for +the maximum order implicit predictors, described in +:numref:`ARKODE.Mathematics.Predictors.Max`, except that derivatives of the +polynomial model may be evaluated upon request. + + + +.. c:function:: int ARKodeGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) + + Computes the *k*-th derivative of the function + :math:`y` at the time *t*, + i.e. :math:`y^{(k)}(t)`, for values of the + independent variable satisfying :math:`t_n-h_n \le t \le t_n`, with + :math:`t_n` as current internal time reached, and :math:`h_n` is + the last internal step size successfully used by the solver. This + routine uses an interpolating polynomial of degree *min(degree, 5)*, + where *degree* is the argument provided to + :c:func:`ARKodeSetInterpolantDegree`. The user may request *k* in the + range {0,..., *min(degree, kmax)*} where *kmax* depends on the choice of + interpolation module. For Hermite interpolants *kmax = 5* and for Lagrange + interpolants *kmax = 3*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param t: the value of the independent variable at which the + derivative is to be evaluated. + :param k: the derivative order requested. + :param dky: output vector (must be allocated by the user). + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_BAD_K: *k* is not in the range {0,..., *min(degree, kmax)*}. + :retval ARK_BAD_T: *t* is not in the interval :math:`[t_n-h_n, t_n]`. + :retval ARK_BAD_DKY: the *dky* vector was ``NULL``. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + It is only legal to call this function after a successful + return from :c:func:`ARKodeEvolve`. + + A user may access the values :math:`t_n` and :math:`h_n` via the + functions :c:func:`ARKodeGetCurrentTime` and + :c:func:`ARKodeGetLastStep`, respectively. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.OptionalOutputs: + +Optional output functions +------------------------------ + +ARKODE provides an extensive set of functions that can be used to +obtain solver performance information. We organize these into groups: + +#. General ARKODE output routines are in + :numref:`ARKODE.Usage.ARKodeMainOutputs`, +#. ARKODE implicit solver output routines are in + :numref:`ARKODE.Usage.ARKodeImplicitSolverOutputs`, +#. Output routines regarding root-finding results are in + :numref:`ARKODE.Usage.ARKodeRootOutputs`, +#. Linear solver output routines are in + :numref:`ARKODE.Usage.ARKLsOutputs` and +#. General usability routines (e.g. to print the current ARKODE + parameters, or output the current Butcher table(s)) are in + :numref:`ARKODE.Usage.ARKodeExtraOutputs`. + +Following each table, we elaborate on each function. + +Some of the optional outputs, especially the various counters, can be +very useful in determining the efficiency of various methods inside +ARKODE. For example: + +* The counters *nsteps*, *nfe_evals* and *nfi_evals* + provide a rough measure of the overall cost of a given run, and can + be compared between runs with different solver options to suggest + which set of options is the most efficient. + +* The ratio *nniters/nsteps* measures the performance of the + nonlinear iteration in solving the nonlinear systems at each stage, + providing a measure of the degree of nonlinearity in the problem. + Typical values of this for a Newton solver on a general problem + range from 1.1 to 1.8. + +* When using a Newton nonlinear solver, the ratio *njevals/nniters* + (when using a direct linear solver), and the ratio + *nliters/nniters* (when using an iterative linear solver) can + indicate the quality of the approximate Jacobian or preconditioner being + used. For example, if this ratio is larger for a user-supplied + Jacobian or Jacobian-vector product routine than for the + difference-quotient routine, it can indicate that the user-supplied + Jacobian is inaccurate. + +* The ratio *expsteps/accsteps* can measure the quality of the ImEx + splitting used, since a higher-quality splitting will be dominated + by accuracy-limited steps, and hence a lower ratio. + +* The ratio *nsteps/step_attempts* can measure the quality of the + time step adaptivity algorithm, since a poor algorithm will result + in more failed steps, and hence a lower ratio. + +It is therefore recommended that users retrieve and output these +statistics following each run, and take some time to investigate +alternate solver options that will be more optimal for their +particular problem of interest. + + + +.. _ARKODE.Usage.ARKodeMainOutputs: + +Main solver optional output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. cssclass:: table-bordered + +===================================================== ============================================ +Optional output Function name +===================================================== ============================================ +Size of ARKODE real and integer workspaces :c:func:`ARKodeGetWorkSpace` +Cumulative number of internal steps :c:func:`ARKodeGetNumSteps` +Actual initial time step size used :c:func:`ARKodeGetActualInitStep` +Step size used for the last successful step :c:func:`ARKodeGetLastStep` +Step size to be attempted on the next step :c:func:`ARKodeGetCurrentStep` +Current internal time reached by the solver :c:func:`ARKodeGetCurrentTime` +Current internal solution reached by the solver :c:func:`ARKodeGetCurrentState` +Current :math:`\gamma` value used by the solver :c:func:`ARKodeGetCurrentGamma` +Suggested factor for tolerance scaling :c:func:`ARKodeGetTolScaleFactor` +Error weight vector for state variables :c:func:`ARKodeGetErrWeights` +Residual weight vector :c:func:`ARKodeGetResWeights` +Single accessor to many statistics at once :c:func:`ARKodeGetStepStats` +Print all statistics :c:func:`ARKodePrintAllStats` +Name of constant associated with a return flag :c:func:`ARKodeGetReturnFlagName` +No. of explicit stability-limited steps :c:func:`ARKodeGetNumExpSteps` +No. of accuracy-limited steps :c:func:`ARKodeGetNumAccSteps` +No. of attempted steps :c:func:`ARKodeGetNumStepAttempts` +No. of local error test failures that have occurred :c:func:`ARKodeGetNumErrTestFails` +No. of failed steps due to a nonlinear solver failure :c:func:`ARKodeGetNumStepSolveFails` +Estimated local truncation error vector :c:func:`ARKodeGetEstLocalErrors` +Number of constraint test failures :c:func:`ARKodeGetNumConstrFails` +Retrieve a pointer for user data :c:func:`ARKodeGetUserData` +Retrieve the accumulated temporal error estimate :c:func:`ARKodeGetAccumulatedError` +===================================================== ============================================ + + + + +.. c:function:: int ARKodeGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) + + Returns the ARKODE real and integer workspace sizes. + + :param arkode_mem: pointer to the ARKODE memory block. + :param lenrw: the number of ``sunrealtype`` values in the ARKODE workspace. + :param leniw: the number of integer values in the ARKODE workspace. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumSteps(void* arkode_mem, long int* nsteps) + + Returns the cumulative number of internal steps taken by + the solver (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param nsteps: number of steps taken in the solver. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetActualInitStep(void* arkode_mem, sunrealtype* hinused) + + Returns the value of the integration step size used on the first step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hinused: actual value of initial step size. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + Even if the value of the initial integration step was + specified by the user through a call to + :c:func:`ARKodeSetInitStep`, this value may have been changed by + ARKODE to ensure that the step size fell within the prescribed + bounds :math:`(h_{min} \le h_0 \le h_{max})`, or to satisfy the + local error test condition, or to ensure convergence of the + nonlinear solver. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetLastStep(void* arkode_mem, sunrealtype* hlast) + + Returns the integration step size taken on the last successful + internal step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hlast: step size taken on the last internal step. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetCurrentStep(void* arkode_mem, sunrealtype* hcur) + + Returns the integration step size to be attempted on the next internal step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param hcur: step size to be attempted on the next internal step. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetCurrentTime(void* arkode_mem, sunrealtype* tcur) + + Returns the current internal time reached by the solver. + + :param arkode_mem: pointer to the ARKODE memory block. + :param tcur: current internal time reached. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetCurrentState(void *arkode_mem, N_Vector *ycur) + + Returns the current internal solution reached by the solver. + + :param arkode_mem: pointer to the ARKODE memory block. + :param ycur: current internal solution. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + Users should exercise extreme caution when using this function, + as altering values of *ycur* may lead to undesirable behavior, depending + on the particular use case and on when this routine is called. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetCurrentGamma(void *arkode_mem, sunrealtype *gamma) + + Returns the current internal value of :math:`\gamma` used in the implicit + solver Newton matrix (see equation :eq:`ARKODE_NewtonMatrix`). + + :param arkode_mem: pointer to the ARKODE memory block. + :param gamma: current step size scaling factor in the Newton system. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac) + + Returns a suggested factor by which the user's + tolerances should be scaled when too much accuracy has been + requested for some internal step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param tolsfac: suggested scaling factor for user-supplied tolerances. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetErrWeights(void* arkode_mem, N_Vector eweight) + + Returns the current error weight vector. + + :param arkode_mem: pointer to the ARKODE memory block. + :param eweight: solution error weights at the current time. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + The user must allocate space for *eweight*, that will be + filled in by this function. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetResWeights(void* arkode_mem, N_Vector rweight) + + Returns the current residual weight vector. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rweight: residual error weights at the current time. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + The user must allocate space for *rweight*, that will be + filled in by this function. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) + + Returns many of the most useful optional outputs in a single call. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nsteps: number of steps taken in the solver. + :param hinused: actual value of initial step size. + :param hlast: step size taken on the last internal step. + :param hcur: step size to be attempted on the next internal step. + :param tcur: current internal time reached. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodePrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) + + Outputs all of the integrator, nonlinear solver, linear solver, and other + statistics. + + :param arkode_mem: pointer to the ARKODE memory block. + :param outfile: pointer to output file. + :param fmt: the output format: + + * :c:enumerator:`SUN_OUTPUTFORMAT_TABLE` -- prints a table of values + + * :c:enumerator:`SUN_OUTPUTFORMAT_CSV` -- prints a comma-separated list + of key and value pairs e.g., ``key1,value1,key2,value2,...`` + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_ILL_INPUT: an invalid formatting option was provided. + + .. note:: + + The file ``scripts/sundials_csv.py`` provides python utility functions to + read and output the data from a SUNDIALS CSV output file using the key + and value pair format. + + .. versionadded:: x.y.z + + +.. c:function:: char* ARKodeGetReturnFlagName(long int flag) + + Returns the name of the ARKODE constant corresponding to *flag*. + See :ref:`ARKODE.Constants`. + + :param flag: a return flag from an ARKODE function. + + :return: The return value is a string containing the name of + the corresponding constant. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumExpSteps(void* arkode_mem, long int* expsteps) + + Returns the cumulative number of stability-limited steps + taken by the solver (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param expsteps: number of stability-limited steps taken in the solver. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumAccSteps(void* arkode_mem, long int* accsteps) + + Returns the cumulative number of accuracy-limited steps + taken by the solver (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param accsteps: number of accuracy-limited steps taken in the solver. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumStepAttempts(void* arkode_mem, long int* step_attempts) + + Returns the cumulative number of steps attempted by the solver (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param step_attempts: number of steps attempted by solver. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumErrTestFails(void* arkode_mem, long int* netfails) + + Returns the number of local error test failures that + have occurred (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param netfails: number of error test failures. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumStepSolveFails(void* arkode_mem, long int* ncnf) + + Returns the number of failed steps due to a nonlinear solver failure (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param ncnf: number of step failures. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: implicit solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetEstLocalErrors(void* arkode_mem, N_Vector ele) + + Returns the vector of estimated local truncation errors + for the current step. + + :param arkode_mem: pointer to the ARKODE memory block. + :param ele: vector of estimated local truncation errors. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + The user must allocate space for *ele*, that will be + filled in by this function. + + The values returned in *ele* are valid only after a successful call + to :c:func:`ARKodeEvolve` (i.e., it returned a non-negative value). + + The *ele* vector, together with the *eweight* vector from + :c:func:`ARKodeGetErrWeights`, can be used to determine how the + various components of the system contributed to the estimated local + error test. Specifically, that error test uses the WRMS norm of a + vector whose components are the products of the components of these + two vectors. Thus, for example, if there were recent error test + failures, the components causing the failures are those with largest + values for the products, denoted loosely as ``eweight[i]*ele[i]``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumConstrFails(void* arkode_mem, long int* nconstrfails) + + Returns the cumulative number of constraint test failures (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param nconstrfails: number of constraint test failures. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: adaptive step sizes are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support temporal adaptivity. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetUserData(void* arkode_mem, void** user_data) + + Returns the user data pointer previously set with + :c:func:`ARKodeSetUserData`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param user_data: memory reference to a user data pointer. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) + + Returns the accumulated temporal error estimate. + + :param arkode_mem: pointer to the ARKODE memory block. + :param accum_error: pointer to accumulated error estimate. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: temporal error estimation is not supported + by the current time-stepping module. + + .. note:: + + If a stepper can support temporal error estimation but is currently configured to + use a non-embedded method, then this routine will return ``*accum_error = 0.0``. + + .. versionadded:: x.y.z + + + + + +.. _ARKODE.Usage.ARKodeImplicitSolverOutputs: + +Implicit solver optional output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. cssclass:: table-bordered + +=================================================== ============================================ +Optional output Function name +=================================================== ============================================ +Computes state given a correction :c:func:`ARKodeComputeState` +Access data to compute the nonlin. sys. function :c:func:`ARKodeGetNonlinearSystemData` +No. of calls to linear solver setup function :c:func:`ARKodeGetNumLinSolvSetups` +No. of nonlinear solver iterations :c:func:`ARKodeGetNumNonlinSolvIters` +No. of nonlinear solver iterations :c:func:`ARKodeGetNumNonlinSolvIters` +No. of nonlinear solver convergence failures :c:func:`ARKodeGetNumNonlinSolvConvFails` +Single accessor to all nonlinear solver statistics :c:func:`ARKodeGetNonlinSolvStats` +=================================================== ============================================ + + + + +.. c:function:: int ARKodeGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) + + Returns the number of calls made to the linear solver's + setup routine (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param nlinsetups: number of linear solver setup calls made. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the nonlinear + solver object; the counter is reset whenever a new nonlinear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) + + Returns the number of nonlinear solver iterations + performed (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param nniters: number of nonlinear iterations performed. + :retval ARK_STEPPER_UNSUPPORTED: nonlinear solvers are not supported + by the current time-stepping module. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NLS_OP_ERR: the SUNNONLINSOL object returned a failure flag. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the nonlinear + solver object; the counter is reset whenever a new nonlinear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumNonlinSolvConvFails(void* arkode_mem, long int* nncfails) + + Returns the number of nonlinear solver convergence + failures that have occurred (so far). + + :param arkode_mem: pointer to the ARKODE memory block. + :param nncfails: number of nonlinear convergence failures. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: nonlinear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the nonlinear + solver object; the counter is reset whenever a new nonlinear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNonlinSolvStats(void* arkode_mem, long int* nniters, long int* nncfails) + + Returns all of the nonlinear solver statistics in a single call. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nniters: number of nonlinear iterations performed. + :param nncfails: number of nonlinear convergence failures. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NLS_OP_ERR: the SUNNONLINSOL object returned a failure flag. + :retval ARK_STEPPER_UNSUPPORTED: nonlinear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the nonlinear + solver object; the counters are reset whenever a new nonlinear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. _ARKODE.Usage.ARKodeRootOutputs: + +Rootfinding optional output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. cssclass:: table-bordered + +=================================================== ========================================== +Optional output Function name +=================================================== ========================================== +Array showing roots found :c:func:`ARKodeGetRootInfo` +No. of calls to user root function :c:func:`ARKodeGetNumGEvals` +=================================================== ========================================== + + + +.. c:function:: int ARKodeGetRootInfo(void* arkode_mem, int* rootsfound) + + Returns an array showing which functions were found to + have a root. + + :param arkode_mem: pointer to the ARKODE memory block. + :param rootsfound: array of length *nrtfn* with the indices of the + user functions :math:`g_i` found to have a root (the value of + *nrtfn* was supplied in the call to + :c:func:`ARKodeRootInit`). For :math:`i = 0 \ldots` + *nrtfn*-1, ``rootsfound[i]`` is nonzero if :math:`g_i` has a + root, and 0 if not. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + The user must allocate space for *rootsfound* prior to + calling this function. + + For the components of :math:`g_i` for which a root was found, the + sign of ``rootsfound[i]`` indicates the direction of + zero-crossing. A value of +1 indicates that :math:`g_i` is + increasing, while a value of -1 indicates a decreasing :math:`g_i`. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumGEvals(void* arkode_mem, long int* ngevals) + + Returns the cumulative number of calls made to the + user's root function :math:`g`. + + :param arkode_mem: pointer to the ARKODE memory block. + :param ngevals: number of calls made to :math:`g` so far. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.ARKLsOutputs: + +Linear solver interface optional output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A variety of optional outputs are available from the ARKLS interface, +as listed in the following table and elaborated below. We note that +where the name of an output would otherwise conflict with the +name of an optional output from the main solver, a suffix LS (for +Linear Solver) or MLS (for Mass Linear Solver) has been added here +(e.g. *lenrwLS*). + + + +.. cssclass:: table-bordered + +================================================================= ======================================== +Optional output Function name +================================================================= ======================================== +Stored Jacobian of the ODE RHS function :c:func:`ARKodeGetJac` +Time at which the Jacobian was evaluated :c:func:`ARKodeGetJacTime` +Step number at which the Jacobian was evaluated :c:func:`ARKodeGetJacNumSteps` +Size of real and integer workspaces :c:func:`ARKodeGetLinWorkSpace` +No. of Jacobian evaluations :c:func:`ARKodeGetNumJacEvals` +No. of preconditioner evaluations :c:func:`ARKodeGetNumPrecEvals` +No. of preconditioner solves :c:func:`ARKodeGetNumPrecSolves` +No. of linear iterations :c:func:`ARKodeGetNumLinIters` +No. of linear convergence failures :c:func:`ARKodeGetNumLinConvFails` +No. of Jacobian-vector setup evaluations :c:func:`ARKodeGetNumJTSetupEvals` +No. of Jacobian-vector product evaluations :c:func:`ARKodeGetNumJtimesEvals` +No. of *fi* calls for finite diff. :math:`J` or :math:`Jv` evals. :c:func:`ARKodeGetNumLinRhsEvals` +Last return from a linear solver function :c:func:`ARKodeGetLastLinFlag` +Name of constant associated with a return flag :c:func:`ARKodeGetLinReturnFlagName` +Size of real and integer mass matrix solver workspaces :c:func:`ARKodeGetMassWorkSpace` +No. of mass matrix solver setups (incl. :math:`M` evals.) :c:func:`ARKodeGetNumMassSetups` +No. of mass matrix multiply setups :c:func:`ARKodeGetNumMassMultSetups` +No. of mass matrix multiplies :c:func:`ARKodeGetNumMassMult` +No. of mass matrix solves :c:func:`ARKodeGetNumMassSolves` +No. of mass matrix preconditioner evaluations :c:func:`ARKodeGetNumMassPrecEvals` +No. of mass matrix preconditioner solves :c:func:`ARKodeGetNumMassPrecSolves` +No. of mass matrix linear iterations :c:func:`ARKodeGetNumMassIters` +No. of mass matrix solver convergence failures :c:func:`ARKodeGetNumMassConvFails` +No. of mass-matrix-vector setup evaluations :c:func:`ARKodeGetNumMTSetups` +Last return from a mass matrix solver function :c:func:`ARKodeGetLastMassFlag` +================================================================= ======================================== + +.. c:function:: int ARKodeGetJac(void* arkode_mem, SUNMatrix* J) + + Returns the internally stored copy of the Jacobian matrix of the ODE + implicit right-hand side function. + + :param arkode_mem: the ARKODE memory structure. + :param J: the Jacobian matrix. + + :retval ARKLS_SUCCESS: the output value has been successfully set. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + .. warning:: + + This function is provided for debugging purposes and the values in the + returned matrix should not be altered. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetJacTime(void* arkode_mem, sunrealtype* t_J) + + Returns the time at which the internally stored copy of the Jacobian matrix + of the ODE implicit right-hand side function was evaluated. + + :param arkode_mem: the ARKODE memory structure. + :param t_J: the time at which the Jacobian was evaluated. + + :retval ARKLS_SUCCESS: the output value has been successfully set. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + +.. c:function:: int ARKodeGetJacNumSteps(void* arkode_mem, long int* nst_J) + + Returns the value of the internal step counter at which the internally stored copy of the + Jacobian matrix of the ODE implicit right-hand side function was evaluated. + + :param arkode_mem: the ARKODE memory structure. + :param nst_J: the value of the internal step counter at which the Jacobian was evaluated. + + :retval ARKLS_SUCCESS: the output value has been successfully set. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver interface has not been initialized. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) + + Returns the real and integer workspace used by the ARKLS linear solver interface. + + :param arkode_mem: pointer to the ARKODE memory block. + :param lenrwLS: the number of ``sunrealtype`` values in the ARKLS workspace. + :param leniwLS: the number of integer values in the ARKLS workspace. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The workspace requirements reported by this routine + correspond only to memory allocated within this interface and to + memory allocated by the ``SUNLinearSolver`` object attached + to it. The template Jacobian matrix allocated by the user outside + of ARKLS is not included in this report. + + In a parallel setting, the above values are global (i.e. summed over all + processors). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumJacEvals(void* arkode_mem, long int* njevals) + + Returns the number of Jacobian evaluations. + + :param arkode_mem: pointer to the ARKODE memory block. + :param njevals: number of Jacobian evaluations. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumPrecEvals(void* arkode_mem, long int* npevals) + + Returns the total number of preconditioner evaluations, + i.e. the number of calls made to *psetup* with ``jok`` = ``SUNFALSE`` and + that returned ``*jcurPtr`` = ``SUNTRUE``. + + :param arkode_mem: pointer to the ARKODE memory block. + :param npevals: the current number of calls to *psetup*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumPrecSolves(void* arkode_mem, long int* npsolves) + + Returns the number of calls made to the preconditioner + solve function, *psolve*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param npsolves: the number of calls to *psolve*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumLinIters(void* arkode_mem, long int* nliters) + + Returns the cumulative number of linear iterations. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nliters: the current number of linear iterations. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumLinConvFails(void* arkode_mem, long int* nlcfails) + + Returns the cumulative number of linear convergence failures. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nlcfails: the current number of linear convergence failures. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumJTSetupEvals(void* arkode_mem, long int* njtsetup) + + Returns the cumulative number of calls made to the user-supplied + Jacobian-vector setup function, *jtsetup*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param njtsetup: the current number of calls to *jtsetup*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumJtimesEvals(void* arkode_mem, long int* njvevals) + + Returns the cumulative number of calls made to the + Jacobian-vector product function, *jtimes*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param njvevals: the current number of calls to *jtimes*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) + + Returns the number of calls to the user-supplied implicit + right-hand side function :math:`f^I` for finite difference + Jacobian or Jacobian-vector product approximation. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nfevalsLS: the number of calls to the user implicit + right-hand side function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + The value *nfevalsLS* is incremented only if the default + internal difference quotient function is used. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new linear solver + module is "attached" to ARKODE, or when ARKODE is resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetLastLinFlag(void* arkode_mem, long int* lsflag) + + Returns the last return value from an ARKLS routine. + + :param arkode_mem: pointer to the ARKODE memory block. + :param lsflag: the value of the last return flag from an + ARKLS function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: linear solvers are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + If the ARKLS setup function failed when using the + ``SUNLINSOL_DENSE`` or ``SUNLINSOL_BAND`` modules, then the value + of *lsflag* is equal to the column index (numbered from one) at + which a zero diagonal element was encountered during the LU + factorization of the (dense or banded) Jacobian matrix. For all + other failures, *lsflag* is negative. + + Otherwise, if the ARKLS setup function failed + (:c:func:`ARKodeEvolve` returned *ARK_LSETUP_FAIL*), then + *lsflag* will be *SUNLS_PSET_FAIL_UNREC*, *SUNLS_ASET_FAIL_UNREC* + or *SUN_ERR_EXT_FAIL*. + + If the ARKLS solve function failed (:c:func:`ARKodeEvolve` + returned *ARK_LSOLVE_FAIL*), then *lsflag* contains the error + return flag from the ``SUNLinearSolver`` object, which will + be one of: + *SUN_ERR_ARG_CORRUPTRRUPT*, indicating that the ``SUNLinearSolver`` + memory is ``NULL``; + *SUNLS_ATIMES_NULL*, indicating that a matrix-free iterative solver + was provided, but is missing a routine for the matrix-vector product + approximation, + *SUNLS_ATIMES_FAIL_UNREC*, indicating an unrecoverable failure in + the :math:`Jv` function; + *SUNLS_PSOLVE_NULL*, indicating that an iterative linear solver was + configured to use preconditioning, but no preconditioner solve + routine was provided, + *SUNLS_PSOLVE_FAIL_UNREC*, indicating that the preconditioner solve + function failed unrecoverably; + *SUNLS_GS_FAIL*, indicating a failure in the Gram-Schmidt procedure + (SPGMR and SPFGMR only); + *SUNLS_QRSOL_FAIL*, indicating that the matrix :math:`R` was found + to be singular during the QR solve phase (SPGMR and SPFGMR only); or + *SUN_ERR_EXT_FAIL*, indicating an unrecoverable failure in + an external iterative linear solver package. + + .. versionadded:: x.y.z + + +.. c:function:: char* ARKodeGetLinReturnFlagName(long int lsflag) + + Returns the name of the ARKLS constant corresponding to *lsflag*. + + :param lsflag: a return flag from an ARKLS function. + + :returns: The return value is a string containing the name of + the corresponding constant. If using the ``SUNLINSOL_DENSE`` or + ``SUNLINSOL_BAND`` modules, then if 1 :math:`\le` `lsflag` + :math:`\le n` (LU factorization failed), this routine returns "NONE". + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, long int* leniwMLS) + + Returns the real and integer workspace used by the ARKLS mass matrix linear solver interface. + + :param arkode_mem: pointer to the ARKODE memory block. + :param lenrwMLS: the number of ``sunrealtype`` values in the ARKLS mass solver workspace. + :param leniwMLS: the number of integer values in the ARKLS mass solver workspace. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + The workspace requirements reported by this routine + correspond only to memory allocated within this interface and to + memory allocated by the ``SUNLinearSolver`` object attached + to it. The template mass matrix allocated by the user outside + of ARKLS is not included in this report. + + In a parallel setting, the above values are global (i.e. summed over all + processors). + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassSetups(void* arkode_mem, long int* nmsetups) + + Returns the number of calls made to the ARKLS mass matrix solver + 'setup' routine; these include all calls to the user-supplied + mass-matrix constructor function. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmsetups: number of calls to the mass matrix solver setup routine. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups) + + Returns the number of calls made to the ARKLS mass matrix 'matvec setup' + (matrix-based solvers) routine. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmvsetups: number of calls to the mass matrix matrix-times-vector setup routine. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassMult(void* arkode_mem, long int* nmmults) + + Returns the number of calls made to the ARKLS mass matrix 'matvec' + routine (matrix-based solvers) or the user-supplied *mtimes* + routine (matris-free solvers). + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmmults: number of calls to the mass matrix solver matrix-times-vector routine. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassSolves(void* arkode_mem, long int* nmsolves) + + Returns the number of calls made to the ARKLS mass matrix solver 'solve' routine. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmsolves: number of calls to the mass matrix solver solve routine. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassPrecEvals(void* arkode_mem, long int* nmpevals) + + Returns the total number of mass matrix preconditioner evaluations, + i.e. the number of calls made to *psetup*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmpevals: the current number of calls to *psetup*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassPrecSolves(void* arkode_mem, long int* nmpsolves) + + Returns the number of calls made to the mass matrix preconditioner + solve function, *psolve*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmpsolves: the number of calls to *psolve*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassIters(void* arkode_mem, long int* nmiters) + + Returns the cumulative number of mass matrix solver iterations. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmiters: the current number of mass matrix solver linear iterations. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMassConvFails(void* arkode_mem, long int* nmcfails) + + Returns the cumulative number of mass matrix solver convergence failures. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmcfails: the current number of mass matrix solver convergence failures. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetNumMTSetups(void* arkode_mem, long int* nmtsetup) + + Returns the cumulative number of calls made to the user-supplied + mass-matrix-vector product setup function, *mtsetup*. + + :param arkode_mem: pointer to the ARKODE memory block. + :param nmtsetup: the current number of calls to *mtsetup*. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + This is only accumulated for the "life" of the linear + solver object; the counter is reset whenever a new mass-matrix + linear solver module is "attached" to ARKODE, or when ARKODE is + resized. + + .. versionadded:: x.y.z + + +.. c:function:: int ARKodeGetLastMassFlag(void* arkode_mem, long int* mlsflag) + + Returns the last return value from an ARKLS mass matrix interface routine. + + :param arkode_mem: pointer to the ARKODE memory block. + :param mlsflag: the value of the last return flag from an ARKLS + mass matrix solver interface function. + + :retval ARKLS_SUCCESS: the function exited successfully. + :retval ARKLS_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARKLS_LMEM_NULL: the linear solver memory was ``NULL``. + :retval ARK_STEPPER_UNSUPPORTED: non-identity mass matrices are not supported + by the current time-stepping module. + + .. note:: + + This is only compatible with time-stepping modules that support non-identity mass matrices. + + The values of *msflag* for each of the various solvers + will match those described above for the function + :c:func:`ARKodeGetLastLinFlag`. + + .. versionadded:: x.y.z + + + + +.. _ARKODE.Usage.ARKodeExtraOutputs: + +General usability functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following optional routine may be called by a user to inquire +about existing solver parameters. While this would not typically be +called during the course of solving an initial value problem, it may +be useful for users wishing to better understand ARKODE. + + +.. cssclass:: table-bordered + +==================================== =================================== +Optional routine Function name +==================================== =================================== +Output all ARKODE solver parameters :c:func:`ARKodeWriteParameters` +==================================== =================================== + + + + +.. c:function:: int ARKodeWriteParameters(void* arkode_mem, FILE *fp) + + Outputs all ARKODE solver parameters to the provided file pointer. + + :param arkode_mem: pointer to the ARKODE memory block. + :param fp: pointer to use for printing the solver parameters. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + + .. note:: + + The *fp* argument can be ``stdout`` or ``stderr``, or it + may point to a specific file created using ``fopen``. + + When run in parallel, only one process should set a non-NULL value + for this pointer, since parameters for all processes would be + identical. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.Reset: + +ARKODE reset function +---------------------- + +To reset the ARKODE module to a particular state :math:`(t_R,y(t_R))` for the +continued solution of a problem, where a prior +call to ``*StepCreate`` has been made, the user must call the function +:c:func:`ARKodeReset`. Like the stepper-specific ``*StepReInit`` functions, +this routine retains the current settings for all solver options and +performs no memory allocations but, unlike ``*StepReInit``, this routine +performs only a *subset* of the input checking and initializations that are +done in ``*StepCreate``. In particular this routine retains all internal +counter values and the step size/error history and does not reinitialize the +linear and/or nonlinear solver but it does indicate that a linear solver setup +is necessary in the next step. Like ``*StepReInit``, a call to +:c:func:`ARKodeReset` will delete any previously-set *tstop* value specified +via a call to :c:func:`ARKodeSetStopTime`. Following a successful call to +:c:func:`ARKodeReset`, call :c:func:`ARKodeEvolve` again to continue +solving the problem. By default the next call to :c:func:`ARKodeEvolve` will +use the step size computed by ARKODE prior to calling :c:func:`ARKodeReset`. +To set a different step size or have ARKODE estimate a new step size use +:c:func:`ARKodeSetInitStep`. + +One important use of the :c:func:`ARKodeReset` function is in the +treating of jump discontinuities in the RHS functions. Except in cases +of fairly small jumps, it is usually more efficient to stop at each +point of discontinuity and restart the integrator with a readjusted +ODE model, using a call to :c:func:`ARKodeReset`. To stop when +the location of the discontinuity is known, simply make that location +a value of ``tout``. To stop when the location of the discontinuity +is determined by the solution, use the rootfinding feature. In either +case, it is critical that the RHS functions *not* incorporate the +discontinuity, but rather have a smooth extension over the +discontinuity, so that the step across it (and subsequent rootfinding, +if used) can be done efficiently. Then use a switch within the RHS +functions (communicated through ``user_data``) that can be flipped +between the stopping of the integration and the restart, so that the +restarted problem uses the new values (which have jumped). Similar +comments apply if there is to be a jump in the dependent variable +vector. + + +.. c:function:: int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR) + + Resets the current ARKODE time-stepper module state to the provided + independent variable value and dependent variable vector. + + :param arkode_mem: pointer to the ARKODE memory block. + :param tR: the value of the independent variable :math:`t`. + :param yR: the value of the dependent variable vector :math:`y(t_R)`. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_MEM_FAIL: a memory allocation failed. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + By default the next call to :c:func:`ARKodeEvolve` will use the step size + computed by ARKODE prior to calling :c:func:`ARKodeReset`. To set a + different step size or have ARKODE estimate a new step size use + :c:func:`ARKodeSetInitStep`. + + All previously set options are retained but may be updated by calling + the appropriate "Set" functions. + + If an error occurred, :c:func:`ARKodeReset` also sends an error message to + the error handler function. + + .. versionadded:: x.y.z + + + +.. _ARKODE.Usage.Resizing: + +ARKODE system resize function +------------------------------------- + +For simulations involving changes to the number of equations and +unknowns in the ODE system (e.g. when using spatially-adaptive +PDE simulations under a method-of-lines approach), the ARKODE +integrator may be "resized" between integration steps, through calls +to the :c:func:`ARKodeResize` function. This function modifies +ARKODE's internal memory structures to use the new problem size, +without destruction of the temporal adaptivity heuristics. It is +assumed that the dynamical time scales before and after the vector +resize will be comparable, so that all time-stepping heuristics prior +to calling :c:func:`ARKodeResize` remain valid after the call. If +instead the dynamics should be recomputed from scratch, the ARKODE +memory structure should be deleted with a call to +:c:func:`ARKodeFree`, and recreated with a calls to +``*StepCreate``. + +To aid in the vector resize operation, the user can supply a vector +resize function that will take as input a vector with the previous +size, and transform it in-place to return a corresponding vector of +the new size. If this function (of type :c:func:`ARKVecResizeFn`) +is not supplied (i.e., is set to ``NULL``), then all existing vectors +internal to ARKODE will be destroyed and re-cloned from the new input +vector. + +In the case that the dynamical time scale should be modified slightly +from the previous time scale, an input *hscale* is allowed, that will +rescale the upcoming time step by the specified factor. If a value +*hscale* :math:`\le 0` is specified, the default of 1.0 will be used. + + + +.. c:function:: int ARKodeResize(void* arkode_mem, N_Vector yR, sunrealtype hscale, sunrealtype tR, ARKVecResizeFn resize, void* resize_data) + + Re-sizes ARKODE with a different state vector but with comparable + dynamical time scale. + + :param arkode_mem: pointer to the ARKODE memory block. + :param yR: the newly-sized state vector, holding the current + dependent variable values :math:`y(t_R)`. + :param hscale: the desired time step scaling factor (i.e. the next + step will be of size *h\*hscale*). + :param tR: the current value of the independent variable + :math:`t_R` (this must be consistent with *yR*). + :param resize: the user-supplied vector resize function (of type + :c:func:`ARKVecResizeFn`. + :param resize_data: the user-supplied data structure to be passed + to *resize* when modifying internal ARKODE vectors. + + :retval ARK_SUCCESS: the function exited successfully. + :retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``. + :retval ARK_NO_MALLOC: ``arkode_mem`` was not allocated. + :retval ARK_ILL_INPUT: an argument had an illegal value. + + .. note:: + + If an error occurred, :c:func:`ARKodeResize` also sends an error + message to the error handler function. + + If inequality constraint checking is enabled a call to + :c:func:`ARKodeResize` will disable constraint checking. A call + to :c:func:`ARKodeSetConstraints` is required to re-enable constraint + checking. + + **Resizing the linear solver:** + + When using any of the SUNDIALS-provided linear solver modules, the + linear solver memory structures must also be resized. At present, + none of these include a solver-specific "resize" function, so the linear + solver memory must be destroyed and re-allocated **following** each + call to :c:func:`ARKodeResize`. Moreover, the existing ARKLS + interface should then be deleted and recreated by attaching the + updated ``SUNLinearSolver`` (and possibly ``SUNMatrix``) object(s) + through calls to + :c:func:`ARKodeSetLinearSolver`, and + :c:func:`ARKodeSetMassLinearSolver`. + + If any user-supplied routines are provided to aid the linear solver + (e.g. Jacobian construction, Jacobian-vector product, + mass-matrix-vector product, preconditioning), then the corresponding + "set" routines must be called again **following** the solver + re-specification. + + **Resizing the absolute tolerance array:** + + If using array-valued absolute tolerances, the absolute tolerance + vector will be invalid after the call to :c:func:`ARKodeResize`, so + the new absolute tolerance vector should be re-set **following** each + call to :c:func:`ARKodeResize` through a new call to + :c:func:`ARKodeSVtolerances` and possibly + :c:func:`ARKodeResVtolerance` if applicable. + + If scalar-valued tolerances or a tolerance function was specified + through either :c:func:`ARKodeSStolerances` or + :c:func:`ARKodeWFtolerances`, then these will remain valid and no + further action is necessary. + + **Example codes:** + + * ``examples/arkode/C_serial/ark_heat1D_adapt.c`` + + .. versionadded:: x.y.z diff --git a/doc/arkode/guide/source/Usage/User_supplied.rst b/doc/arkode/guide/source/Usage/User_supplied.rst index 88942bff99..cb27409c48 100644 --- a/doc/arkode/guide/source/Usage/User_supplied.rst +++ b/doc/arkode/guide/source/Usage/User_supplied.rst @@ -20,52 +20,60 @@ User-supplied functions The user-supplied functions for ARKODE consist of: -* at least one function defining the ODE (required), +* at least one function :ref:`defining the ODE ` + (required), -* a function that handles error and warning messages (optional), +* a function that + :ref:`provides the error weight vector ` (optional), -* a function that provides the error weight vector (optional), +* a function that + :ref:`provides the residual weight vector ` (optional), -* a function that provides the residual weight vector (optional, ARKStep only), +* a function that + :ref:`handles explicit time step stability ` (optional), -* a function that handles adaptive time step error control (optional, ARKStep/ERKStep only), +* a function that + :ref:`updates the implicit stage prediction ` (optional), -* a function that handles explicit time step stability (optional, ARKStep/ERKStep only), +* a function that + :ref:`defines auxiliary temporal root-finding problem(s) to solve ` (optional), -* a function that updates the implicit stage prediction (optional, ARKStep/MRIStep only), +* one or two functions that + :ref:`provide Jacobian-related information ` + for the linear solver, if a component is treated implicitly and a + Newton-based nonlinear iteration is chosen (optional), -* a function that defines the root-finding problem(s) to solve (optional), - -* one or two functions that provide Jacobian-related information for - the linear solver, if a component is treated implicitly and a - Newton-based nonlinear iteration is chosen (optional, ARKStep/MRIStep only), - -* one or two functions that define the preconditioner for use in any - of the Krylov iterative algorithms, if linear systems of equations are to - be solved using an iterative method (optional, ARKStep/MRIStep only), +* one or two functions that :ref:`define the preconditioner ` + for use in any of the Krylov iterative algorithms, if linear systems of + equations are to be solved using an iterative method (optional), * if the problem involves a non-identity mass matrix :math:`M\ne I` with ARKStep: - * one or two functions that provide mass-matrix-related information + * one or two functions that + :ref:`provide mass-matrix-related information ` for the linear and mass matrix solvers (required), - * one or two functions that define the mass matrix preconditioner + * one or two functions that + :ref:`define the mass matrix preconditioner ` for use if an iterative mass matrix solver is chosen (optional), and -* a function that handles vector resizing operations, if the +* a function that + :ref:`handles vector resizing operations `, if the underlying vector structure supports resizing (as opposed to deletion/recreation), and if the user plans to call - :c:func:`ARKStepResize`, :c:func:`ERKStepResize`, or - :c:func:`MRIStepResize` (optional). + :c:func:`ARKodeResize` (optional). -* MRIStep only: functions to be called before and after each inner integration to - perform any communication or memory transfers of forcing data supplied +* MRIStep only: functions to be + :ref:`called before and after each inner integration ` + to perform any communication or memory transfers of forcing data supplied by the outer integrator to the inner integrator, or state data supplied by the inner integrator to the outer integrator. -* if relaxation is enabled (optional), a function that evaluates the - conservative or dissipative function :math:`\xi(y(t))` (required) and a - function to evaluate its Jacobian :math:`\xi'(y(t))` (required). +* if relaxation is enabled (optional), a function that + :ref:`evaluates the conservative or dissipative function ` + :math:`\xi(y(t))` (required) and a function to + :ref:`evaluate its Jacobian ` + :math:`\xi'(y(t))` (required). .. _ARKODE.Usage.ODERHS: @@ -74,31 +82,26 @@ ODE right-hand side ----------------------------- The user must supply at least one function of type :c:type:`ARKRhsFn` to -specify the explicit and/or implicit portions of the ODE system to ARKStep, -the ODE system function to ERKStep, or the "slow" right-hand side of the -ODE system to MRIStep: - +specify the IVP-defininig right-hand side function(s) when creating the +ARKODE time-stepping module: .. c:type:: int (*ARKRhsFn)(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data) These functions compute the ODE right-hand side for a given value of the independent variable :math:`t` and state vector :math:`y`. - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *ydot* -- the output vector that forms [a portion of] the ODE RHS :math:`f(t,y)`. - * *user_data* -- the `user_data` pointer that was passed to - :c:func:`ARKStepSetUserData`, :c:func:`ERKStepSetUserData`, or :c:func:`MRIStepSetUserData`. + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param ydot: the output vector that forms [a portion of] the ODE RHS :math:`f(t,y)`. + :param user_data: the `user_data` pointer that was passed to + :c:func:`ARKodeSetUserData`. - **Return value:** + :return: An *ARKRhsFn* should return 0 if successful, a positive value if a + recoverable error occurred (in which case ARKODE will attempt to + correct), or a negative value if it failed unrecoverably (in which + case the integration is halted and *ARK_RHSFUNC_FAIL* is returned). - An *ARKRhsFn* should return 0 if successful, a positive value if a - recoverable error occurred (in which case ARKODE will attempt to - correct), or a negative value if it failed unrecoverably (in which - case the integration is halted and *ARK_RHSFUNC_FAIL* is returned). - - **Notes:** + .. note:: Allocation of memory for `ydot` is handled within ARKODE. @@ -110,18 +113,17 @@ ODE system to MRIStep: "illegal" in some way (e.g., negative where only a non-negative value is physically meaningful). If such a return is made, ARKODE will attempt to recover (possibly repeating the - nonlinear iteration, or reducing the step size in ARKStep or ERKStep) + nonlinear iteration, or reducing the step size in ARKodeEvolve) in order to avoid this recoverable error return. There are some situations in which recovery is not possible even if the right-hand side function returns a recoverable error flag. One is when this occurs at the very first call to the *ARKRhsFn* (in which case ARKODE returns *ARK_FIRST_RHSFUNC_ERR*). Another is when a - recoverable error is reported by *ARKRhsFn* after the ARKStep - integrator completes a successful stage, in which case ARKStep returns - *ARK_UNREC_RHSFUNC_ERR*). Similarly, since MRIStep does not currently - support adaptive time stepping at the slow time scale, it may - halt on a recoverable error flag that would normally have resulted - in a stepsize reduction. + recoverable error is reported by *ARKRhsFn* after the time-stepping + module completes a successful stage, in which case ARKodeEvolve returns + *ARK_UNREC_RHSFUNC_ERR*). Finally, when ARKODE is run in fixed-step + mode, it may halt on a recoverable error flag that would normally have + resulted in a stepsize reduction. @@ -144,18 +146,16 @@ in :numref:`ARKODE.Mathematics.Error.Norm`. This function computes the WRMS error weights for the vector :math:`y`. - **Arguments:** - * *y* -- the dependent variable vector at which the - weight vector is to be computed. - * *ewt* -- the output vector containing the error weights. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to the ``SetUserData`` function + :param y: the dependent variable vector at which the weight vector is to be computed. + :param ewt: the output vector containing the error weights. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData` function + + :return: An *ARKEwtFn* function must return 0 if it + successfully set the error weights, and -1 otherwise. - **Return value:** - An *ARKEwtFn* function must return 0 if it - successfully set the error weights, and -1 otherwise. + .. note:: - **Notes:** Allocation of memory for *ewt* is handled within ARKODE. The error weight vector must have all components positive. It is @@ -166,8 +166,14 @@ in :numref:`ARKODE.Mathematics.Error.Norm`. .. _ARKODE.Usage.ResidualWeight: -Residual weight function (ARKStep only) ----------------------------------------- +Residual weight function +------------------------ + +.. warning:: + + The functions in this section are specific to time-stepping modules + that support non-identity mass matrices. + As an alternative to providing the scalar or vector absolute residual tolerances (when the IVP units differ from the solution units), the @@ -184,19 +190,18 @@ in :numref:`ARKODE.Mathematics.Error.Norm`. This function computes the WRMS residual weights for the vector :math:`y`. - **Arguments:** - * *y* -- the dependent variable vector at which the - weight vector is to be computed. - * *rwt* -- the output vector containing the residual weights. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData()`. + :param y: the dependent variable vector at which the + weight vector is to be computed. + :param rwt: the output vector containing the residual weights. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + + :return: An *ARKRwtFn* function must return 0 if it + successfully set the residual weights, and -1 otherwise. - **Return value:** - An *ARKRwtFn* function must return 0 if it - successfully set the residual weights, and -1 otherwise. + .. note:: - **Notes:** - Allocation of memory for *rwt* is handled within ARKStep. + Allocation of memory for *rwt* is handled within ARKODE. The residual weight vector must have all components positive. It is the user's responsibility to perform this test and return -1 if it @@ -206,9 +211,15 @@ in :numref:`ARKODE.Mathematics.Error.Norm`. .. _ARKODE.Usage.AdaptivityFn: -Time step adaptivity function (ARKStep and ERKStep only) +Time step adaptivity function -------------------------------------------------------- +.. warning:: + + The function in this section is only used in now-deprecated functions + in ARKStep and ERKStep, and will be removed in a future release. + + As an alternative to using one of the built-in time step adaptivity methods for controlling solution error, the user may provide a function of type :c:type:`ARKAdaptFn` to compute a target step size @@ -222,41 +233,48 @@ such that the error estimate for the next time step remains below 1. This function implements a time step adaptivity algorithm that chooses :math:`h` to satisfy the error tolerances. - **Arguments:** - * *y* -- the current value of the dependent variable vector. - * *t* -- the current value of the independent variable. - * *h1* -- the current step size, :math:`t_n - t_{n-1}`. - * *h2* -- the previous step size, :math:`t_{n-1} - t_{n-2}`. - * *h3* -- the step size :math:`t_{n-2}-t_{n-3}`. - * *e1* -- the error estimate from the current step, :math:`n`. - * *e2* -- the error estimate from the previous step, :math:`n-1`. - * *e3* -- the error estimate from the step :math:`n-2`. - * *q* -- the global order of accuracy for the method. - * *p* -- the global order of accuracy for the embedded method. - * *hnew* -- the output value of the next step size. - * *user_data* -- a pointer to user data, the same as the - *h_data* parameter that was passed to :c:func:`ARKStepSetAdaptivityFn` - or :c:func:`ERKStepSetAdaptivityFn`. + :param y: the current value of the dependent variable vector. + :param t: the current value of the independent variable. + :param h1: the current step size, :math:`t_n - t_{n-1}`. + :param h2: the previous step size, :math:`t_{n-1} - t_{n-2}`. + :param h3: the step size :math:`t_{n-2}-t_{n-3}`. + :param e1: the error estimate from the current step, :math:`n`. + :param e2: the error estimate from the previous step, :math:`n-1`. + :param e3: the error estimate from the step :math:`n-2`. + :param q: the global order of accuracy for the method. + :param p: the global order of accuracy for the embedded method. + :param hnew: the output value of the next step size. + :param user_data: a pointer to user data, the same as the + *h_data* parameter that was passed to :c:func:`ARKStepSetAdaptivityFn` + or :c:func:`ERKStepSetAdaptivityFn`. - **Return value:** - An *ARKAdaptFn* function should return 0 if it - successfully set the next step size, and a non-zero value otherwise. + :return: An *ARKAdaptFn* function should return 0 if it + successfully set the next step size, and a non-zero value otherwise. + .. deprecated:: 5.7.0 + + Use the SUNAdaptController infrastructure instead (see + :numref:`SUNAdaptController.Description`). .. _ARKODE.Usage.StabilityFn: -Explicit stability function (ARKStep and ERKStep only) ------------------------------------------------------- +Explicit stability function +--------------------------- + +.. warning:: + + The functions in this section are specific to time-stepping modules + that support temporal adaptivity. + A user may supply a function to predict the maximum stable step size -for the explicit portion of the problem, :math:`f^E(t,y)` in ARKStep -or the full :math:`f(t,y)` in ERKStep. While -the accuracy-based time step adaptivity algorithms may be sufficient -for retaining a stable solution to the ODE system, these may be -inefficient if the explicit right-hand side function contains moderately stiff terms. In -this scenario, a user may provide a function of type :c:type:`ARKExpStabFn` +for an explicit portion of their IVP. While the accuracy-based time step +adaptivity algorithms may be sufficient for retaining a stable solution to +the ODE system, these may be inefficient if the explicit right-hand side +function contains moderately stiff terms. In this scenario, a user may +provide a function of type :c:type:`ARKExpStabFn` to provide this stability information to ARKODE. This function must set the scalar step size satisfying the stability restriction for the upcoming time step. This value will subsequently be bounded by @@ -270,21 +288,19 @@ step, and the accuracy-based time step. This function predicts the maximum stable step size for the explicit portion of the ODE system. - **Arguments:** - * *y* -- the current value of the dependent variable vector. - * *t* -- the current value of the independent variable. - * *hstab* -- the output value with the absolute value of the - maximum stable step size. - * *user_data* -- a pointer to user data, the same as the - *estab_data* parameter that was passed to :c:func:`ARKStepSetStabilityFn` - or :c:func:`ERKStepSetStabilityFn`. - - **Return value:** - An *ARKExpStabFn* function should return 0 if it - successfully set the upcoming stable step size, and a non-zero - value otherwise. - - **Notes:** + :param y: the current value of the dependent variable vector. + :param t: the current value of the independent variable. + :param hstab: the output value with the absolute value of the + maximum stable step size. + :param user_data: a pointer to user data, the same as the *estab_data* + parameter that was passed to :c:func:`ARKodeSetStabilityFn`. + + :return: An *ARKExpStabFn* function should return 0 if it + successfully set the upcoming stable step size, and a non-zero + value otherwise. + + .. note:: + If this function is not supplied, or if it returns *hstab* :math:`\le 0.0`, then ARKODE will assume that there is no explicit stability restriction on the time step size. @@ -294,19 +310,19 @@ step, and the accuracy-based time step. .. _ARKODE.Usage.StagePredictFn: -Implicit stage prediction function (ARKStep and MRIStep only) -------------------------------------------------------------- +Implicit stage prediction function +---------------------------------- A user may supply a function to update the prediction for each implicit stage solution. -If supplied, this routine will be called *after* any existing ARKStep or MRIStep predictor +If supplied, this routine will be called *after* any existing ARKODE predictor algorithm completes, so that the predictor may be modified by the user as desired. In this scenario, a user may provide a function of type :c:type:`ARKStagePredictFn` to provide this implicit predictor to ARKODE. This function takes as input the already-predicted implicit stage solution and the corresponding "time" for that prediction; it then updates the prediction vector as desired. If the user-supplied routine will construct a full prediction (and thus the ARKODE prediction is irrelevant), it is -recommended that the user *not* call :c:func:`ARKStepSetPredictorMethod` or -:c:func:`MRIStepSetPredictorMethod`, thereby leaving the default trivial predictor in place. +recommended that the user *not* call :c:func:`ARKodeSetPredictorMethod`, thereby leaving +the default trivial predictor in place. @@ -314,27 +330,25 @@ recommended that the user *not* call :c:func:`ARKStepSetPredictorMethod` or This function updates the prediction for the implicit stage solution. - **Arguments:** - * *t* -- the current value of the independent variable containing the - "time" corresponding to the predicted solution. - * *zpred* -- the ARKStep-predicted stage solution on input, and the - user-modified predicted stage solution on output. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData` - or :c:func:`MRIStepSetUserData`. - - **Return value:** - An *ARKStagePredictFn* function should return 0 if it - successfully set the upcoming stable step size, and a non-zero - value otherwise. - - **Notes:** + :param t: the current value of the independent variable containing the + "time" corresponding to the predicted solution. + :param zpred: the ARKODE-predicted stage solution on input, and the + user-modified predicted stage solution on output. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + + :return: An *ARKStagePredictFn* function should return 0 if it + successfully set the upcoming stable step size, and a non-zero + value otherwise. + + .. note:: + This may be useful if there are bound constraints on the solution, and these should be enforced prior to beginning the nonlinear or linear implicit solver algorithm. This routine is incompatible with the "minimum correction predictor" -- option 5 to the - routine :c:func:`ARKStepSetPredictorMethod()`. If both are selected, then ARKStep will + routine :c:func:`ARKodeSetPredictorMethod`. If both are selected, then ARKODE will override its built-in implicit predictor routine to instead use option 0 (trivial predictor). @@ -354,65 +368,60 @@ ODE system, the user must supply a function of type :c:type:`ARKRootFn`. :math:`g(t,y)` such that roots are sought for the components :math:`g_i(t,y)`, :math:`i=0,\ldots,` *nrtfn*-1. - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *gout* -- the output array, of length *nrtfn*, with components :math:`g_i(t,y)`. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to the ``SetUserData`` function + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param gout: the output array, of length *nrtfn*, with components :math:`g_i(t,y)`. + :param user_data: a pointer to user data, the same as the + *user_data* parameter that was passed to the ``SetUserData`` function + + :return: An *ARKRootFn* function should return 0 if successful + or a non-zero value if an error occurred (in which case the + integration is halted and ARKODE returns *ARK_RTFUNC_FAIL*). - **Return value:** - An *ARKRootFn* function should return 0 if successful - or a non-zero value if an error occurred (in which case the - integration is halted and ARKODE returns *ARK_RTFUNC_FAIL*). + .. note:: - **Notes:** Allocation of memory for *gout* is handled within ARKODE. .. _ARKODE.Usage.JacobianFn: -Jacobian construction (matrix-based linear solvers, ARKStep and MRIStep only) ------------------------------------------------------------------------------ +Jacobian construction +--------------------- If a matrix-based linear solver module is used (i.e., a non-NULL ``SUNMatrix`` -object was supplied to :c:func:`ARKStepSetLinearSolver` or -:c:func:`MRIStepSetLinearSolver`, the user may provide a function of type -:c:type:`ARKLsJacFn` to provide the Jacobian approximation or +object was supplied to :c:func:`ARKodeSetLinearSolver`, the user may provide a +function of type :c:type:`ARKLsJacFn` to provide the Jacobian approximation or :c:type:`ARKLsLinSysFn` to provide an approximation of the linear system :math:`\mathcal{A}(t,y) = M(t) - \gamma J(t,y)`. - .. c:type:: int (*ARKLsJacFn)(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) This function computes the Jacobian matrix :math:`J(t,y) = \dfrac{\partial f^I}{\partial y}(t,y)` (or an approximation to it). - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector, namely - the predicted value of :math:`y(t)`. - * *fy* -- the current value of the vector :math:`f^I(t,y)`. - * *Jac* -- the output Jacobian matrix. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData` - or :c:func:`MRIStepSetUserData`. - * *tmp1*, *tmp2*, *tmp3* -- pointers to memory allocated to - variables of type ``N_Vector`` which can be used by an - ARKLsJacFn as temporary storage or work space. - - **Return value:** - An *ARKLsJacFn* function should return 0 if successful, a positive - value if a recoverable error occurred (in which case ARKODE will - attempt to correct, while ARKLS sets *last_flag* to - *ARKLS_JACFUNC_RECVR*), or a negative value if it failed - unrecoverably (in which case the integration is halted, - :c:func:`ARKStepEvolve` or :c:func:`MRIStepEvolve` returns - *ARK_LSETUP_FAIL* and ARKLS sets *last_flag* to *ARKLS_JACFUNC_UNRECVR*). - - **Notes:** + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector, namely + the predicted value of :math:`y(t)`. + :param fy: the current value of the vector :math:`f^I(t,y)`. + :param Jac: the output Jacobian matrix. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + :param tmp*: pointers to memory allocated to + variables of type ``N_Vector`` which can be used by an + ARKLsJacFn as temporary storage or work space. + + :return: An *ARKLsJacFn* function should return 0 if successful, a positive + value if a recoverable error occurred (in which case ARKODE will + attempt to correct, while ARKLS sets *last_flag* to + *ARKLS_JACFUNC_RECVR*), or a negative value if it failed + unrecoverably (in which case the integration is halted, + :c:func:`ARKodeEvolve` returns *ARK_LSETUP_FAIL* and + ARKLS sets *last_flag* to *ARKLS_JACFUNC_UNRECVR*). + + .. note:: + Information regarding the specific ``SUNMatrix`` structure (e.g.~number of rows, upper/lower bandwidth, sparsity type) may be obtained through using the @@ -439,9 +448,8 @@ object was supplied to :c:func:`ARKStepSetLinearSolver` or in the argument list, including the current step size, the error weights, etc. To obtain these, the user will need to add a pointer to the ``ark_mem`` structure to their ``user_data``, and - then use the ``ARKStepGet*`` or ``MRIStepGet*`` functions listed in - :numref:`ARKODE.Usage.ARKStep.OptionalOutputs` or - :numref:`ARKODE.Usage.MRIStep.OptionalOutputs`. The unit roundoff can be + then use the ``ARKSodeGet*`` functions listed in + :numref:`ARKODE.Usage.OptionalOutputs`. The unit roundoff can be accessed as ``SUN_UNIT_ROUNDOFF``, which is defined in the header file ``sundials_types.h``. @@ -478,51 +486,47 @@ object was supplied to :c:func:`ARKStepSetLinearSolver` or This function computes the linear system matrix :math:`\mathcal{A}(t,y) = M(t) - \gamma J(t,y)` (or an approximation to it). - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector, namely the - predicted value of :math:`y(t)`. - * *fy* -- the current value of the vector :math:`f^I(t,y)`. - * *A* -- the output linear system matrix. - * *M* -- the current mass matrix (this input is ``NULL`` if :math:`M = I`). - * *jok* -- is an input flag indicating whether the Jacobian-related data - needs to be updated. The *jok* argument provides for the reuse of - Jacobian data. When *jok* = ``SUNFALSE``, the Jacobian-related data - should be recomputed from scratch. When *jok* = ``SUNTRUE`` the Jacobian - data, if saved from the previous call to this function, can be reused - (with the current value of *gamma*). A call with *jok* = ``SUNTRUE`` can - only occur after a call with *jok* = ``SUNFALSE``. - * *jcur* -- is a pointer to a flag which should be set to ``SUNTRUE`` if - Jacobian data was recomputed, or set to ``SUNFALSE`` if Jacobian data - was not recomputed, but saved data was still reused. - * *gamma* -- the scalar :math:`\gamma` appearing in the Newton system matrix - :math:`\mathcal{A}=M(t)-\gamma J(t,y)`. - * *user_data* -- a pointer to user data, the same as the *user_data* - parameter that was passed to :c:func:`ARKStepSetUserData` or - :c:func:`MRIStepSetUserData`. - * *tmp1*, *tmp2*, *tmp3* -- pointers to memory allocated to variables of - type ``N_Vector`` which can be used by an ARKLsLinSysFn as temporary - storage or work space. - - **Return value:** - An *ARKLsLinSysFn* function should return 0 if successful, a positive value - if a recoverable error occurred (in which case ARKODE will attempt to - correct, while ARKLS sets *last_flag* to *ARKLS_JACFUNC_RECVR*), or a - negative value if it failed unrecoverably (in which case the integration is - halted, :c:func:`ARKStepEvolve` or :c:func:`MRIStepEvolve` returns - *ARK_LSETUP_FAIL* and ARKLS sets *last_flag* to *ARKLS_JACFUNC_UNRECVR*). + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector, namely the + predicted value of :math:`y(t)`. + :param fy: the current value of the vector :math:`f^I(t,y)`. + :param A: the output linear system matrix. + :param M: the current mass matrix (this input is ``NULL`` if :math:`M = I`). + :param jok: is an input flag indicating whether the Jacobian-related data + needs to be updated. The *jok* argument provides for the reuse of + Jacobian data. When *jok* = ``SUNFALSE``, the Jacobian-related data + should be recomputed from scratch. When *jok* = ``SUNTRUE`` the Jacobian + data, if saved from the previous call to this function, can be reused + (with the current value of *gamma*). A call with *jok* = ``SUNTRUE`` can + only occur after a call with *jok* = ``SUNFALSE``. + :param jcur: is a pointer to a flag which should be set to ``SUNTRUE`` if + Jacobian data was recomputed, or set to ``SUNFALSE`` if Jacobian data + was not recomputed, but saved data was still reused. + :param gamma: the scalar :math:`\gamma` appearing in the Newton system matrix + :math:`\mathcal{A}=M(t)-\gamma J(t,y)`. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + :param tmp*: pointers to memory allocated to variables of + type ``N_Vector`` which can be used by an ARKLsLinSysFn as temporary + storage or work space. + + :return: An *ARKLsLinSysFn* function should return 0 if successful, a positive value + if a recoverable error occurred (in which case ARKODE will attempt to + correct, while ARKLS sets *last_flag* to *ARKLS_JACFUNC_RECVR*), or a + negative value if it failed unrecoverably (in which case the integration is + halted, :c:func:`ARKodeEvolve` returns *ARK_LSETUP_FAIL* and ARKLS sets + *last_flag* to *ARKLS_JACFUNC_UNRECVR*). .. _ARKODE.Usage.JTimesFn: -Jacobian-vector product (matrix-free linear solvers, ARKStep and MRIStep only) ------------------------------------------------------------------------------- +Jacobian-vector product +----------------------- When using a matrix-free linear solver module for the implicit stage solves (i.e., a NULL-valued SUNMATRIX argument was supplied to -:c:func:`ARKStepSetLinearSolver` or :c:func:`MRIStepSetLinearSolver`, -the user may provide a function +:c:func:`ARKodeSetLinearSolver`, the user may provide a function of type :c:type:`ARKLsJacTimesVecFn` in the following form, to compute matrix-vector products :math:`Jv`. If such a function is not supplied, the default is a difference quotient approximation to these products. @@ -533,43 +537,40 @@ the default is a difference quotient approximation to these products. This function computes the product :math:`Jv` where :math:`J(t,y) \approx \dfrac{\partial f^I}{\partial y}(t,y)` (or an approximation to it). - **Arguments:** - * *v* -- the vector to multiply. - * *Jv* -- the output vector computed. - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *fy* -- the current value of the vector :math:`f^I(t,y)`. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData` - or :c:func:`MRIStepSetUserData`. - * *tmp* -- pointer to memory allocated to a variable of type - ``N_Vector`` which can be used as temporary storage or work space. - - **Return value:** - The value to be returned by the Jacobian-vector product - function should be 0 if successful. Any other return value will - result in an unrecoverable error of the generic Krylov solver, - in which case the integration is halted. - - **Notes:** + :param v: the vector to multiply. + :param Jv: the output vector computed. + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param fy: the current value of the vector :math:`f^I(t,y)`. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + :param tmp: pointer to memory allocated to a variable of type + ``N_Vector`` which can be used as temporary storage or work space. + + :return: The value to be returned by the Jacobian-vector product + function should be 0 if successful. Any other return value will + result in an unrecoverable error of the generic Krylov solver, + in which case the integration is halted. + + .. note:: + If the user's :c:type:`ARKLsJacTimesVecFn` function uses difference quotient approximations, it may need to access quantities not in the argument list. These include the current step size, the error weights, etc. To obtain these, the user will need to add a pointer to the ``ark_mem`` structure to - their ``user_data``, and then use the ``ARKStepGet*`` or ``MRIStepGet*`` - functions listed in :numref:`ARKODE.Usage.ARKStep.OptionalOutputs` or - :numref:`ARKODE.Usage.MRIStep.OptionalOutputs`. The unit roundoff can be - accessed as ``SUN_UNIT_ROUNDOFF``, which is defined in the header - file ``sundials_types.h``. + their ``user_data``, and then use the ``ARKodeGet*`` functions + listed in :numref:`ARKODE.Usage.OptionalOutputs`. The unit roundoff + can be accessed as ``SUN_UNIT_ROUNDOFF``, which is defined in the + header file ``sundials_types.h``. .. _ARKODE.Usage.JTSetupFn: -Jacobian-vector product setup (matrix-free linear solvers, ARKStep and MRIStep only) ------------------------------------------------------------------------------------- +Jacobian-vector product setup +----------------------------- If the user's Jacobian-times-vector routine requires that any Jacobian-related data be preprocessed or evaluated, then this needs to be done in a @@ -582,21 +583,19 @@ defined as follows: This function preprocesses and/or evaluates any Jacobian-related data needed by the Jacobian-times-vector routine. - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *fy* -- the current value of the vector :math:`f^I(t,y)`. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData` - or :c:func:`MRIStepSetUserData`. - - **Return value:** - The value to be returned by the Jacobian-vector setup - function should be 0 if successful, positive for a recoverable - error (in which case the step will be retried), or negative for an - unrecoverable error (in which case the integration is halted). - - **Notes:** + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param fy: the current value of the vector :math:`f^I(t,y)`. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + + :return: The value to be returned by the Jacobian-vector setup + function should be 0 if successful, positive for a recoverable + error (in which case the step will be retried), or negative for an + unrecoverable error (in which case the integration is halted). + + .. note:: + Each call to the Jacobian-vector setup function is preceded by a call to the implicit :c:type:`ARKRhsFn` user function with the same :math:`(t,y)` arguments. Thus, the setup @@ -608,20 +607,18 @@ defined as follows: quantities not in the argument list. These include the current step size, the error weights, etc. To obtain these, the user will need to add a pointer to the ``ark_mem`` structure to - their ``user_data``, and then use the ``ARKStepGet*`` or - ``MRIStepGet*`` functions listed in - :numref:`ARKODE.Usage.ARKStep.OptionalOutputs` or - :numref:`ARKODE.Usage.MRIStep.OptionalOutputs`. The unit roundoff can be - accessed as ``SUN_UNIT_ROUNDOFF``, which is defined in the header - file ``sundials_types.h``. + their ``user_data``, and then use the ``ARKodeGet*`` functions + listed in :numref:`ARKODE.Usage.OptionalOutputs`. The unit roundoff + can be accessed as ``SUN_UNIT_ROUNDOFF``, which is defined in the + header file ``sundials_types.h``. .. _ARKODE.Usage.PrecSolveFn: -Preconditioner solve (iterative linear solvers, ARKStep and MRIStep only) -------------------------------------------------------------------------- +Preconditioner solve +-------------------- If a user-supplied preconditioner is to be used with a SUNLinSol solver module, then the user must provide a function of type @@ -639,44 +636,41 @@ preconditioner matrices should approximate :math:`\mathcal{A}`. This function solves the preconditioner system :math:`Pz=r`. - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *fy* -- the current value of the vector :math:`f^I(t,y)`. - * *r* -- the right-hand side vector of the linear system. - * *z* -- the computed output solution vector. - * *gamma* -- the scalar :math:`\gamma` appearing in the Newton - matrix given by :math:`\mathcal{A}=M(t)-\gamma J(t,y)`. - * *delta* -- an input tolerance to be used if an iterative method - is employed in the solution. In that case, the residual vector - :math:`Res = r-Pz` of the system should be made to be less than *delta* - in the weighted :math:`l_2` norm, i.e. :math:`\left(\displaystyle \sum_{i=1}^n - \left(Res_i * ewt_i\right)^2 \right)^{1/2} < \delta`, where :math:`\delta =` - `delta`. To obtain the ``N_Vector`` *ewt*, call - :c:func:`ARKStepGetErrWeights` or :c:func:`MRIStepGetErrWeights`. - * *lr* -- an input flag indicating whether the preconditioner - solve is to use the left preconditioner (*lr* = 1) or the right - preconditioner (*lr* = 2). - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData` - or :c:func:`MRIStepSetUserData`. - - **Return value:** - The value to be returned by the preconditioner solve - function is a flag indicating whether it was successful. This value - should be 0 if successful, positive for a recoverable error (in - which case the step will be retried), or negative for an - unrecoverable error (in which case the integration is halted). + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param fy: the current value of the vector :math:`f^I(t,y)`. + :param r: the right-hand side vector of the linear system. + :param z: the computed output solution vector. + :param gamma: the scalar :math:`\gamma` appearing in the Newton + matrix given by :math:`\mathcal{A}=M(t)-\gamma J(t,y)`. + :param delta: an input tolerance to be used if an iterative method + is employed in the solution. In that case, the residual vector + :math:`Res = r-Pz` of the system should be made to be less than *delta* + in the weighted :math:`l_2` norm, i.e. :math:`\left(\displaystyle \sum_{i=1}^n + \left(Res_i * ewt_i\right)^2 \right)^{1/2} < \delta`, where :math:`\delta =` + `delta`. To obtain the ``N_Vector`` *ewt*, call + :c:func:`ARKodeGetErrWeights`. + :param lr: an input flag indicating whether the preconditioner + solve is to use the left preconditioner (*lr* = 1) or the right + preconditioner (*lr* = 2). + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + + :return: The value to be returned by the preconditioner solve + function is a flag indicating whether it was successful. This value + should be 0 if successful, positive for a recoverable error (in + which case the step will be retried), or negative for an + unrecoverable error (in which case the integration is halted). .. _ARKODE.Usage.PrecSetupFn: -Preconditioner setup (iterative linear solvers, ARKStep and MRIStep only) -------------------------------------------------------------------------- +Preconditioner setup +-------------------- -If the user's preconditioner routine requires that any data be +If the user's preconditioner routine above requires that any data be preprocessed or evaluated, then these actions need to occur within a user-supplied function of type :c:type:`ARKLsPrecSetupFn`. @@ -686,35 +680,33 @@ user-supplied function of type :c:type:`ARKLsPrecSetupFn`. This function preprocesses and/or evaluates Jacobian-related data needed by the preconditioner. - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *fy* -- the current value of the vector :math:`f^I(t,y)`. - * *jok* -- is an input flag indicating whether the Jacobian-related - data needs to be updated. The *jok* argument provides for the - reuse of Jacobian data in the preconditioner solve function. When - *jok* = ``SUNFALSE``, the Jacobian-related data should be recomputed - from scratch. When *jok* = ``SUNTRUE`` the Jacobian data, if saved from the - previous call to this function, can be reused (with the current - value of *gamma*). A call with *jok* = ``SUNTRUE`` can only occur - after a call with *jok* = ``SUNFALSE``. - * *jcurPtr* -- is a pointer to a flag which should be set to - ``SUNTRUE`` if Jacobian data was recomputed, or set to ``SUNFALSE`` if - Jacobian data was not recomputed, but saved data was still reused. - * *gamma* -- the scalar :math:`\gamma` appearing in the Newton - matrix given by :math:`\mathcal{A}=M(t)-\gamma J(t,y)`. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData` - or :c:func:`MRIStepSetUserData`. - - **Return value:** - The value to be returned by the preconditioner setup - function is a flag indicating whether it was successful. This value - should be 0 if successful, positive for a recoverable error (in - which case the step will be retried), or negative for an - unrecoverable error (in which case the integration is halted). - - **Notes:** + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param fy: the current value of the vector :math:`f^I(t,y)`. + :param jok: is an input flag indicating whether the Jacobian-related + data needs to be updated. The *jok* argument provides for the + reuse of Jacobian data in the preconditioner solve function. When + *jok* = ``SUNFALSE``, the Jacobian-related data should be recomputed + from scratch. When *jok* = ``SUNTRUE`` the Jacobian data, if saved from the + previous call to this function, can be reused (with the current + value of *gamma*). A call with *jok* = ``SUNTRUE`` can only occur + after a call with *jok* = ``SUNFALSE``. + :param jcurPtr: is a pointer to a flag which should be set to + ``SUNTRUE`` if Jacobian data was recomputed, or set to ``SUNFALSE`` if + Jacobian data was not recomputed, but saved data was still reused. + :param gamma: the scalar :math:`\gamma` appearing in the Newton + matrix given by :math:`\mathcal{A}=M(t)-\gamma J(t,y)`. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + + :return: The value to be returned by the preconditioner setup + function is a flag indicating whether it was successful. This value + should be 0 if successful, positive for a recoverable error (in + which case the step will be retried), or negative for an + unrecoverable error (in which case the integration is halted). + + .. note:: + The operations performed by this function might include forming a crude approximate Jacobian, and performing an LU factorization of the resulting approximation to :math:`\mathcal{A} = M(t) - @@ -739,9 +731,8 @@ user-supplied function of type :c:type:`ARKLsPrecSetupFn`. quantities not in the call list. These include the current step size, the error weights, etc. To obtain these, the user will need to add a pointer to the ``ark_mem`` structure to their - ``user_data``, and then use the ``ARKStepGet*`` or ``MRIStepGet*`` - functions listed in :numref:`ARKODE.Usage.ARKStep.OptionalOutputs` or - :numref:`ARKODE.Usage.MRIStep.OptionalOutputs`. The unit roundoff can be + ``user_data``, and then use the ``ARKodeGet*`` functions listed in + :numref:`ARKODE.Usage.OptionalOutputs`. The unit roundoff can be accessed as ``SUN_UNIT_ROUNDOFF``, which is defined in the header file ``sundials_types.h``. @@ -749,11 +740,12 @@ user-supplied function of type :c:type:`ARKLsPrecSetupFn`. .. _ARKODE.Usage.MassFn: -Mass matrix construction (matrix-based linear solvers, ARKStep only) --------------------------------------------------------------------- +Mass matrix construction +------------------------ -If a matrix-based mass-matrix linear solver is used (i.e., a non-NULL -SUNMATRIX was supplied to :c:func:`ARKStepSetMassLinearSolver`, the +For problems involving a non-identity mass matrix, if a matrix-based +mass-matrix linear solver is used (i.e., a non-NULL SUNMATRIX was +supplied to :c:func:`ARKodeSetMassLinearSolver`, the user must provide a function of type :c:type:`ARKLsMassFn` to provide the mass matrix approximation. @@ -763,23 +755,22 @@ the mass matrix approximation. This function computes the mass matrix :math:`M(t)` (or an approximation to it). - **Arguments:** - * *t* -- the current value of the independent variable. - * *M* -- the output mass matrix. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData()`. - * *tmp1*, *tmp2*, *tmp3* -- pointers to memory allocated to - variables of type ``N_Vector`` which can be used by an - ARKLsMassFn as temporary storage or work space. - - **Return value:** - An *ARKLsMassFn* function should return 0 if successful, or a - negative value if it failed unrecoverably (in which case the - integration is halted, :c:func:`ARKStepEvolve()` returns - *ARK_MASSSETUP_FAIL* and ARKLS sets *last_flag* to - *ARKLS_MASSFUNC_UNRECVR*). - - **Notes:** + :param t: the current value of the independent variable. + :param M: the output mass matrix. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + :param tmp1*: pointers to memory allocated to + variables of type ``N_Vector`` which can be used by an + ARKLsMassFn as temporary storage or work space. + + :return: An *ARKLsMassFn* function should return 0 if successful, or a + negative value if it failed unrecoverably (in which case the + integration is halted, :c:func:`ARKodeEvolve` returns + *ARK_MASSSETUP_FAIL* and ARKLS sets *last_flag* to + *ARKLS_MASSFUNC_UNRECVR*). + + .. note:: + Information regarding the structure of the specific ``SUNMatrix`` structure (e.g.~number of rows, upper/lower bandwidth, sparsity type) may be obtained through using the @@ -818,13 +809,14 @@ the mass matrix approximation. .. _ARKODE.Usage.MTimesFn: -Mass matrix-vector product (matrix-free linear solvers, ARKStep only) ---------------------------------------------------------------------- +Mass matrix-vector product +-------------------------- -If a matrix-free linear solver is to be used for mass-matrix linear -systems (i.e., a NULL-valued SUNMATRIX argument was supplied to -:c:func:`ARKStepSetMassLinearSolver()` in -:numref:`ARKODE.Usage.ARKStep.Skeleton`), the user *must* provide a +For problems involving a non-identity mass matrix, if a matrix-free +linear solver is to be used for mass-matrix linear systems (i.e., a +NULL-valued SUNMATRIX argument was supplied to +:c:func:`ARKodeSetMassLinearSolver` in +:numref:`ARKODE.Usage.Skeleton`), the user *must* provide a function of type :c:type:`ARKLsMassTimesVecFn` in the following form, to compute matrix-vector products :math:`M(t)\, v`. @@ -834,28 +826,27 @@ compute matrix-vector products :math:`M(t)\, v`. This function computes the product :math:`M(t)\, v` (or an approximation to it). - **Arguments:** - * *v* -- the vector to multiply. - * *Mv* -- the output vector computed. - * *t* -- the current value of the independent variable. - * *mtimes_data* -- a pointer to user data, the same as the - *mtimes_data* parameter that was passed to :c:func:`ARKStepSetMassTimes()`. + :param v: the vector to multiply. + :param Mv: the output vector computed. + :param t: the current value of the independent variable. + :param mtimes_data: a pointer to user data, the same as the *mtimes_data* + parameter that was passed to :c:func:`ARKodeSetMassTimes`. - **Return value:** - The value to be returned by the mass-matrix-vector product - function should be 0 if successful. Any other return value will - result in an unrecoverable error of the generic Krylov solver, - in which case the integration is halted. + :return: The value to be returned by the mass-matrix-vector product + function should be 0 if successful. Any other return value will + result in an unrecoverable error of the generic Krylov solver, + in which case the integration is halted. .. _ARKODE.Usage.MTSetupFn: -Mass matrix-vector product setup (matrix-free linear solvers, ARKStep only) ---------------------------------------------------------------------------- +Mass matrix-vector product setup +-------------------------------- -If the user's mass-matrix-times-vector routine requires that any mass -matrix-related data be preprocessed or evaluated, then this needs to +For problems involving a non-identity mass matrix and a matrix-free linear +solver, if the user's mass-matrix-times-vector routine requires that any +mass matrix-related data be preprocessed or evaluated, then this needs to be done in a user-supplied function of type :c:type:`ARKLsMassTimesSetupFn`, defined as follows: @@ -866,25 +857,24 @@ be done in a user-supplied function of type This function preprocesses and/or evaluates any mass-matrix-related data needed by the mass-matrix-times-vector routine. - **Arguments:** - * *t* -- the current value of the independent variable. - * *mtimes_data* -- a pointer to user data, the same as the - *mtimes_data* parameter that was passed to :c:func:`ARKStepSetMassTimes()`. + :param t: the current value of the independent variable. + :param mtimes_data: a pointer to user data, the same as the *mtimes_data* + parameter that was passed to :c:func:`ARKodeSetMassTimes`. - **Return value:** - The value to be returned by the mass-matrix-vector setup - function should be 0 if successful. Any other return value will - result in an unrecoverable error of the ARKLS mass matrix solver - interface, in which case the integration is halted. + :return: The value to be returned by the mass-matrix-vector setup + function should be 0 if successful. Any other return value will + result in an unrecoverable error of the ARKLS mass matrix solver + interface, in which case the integration is halted. .. _ARKODE.Usage.MassPrecSolveFn: -Mass matrix preconditioner solve (iterative linear solvers, ARKStep only) -------------------------------------------------------------------------- +Mass matrix preconditioner solve +-------------------------------- -If a user-supplied preconditioner is to be used with a SUNLINEAR +For problems involving a non-identity mass matrix and an iterative linear +solver, if a user-supplied preconditioner is to be used with a SUNLINEAR solver module for mass matrix linear systems, then the user must provide a function of type :c:type:`ARKLsMassPrecSolveFn` to solve the linear system :math:`Pz=r`, where :math:`P` may be either a left or right @@ -898,39 +888,38 @@ approximate :math:`M(t)`. This function solves the preconditioner system :math:`Pz=r`. - **Arguments:** - * *t* -- the current value of the independent variable. - * *r* -- the right-hand side vector of the linear system. - * *z* -- the computed output solution vector. - * *delta* -- an input tolerance to be used if an iterative method - is employed in the solution. In that case, the residual vector - :math:`Res = r-Pz` of the system should be made to be less than *delta* - in the weighted :math:`l_2` norm, i.e. :math:`\left(\displaystyle \sum_{i=1}^n - \left(Res_i * ewt_i\right)^2 \right)^{1/2} < \delta`, where :math:`\delta =` - *delta*. To obtain the ``N_Vector`` *ewt*, call - :c:func:`ARKStepGetErrWeights()`. - * *lr* -- an input flag indicating whether the preconditioner - solve is to use the left preconditioner (*lr* = 1) or the right - preconditioner (*lr* = 2). - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData()`. - - **Return value:** - The value to be returned by the preconditioner solve - function is a flag indicating whether it was successful. This value - should be 0 if successful, positive for a recoverable error (in - which case the step will be retried), or negative for an - unrecoverable error (in which case the integration is halted). + :param t: the current value of the independent variable. + :param r: the right-hand side vector of the linear system. + :param z: the computed output solution vector. + :param delta: an input tolerance to be used if an iterative method + is employed in the solution. In that case, the residual vector + :math:`Res = r-Pz` of the system should be made to be less than *delta* + in the weighted :math:`l_2` norm, i.e. :math:`\left(\displaystyle \sum_{i=1}^n + \left(Res_i * ewt_i\right)^2 \right)^{1/2} < \delta`, where :math:`\delta =` + *delta*. To obtain the ``N_Vector`` *ewt*, call + :c:func:`ARKodeGetErrWeights`. + :param lr: an input flag indicating whether the preconditioner + solve is to use the left preconditioner (*lr* = 1) or the right + preconditioner (*lr* = 2). + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. + + :return: The value to be returned by the preconditioner solve + function is a flag indicating whether it was successful. This value + should be 0 if successful, positive for a recoverable error (in + which case the step will be retried), or negative for an + unrecoverable error (in which case the integration is halted). .. _ARKODE.Usage.MassPrecSetupFn: -Mass matrix preconditioner setup (iterative linear solvers, ARKStep only) -------------------------------------------------------------------------- +Mass matrix preconditioner setup +-------------------------------- -If the user's mass matrix preconditioner above requires that any +For problems involving a non-identity mass matrix and an iterative linear +solver, if the user's mass matrix preconditioner above requires that any problem data be preprocessed or evaluated, then these actions need to occur within a user-supplied function of type :c:type:`ARKLsMassPrecSetupFn`. @@ -942,19 +931,18 @@ occur within a user-supplied function of type This function preprocesses and/or evaluates mass-matrix-related data needed by the preconditioner. - **Arguments:** - * *t* -- the current value of the independent variable. - * *user_data* -- a pointer to user data, the same as the - *user_data* parameter that was passed to :c:func:`ARKStepSetUserData()`. + :param t: the current value of the independent variable. + :param user_data: a pointer to user data, the same as the *user_data* + parameter that was passed to :c:func:`ARKodeSetUserData`. - **Return value:** - The value to be returned by the mass matrix preconditioner setup - function is a flag indicating whether it was successful. This value - should be 0 if successful, positive for a recoverable error (in - which case the step will be retried), or negative for an - unrecoverable error (in which case the integration is halted). + :return: The value to be returned by the mass matrix preconditioner setup + function is a flag indicating whether it was successful. This value + should be 0 if successful, positive for a recoverable error (in + which case the step will be retried), or negative for an + unrecoverable error (in which case the integration is halted). + + .. note:: - **Notes:** The operations performed by this function might include forming a mass matrix and performing an incomplete factorization of the result. Although such operations would @@ -976,8 +964,7 @@ Vector resize function For simulations involving changes to the number of equations and unknowns in the ODE system (e.g. when using spatial adaptivity in a PDE simulation), the ARKODE integrator may be "resized" between -integration steps, through calls to the :c:func:`ARKStepResize`, -:c:func:`ERKStepResize`, or :c:func:`MRIStepResize` +integration steps, through calls to the :c:func:`ARKodeResize` function. Typically, when performing adaptive simulations the solution is stored in a customized user-supplied data structure, to enable adaptivity without repeated allocation/deallocation of memory. In @@ -985,8 +972,7 @@ these scenarios, it is recommended that the user supply a customized vector kernel to interface between SUNDIALS and their problem-specific data structure. If this vector kernel includes a function of type :c:type:`ARKVecResizeFn` to resize a given vector implementation, then -this function may be supplied to :c:func:`ARKStepResize`, -:c:func:`ERKStepResize`, or :c:func:`MRIStepResize`, so that all +this function may be supplied to :c:func:`ARKodeResize` so that all internal ARKODE vectors may be resized, instead of deleting and re-creating them at each call. This resize function should have the following form: @@ -997,18 +983,16 @@ following form: This function resizes the vector *y* to match the dimensions of the supplied vector, *ytemplate*. - **Arguments:** - * *y* -- the vector to resize. - * *ytemplate* -- a vector of the desired size. - * *user_data* -- a pointer to user data, the same as the - *resize_data* parameter that was passed to :c:func:`ARKStepResize`, - :c:func:`ERKStepResize`, or :c:func:`MRIStepResize`. + :param y: the vector to resize. + :param ytemplate: a vector of the desired size. + :param user_data: a pointer to user data, the same as the *resize_data* + parameter that was passed to :c:func:`ARKodeResize`. + + :return: An *ARKVecResizeFn* function should return 0 if it successfully + resizes the vector *y*, and a non-zero value otherwise. - **Return value:** - An *ARKVecResizeFn* function should return 0 if it successfully - resizes the vector *y*, and a non-zero value otherwise. + .. note:: - **Notes:** If this function is not supplied, then ARKODE will instead destroy the vector *y* and clone a new vector *y* off of *ytemplate*. @@ -1029,20 +1013,19 @@ integrator for the inner integration. .. c:type:: int (*MRIStepPreInnerFn)(sunrealtype t, N_Vector* f, int num_vecs, void* user_data) - **Arguments:** - * *t* -- the current value of the independent variable. - * *f* -- an ``N_Vector`` array of outer forcing vectors. - * *num_vecs* -- the number of vectors in the ``N_Vector`` array. - * *user_data* -- the `user_data` pointer that was passed to - :c:func:`MRIStepSetUserData()`. + :param t: the current value of the independent variable. + :param f: an ``N_Vector`` array of outer forcing vectors. + :param num_vecs: the number of vectors in the ``N_Vector`` array. + :param user_data: the `user_data` pointer that was passed to + :c:func:`MRIStepSetUserData`. + + :return: An *MRIStepPreInnerFn* function should return 0 if successful, a positive value + if a recoverable error occurred, or a negative value if an unrecoverable + error occurred. As the MRIStep module only supports fixed step sizes at this + time any non-zero return value will halt the integration. - **Return value:** - An *MRIStepPreInnerFn* function should return 0 if successful, a positive value - if a recoverable error occurred, or a negative value if an unrecoverable - error occurred. As the MRIStep module only supports fixed step sizes at this - time any non-zero return value will halt the integration. + .. note:: - **Notes:** In a heterogeneous computing environment if any data copies between the host and device vector data are necessary, this is where that should occur. @@ -1060,19 +1043,18 @@ outer integrator for the outer integration. .. c:type:: int (*MRIStepPostInnerFn)(sunrealtype t, N_Vector y, void* user_data) - **Arguments:** - * *t* -- the current value of the independent variable. - * *y* -- the current value of the dependent variable vector. - * *user_data* -- the ``user_data`` pointer that was passed to - :c:func:`MRIStepSetUserData`. + :param t: the current value of the independent variable. + :param y: the current value of the dependent variable vector. + :param user_data: the ``user_data`` pointer that was passed to + :c:func:`MRIStepSetUserData`. - **Return value:** - An :c:func:`MRIStepPostInnerFn` function should return 0 if successful, a - positive value if a recoverable error occurred, or a negative value if an - unrecoverable error occurred. As the MRIStep module only supports fixed step - sizes at this time any non-zero return value will halt the integration. + :return: An :c:func:`MRIStepPostInnerFn` function should return 0 if successful, a + positive value if a recoverable error occurred, or a negative value if an + unrecoverable error occurred. As the MRIStep module only supports fixed step + sizes at this time any non-zero return value will halt the integration. + + .. note:: - **Notes:** In a heterogeneous computing environment if any data copies between the host and device vector data are necessary, this is where that should occur. @@ -1087,17 +1069,15 @@ Relaxation function When applying relaxation, an :c:func:`ARKRelaxFn` function is required to compute the conservative or dissipative function :math:`\xi(y)`. - **Arguments:** - * *y* -- the current value of the dependent variable vector. - * *r* -- the value of :math:`\xi(y)`. - * *user_data* -- the ``user_data`` pointer that was passed to - :c:func:`ARKStepSetUserData`. + :param y: the current value of the dependent variable vector. + :param r: the value of :math:`\xi(y)`. + :param user_data: the ``user_data`` pointer that was passed to + :c:func:`ARKodeSetUserData`. - **Return value:** - An :c:func:`ARKRelaxFn` function should return 0 if successful, a positive - value if a recoverable error occurred, or a negative value if an - unrecoverable error occurred. If a recoverable error occurs, the step size - will be reduced and the step repeated. + :return: An :c:func:`ARKRelaxFn` function should return 0 if successful, a positive + value if a recoverable error occurred, or a negative value if an + unrecoverable error occurred. If a recoverable error occurs, the step size + will be reduced and the step repeated. .. _ARKODE.Usage.RelaxJacFn: @@ -1110,14 +1090,12 @@ Relaxation Jacobian function compute the Jacobian :math:`\xi'(y)` of the :c:func:`ARKRelaxFn` :math:`\xi(y)`. - **Arguments:** - * *y* -- the current value of the dependent variable vector. - * *J* -- the Jacobian vector :math:`\xi'(y)`. - * *user_data* -- the ``user_data`` pointer that was passed to - :c:func:`ARKStepSetUserData`. - - **Return value:** - An :c:func:`ARKRelaxJacFn` function should return 0 if successful, a - positive value if a recoverable error occurred, or a negative value if an - unrecoverable error occurred. If a recoverable error occurs, the step size - will be reduced and the step repeated. + :param y: the current value of the dependent variable vector. + :param J: the Jacobian vector :math:`\xi'(y)`. + :param user_data: the ``user_data`` pointer that was passed to + :c:func:`ARKodeSetUserData`. + + :return: An :c:func:`ARKRelaxJacFn` function should return 0 if successful, a + positive value if a recoverable error occurred, or a negative value if an + unrecoverable error occurred. If a recoverable error occurs, the step size + will be reduced and the step repeated. diff --git a/doc/arkode/guide/source/Usage/index.rst b/doc/arkode/guide/source/Usage/index.rst index fba04368cd..2ecc9a671c 100644 --- a/doc/arkode/guide/source/Usage/index.rst +++ b/doc/arkode/guide/source/Usage/index.rst @@ -16,23 +16,66 @@ Using ARKODE ************ -This chapter discusses usage for ARKODE from C, C++ and Fortran applications. -The chapter builds upon :numref:`SUNDIALS`. We first discuss commonalities to -each of ARKODE's time-stepping modules, including locations and naming -conventions for the library and header files, and discussion of data types in -SUNDIALS. We then separately discuss the C and C++ interfaces to each of -ARKODE's time stepping modules: :ref:`ARKStep `, +This chapter discusses usage of ARKODE for the solution of initial value +problems (IVPs) in C, C++ and Fortran applications. The chapter builds upon +:numref:`SUNDIALS`. Unlike other packages in SUNDIALS, ARKODE provides an +infrastructure for one-step methods. However, ARKODE's individual +time-stepping methods, including definition of the IVP itself, are handled +by time-stepping modules that sit on top of ARKODE. While most of the +routines to use ARKODE generally apply to all of its time-stepping modules, +some of these apply to only a subset of these "steppers," while others are +specific to a given stepper. + +Thus, we organize this chapter as follows. We first discuss commonalities +to each of ARKODE's time-stepping modules. These commonalities include the +locations and naming conventions for the library and header files, data types +in SUNDIALS, the layout of the user's main program, and a variety of +user-callable and user-supplied functions. For these user-callable routines, +we distinguish those that apply for only a subset of ARKODE's time-stepping +modules. We then describe shared utilities that are supported by some of +ARKODE's time stepping modules, including "relaxation" methods and +preconitioners. Following our discussion of these commonalities, we +separately discuss the usage details that that are specific to each of ARKODE's +time stepping modules: :ref:`ARKStep `, :ref:`ERKStep `, :ref:`SPRKStep ` -and :ref:`MRIStep `. Following these, we describe the set of -:ref:`user-supplied routines ` -(both required and optional) that can be supplied to ARKODE. +and :ref:`MRIStep `. + +ARKODE also uses various input and output constants; these are defined as +needed throughout this chapter, but for convenience the full list is provided +separately in :numref:`ARKODE.Constants`. + +The example programs for ARKODE are located in the source code ``examples/arkode`` +folder. We note that these may be helpful as templates for new codes. Users +with applications written in Fortran should see the chapter +:numref:`SUNDIALS.Fortran`, which describes the Fortran interfaces for +SUNDIALS, and we additionally include multiple Fortran example programs +in the ARKODE ``examples`` directory. + +When solving problems with an implicit component, we note that not all +SUNLINSOL, SUNMATRIX, and preconditioning modules are compatible with +all NVECTOR implementations. Details on compatibility are given in the +documentation for each SUNMATRIX (see :numref:`SUNMatrix`) and each +SUNLINSOL module (see :numref:`SUNLinSol`). For example, NVECTOR_PARALLEL +is not compatible with the dense, banded, or sparse SUNMATRIX types, +or with the corresponding dense, banded, or sparse SUNLINSOL modules. +Please check :numref:`SUNMatrix` and :numref:`SUNLinSol` to +verify compatibility between these modules. In addition to that +documentation, we note that the ARKBANDPRE preconditioning module is +only compatible with the NVECTOR_SERIAL, NVECTOR_OPENMP or +NVECTOR_PTHREADS vector implementations, and the preconditioner module +ARKBBDPRE can only be used with NVECTOR_PARALLEL. + .. toctree:: :maxdepth: 1 - General.rst + General + Skeleton + User_callable + User_supplied + Relaxation + Preconditioners ARKStep_c_interface/index.rst ERKStep_c_interface/index.rst SPRKStep_c_interface/index.rst MRIStep_c_interface/index.rst - User_supplied.rst diff --git a/doc/arkode/guide/source/index.rst b/doc/arkode/guide/source/index.rst index 809a408329..e809010fd0 100644 --- a/doc/arkode/guide/source/index.rst +++ b/doc/arkode/guide/source/index.rst @@ -19,7 +19,7 @@ ARKODE Documentation This is the documentation for ARKODE, an adaptive step time integration package for stiff, nonstiff and mixed stiff/nonstiff systems of ordinary differential equations (ODEs) using Runge--Kutta -(i.e. one-step, multi-stage) methods. The ARKODE solver is a +(i.e., one-step, multi-stage) methods. The ARKODE solver is a component of the `SUNDIALS `_ suite of nonlinear and differential/algebraic equation solvers. It is designed diff --git a/doc/arkode/guide/source/sunnonlinsol/ARKODE_interface.rst b/doc/arkode/guide/source/sunnonlinsol/ARKODE_interface.rst index 5607ca9084..fe7f768419 100644 --- a/doc/arkode/guide/source/sunnonlinsol/ARKODE_interface.rst +++ b/doc/arkode/guide/source/sunnonlinsol/ARKODE_interface.rst @@ -74,8 +74,128 @@ access to the internal integrator data required to evaluate :eq:`ARKODE_Residual_corrector` or :eq:`ARKODE_FixedPt_corrector`. -ARKStep advanced output functions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +ARKODE advanced output functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Two notable functions were already listed in :numref:`ARKODE.Usage.ARKodeMainOutputs`: + +* :c:func:`ARKodeGetCurrentState` -- returns the current state vector. + When called within the computation of a step (i.e., during a nonlinear solve) + this is the current stage state vector :math:`z_i = z_{pred} + z_{cor}`. + Otherwise this is the current internal solution state vector :math:`y(t)`. In + either case the corresponding stage or solution time can be obtained from + :c:func:`ARKodeGetCurrentTime`. + +* :c:func:`ARKodeGetCurrentGamma` -- returns the current value of the scalar :math:`\gamma`. + + +Additional advanced output functions that are provided to aid in the construction +of user-supplied SUNNonlinSol modules are as follows. + +.. c:function:: int ARKodeGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M) + + Returns the current mass matrix. For a time dependent mass matrix the + corresponding time can be obtained from :c:func:`ARKodeGetCurrentTime`. + + **Arguments:** + * *arkode_mem* -- pointer to the ARKODE memory block. + * *M* -- SUNMatrix pointer that will get set to the current mass matrix + :math:`M(t)`. If a matrix-free method is used the output is ``NULL``. + + **Return value:** + * ``ARK_SUCCESS`` if successful. + * ``ARK_MEM_NULL`` if the ARKStep memory was ``NULL``. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + +.. c:function:: int ARKodeGetNonlinearSystemData(void* arkode_mem, sunrealtype *tcur, N_Vector *zpred, N_Vector *z, N_Vector *Fi, sunrealtype *gamma, N_Vector *sdata, void **user_data) + + Returns all internal data required to construct the current nonlinear + implicit system :eq:`ARKODE_Residual_corrector` or :eq:`ARKODE_FixedPt_corrector`: + + **Arguments:** + * *arkode_mem* -- pointer to the ARKODE memory block. + * *tcur* -- value of the independent variable corresponding to implicit + stage, :math:`t^I_{n,i}`. + * *zpred* -- the predicted stage vector :math:`z_{pred}` at + :math:`t^I_{n,i}`. This vector must not be changed. + * *z* -- the stage vector :math:`z_{i}` above. This vector may be not + current and may need to be filled (see the note below). + * *Fi* -- the implicit function evaluated at the current time and state, + :math:`f^I(t^I_{n,i}, z_{i})`. This vector may be not current and may + need to be filled (see the note below). + * *gamma* -- current :math:`\gamma` for implicit stage calculation. + * *sdata* -- accumulated data from previous solution and stages, + :math:`\tilde{a}_i`. This vector must not be changed. + * *user_data* -- pointer to the user-defined data structure (as specified + through :c:func:`ARKodeSetUserData`, or ``NULL`` otherwise) + + **Return value:** + * ``ARK_SUCCESS`` if successful. + * ``ARK_MEM_NULL`` if the ARKODE memory was ``NULL``. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + This routine is intended for users who whish to attach a custom + :c:type:`SUNNonlinSolSysFn` to an existing ``SUNNonlinearSolver`` object + (through a call to :c:func:`SUNNonlinSolSetSysFn`) or who need access to + nonlinear system data to compute the nonlinear system function as part of + a custom ``SUNNonlinearSolver`` object. + + When supplying a custom :c:type:`SUNNonlinSolSysFn` to an existing + ``SUNNonlinearSolver`` object, the user should call + :c:func:`ARKodeGetNonlinearSystemData()` **inside** the nonlinear system + function to access the requisite data for evaluting the nonlinear systen + function of their choosing. Additionlly, if the ``SUNNonlinearSolver`` object + (existing or custom) leverages the :c:type:`SUNNonlinSolLSetupFn` and/or + :c:type:`SUNNonlinSolLSolveFn` functions supplied by ARKODE (through + calls to :c:func:`SUNNonlinSolSetLSetupFn()` and + :c:func:`SUNNonlinSolSetLSolveFn()` respectively) the vectors *z* and *Fi* + **must be filled** in by the user's :c:type:`SUNNonlinSolSysFn` with the + current state and corresponding evaluation of the right-hand side function + respectively i.e., + + .. math:: + z &= z_{pred} + z_{cor}, \\ + Fi &= f^I\left(t^I_{n,i}, z_i\right), + + where :math:`z_{cor}` was the first argument supplied to the + :c:type:`SUNNonlinSolSysFn`. + + If this function is called as part of a custom linear solver (i.e., the + default :c:type:`SUNNonlinSolSysFn` is used) then the vectors *z* and + *Fi* are only current when :c:func:`ARKodeGetNonlinearSystemData()` is + called after an evaluation of the nonlinear system function. + + +.. c:function:: int ARKodeComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) + + Computes the current stage state vector using the stored prediction and the + supplied correction from the nonlinear solver i.e., + :math:`z_i(t) = z_{pred} + z_{cor}`. + + **Arguments:** + * *arkode_mem* -- pointer to the ARKODE memory block. + * *zcor* -- the correction from the nonlinear solver. + * *z* -- on output, the current stage state vector :math:`z_i`. + + **Return value:** + * ``ARK_SUCCESS`` if successful. + * ``ARK_MEM_NULL`` if the ARKODE memory was ``NULL``. + + .. note:: + + This is only compatible with time-stepping modules that support implicit algebraic solvers. + + + +ARKStep advanced output functions (deprecated) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Two notable functions were already listed in :numref:`ARKODE.Usage.ARKStep.ARKStepMainOutputs`: @@ -106,6 +226,10 @@ of user-supplied SUNNonlinSol modules are as follows. * ``ARK_SUCCESS`` if successful. * ``ARK_MEM_NULL`` if the ARKStep memory was ``NULL``. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetCurrentMassMatrix` instead. + .. c:function:: int ARKStepGetNonlinearSystemData(void* arkode_mem, sunrealtype *tcur, N_Vector *zpred, N_Vector *z, N_Vector *Fi, sunrealtype *gamma, N_Vector *sdata, void **user_data) @@ -166,6 +290,10 @@ of user-supplied SUNNonlinSol modules are as follows. *Fi* are only current when :c:func:`ARKStepGetNonlinearSystemData()` is called after an evaluation of the nonlinear system function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNonlinearSystemData` instead. + .. c:function:: int ARKStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) @@ -182,10 +310,13 @@ of user-supplied SUNNonlinSol modules are as follows. * ``ARK_SUCCESS`` if successful. * ``ARK_MEM_NULL`` if the ARKStep memory was ``NULL``. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeComputeState` instead. -MRIStep advanced output functions -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +MRIStep advanced output functions (deprecated) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Two notable functions were already listed in :numref:`ARKODE.Usage.MRIStep.MRIStepMainOutputs`: @@ -262,6 +393,10 @@ of user-supplied SUNNonlinSol modules are as follows. *Fi* are only current when :c:func:`MRIStepGetNonlinearSystemData()` is called after an evaluation of the nonlinear system function. + .. deprecated:: x.y.z + + Use :c:func:`ARKodeGetNonlinearSystemData` instead. + .. c:function:: int MRIStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) @@ -277,3 +412,7 @@ of user-supplied SUNNonlinSol modules are as follows. **Return value:** * ``ARK_SUCCESS`` if successful. * ``ARK_MEM_NULL`` if the MRIStep memory was ``NULL``. + + .. deprecated:: x.y.z + + Use :c:func:`ARKodeComputeState` instead. diff --git a/doc/shared/RecentChanges.rst b/doc/shared/RecentChanges.rst index a6a43884bd..f4135699b5 100644 --- a/doc/shared/RecentChanges.rst +++ b/doc/shared/RecentChanges.rst @@ -1,8 +1,5 @@ **New Features** -Added CMake infrastructure that enables externally maintained addons/plugins -to be *optionally* built with SUNDIALS. See :ref:`Contributing` for details. - Added Multirate time step adaptivity controllers, based on the recently introduced `SUNAdaptController` base class, to ARKODE's MRIStep module. @@ -12,6 +9,21 @@ estimate over multiple time steps. See the routines :c:func:`ARKStepSetAccumula :c:func:`ERKStepSetAccumulatedErrorType`, :c:func:`ERKStepResetAccumulatedError`, and :c:func:`ERKStepGetAccumulatedError` for details. +Created shared user interface for ARKODE user-callable routines, to allow more +uniform control over time-stepping algorithms, improved extensibility, and +simplified code maintenance. Marked the corresponding stepper-specific +user-callable routines as deprecated; these will be removed in a future major +release. + +Added "Resize" capability, as well as missing ``SetRootDirection`` and +``SetNoInactiveRootWarn`` functions, to ARKODE's SPRKStep time-stepping module. + +Deprecated ``ARKStepSetOptimalParams`` function; added instructions to user guide +for users who wish to retain the current functionality. + +Added CMake infrastructure that enables externally maintained addons/plugins +to be *optionally* built with SUNDIALS. See :ref:`Contributing` for details. + **Bug Fixes** Updated the CMake variable ``HIP_PLATFORM`` default to ``amd`` as the previous @@ -35,3 +47,7 @@ produced from evolving the inner stepper. Added support for Kokkos Kernels v4. Fixed a bug that caused error messages to be cut off in some cases. Fixes `GitHub Issue #461 `_. + +Fixed a memory leak when an error handler was added to a :c:type:`SUNContext`. Fixes `GitHub Issue #466 `_. + +Fixed a CMake bug that caused an MPI linking error for our C++ examples in some instances. Fixes `GitHub Issue #464 `_. diff --git a/doc/shared/nvectors/NVector_Description.rst b/doc/shared/nvectors/NVector_Description.rst index 8c197fd7b6..f9ca95f18c 100644 --- a/doc/shared/nvectors/NVector_Description.rst +++ b/doc/shared/nvectors/NVector_Description.rst @@ -329,7 +329,7 @@ routines these functions will ease the introduction of any new optional vector operations to the NVECTOR API by ensuring that only required operations need to be set, and that all operations are copied when cloning a vector. -.. c:function:: N_Vector N_VNewEmpty() +.. c:function:: N_Vector N_VNewEmpty(SUNContext sunctx) This allocates a new generic ``N_Vector`` object and initializes its content pointer and the function pointers in the operations structure to ``NULL``. diff --git a/doc/shared/sundials/Errors.rst b/doc/shared/sundials/Errors.rst index 3b5c6a8748..20cbcc5405 100644 --- a/doc/shared/sundials/Errors.rst +++ b/doc/shared/sundials/Errors.rst @@ -96,7 +96,7 @@ Specific error handlers can be enabled by pushing them onto the error handler st with the function :c:func:`SUNContext_PushErrHandler`. They may disabled by calling :c:func:`SUNContext_PopErrHandler` or :c:func:`SUNContext_ClearErrHandlers`. A SUNDIALS error handler function has the type -.. c:type:: int (*SUNErrHandlerFn)(int line, const char* func, const char* file, \ +.. c:type:: void (*SUNErrHandlerFn)(int line, const char* func, const char* file, \ const char* msg, SUNErrCode err_code, \ void* err_user_data, SUNContext sunctx) diff --git a/doc/shared/sunlinsol/SUNLinSol_API.rst b/doc/shared/sunlinsol/SUNLinSol_API.rst index 3f6436d249..ad1be8c5ae 100644 --- a/doc/shared/sunlinsol/SUNLinSol_API.rst +++ b/doc/shared/sunlinsol/SUNLinSol_API.rst @@ -765,7 +765,7 @@ constructors this function will ease the introduction of any new optional linear solver operations to the ``SUNLinearSolver`` API by ensuring that only required operations need to be set. -.. c:function:: SUNLinearSolver SUNLinSolNewEmpty() +.. c:function:: SUNLinearSolver SUNLinSolNewEmpty(SUNContext sunctx) This function allocates a new generic ``SUNLinearSolver`` object and initializes its content pointer and the function pointers in the operations diff --git a/doc/shared/sunmatrix/SUNMatrix_Description.rst b/doc/shared/sunmatrix/SUNMatrix_Description.rst index b74555c31d..e60b31e097 100644 --- a/doc/shared/sunmatrix/SUNMatrix_Description.rst +++ b/doc/shared/sunmatrix/SUNMatrix_Description.rst @@ -118,7 +118,7 @@ routines these functions will ease the introduction of any new optional matrix operations to the SUNMATRIX API by ensuring only required operations need to be set and all operations are copied when cloning a matrix. -.. c:function:: SUNMatrix SUNMatNewEmpty() +.. c:function:: SUNMatrix SUNMatNewEmpty(SUNContext sunctx) This function allocates a new generic ``SUNMatrix`` object and initializes its content pointer and the function pointers in the operations structure to ``NULL``. diff --git a/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst b/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst index 6a21325a19..aef87888b2 100644 --- a/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst +++ b/doc/shared/sunnonlinsol/SUNNonlinSol_API.rst @@ -588,7 +588,7 @@ introduction of any new optional nonlinear solver operations to the ``SUNNonlinearSolver`` API by ensuring that only required operations need to be set. -.. c:function:: SUNNonlinearSolver SUNNonlinSolNewEmpty() +.. c:function:: SUNNonlinearSolver SUNNonlinSolNewEmpty(SUNContext sunctx) This function allocates a new generic ``SUNNonlinearSolver`` object and initializes its content pointer and the function pointers in the operations diff --git a/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp b/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp index a1f583cbd7..8bee143d0b 100644 --- a/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp +++ b/examples/arkode/CXX_parallel/ark_brusselator1D_task_local_nls.cpp @@ -246,20 +246,20 @@ int EvolveProblemIMEX(SUNContext ctx, N_Vector y, UserData* udata, if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Select the method order */ - retval = ARKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ARKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } /* Attach user data */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData*", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData*", 1)) { return 1; } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Create the (non)linear solver */ if (uopt->global) @@ -269,20 +269,20 @@ int EvolveProblemIMEX(SUNContext ctx, N_Vector y, UserData* udata, if (check_retval((void*)NLS, "SUNNonlinSol_Newton", 0)) { return 1; } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1)) { return 1; } + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1)) { return 1; } /* Create linear solver */ LS = SUNLinSol_SPGMR(y, SUN_PREC_LEFT, 0, ctx); if (check_retval((void*)LS, "SUNLinSol_SPGMR", 0)) { return 1; } /* Attach linear solver */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Attach preconditioner */ - retval = ARKStepSetPreconditioner(arkode_mem, NULL, PSolve); - if (check_retval(&retval, "ARKStepSetPreconditioner", 1)) { return 1; } + retval = ARKodeSetPreconditioner(arkode_mem, NULL, PSolve); + if (check_retval(&retval, "ARKodeSetPreconditioner", 1)) { return 1; } } else { @@ -292,8 +292,8 @@ int EvolveProblemIMEX(SUNContext ctx, N_Vector y, UserData* udata, if (check_retval((void*)NLS, "TaskLocalNewton", 0)) { return 1; } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1)) { return 1; } + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1)) { return 1; } } /* Output initial condition */ @@ -313,8 +313,8 @@ int EvolveProblemIMEX(SUNContext ctx, N_Vector y, UserData* udata, do { /* Integrate to output time */ - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* Output state */ WriteOutput(t, y, udata, uopt); @@ -328,24 +328,24 @@ int EvolveProblemIMEX(SUNContext ctx, N_Vector y, UserData* udata, while (iout < uopt->nout); /* Get final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncnf); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncnf); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1); if (uopt->global) { - retval = ARKStepGetNumLinIters(arkode_mem, &nli); - check_retval(&retval, "ARKStepGetNumLinIters", 1); - retval = ARKStepGetNumPrecSolves(arkode_mem, &npsol); - check_retval(&retval, "ARKStepGetNumPrecSolves", 1); + retval = ARKodeGetNumLinIters(arkode_mem, &nli); + check_retval(&retval, "ARKodeGetNumLinIters", 1); + retval = ARKodeGetNumPrecSolves(arkode_mem, &npsol); + check_retval(&retval, "ARKodeGetNumPrecSolves", 1); } /* Print final statistics */ @@ -366,7 +366,7 @@ int EvolveProblemIMEX(SUNContext ctx, N_Vector y, UserData* udata, } /* Clean up */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNNonlinSolFree(NLS); if (LS) { SUNLinSolFree(LS); } @@ -390,20 +390,20 @@ int EvolveProblemExplicit(SUNContext ctx, N_Vector y, UserData* udata, if (check_retval((void*)arkode_mem, "ERKStepCreate", 0)) { return 1; } /* Select the method order */ - retval = ERKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ERKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } /* Attach user data */ - retval = ERKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ERKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Specify tolerances */ - retval = ERKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ERKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Output initial condition */ if (udata->myid == 0 && uopt->monitor) @@ -422,8 +422,8 @@ int EvolveProblemExplicit(SUNContext ctx, N_Vector y, UserData* udata, do { /* Integrate to output time */ - retval = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* Output state */ WriteOutput(t, y, udata, uopt); @@ -437,14 +437,14 @@ int EvolveProblemExplicit(SUNContext ctx, N_Vector y, UserData* udata, while (iout < uopt->nout); /* Get final statistics */ - retval = ERKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ERKStepGetNumSteps", 1); - retval = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ERKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ERKStepGetNumRhsEvals(arkode_mem, &nfe); check_retval(&retval, "ERKStepGetNumRhsEvals", 1); - retval = ERKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ERKStepGetNumErrTestFails", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); /* Print final statistics */ if (udata->myid == 0) @@ -456,7 +456,7 @@ int EvolveProblemExplicit(SUNContext ctx, N_Vector y, UserData* udata, } /* Clean up */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* Return success */ return (0); @@ -911,9 +911,9 @@ int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) double tcur, gamma; void* user_data; - retval = ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, - &gamma, &sdata, &user_data); - if (check_retval((void*)&retval, "ARKStepGetNonlinearSystemData", 1)) + retval = ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, + &gamma, &sdata, &user_data); + if (check_retval((void*)&retval, "ARKodeGetNonlinearSystemData", 1)) { return (-1); } @@ -956,9 +956,9 @@ int TaskLocalLSolve(N_Vector delta, void* arkode_mem) double tcur, gamma; void* user_data = NULL; - retval = ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, - &gamma, &sdata, &user_data); - if (check_retval((void*)&retval, "ARKStepGetNonlinearSystemData", 1)) + retval = ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, + &gamma, &sdata, &user_data); + if (check_retval((void*)&retval, "ARKodeGetNonlinearSystemData", 1)) { return (-1); } diff --git a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp index d70b4d680c..63108a9bd2 100644 --- a/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp +++ b/examples/arkode/CXX_parallel/ark_diffusion_reaction_p.cpp @@ -611,16 +611,8 @@ int main(int argc, char* argv[]) udata.evolve.start(); // Evolve - if (udata.integrator) - { - flag = MRIStepEvolve(arkode_mem, tout, u, &t, stepmode); - if (check_flag(&flag, "MRIStepEvolve", 1)) { break; } - } - else - { - flag = ARKStepEvolve(arkode_mem, tout, u, &t, stepmode); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } - } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, stepmode); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer udata.evolve.stop(); @@ -678,14 +670,14 @@ int main(int argc, char* argv[]) switch (udata.integrator) { - case (0): ARKStepFree(&arkode_mem); break; + case (0): ARKodeFree(&arkode_mem); break; case (1): { void* inner_arkode_mem = NULL; MRIStepInnerStepper_GetContent(stepper, &inner_arkode_mem); - ARKStepFree(&inner_arkode_mem); + ARKodeFree(&inner_arkode_mem); MRIStepInnerStepper_Free(&stepper); - MRIStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); break; } case (2): @@ -698,7 +690,7 @@ int main(int argc, char* argv[]) delete content; MRIStepInnerStepper_Free(&stepper); SUNNonlinSolFree(NLS); - MRIStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); break; } default: cerr << "Invalid integrator option" << endl; break; @@ -928,51 +920,51 @@ static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u, if (check_flag((void*)*arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(*arkode_mem, udata->rtol_imex, udata->atol_imex); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(*arkode_mem, udata->rtol_imex, udata->atol_imex); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(*arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } if (udata->diffusion) { // Attach linear solver - flag = ARKStepSetLinearSolver(*arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(*arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(*arkode_mem, NULL, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(*arkode_mem, NULL, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(*arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(*arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(*arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(*arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(*arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(*arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } } // Select method order - flag = ARKStepSetOrder(*arkode_mem, udata->order_imex); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(*arkode_mem, udata->order_imex); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } // Set fixed step size or adaptivity method if (udata->h_imex > ZERO) { - flag = ARKStepSetFixedStep(*arkode_mem, udata->h_imex); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, udata->h_imex); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -985,17 +977,17 @@ static int SetupARK(SUNContext ctx, UserData* udata, N_Vector u, case (ARK_ADAPT_IMP_GUS): *Ctrl = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): *Ctrl = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(*arkode_mem, *Ctrl); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(*arkode_mem, *Ctrl); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(*arkode_mem, udata->maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(*arkode_mem, udata->tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } return 0; } @@ -1015,23 +1007,22 @@ static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y, if (check_flag((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(inner_arkode_mem, udata->rtol_fast, - udata->atol_fast); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(inner_arkode_mem, udata->rtol_fast, udata->atol_fast); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(inner_arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(inner_arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Select method order - flag = ARKStepSetOrder(inner_arkode_mem, udata->order_fast); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(inner_arkode_mem, udata->order_fast); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } // Set fixed step size or adaptivity method if (udata->h_fast > ZERO) { - flag = ARKStepSetFixedStep(inner_arkode_mem, udata->h_fast); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(inner_arkode_mem, udata->h_fast); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -1044,13 +1035,13 @@ static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y, case (ARK_ADAPT_IMP_GUS): *Ctrl = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): *Ctrl = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(inner_arkode_mem, *Ctrl); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(inner_arkode_mem, *Ctrl); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(inner_arkode_mem, udata->maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(inner_arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Wrap ARKODE as an MRIStepInnerStepper flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, stepper); @@ -1075,50 +1066,50 @@ static int SetupMRI(SUNContext ctx, UserData* udata, N_Vector y, MRIStepCoupling_Free(C); // Set the slow step size - flag = MRIStepSetFixedStep(*arkode_mem, udata->h_slow); - if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, udata->h_slow); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } // Specify tolerances - flag = MRIStepSStolerances(*arkode_mem, udata->rtol_slow, udata->atol_slow); - if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(*arkode_mem, udata->rtol_slow, udata->atol_slow); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = MRIStepSetUserData(*arkode_mem, (void*)udata); - if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = MRIStepSetLinearSolver(*arkode_mem, LS, NULL); - if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(*arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = MRIStepSetPreconditioner(*arkode_mem, NULL, PSolve); - if (check_flag(&flag, "MRIStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(*arkode_mem, NULL, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = MRIStepSetLSetupFrequency(*arkode_mem, udata->msbp); - if (check_flag(&flag, "MRIStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(*arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = MRIStepSetEpsLin(*arkode_mem, udata->epslin); - if (check_flag(&flag, "MRIStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(*arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = MRIStepSetLinear(*arkode_mem, 0); - if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(*arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = MRIStepSetMaxNumSteps(*arkode_mem, udata->maxsteps); - if (check_flag(&flag, "MRIStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = MRIStepSetStopTime(*arkode_mem, udata->tf); - if (check_flag(&flag, "MRIStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } return 0; } @@ -1219,50 +1210,50 @@ static int SetupMRICVODE(SUNContext ctx, UserData* udata, N_Vector y, MRIStepCoupling_Free(C); // Set the slow step size - flag = MRIStepSetFixedStep(*arkode_mem, udata->h_slow); - if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, udata->h_slow); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } // Specify tolerances - flag = MRIStepSStolerances(*arkode_mem, udata->rtol_slow, udata->atol_slow); - if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(*arkode_mem, udata->rtol_slow, udata->atol_slow); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = MRIStepSetUserData(*arkode_mem, (void*)udata); - if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = MRIStepSetLinearSolver(*arkode_mem, LS, NULL); - if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(*arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = MRIStepSetPreconditioner(*arkode_mem, NULL, PSolve); - if (check_flag(&flag, "MRIStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(*arkode_mem, NULL, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = MRIStepSetLSetupFrequency(*arkode_mem, udata->msbp); - if (check_flag(&flag, "MRIStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(*arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = MRIStepSetEpsLin(*arkode_mem, udata->epslin); - if (check_flag(&flag, "MRIStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(*arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = MRIStepSetLinear(*arkode_mem, 0); - if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(*arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = MRIStepSetMaxNumSteps(*arkode_mem, udata->maxsteps); - if (check_flag(&flag, "MRIStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = MRIStepSetStopTime(*arkode_mem, udata->tf); - if (check_flag(&flag, "MRIStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } return 0; } @@ -2603,31 +2594,31 @@ static int OutputStatsIMEX(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } if (udata->diffusion) { - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } } cout << fixed; @@ -2663,10 +2654,10 @@ static int OutputStatsIMEX(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; @@ -2685,24 +2676,24 @@ static int OutputStatsMRI(void* arkode_mem, MRIStepInnerStepper stepper, // Get slow integrator and solver stats long int nsts, nfse, nfsi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = MRIStepGetNumSteps(arkode_mem, &nsts); - if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nsts); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } flag = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return -1; } - flag = MRIStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = MRIStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = MRIStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "MRIStepGetNumLinIters", 1)) { return -1; } - flag = MRIStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "MRIStepGetNumLinConvFails", 1)) { return -1; } - flag = MRIStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return -1; } - flag = MRIStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "MRIStepGetNumLinRhsEvals", 1)) { return -1; } - flag = MRIStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "MRIStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -2731,10 +2722,10 @@ static int OutputStatsMRI(void* arkode_mem, MRIStepInnerStepper stepper, if (udata->prec) { long int npe, nps; - flag = MRIStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "MRIStepGetNumPrecEvals", 1)) { return -1; } - flag = MRIStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "MRIStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; @@ -2747,12 +2738,12 @@ static int OutputStatsMRI(void* arkode_mem, MRIStepInnerStepper stepper, long int nstf, nstf_a, netff, nffe, nffi; - flag = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(inner_arkode_mem, &nstf_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(inner_arkode_mem, &netff); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(inner_arkode_mem, &nstf_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(inner_arkode_mem, &nffe, &nffi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } @@ -2773,24 +2764,24 @@ static int OutputStatsMRICVODE(void* arkode_mem, MRIStepInnerStepper stepper, // Get slow integrator and solver stats long int nsts, nfse, nfsi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = MRIStepGetNumSteps(arkode_mem, &nsts); - if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nsts); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } flag = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return -1; } - flag = MRIStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = MRIStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = MRIStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "MRIStepGetNumLinIters", 1)) { return -1; } - flag = MRIStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "MRIStepGetNumLinConvFails", 1)) { return -1; } - flag = MRIStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return -1; } - flag = MRIStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "MRIStepGetNumLinRhsEvals", 1)) { return -1; } - flag = MRIStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "MRIStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -2819,10 +2810,10 @@ static int OutputStatsMRICVODE(void* arkode_mem, MRIStepInnerStepper stepper, if (udata->prec) { long int npe, nps; - flag = MRIStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "MRIStepGetNumPrecEvals", 1)) { return -1; } - flag = MRIStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "MRIStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; diff --git a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp index 5c1a264c8f..78a25fa210 100644 --- a/examples/arkode/CXX_parallel/ark_heat2D_p.cpp +++ b/examples/arkode/CXX_parallel/ark_heat2D_p.cpp @@ -41,7 +41,7 @@ * problem is advanced in time with a diagonally implicit Runge-Kutta method * using an inexact Newton method paired with the PCG or SPGMR linear solver. * Several command line options are available to change the problem parameters - * and ARKStep settings. Use the flag --help for more information. + * and ARKODE settings. Use the flag --help for more information. * ---------------------------------------------------------------------------*/ #include @@ -382,7 +382,7 @@ int main(int argc, char* argv[]) } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -390,38 +390,38 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -445,8 +445,8 @@ int main(int argc, char* argv[]) // Set fixed step size or adaptivity method if (udata->hfixed > ZERO) { - flag = ARKStepSetFixedStep(arkode_mem, udata->hfixed); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, udata->hfixed); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -459,24 +459,24 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(arkode_mem, udata->maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(arkode_mem, udata->tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -499,8 +499,8 @@ int main(int argc, char* argv[]) t1 = MPI_Wtime(); // Evolve in time - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer t2 = MPI_Wtime(); @@ -560,10 +560,10 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; (void)SUNAdaptController_Destroy(C); // Free timestep adaptivity controller SUNContext_Free(&ctx); // Free context @@ -1820,28 +1820,28 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -1870,10 +1870,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp index 7b2031e540..09e95bc328 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp @@ -41,7 +41,7 @@ * problem is advanced in time with a diagonally implicit Runge-Kutta method * using an inexact Newton method paired with the hypre's PCG or GMRES linear * solver and PFMG preconditioner. Several command line options are available - * to change the problem parameters and ARKStep settings. Use the flag --help + * to change the problem parameters and ARKODE settings. Use the flag --help * for more information. * ---------------------------------------------------------------------------*/ @@ -439,7 +439,7 @@ int main(int argc, char* argv[]) if (check_flag((void*)LS, "HypreLS", 0)) { return 1; } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -447,35 +447,35 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } // Specify the Jacobian evaluation function - flag = ARKStepSetJacFn(arkode_mem, Jac); - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } // Set linear solver setup frequency (update linear system matrix) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -499,8 +499,8 @@ int main(int argc, char* argv[]) // Set fixed step size or adaptivity method if (udata->hfixed > ZERO) { - flag = ARKStepSetFixedStep(arkode_mem, udata->hfixed); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, udata->hfixed); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -513,24 +513,24 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(arkode_mem, udata->maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(arkode_mem, udata->tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -553,8 +553,8 @@ int main(int argc, char* argv[]) t1 = MPI_Wtime(); // Evolve in time - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer t2 = MPI_Wtime(); @@ -614,11 +614,11 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - SUNMatDestroy(A); // Free matrix - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + SUNMatDestroy(A); // Free matrix + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; (void)SUNAdaptController_Destroy(C); // Free time adaptivity controller SUNContext_Free(&ctx); // Free context @@ -2120,26 +2120,26 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nJeval; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumJacEvals(arkode_mem, &nJeval); - if (check_flag(&flag, "ARKStepGetNumJacEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumJacEvals(arkode_mem, &nJeval); + if (check_flag(&flag, "ARKodeGetNumJacEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp index eeb61d0af4..bb541e41d6 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp @@ -41,7 +41,7 @@ * problem is advanced in time with a diagonally implicit Runge-Kutta method * using an inexact Newton method paired with the PCG or SPGMR linear solver * using hypre's PFMG preconditioner. Several command line options are available - * to change the problem parameters and ARKStep settings. Use the flag --help + * to change the problem parameters and ARKODE settings. Use the flag --help * for more information. * ---------------------------------------------------------------------------*/ @@ -412,7 +412,7 @@ int main(int argc, char* argv[]) } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -420,45 +420,45 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->matvec) { // Attach Jacobian-vector product function - flag = ARKStepSetJacTimes(arkode_mem, NULL, JTimes); - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, JTimes); + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -482,8 +482,8 @@ int main(int argc, char* argv[]) // Set fixed step size or adaptivity method if (udata->hfixed > ZERO) { - flag = ARKStepSetFixedStep(arkode_mem, udata->hfixed); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, udata->hfixed); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -496,24 +496,24 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(arkode_mem, udata->maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(arkode_mem, udata->tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -536,8 +536,8 @@ int main(int argc, char* argv[]) t1 = MPI_Wtime(); // Evolve in time - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer t2 = MPI_Wtime(); @@ -597,10 +597,10 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; (void)SUNAdaptController_Destroy(C); // Free timestep adaptivity controller SUNContext_Free(&ctx); // Free context @@ -2634,28 +2634,28 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -2684,10 +2684,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp index b36045a68d..8410570911 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_imex.cpp @@ -41,7 +41,7 @@ * If the requested accuracy is 5th order, the problem is treated implicitly. * This option is included for computing a reference solution. * Several command line options are available to - * change the problem parameters and ARKStep settings. Use the flag --help for + * change the problem parameters and ARKODE settings. Use the flag --help for * more information. * ---------------------------------------------------------------------------*/ @@ -391,7 +391,7 @@ int main(int argc, char* argv[]) } // ---------------------------------------------- - // Setup ARKStep integrator and set options + // Setup ARKODE integrator and set options // ---------------------------------------------- // Create integrator @@ -407,37 +407,37 @@ int main(int argc, char* argv[]) } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata.rtol, udata.atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata.rtol, udata.atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata.prectype != SUN_PREC_NONE) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set max steps between linear solver (preconditioner) setup calls - flag = ARKStepSetLSetupFrequency(arkode_mem, udata.msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata.msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata.epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata.epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata.order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata.order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } // Set fixed step size or adaptivity method if (udata.hf > ZERO) { - flag = ARKStepSetFixedStep(arkode_mem, udata.hf); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, udata.hf); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -450,28 +450,28 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(sunctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(sunctx); break; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Specify linearly implicit non-time-dependent RHS if (udata.linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Attach user data - flag = ARKStepSetUserData(arkode_mem, &udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, &udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(arkode_mem, udata.maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, udata.maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(arkode_mem, udata.tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata.tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -494,8 +494,8 @@ int main(int argc, char* argv[]) t1 = MPI_Wtime(); // Evolve in time - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer t2 = MPI_Wtime(); @@ -539,7 +539,7 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory + ARKodeFree(&arkode_mem); // Free integrator memory SUNLinSolFree(LS); // Free linear solver N_VDestroy(u); // Free vectors FreeUserData(&udata); // Free user data @@ -2720,26 +2720,26 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -2767,10 +2767,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prectype != SUN_PREC_NONE) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; diff --git a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp index 9cd4b0eab9..1f90ddcc7a 100644 --- a/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp +++ b/examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg_mri.cpp @@ -39,7 +39,7 @@ * an inexact Newton method paired with the PCG linear solver using hypre's PFMG * preconditioner for the slow-implicit nonlinear solve and inexact Newton with * GMRES for the fast nonlinear solve. Several command line options are - * available to change the problem parameters and ARKStep settings. Use the flag + * available to change the problem parameters and ARKODE settings. Use the flag * --help for more information. * ---------------------------------------------------------------------------*/ @@ -413,26 +413,26 @@ int main(int argc, char* argv[]) if (check_flag((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(inner_arkode_mem, udata.rtol, udata.atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(inner_arkode_mem, udata.rtol, udata.atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(inner_arkode_mem, LSf, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(inner_arkode_mem, LSf, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(inner_arkode_mem, udata.epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(inner_arkode_mem, udata.epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Use an ARKode provided table - flag = ARKStepSetOrder(inner_arkode_mem, udata.forder); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(inner_arkode_mem, udata.forder); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } // Set fixed step size or adaptivity method if (udata.hf > ZERO) { - flag = ARKStepSetFixedStep(inner_arkode_mem, udata.hf); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(inner_arkode_mem, udata.hf); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -447,17 +447,17 @@ int main(int argc, char* argv[]) Ctrl = SUNAdaptController_ImExGus(sunctx); break; } - flag = ARKStepSetAdaptController(inner_arkode_mem, Ctrl); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(inner_arkode_mem, Ctrl); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Attach user data - flag = ARKStepSetUserData(inner_arkode_mem, &udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(inner_arkode_mem, &udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(inner_arkode_mem, udata.maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(inner_arkode_mem, udata.maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Create inner stepper flag = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -475,27 +475,27 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } // Specify tolerances - flag = MRIStepSStolerances(arkode_mem, udata.rtol, udata.atol); - if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata.rtol, udata.atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach linear solver - flag = MRIStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata.prectype != SUN_PREC_NONE) { // Attach preconditioner - flag = MRIStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "MRIStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set max steps between linear solver (preconditioner) setup calls - flag = MRIStepSetLSetupFrequency(arkode_mem, udata.msbp); - if (check_flag(&flag, "MRIStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata.msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = MRIStepSetEpsLin(arkode_mem, udata.epslin); - if (check_flag(&flag, "MRIStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata.epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } if (udata.sorder == 3) { @@ -513,27 +513,27 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "MRIStepSetCoupling", 1)) { return 1; } // Set fixed step size - flag = MRIStepSetFixedStep(arkode_mem, udata.hs); - if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, udata.hs); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } // Specify linearly implicit non-time-dependent RHS if (udata.linear) { - flag = MRIStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Attach user data - flag = MRIStepSetUserData(arkode_mem, &udata); - if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, &udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Set max steps between outputs - flag = MRIStepSetMaxNumSteps(arkode_mem, udata.maxsteps); - if (check_flag(&flag, "MRIStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, udata.maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = MRIStepSetStopTime(arkode_mem, udata.tf); - if (check_flag(&flag, "MRIStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata.tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -556,8 +556,8 @@ int main(int argc, char* argv[]) t1 = MPI_Wtime(); // Evolve in time - flag = MRIStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "MRIStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer t2 = MPI_Wtime(); @@ -605,8 +605,8 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - MRIStepFree(&arkode_mem); // Free slow integrator memory - ARKStepFree(&inner_arkode_mem); // Free fast integrator memory + ARKodeFree(&arkode_mem); // Free slow integrator memory + ARKodeFree(&inner_arkode_mem); // Free fast integrator memory MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper MRIStepCoupling_Free(C); // Free coupling coefficients SUNLinSolFree(LS); // Free linear solver @@ -2695,26 +2695,26 @@ static int OutputFastStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -2742,10 +2742,10 @@ static int OutputFastStats(void* arkode_mem, UserData* udata) if (udata->prectype != SUN_PREC_NONE) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; @@ -2763,22 +2763,22 @@ static int OutputSlowStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nJv; - flag = MRIStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } flag = MRIStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return -1; } - flag = MRIStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = MRIStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = MRIStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "MRIStepGetNumLinIters", 1)) { return -1; } - flag = MRIStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "MRIStepGetNumLinConvFails", 1)) { return -1; } - flag = MRIStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return -1; } - flag = MRIStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "MRIStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -2802,10 +2802,10 @@ static int OutputSlowStats(void* arkode_mem, UserData* udata) if (udata->prectype != SUN_PREC_NONE) { long int npe, nps; - flag = MRIStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "MRIStepGetNumPrecEvals", 1)) { return -1; } - flag = MRIStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "MRIStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp index fc403e7404..9afe3e1ac3 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.cpp @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) // Setup the integrator // -------------------- - // ERKStep, ARKStep, or MRIStep memory structure + // ARKODE memory structure void* arkode_mem = nullptr; // Matrix and linear solver for DIRK, IMEX, or MRI slow integrators @@ -234,55 +234,16 @@ int main(int argc, char* argv[]) for (int iout = 0; iout < uopts.nout; iout++) { // Evolve - switch (uopts.integrator) + if (uopts.output == 3) { - case (0): - if (uopts.output == 3) - { - // Stop at output time (do not interpolate output) - flag = ERKStepSetStopTime(arkode_mem, tout); - if (check_flag(flag, "ARKStepSetStopTime")) { return 1; } - } - - // Advance in time - flag = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - break; - case (1): - if (uopts.output == 3) - { - // Stop at output time (do not interpolate output) - flag = ARKStepSetStopTime(arkode_mem, tout); - if (check_flag(flag, "ARKStepSetStopTime")) { return 1; } - } - - // Advance in time - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - break; - case (2): - if (uopts.output == 3) - { - // Stop at output time (do not interpolate output) - flag = MRIStepSetStopTime(arkode_mem, tout); - if (check_flag(flag, "MRIStepSetStopTime")) { return 1; } - } - - // Advance in time - flag = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - break; - case (3): - if (uopts.output == 3) - { - // Stop at output time (do not interpolate output) - flag = MRIStepSetStopTime(arkode_mem, tout); - if (check_flag(flag, "MRIStepSetStopTime")) { return 1; } - } - - // Advance in time - flag = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - break; - default: flag = -1; + // Stop at output time (do not interpolate output) + flag = ARKodeSetStopTime(arkode_mem, tout); + if (check_flag(flag, "ARKodeSetStopTime")) { return 1; } } - if (check_flag(flag, "Evolve")) { break; } + + // Advance in time + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_flag(flag, "ARKodeEvolve")) { break; } // Output solution flag = WriteOutput(t, y, udata, uopts); @@ -321,15 +282,15 @@ int main(int argc, char* argv[]) switch (uopts.integrator) { - case (0): ERKStepFree(&arkode_mem); break; - case (1): ARKStepFree(&arkode_mem); break; + case (0): ARKodeFree(&arkode_mem); break; + case (1): ARKodeFree(&arkode_mem); break; case (2): { void* inner_arkode_mem = nullptr; MRIStepInnerStepper_GetContent(fast_mem, &inner_arkode_mem); - ARKStepFree(&inner_arkode_mem); + ARKodeFree(&inner_arkode_mem); MRIStepInnerStepper_Free(&fast_mem); - MRIStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); break; } case (3): @@ -340,7 +301,7 @@ int main(int argc, char* argv[]) CVodeFree(&(content->cvode_mem)); delete content; MRIStepInnerStepper_Free(&fast_mem); - MRIStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); break; } } @@ -391,22 +352,22 @@ int SetupERK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(arkode_mem, "ERKStepCreate")) { return 1; } // Specify tolerances - int flag = ERKStepSStolerances(*arkode_mem, uopts.rtol, uopts.atol); - if (check_flag(flag, "ERKStepSStolerances")) { return 1; } + int flag = ARKodeSStolerances(*arkode_mem, uopts.rtol, uopts.atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } // Attach user data - flag = ERKStepSetUserData(*arkode_mem, &udata); - if (check_flag(flag, "ERKStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, &udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // Select method order - flag = ERKStepSetOrder(*arkode_mem, uopts.order); - if (check_flag(flag, "ERKStepSetOrder")) { return 1; } + flag = ARKodeSetOrder(*arkode_mem, uopts.order); + if (check_flag(flag, "ARKodeSetOrder")) { return 1; } // Set fixed step size or adaptivity method if (uopts.fixed_h > ZERO) { - flag = ERKStepSetFixedStep(*arkode_mem, uopts.fixed_h); - if (check_flag(flag, "ERKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, uopts.fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } else if (uopts.controller >= 0) { @@ -419,17 +380,17 @@ int SetupERK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, case (ARK_ADAPT_IMP_GUS): *C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): *C = SUNAdaptController_ImExGus(ctx); break; } - flag = ERKStepSetAdaptController(*arkode_mem, *C); - if (check_flag(flag, "ERKStepSetAdaptController")) { return 1; } + flag = ARKodeSetAdaptController(*arkode_mem, *C); + if (check_flag(flag, "ARKodeSetAdaptController")) { return 1; } } // Set max steps between outputs - flag = ERKStepSetMaxNumSteps(*arkode_mem, uopts.maxsteps); - if (check_flag(flag, "ERKStepSetMaxNumSteps")) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, uopts.maxsteps); + if (check_flag(flag, "ARKodeSetMaxNumSteps")) { return 1; } // Set stopping time - flag = ERKStepSetStopTime(*arkode_mem, udata.tf); - if (check_flag(flag, "ERKStepSetStopTime")) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata.tf); + if (check_flag(flag, "ARKodeSetStopTime")) { return 1; } return 0; } @@ -583,12 +544,12 @@ int SetupARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } // Specify tolerances - int flag = ARKStepSStolerances(*arkode_mem, uopts.rtol, uopts.atol); - if (check_flag(flag, "ARKStepSStolerances")) { return 1; } + int flag = ARKodeSStolerances(*arkode_mem, uopts.rtol, uopts.atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } // Attach user data - flag = ARKStepSetUserData(*arkode_mem, &udata); - if (check_flag(flag, "ARKStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, &udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // If implicit, setup solvers if (fi_RHS) @@ -602,26 +563,26 @@ int SetupARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(*LS, "SUNLinSol_Band")) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(*arkode_mem, *LS, *A); - if (check_flag(flag, "ARKStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(*arkode_mem, *LS, *A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } // Attach Jacobian function - flag = ARKStepSetJacFn(*arkode_mem, Ji_RHS); - if (check_flag(flag, "ARKStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(*arkode_mem, Ji_RHS); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } // Set the predictor method - flag = ARKStepSetPredictorMethod(*arkode_mem, uopts.predictor); - if (check_flag(flag, "ARKStepSetPredictorMethod")) { return 1; } + flag = ARKodeSetPredictorMethod(*arkode_mem, uopts.predictor); + if (check_flag(flag, "ARKodeSetPredictorMethod")) { return 1; } // Set linear solver setup frequency - flag = ARKStepSetLSetupFrequency(*arkode_mem, uopts.ls_setup_freq); - if (check_flag(flag, "ARKStepSetLSetupFrequency")) { return 1; } + flag = ARKodeSetLSetupFrequency(*arkode_mem, uopts.ls_setup_freq); + if (check_flag(flag, "ARKodeSetLSetupFrequency")) { return 1; } if (uopts.linear) { // Specify linearly implicit non-time-dependent RHS - flag = ARKStepSetLinear(*arkode_mem, SUNFALSE); - if (check_flag(flag, "ARKStepSetLinear")) { return 1; } + flag = ARKodeSetLinear(*arkode_mem, SUNFALSE); + if (check_flag(flag, "ARKodeSetLinear")) { return 1; } } } @@ -653,15 +614,15 @@ int SetupARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, else { // Select default method of a given order - flag = ARKStepSetOrder(*arkode_mem, uopts.order); - if (check_flag(flag, "ARKStepSetOrder")) { return 1; } + flag = ARKodeSetOrder(*arkode_mem, uopts.order); + if (check_flag(flag, "ARKodeSetOrder")) { return 1; } } // Set fixed step size or adaptivity method if (uopts.fixed_h > ZERO) { - flag = ARKStepSetFixedStep(*arkode_mem, uopts.fixed_h); - if (check_flag(flag, "ARKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, uopts.fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } else if (uopts.controller >= 0) { @@ -674,17 +635,17 @@ int SetupARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, case (ARK_ADAPT_IMP_GUS): *C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): *C = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(*arkode_mem, *C); - if (check_flag(flag, "ARKStepSetAdaptController")) { return 1; } + flag = ARKodeSetAdaptController(*arkode_mem, *C); + if (check_flag(flag, "ARKodeSetAdaptController")) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(*arkode_mem, uopts.maxsteps); - if (check_flag(flag, "ARKStepSetMaxNumSteps")) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, uopts.maxsteps); + if (check_flag(flag, "ARKodeSetMaxNumSteps")) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(*arkode_mem, udata.tf); - if (check_flag(flag, "ARKStepSetStopTime")) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata.tf); + if (check_flag(flag, "ARKodeSetStopTime")) { return 1; } return 0; } @@ -756,13 +717,13 @@ int SetupMRIARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } // Specify tolerances - int flag = ARKStepSStolerances(fast_arkode_mem, uopts.rtol_fast, - uopts.atol_fast); - if (check_flag(flag, "ARKStepSStolerances")) { return 1; } + int flag = ARKodeSStolerances(fast_arkode_mem, uopts.rtol_fast, + uopts.atol_fast); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } // Attach user data - flag = ARKStepSetUserData(fast_arkode_mem, &udata); - if (check_flag(flag, "ARKStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(fast_arkode_mem, &udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // If implicit, setup solvers if (ffi_RHS) @@ -776,31 +737,31 @@ int SetupMRIARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(*LS_fast, "SUNLinSol_Band")) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(fast_arkode_mem, *LS_fast, *A_fast); - if (check_flag(flag, "ARKStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(fast_arkode_mem, *LS_fast, *A_fast); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } // Attach Jacobian function - flag = ARKStepSetJacFn(fast_arkode_mem, Jfi_RHS); - if (check_flag(flag, "ARKStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(fast_arkode_mem, Jfi_RHS); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } // Set the predictor method - flag = ARKStepSetPredictorMethod(fast_arkode_mem, uopts.predictor_fast); - if (check_flag(flag, "ARKStepSetPredictorMethod")) { return 1; } + flag = ARKodeSetPredictorMethod(fast_arkode_mem, uopts.predictor_fast); + if (check_flag(flag, "ARKodeSetPredictorMethod")) { return 1; } // Set linear solver setup frequency - flag = ARKStepSetLSetupFrequency(fast_arkode_mem, uopts.ls_setup_freq_fast); - if (check_flag(flag, "ARKStepSetLSetupFrequency")) { return 1; } + flag = ARKodeSetLSetupFrequency(fast_arkode_mem, uopts.ls_setup_freq_fast); + if (check_flag(flag, "ARKodeSetLSetupFrequency")) { return 1; } } // Select method order - flag = ARKStepSetOrder(fast_arkode_mem, uopts.order_fast); - if (check_flag(flag, "ARKStepSetOrder")) { return 1; } + flag = ARKodeSetOrder(fast_arkode_mem, uopts.order_fast); + if (check_flag(flag, "ARKodeSetOrder")) { return 1; } // Set fixed step size or adaptivity method if (uopts.fixed_h_fast > ZERO) { - flag = ARKStepSetFixedStep(fast_arkode_mem, uopts.fixed_h_fast); - if (check_flag(flag, "ARKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(fast_arkode_mem, uopts.fixed_h_fast); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } else if (uopts.controller_fast >= 0) { @@ -813,13 +774,13 @@ int SetupMRIARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, case (ARK_ADAPT_IMP_GUS): *C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): *C = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(fast_arkode_mem, *C); - if (check_flag(flag, "ARKStepSetAdaptController")) { return 1; } + flag = ARKodeSetAdaptController(fast_arkode_mem, *C); + if (check_flag(flag, "ARKodeSetAdaptController")) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(fast_arkode_mem, uopts.maxsteps); - if (check_flag(flag, "ARKStepSetMaxNumSteps")) { return 1; } + flag = ARKodeSetMaxNumSteps(fast_arkode_mem, uopts.maxsteps); + if (check_flag(flag, "ARKodeSetMaxNumSteps")) { return 1; } // Wrap ARKODE as an MRIStepInnerStepper flag = ARKStepCreateMRIStepInnerStepper(fast_arkode_mem, fast_mem); @@ -834,16 +795,16 @@ int SetupMRIARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(*arkode_mem, "MRIStepCreate")) { return 1; } // Set the slow step size - flag = MRIStepSetFixedStep(*arkode_mem, uopts.fixed_h); - if (check_flag(flag, "MRIStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, uopts.fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } // Specify tolerances - flag = MRIStepSStolerances(*arkode_mem, uopts.rtol, uopts.atol); - if (check_flag(flag, "MRIStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(*arkode_mem, uopts.rtol, uopts.atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } // Attach user data - flag = MRIStepSetUserData(*arkode_mem, &udata); - if (check_flag(flag, "MRIStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, &udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // If implicit, setup solvers if (fsi_RHS) @@ -857,40 +818,40 @@ int SetupMRIARK(SUNContext ctx, UserData& udata, UserOptions& uopts, N_Vector y, if (check_ptr(*LS, "SUNLinSol_Band")) { return 1; } // Attach linear solver - flag = MRIStepSetLinearSolver(*arkode_mem, *LS, *A); - if (check_flag(flag, "MRIStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(*arkode_mem, *LS, *A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } // Attach Jacobian function - flag = MRIStepSetJacFn(*arkode_mem, Jsi_RHS); - if (check_flag(flag, "MRIStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(*arkode_mem, Jsi_RHS); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } // Set linear solver setup frequency - flag = MRIStepSetLSetupFrequency(*arkode_mem, uopts.ls_setup_freq); - if (check_flag(flag, "MRIStepSetLSetupFrequency")) { return 1; } + flag = ARKodeSetLSetupFrequency(*arkode_mem, uopts.ls_setup_freq); + if (check_flag(flag, "ARKodeSetLSetupFrequency")) { return 1; } // Set the predictor method - flag = MRIStepSetPredictorMethod(*arkode_mem, uopts.predictor); - if (check_flag(flag, "MRIStepSetPredictorMethod")) { return 1; } + flag = ARKodeSetPredictorMethod(*arkode_mem, uopts.predictor); + if (check_flag(flag, "ARKodeSetPredictorMethod")) { return 1; } if (uopts.linear) { // Specify linearly implicit non-time-dependent RHS - flag = MRIStepSetLinear(*arkode_mem, SUNFALSE); - if (check_flag(flag, "MRIStepSetLinear")) { return 1; } + flag = ARKodeSetLinear(*arkode_mem, SUNFALSE); + if (check_flag(flag, "ARKodeSetLinear")) { return 1; } } } // Select method order - flag = MRIStepSetOrder(*arkode_mem, uopts.order); - if (check_flag(flag, "MRIStepSetOrder")) { return 1; } + flag = ARKodeSetOrder(*arkode_mem, uopts.order); + if (check_flag(flag, "ARKodeSetOrder")) { return 1; } // Set max steps between outputs - flag = MRIStepSetMaxNumSteps(*arkode_mem, uopts.maxsteps); - if (check_flag(flag, "MRIStepSetMaxNumSteps")) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, uopts.maxsteps); + if (check_flag(flag, "ARKodeSetMaxNumSteps")) { return 1; } // Set stopping time - flag = MRIStepSetStopTime(*arkode_mem, udata.tf); - if (check_flag(flag, "MRIStepSetStopTime")) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata.tf); + if (check_flag(flag, "ARKodeSetStopTime")) { return 1; } return 0; } @@ -1025,16 +986,16 @@ int SetupMRICVODE(SUNContext ctx, UserData& udata, UserOptions& uopts, if (check_ptr(*arkode_mem, "MRIStepCreate")) { return 1; } // Set the slow step size - flag = MRIStepSetFixedStep(*arkode_mem, uopts.fixed_h); - if (check_flag(flag, "MRIStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(*arkode_mem, uopts.fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } // Specify tolerances - flag = MRIStepSStolerances(*arkode_mem, uopts.rtol, uopts.atol); - if (check_flag(flag, "MRIStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(*arkode_mem, uopts.rtol, uopts.atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } // Attach user data - flag = MRIStepSetUserData(*arkode_mem, &udata); - if (check_flag(flag, "MRIStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(*arkode_mem, &udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // If implicit, setup solvers if (fsi_RHS) @@ -1048,40 +1009,40 @@ int SetupMRICVODE(SUNContext ctx, UserData& udata, UserOptions& uopts, if (check_ptr(*LS, "SUNLinSol_Band")) { return 1; } // Attach linear solver - flag = MRIStepSetLinearSolver(*arkode_mem, *LS, *A); - if (check_flag(flag, "MRIStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(*arkode_mem, *LS, *A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } // Attach Jacobian function - flag = MRIStepSetJacFn(*arkode_mem, Jsi_RHS); - if (check_flag(flag, "MRIStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(*arkode_mem, Jsi_RHS); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } // Set linear solver setup frequency - flag = MRIStepSetLSetupFrequency(*arkode_mem, uopts.ls_setup_freq); - if (check_flag(flag, "MRIStepSetLSetupFrequency")) { return 1; } + flag = ARKodeSetLSetupFrequency(*arkode_mem, uopts.ls_setup_freq); + if (check_flag(flag, "ARKodeSetLSetupFrequency")) { return 1; } // Set the predictor method - flag = MRIStepSetPredictorMethod(*arkode_mem, uopts.predictor); - if (check_flag(flag, "MRIStepSetPredictorMethod")) { return 1; } + flag = ARKodeSetPredictorMethod(*arkode_mem, uopts.predictor); + if (check_flag(flag, "ARKodeSetPredictorMethod")) { return 1; } if (uopts.linear) { // Specify linearly implicit non-time-dependent RHS - flag = MRIStepSetLinear(*arkode_mem, SUNFALSE); - if (check_flag(flag, "MRIStepSetLinear")) { return 1; } + flag = ARKodeSetLinear(*arkode_mem, SUNFALSE); + if (check_flag(flag, "ARKodeSetLinear")) { return 1; } } } // Select method order - flag = MRIStepSetOrder(*arkode_mem, uopts.order); - if (check_flag(flag, "MRIStepSetOrder")) { return 1; } + flag = ARKodeSetOrder(*arkode_mem, uopts.order); + if (check_flag(flag, "ARKodeSetOrder")) { return 1; } // Set max steps between outputs - flag = MRIStepSetMaxNumSteps(*arkode_mem, uopts.maxsteps); - if (check_flag(flag, "MRIStepSetMaxNumSteps")) { return 1; } + flag = ARKodeSetMaxNumSteps(*arkode_mem, uopts.maxsteps); + if (check_flag(flag, "ARKodeSetMaxNumSteps")) { return 1; } // Set stopping time - flag = MRIStepSetStopTime(*arkode_mem, udata.tf); - if (check_flag(flag, "MRIStepSetStopTime")) { return 1; } + flag = ARKodeSetStopTime(*arkode_mem, udata.tf); + if (check_flag(flag, "ARKodeSetStopTime")) { return 1; } return 0; } diff --git a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp index 293cf06d48..6d0bc8a09d 100644 --- a/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp +++ b/examples/arkode/CXX_serial/ark_advection_diffusion_reaction.hpp @@ -291,12 +291,12 @@ int OutputStatsERK(void* arkode_mem, UserData& udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe; - flag = ERKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(flag, "ERKStepGetNumSteps")) { return -1; } - flag = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(flag, "ERKStepGetNumStepAttempts")) { return -1; } - flag = ERKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(flag, "ERKStepGetNumErrTestFails")) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(flag, "ARKodeGetNumSteps")) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(flag, "ARKodeGetNumStepAttempts")) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(flag, "ARKodeGetNumErrTestFails")) { return -1; } flag = ERKStepGetNumRhsEvals(arkode_mem, &nfe); if (check_flag(flag, "ERKStepGetNumRhsEvals")) { return -1; } @@ -315,12 +315,12 @@ int OutputStatsARK(void* arkode_mem, UserData& udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(flag, "ARKStepGetNumSteps")) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(flag, "ARKStepGetNumStepAttempts")) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(flag, "ARKStepGetNumErrTestFails")) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(flag, "ARKodeGetNumSteps")) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(flag, "ARKodeGetNumStepAttempts")) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(flag, "ARKodeGetNumErrTestFails")) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(flag, "ARKStepGetNumRhsEvals")) { return -1; } @@ -334,16 +334,16 @@ int OutputStatsARK(void* arkode_mem, UserData& udata) if (udata.splitting) { long int nni, ncfn; - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(flag, "ARKStepGetNumNonlinSolvIters")) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(flag, "ARKStepGetNumNonlinSolvConvFails")) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(flag, "ARKodeGetNumNonlinSolvIters")) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(flag, "ARKodeGetNumNonlinSolvConvFails")) { return -1; } long int nsetups, nje; - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(flag, "ARKStepGetNumLinSolvSetups")) { return -1; } - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - if (check_flag(flag, "ARKStepGetNumJacEvals")) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(flag, "ARKodeGetNumLinSolvSetups")) { return -1; } + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + if (check_flag(flag, "ARKodeGetNumJacEvals")) { return -1; } cout << " NLS iters = " << nni << endl; cout << " NLS fails = " << ncfn << endl; @@ -369,8 +369,8 @@ int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, // Get slow integrator and solver stats long int nst, nst_a, netf, nfe, nfi; - flag = MRIStepGetNumSteps(arkode_mem, &nst); - if (check_flag(flag, "MRIStepGetNumSteps")) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(flag, "ARKodeGetNumSteps")) { return -1; } flag = MRIStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(flag, "MRIStepGetNumRhsEvals")) { return -1; } @@ -383,16 +383,16 @@ int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, if (udata.diffusion) { long int nni, ncfn; - flag = MRIStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(flag, "MRIStepGetNumNonlinSolvIters")) { return -1; } - flag = MRIStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(flag, "MRIStepGetNumNonlinSolvConvFails")) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(flag, "ARKodeGetNumNonlinSolvIters")) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(flag, "ARKodeGetNumNonlinSolvConvFails")) { return -1; } long int nsetups, nje; - flag = MRIStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(flag, "MRIStepGetNumLinSolvSetups")) { return -1; } - flag = MRIStepGetNumJacEvals(arkode_mem, &nje); - if (check_flag(flag, "MRIStepGetNumJacEvals")) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(flag, "ARKodeGetNumLinSolvSetups")) { return -1; } + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + if (check_flag(flag, "ARKodeGetNumJacEvals")) { return -1; } cout << " NLS iters = " << nni << endl; cout << " NLS fails = " << ncfn << endl; @@ -413,12 +413,12 @@ int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, MRIStepInnerStepper_GetContent(fast_mem, &fast_arkode_mem); // Get fast integrator and solver stats - flag = ARKStepGetNumSteps(fast_arkode_mem, &nst); - if (check_flag(flag, "ARKStepGetNumSteps")) { return -1; } - flag = ARKStepGetNumStepAttempts(fast_arkode_mem, &nst_a); - if (check_flag(flag, "ARKStepGetNumStepAttempts")) { return -1; } - flag = ARKStepGetNumErrTestFails(fast_arkode_mem, &netf); - if (check_flag(flag, "ARKStepGetNumErrTestFails")) { return -1; } + flag = ARKodeGetNumSteps(fast_arkode_mem, &nst); + if (check_flag(flag, "ARKodeGetNumSteps")) { return -1; } + flag = ARKodeGetNumStepAttempts(fast_arkode_mem, &nst_a); + if (check_flag(flag, "ARKodeGetNumStepAttempts")) { return -1; } + flag = ARKodeGetNumErrTestFails(fast_arkode_mem, &netf); + if (check_flag(flag, "ARKodeGetNumErrTestFails")) { return -1; } flag = ARKStepGetNumRhsEvals(fast_arkode_mem, &nfe, &nfi); if (check_flag(flag, "ARKStepGetNumRhsEvals")) { return -1; } @@ -433,16 +433,16 @@ int OutputStatsMRIARK(void* arkode_mem, MRIStepInnerStepper fast_mem, if (udata.splitting) { long int nni, ncfn; - flag = ARKStepGetNumNonlinSolvIters(fast_arkode_mem, &nni); - if (check_flag(flag, "ARKStepGetNumNonlinSolvIters")) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(fast_arkode_mem, &ncfn); - if (check_flag(flag, "ARKStepGetNumNonlinSolvConvFails")) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(fast_arkode_mem, &nni); + if (check_flag(flag, "ARKodeGetNumNonlinSolvIters")) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(fast_arkode_mem, &ncfn); + if (check_flag(flag, "ARKodeGetNumNonlinSolvConvFails")) { return -1; } long int nsetups, nje; - flag = ARKStepGetNumLinSolvSetups(fast_arkode_mem, &nsetups); - if (check_flag(flag, "ARKStepGetNumLinSolvSetups")) { return -1; } - flag = ARKStepGetNumJacEvals(fast_arkode_mem, &nje); - if (check_flag(flag, "ARKStepGetNumJacEvals")) { return -1; } + flag = ARKodeGetNumLinSolvSetups(fast_arkode_mem, &nsetups); + if (check_flag(flag, "ARKodeGetNumLinSolvSetups")) { return -1; } + flag = ARKodeGetNumJacEvals(fast_arkode_mem, &nje); + if (check_flag(flag, "ARKodeGetNumJacEvals")) { return -1; } cout << " NLS iters = " << nni << endl; cout << " NLS fails = " << ncfn << endl; @@ -505,22 +505,22 @@ int OutputStatsMRICVODE(void* arkode_mem, MRIStepInnerStepper fast_mem, // Get slow integrator and solver stats long int nsts, nfse, nfsi; - flag = MRIStepGetNumSteps(arkode_mem, &nsts); - if (check_flag(flag, "MRIStepGetNumSteps")) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nsts); + if (check_flag(flag, "ARKodeGetNumSteps")) { return -1; } flag = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); if (check_flag(flag, "MRIStepGetNumRhsEvals")) { return -1; } long int nni, ncfn; - flag = MRIStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(flag, "MRIStepGetNumNonlinSolvIters")) { return -1; } - flag = MRIStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(flag, "MRIStepGetNumNonlinSolvConvFails")) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(flag, "ARKodeGetNumNonlinSolvIters")) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(flag, "ARKodeGetNumNonlinSolvConvFails")) { return -1; } long int nsetups, nje; - flag = MRIStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(flag, "MRIStepGetNumLinSolvSetups")) { return -1; } - flag = MRIStepGetNumJacEvals(arkode_mem, &nje); - if (check_flag(flag, "MRIStepGetNumJacEvals")) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(flag, "ARKodeGetNumLinSolvSetups")) { return -1; } + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + if (check_flag(flag, "ARKodeGetNumJacEvals")) { return -1; } cout << fixed << setprecision(6); cout << endl << "Slow Integrator:" << endl; diff --git a/examples/arkode/CXX_serial/ark_analytic_sys.cpp b/examples/arkode/CXX_serial/ark_analytic_sys.cpp index ffcad8e516..e0a668f025 100644 --- a/examples/arkode/CXX_serial/ark_analytic_sys.cpp +++ b/examples/arkode/CXX_serial/ark_analytic_sys.cpp @@ -173,22 +173,22 @@ int main() if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Set routines - flag = ARKStepSetUserData(arkode_mem, - (void*)&lamda); // Pass lamda to user functions - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); // Specify tolerances - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)&lamda); // Pass lamda to user functions + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); // Specify tolerances + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Linear solver interface - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); // Attach matrix and linear solver - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); // Set Jacobian routine - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); // Attach matrix and linear solver + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); // Set Jacobian routine + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } // Specify linearly implicit RHS, with non-time-dependent Jacobian - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } // Open output stream for results, output comment line FILE* UFID = fopen("solution.txt", "w"); @@ -198,7 +198,7 @@ int main() fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ sunrealtype t = T0; sunrealtype tout = T0 + dTout; @@ -206,8 +206,8 @@ int main() cout << " --------------------------------------\n"; while (Tf - t > 1.0e-15) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); // call integrator - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); // call integrator + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %8.4" FSYM " %8.5" FSYM " %8.5" FSYM " %8.5" FSYM "\n", // access/print solution t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); @@ -229,24 +229,24 @@ int main() // Print some final statistics long int nst, nst_a, nfe, nfi, nsetups, nje, nfeLS, nni, ncfn, netf; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); cout << "\nFinal Solver Statistics:\n"; cout << " Internal solver steps = " << nst << " (attempted = " << nst_a @@ -262,10 +262,10 @@ int main() cout << " Total number of error test failures = " << netf << "\n\n"; // Clean up and return with successful completion - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - SUNMatDestroy(A); // Free A matrix - N_VDestroy(y); // Free y vector + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + SUNMatDestroy(A); // Free A matrix + N_VDestroy(y); // Free y vector if (logger) { SUNLogger_Destroy(&logger); // Free logger diff --git a/examples/arkode/CXX_serial/ark_heat2D.cpp b/examples/arkode/CXX_serial/ark_heat2D.cpp index 414bbff076..bf18a6fbb0 100644 --- a/examples/arkode/CXX_serial/ark_heat2D.cpp +++ b/examples/arkode/CXX_serial/ark_heat2D.cpp @@ -41,7 +41,7 @@ * problem is advanced in time with a diagonally implicit Runge-Kutta method * using an inexact Newton method paired with the PCG or SPGMR linear solver. * Several command line options are available to change the problem parameters - * and ARKStep settings. Use the flag --help for more information. + * and ARKODE settings. Use the flag --help for more information. * ---------------------------------------------------------------------------*/ #include @@ -290,7 +290,7 @@ int main(int argc, char* argv[]) } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -298,38 +298,38 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -353,8 +353,8 @@ int main(int argc, char* argv[]) // Set fixed step size or adaptivity method if (udata->hfixed > ZERO) { - flag = ARKStepSetFixedStep(arkode_mem, udata->hfixed); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, udata->hfixed); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } } else { @@ -367,24 +367,24 @@ int main(int argc, char* argv[]) case (ARK_ADAPT_IMP_GUS): C = SUNAdaptController_ImpGus(ctx); break; case (ARK_ADAPT_IMEX_GUS): C = SUNAdaptController_ImExGus(ctx); break; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } } // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set max steps between outputs - flag = ARKStepSetMaxNumSteps(arkode_mem, udata->maxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, udata->maxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Set stopping time - flag = ARKStepSetStopTime(arkode_mem, udata->tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, udata->tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } // ----------------------- // Loop over output times @@ -407,8 +407,8 @@ int main(int argc, char* argv[]) t1 = chrono::steady_clock::now(); // Evolve in time - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } // Stop timer t2 = chrono::steady_clock::now(); @@ -465,10 +465,10 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; (void)SUNAdaptController_Destroy(C); // Free time adaptivity controller SUNContext_Free(&ctx); // Free context @@ -1087,28 +1087,28 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } cout << fixed; cout << setprecision(6); @@ -1137,10 +1137,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } cout << " Preconditioner setups = " << npe << endl; cout << " Preconditioner solves = " << nps << endl; diff --git a/examples/arkode/CXX_serial/ark_kpr_Mt.cpp b/examples/arkode/CXX_serial/ark_kpr_Mt.cpp index 6a32290cca..ff1d6daa05 100644 --- a/examples/arkode/CXX_serial/ark_kpr_Mt.cpp +++ b/examples/arkode/CXX_serial/ark_kpr_Mt.cpp @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) // general problem variables int retval; // reusable error-checking flag N_Vector y = NULL; // empty vector for the computed solution - void* arkode_mem = NULL; // empty ARKStep memory structure + void* arkode_mem = NULL; // empty ARKODE memory structure SUNMatrix A = NULL; // empty system matrix SUNMatrix M = NULL; // empty mass matrix SUNLinearSolver LS = NULL; // empty system linear solver object @@ -269,34 +269,34 @@ int main(int argc, char* argv[]) NLS = SUNNonlinSol_Newton(y, ctx); if (check_retval((void*)NLS, "SUNNonlinSol_Newton", 0)) { return 1; } - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1)) { return (1); } + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1)) { return (1); } A = SUNDenseMatrix(NEQ, NEQ, ctx); if (check_retval((void*)A, "SUNDenseMatrix", 0)) { return 1; } LS = SUNLinSol_Dense(y, A, ctx); if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return (1); } - if (rk_type == 0) { retval = ARKStepSetJacFn(arkode_mem, Ji); } - else { retval = ARKStepSetJacFn(arkode_mem, Jn); } - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return (1); } + if (rk_type == 0) { retval = ARKodeSetJacFn(arkode_mem, Ji); } + else { retval = ARKodeSetJacFn(arkode_mem, Jn); } + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } } else { // Fixed-point NLS = SUNNonlinSol_FixedPoint(y, 4, ctx); if (check_retval((void*)NLS, "SUNNonlinSol_FixedPoint", 0)) { return 1; } - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1)) { return (1); } + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1)) { return (1); } } } // Set maximum stepsize for ERK run if (rk_type == 2) { - retval = ARKStepSetMaxStep(arkode_mem, ONE / SUNRabs(udata.G)); - if (check_retval(&retval, "ARKStepSetMaxStep", 1)) { return (1); } + retval = ARKodeSetMaxStep(arkode_mem, ONE / SUNRabs(udata.G)); + if (check_retval(&retval, "ARKodeSetMaxStep", 1)) { return (1); } } // Initialize/attach mass matrix solver @@ -304,21 +304,21 @@ int main(int argc, char* argv[]) if (check_retval((void*)M, "SUNDenseMatrix", 0)) { return 1; } MLS = SUNLinSol_Dense(y, M, ctx); if (check_retval((void*)MLS, "SUNLinSol_Dense", 0)) { return 1; } - retval = ARKStepSetMassLinearSolver(arkode_mem, MLS, M, SUNTRUE); - if (check_retval(&retval, "ARKStepSetMassLinearSolver", 1)) { return (1); } - retval = ARKStepSetMassFn(arkode_mem, MassMatrix); - if (check_retval(&retval, "ARKStepSetMassFn", 1)) { return (1); } + retval = ARKodeSetMassLinearSolver(arkode_mem, MLS, M, SUNTRUE); + if (check_retval(&retval, "ARKodeSetMassLinearSolver", 1)) { return (1); } + retval = ARKodeSetMassFn(arkode_mem, MassMatrix); + if (check_retval(&retval, "ARKodeSetMassFn", 1)) { return (1); } // Set desired solver order - retval = ARKStepSetOrder(arkode_mem, order); - if (check_retval(&retval, "ARKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } - retval = ARKStepSetDeduceImplicitRhs(arkode_mem, deduce); - if (check_retval(&retval, "ARKStepSetDeduceImplicitRhs", 1)) { return 1; } + retval = ARKodeSetDeduceImplicitRhs(arkode_mem, deduce); + if (check_retval(&retval, "ARKodeSetDeduceImplicitRhs", 1)) { return 1; } // Set the user data pointer - retval = ARKStepSetUserData(arkode_mem, (void*)&udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } // Integrate ODE, based on run type if (adaptive) @@ -334,13 +334,13 @@ int main(int argc, char* argv[]) } // Clean up and return - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // free system linear solver - SUNLinSolFree(MLS); // free mass linear solver - SUNNonlinSolFree(NLS); // free nonlinear solver - SUNMatDestroy(A); // free system matrix - SUNMatDestroy(M); // free mass matrix - N_VDestroy(y); // Free y vector + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // free system linear solver + SUNLinSolFree(MLS); // free mass linear solver + SUNNonlinSolFree(NLS); // free nonlinear solver + SUNMatDestroy(A); // free system matrix + SUNMatDestroy(M); // free mass matrix + N_VDestroy(y); // Free y vector return 0; } @@ -509,10 +509,10 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, int retval; // Set tolerances - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } - retval = ARKStepResStolerance(arkode_mem, abstol); - if (check_retval(&retval, "ARKStepResStolerance", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } + retval = ARKodeResStolerance(arkode_mem, abstol); + if (check_retval(&retval, "ARKodeResStolerance", 1)) { return 1; } // Open output stream for results, output comment line FILE* UFID = fopen("ark_kpr_Mt_solution.txt", "w"); @@ -524,7 +524,7 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), SUNRabs(NV_Ith_S(y, 0) - utrue(T0)), SUNRabs(NV_Ith_S(y, 1) - vtrue(T0))); - // Main time-stepping loop: calls ARKStepEvolve to perform integration, + // Main time-stepping loop: calls ARKodeEvolve to perform integration, // then prints results. Stops when the final time has been reached int Nt = (int)ceil((Tf - T0) / dTout); sunrealtype t = T0; @@ -543,8 +543,8 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, for (int iout = 0; iout < Nt; iout++) { // call integrator - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } // access/print solution and error uerr = SUNRabs(NV_Ith_S(y, 0) - utrue(t)); @@ -571,30 +571,30 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Get integrator statistics long int nst, nst_a, nfe, nfi, nni, nnc, nje, nsetups, netf, nmset, nms, nMv; - retval = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) { return 1; } - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_retval(&retval, "ARKStepGetNumStepAttempts", 1)) { return 1; } + retval = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) { return 1; } + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_retval(&retval, "ARKodeGetNumStepAttempts", 1)) { return 1; } retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_retval(&retval, "ARKStepGetNumRhsEvals", 1)) { return 1; } - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_retval(&retval, "ARKStepGetNumErrTestFails", 1)) { return 1; } - retval = ARKStepGetNumMassSetups(arkode_mem, &nmset); - if (check_retval(&retval, "ARKStepGetNumMassSetups", 1)) { return 1; } - retval = ARKStepGetNumMassSolves(arkode_mem, &nms); - if (check_retval(&retval, "ARKStepGetNumMassSolves", 1)) { return 1; } - retval = ARKStepGetNumMassMult(arkode_mem, &nMv); - if (check_retval(&retval, "ARKStepGetNumMassMult", 1)) { return 1; } + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_retval(&retval, "ARKodeGetNumErrTestFails", 1)) { return 1; } + retval = ARKodeGetNumMassSetups(arkode_mem, &nmset); + if (check_retval(&retval, "ARKodeGetNumMassSetups", 1)) { return 1; } + retval = ARKodeGetNumMassSolves(arkode_mem, &nms); + if (check_retval(&retval, "ARKodeGetNumMassSolves", 1)) { return 1; } + retval = ARKodeGetNumMassMult(arkode_mem, &nMv); + if (check_retval(&retval, "ARKodeGetNumMassMult", 1)) { return 1; } if (rk_type < 2) { - retval = ARKStepGetNonlinSolvStats(arkode_mem, &nni, &nnc); - if (check_retval(&retval, "ARKStepGetNonlinSolvStats", 1)) { return 1; } - retval = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_retval(&retval, "ARKStepGetNumLinSolvSetups", 1)) { return 1; } + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nni, &nnc); + if (check_retval(&retval, "ARKodeGetNonlinSolvStats", 1)) { return 1; } + retval = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_retval(&retval, "ARKodeGetNumLinSolvSetups", 1)) { return 1; } if (nls_type == 0) { - retval = ARKStepGetNumJacEvals(arkode_mem, &nje); - if (check_retval(&retval, "ARKStepGetNumJacEvals", 1)) { return 1; } + retval = ARKodeGetNumJacEvals(arkode_mem, &nje); + if (check_retval(&retval, "ARKodeGetNumJacEvals", 1)) { return 1; } } else { nje = 0; } } @@ -632,22 +632,22 @@ static int check_order(void* arkode_mem, N_Vector y, sunrealtype T0, a11 = a12 = a21 = a22 = b1 = b2 = ZERO; // Tighten implicit solver to accommodate fixed step sizes - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } - retval = ARKStepResStolerance(arkode_mem, abstol); - if (check_retval(&retval, "ARKStepResStolerance", 1)) { return (1); } - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) { return (1); } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } + retval = ARKodeResStolerance(arkode_mem, abstol); + if (check_retval(&retval, "ARKodeResStolerance", 1)) { return (1); } + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return (1); } if (rk_type < 2) { - retval = ARKStepSetJacEvalFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetJacEvalFrequency", 1)) { return 1; } - retval = ARKStepSetLSetupFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetLSetupFrequency", 1)) { return 1; } - retval = ARKStepSetMaxNonlinIters(arkode_mem, 20); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) { return 1; } - retval = ARKStepSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); - if (check_retval(&retval, "ARKStepSetNonlinConvCoef", 1)) { return 1; } + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) { return 1; } + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) { return 1; } + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) { return 1; } + retval = ARKodeSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); + if (check_retval(&retval, "ARKodeSetNonlinConvCoef", 1)) { return 1; } } // Set array of fixed step sizes to use, storage for corresponding errors/orders @@ -667,13 +667,13 @@ static int check_order(void* arkode_mem, N_Vector y, sunrealtype T0, cout << " -----------------------------------------------------\n"; for (size_t ih = 0; ih < hvals.size(); ih++) { - // Reset ARKStep for this run + // Reset ARKODE for this run retval = Ytrue(T0, y); if (check_retval(&retval, "Ytrue", 1)) { return 1; } - retval = ARKStepReset(arkode_mem, T0, y); - if (check_retval(&retval, "ARKStepReset", 1)) { return 1; } - retval = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, T0, y); + if (check_retval(&retval, "ARKodeReset", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } // Main time-stepping loop: run for Nout periods, accumulating overall error sunrealtype t = T0; @@ -685,8 +685,8 @@ static int check_order(void* arkode_mem, N_Vector y, sunrealtype T0, for (size_t iout = 0; iout < Nout; iout++) { // call integrator and update output time - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } tout += dTout; tout = (tout > Tf) ? Tf : tout; diff --git a/examples/arkode/CXX_serial/ark_pendulum.cpp b/examples/arkode/CXX_serial/ark_pendulum.cpp index 776dc831d8..be36be088c 100644 --- a/examples/arkode/CXX_serial/ark_pendulum.cpp +++ b/examples/arkode/CXX_serial/ark_pendulum.cpp @@ -139,14 +139,14 @@ int main(int argc, char* argv[]) if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(flag, "ARKStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } if (relax) { // Enable relaxation methods - flag = ARKStepSetRelaxFn(arkode_mem, Eng, JacEng); - if (check_flag(flag, "ARKStepSetRelaxFn")) { return 1; } + flag = ARKodeSetRelaxFn(arkode_mem, Eng, JacEng); + if (check_flag(flag, "ARKodeSetRelaxFn")) { return 1; } } SUNMatrix A = nullptr; @@ -162,12 +162,12 @@ int main(int argc, char* argv[]) if (check_ptr(LS, "SUNLinSol_Dense")) { return 1; } // Attach the matrix and linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(flag, "ARKStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } // Set Jacobian routine - flag = ARKStepSetJacFn(arkode_mem, Jac); - if (check_flag(flag, "ARKStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } if (fixed_h > SUN_RCONST(0.0)) { @@ -206,12 +206,12 @@ int main(int argc, char* argv[]) if (fixed_h > SUN_RCONST(0.0)) { - flag = ARKStepSetFixedStep(arkode_mem, fixed_h); - if (check_flag(flag, "ARKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } - flag = ARKStepSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); - if (check_flag(flag, "ARKStepSetNonlinConvCoef")) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); + if (check_flag(flag, "ARKodeSetNonlinConvCoef")) { return 1; } /* --------------- * * Advance in Time * @@ -248,8 +248,8 @@ int main(int argc, char* argv[]) while (t < tf) { // Evolve in time - flag = ARKStepEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); - if (check_flag(flag, "ARKStepEvolve")) { break; } + flag = ARKodeEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { break; } // Output solution and errors sunrealtype eng; @@ -260,8 +260,8 @@ int main(int argc, char* argv[]) /* Output to the screen periodically */ long int nst; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ARKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); if (nst % 1000 == 0) { @@ -288,14 +288,14 @@ int main(int argc, char* argv[]) long int nst, nst_a, netf, nfe, nfi; // Get final statistics on how the solve progressed - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ARKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(flag, "ARKStepGetNumStepAttempts"); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(flag, "ARKodeGetNumStepAttempts"); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(flag, "ARKStepGetNumErrTestFails"); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(flag, "ARKodeGetNumErrTestFails"); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(flag, "ARKStepGetNumRhsEvals"); @@ -311,20 +311,20 @@ int main(int argc, char* argv[]) { long int nsetups, nje, nfeLS, nni, ncfn; - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(flag, "ARKStepGetNumNonlinSolvIters"); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(flag, "ARKodeGetNumNonlinSolvIters"); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(flag, "ARKStepGetNumNonlinSolvConvFails"); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(flag, "ARKodeGetNumNonlinSolvConvFails"); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(flag, "ARKStepGetNumLinSolvSetups"); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(flag, "ARKodeGetNumLinSolvSetups"); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(flag, "ARKStepGetNumJacEvals"); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(flag, "ARKodeGetNumJacEvals"); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(flag, "ARKStepGetNumLinRhsEvals"); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(flag, "ARKodeGetNumLinRhsEvals"); std::cout << " Total number of Newton iterations = " << nni << "\n"; std::cout << " Total number of linear solver convergence failures = " << ncfn @@ -339,23 +339,23 @@ int main(int argc, char* argv[]) { long int nre, nrje, nrf, nrbf, nrnlsi, nrnlsf; - flag = ARKStepGetNumRelaxFnEvals(arkode_mem, &nre); - check_flag(flag, "ARKStepGetNumRelaxFnEvals"); + flag = ARKodeGetNumRelaxFnEvals(arkode_mem, &nre); + check_flag(flag, "ARKodeGetNumRelaxFnEvals"); - flag = ARKStepGetNumRelaxJacEvals(arkode_mem, &nrje); - check_flag(flag, "ARKStepGetNumRelaxJacEvals"); + flag = ARKodeGetNumRelaxJacEvals(arkode_mem, &nrje); + check_flag(flag, "ARKodeGetNumRelaxJacEvals"); - flag = ARKStepGetNumRelaxFails(arkode_mem, &nrf); - check_flag(flag, "ARKStepGetNumRelaxFails"); + flag = ARKodeGetNumRelaxFails(arkode_mem, &nrf); + check_flag(flag, "ARKodeGetNumRelaxFails"); - flag = ARKStepGetNumRelaxBoundFails(arkode_mem, &nrbf); - check_flag(flag, "ARKStepGetNumRelaxBoundFails"); + flag = ARKodeGetNumRelaxBoundFails(arkode_mem, &nrbf); + check_flag(flag, "ARKodeGetNumRelaxBoundFails"); - flag = ARKStepGetNumRelaxSolveFails(arkode_mem, &nrnlsf); - check_flag(flag, "ARKStepGetNumRelaxSolveFails"); + flag = ARKodeGetNumRelaxSolveFails(arkode_mem, &nrnlsf); + check_flag(flag, "ARKodeGetNumRelaxSolveFails"); - flag = ARKStepGetNumRelaxSolveIters(arkode_mem, &nrnlsi); - check_flag(flag, "ARKStepGetNumRelaxSolveIters"); + flag = ARKodeGetNumRelaxSolveIters(arkode_mem, &nrnlsi); + check_flag(flag, "ARKodeGetNumRelaxSolveIters"); std::cout << " Total Relaxation Fn evals = " << nre << "\n"; std::cout << " Total Relaxation Jac evals = " << nrje << "\n"; @@ -370,8 +370,8 @@ int main(int argc, char* argv[]) * Clean up * * -------- */ - // Free ARKStep integrator and SUNDIALS objects - ARKStepFree(&arkode_mem); + // Free ARKODE integrator and SUNDIALS objects + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); SUNMatDestroy(A); N_VDestroy(y); diff --git a/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.cpp b/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.cpp index 67d2b9db30..25b366c677 100644 --- a/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.cpp +++ b/examples/arkode/CXX_superludist/ark_brusselator1D_FEM_sludist.cpp @@ -342,22 +342,22 @@ int main(int argc, char* argv[]) /* Set routines */ /* Pass udata to user functions */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { MPI_Abort(grid.comm, 1); } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { MPI_Abort(grid.comm, 1); } /* Specify residual tolerance */ - retval = ARKStepResStolerance(arkode_mem, abstol); - if (check_retval(&retval, "ARKStepResStolerance", 1)) + retval = ARKodeResStolerance(arkode_mem, abstol); + if (check_retval(&retval, "ARKodeResStolerance", 1)) { MPI_Abort(grid.comm, 1); } @@ -481,28 +481,28 @@ int main(int argc, char* argv[]) MPI_Abort(grid.comm, 1); } - /* Attach the matrix, linear solver, and Jacobian construction routine to ARKStep */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) + /* Attach the matrix, linear solver, and Jacobian construction routine to ARKODE */ + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { MPI_Abort(grid.comm, 1); } /* Supply Jac routine */ - retval = ARKStepSetJacFn(arkode_mem, Jac); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { MPI_Abort(grid.comm, 1); } + retval = ARKodeSetJacFn(arkode_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { MPI_Abort(grid.comm, 1); } - /* Attach the mass matrix, linear solver and construction routines to ARKStep; - notify ARKStep that the mass matrix is not time-dependent */ - retval = ARKStepSetMassLinearSolver(arkode_mem, MLS, M, SUNFALSE); - if (check_retval(&retval, "ARKStepSetMassLinearSolver", 1)) + /* Attach the mass matrix, linear solver and construction routines to ARKODE; + notify ARKode that the mass matrix is not time-dependent */ + retval = ARKodeSetMassLinearSolver(arkode_mem, MLS, M, SUNFALSE); + if (check_retval(&retval, "ARKodeSetMassLinearSolver", 1)) { MPI_Abort(grid.comm, 1); } /* Supply M routine */ - retval = ARKStepSetMassFn(arkode_mem, MassMatrix); - if (check_retval(&retval, "ARKStepSetMassFn", 1)) { MPI_Abort(grid.comm, 1); } + retval = ARKodeSetMassFn(arkode_mem, MassMatrix); + if (check_retval(&retval, "ARKodeSetMassFn", 1)) { MPI_Abort(grid.comm, 1); } /* output mesh to disk */ FID = fopen("bruss_FEM_mesh.txt", "w"); @@ -527,7 +527,7 @@ int main(int argc, char* argv[]) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = Tf / Nt; @@ -536,9 +536,8 @@ int main(int argc, char* argv[]) printf(" ----------------------------------------------\n"); for (iout = 0; iout < Nt; iout++) { - retval = ARKStepEvolve(arkode_mem, tout, y, &t, - ARK_NORMAL); /* call integrator */ - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } u = N_VWL2Norm(y, umask); /* access/print solution statistics */ u = sqrt(u * u / N); v = N_VWL2Norm(y, vmask); @@ -572,28 +571,28 @@ int main(int argc, char* argv[]) fclose(WFID); /* Print some final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); - retval = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_retval(&retval, "ARKStepGetNumLinSolvSetups", 1); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1); - retval = ARKStepGetNumMassSetups(arkode_mem, &nmset); - check_retval(&retval, "ARKStepGetNumMassSetups", 1); - retval = ARKStepGetNumMassSolves(arkode_mem, &nms); - check_retval(&retval, "ARKStepGetNumMassSolves", 1); - retval = ARKStepGetNumMassMult(arkode_mem, &nMv); - check_retval(&retval, "ARKStepGetNumMassMult", 1); - retval = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_retval(&retval, "ARKStepGetNumJacEvals", 1); + retval = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_retval(&retval, "ARKodeGetNumLinSolvSetups", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1); + retval = ARKodeGetNumMassSetups(arkode_mem, &nmset); + check_retval(&retval, "ARKodeGetNumMassSetups", 1); + retval = ARKodeGetNumMassSolves(arkode_mem, &nms); + check_retval(&retval, "ARKodeGetNumMassSolves", 1); + retval = ARKodeGetNumMassMult(arkode_mem, &nMv); + check_retval(&retval, "ARKodeGetNumMassMult", 1); + retval = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -613,8 +612,8 @@ int main(int argc, char* argv[]) N_VDestroy(umask); N_VDestroy(vmask); N_VDestroy(wmask); - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solvers */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solvers */ SUNLinSolFree(MLS); SUNMatDestroy(A); /* Free matrices */ SUNMatDestroy(M); diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp index e1a02fed2f..3d11f6a539 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_hypre_pfmg_xbraid.cpp @@ -448,7 +448,7 @@ int main(int argc, char* argv[]) } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -456,45 +456,45 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->matvec) { // Attach Jacobian-vector product function - flag = ARKStepSetJacTimes(arkode_mem, NULL, JTimes); - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, JTimes); + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -518,8 +518,8 @@ int main(int argc, char* argv[]) // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set adaptive stepping (XBraid with temporal refinement) options @@ -528,16 +528,16 @@ int main(int argc, char* argv[]) // Use I controller with default parameters C = SUNAdaptController_I(ctx); if (check_flag((void*)C, "SUNAdaptController_I", 0)) { return 1; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } // Set the step size reduction factor limit (1 / refinement factor limit) - flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); - if (check_flag(&flag, "ARKStepSetMinReduction", 1)) { return 1; } + flag = ARKodeSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); + if (check_flag(&flag, "ARKodeSetMinReduction", 1)) { return 1; } // Set the failed solve step size reduction factor (1 / refinement factor) - flag = ARKStepSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); - if (check_flag(&flag, "ARKStepSetMaxCFailGrowth", 1)) { return 1; } + flag = ARKodeSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); + if (check_flag(&flag, "ARKodeSetMaxCFailGrowth", 1)) { return 1; } } // ------------------------ @@ -701,10 +701,10 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; braid_Destroy(core); // Free braid memory ARKBraid_Free(&app); // Free interface memory @@ -2889,28 +2889,28 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } // Reduce stats across time MPI_Allreduce(MPI_IN_PLACE, &nst, 1, MPI_LONG, MPI_MAX, udata->comm_w); @@ -2955,10 +2955,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } MPI_Allreduce(MPI_IN_PLACE, &npe, 1, MPI_LONG, MPI_MAX, udata->comm_w); MPI_Allreduce(MPI_IN_PLACE, &nps, 1, MPI_LONG, MPI_MAX, udata->comm_w); diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp index 0fb944fdfa..686862ea5a 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp @@ -402,7 +402,7 @@ int main(int argc, char* argv[]) } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -410,38 +410,38 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -465,8 +465,8 @@ int main(int argc, char* argv[]) // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set adaptive stepping (XBraid with temporal refinement) options @@ -475,16 +475,16 @@ int main(int argc, char* argv[]) // Use I controller with default parameters C = SUNAdaptController_I(ctx); if (check_flag((void*)C, "SUNAdaptController_I", 0)) { return 1; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } // Set the step size reduction factor limit (1 / refinement factor limit) - flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); - if (check_flag(&flag, "ARKStepSetMinReduction", 1)) { return 1; } + flag = ARKodeSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); + if (check_flag(&flag, "ARKodeSetMinReduction", 1)) { return 1; } // Set the failed solve step size reduction factor (1 / refinement factor) - flag = ARKStepSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); - if (check_flag(&flag, "ARKStepSetMaxCFailGrowth", 1)) { return 1; } + flag = ARKodeSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); + if (check_flag(&flag, "ARKodeSetMaxCFailGrowth", 1)) { return 1; } } // ------------------------ @@ -648,10 +648,10 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; braid_Destroy(core); // Free braid memory ARKBraid_Free(&app); // Free interface memory @@ -2053,28 +2053,28 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } // Reduce stats across time MPI_Allreduce(MPI_IN_PLACE, &nst, 1, MPI_LONG, MPI_MAX, udata->comm_w); @@ -2119,10 +2119,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } MPI_Allreduce(MPI_IN_PLACE, &npe, 1, MPI_LONG, MPI_MAX, udata->comm_w); MPI_Allreduce(MPI_IN_PLACE, &nps, 1, MPI_LONG, MPI_MAX, udata->comm_w); diff --git a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp index cfddfbbdd7..3ca94f8fcf 100644 --- a/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp +++ b/examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp @@ -41,7 +41,7 @@ * with a diagonally implicit Runge-Kutta method from the ARKODE ARKStep module * using an inexact Newton method paired with the PCG or SPGMR linear solver. * Several command line options are available to change the problem parameters - * and ARKStep settings. Use the flag --help for more information. + * and ARKODE settings. Use the flag --help for more information. * ---------------------------------------------------------------------------*/ #include @@ -340,7 +340,7 @@ int main(int argc, char* argv[]) } // -------------- - // Setup ARKStep + // Setup ARKODE // -------------- // Create integrator @@ -348,38 +348,38 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkode_mem, udata->rtol, udata->atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, udata->rtol, udata->atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Attach user data - flag = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } if (udata->prec) { // Attach preconditioner - flag = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Set linear solver setup frequency (update preconditioner) - flag = ARKStepSetLSetupFrequency(arkode_mem, udata->msbp); - if (check_flag(&flag, "ARKStepSetLSetupFrequency", 1)) { return 1; } + flag = ARKodeSetLSetupFrequency(arkode_mem, udata->msbp); + if (check_flag(&flag, "ARKodeSetLSetupFrequency", 1)) { return 1; } } // Set linear solver tolerance factor - flag = ARKStepSetEpsLin(arkode_mem, udata->epslin); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return 1; } + flag = ARKodeSetEpsLin(arkode_mem, udata->epslin); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return 1; } // Select method order if (udata->order > 1) { // Use an ARKode provided table - flag = ARKStepSetOrder(arkode_mem, udata->order); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, udata->order); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } } else { @@ -403,8 +403,8 @@ int main(int argc, char* argv[]) // Specify linearly implicit non-time-dependent RHS if (udata->linear) { - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // Set adaptive stepping (XBraid with temporal refinement) options @@ -413,16 +413,16 @@ int main(int argc, char* argv[]) // Use I controller with default parameters C = SUNAdaptController_I(ctx); if (check_flag((void*)C, "SUNAdaptController_I", 0)) { return 1; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } // Set the step size reduction factor limit (1 / refinement factor limit) - flag = ARKStepSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); - if (check_flag(&flag, "ARKStepSetMinReduction", 1)) { return 1; } + flag = ARKodeSetMinReduction(arkode_mem, ONE / udata->x_rfactor_limit); + if (check_flag(&flag, "ARKodeSetMinReduction", 1)) { return 1; } // Set the failed solve step size reduction factor (1 / refinement factor) - flag = ARKStepSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); - if (check_flag(&flag, "ARKStepSetMaxCFailGrowth", 1)) { return 1; } + flag = ARKodeSetMaxCFailGrowth(arkode_mem, ONE / udata->x_rfactor_fail); + if (check_flag(&flag, "ARKodeSetMaxCFailGrowth", 1)) { return 1; } } // ------------------------ @@ -586,10 +586,10 @@ int main(int argc, char* argv[]) // Clean up and return // -------------------- - ARKStepFree(&arkode_mem); // Free integrator memory - SUNLinSolFree(LS); // Free linear solver - N_VDestroy(u); // Free vectors - FreeUserData(udata); // Free user data + ARKodeFree(&arkode_mem); // Free integrator memory + SUNLinSolFree(LS); // Free linear solver + N_VDestroy(u); // Free vectors + FreeUserData(udata); // Free user data delete udata; braid_Destroy(core); // Free braid memory ARKBraid_Free(&app); // Free interface memory @@ -1352,28 +1352,28 @@ static int OutputStats(void* arkode_mem, UserData* udata) // Get integrator and solver stats long int nst, nst_a, netf, nfe, nfi, nni, ncfn, nli, nlcf, nsetups, nfi_ls, nJv; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return -1; } - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - if (check_flag(&flag, "ARKStepGetNumStepAttempts", 1)) { return -1; } - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - if (check_flag(&flag, "ARKStepGetNumErrTestFails", 1)) { return -1; } + flag = ARKodeGetNumSteps(arkode_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return -1; } + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + if (check_flag(&flag, "ARKodeGetNumStepAttempts", 1)) { return -1; } + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + if (check_flag(&flag, "ARKodeGetNumErrTestFails", 1)) { return -1; } flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return -1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return -1; } - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return -1; } - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return -1; } - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfi_ls); - if (check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1)) { return -1; } - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return -1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return -1; } + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return -1; } + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return -1; } + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfi_ls); + if (check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1)) { return -1; } + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return -1; } // Reduce stats across time MPI_Allreduce(MPI_IN_PLACE, &nst, 1, MPI_LONG, MPI_MAX, udata->comm_w); @@ -1418,10 +1418,10 @@ static int OutputStats(void* arkode_mem, UserData* udata) if (udata->prec) { long int npe, nps; - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return -1; } - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return -1; } + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return -1; } + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return -1; } MPI_Allreduce(MPI_IN_PLACE, &npe, 1, MPI_LONG, MPI_MAX, udata->comm_w); MPI_Allreduce(MPI_IN_PLACE, &nps, 1, MPI_LONG, MPI_MAX, udata->comm_w); diff --git a/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c b/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c index ff80e737d2..dca37e62d8 100644 --- a/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c +++ b/examples/arkode/C_manyvector/ark_brusselator1D_manyvec.c @@ -201,22 +201,22 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)userdata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)userdata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize spgmr solver */ LS = SUNLinSol_SPGMR(y, SUN_PREC_NONE, 10, ctx); if (check_flag((void*)LS, "SUNLinSol_SPGMR", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); /* Attach linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, - JacVI); /* Set the Jacobian-vector product */ - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); /* Attach linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, + JacVI); /* Set the Jacobian-vector product */ + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } /* output spatial mesh to disk */ FID = fopen("bruss_mesh.txt", "w"); @@ -239,7 +239,7 @@ int main(void) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -249,8 +249,8 @@ int main(void) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } /* print solution statistics */ unorm = N_VDotProd(u, u); @@ -288,28 +288,28 @@ int main(void) fclose(WFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1); - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1); - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - check_flag(&flag, "ARKStepGetNumJtimesEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1); + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1); + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + check_flag(&flag, "ARKodeGetNumJtimesEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -329,10 +329,10 @@ int main(void) N_VDestroy(u); N_VDestroy(v); N_VDestroy(w); - free(userdata); /* Free user data */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free context */ + free(userdata); /* Free user data */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_openmp/ark_brusselator1D_omp.c b/examples/arkode/C_openmp/ark_brusselator1D_omp.c index 8a57f87c5f..2dde9c37ee 100644 --- a/examples/arkode/C_openmp/ark_brusselator1D_omp.c +++ b/examples/arkode/C_openmp/ark_brusselator1D_omp.c @@ -236,18 +236,18 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Linear solver specification */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* output spatial mesh to disk */ FID = fopen("bruss_mesh.txt", "w"); @@ -269,7 +269,7 @@ int main(int argc, char* argv[]) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -278,8 +278,8 @@ int main(int argc, char* argv[]) printf(" ----------------------------------------------\n"); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } u = N_VWL2Norm(y, umask); /* access/print solution statistics */ u = sqrt(u * u / N); v = N_VWL2Norm(y, vmask); @@ -313,24 +313,24 @@ int main(int argc, char* argv[]) fclose(WFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -344,11 +344,11 @@ int main(int argc, char* argv[]) printf(" Total number of error test failures = %li\n\n", netf); /* Clean up and return with successful completion */ - free(udata); /* Free user data */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free matrix */ - N_VDestroy(y); /* Free vectors */ + free(udata); /* Free user data */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free matrix */ + N_VDestroy(y); /* Free vectors */ N_VDestroy(umask); N_VDestroy(vmask); N_VDestroy(wmask); diff --git a/examples/arkode/C_openmp/ark_heat1D_omp.c b/examples/arkode/C_openmp/ark_heat1D_omp.c index e59b1f03d0..4fc8eb998b 100644 --- a/examples/arkode/C_openmp/ark_heat1D_omp.c +++ b/examples/arkode/C_openmp/ark_heat1D_omp.c @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) int flag; /* reusable error-checking flag */ N_Vector y = NULL; /* empty vector for storing solution */ SUNLinearSolver LS = NULL; /* empty linear solver object */ - void* arkode_mem = NULL; /* empty ARKStep memory structure */ + void* arkode_mem = NULL; /* empty ARKODE memory structure */ FILE *FID, *UFID; sunrealtype t, dTout, tout; int iout, num_threads; @@ -139,31 +139,31 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, - 1); /* Specify maximum-order predictor */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, + 1); /* Specify maximum-order predictor */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize PCG solver -- no preconditioning, with up to N iterations */ LS = SUNLinSol_PCG(y, 0, (int)N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } /* Linear solver interface -- set user-supplied J*v routine (no 'jtsetup' required) */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - NULL); /* Attach linear solver to ARKStep */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + NULL); /* Attach linear solver to ARKODE */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* output mesh to disk */ FID = fopen("heat_mesh.txt", "w"); @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) for (i = 0; i < N; i++) { fprintf(UFID, " %.16" ESYM "", data[i]); } fprintf(UFID, "\n"); - /* Main time-stepping loop: calls ARKStep to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -188,8 +188,8 @@ int main(int argc, char* argv[]) printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); /* print solution stats */ if (flag >= 0) @@ -211,26 +211,26 @@ int main(int argc, char* argv[]) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1); - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - check_flag(&flag, "ARKStepGetNumJtimesEvals", 1); - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1); + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + check_flag(&flag, "ARKodeGetNumJtimesEvals", 1); + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -245,11 +245,11 @@ int main(int argc, char* argv[]) printf(" Total number of error test failures = %li\n", netf); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free vectors */ - free(udata); /* Free user data */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free vectors */ + free(udata); /* Free user data */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c b/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c index 83d89bfc0f..1f847e9dfe 100644 --- a/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c +++ b/examples/arkode/C_openmpdev/ark_analytic_nonlin_ompdev.c @@ -96,8 +96,8 @@ int main(void) if (check_flag((void*)arkode_mem, "ERKStepCreate", 0)) { return 1; } /* Specify tolerances */ - flag = ERKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ERKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -107,7 +107,7 @@ int main(void) N_VCopyFromDevice_OpenMPDEV(y); fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", T0, y_data[0]); - /* Main time-stepping loop: calls ERKStep to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -115,8 +115,8 @@ int main(void) printf(" ---------------------\n"); while (Tf - t > 1.0e-15) { - flag = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ERKStep", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } N_VCopyFromDevice_OpenMPDEV(y); printf(" %10.6" FSYM " %10.6" FSYM "\n", t, y_data[0]); /* access/print solution */ @@ -136,14 +136,14 @@ int main(void) fclose(UFID); /* Print some final statistics */ - flag = ERKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ERKStepGetNumSteps", 1); - flag = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ERKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ERKStepGetNumRhsEvals(arkode_mem, &nfe); check_flag(&flag, "ERKStepGetNumRhsEvals", 1); - flag = ERKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ERKStepGetNumErrTestFails", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -151,9 +151,9 @@ int main(void) printf(" Total number of error test failures = %li\n\n", netf); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free y vector */ - ERKStepFree(&arkode_mem); /* Free integrator memory */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_openmpdev/ark_heat1D_adapt_ompdev.c b/examples/arkode/C_openmpdev/ark_heat1D_adapt_ompdev.c index ec98fbcd5a..7d12f225f8 100644 --- a/examples/arkode/C_openmpdev/ark_heat1D_adapt_ompdev.c +++ b/examples/arkode/C_openmpdev/ark_heat1D_adapt_ompdev.c @@ -184,41 +184,41 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } - flag = ARKStepSetAdaptivityMethod(arkode_mem, 2, 1, 0, - NULL); /* Set adaptivity method */ - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, 0); /* Set predictor method */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetAdaptivityMethod(arkode_mem, 2, 1, 0, + NULL); /* Set adaptivity method */ + if (check_flag(&flag, "ARKodeSetAdaptivityMethod", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, 0); /* Set predictor method */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } /* Specify I-controller with default parameters */ C = SUNAdaptController_I(ctx); if (check_flag((void*)C, "SUNAdaptController_I", 0)) { return 1; } - flag = ARKStepSetAdaptController(arkode_mem, C); - if (check_flag(&flag, "ARKStepSetAdaptController", 1)) { return 1; } + flag = ARKodeSetAdaptController(arkode_mem, C); + if (check_flag(&flag, "ARKodeSetAdaptController", 1)) { return 1; } /* Specify linearly implicit RHS, with time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 1); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 1); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Initialize PCG solver -- no preconditioning, with up to N iterations */ LS = SUNLinSol_PCG(y, 0, (int)N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } /* Linear solver interface -- set user-supplied J*v routine (no 'jtsetup' required) */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - NULL); /* Attach linear solver to ARKStep */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + NULL); /* Attach linear solver to ARKODE */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; olddt = ZERO; @@ -234,24 +234,24 @@ int main(void) while (t < Tf) { /* "set" routines */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } - flag = ARKStepSetInitStep(arkode_mem, newdt); - if (check_flag(&flag, "ARKStepSetInitStep", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } + flag = ARKodeSetInitStep(arkode_mem, newdt); + if (check_flag(&flag, "ARKodeSetInitStep", 1)) { return 1; } /* call integrator */ - flag = ARKStepEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } /* "get" routines */ - flag = ARKStepGetLastStep(arkode_mem, &olddt); - if (check_flag(&flag, "ARKStepGetLastStep", 1)) { return 1; } - flag = ARKStepGetCurrentStep(arkode_mem, &newdt); - if (check_flag(&flag, "ARKStepGetCurrentStep", 1)) { return 1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return 1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return 1; } + flag = ARKodeGetLastStep(arkode_mem, &olddt); + if (check_flag(&flag, "ARKodeGetLastStep", 1)) { return 1; } + flag = ARKodeGetCurrentStep(arkode_mem, &newdt); + if (check_flag(&flag, "ARKodeGetCurrentStep", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return 1; } /* print current solution stats */ iout++; @@ -307,18 +307,18 @@ int main(void) y = y2; y2 = yt; - /* call ARKStepResize to notify integrator of change in mesh */ - flag = ARKStepResize(arkode_mem, y, hscale, t, NULL, NULL); - if (check_flag(&flag, "ARKStepResize", 1)) { return 1; } + /* call ARKodeResize to notify integrator of change in mesh */ + flag = ARKodeResize(arkode_mem, y, hscale, t, NULL, NULL); + if (check_flag(&flag, "ARKodeResize", 1)) { return 1; } - /* destroy and re-allocate linear solver memory; reattach to ARKStep interface */ + /* destroy and re-allocate linear solver memory; reattach to ARKODE interface */ SUNLinSolFree(LS); LS = SUNLinSol_PCG(y, 0, (int)N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } } printf(" --------------------------------------------------------------------" "--------------------\n"); @@ -336,7 +336,7 @@ int main(void) free(udata->x_host); /* Free user data */ omp_target_free(udata->x_dev, dev); free(udata); - ARKStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ SUNLinSolFree(LS); /* Free linear solver */ (void)SUNAdaptController_Destroy(C); /* Free time adaptivity controller */ SUNContext_Free(&ctx); /* Free context */ diff --git a/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c b/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c index f85ec24efb..82e13c66a7 100644 --- a/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c +++ b/examples/arkode/C_openmpdev/ark_heat1D_ompdev.c @@ -97,7 +97,7 @@ int main(void) int flag; /* reusable error-checking flag */ N_Vector y = NULL; /* empty vector for storing solution */ SUNLinearSolver LS = NULL; /* empty linear solver object */ - void* arkode_mem = NULL; /* empty ARKStep memory structure */ + void* arkode_mem = NULL; /* empty ARKODE memory structure */ FILE *FID, *UFID; sunrealtype t, dTout, tout; int iout; @@ -132,31 +132,31 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, - 1); /* Specify maximum-order predictor */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, + 1); /* Specify maximum-order predictor */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize PCG solver -- no preconditioning, with up to N iterations */ LS = SUNLinSol_PCG(y, 0, N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } /* Linear solver interface -- set user-supplied J*v routine (no 'jtsetup' required) */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - NULL); /* Attach linear solver to ARKStep */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + NULL); /* Attach linear solver to ARKStep */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* output mesh to disk */ FID = fopen("heat_mesh.txt", "w"); @@ -172,7 +172,7 @@ int main(void) for (i = 0; i < N; i++) { fprintf(UFID, " %.16" ESYM "", data[i]); } fprintf(UFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -182,8 +182,8 @@ int main(void) printf(" %10.6" FSYM " %10.6" FSYM "\n", t, SUNRsqrt(N_VDotProd(y, y) / N)); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStep", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6" FSYM "\n", t, SUNRsqrt(N_VDotProd(y, y) / N)); /* print solution stats */ if (flag >= 0) @@ -207,26 +207,26 @@ int main(void) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1); - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - check_flag(&flag, "ARKStepGetNumJtimesEvals", 1); - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1); + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + check_flag(&flag, "ARKodeGetNumJtimesEvals", 1); + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -241,11 +241,11 @@ int main(void) printf(" Total number of error test failures = %li\n", netf); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free vectors */ - free(udata); /* Free user data */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free vectors */ + free(udata); /* Free user data */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c b/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c index ab26d152eb..73825d1221 100644 --- a/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c +++ b/examples/arkode/C_parallel/ark_brusselator1D_task_local_nls.c @@ -371,20 +371,20 @@ int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNContext c if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Select the method order */ - retval = ARKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ARKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } /* Attach user data */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Create the (non)linear solver */ if (uopt->global) @@ -394,20 +394,20 @@ int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNContext c if (check_retval((void*)NLS, "SUNNonlinSol_Newton", 0)) { return 1; } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1)) { return 1; } + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1)) { return 1; } /* Create linear solver */ LS = SUNLinSol_SPGMR(y, SUN_PREC_LEFT, 0, ctx); if (check_retval((void*)LS, "SUNLinSol_SPGMR", 0)) { return 1; } /* Attach linear solver */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Attach preconditioner */ - retval = ARKStepSetPreconditioner(arkode_mem, PSetup, PSolve); - if (check_retval(&retval, "ARKStepSetPreconditioner", 1)) { return 1; } + retval = ARKodeSetPreconditioner(arkode_mem, PSetup, PSolve); + if (check_retval(&retval, "ARKodeSetPreconditioner", 1)) { return 1; } } else { @@ -417,8 +417,8 @@ int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNContext c if (check_retval((void*)NLS, "TaskLocalNewton", 0)) { return 1; } /* Attach nonlinear solver */ - retval = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&retval, "ARKStepSetNonlinearSolver", 1)) { return 1; } + retval = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&retval, "ARKodeSetNonlinearSolver", 1)) { return 1; } } /* Output initial condition */ @@ -438,8 +438,8 @@ int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNContext c do { /* Integrate to output time */ - retval = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* Output state */ WriteOutput(t, y, udata, uopt); @@ -453,26 +453,26 @@ int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNContext c while (iout < uopt->nout); /* Get final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncnf); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncnf); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1); if (uopt->global) { - retval = ARKStepGetNumLinIters(arkode_mem, &nli); - check_retval(&retval, "ARKStepGetNumLinIters", 1); - retval = ARKStepGetNumPrecEvals(arkode_mem, &npre); - check_retval(&retval, "ARKStepGetNumPrecEvals", 1); - retval = ARKStepGetNumPrecSolves(arkode_mem, &npsol); - check_retval(&retval, "ARKStepGetNumPrecSolves", 1); + retval = ARKodeGetNumLinIters(arkode_mem, &nli); + check_retval(&retval, "ARKodeGetNumLinIters", 1); + retval = ARKodeGetNumPrecEvals(arkode_mem, &npre); + check_retval(&retval, "ARKodeGetNumPrecEvals", 1); + retval = ARKodeGetNumPrecSolves(arkode_mem, &npsol); + check_retval(&retval, "ARKodeGetNumPrecSolves", 1); } /* Print final statistics */ @@ -494,7 +494,7 @@ int EvolveProblemIMEX(N_Vector y, UserData udata, UserOptions uopt, SUNContext c } /* Clean up */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNNonlinSolFree(NLS); if (LS) { SUNLinSolFree(LS); } @@ -518,20 +518,20 @@ int EvolveProblemExplicit(N_Vector y, UserData udata, UserOptions uopt, if (check_retval((void*)arkode_mem, "ERKStepCreate", 0)) { return 1; } /* Select the method order */ - retval = ERKStepSetOrder(arkode_mem, uopt->order); - if (check_retval(&retval, "ERKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, uopt->order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } /* Attach user data */ - retval = ERKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ERKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Specify tolerances */ - retval = ERKStepSStolerances(arkode_mem, uopt->rtol, uopt->atol); - if (check_retval(&retval, "ERKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, uopt->rtol, uopt->atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Increase the max number of steps allowed between outputs */ - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Output initial condition */ if (udata->myid == 0 && uopt->monitor) @@ -550,8 +550,8 @@ int EvolveProblemExplicit(N_Vector y, UserData udata, UserOptions uopt, do { /* Integrate to output time */ - retval = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* Output state */ WriteOutput(t, y, udata, uopt); @@ -565,14 +565,14 @@ int EvolveProblemExplicit(N_Vector y, UserData udata, UserOptions uopt, while (iout < uopt->nout); /* Get final statistics */ - retval = ERKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ERKStepGetNumSteps", 1); - retval = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ERKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ERKStepGetNumRhsEvals(arkode_mem, &nfe); check_retval(&retval, "ERKStepGetNumRhsEvals", 1); - retval = ERKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ERKStepGetNumErrTestFails", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); /* Print final statistics */ if (udata->myid == 0) @@ -584,7 +584,7 @@ int EvolveProblemExplicit(N_Vector y, UserData udata, UserOptions uopt, } /* Clean up */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* Return success */ return 0; @@ -892,9 +892,9 @@ int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem) double tcur, gamma; void* user_data; - retval = ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, - &gamma, &sdata, &user_data); - if (check_retval((void*)&retval, "ARKStepGetNonlinearSystemData", 1)) + retval = ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, + &gamma, &sdata, &user_data); + if (check_retval((void*)&retval, "ARKodeGetNonlinearSystemData", 1)) { return (-1); } @@ -948,9 +948,9 @@ int TaskLocalLSolve(N_Vector delta, void* arkode_mem) double tcur, gamma; void* user_data = NULL; - retval = ARKStepGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, - &gamma, &sdata, &user_data); - if (check_retval((void*)&retval, "ARKStepGetNonlinearSystemData", 1)) + retval = ARKodeGetNonlinearSystemData(arkode_mem, &tcur, &zpred, &z, &Fi, + &gamma, &sdata, &user_data); + if (check_retval((void*)&retval, "ARKodeGetNonlinearSystemData", 1)) { return (-1); } diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c index 46eeb4b865..97802077ee 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.c @@ -229,21 +229,21 @@ int main(int argc, char* argv[]) } /* Set the pointer to user-defined data */ - flag = ARKStepSetUserData(arkode_mem, data); - if (check_flag(&flag, "ARKStepSetUserData", 1, my_pe)) { MPI_Abort(comm, 1); } + flag = ARKodeSetUserData(arkode_mem, data); + if (check_flag(&flag, "ARKodeSetUserData", 1, my_pe)) { MPI_Abort(comm, 1); } - /* Call ARKStepSetMaxNumSteps to increase default */ - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1, my_pe)) { return (1); } + /* Call ARKodeSetMaxNumSteps to increase default */ + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1, my_pe)) { return (1); } - /* Call ARKStepSStolerances to specify the scalar relative tolerance + /* Call ARKodeSStolerances to specify the scalar relative tolerance and scalar absolute tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1, my_pe)) { return (1); } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1, my_pe)) { return (1); } - /* Attach SPGMR solver structure to ARKStep interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1, my_pe)) + /* Attach SPGMR solver structure to ARKODE interface */ + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1, my_pe)) { MPI_Abort(comm, 1); } @@ -256,8 +256,8 @@ int main(int argc, char* argv[]) if (check_flag(&flag, "ARKBBDPrecInit", 1, my_pe)) { MPI_Abort(comm, 1); } /* Tighten nonlinear solver tolerance */ - flag = ARKStepSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1, my_pe)) + flag = ARKodeSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1, my_pe)) { MPI_Abort(comm, 1); } @@ -302,11 +302,11 @@ int main(int argc, char* argv[]) (jpre == SUN_PREC_LEFT) ? "SUN_PREC_LEFT" : "SUN_PREC_RIGHT"); } - /* In loop over output points, call ARKStepEvolve, print results, test for error */ + /* In loop over output points, call ARKodeEvolve, print results, test for error */ for (iout = 1, tout = TWOHR; iout <= NOUT; iout++, tout += TWOHR) { - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1, my_pe)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1, my_pe)) { break; } PrintOutput(arkode_mem, my_pe, comm, u, t); } @@ -318,7 +318,7 @@ int main(int argc, char* argv[]) /* Free memory */ N_VDestroy(u); free(data); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); SUNContext_Free(&ctx); MPI_Finalize(); @@ -447,10 +447,10 @@ static void PrintOutput(void* arkode_mem, int my_pe, MPI_Comm comm, N_Vector u, { MPI_Recv(&tempu[0], 2, MPI_SUNREALTYPE, npelast, 0, comm, &status); } - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1, my_pe); - flag = ARKStepGetLastStep(arkode_mem, &hu); - check_flag(&flag, "ARKStepGetLastStep", 1, my_pe); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe); + flag = ARKodeGetLastStep(arkode_mem, &hu); + check_flag(&flag, "ARKodeGetLastStep", 1, my_pe); #if defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld stepsize = %.2Le\n", t, nst, hu); printf("At bottom left: c1, c2 = %12.3Le %12.3Le \n", uarray[0], uarray[1]); @@ -477,33 +477,33 @@ static void PrintFinalStats(void* arkode_mem) long int nli, npe, nps, ncfl, nfeLS, ngevalsBBDP; int flag; - flag = ARKStepGetWorkSpace(arkode_mem, &lenrw, &leniw); - check_flag(&flag, "ARKStepGetWorkSpace", 1, 0); - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1, 0); + flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw); + check_flag(&flag, "ARKodeGetWorkSpace", 1, 0); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1, 0); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1, 0); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1, 0); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1, 0); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1, 0); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1, 0); - - flag = ARKStepGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); - check_flag(&flag, "ARKStepGetLinWorkSpace", 1, 0); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1, 0); - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - check_flag(&flag, "ARKStepGetNumPrecEvals", 1, 0); - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - check_flag(&flag, "ARKStepGetNumPrecSolves", 1, 0); - flag = ARKStepGetNumLinConvFails(arkode_mem, &ncfl); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1, 0); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1, 0); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1, 0); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1, 0); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1, 0); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1, 0); + + flag = ARKodeGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); + check_flag(&flag, "ARKodeGetLinWorkSpace", 1, 0); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1, 0); + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + check_flag(&flag, "ARKodeGetNumPrecEvals", 1, 0); + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + check_flag(&flag, "ARKodeGetNumPrecSolves", 1, 0); + flag = ARKodeGetNumLinConvFails(arkode_mem, &ncfl); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1, 0); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1, 0); printf("\nFinal Statistics: \n\n"); printf("lenrw = %5ld leniw = %5ld\n", lenrw, leniw); diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out index df7478fcae..6ec12802af 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_bbd_p.out @@ -8,57 +8,57 @@ Preconditioner type is: jpre = SUN_PREC_LEFT t = 7.20e+03 no. steps = 980 stepsize = 3.07e+00 -At bottom left: c1, c2 = 1.047e+04 2.527e+11 -At top right: c1, c2 = 1.119e+04 2.700e+11 +At bottom left: c1, c2 = 1.047e+04 2.527e+11 +At top right: c1, c2 = 1.119e+04 2.700e+11 t = 1.44e+04 no. steps = 2730 stepsize = 6.90e+00 -At bottom left: c1, c2 = 6.659e+06 2.582e+11 -At top right: c1, c2 = 7.301e+06 2.833e+11 +At bottom left: c1, c2 = 6.659e+06 2.582e+11 +At top right: c1, c2 = 7.301e+06 2.833e+11 t = 2.16e+04 no. steps = 3533 stepsize = 1.04e+01 -At bottom left: c1, c2 = 2.665e+07 2.993e+11 -At top right: c1, c2 = 2.931e+07 3.313e+11 +At bottom left: c1, c2 = 2.665e+07 2.993e+11 +At top right: c1, c2 = 2.931e+07 3.313e+11 t = 2.88e+04 no. steps = 4681 stepsize = 4.32e+00 -At bottom left: c1, c2 = 8.702e+06 3.380e+11 -At top right: c1, c2 = 9.650e+06 3.751e+11 +At bottom left: c1, c2 = 8.702e+06 3.380e+11 +At top right: c1, c2 = 9.650e+06 3.751e+11 t = 3.60e+04 no. steps = 5975 stepsize = 2.55e+00 -At bottom left: c1, c2 = 1.404e+04 3.387e+11 -At top right: c1, c2 = 1.561e+04 3.765e+11 +At bottom left: c1, c2 = 1.404e+04 3.387e+11 +At top right: c1, c2 = 1.561e+04 3.765e+11 t = 4.32e+04 no. steps = 7163 stepsize = 4.64e+02 -At bottom left: c1, c2 = 2.125e-08 3.382e+11 -At top right: c1, c2 = 4.245e-08 3.804e+11 +At bottom left: c1, c2 = 2.125e-08 3.382e+11 +At top right: c1, c2 = 4.245e-08 3.804e+11 t = 5.04e+04 no. steps = 7179 stepsize = 4.64e+02 -At bottom left: c1, c2 = -4.072e-07 3.358e+11 -At top right: c1, c2 = 4.005e-11 3.864e+11 +At bottom left: c1, c2 = -4.072e-07 3.358e+11 +At top right: c1, c2 = 4.005e-11 3.864e+11 t = 5.76e+04 no. steps = 7195 stepsize = 3.44e+02 -At bottom left: c1, c2 = 3.487e-08 3.320e+11 -At top right: c1, c2 = 3.658e-18 3.909e+11 +At bottom left: c1, c2 = 3.487e-08 3.320e+11 +At top right: c1, c2 = 3.658e-18 3.909e+11 t = 6.48e+04 no. steps = 7210 stepsize = 5.15e+02 -At bottom left: c1, c2 = 2.253e-07 3.313e+11 -At top right: c1, c2 = -2.680e-19 3.963e+11 +At bottom left: c1, c2 = 2.253e-07 3.313e+11 +At top right: c1, c2 = -2.680e-19 3.963e+11 t = 7.20e+04 no. steps = 7224 stepsize = 5.15e+02 -At bottom left: c1, c2 = 8.966e-08 3.330e+11 -At top right: c1, c2 = -1.036e-18 4.039e+11 +At bottom left: c1, c2 = 8.966e-08 3.330e+11 +At top right: c1, c2 = -1.036e-18 4.039e+11 t = 7.92e+04 no. steps = 7238 stepsize = 5.15e+02 -At bottom left: c1, c2 = 2.038e-08 3.334e+11 -At top right: c1, c2 = -2.330e-18 4.120e+11 +At bottom left: c1, c2 = 2.038e-08 3.334e+11 +At top right: c1, c2 = -2.330e-18 4.120e+11 t = 8.64e+04 no. steps = 7252 stepsize = 5.15e+02 -At bottom left: c1, c2 = -3.746e-21 3.352e+11 -At top right: c1, c2 = -2.537e-27 4.163e+11 +At bottom left: c1, c2 = -3.746e-21 3.352e+11 +At top right: c1, c2 = -2.537e-27 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3902 leniw = 267 +lenrw = 3902 leniw = 279 lenrwls = 2455 leniwls = 126 nst = 7252 nfe = 0 nfe = 76929 nfels = 102816 @@ -77,57 +77,57 @@ In ARKBBDPRE: real/integer local work space sizes = 1300, 192 Preconditioner type is: jpre = SUN_PREC_RIGHT t = 7.20e+03 no. steps = 980 stepsize = 3.07e+00 -At bottom left: c1, c2 = 1.047e+04 2.527e+11 -At top right: c1, c2 = 1.119e+04 2.700e+11 +At bottom left: c1, c2 = 1.047e+04 2.527e+11 +At top right: c1, c2 = 1.119e+04 2.700e+11 t = 1.44e+04 no. steps = 2730 stepsize = 6.90e+00 -At bottom left: c1, c2 = 6.659e+06 2.582e+11 -At top right: c1, c2 = 7.301e+06 2.833e+11 +At bottom left: c1, c2 = 6.659e+06 2.582e+11 +At top right: c1, c2 = 7.301e+06 2.833e+11 t = 2.16e+04 no. steps = 3533 stepsize = 1.04e+01 -At bottom left: c1, c2 = 2.665e+07 2.993e+11 -At top right: c1, c2 = 2.931e+07 3.313e+11 +At bottom left: c1, c2 = 2.665e+07 2.993e+11 +At top right: c1, c2 = 2.931e+07 3.313e+11 t = 2.88e+04 no. steps = 4705 stepsize = 3.57e+00 -At bottom left: c1, c2 = 8.702e+06 3.380e+11 -At top right: c1, c2 = 9.650e+06 3.751e+11 +At bottom left: c1, c2 = 8.702e+06 3.380e+11 +At top right: c1, c2 = 9.650e+06 3.751e+11 t = 3.60e+04 no. steps = 6160 stepsize = 2.56e+00 -At bottom left: c1, c2 = 1.404e+04 3.387e+11 -At top right: c1, c2 = 1.561e+04 3.765e+11 +At bottom left: c1, c2 = 1.404e+04 3.387e+11 +At top right: c1, c2 = 1.561e+04 3.765e+11 t = 4.32e+04 no. steps = 7347 stepsize = 4.30e+02 -At bottom left: c1, c2 = 4.255e-12 3.382e+11 -At top right: c1, c2 = -2.358e-07 3.804e+11 +At bottom left: c1, c2 = 4.255e-12 3.382e+11 +At top right: c1, c2 = -2.358e-07 3.804e+11 t = 5.04e+04 no. steps = 7364 stepsize = 4.81e+02 -At bottom left: c1, c2 = -1.312e-17 3.358e+11 -At top right: c1, c2 = 2.130e-11 3.864e+11 +At bottom left: c1, c2 = -1.312e-17 3.358e+11 +At top right: c1, c2 = 2.130e-11 3.864e+11 t = 5.76e+04 no. steps = 7380 stepsize = 2.39e+02 -At bottom left: c1, c2 = -6.762e-21 3.320e+11 -At top right: c1, c2 = -4.330e-12 3.909e+11 +At bottom left: c1, c2 = -6.762e-21 3.320e+11 +At top right: c1, c2 = -4.330e-12 3.909e+11 t = 6.48e+04 no. steps = 7393 stepsize = 6.42e+02 -At bottom left: c1, c2 = -3.898e-25 3.313e+11 -At top right: c1, c2 = -4.918e-07 3.963e+11 +At bottom left: c1, c2 = -3.898e-25 3.313e+11 +At top right: c1, c2 = -4.918e-07 3.963e+11 t = 7.20e+04 no. steps = 7405 stepsize = 6.42e+02 -At bottom left: c1, c2 = 5.173e-25 3.330e+11 -At top right: c1, c2 = -1.031e-06 4.039e+11 +At bottom left: c1, c2 = 5.173e-25 3.330e+11 +At top right: c1, c2 = -1.031e-06 4.039e+11 t = 7.92e+04 no. steps = 7416 stepsize = 6.42e+02 -At bottom left: c1, c2 = 5.441e-26 3.334e+11 -At top right: c1, c2 = -1.290e-06 4.120e+11 +At bottom left: c1, c2 = 5.441e-26 3.334e+11 +At top right: c1, c2 = -1.290e-06 4.120e+11 t = 8.64e+04 no. steps = 7427 stepsize = 6.42e+02 -At bottom left: c1, c2 = 1.538e-27 3.352e+11 -At top right: c1, c2 = -5.134e-07 4.163e+11 +At bottom left: c1, c2 = 1.538e-27 3.352e+11 +At top right: c1, c2 = -5.134e-07 4.163e+11 -Final Statistics: +Final Statistics: -lenrw = 3902 leniw = 272 +lenrw = 3902 leniw = 284 lenrwls = 2455 leniwls = 126 nst = 7427 nfe = 0 nfe = 78794 nfels = 111450 diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.c b/examples/arkode/C_parallel/ark_diurnal_kry_p.c index 3fc249d26b..b7b08ab4c3 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_p.c +++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.c @@ -243,36 +243,36 @@ int main(int argc, char* argv[]) } /* Set the pointer to user-defined data */ - flag = ARKStepSetUserData(arkode_mem, data); - if (check_flag(&flag, "ARKStepSetUserData", 1, my_pe)) { MPI_Abort(comm, 1); } + flag = ARKodeSetUserData(arkode_mem, data); + if (check_flag(&flag, "ARKodeSetUserData", 1, my_pe)) { MPI_Abort(comm, 1); } - /* Call ARKStepSetMaxNumSteps to increase default */ - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1, my_pe)) { return (1); } + /* Call ARKodeSetMaxNumSteps to increase default */ + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1, my_pe)) { return (1); } - /* Call ARKStepSStolerances to specify the scalar relative tolerance + /* Call ARKodeSStolerances to specify the scalar relative tolerance and scalar absolute tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1, my_pe)) { return (1); } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1, my_pe)) { return (1); } - /* Attach SPGMR solver structure to ARKStep interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1, my_pe)) + /* Attach SPGMR solver structure to ARKODE interface */ + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1, my_pe)) { MPI_Abort(comm, 1); } /* Set preconditioner setup and solve routines Precond and PSolve, and the pointer to the user-defined block data */ - flag = ARKStepSetPreconditioner(arkode_mem, Precond, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1, my_pe)) + flag = ARKodeSetPreconditioner(arkode_mem, Precond, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1, my_pe)) { MPI_Abort(comm, 1); } /* Tighten nonlinear solver tolerance */ - flag = ARKStepSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1, my_pe)) + flag = ARKodeSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1, my_pe)) { MPI_Abort(comm, 1); } @@ -283,11 +283,11 @@ int main(int argc, char* argv[]) printf("\n2-species diurnal advection-diffusion problem\n\n"); } - /* In loop over output points, call ARKStepEvolve, print results, test for error */ + /* In loop over output points, call ARKodeEvolve, print results, test for error */ for (iout = 1, tout = TWOHR; iout <= NOUT; iout++, tout += TWOHR) { - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1, my_pe)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1, my_pe)) { break; } PrintOutput(arkode_mem, my_pe, comm, u, t); } @@ -296,7 +296,7 @@ int main(int argc, char* argv[]) /* Free memory */ FreeUserData(data); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); N_VDestroy(u); SUNContext_Free(&ctx); @@ -440,10 +440,10 @@ static void PrintOutput(void* arkode_mem, int my_pe, MPI_Comm comm, N_Vector u, { MPI_Recv(&tempu[0], 2, MPI_SUNREALTYPE, npelast, 0, comm, &status); } - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1, my_pe); - flag = ARKStepGetLastStep(arkode_mem, &hu); - check_flag(&flag, "ARKStepGetLastStep", 1, my_pe); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe); + flag = ARKodeGetLastStep(arkode_mem, &hu); + check_flag(&flag, "ARKodeGetLastStep", 1, my_pe); #if defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld stepsize = %.2Le\n", t, nst, hu); @@ -470,33 +470,33 @@ static void PrintFinalStats(void* arkode_mem) long int nli, npe, nps, ncfl, nfeLS; int flag; - flag = ARKStepGetWorkSpace(arkode_mem, &lenrw, &leniw); - check_flag(&flag, "ARKStepGetWorkSpace", 1, 0); - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1, 0); + flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw); + check_flag(&flag, "ARKodeGetWorkSpace", 1, 0); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1, 0); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1, 0); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1, 0); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1, 0); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1, 0); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1, 0); - - flag = ARKStepGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); - check_flag(&flag, "ARKStepGetLinWorkSpace", 1, 0); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1, 0); - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - check_flag(&flag, "ARKStepGetNumPrecEvals", 1, 0); - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - check_flag(&flag, "ARKStepGetNumPrecSolves", 1, 0); - flag = ARKStepGetNumLinConvFails(arkode_mem, &ncfl); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1, 0); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1, 0); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1, 0); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1, 0); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1, 0); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1, 0); + + flag = ARKodeGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); + check_flag(&flag, "ARKodeGetLinWorkSpace", 1, 0); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1, 0); + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + check_flag(&flag, "ARKodeGetNumPrecEvals", 1, 0); + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + check_flag(&flag, "ARKodeGetNumPrecSolves", 1, 0); + flag = ARKodeGetNumLinConvFails(arkode_mem, &ncfl); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1, 0); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1, 0); printf("\nFinal Statistics: \n\n"); printf("lenrw = %5ld leniw = %5ld\n", lenrw, leniw); diff --git a/examples/arkode/C_parallel/ark_diurnal_kry_p.out b/examples/arkode/C_parallel/ark_diurnal_kry_p.out index a2db3d9006..b2a0ee2812 100644 --- a/examples/arkode/C_parallel/ark_diurnal_kry_p.out +++ b/examples/arkode/C_parallel/ark_diurnal_kry_p.out @@ -2,57 +2,57 @@ 2-species diurnal advection-diffusion problem t = 7.20e+03 no. steps = 980 stepsize = 3.07e+00 -At bottom left: c1, c2 = 1.047e+04 2.527e+11 -At top right: c1, c2 = 1.119e+04 2.700e+11 +At bottom left: c1, c2 = 1.047e+04 2.527e+11 +At top right: c1, c2 = 1.119e+04 2.700e+11 t = 1.44e+04 no. steps = 2730 stepsize = 6.90e+00 -At bottom left: c1, c2 = 6.659e+06 2.582e+11 -At top right: c1, c2 = 7.301e+06 2.833e+11 +At bottom left: c1, c2 = 6.659e+06 2.582e+11 +At top right: c1, c2 = 7.301e+06 2.833e+11 t = 2.16e+04 no. steps = 3533 stepsize = 1.04e+01 At bottom left: c1, c2 = 2.665e+07 2.993e+11 At top right: c1, c2 = 2.931e+07 3.313e+11 t = 2.88e+04 no. steps = 4695 stepsize = 3.50e+00 -At bottom left: c1, c2 = 8.702e+06 3.380e+11 -At top right: c1, c2 = 9.650e+06 3.751e+11 +At bottom left: c1, c2 = 8.702e+06 3.380e+11 +At top right: c1, c2 = 9.650e+06 3.751e+11 t = 3.60e+04 no. steps = 6172 stepsize = 2.55e+00 -At bottom left: c1, c2 = 1.404e+04 3.387e+11 -At top right: c1, c2 = 1.561e+04 3.765e+11 +At bottom left: c1, c2 = 1.404e+04 3.387e+11 +At top right: c1, c2 = 1.561e+04 3.765e+11 t = 4.32e+04 no. steps = 7361 stepsize = 5.00e+02 -At bottom left: c1, c2 = 3.855e-13 3.382e+11 -At top right: c1, c2 = -1.439e-12 3.804e+11 +At bottom left: c1, c2 = 3.855e-13 3.382e+11 +At top right: c1, c2 = -1.439e-12 3.804e+11 t = 5.04e+04 no. steps = 7379 stepsize = 3.71e+02 -At bottom left: c1, c2 = -4.407e-14 3.358e+11 -At top right: c1, c2 = 1.551e-13 3.864e+11 +At bottom left: c1, c2 = -4.407e-14 3.358e+11 +At top right: c1, c2 = 1.551e-13 3.864e+11 t = 5.76e+04 no. steps = 7394 stepsize = 1.90e+02 -At bottom left: c1, c2 = 2.370e-12 3.320e+11 -At top right: c1, c2 = -4.013e-12 3.909e+11 +At bottom left: c1, c2 = 2.370e-12 3.320e+11 +At top right: c1, c2 = -4.013e-12 3.909e+11 t = 6.48e+04 no. steps = 7409 stepsize = 5.59e+02 -At bottom left: c1, c2 = 1.301e-12 3.313e+11 -At top right: c1, c2 = -4.849e-12 3.963e+11 +At bottom left: c1, c2 = 1.301e-12 3.313e+11 +At top right: c1, c2 = -4.849e-12 3.963e+11 t = 7.20e+04 no. steps = 7421 stepsize = 5.59e+02 -At bottom left: c1, c2 = -1.797e-23 3.330e+11 -At top right: c1, c2 = -3.890e-22 4.039e+11 +At bottom left: c1, c2 = -1.797e-23 3.330e+11 +At top right: c1, c2 = -3.890e-22 4.039e+11 t = 7.92e+04 no. steps = 7434 stepsize = 5.59e+02 -At bottom left: c1, c2 = -2.819e-27 3.334e+11 -At top right: c1, c2 = -1.209e-25 4.120e+11 +At bottom left: c1, c2 = -2.819e-27 3.334e+11 +At top right: c1, c2 = -1.209e-25 4.120e+11 t = 8.64e+04 no. steps = 7447 stepsize = 5.59e+02 -At bottom left: c1, c2 = -2.334e-27 3.352e+11 -At top right: c1, c2 = -8.983e-26 4.163e+11 +At bottom left: c1, c2 = -2.334e-27 3.352e+11 +At top right: c1, c2 = -8.983e-26 4.163e+11 Final Statistics: -lenrw = 3302 leniw = 243 +lenrw = 3302 leniw = 255 lenrwls = 2455 leniwls = 126 nst = 7447 nfe = 0 nfi = 79041 nfels = 108536 @@ -60,4 +60,3 @@ nni = 41643 nli = 108536 nsetups = 456 netf = 32 npe = 125 nps = 147035 ncfn = 0 ncfl = 83 - diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c index 0f1585c26b..ab5090e86f 100644 --- a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c +++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.c @@ -251,29 +251,29 @@ int main(int argc, char* argv[]) } /* Set the pointer to user-defined data */ - flag = ARKStepSetUserData(arkode_mem, data); - if (check_flag(&flag, "ARKStepSetUserData", 1, my_pe)) { MPI_Abort(comm, 1); } + flag = ARKodeSetUserData(arkode_mem, data); + if (check_flag(&flag, "ARKodeSetUserData", 1, my_pe)) { MPI_Abort(comm, 1); } - /* Call ARKStepSetMaxNumSteps to increase default */ - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1, my_pe)) { return (1); } + /* Call ARKodeSetMaxNumSteps to increase default */ + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1, my_pe)) { return (1); } - /* Call ARKStepSStolerances to specify the scalar relative tolerance + /* Call ARKodeSStolerances to specify the scalar relative tolerance and scalar absolute tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1, my_pe)) { return (1); } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1, my_pe)) { return (1); } - /* Attach SPGMR solver structure to ARKStep interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1, my_pe)) + /* Attach SPGMR solver structure to ARKODE interface */ + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1, my_pe)) { MPI_Abort(comm, 1); } /* Set preconditioner setup and solve routines Precond and PSolve, and the pointer to the user-defined block data */ - flag = ARKStepSetPreconditioner(arkode_mem, Precond, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1, my_pe)) + flag = ARKodeSetPreconditioner(arkode_mem, Precond, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1, my_pe)) { MPI_Abort(comm, 1); } @@ -284,11 +284,11 @@ int main(int argc, char* argv[]) printf("\n2-species diurnal advection-diffusion problem\n\n"); } - /* In loop over output points, call ARKStepEvolve, print results, test for error */ + /* In loop over output points, call ARKodeEvolve, print results, test for error */ for (iout = 1, tout = TWOHR; iout <= NOUT; iout++, tout += TWOHR) { - flag = ARKStepEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1, my_pe)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, u, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1, my_pe)) { break; } PrintOutput(arkode_mem, my_pe, comm, u, t); } @@ -299,7 +299,7 @@ int main(int argc, char* argv[]) N_VDestroy(u); /* Free hypre vector wrapper */ HYPRE_IJVectorDestroy(Uij); /* Free the underlying hypre vector */ FreeUserData(data); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); SUNContext_Free(&sunctx); /* Free context */ MPI_Finalize(); @@ -452,10 +452,10 @@ static void PrintOutput(void* arkode_mem, int my_pe, MPI_Comm comm, N_Vector u, { MPI_Recv(&tempu[0], 2, MPI_SUNREALTYPE, npelast, 0, comm, &status); } - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1, my_pe); - flag = ARKStepGetLastStep(arkode_mem, &hu); - check_flag(&flag, "ARKStepGetLastStep", 1, my_pe); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1, my_pe); + flag = ARKodeGetLastStep(arkode_mem, &hu); + check_flag(&flag, "ARKodeGetLastStep", 1, my_pe); #if defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %.2Le no. steps = %ld stepsize = %.2Le\n", t, nst, hu); @@ -482,33 +482,33 @@ static void PrintFinalStats(void* arkode_mem) long int nli, npe, nps, ncfl, nfeLS; int flag; - flag = ARKStepGetWorkSpace(arkode_mem, &lenrw, &leniw); - check_flag(&flag, "ARKStepGetWorkSpace", 1, 0); - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1, 0); + flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw); + check_flag(&flag, "ARKodeGetWorkSpace", 1, 0); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1, 0); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1, 0); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1, 0); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1, 0); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1, 0); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1, 0); - - flag = ARKStepGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); - check_flag(&flag, "ARKStepGetLinWorkSpace", 1, 0); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1, 0); - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - check_flag(&flag, "ARKStepGetNumPrecEvals", 1, 0); - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - check_flag(&flag, "ARKStepGetNumPrecSolves", 1, 0); - flag = ARKStepGetNumLinConvFails(arkode_mem, &ncfl); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1, 0); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1, 0); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1, 0); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1, 0); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1, 0); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1, 0); + + flag = ARKodeGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); + check_flag(&flag, "ARKodeGetLinWorkSpace", 1, 0); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1, 0); + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + check_flag(&flag, "ARKodeGetNumPrecEvals", 1, 0); + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + check_flag(&flag, "ARKodeGetNumPrecSolves", 1, 0); + flag = ARKodeGetNumLinConvFails(arkode_mem, &ncfl); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1, 0); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1, 0); printf("\nFinal Statistics: \n\n"); printf("lenrw = %5ld leniw = %5ld\n", lenrw, leniw); diff --git a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out index ffb0e71104..a6c5f580fa 100644 --- a/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out +++ b/examples/arkode/C_parhyp/ark_diurnal_kry_ph.out @@ -6,53 +6,53 @@ At bottom left: c1, c2 = 1.047e+04 2.527e+11 At top right: c1, c2 = 1.119e+04 2.700e+11 t = 1.44e+04 no. steps = 2733 stepsize = 6.93e+00 -At bottom left: c1, c2 = 6.659e+06 2.582e+11 -At top right: c1, c2 = 7.301e+06 2.833e+11 +At bottom left: c1, c2 = 6.659e+06 2.582e+11 +At top right: c1, c2 = 7.301e+06 2.833e+11 t = 2.16e+04 no. steps = 3532 stepsize = 1.04e+01 -At bottom left: c1, c2 = 2.665e+07 2.993e+11 -At top right: c1, c2 = 2.931e+07 3.313e+11 +At bottom left: c1, c2 = 2.665e+07 2.993e+11 +At top right: c1, c2 = 2.931e+07 3.313e+11 t = 2.88e+04 no. steps = 4588 stepsize = 4.86e+00 -At bottom left: c1, c2 = 8.702e+06 3.380e+11 -At top right: c1, c2 = 9.650e+06 3.751e+11 +At bottom left: c1, c2 = 8.702e+06 3.380e+11 +At top right: c1, c2 = 9.650e+06 3.751e+11 t = 3.60e+04 no. steps = 5824 stepsize = 2.55e+00 -At bottom left: c1, c2 = 1.404e+04 3.387e+11 -At top right: c1, c2 = 1.561e+04 3.765e+11 +At bottom left: c1, c2 = 1.404e+04 3.387e+11 +At top right: c1, c2 = 1.561e+04 3.765e+11 t = 4.32e+04 no. steps = 7026 stepsize = 5.12e+02 -At bottom left: c1, c2 = 1.334e-12 3.382e+11 -At top right: c1, c2 = -4.825e-12 3.804e+11 +At bottom left: c1, c2 = 1.334e-12 3.382e+11 +At top right: c1, c2 = -4.825e-12 3.804e+11 t = 5.04e+04 no. steps = 7041 stepsize = 5.36e+02 -At bottom left: c1, c2 = 1.415e-13 3.358e+11 -At top right: c1, c2 = -1.712e-12 3.864e+11 +At bottom left: c1, c2 = 1.415e-13 3.358e+11 +At top right: c1, c2 = -1.712e-12 3.864e+11 t = 5.76e+04 no. steps = 7055 stepsize = 2.34e+02 -At bottom left: c1, c2 = -2.533e-12 3.320e+11 -At top right: c1, c2 = -5.401e-12 3.909e+11 +At bottom left: c1, c2 = -2.533e-12 3.320e+11 +At top right: c1, c2 = -5.401e-12 3.909e+11 t = 6.48e+04 no. steps = 7068 stepsize = 6.40e+02 -At bottom left: c1, c2 = -4.169e-12 3.313e+11 -At top right: c1, c2 = 1.665e-11 3.963e+11 +At bottom left: c1, c2 = -4.169e-12 3.313e+11 +At top right: c1, c2 = 1.665e-11 3.963e+11 t = 7.20e+04 no. steps = 7080 stepsize = 6.40e+02 -At bottom left: c1, c2 = -3.839e-12 3.330e+11 -At top right: c1, c2 = -3.434e-11 4.039e+11 +At bottom left: c1, c2 = -3.839e-12 3.330e+11 +At top right: c1, c2 = -3.434e-11 4.039e+11 t = 7.92e+04 no. steps = 7091 stepsize = 6.40e+02 -At bottom left: c1, c2 = 2.289e-26 3.334e+11 -At top right: c1, c2 = 4.220e-25 4.120e+11 +At bottom left: c1, c2 = 2.289e-26 3.334e+11 +At top right: c1, c2 = 4.220e-25 4.120e+11 t = 8.64e+04 no. steps = 7102 stepsize = 6.40e+02 -At bottom left: c1, c2 = -5.225e-26 3.352e+11 -At top right: c1, c2 = -5.452e-25 4.163e+11 +At bottom left: c1, c2 = -5.225e-26 3.352e+11 +At top right: c1, c2 = -5.452e-25 4.163e+11 Final Statistics: -lenrw = 3302 leniw = 243 +lenrw = 3302 leniw = 255 lenrwls = 2455 leniwls = 126 nst = 7102 nfe = 0 nfi = 74579 nfels = 87090 diff --git a/examples/arkode/C_petsc/ark_petsc_ex25.c b/examples/arkode/C_petsc/ark_petsc_ex25.c index 47373cb11f..0c0bf03fba 100644 --- a/examples/arkode/C_petsc/ark_petsc_ex25.c +++ b/examples/arkode/C_petsc/ark_petsc_ex25.c @@ -60,7 +60,7 @@ static PetscErrorCode FormIFunction(PetscReal, Vec, Vec, Vec, void*); static PetscErrorCode FormIJacobian(SNES, Vec, Mat, Mat, void*); static PetscErrorCode FormInitialSolution(Vec, void*); -/* User-supplied Functions called by ARKStep */ +/* User-supplied Functions called by ARKODE */ static int f_I(PetscReal, N_Vector, N_Vector, void*); static int f_E(PetscReal, N_Vector, N_Vector, void*); @@ -188,7 +188,7 @@ int main(int argc, char** argv) dt = 0.4 * PetscSqr(hx) / user.alpha; /* Diffusive stability limit */ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create ARKStep time stepper + Create ARKODE time stepper - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Call ARKStepCreate to initialize the ARK timestepper module and @@ -225,28 +225,28 @@ int main(int argc, char** argv) CHKERRQ(ierr); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set ARKStep options + Set ARKODE options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - ierr = ARKStepSStolerances(arkode_mem, rtol, atol); - if (check_retval(&ierr, "ARKStepSStolerances", 1)) { return 1; } + ierr = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_retval(&ierr, "ARKodeSStolerances", 1)) { return 1; } - ierr = ARKStepSetOrder(arkode_mem, 3); - if (check_retval(&ierr, "ARKStepSetOrder", 1)) { return 1; } + ierr = ARKodeSetOrder(arkode_mem, 3); + if (check_retval(&ierr, "ARKodeSetOrder", 1)) { return 1; } - ierr = ARKStepSetUserData(arkode_mem, (void*)&user); - if (check_retval(&ierr, "ARKStepSetUserData", 1)) { return 1; } + ierr = ARKodeSetUserData(arkode_mem, (void*)&user); + if (check_retval(&ierr, "ARKodeSetUserData", 1)) { return 1; } - ierr = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_retval(&ierr, "ARKStepSetNonlinearSolver", 1)) { return 1; } + ierr = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_retval(&ierr, "ARKodeSetNonlinearSolver", 1)) { return 1; } C = SUNAdaptController_I(ctx); if (check_retval((void*)C, "SUNAdaptController_I", 0)) { return 1; } - ierr = ARKStepSetAdaptController(arkode_mem, C); - if (check_retval(&ierr, "ARKStepSetAdaptController", 1)) { return 1; } + ierr = ARKodeSetAdaptController(arkode_mem, C); + if (check_retval(&ierr, "ARKodeSetAdaptController", 1)) { return 1; } - ierr = ARKStepSetInitStep(arkode_mem, dt); - if (check_retval(&ierr, "ARKStepSetInitStep", 1)) { return 1; } + ierr = ARKodeSetInitStep(arkode_mem, dt); + if (check_retval(&ierr, "ARKodeSetInitStep", 1)) { return 1; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Perform the integration @@ -265,18 +265,18 @@ int main(int argc, char** argv) /* Advance time */ tstop += dtout; - ierr = ARKStepSetStopTime(arkode_mem, tstop); - if (check_retval(&ierr, "ARKStepSetStopTime", 1)) { return 1; } + ierr = ARKodeSetStopTime(arkode_mem, tstop); + if (check_retval(&ierr, "ARKodeSetStopTime", 1)) { return 1; } /* Evolve solution in time */ - ierr = ARKStepEvolve(arkode_mem, ftime, nvecx, &t, ARK_NORMAL); - if (check_retval(&ierr, "ARKStepEvolve", 1)) { return 1; } + ierr = ARKodeEvolve(arkode_mem, ftime, nvecx, &t, ARK_NORMAL); + if (check_retval(&ierr, "ARKodeEvolve", 1)) { return 1; } /* Get statistics */ - ierr = ARKStepGetCurrentStep(arkode_mem, &dt); - if (check_retval(&ierr, "ARKStepGetCurrntStep", 1)) { return 1; } - ierr = ARKStepGetNumSteps(arkode_mem, &steps); - if (check_retval(&ierr, "ARKStepGetNumSteps", 1)) { return 1; } + ierr = ARKodeGetCurrentStep(arkode_mem, &dt); + if (check_retval(&ierr, "ARKodeGetCurrntStep", 1)) { return 1; } + ierr = ARKodeGetNumSteps(arkode_mem, &steps); + if (check_retval(&ierr, "ARKodeGetNumSteps", 1)) { return 1; } } printf("Converged at time %g after %ld steps.\n", t, steps); @@ -288,7 +288,7 @@ int main(int argc, char** argv) /* Free SUNDIALS data structures */ N_VDestroy(nvecx); /* Free x nvector */ SUNNonlinSolFree(NLS); /* Free nonlinear solver */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ (void)SUNAdaptController_Destroy(C); /* Free time adaptivity controller */ /* Free petsc data structures */ @@ -305,7 +305,7 @@ int main(int argc, char** argv) } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - User provided functions in ARKStep format + User provided functions in ARKODE format - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Implicit component of RHS */ @@ -459,7 +459,7 @@ PetscErrorCode FormIJacobian(SNES snes, Vec X, Mat J, Mat Jpre, void* ptr) hx = 1.0 / (PetscReal)(info.mx - 1); /* Get current gamma value from ARKode */ - ierr = ARKStepGetCurrentGamma(user->arkode_mem, &gamma); + ierr = ARKodeGetCurrentGamma(user->arkode_mem, &gamma); /* Get pointers to vector data */ ierr = DMDAVecGetArrayRead(user->da, X, &x); diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.c b/examples/arkode/C_serial/ark_KrylovDemo_prec.c index 7bbbd42a6d..26774ead15 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.c +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.c @@ -68,7 +68,7 @@ * preconditoner is applied on the left and on the right. In each * case, both the modified and classical Gram-Schmidt options are * tested. In the series of runs, ARKStepCreate, SUNLinSol_SPGMR and - * ARKStepSetLinearSolver are called only for the first run, whereas + * ARKodeSetLinearSolver are called only for the first run, whereas * ARKStepReInit, SUNLinSol_SPGMRSetPrecType, and * SUNLinSol_SPGMRSetGSType are called for each of the remaining * three runs. @@ -294,32 +294,32 @@ int main(int argc, char* argv[]) wdata->arkode_mem = arkode_mem; - flag = ARKStepSetUserData(arkode_mem, wdata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return (1); } + flag = ARKodeSetUserData(arkode_mem, wdata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return (1); } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return (1); } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return (1); } - flag = ARKStepSetMaxNumSteps(arkode_mem, 1000); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return (1); } + flag = ARKodeSetMaxNumSteps(arkode_mem, 1000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return (1); } - flag = ARKStepSetNonlinConvCoef(arkode_mem, 1.e-3); - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1)) { return (1); } + flag = ARKodeSetNonlinConvCoef(arkode_mem, 1.e-3); + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return (1); } LS = SUNLinSol_SPGMR(c, jpre, MAXL, ctx); if (check_flag((void*)LS, "SUNLinSol_SPGMR", 0)) { return (1); } - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } flag = SUNLinSol_SPGMRSetGSType(LS, gstype); if (check_flag(&flag, "SUNLinSol_SPGMRSetGSType", 1)) { return (1); } - flag = ARKStepSetEpsLin(arkode_mem, DELT); - if (check_flag(&flag, "ARKStepSetEpsLin", 1)) { return (1); } + flag = ARKodeSetEpsLin(arkode_mem, DELT); + if (check_flag(&flag, "ARKodeSetEpsLin", 1)) { return (1); } - flag = ARKStepSetPreconditioner(arkode_mem, Precond, PSolve); - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return (1); } + flag = ARKodeSetPreconditioner(arkode_mem, Precond, PSolve); + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return (1); } /* Set the linear solver tolerance conversion factor */ switch (nrmfactor) @@ -338,8 +338,8 @@ int main(int argc, char* argv[]) break; } - flag = ARKStepSetLSNormFactor(arkode_mem, nrmfac); - if (check_flag(&flag, "ARKStepSetLSNormFactor", 1)) { return (1); } + flag = ARKodeSetLSNormFactor(arkode_mem, nrmfac); + if (check_flag(&flag, "ARKodeSetLSNormFactor", 1)) { return (1); } } else { @@ -356,14 +356,14 @@ int main(int argc, char* argv[]) /* Print initial values */ if (firstrun) { PrintAllSpecies(c, ns, mxns, T0); } - /* Loop over output points, call ARKStepEvolve, print sample solution values. */ + /* Loop over output points, call ARKodeEvolve, print sample solution values. */ tout = T1; for (iout = 1; iout <= NOUT; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, c, &t, ARK_NORMAL); + flag = ARKodeEvolve(arkode_mem, tout, c, &t, ARK_NORMAL); PrintOutput(arkode_mem, t); if (firstrun && (iout % 3 == 0)) { PrintAllSpecies(c, ns, mxns, t); } - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } if (tout > SUN_RCONST(0.9)) { tout += DTOUT; } else { tout *= TOUT_MULT; } } @@ -374,7 +374,7 @@ int main(int argc, char* argv[]) } /* Free all memory */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); N_VDestroy(c); SUNLinSolFree(LS); FreeUserData(wdata); @@ -624,14 +624,14 @@ static void PrintOutput(void* arkode_mem, sunrealtype t) int flag; sunrealtype hu; - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetLastStep(arkode_mem, &hu); - check_flag(&flag, "ARKStepGetLastStep", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetLastStep(arkode_mem, &hu); + check_flag(&flag, "ARKodeGetLastStep", 1); #if defined(SUNDIALS_EXTENDED_PRECISION) printf("t = %10.2Le nst = %ld nfe = %ld nfi = %ld nni = %ld", t, nst, nfe, @@ -657,33 +657,33 @@ static void PrintFinalStats(void* arkode_mem) int flag; sunrealtype avdim; - flag = ARKStepGetWorkSpace(arkode_mem, &lenrw, &leniw); - check_flag(&flag, "ARKStepGetWorkSpace", 1); - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); + flag = ARKodeGetWorkSpace(arkode_mem, &lenrw, &leniw); + check_flag(&flag, "ARKodeGetWorkSpace", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - - flag = ARKStepGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); - check_flag(&flag, "ARKStepGetLinWorkSpace", 1); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1); - flag = ARKStepGetNumPrecEvals(arkode_mem, &npe); - check_flag(&flag, "ARKStepGetNumPrecEvals", 1); - flag = ARKStepGetNumPrecSolves(arkode_mem, &nps); - check_flag(&flag, "ARKStepGetNumPrecSolves", 1); - flag = ARKStepGetNumLinConvFails(arkode_mem, &ncfl); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + + flag = ARKodeGetLinWorkSpace(arkode_mem, &lenrwLS, &leniwLS); + check_flag(&flag, "ARKodeGetLinWorkSpace", 1); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1); + flag = ARKodeGetNumPrecEvals(arkode_mem, &npe); + check_flag(&flag, "ARKodeGetNumPrecEvals", 1); + flag = ARKodeGetNumPrecSolves(arkode_mem, &nps); + check_flag(&flag, "ARKodeGetNumPrecSolves", 1); + flag = ARKodeGetNumLinConvFails(arkode_mem, &ncfl); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); printf("\n\n Final statistics for this run:\n\n"); printf(" ARKStep real workspace length = %4ld \n", lenrw); @@ -846,8 +846,8 @@ static int Precond(sunrealtype t, N_Vector c, N_Vector fc, sunbooleantype jok, arkode_mem = wdata->arkode_mem; cdata = N_VGetArrayPointer(c); rewt = wdata->rewt; - flag = ARKStepGetErrWeights(arkode_mem, rewt); - if (check_flag(&flag, "ARKStepGetErrWeights", 1)) { return (1); } + flag = ARKodeGetErrWeights(arkode_mem, rewt); + if (check_flag(&flag, "ARKodeGetErrWeights", 1)) { return (1); } rewtdata = N_VGetArrayPointer(rewt); uround = SUN_UNIT_ROUNDOFF; diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec.out b/examples/arkode/C_serial/ark_KrylovDemo_prec.out index 79d7c4a86f..e60c62304f 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec.out @@ -419,7 +419,7 @@ Species 6 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 131 + ARKStep integer workspace length = 143 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 190 @@ -488,7 +488,7 @@ t = 1.00e+01 nst = 190 nfe = 0 nfi = 3030 nni = 2072 hu = 1.57e+00 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 136 + ARKStep integer workspace length = 148 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 190 @@ -557,7 +557,7 @@ t = 1.00e+01 nst = 349 nfe = 0 nfi = 5589 nni = 3826 hu = 2.80e-01 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 141 + ARKStep integer workspace length = 153 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 349 @@ -626,7 +626,7 @@ t = 1.00e+01 nst = 349 nfe = 0 nfi = 5589 nni = 3826 hu = 2.80e-01 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 146 + ARKStep integer workspace length = 158 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 349 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out index 79d7c4a86f..e60c62304f 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_1.out @@ -419,7 +419,7 @@ Species 6 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 131 + ARKStep integer workspace length = 143 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 190 @@ -488,7 +488,7 @@ t = 1.00e+01 nst = 190 nfe = 0 nfi = 3030 nni = 2072 hu = 1.57e+00 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 136 + ARKStep integer workspace length = 148 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 190 @@ -557,7 +557,7 @@ t = 1.00e+01 nst = 349 nfe = 0 nfi = 5589 nni = 3826 hu = 2.80e-01 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 141 + ARKStep integer workspace length = 153 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 349 @@ -626,7 +626,7 @@ t = 1.00e+01 nst = 349 nfe = 0 nfi = 5589 nni = 3826 hu = 2.80e-01 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 146 + ARKStep integer workspace length = 158 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 349 diff --git a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out index 79d7c4a86f..e60c62304f 100644 --- a/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out +++ b/examples/arkode/C_serial/ark_KrylovDemo_prec_2.out @@ -419,7 +419,7 @@ Species 6 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 131 + ARKStep integer workspace length = 143 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 190 @@ -488,7 +488,7 @@ t = 1.00e+01 nst = 190 nfe = 0 nfi = 3030 nni = 2072 hu = 1.57e+00 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 136 + ARKStep integer workspace length = 148 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 190 @@ -557,7 +557,7 @@ t = 1.00e+01 nst = 349 nfe = 0 nfi = 5589 nni = 3826 hu = 2.80e-01 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 141 + ARKStep integer workspace length = 153 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 349 @@ -626,7 +626,7 @@ t = 1.00e+01 nst = 349 nfe = 0 nfi = 5589 nni = 3826 hu = 2.80e-01 Final statistics for this run: ARKStep real workspace length = 3558 - ARKStep integer workspace length = 146 + ARKStep integer workspace length = 158 ARKLS real workspace length = 2647 ARKLS integer workspace length = 42 Number of steps = 349 diff --git a/examples/arkode/C_serial/ark_analytic.c b/examples/arkode/C_serial/ark_analytic.c index eb1a7cd934..c13bd87b15 100644 --- a/examples/arkode/C_serial/ark_analytic.c +++ b/examples/arkode/C_serial/ark_analytic.c @@ -107,11 +107,11 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)&lamda); /* Pass lamda to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)&lamda); /* Pass lamda to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize dense matrix data structure and solver */ A = SUNDenseMatrix(NEQ, NEQ, ctx); @@ -120,15 +120,15 @@ int main(void) if (check_flag((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -137,7 +137,7 @@ int main(void) /* output initial condition to disk */ fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -145,8 +145,8 @@ int main(void) printf(" ---------------------\n"); while (Tf - t > 1.0e-15) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6" FSYM "\n", t, NV_Ith_S(y, 0)); /* access/print solution */ fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", t, NV_Ith_S(y, 0)); @@ -165,24 +165,24 @@ int main(void) fclose(UFID); /* Get/print some final statistics on how the solve progressed */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -198,11 +198,11 @@ int main(void) flag = check_ans(y, t, reltol, abstol); /* Clean up and return */ - N_VDestroy(y); /* Free y vector */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return flag; } diff --git a/examples/arkode/C_serial/ark_analytic_mels.c b/examples/arkode/C_serial/ark_analytic_mels.c index e1dd476909..08d0fa5884 100644 --- a/examples/arkode/C_serial/ark_analytic_mels.c +++ b/examples/arkode/C_serial/ark_analytic_mels.c @@ -46,7 +46,7 @@ #define FSYM "f" #endif -/* User-supplied functions called by ARKStep */ +/* User-supplied functions called by ARKODE */ static int f(sunrealtype t, N_Vector y, N_Vector ydot, void* user_data); /* Custom linear solver data structure, accessor macros, and routines */ @@ -107,23 +107,23 @@ int main(void) if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - retval = ARKStepSetUserData(arkode_mem, - (void*)&lamda); /* Pass lamda to user functions */ - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, + (void*)&lamda); /* Pass lamda to user functions */ + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Initialize custom matrix-embedded linear solver */ LS = MatrixEmbeddedLS(arkode_mem, ctx); if (check_retval((void*)LS, "MatrixEmbeddedLS", 0)) { return 1; } - retval = ARKStepSetLinearSolver(arkode_mem, LS, NULL); /* Attach linear solver */ - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LS, NULL); /* Attach linear solver */ + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - retval = ARKStepSetLinear(arkode_mem, 0); - if (check_retval(&retval, "ARKStepSetLinear", 1)) { return 1; } + retval = ARKodeSetLinear(arkode_mem, 0); + if (check_retval(&retval, "ARKodeSetLinear", 1)) { return 1; } - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached. */ t = T0; tout = T0 + dTout; @@ -131,9 +131,8 @@ int main(void) printf(" ---------------------\n"); while (Tf - t > 1.0e-15) { - retval = ARKStepEvolve(arkode_mem, tout, y, &t, - ARK_NORMAL); /* call integrator */ - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6" FSYM "\n", t, NV_Ith_S(y, 0)); /* access/print solution */ if (retval >= 0) @@ -150,24 +149,24 @@ int main(void) printf(" ---------------------\n"); /* Get/print some final statistics on how the solve progressed */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); - retval = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_retval(&retval, "ARKStepGetNumLinSolvSetups", 1); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1); - retval = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_retval(&retval, "ARKStepGetNumJacEvals", 1); - retval = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_retval(&retval, "ARKStepGetNumLinRhsEvals", 1); + retval = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_retval(&retval, "ARKodeGetNumLinSolvSetups", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1); + retval = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); + retval = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_retval(&retval, "ARKodeGetNumLinRhsEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -183,10 +182,10 @@ int main(void) retval = check_ans(y, t, reltol, abstol); /* Clean up and return */ - N_VDestroy(y); /* Free y vector */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free the SUNContext */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNContext_Free(&ctx); /* Free the SUNContext */ return retval; } @@ -250,10 +249,10 @@ static int MatrixEmbeddedLSSolve(SUNLinearSolver LS, SUNMatrix A, N_Vector x, sunrealtype* rdata; sunrealtype lamda; - /* retrieve implicit system data from ARKStep */ - retval = ARKStepGetNonlinearSystemData(LS->content, &tcur, &zpred, &z, &Fi, - &gamma, &sdata, &user_data); - if (check_retval((void*)&retval, "ARKStepGetNonlinearSystemData", 1)) + /* retrieve implicit system data from ARKODE */ + retval = ARKodeGetNonlinearSystemData(LS->content, &tcur, &zpred, &z, &Fi, + &gamma, &sdata, &user_data); + if (check_retval((void*)&retval, "ARKodeGetNonlinearSystemData", 1)) { return (-1); } diff --git a/examples/arkode/C_serial/ark_analytic_nonlin.c b/examples/arkode/C_serial/ark_analytic_nonlin.c index f8a4565c55..1bb5f99987 100644 --- a/examples/arkode/C_serial/ark_analytic_nonlin.c +++ b/examples/arkode/C_serial/ark_analytic_nonlin.c @@ -89,8 +89,8 @@ int main(void) if (check_flag((void*)arkode_mem, "ERKStepCreate", 0)) { return 1; } /* Specify tolerances */ - flag = ERKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ERKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -99,7 +99,7 @@ int main(void) /* output initial condition to disk */ fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0)); - /* Main time-stepping loop: calls ERKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -107,8 +107,8 @@ int main(void) printf(" ---------------------\n"); while (Tf - t > 1.0e-15) { - flag = ERKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ERKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6" FSYM "\n", t, NV_Ith_S(y, 0)); /* access/print solution */ fprintf(UFID, " %.16" ESYM " %.16" ESYM "\n", t, NV_Ith_S(y, 0)); @@ -128,17 +128,17 @@ int main(void) /* Print final statistics */ printf("\nFinal Statistics:\n"); - flag = ERKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); /* Print final statistics to a file in CSV format */ FID = fopen("ark_analytic_nonlin_stats.csv", "w"); - flag = ERKStepPrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); + flag = ARKodePrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); fclose(FID); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free y vector */ - ERKStepFree(&arkode_mem); /* Free integrator memory */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_brusselator.c b/examples/arkode/C_serial/ark_brusselator.c index 9dc799d308..927c3e57da 100644 --- a/examples/arkode/C_serial/ark_brusselator.c +++ b/examples/arkode/C_serial/ark_brusselator.c @@ -168,17 +168,16 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)rdata); /* Pass rdata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } - flag = ARKStepSetInterpolantType(arkode_mem, - ARK_INTERP_LAGRANGE); /* Specify stiff interpolant */ - if (check_flag(&flag, "ARKStepSetInterpolantType", 1)) { return 1; } - flag = ARKStepSetDeduceImplicitRhs(arkode_mem, - 1); /* Avoid eval of f after stage */ - if (check_flag(&flag, "ARKStepSetDeduceImplicitRhs", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)rdata); /* Pass rdata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetInterpolantType(arkode_mem, + ARK_INTERP_LAGRANGE); /* Specify stiff interpolant */ + if (check_flag(&flag, "ARKodeSetInterpolantType", 1)) { return 1; } + flag = ARKodeSetDeduceImplicitRhs(arkode_mem, 1); /* Avoid eval of f after stage */ + if (check_flag(&flag, "ARKodeSetDeduceImplicitRhs", 1)) { return 1; } /* Initialize dense matrix data structure and solver */ A = SUNDenseMatrix(NEQ, NEQ, ctx); @@ -187,11 +186,11 @@ int main(void) if (check_flag((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -201,7 +200,7 @@ int main(void) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -212,8 +211,8 @@ int main(void) for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM "\n", /* access/print solution */ t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); @@ -234,26 +233,26 @@ int main(void) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumStepSolveFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumStepSolveFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &nnf); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumStepSolveFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumStepSolveFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &nnf); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -267,11 +266,11 @@ int main(void) printf(" Total number of failed steps from solver failure = %li\n", ncfn); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free y vector */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_brusselator1D.c b/examples/arkode/C_serial/ark_brusselator1D.c index abd7399099..6857fab6d0 100644 --- a/examples/arkode/C_serial/ark_brusselator1D.c +++ b/examples/arkode/C_serial/ark_brusselator1D.c @@ -207,11 +207,11 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize band matrix data structure and solver -- A will be factored, so set smu to ml+mu */ A = SUNBandMatrix(NEQ, 4, 4, ctx); @@ -220,11 +220,11 @@ int main(void) if (check_flag((void*)LS, "SUNLinSol_Band", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* output spatial mesh to disk */ FID = fopen("bruss_mesh.txt", "w"); @@ -246,7 +246,7 @@ int main(void) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -255,8 +255,8 @@ int main(void) printf(" ----------------------------------------------\n"); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } u = N_VWL2Norm(y, umask); /* access/print solution statistics */ u = sqrt(u * u / N); v = N_VWL2Norm(y, vmask); @@ -290,24 +290,24 @@ int main(void) fclose(WFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -325,11 +325,11 @@ int main(void) N_VDestroy(umask); N_VDestroy(vmask); N_VDestroy(wmask); - free(udata); /* Free user data */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + free(udata); /* Free user data */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c index 11d9dbab40..a79e142eea 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c +++ b/examples/arkode/C_serial/ark_brusselator1D_FEM_slu.c @@ -285,16 +285,16 @@ int main(int argc, char* argv[]) /* Set routines */ /* Pass udata to user functions */ - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return (1); } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return (1); } /* Specify tolerances */ - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return (1); } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return (1); } /* Specify residual tolerance */ - retval = ARKStepResStolerance(arkode_mem, abstol); - if (check_retval(&retval, "ARKStepResStolerance", 1)) { return (1); } + retval = ARKodeResStolerance(arkode_mem, abstol); + if (check_retval(&retval, "ARKodeResStolerance", 1)) { return (1); } /* Initialize sparse matrix data structure and linear solvers (system and mass) */ NNZ = 15 * NEQ; @@ -311,26 +311,26 @@ int main(int argc, char* argv[]) MLS = SUNLinSol_SuperLUMT(y, M, num_threads, ctx); if (check_retval((void*)MLS, "SUNLinSol_SuperLUMT", 0)) { return (1); } - /* Attach the matrix, linear solver, and Jacobian construction routine to ARKStep */ + /* Attach the matrix, linear solver, and Jacobian construction routine to ARKODE */ /* Attach matrix and LS */ - retval = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return (1); } + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return (1); } /* Supply Jac routine */ - retval = ARKStepSetJacFn(arkode_mem, Jac); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return (1); } + retval = ARKodeSetJacFn(arkode_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return (1); } - /* Attach the mass matrix, linear solver and construction routines to ARKStep; - notify ARKStep that the mass matrix is not time-dependent */ + /* Attach the mass matrix, linear solver and construction routines to ARKode; + notify ARKode that the mass matrix is not time-dependent */ /* Attach matrix and LS */ - retval = ARKStepSetMassLinearSolver(arkode_mem, MLS, M, SUNFALSE); - if (check_retval(&retval, "ARKStepSetMassLinearSolver", 1)) { return (1); } + retval = ARKodeSetMassLinearSolver(arkode_mem, MLS, M, SUNFALSE); + if (check_retval(&retval, "ARKodeSetMassLinearSolver", 1)) { return (1); } /* Supply M routine */ - retval = ARKStepSetMassFn(arkode_mem, MassMatrix); - if (check_retval(&retval, "ARKStepSetMassFn", 1)) { return (1); } + retval = ARKodeSetMassFn(arkode_mem, MassMatrix); + if (check_retval(&retval, "ARKodeSetMassFn", 1)) { return (1); } /* output mesh to disk */ FID = fopen("bruss_FEM_mesh.txt", "w"); @@ -352,7 +352,7 @@ int main(int argc, char* argv[]) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = Tf / Nt; @@ -361,9 +361,8 @@ int main(int argc, char* argv[]) printf(" ----------------------------------------------\n"); for (iout = 0; iout < Nt; iout++) { - retval = ARKStepEvolve(arkode_mem, tout, y, &t, - ARK_NORMAL); /* call integrator */ - if (check_retval(&retval, "ARKStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } u = N_VWL2Norm(y, umask); /* access/print solution statistics */ u = sqrt(u * u / N); v = N_VWL2Norm(y, vmask); @@ -397,28 +396,28 @@ int main(int argc, char* argv[]) fclose(WFID); /* Print some final statistics */ - retval = ARKStepGetNumSteps(arkode_mem, &nst); - check_retval(&retval, "ARKStepGetNumSteps", 1); - retval = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nst); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); - retval = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_retval(&retval, "ARKStepGetNumLinSolvSetups", 1); - retval = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1); - retval = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1); - retval = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1); - retval = ARKStepGetNumMassSetups(arkode_mem, &nmset); - check_retval(&retval, "ARKStepGetNumMassSetups", 1); - retval = ARKStepGetNumMassSolves(arkode_mem, &nms); - check_retval(&retval, "ARKStepGetNumMassSolves", 1); - retval = ARKStepGetNumMassMult(arkode_mem, &nMv); - check_retval(&retval, "ARKStepGetNumMassMult", 1); - retval = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_retval(&retval, "ARKStepGetNumJacEvals", 1); + retval = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_retval(&retval, "ARKodeGetNumLinSolvSetups", 1); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); + retval = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1); + retval = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1); + retval = ARKodeGetNumMassSetups(arkode_mem, &nmset); + check_retval(&retval, "ARKodeGetNumMassSetups", 1); + retval = ARKodeGetNumMassSolves(arkode_mem, &nms); + check_retval(&retval, "ARKodeGetNumMassSolves", 1); + retval = ARKodeGetNumMassMult(arkode_mem, &nMv); + check_retval(&retval, "ARKodeGetNumMassMult", 1); + retval = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -442,8 +441,8 @@ int main(int argc, char* argv[]) N_VDestroy(udata->tmp); free(udata->x); free(udata); - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solvers */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solvers */ SUNLinSolFree(MLS); SUNMatDestroy(A); /* Free matrices */ SUNMatDestroy(M); diff --git a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c index 7a557fa22a..c1245a4f4e 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_imexmri.c +++ b/examples/arkode/C_serial/ark_brusselator1D_imexmri.c @@ -400,28 +400,28 @@ int main(int argc, char* argv[]) if (check_retval((void*)LSf, "SUNLinSol_Band", 0)) { return 1; } /* Specify fast tolerances */ - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = ARKStepSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set max number of nonlinear iters */ - retval = ARKStepSetMaxNonlinIters(inner_arkode_mem, 10); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) { return 1; } + retval = ARKodeSetMaxNonlinIters(inner_arkode_mem, 10); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) { return 1; } /* Set the Jacobian routine */ - retval = ARKStepSetJacFn(inner_arkode_mem, Jf); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jf); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } break; case (1): /*dirk 5th order fast solver (full problem) */ inner_arkode_mem = ARKStepCreate(NULL, f, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set method order to use */ - retval = ARKStepSetOrder(inner_arkode_mem, 5); - if (check_retval(&retval, "ARKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } /* Initialize matrix and linear solver data structures */ Af = SUNBandMatrix(NEQ, 4, 4, ctx); @@ -431,16 +431,16 @@ int main(int argc, char* argv[]) if (check_retval((void*)LSf, "SUNLinSol_Band", 0)) { return 1; } /* Specify fast tolerances */ - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = ARKStepSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set the Jacobian routine */ - retval = ARKStepSetJacFn(inner_arkode_mem, Jac); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } break; case (2): /* erk-3-3 fast solver */ case (4): @@ -497,30 +497,30 @@ int main(int argc, char* argv[]) if (check_retval((void*)LSf, "SUNLinSol_Band", 0)) { return 1; } /* Specify fast tolerances */ - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = ARKStepSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set max number of nonlinear iters */ - retval = ARKStepSetMaxNonlinIters(inner_arkode_mem, 10); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) { return 1; } + retval = ARKodeSetMaxNonlinIters(inner_arkode_mem, 10); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) { return 1; } /* Set the Jacobian routine */ - retval = ARKStepSetJacFn(inner_arkode_mem, Jf); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jf); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } break; } /* Attach user data to fast integrator */ - retval = ARKStepSetUserData(inner_arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(inner_arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the fast step size */ - retval = ARKStepSetFixedStep(inner_arkode_mem, hf); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(inner_arkode_mem, hf); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -576,16 +576,16 @@ int main(int argc, char* argv[]) if (check_retval((void*)LSs, "SUNLinSol_Band", 0)) { return 1; } /* Specify tolerances */ - retval = MRIStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set the Jacobian routine */ - retval = MRIStepSetJacFn(arkode_mem, Js); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Js); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } break; case (4): case (5): /* IMEX-MRI-GARK3b, solve-decoupled slow solver */ @@ -606,16 +606,16 @@ int main(int argc, char* argv[]) if (check_retval((void*)LSs, "SUNLinSol_Band", 0)) { return 1; } /* Specify tolerances */ - retval = MRIStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set the Jacobian routine */ - retval = MRIStepSetJacFn(arkode_mem, Jsi); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jsi); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } break; case (6): case (7): /* IMEX-MRI-GARK4, solve-decoupled slow solver */ @@ -636,30 +636,30 @@ int main(int argc, char* argv[]) if (check_retval((void*)LSs, "SUNLinSol_Band", 0)) { return 1; } /* Specify tolerances */ - retval = MRIStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set the Jacobian routine */ - retval = MRIStepSetJacFn(arkode_mem, Jsi); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jsi); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } break; } /* Pass udata to user functions */ - retval = MRIStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Set maximum number of steps taken by solver */ - retval = MRIStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "MRIStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* * Integrate ODE @@ -706,7 +706,7 @@ int main(int argc, char* argv[]) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls MRIStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -715,8 +715,8 @@ int main(int argc, char* argv[]) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* access/print solution statistics */ u = N_VWL2Norm(y, umask); @@ -750,14 +750,14 @@ int main(int argc, char* argv[]) */ /* Get some slow integrator statistics */ - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_retval(&retval, "MRIStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_retval(&retval, "MRIStepGetNumRhsEvals", 1); /* Get some fast integrator statistics */ - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_retval(&retval, "ARKStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nffe, &nffi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); @@ -801,10 +801,10 @@ int main(int argc, char* argv[]) /* Get/print slow integrator decoupled implicit solver statistics */ if (solve_type > 1) { - retval = MRIStepGetNonlinSolvStats(arkode_mem, &nnis, &nncs); - check_retval(&retval, "MRIStepGetNonlinSolvStats", 1); - retval = MRIStepGetNumJacEvals(arkode_mem, &njes); - check_retval(&retval, "MRIStepGetNumJacEvals", 1); + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); + check_retval(&retval, "ARKodeGetNonlinSolvStats", 1); + retval = ARKodeGetNumJacEvals(arkode_mem, &njes); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); printf(" Slow Newton iters = %li\n", nnis); printf(" Slow Newton conv fails = %li\n", nncs); printf(" Slow Jacobian evals = %li\n", njes); @@ -814,10 +814,10 @@ int main(int argc, char* argv[]) if ((solve_type == 0) || (solve_type == 1) || (solve_type == 3) || (solve_type == 5) || (solve_type == 7)) { - retval = ARKStepGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); - check_retval(&retval, "ARKStepGetNonlinSolvStats", 1); - retval = ARKStepGetNumJacEvals(inner_arkode_mem, &njef); - check_retval(&retval, "ARKStepGetNumJacEvals", 1); + retval = ARKodeGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); + check_retval(&retval, "ARKodeGetNonlinSolvStats", 1); + retval = ARKodeGetNumJacEvals(inner_arkode_mem, &njef); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); printf(" Fast Newton iters = %li\n", nnif); printf(" Fast Newton conv fails = %li\n", nncf); printf(" Fast Jacobian evals = %li\n", njef); @@ -825,9 +825,9 @@ int main(int argc, char* argv[]) /* Clean up and return with successful completion */ free(udata); /* Free user data */ - ARKStepFree(&inner_arkode_mem); /* Free integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ ARKodeButcherTable_Free(B); /* Free Butcher table */ MRIStepCoupling_Free(C); /* Free coupling coefficients */ SUNMatDestroy(Af); /* Free fast matrix */ diff --git a/examples/arkode/C_serial/ark_brusselator1D_klu.c b/examples/arkode/C_serial/ark_brusselator1D_klu.c index 1c34e56c3c..208acb9a92 100644 --- a/examples/arkode/C_serial/ark_brusselator1D_klu.c +++ b/examples/arkode/C_serial/ark_brusselator1D_klu.c @@ -223,11 +223,11 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize sparse matrix data structure and KLU solver */ NNZ = 5 * NEQ; @@ -236,11 +236,11 @@ int main(void) LS = SUNLinSol_KLU(y, A, ctx); if (check_flag((void*)LS, "SUNLinSol_KLU", 0)) { return 1; } - /* Attach the matrix, linear solver, and Jacobian construction routine to ARKStep */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); /* Attach matrix and LS */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Supply Jac routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + /* Attach the matrix, linear solver, and Jacobian construction routine to ARKODE */ + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); /* Attach matrix and LS */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Supply Jac routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* output spatial mesh to disk */ FID = fopen("bruss_mesh.txt", "w"); @@ -262,7 +262,7 @@ int main(void) fprintf(VFID, "\n"); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = Tf / Nt; @@ -271,7 +271,7 @@ int main(void) printf(" ----------------------------------------------\n"); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ u = N_VWL2Norm(y, umask); u = SUNRsqrt(u * u / N); v = N_VWL2Norm(y, vmask); @@ -305,22 +305,22 @@ int main(void) fclose(WFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -339,10 +339,10 @@ int main(void) N_VDestroy(wmask); SUNMatDestroy(udata->R); /* Free user data */ free(udata); - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_brusselator_1D_mri.c b/examples/arkode/C_serial/ark_brusselator_1D_mri.c index 57171864e9..ba858f7a0e 100644 --- a/examples/arkode/C_serial/ark_brusselator_1D_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_1D_mri.c @@ -228,24 +228,24 @@ int main(int argc, char* argv[]) if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Attach user data to fast integrator */ - retval = ARKStepSetUserData(inner_arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(inner_arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the fast method */ retval = ARKStepSetTableNum(inner_arkode_mem, ARKODE_ARK324L2SA_DIRK_4_2_3, -1); if (check_retval(&retval, "ARKStepSetTableNum", 1)) { return 1; } /* Specify fast tolerances */ - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Attach matrix and linear solver */ - retval = ARKStepSetLinearSolver(inner_arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set the Jacobian routine */ - retval = ARKStepSetJacFn(inner_arkode_mem, Jf); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jf); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -265,12 +265,12 @@ int main(int argc, char* argv[]) if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } /* Pass udata to user functions */ - retval = MRIStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* output spatial mesh to disk (add extra point for periodic BC) */ FID = fopen("mesh.txt", "w"); @@ -301,7 +301,7 @@ int main(int argc, char* argv[]) fprintf(WFID, " %.16" ESYM, data[IDX(0, 2)]); fprintf(WFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -311,8 +311,8 @@ int main(int argc, char* argv[]) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* access/print solution statistics */ u = N_VWL2Norm(y, umask); @@ -347,30 +347,30 @@ int main(int argc, char* argv[]) fclose(WFID); /* Get some slow integrator statistics */ - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_retval(&retval, "MRIStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_retval(&retval, "MRIStepGetNumRhsEvals", 1); /* Get some fast integrator statistics */ - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_retval(&retval, "ARKStepGetNumSteps", 1); - retval = ARKStepGetNumStepAttempts(inner_arkode_mem, &nstf_a); - check_retval(&retval, "ARKStepGetNumStepAttempts", 1); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_retval(&retval, "ARKodeGetNumSteps", 1); + retval = ARKodeGetNumStepAttempts(inner_arkode_mem, &nstf_a); + check_retval(&retval, "ARKodeGetNumStepAttempts", 1); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nffe, &nffi); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); - retval = ARKStepGetNumLinSolvSetups(inner_arkode_mem, &nsetups); - check_retval(&retval, "ARKStepGetNumLinSolvSetups", 1); - retval = ARKStepGetNumErrTestFails(inner_arkode_mem, &netf); - check_retval(&retval, "ARKStepGetNumErrTestFails", 1); - retval = ARKStepGetNumNonlinSolvIters(inner_arkode_mem, &nni); - check_retval(&retval, "ARKStepGetNumNonlinSolvIters", 1); - retval = ARKStepGetNumNonlinSolvConvFails(inner_arkode_mem, &ncfn); - check_retval(&retval, "ARKStepGetNumNonlinSolvConvFails", 1); - retval = ARKStepGetNumJacEvals(inner_arkode_mem, &nje); - check_retval(&retval, "ARKStepGetNumJacEvals", 1); - retval = ARKStepGetNumLinRhsEvals(inner_arkode_mem, &nfeLS); - check_retval(&retval, "ARKStepGetNumLinRhsEvals", 1); + retval = ARKodeGetNumLinSolvSetups(inner_arkode_mem, &nsetups); + check_retval(&retval, "ARKodeGetNumLinSolvSetups", 1); + retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netf); + check_retval(&retval, "ARKodeGetNumErrTestFails", 1); + retval = ARKodeGetNumNonlinSolvIters(inner_arkode_mem, &nni); + check_retval(&retval, "ARKodeGetNumNonlinSolvIters", 1); + retval = ARKodeGetNumNonlinSolvConvFails(inner_arkode_mem, &ncfn); + check_retval(&retval, "ARKodeGetNumNonlinSolvConvFails", 1); + retval = ARKodeGetNumJacEvals(inner_arkode_mem, &nje); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); + retval = ARKodeGetNumLinRhsEvals(inner_arkode_mem, &nfeLS); + check_retval(&retval, "ARKodeGetNumLinRhsEvals", 1); /* Print some final statistics */ printf("\nFinal Solver Statistics:\n"); @@ -387,9 +387,9 @@ int main(int argc, char* argv[]) /* Clean up and return with successful completion */ free(udata); /* Free user data */ - ARKStepFree(&inner_arkode_mem); /* Free integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ SUNLinSolFree(LS); /* Free linear solver */ SUNMatDestroy(A); /* Free matrix */ N_VDestroy(y); /* Free vectors */ diff --git a/examples/arkode/C_serial/ark_brusselator_fp.c b/examples/arkode/C_serial/ark_brusselator_fp.c index 012acd329e..96b6e2fff6 100644 --- a/examples/arkode/C_serial/ark_brusselator_fp.c +++ b/examples/arkode/C_serial/ark_brusselator_fp.c @@ -185,22 +185,22 @@ int main(int argc, char* argv[]) arkode_mem = ARKStepCreate(fe, fi, T0, y, ctx); if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } - /* Initialize fixed-point nonlinear solver and attach to ARKStep */ + /* Initialize fixed-point nonlinear solver and attach to ARKODE */ NLS = SUNNonlinSol_FixedPoint(y, fp_m, ctx); if (check_flag((void*)NLS, "SUNNonlinSol_FixedPoint", 0)) { return 1; } - flag = ARKStepSetNonlinearSolver(arkode_mem, NLS); - if (check_flag(&flag, "ARKStepSetNonlinearSolver", 1)) { return 1; } + flag = ARKodeSetNonlinearSolver(arkode_mem, NLS); + if (check_flag(&flag, "ARKodeSetNonlinearSolver", 1)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)rdata); /* Pass rdata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } - flag = ARKStepSetMaxNonlinIters(arkode_mem, - maxcor); /* Increase default iterations */ - if (check_flag(&flag, "ARKStepSetMaxNonlinIters", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)rdata); /* Pass rdata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetMaxNonlinIters(arkode_mem, + maxcor); /* Increase default iterations */ + if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -210,7 +210,7 @@ int main(int argc, char* argv[]) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -218,8 +218,8 @@ int main(int argc, char* argv[]) printf(" ----------------------------------------------\n"); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM "\n", /* access/print solution */ t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); @@ -240,18 +240,18 @@ int main(int argc, char* argv[]) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -263,7 +263,7 @@ int main(int argc, char* argv[]) /* Clean up and return with successful completion */ N_VDestroy(y); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNNonlinSolFree(NLS); SUNLogger_Destroy(&logger); SUNContext_Free(&ctx); diff --git a/examples/arkode/C_serial/ark_brusselator_mri.c b/examples/arkode/C_serial/ark_brusselator_mri.c index 0fbca635e7..0b636fd3a7 100644 --- a/examples/arkode/C_serial/ark_brusselator_mri.c +++ b/examples/arkode/C_serial/ark_brusselator_mri.c @@ -135,16 +135,16 @@ int main(void) if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Attach user data to fast integrator */ - retval = ARKStepSetUserData(inner_arkode_mem, (void*)rdata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(inner_arkode_mem, (void*)rdata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the fast method */ retval = ARKStepSetTableNum(inner_arkode_mem, -1, ARKODE_KNOTH_WOLKE_3_3); if (check_retval(&retval, "ARKStepSetTableNum", 1)) { return 1; } /* Set the fast step size */ - retval = ARKStepSetFixedStep(inner_arkode_mem, hf); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(inner_arkode_mem, hf); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -164,12 +164,12 @@ int main(void) if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } /* Pass rdata to user functions */ - retval = MRIStepSetUserData(arkode_mem, (void*)rdata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)rdata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* * Integrate ODE @@ -183,7 +183,7 @@ int main(void) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls MRIStepEvolve to perform the + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; @@ -196,8 +196,8 @@ int main(void) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* access/print solution */ printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM "\n", t, @@ -217,14 +217,14 @@ int main(void) */ /* Get some slow integrator statistics */ - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_retval(&retval, "MRIStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_retval(&retval, "MRIStepGetNumRhsEvals", 1); /* Get some fast integrator statistics */ - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_retval(&retval, "ARKStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nff, &tmp); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); @@ -235,9 +235,9 @@ int main(void) /* Clean up and return */ N_VDestroy(y); /* Free y vector */ - ARKStepFree(&inner_arkode_mem); /* Free integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ SUNContext_Free(&ctx); /* Free context */ return 0; diff --git a/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c b/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c index 4ef129b9d3..c9570e8bec 100644 --- a/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c +++ b/examples/arkode/C_serial/ark_conserved_exp_entropy_ark.c @@ -215,14 +215,14 @@ int main(int argc, char* argv[]) if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } /* Specify tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(flag, "ARKStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } if (relax) { /* Enable relaxation methods */ - flag = ARKStepSetRelaxFn(arkode_mem, Ent, JacEnt); - if (check_flag(flag, "ARKStepSetRelaxFn")) { return 1; } + flag = ARKodeSetRelaxFn(arkode_mem, Ent, JacEnt); + if (check_flag(flag, "ARKodeSetRelaxFn")) { return 1; } } if (implicit) @@ -235,12 +235,12 @@ int main(int argc, char* argv[]) if (check_ptr(LS, "SUNLinSol_Dense")) { return 1; } /* Attach the matrix and linear solver */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(flag, "ARKStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } /* Set Jacobian routine */ - flag = ARKStepSetJacFn(arkode_mem, Jac); - if (check_flag(flag, "ARKStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } /* Select a Butcher table with non-negative b values */ flag = ARKStepSetTableName(arkode_mem, "ARKODE_ARK2_DIRK_3_1_2", @@ -248,14 +248,14 @@ int main(int argc, char* argv[]) if (check_flag(flag, "ARKStepSetTableName")) { return 1; } /* Tighten nonlinear solver tolerance */ - flag = ARKStepSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); - if (check_flag(flag, "ARKStepSetNonlinConvCoef")) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); + if (check_flag(flag, "ARKodeSetNonlinConvCoef")) { return 1; } } if (fixed_h > SUN_RCONST(0.0)) { - flag = ARKStepSetFixedStep(arkode_mem, fixed_h); - if (check_flag(flag, "ARKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } /* Open output stream for results, output comment line */ @@ -290,8 +290,8 @@ int main(int argc, char* argv[]) while (t < tf) { /* Evolve in time */ - flag = ARKStepEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); - if (check_flag(flag, "ARKStepEvolve")) { break; } + flag = ARKodeEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { break; } /* Output solution and errors */ flag = Ent(y, &ent, NULL); @@ -305,8 +305,8 @@ int main(int argc, char* argv[]) v_err = ydata[1] - ytdata[1]; /* Output to the screen periodically */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ARKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); if (nst % 40 == 0) { @@ -331,14 +331,14 @@ int main(int argc, char* argv[]) * ------------ */ /* Get final statistics on how the solve progressed */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ARKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(flag, "ARKStepGetNumStepAttempts"); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(flag, "ARKodeGetNumStepAttempts"); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(flag, "ARKStepGetNumErrTestFails"); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(flag, "ARKodeGetNumErrTestFails"); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(flag, "ARKStepGetNumRhsEvals"); @@ -350,20 +350,20 @@ int main(int argc, char* argv[]) if (implicit) { - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(flag, "ARKStepGetNumNonlinSolvIters"); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(flag, "ARKodeGetNumNonlinSolvIters"); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(flag, "ARKStepGetNumNonlinSolvConvFails"); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(flag, "ARKodeGetNumNonlinSolvConvFails"); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(flag, "ARKStepGetNumLinSolvSetups"); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(flag, "ARKodeGetNumLinSolvSetups"); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(flag, "ARKStepGetNumJacEvals"); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(flag, "ARKodeGetNumJacEvals"); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(flag, "ARKStepGetNumLinRhsEvals"); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(flag, "ARKodeGetNumLinRhsEvals"); printf(" Total number of Newton iterations = %li\n", nni); printf(" Total number of linear solver convergence failures = %li\n", ncfn); @@ -374,23 +374,23 @@ int main(int argc, char* argv[]) if (relax) { - flag = ARKStepGetNumRelaxFnEvals(arkode_mem, &nre); - check_flag(flag, "ARKStepGetNumRelaxFnEvals"); + flag = ARKodeGetNumRelaxFnEvals(arkode_mem, &nre); + check_flag(flag, "ARKodeGetNumRelaxFnEvals"); - flag = ARKStepGetNumRelaxJacEvals(arkode_mem, &nrje); - check_flag(flag, "ARKStepGetNumRelaxJacEvals"); + flag = ARKodeGetNumRelaxJacEvals(arkode_mem, &nrje); + check_flag(flag, "ARKodeGetNumRelaxJacEvals"); - flag = ARKStepGetNumRelaxFails(arkode_mem, &nrf); - check_flag(flag, "ARKStepGetNumRelaxFails"); + flag = ARKodeGetNumRelaxFails(arkode_mem, &nrf); + check_flag(flag, "ARKodeGetNumRelaxFails"); - flag = ARKStepGetNumRelaxBoundFails(arkode_mem, &nrbf); - check_flag(flag, "ARKStepGetNumRelaxBoundFails"); + flag = ARKodeGetNumRelaxBoundFails(arkode_mem, &nrbf); + check_flag(flag, "ARKodeGetNumRelaxBoundFails"); - flag = ARKStepGetNumRelaxSolveFails(arkode_mem, &nrnlsf); - check_flag(flag, "ARKStepGetNumRelaxSolveFails"); + flag = ARKodeGetNumRelaxSolveFails(arkode_mem, &nrnlsf); + check_flag(flag, "ARKodeGetNumRelaxSolveFails"); - flag = ARKStepGetNumRelaxSolveIters(arkode_mem, &nrnlsi); - check_flag(flag, "ARKStepGetNumRelaxSolveIters"); + flag = ARKodeGetNumRelaxSolveIters(arkode_mem, &nrnlsi); + check_flag(flag, "ARKodeGetNumRelaxSolveIters"); printf(" Total Relaxation Fn evals = %li\n", nre); printf(" Total Relaxation Jac evals = %li\n", nrje); @@ -405,8 +405,8 @@ int main(int argc, char* argv[]) * Clean up * * -------- */ - /* Free ARKStep integrator and SUNDIALS objects */ - ARKStepFree(&arkode_mem); + /* Free ARKode integrator and SUNDIALS objects */ + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); SUNMatDestroy(A); N_VDestroy(y); diff --git a/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c b/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c index e78a50e9bc..6b73b0d999 100644 --- a/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c +++ b/examples/arkode/C_serial/ark_conserved_exp_entropy_erk.c @@ -202,20 +202,20 @@ int main(int argc, char* argv[]) if (check_ptr(arkode_mem, "ERKStepCreate")) { return 1; } /* Specify tolerances */ - flag = ERKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(flag, "ERKStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } if (relax) { /* Enable relaxation methods */ - flag = ERKStepSetRelaxFn(arkode_mem, Ent, JacEnt); - if (check_flag(flag, "ERKStepSetRelaxFn")) { return 1; } + flag = ARKodeSetRelaxFn(arkode_mem, Ent, JacEnt); + if (check_flag(flag, "ARKodeSetRelaxFn")) { return 1; } } if (fixed_h > SUN_RCONST(0.0)) { - flag = ERKStepSetFixedStep(arkode_mem, fixed_h); - if (check_flag(flag, "ERKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } /* Open output stream for results, output comment line */ @@ -250,8 +250,8 @@ int main(int argc, char* argv[]) while (t < tf) { /* Evolve in time */ - flag = ERKStepEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); - if (check_flag(flag, "ERKStepEvolve")) { break; } + flag = ARKodeEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { break; } /* Output solution and errors */ flag = Ent(y, &ent, NULL); @@ -265,8 +265,8 @@ int main(int argc, char* argv[]) v_err = ydata[1] - ytdata[1]; /* Output to the screen periodically */ - flag = ERKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ERKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); if (nst % 40 == 0) { @@ -291,14 +291,14 @@ int main(int argc, char* argv[]) * ------------ */ /* Get final statistics on how the solve progressed */ - flag = ERKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ERKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); - flag = ERKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(flag, "ERKStepGetNumStepAttempts"); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(flag, "ARKodeGetNumStepAttempts"); - flag = ERKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(flag, "ERKStepGetNumErrTestFails"); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(flag, "ARKodeGetNumErrTestFails"); flag = ERKStepGetNumRhsEvals(arkode_mem, &nfe); check_flag(flag, "ERKStepGetNumRhsEvals"); @@ -310,23 +310,23 @@ int main(int argc, char* argv[]) if (relax) { - flag = ERKStepGetNumRelaxFnEvals(arkode_mem, &nre); - check_flag(flag, "ERKStepGetNumRelaxFnEvals"); + flag = ARKodeGetNumRelaxFnEvals(arkode_mem, &nre); + check_flag(flag, "ARKodeGetNumRelaxFnEvals"); - flag = ERKStepGetNumRelaxJacEvals(arkode_mem, &nrje); - check_flag(flag, "ERKStepGetNumRelaxJacEvals"); + flag = ARKodeGetNumRelaxJacEvals(arkode_mem, &nrje); + check_flag(flag, "ARKodeGetNumRelaxJacEvals"); - flag = ERKStepGetNumRelaxFails(arkode_mem, &nrf); - check_flag(flag, "ERKStepGetNumRelaxFails"); + flag = ARKodeGetNumRelaxFails(arkode_mem, &nrf); + check_flag(flag, "ARKodeGetNumRelaxFails"); - flag = ERKStepGetNumRelaxBoundFails(arkode_mem, &nrbf); - check_flag(flag, "ERKStepGetNumRelaxBoundFails"); + flag = ARKodeGetNumRelaxBoundFails(arkode_mem, &nrbf); + check_flag(flag, "ARKodeGetNumRelaxBoundFails"); - flag = ERKStepGetNumRelaxSolveFails(arkode_mem, &nrnlsf); - check_flag(flag, "ERKStepGetNumRelaxSolveFails"); + flag = ARKodeGetNumRelaxSolveFails(arkode_mem, &nrnlsf); + check_flag(flag, "ARKodeGetNumRelaxSolveFails"); - flag = ERKStepGetNumRelaxSolveIters(arkode_mem, &nrnlsi); - check_flag(flag, "ERKStepGetNumRelaxSolveIters"); + flag = ARKodeGetNumRelaxSolveIters(arkode_mem, &nrnlsi); + check_flag(flag, "ARKodeGetNumRelaxSolveIters"); printf(" Total Relaxation Fn evals = %li\n", nre); printf(" Total Relaxation Jac evals = %li\n", nrje); @@ -341,8 +341,8 @@ int main(int argc, char* argv[]) * Clean up * * -------- */ - /* Free ERKStep integrator and SUNDIALS objects */ - ERKStepFree(&arkode_mem); + /* Free ARKode integrator and SUNDIALS objects */ + ARKodeFree(&arkode_mem); N_VDestroy(y); N_VDestroy(ytrue); SUNContext_Free(&ctx); diff --git a/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c b/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c index 79e6310538..8bfca224ed 100644 --- a/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c +++ b/examples/arkode/C_serial/ark_damped_harmonic_symplectic.c @@ -106,17 +106,17 @@ int main(int argc, char* argv[]) /* Create SPRKStep integrator */ arkode_mem = SPRKStepCreate(qdot, pdot, T0, y, sunctx); - retval = SPRKStepSetOrder(arkode_mem, order); - if (check_retval(&retval, "SPRKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } retval = SPRKStepSetUseCompensatedSums(arkode_mem, use_compsums); if (check_retval(&retval, "SPRKStepSetUseCompensatedSums", 1)) { return 1; } - retval = SPRKStepSetFixedStep(arkode_mem, dt); - if (check_retval(&retval, "SPRKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, dt); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } - retval = SPRKStepSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 2); - if (check_retval(&retval, "SPRKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 2); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Print out starting Hamiltonian before integrating */ tret = T0; @@ -128,8 +128,8 @@ int main(int argc, char* argv[]) /* Do integration */ for (iout = 0; iout < num_output_times; iout++) { - if (args.use_tstop) { SPRKStepSetStopTime(arkode_mem, tout); } - retval = SPRKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (args.use_tstop) { ARKodeSetStopTime(arkode_mem, tout); } + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); /* Output current integration status */ fprintf(stdout, "t = %.6Lf, q(t) = %.6Lf, H = %.6Lf\n", (long double)tret, @@ -149,9 +149,9 @@ int main(int argc, char* argv[]) } fprintf(stdout, "\n"); - SPRKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); N_VDestroy(y); - SPRKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); SUNContext_Free(&sunctx); return 0; diff --git a/examples/arkode/C_serial/ark_dissipated_exp_entropy.c b/examples/arkode/C_serial/ark_dissipated_exp_entropy.c index 7f6db669c1..5b071b61ae 100644 --- a/examples/arkode/C_serial/ark_dissipated_exp_entropy.c +++ b/examples/arkode/C_serial/ark_dissipated_exp_entropy.c @@ -195,14 +195,14 @@ int main(int argc, char* argv[]) if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } /* Specify tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(flag, "ARKStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } if (relax) { /* Enable relaxation methods */ - flag = ARKStepSetRelaxFn(arkode_mem, Ent, JacEnt); - if (check_flag(flag, "ARKStepSetRelaxFn")) { return 1; } + flag = ARKodeSetRelaxFn(arkode_mem, Ent, JacEnt); + if (check_flag(flag, "ARKodeSetRelaxFn")) { return 1; } } if (implicit) @@ -215,12 +215,12 @@ int main(int argc, char* argv[]) if (check_ptr(LS, "SUNLinSol_Dense")) { return 1; } /* Attach the matrix and linear solver */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(flag, "ARKStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } /* Set Jacobian routine */ - flag = ARKStepSetJacFn(arkode_mem, Jac); - if (check_flag(flag, "ARKStepSetJacFn")) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); + if (check_flag(flag, "ARKodeSetJacFn")) { return 1; } /* Select a Butcher table with non-negative b values */ flag = ARKStepSetTableName(arkode_mem, "ARKODE_ARK2_DIRK_3_1_2", @@ -228,14 +228,14 @@ int main(int argc, char* argv[]) if (check_flag(flag, "ARKStepSetTableName")) { return 1; } /* Tighten nonlinear solver tolerance */ - flag = ARKStepSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); - if (check_flag(flag, "ARKStepSetNonlinConvCoef")) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkode_mem, SUN_RCONST(0.01)); + if (check_flag(flag, "ARKodeSetNonlinConvCoef")) { return 1; } } if (fixed_h > SUN_RCONST(0.0)) { - flag = ARKStepSetFixedStep(arkode_mem, fixed_h); - if (check_flag(flag, "ARKStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, fixed_h); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } } /* Open output stream for results, output comment line */ @@ -269,8 +269,8 @@ int main(int argc, char* argv[]) while (t < tf) { /* Evolve in time */ - flag = ARKStepEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); - if (check_flag(flag, "ARKStepEvolve")) { break; } + flag = ARKodeEvolve(arkode_mem, tf, y, &t, ARK_ONE_STEP); + if (check_flag(flag, "ARKodeEvolve")) { break; } /* Output solution and errors */ flag = Ent(y, &ent, NULL); @@ -283,8 +283,8 @@ int main(int argc, char* argv[]) u_err = ydata[0] - ytdata[0]; /* Output to the screen periodically */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ARKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); if (nst % 40 == 0) { @@ -309,14 +309,14 @@ int main(int argc, char* argv[]) * ------------ */ /* Get final statistics on how the solve progressed */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(flag, "ARKStepGetNumSteps"); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(flag, "ARKodeGetNumSteps"); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(flag, "ARKStepGetNumStepAttempts"); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(flag, "ARKodeGetNumStepAttempts"); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(flag, "ARKStepGetNumErrTestFails"); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(flag, "ARKodeGetNumErrTestFails"); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(flag, "ARKStepGetNumRhsEvals"); @@ -328,20 +328,20 @@ int main(int argc, char* argv[]) if (implicit) { - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(flag, "ARKStepGetNumNonlinSolvIters"); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(flag, "ARKodeGetNumNonlinSolvIters"); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(flag, "ARKStepGetNumNonlinSolvConvFails"); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(flag, "ARKodeGetNumNonlinSolvConvFails"); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(flag, "ARKStepGetNumLinSolvSetups"); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(flag, "ARKodeGetNumLinSolvSetups"); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(flag, "ARKStepGetNumJacEvals"); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(flag, "ARKodeGetNumJacEvals"); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(flag, "ARKStepGetNumLinRhsEvals"); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(flag, "ARKodeGetNumLinRhsEvals"); printf(" Total number of Newton iterations = %li\n", nni); printf(" Total number of linear solver convergence failures = %li\n", ncfn); @@ -352,23 +352,23 @@ int main(int argc, char* argv[]) if (relax) { - flag = ARKStepGetNumRelaxFnEvals(arkode_mem, &nre); - check_flag(flag, "ARKStepGetNumRelaxFnEvals"); + flag = ARKodeGetNumRelaxFnEvals(arkode_mem, &nre); + check_flag(flag, "ARKodeGetNumRelaxFnEvals"); - flag = ARKStepGetNumRelaxJacEvals(arkode_mem, &nrje); - check_flag(flag, "ARKStepGetNumRelaxJacEvals"); + flag = ARKodeGetNumRelaxJacEvals(arkode_mem, &nrje); + check_flag(flag, "ARKodeGetNumRelaxJacEvals"); - flag = ARKStepGetNumRelaxFails(arkode_mem, &nrf); - check_flag(flag, "ARKStepGetNumRelaxFails"); + flag = ARKodeGetNumRelaxFails(arkode_mem, &nrf); + check_flag(flag, "ARKodeGetNumRelaxFails"); - flag = ARKStepGetNumRelaxBoundFails(arkode_mem, &nrbf); - check_flag(flag, "ARKStepGetNumRelaxBoundFails"); + flag = ARKodeGetNumRelaxBoundFails(arkode_mem, &nrbf); + check_flag(flag, "ARKodeGetNumRelaxBoundFails"); - flag = ARKStepGetNumRelaxSolveFails(arkode_mem, &nrnlsf); - check_flag(flag, "ARKStepGetNumRelaxSolveFails"); + flag = ARKodeGetNumRelaxSolveFails(arkode_mem, &nrnlsf); + check_flag(flag, "ARKodeGetNumRelaxSolveFails"); - flag = ARKStepGetNumRelaxSolveIters(arkode_mem, &nrnlsi); - check_flag(flag, "ARKStepGetNumRelaxSolveIters"); + flag = ARKodeGetNumRelaxSolveIters(arkode_mem, &nrnlsi); + check_flag(flag, "ARKodeGetNumRelaxSolveIters"); printf(" Total Relaxation Fn evals = %li\n", nre); printf(" Total Relaxation Jac evals = %li\n", nrje); @@ -383,8 +383,8 @@ int main(int argc, char* argv[]) * Clean up * * -------- */ - /* Free ARKStep integrator and SUNDIALS objects */ - ARKStepFree(&arkode_mem); + /* Free ARKODE integrator and SUNDIALS objects */ + ARKodeFree(&arkode_mem); SUNLinSolFree(LS); SUNMatDestroy(A); N_VDestroy(y); diff --git a/examples/arkode/C_serial/ark_harmonic_symplectic.c b/examples/arkode/C_serial/ark_harmonic_symplectic.c index 411c49ea63..72ddfa656c 100644 --- a/examples/arkode/C_serial/ark_harmonic_symplectic.c +++ b/examples/arkode/C_serial/ark_harmonic_symplectic.c @@ -125,20 +125,20 @@ int main(int argc, char* argv[]) /* Create SPRKStep integrator */ arkode_mem = SPRKStepCreate(xdot, vdot, T0, y, sunctx); - retval = SPRKStepSetOrder(arkode_mem, order); - if (check_retval(&retval, "SPRKStepSetOrder", 1)) { return 1; } + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) { return 1; } - retval = SPRKStepSetUserData(arkode_mem, &udata); - if (check_retval(&retval, "SPRKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, &udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } retval = SPRKStepSetUseCompensatedSums(arkode_mem, use_compsums); if (check_retval(&retval, "SPRKStepSetUseCompensatedSums", 1)) { return 1; } - retval = SPRKStepSetFixedStep(arkode_mem, dt); - if (check_retval(&retval, "SPRKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, dt); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } - retval = SPRKStepSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 2); - if (check_retval(&retval, "SPRKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 2); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Print out starting energy, momentum before integrating */ tret = T0; @@ -150,8 +150,8 @@ int main(int argc, char* argv[]) /* Do integration */ for (iout = 0; iout < num_output_times; iout++) { - if (args.use_tstop) { SPRKStepSetStopTime(arkode_mem, tout); } - retval = SPRKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (args.use_tstop) { ARKodeSetStopTime(arkode_mem, tout); } + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); /* Compute the anaytical solution */ Solution(tret, y, solution, &udata); @@ -188,8 +188,8 @@ int main(int argc, char* argv[]) fprintf(stdout, "\n"); N_VDestroy(y); N_VDestroy(solution); - SPRKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); - SPRKStepFree(&arkode_mem); + ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + ARKodeFree(&arkode_mem); SUNContext_Free(&sunctx); return 0; diff --git a/examples/arkode/C_serial/ark_heat1D.c b/examples/arkode/C_serial/ark_heat1D.c index eb6609029d..c5e7597ecb 100644 --- a/examples/arkode/C_serial/ark_heat1D.c +++ b/examples/arkode/C_serial/ark_heat1D.c @@ -124,31 +124,31 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, - 1); /* Specify maximum-order predictor */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, + 1); /* Specify maximum-order predictor */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize PCG solver -- no preconditioning, with up to N iterations */ LS = SUNLinSol_PCG(y, 0, (int)N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } /* Linear solver interface -- set user-supplied J*v routine (no 'jtsetup' required) */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - NULL); /* Attach linear solver to ARKStep */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + NULL); /* Attach linear solver to ARKODE */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* output mesh to disk */ FID = fopen("heat_mesh.txt", "w"); @@ -163,7 +163,7 @@ int main(void) for (i = 0; i < N; i++) { fprintf(UFID, " %.16" ESYM "", data[i]); } fprintf(UFID, "\n"); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -173,8 +173,8 @@ int main(void) printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); /* print solution stats */ if (flag >= 0) @@ -196,26 +196,26 @@ int main(void) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - check_flag(&flag, "ARKStepGetNumLinIters", 1); - flag = ARKStepGetNumJtimesEvals(arkode_mem, &nJv); - check_flag(&flag, "ARKStepGetNumJtimesEvals", 1); - flag = ARKStepGetNumLinConvFails(arkode_mem, &nlcf); - check_flag(&flag, "ARKStepGetNumLinConvFails", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + check_flag(&flag, "ARKodeGetNumLinIters", 1); + flag = ARKodeGetNumJtimesEvals(arkode_mem, &nJv); + check_flag(&flag, "ARKodeGetNumJtimesEvals", 1); + flag = ARKodeGetNumLinConvFails(arkode_mem, &nlcf); + check_flag(&flag, "ARKodeGetNumLinConvFails", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -230,11 +230,11 @@ int main(void) printf(" Total number of error test failures = %li\n", netf); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free vectors */ - free(udata); /* Free user data */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free vectors */ + free(udata); /* Free user data */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_heat1D_adapt.c b/examples/arkode/C_serial/ark_heat1D_adapt.c index 2852bffc4a..3f9e349073 100644 --- a/examples/arkode/C_serial/ark_heat1D_adapt.c +++ b/examples/arkode/C_serial/ark_heat1D_adapt.c @@ -161,35 +161,35 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetUserData(arkode_mem, - (void*)udata); /* Pass udata to user functions */ - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, + (void*)udata); /* Pass udata to user functions */ + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 10000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } flag = ARKStepSetAdaptivityMethod(arkode_mem, 2, 1, 0, NULL); /* Set adaptivity method */ - if (check_flag(&flag, "ARKStepSetAdaptivityMethod", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, 0); /* Set predictor method */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } + if (check_flag(&flag, "ARKodeSetAdaptivityMethod", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, 0); /* Set predictor method */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } /* Specify linearly implicit RHS, with time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 1); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 1); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Initialize PCG solver -- no preconditioning, with up to N iterations */ LS = SUNLinSol_PCG(y, 0, (int)N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } /* Linear solver interface -- set user-supplied J*v routine (no 'jtsetup' required) */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - NULL); /* Attach linear solver to ARKStep */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + NULL); /* Attach linear solver to ARKODE */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; olddt = ZERO; @@ -204,22 +204,22 @@ int main(void) while (t < Tf) { /* "set" routines */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } /* call integrator */ - flag = ARKStepEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } /* "get" routines */ - flag = ARKStepGetLastStep(arkode_mem, &olddt); - if (check_flag(&flag, "ARKStepGetLastStep", 1)) { return 1; } - flag = ARKStepGetCurrentStep(arkode_mem, &newdt); - if (check_flag(&flag, "ARKStepGetCurrentStep", 1)) { return 1; } - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return 1; } - flag = ARKStepGetNumLinIters(arkode_mem, &nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return 1; } + flag = ARKodeGetLastStep(arkode_mem, &olddt); + if (check_flag(&flag, "ARKodeGetLastStep", 1)) { return 1; } + flag = ARKodeGetCurrentStep(arkode_mem, &newdt); + if (check_flag(&flag, "ARKodeGetCurrentStep", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumLinIters(arkode_mem, &nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return 1; } /* print current solution stats */ iout++; @@ -262,18 +262,18 @@ int main(void) y = y2; y2 = yt; - /* call ARKStepResize to notify integrator of change in mesh */ - flag = ARKStepResize(arkode_mem, y, hscale, t, NULL, NULL); - if (check_flag(&flag, "ARKStepResize", 1)) { return 1; } + /* call ARKodeResize to notify integrator of change in mesh */ + flag = ARKodeResize(arkode_mem, y, hscale, t, NULL, NULL); + if (check_flag(&flag, "ARKodeResize", 1)) { return 1; } - /* destroy and re-allocate linear solver memory; reattach to ARKStep interface */ + /* destroy and re-allocate linear solver memory; reattach to ARKODE interface */ SUNLinSolFree(LS); LS = SUNLinSol_PCG(y, 0, (int)N, ctx); if (check_flag((void*)LS, "SUNLinSol_PCG", 0)) { return 1; } - flag = ARKStepSetLinearSolver(arkode_mem, LS, NULL); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacTimes(arkode_mem, NULL, Jac); - if (check_flag(&flag, "ARKStepSetJacTimes", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, NULL); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacTimes(arkode_mem, NULL, Jac); + if (check_flag(&flag, "ARKodeSetJacTimes", 1)) { return 1; } } printf(" --------------------------------------------------------------------" "--------------------\n"); @@ -290,9 +290,9 @@ int main(void) N_VDestroy(y); /* Free vectors */ free(udata->x); /* Free user data */ free(udata); - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNContext_Free(&ctx); /* Free context */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_kepler.c b/examples/arkode/C_serial/ark_kepler.c index f6fd9982d5..5492d040fd 100644 --- a/examples/arkode/C_serial/ark_kepler.c +++ b/examples/arkode/C_serial/ark_kepler.c @@ -161,8 +161,8 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) /* Optional: enable temporal root-finding */ if (count_orbits) { - SPRKStepRootInit(arkode_mem, 1, rootfn); - if (check_retval(&retval, "SPRKStepRootInit", 1)) { return 1; } + ARKodeRootInit(arkode_mem, 1, rootfn); + if (check_retval(&retval, "ARKodeRootInit", 1)) { return 1; } } retval = SPRKStepSetMethodName(arkode_mem, method_name); @@ -173,11 +173,11 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) if (step_mode == 0) { - retval = SPRKStepSetFixedStep(arkode_mem, dt); - if (check_retval(&retval, "SPRKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, dt); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } - retval = SPRKStepSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 1); - if (check_retval(&retval, "SPRKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 1); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } } else { @@ -186,8 +186,8 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) return 1; } - retval = SPRKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "SPRKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } } else if (stepper == 1) { @@ -198,21 +198,21 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) if (count_orbits) { - ARKStepRootInit(arkode_mem, 1, rootfn); - if (check_retval(&retval, "ARKStepRootInit", 1)) { return 1; } + ARKodeRootInit(arkode_mem, 1, rootfn); + if (check_retval(&retval, "ARKodeRootInit", 1)) { return 1; } } - retval = ARKStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } - retval = ARKStepSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 1); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, ((long int)ceil(Tf / dt)) + 1); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } - if (step_mode == 0) { retval = ARKStepSetFixedStep(arkode_mem, dt); } + if (step_mode == 0) { retval = ARKodeSetFixedStep(arkode_mem, dt); } else { - retval = ARKStepSStolerances(arkode_mem, dt, dt); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, dt, dt); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } } } @@ -264,15 +264,15 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) exact requested output time will not be hit (even with a fixed time-step due to roundoff error accumulation) and interpolation will be used to get the solution at the output time. */ - if (args->use_tstop) { SPRKStepSetStopTime(arkode_mem, tout); } - retval = SPRKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (args->use_tstop) { ARKodeSetStopTime(arkode_mem, tout); } + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); if (retval == ARK_ROOT_RETURN) { num_orbits += SUN_RCONST(0.5); fprintf(stdout, "ROOT RETURN:\t"); - SPRKStepGetRootInfo(arkode_mem, &rootsfound); + ARKodeGetRootInfo(arkode_mem, &rootsfound); fprintf(stdout, " g[0] = %3d, y[0] = %3Lg, y[1] = %3Lg, num. orbits is now %.2Lf\n", rootsfound, (long double)ydata[0], (long double)ydata[1], (long double)num_orbits); @@ -311,15 +311,15 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) exact requested output time will not be hit (even with a fixed time-step due to roundoff error accumulation) and interpolation will be used to get the solution at the output time. */ - if (args->use_tstop) { ARKStepSetStopTime(arkode_mem, tout); } - retval = ARKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + if (args->use_tstop) { ARKodeSetStopTime(arkode_mem, tout); } + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); if (retval == ARK_ROOT_RETURN) { num_orbits += SUN_RCONST(0.5); fprintf(stdout, "ROOT RETURN:\t"); - ARKStepGetRootInfo(arkode_mem, &rootsfound); + ARKodeGetRootInfo(arkode_mem, &rootsfound); fprintf(stdout, " g[0] = %3d, y[0] = %3Lg, y[1] = %3Lg, num. orbits is now %.2Lf\n", rootsfound, (long double)ydata[0], (long double)ydata[1], (long double)num_orbits); @@ -361,17 +361,8 @@ int SolveProblem(ProgramArgs* args, ProblemResult* result, SUNContext sunctx) fclose(solution_fp); if (NLS) { SUNNonlinSolFree(NLS); } N_VDestroy(y); - if (stepper == 0) - { - SPRKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); - SPRKStepFree(&arkode_mem); - } - else - { - ARKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); - ARKStepFree(&arkode_mem); - } - + ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + ARKodeFree(&arkode_mem); return 0; } diff --git a/examples/arkode/C_serial/ark_kpr_mri.c b/examples/arkode/C_serial/ark_kpr_mri.c index aac99fbb99..1495435820 100644 --- a/examples/arkode/C_serial/ark_kpr_mri.c +++ b/examples/arkode/C_serial/ark_kpr_mri.c @@ -159,14 +159,14 @@ int main(int argc, char* argv[]) SUNLinearSolver LSf = NULL; /* fast linear solver object */ SUNMatrix As = NULL; /* matrix for slow solver */ SUNLinearSolver LSs = NULL; /* slow linear solver object */ - sunbooleantype implicit_slow = SUNFALSE; - sunbooleantype imex_slow = SUNFALSE; - sunbooleantype explicit_slow = SUNFALSE; - sunbooleantype no_slow = SUNFALSE; - sunbooleantype implicit_fast = SUNFALSE; - sunbooleantype explicit_fast = SUNFALSE; - sunbooleantype no_fast = SUNFALSE; - sunbooleantype deduce = SUNFALSE; + sunbooleantype implicit_slow = SUNFALSE; + sunbooleantype imex_slow = SUNFALSE; + sunbooleantype explicit_slow = SUNFALSE; + sunbooleantype no_slow = SUNFALSE; + sunbooleantype implicit_fast = SUNFALSE; + sunbooleantype explicit_fast = SUNFALSE; + sunbooleantype no_fast = SUNFALSE; + sunbooleantype deduce = SUNFALSE; FILE* UFID; sunrealtype hf, gamma, beta, t, tout, rpar[3]; sunrealtype uerr, verr, uerrtot, verrtot, errtot; @@ -180,10 +180,11 @@ int main(int argc, char* argv[]) /* Retrieve the command-line options: slow_type fast_type h G w e deduce */ if (argc < 3) { - printf("ERROR: executable requires at least two arguments [slow_type fast_type]\n"); + printf("ERROR: executable requires at least two arguments [slow_type " + "fast_type]\n"); printf("Usage:\n"); printf(" a.out slow_type fast_type h G w e deduce"); - return(-1); + return (-1); } slow_type = (sunindextype)atol(argv[1]); fast_type = (sunindextype)atol(argv[2]); @@ -217,7 +218,8 @@ int main(int argc, char* argv[]) } if (((slow_type == 9) || (slow_type == 10)) && (fast_type == 0)) { - printf("ERROR: example not configured for ImEx slow solver with no fast solver\n"); + printf("ERROR: example not configured for ImEx slow solver with no fast " + "solver\n"); return (-1); } if (G >= ZERO) @@ -255,92 +257,92 @@ int main(int argc, char* argv[]) printf(" e = %" GSYM "\n", e); switch (slow_type) { - case (0): - printf(" slow solver: none\n"); - no_slow = SUNTRUE; - break; - case (1): - printf(" slow solver: ARKODE_MIS_KW3\n"); - explicit_slow = SUNTRUE; - break; - case (7): - printf(" slow solver: ARKODE_MRI_GARK_IRK21a\n"); - implicit_slow = SUNTRUE; - reltol = SUNMAX(hs * hs, 1e-10); - abstol = 1e-11; - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); - break; - case (2): - printf(" slow solver: ARKODE_MRI_GARK_ERK45a\n"); - explicit_slow = SUNTRUE; - break; - case (8): - printf(" slow solver: ARKODE_MRI_GARK_ESDIRK34a\n"); - implicit_slow = SUNTRUE; - reltol = SUNMAX(hs * hs * hs, 1e-10); - abstol = 1e-11; - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); - break; - case (9): - printf(" slow solver: ARKODE_IMEX_MRI_GARK3b\n"); - imex_slow = SUNTRUE; - reltol = SUNMAX(hs * hs * hs, 1e-10); - abstol = 1e-11; - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); - break; - case (10): - printf(" slow solver: ARKODE_IMEX_MRI_GARK4\n"); - imex_slow = SUNTRUE; - reltol = SUNMAX(hs * hs * hs * hs, 1e-14); - abstol = 1e-14; - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); - break; - case (3): - printf(" slow solver: ARKODE_MERK21\n"); - explicit_slow = SUNTRUE; - break; - case (4): - printf(" slow solver: ARKODE_MERK32\n"); - explicit_slow = SUNTRUE; - break; - case (5): - printf(" slow solver: ARKODE_MERK43\n"); - explicit_slow = SUNTRUE; - break; - case (6): - printf(" slow solver: ARKODE_MERK54\n"); - explicit_slow = SUNTRUE; - break; + case (0): + printf(" slow solver: none\n"); + no_slow = SUNTRUE; + break; + case (1): + printf(" slow solver: ARKODE_MIS_KW3\n"); + explicit_slow = SUNTRUE; + break; + case (7): + printf(" slow solver: ARKODE_MRI_GARK_IRK21a\n"); + implicit_slow = SUNTRUE; + reltol = SUNMAX(hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (2): + printf(" slow solver: ARKODE_MRI_GARK_ERK45a\n"); + explicit_slow = SUNTRUE; + break; + case (8): + printf(" slow solver: ARKODE_MRI_GARK_ESDIRK34a\n"); + implicit_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (9): + printf(" slow solver: ARKODE_IMEX_MRI_GARK3b\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (10): + printf(" slow solver: ARKODE_IMEX_MRI_GARK4\n"); + imex_slow = SUNTRUE; + reltol = SUNMAX(hs * hs * hs * hs, 1e-14); + abstol = 1e-14; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (3): + printf(" slow solver: ARKODE_MERK21\n"); + explicit_slow = SUNTRUE; + break; + case (4): + printf(" slow solver: ARKODE_MERK32\n"); + explicit_slow = SUNTRUE; + break; + case (5): + printf(" slow solver: ARKODE_MERK43\n"); + explicit_slow = SUNTRUE; + break; + case (6): + printf(" slow solver: ARKODE_MERK54\n"); + explicit_slow = SUNTRUE; + break; } switch (fast_type) { - case (0): - printf(" fast solver: none\n"); - no_fast = SUNTRUE; - break; - case (3): - printf(" fast solver: erk-3-3\n"); - explicit_fast = SUNTRUE; - break; - case (1): - printf(" fast solver: esdirk-3-3\n"); - implicit_fast = SUNTRUE; - reltol = SUNMAX(hs * hs * hs, 1e-10); - abstol = 1e-11; - printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); - break; - case (4): - printf(" fast solver: erk-4-4\n"); - explicit_fast = SUNTRUE; - break; - case (2): - printf(" fast solver: ARKODE_HEUN_EULER_2_1_2\n"); - explicit_fast = SUNTRUE; - break; - case (5): - printf(" fast solver: ARKODE_DORMAND_PRINCE_7_4_5\n"); - explicit_fast = SUNTRUE; - break; + case (0): + printf(" fast solver: none\n"); + no_fast = SUNTRUE; + break; + case (3): + printf(" fast solver: erk-3-3\n"); + explicit_fast = SUNTRUE; + break; + case (1): + printf(" fast solver: esdirk-3-3\n"); + implicit_fast = SUNTRUE; + reltol = SUNMAX(hs * hs * hs, 1e-10); + abstol = 1e-11; + printf(" reltol = %.2" ESYM ", abstol = %.2" ESYM "\n", reltol, abstol); + break; + case (4): + printf(" fast solver: erk-4-4\n"); + explicit_fast = SUNTRUE; + break; + case (2): + printf(" fast solver: ARKODE_HEUN_EULER_2_1_2\n"); + explicit_fast = SUNTRUE; + break; + case (5): + printf(" fast solver: ARKODE_DORMAND_PRINCE_7_4_5\n"); + explicit_fast = SUNTRUE; + break; } /* Create the SUNDIALS context object for this simulation */ @@ -387,109 +389,111 @@ int main(int argc, char* argv[]) { inner_arkode_mem = ARKStepCreate(NULL, fn, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } - retval = ARKStepSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } - retval = ARKStepSetJacFn(inner_arkode_mem, Jn); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } } else if (implicit_fast && !no_slow) { inner_arkode_mem = ARKStepCreate(NULL, ff, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } - retval = ARKStepSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } - retval = ARKStepSetJacFn(inner_arkode_mem, Jf); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(inner_arkode_mem, Jf); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } } /* Set Butcher table for fast integrator */ switch (fast_type) { - case (0): - case (3): - B = ARKodeButcherTable_Alloc(3, SUNTRUE); - if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - B->A[1][0] = SUN_RCONST(0.5); - B->A[2][0] = -ONE; - B->A[2][1] = TWO; - B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = TWO / SUN_RCONST(3.0); - B->b[2] = ONE / SUN_RCONST(6.0); - B->d[1] = ONE; - B->c[1] = SUN_RCONST(0.5); - B->c[2] = ONE; - B->q = 3; - B->p = 2; - retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - break; - case (1): - B = ARKodeButcherTable_Alloc(3, SUNFALSE); - if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - beta = SUNRsqrt(SUN_RCONST(3.0)) / SUN_RCONST(6.0) + SUN_RCONST(0.5); - gamma = (-ONE / SUN_RCONST(8.0)) * (SUNRsqrt(SUN_RCONST(3.0)) + ONE); - B->A[1][0] = SUN_RCONST(4.0) * gamma + TWO * beta; - B->A[1][1] = ONE - SUN_RCONST(4.0) * gamma - TWO * beta; - B->A[2][0] = SUN_RCONST(0.5) - beta - gamma; - B->A[2][1] = gamma; - B->A[2][2] = beta; - B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = ONE / SUN_RCONST(6.0); - B->b[2] = TWO / SUN_RCONST(3.0); - B->c[1] = ONE; - B->c[2] = SUN_RCONST(0.5); - B->q = 3; - retval = ARKStepSetTables(inner_arkode_mem, 3, 0, B, NULL); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - break; - case (4): - B = ARKodeButcherTable_Alloc(4, SUNFALSE); - if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } - B->A[1][0] = SUN_RCONST(0.5); - B->A[2][1] = SUN_RCONST(0.5); - B->A[3][2] = ONE; - B->b[0] = ONE / SUN_RCONST(6.0); - B->b[1] = ONE / SUN_RCONST(3.0); - B->b[2] = ONE / SUN_RCONST(3.0); - B->b[3] = ONE / SUN_RCONST(6.0); - B->c[1] = SUN_RCONST(0.5); - B->c[2] = SUN_RCONST(0.5); - B->c[3] = ONE; - B->q = 4; - retval = ARKStepSetTables(inner_arkode_mem, 4, 0, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - break; - case (2): - B = ARKodeButcherTable_LoadERK(ARKODE_HEUN_EULER_2_1_2); - if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } - retval = ARKStepSetTables(inner_arkode_mem, 2, 1, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - break; - case (5): - B = ARKodeButcherTable_LoadERK(ARKODE_DORMAND_PRINCE_7_4_5); - if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } - retval = ARKStepSetTables(inner_arkode_mem, 5, 4, NULL, B); - if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } - break; + case (0): + case (3): + B = ARKodeButcherTable_Alloc(3, SUNTRUE); + if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } + B->A[1][0] = SUN_RCONST(0.5); + B->A[2][0] = -ONE; + B->A[2][1] = TWO; + B->b[0] = ONE / SUN_RCONST(6.0); + B->b[1] = TWO / SUN_RCONST(3.0); + B->b[2] = ONE / SUN_RCONST(6.0); + B->d[1] = ONE; + B->c[1] = SUN_RCONST(0.5); + B->c[2] = ONE; + B->q = 3; + B->p = 2; + retval = ARKStepSetTables(inner_arkode_mem, 3, 2, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; + case (1): + B = ARKodeButcherTable_Alloc(3, SUNFALSE); + if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } + beta = SUNRsqrt(SUN_RCONST(3.0)) / SUN_RCONST(6.0) + SUN_RCONST(0.5); + gamma = (-ONE / SUN_RCONST(8.0)) * (SUNRsqrt(SUN_RCONST(3.0)) + ONE); + B->A[1][0] = SUN_RCONST(4.0) * gamma + TWO * beta; + B->A[1][1] = ONE - SUN_RCONST(4.0) * gamma - TWO * beta; + B->A[2][0] = SUN_RCONST(0.5) - beta - gamma; + B->A[2][1] = gamma; + B->A[2][2] = beta; + B->b[0] = ONE / SUN_RCONST(6.0); + B->b[1] = ONE / SUN_RCONST(6.0); + B->b[2] = TWO / SUN_RCONST(3.0); + B->c[1] = ONE; + B->c[2] = SUN_RCONST(0.5); + B->q = 3; + retval = ARKStepSetTables(inner_arkode_mem, 3, 0, B, NULL); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; + case (4): + B = ARKodeButcherTable_Alloc(4, SUNFALSE); + if (check_retval((void*)B, "ARKodeButcherTable_Alloc", 0)) { return 1; } + B->A[1][0] = SUN_RCONST(0.5); + B->A[2][1] = SUN_RCONST(0.5); + B->A[3][2] = ONE; + B->b[0] = ONE / SUN_RCONST(6.0); + B->b[1] = ONE / SUN_RCONST(3.0); + B->b[2] = ONE / SUN_RCONST(3.0); + B->b[3] = ONE / SUN_RCONST(6.0); + B->c[1] = SUN_RCONST(0.5); + B->c[2] = SUN_RCONST(0.5); + B->c[3] = ONE; + B->q = 4; + retval = ARKStepSetTables(inner_arkode_mem, 4, 0, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; + case (2): + B = ARKodeButcherTable_LoadERK(ARKODE_HEUN_EULER_2_1_2); + if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } + retval = ARKStepSetTables(inner_arkode_mem, 2, 1, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; + case (5): + B = ARKodeButcherTable_LoadERK(ARKODE_DORMAND_PRINCE_7_4_5); + if (check_retval((void*)B, "ARKodeButcherTable_LoadERK", 0)) { return 1; } + retval = ARKStepSetTables(inner_arkode_mem, 5, 4, NULL, B); + if (check_retval(&retval, "ARKStepSetTables", 1)) { return 1; } + break; } ARKodeButcherTable_Free(B); /* Set the tolerances */ - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Set the user data pointer */ - retval = ARKStepSetUserData(inner_arkode_mem, (void*)rpar); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(inner_arkode_mem, (void*)rpar); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the fast step size */ - retval = ARKStepSetFixedStep(inner_arkode_mem, hf); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(inner_arkode_mem, hf); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) - { return 1; } + { + return 1; + } /* * Create the slow integrator and set options @@ -526,28 +530,28 @@ int main(int argc, char* argv[]) { arkode_mem = MRIStepCreate(NULL, fs, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } - retval = MRIStepSetJacFn(arkode_mem, Js); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Js); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } } else if (implicit_slow && no_fast) { arkode_mem = MRIStepCreate(NULL, fn, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } - retval = MRIStepSetJacFn(arkode_mem, Jn); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } } else if (imex_slow) { arkode_mem = MRIStepCreate(fse, fsi, T0, y, inner_stepper, ctx); if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } - retval = MRIStepSetJacFn(arkode_mem, Jsi); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jsi); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } } /* Set coupling table for slow integrator */ @@ -631,19 +635,19 @@ int main(int argc, char* argv[]) MRIStepCoupling_Free(C); /* free coupling coefficients */ /* Set the tolerances */ - retval = MRIStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } /* Set the user data pointer */ - retval = MRIStepSetUserData(arkode_mem, (void*)rpar); - if (check_retval(&retval, "MRIStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)rpar); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } - retval = MRIStepSetDeduceImplicitRhs(arkode_mem, deduce); - if (check_retval(&retval, "MRIStepSetDeduceImplicitRhs", 1)) { return 1; } + retval = ARKodeSetDeduceImplicitRhs(arkode_mem, deduce); + if (check_retval(&retval, "ARKodeSetDeduceImplicitRhs", 1)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* * Integrate ODE @@ -660,7 +664,7 @@ int main(int argc, char* argv[]) SUNRabs(NV_Ith_S(y, 0) - utrue(T0, rpar)), SUNRabs(NV_Ith_S(y, 1) - vtrue(T0, rpar))); - /* Main time-stepping loop: calls MRIStepEvolve to perform the + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; @@ -679,8 +683,8 @@ int main(int argc, char* argv[]) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* access/print solution and error */ uerr = SUNRabs(NV_Ith_S(y, 0) - utrue(t, rpar)); @@ -710,14 +714,14 @@ int main(int argc, char* argv[]) */ /* Get some slow integrator statistics */ - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_retval(&retval, "MRIStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_retval(&retval, "MRIStepGetNumRhsEvals", 1); /* Get some fast integrator statistics */ - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_retval(&retval, "ARKStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nff, &tmp); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); @@ -739,12 +743,12 @@ int main(int argc, char* argv[]) else { printf(" Total RHS evals: Fs = %li, Ff = %li\n", nfse, nff); } /* Get/print slow integrator decoupled implicit solver statistics */ - if (implicit_slow || imex_slow ) + if (implicit_slow || imex_slow) { - retval = MRIStepGetNonlinSolvStats(arkode_mem, &nnis, &nncs); - check_retval(&retval, "MRIStepGetNonlinSolvStats", 1); - retval = MRIStepGetNumJacEvals(arkode_mem, &njes); - check_retval(&retval, "MRIStepGetNumJacEvals", 1); + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); + check_retval(&retval, "ARKodeGetNonlinSolvStats", 1); + retval = ARKodeGetNumJacEvals(arkode_mem, &njes); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); printf(" Slow Newton iters = %li\n", nnis); printf(" Slow Newton conv fails = %li\n", nncs); printf(" Slow Jacobian evals = %li\n", njes); @@ -753,10 +757,10 @@ int main(int argc, char* argv[]) /* Get/print fast integrator implicit solver statistics */ if (implicit_fast) { - retval = ARKStepGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); - check_retval(&retval, "ARKStepGetNonlinSolvStats", 1); - retval = ARKStepGetNumJacEvals(inner_arkode_mem, &njef); - check_retval(&retval, "ARKStepGetNumJacEvals", 1); + retval = ARKodeGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); + check_retval(&retval, "ARKodeGetNonlinSolvStats", 1); + retval = ARKodeGetNumJacEvals(inner_arkode_mem, &njef); + check_retval(&retval, "ARKodeGetNumJacEvals", 1); printf(" Fast Newton iters = %li\n", nnif); printf(" Fast Newton conv fails = %li\n", nncf); printf(" Fast Jacobian evals = %li\n", njef); @@ -768,9 +772,9 @@ int main(int argc, char* argv[]) SUNLinSolFree(LSf); /* free fast linear solver */ SUNMatDestroy(As); /* free fast matrix */ SUNLinSolFree(LSs); /* free fast linear solver */ - ARKStepFree(&inner_arkode_mem); /* Free fast integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free fast integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free slow integrator memory */ + ARKodeFree(&arkode_mem); /* Free slow integrator memory */ SUNContext_Free(&ctx); /* Free context */ return 0; @@ -957,7 +961,6 @@ static int Jf(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix J, void* user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) { sunrealtype* rpar = (sunrealtype*)user_data; - const sunrealtype G = rpar[0]; const sunrealtype e = rpar[2]; const sunrealtype u = NV_Ith_S(y, 0); const sunrealtype v = NV_Ith_S(y, 1); diff --git a/examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out b/examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out new file mode 100644 index 0000000000..ce045454c5 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_1_1_0.002.out @@ -0,0 +1,73 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.002 + hf = 2e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MIS_KW3 + fast solver: esdirk-3-3 + reltol = 8.00e-09, abstol = 1.00e-11 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 4.99e-09 6.44e-11 + 0.200000 1.220669 1.551800 4.96e-09 1.43e-10 + 0.300000 1.215594 1.467737 4.90e-09 2.14e-10 + 0.400000 1.208524 1.154583 4.81e-09 2.79e-10 + 0.500000 1.199496 1.721908 4.70e-09 3.33e-10 + 0.600000 1.188557 1.023517 4.57e-09 3.84e-10 + 0.700000 1.175764 1.622751 4.40e-09 4.23e-10 + 0.800000 1.161186 1.374632 4.21e-09 4.58e-10 + 0.900000 1.144904 1.245763 3.98e-09 4.86e-10 + 1.000000 1.127010 1.691839 3.73e-09 5.06e-10 + 1.100000 1.107609 1.000489 3.45e-09 5.20e-10 + 1.200000 1.086821 1.677552 3.13e-09 5.29e-10 + 1.300000 1.064777 1.277775 2.77e-09 5.30e-10 + 1.400000 1.041625 1.342455 2.38e-09 5.25e-10 + 1.500000 1.017531 1.642940 1.94e-09 5.15e-10 + 1.600000 0.992673 1.012112 1.46e-09 4.96e-10 + 1.700000 0.967253 1.714058 9.32e-10 4.72e-10 + 1.800000 0.941488 1.183867 3.54e-10 4.40e-10 + 1.900000 0.915617 1.437465 2.75e-10 4.01e-10 + 2.000000 0.889903 1.577082 9.56e-10 3.55e-10 + 2.100000 0.864625 1.056467 1.69e-09 3.06e-10 + 2.200000 0.840089 1.730920 2.47e-09 2.39e-10 + 2.300000 0.816616 1.101047 3.30e-09 1.74e-10 + 2.400000 0.794546 1.525051 4.15e-09 9.35e-11 + 2.500000 0.774227 1.496993 5.01e-09 9.06e-12 + 2.600000 0.756013 1.126857 5.86e-09 7.92e-11 + 2.700000 0.740246 1.727536 6.67e-09 1.81e-10 + 2.800000 0.727247 1.038393 7.38e-09 2.77e-10 + 2.900000 0.717301 1.600759 7.97e-09 3.85e-10 + 3.000000 0.710636 1.406380 8.40e-09 4.86e-10 + 3.100000 0.707412 1.214353 8.63e-09 5.84e-10 + 3.200000 0.707709 1.704026 8.65e-09 6.81e-10 + 3.300000 0.711520 1.004391 8.46e-09 7.58e-10 + 3.400000 0.718750 1.661225 8.06e-09 8.35e-10 + 3.500000 0.729227 1.310102 7.50e-09 8.89e-10 + 3.600000 0.742712 1.310080 6.80e-09 9.29e-10 + 3.700000 0.758914 1.661237 6.01e-09 9.56e-10 + 3.800000 0.777506 1.004387 5.16e-09 9.59e-10 + 3.900000 0.798144 1.704019 4.29e-09 9.58e-10 + 4.000000 0.820474 1.214374 3.43e-09 9.32e-10 + 4.100000 0.844149 1.406358 2.60e-09 9.00e-10 + 4.200000 0.868832 1.600774 1.81e-09 8.56e-10 + 4.300000 0.894204 1.038382 1.06e-09 7.97e-10 + 4.400000 0.919964 1.727533 3.69e-10 7.42e-10 + 4.500000 0.945834 1.126875 2.71e-10 6.69e-10 + 4.600000 0.971557 1.496974 8.58e-10 6.01e-10 + 4.700000 0.996898 1.525070 1.40e-09 5.27e-10 + 4.800000 1.021641 1.101030 1.88e-09 4.46e-10 + 4.900000 1.045589 1.730922 2.33e-09 3.74e-10 + 5.000000 1.068565 1.056480 2.73e-09 2.91e-10 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 2501, nstf = 252601 + u error = 4.671e-09, v error = 5.637e-10, total error = 3.327e-09 + Total RHS evals: Fs = 7504, Ff = 0 + Fast Newton iters = 653849 + Fast Newton conv fails = 0 + Fast Jacobian evals = 4169 diff --git a/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out new file mode 100644 index 0000000000..f5196d7797 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_3_2_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK21 + fast solver: ARKODE_HEUN_EULER_2_1_2 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 2.66e-08 4.86e-08 + 0.200000 1.220669 1.551800 2.66e-08 1.34e-09 + 0.300000 1.215594 1.467737 2.62e-08 4.29e-09 + 0.400000 1.208524 1.154583 2.58e-08 2.80e-08 + 0.500000 1.199496 1.721908 2.53e-08 1.39e-08 + 0.600000 1.188557 1.023517 2.44e-08 4.48e-08 + 0.700000 1.175764 1.622750 2.37e-08 1.39e-08 + 0.800000 1.161186 1.374632 2.25e-08 9.64e-11 + 0.900000 1.144904 1.245763 2.14e-08 8.43e-09 + 1.000000 1.127010 1.691839 2.01e-08 2.07e-08 + 1.100000 1.107609 1.000490 1.84e-08 4.20e-08 + 1.200000 1.086821 1.677552 1.69e-08 2.25e-08 + 1.300000 1.064777 1.277775 1.48e-08 2.79e-09 + 1.400000 1.041625 1.342455 1.28e-08 4.44e-09 + 1.500000 1.017531 1.642940 1.04e-08 2.19e-08 + 1.600000 0.992673 1.012112 7.76e-09 3.67e-08 + 1.700000 0.967253 1.714058 5.06e-09 2.59e-08 + 1.800000 0.941488 1.183867 1.75e-09 1.13e-08 + 1.900000 0.915617 1.437465 1.44e-09 1.16e-08 + 2.000000 0.889903 1.577082 5.21e-09 1.82e-08 + 2.100000 0.864625 1.056467 9.17e-09 2.94e-08 + 2.200000 0.840089 1.730920 1.33e-08 2.47e-08 + 2.300000 0.816616 1.101047 1.79e-08 2.45e-08 + 2.400000 0.794546 1.525051 2.23e-08 1.36e-08 + 2.500000 0.774228 1.496993 2.71e-08 9.85e-09 + 2.600000 0.756013 1.126857 3.16e-08 2.30e-08 + 2.700000 0.740246 1.727536 3.59e-08 1.92e-08 + 2.800000 0.727247 1.038393 3.99e-08 4.04e-08 + 2.900000 0.717301 1.600759 4.28e-08 1.12e-08 + 3.000000 0.710636 1.406380 4.52e-08 2.44e-09 + 3.100000 0.707413 1.214353 4.63e-08 1.90e-08 + 3.200000 0.707709 1.704026 4.64e-08 1.14e-08 + 3.300000 0.711520 1.004391 4.55e-08 5.32e-08 + 3.400000 0.718750 1.661225 4.31e-08 8.10e-09 + 3.500000 0.729227 1.310102 4.03e-08 1.50e-08 + 3.600000 0.742712 1.310080 3.64e-08 1.43e-08 + 3.700000 0.758914 1.661237 3.21e-08 6.04e-09 + 3.800000 0.777506 1.004387 2.77e-08 5.53e-08 + 3.900000 0.798144 1.704019 2.29e-08 8.68e-09 + 4.000000 0.820474 1.214374 1.85e-08 2.42e-08 + 4.100000 0.844149 1.406358 1.38e-08 6.00e-09 + 4.200000 0.868832 1.600774 9.67e-09 4.99e-09 + 4.300000 0.894204 1.038382 5.70e-09 4.57e-08 + 4.400000 0.919964 1.727533 1.89e-09 1.31e-08 + 4.500000 0.945834 1.126875 1.34e-09 3.06e-08 + 4.600000 0.971557 1.496974 4.69e-09 4.31e-09 + 4.700000 0.996898 1.525070 7.45e-09 5.97e-09 + 4.800000 1.021641 1.101030 1.01e-08 2.99e-08 + 4.900000 1.045589 1.730922 1.25e-08 1.86e-08 + 5.000000 1.068565 1.056480 1.45e-08 3.56e-08 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 750000 + u error = 2.508e-08, v error = 2.443e-08, total error = 2.476e-08 + Total RHS evals: Fs = 10001, Ff = 1500050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out new file mode 100644 index 0000000000..5002013f25 --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_4_3_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK32 + fast solver: erk-3-3 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 8.92e-10 3.75e-11 + 0.200000 1.220669 1.551800 8.86e-10 7.57e-11 + 0.300000 1.215594 1.467737 8.75e-10 1.10e-10 + 0.400000 1.208524 1.154583 8.59e-10 1.40e-10 + 0.500000 1.199496 1.721908 8.39e-10 1.66e-10 + 0.600000 1.188557 1.023517 8.15e-10 1.89e-10 + 0.700000 1.175764 1.622751 7.85e-10 2.09e-10 + 0.800000 1.161186 1.374632 7.50e-10 2.25e-10 + 0.900000 1.144904 1.245763 7.10e-10 2.38e-10 + 1.000000 1.127010 1.691839 6.65e-10 2.47e-10 + 1.100000 1.107609 1.000489 6.13e-10 2.58e-10 + 1.200000 1.086821 1.677552 5.56e-10 2.57e-10 + 1.300000 1.064777 1.277775 4.92e-10 2.59e-10 + 1.400000 1.041625 1.342455 4.21e-10 2.56e-10 + 1.500000 1.017531 1.642940 3.43e-10 2.47e-10 + 1.600000 0.992673 1.012112 2.56e-10 2.42e-10 + 1.700000 0.967253 1.714058 1.61e-10 2.25e-10 + 1.800000 0.941488 1.183867 5.78e-11 2.12e-10 + 1.900000 0.915617 1.437465 5.52e-11 1.90e-10 + 2.000000 0.889903 1.577082 1.78e-10 1.66e-10 + 2.100000 0.864625 1.056467 3.09e-10 1.42e-10 + 2.200000 0.840089 1.730920 4.50e-10 1.07e-10 + 2.300000 0.816616 1.101047 5.97e-10 7.65e-11 + 2.400000 0.794546 1.525051 7.50e-10 3.53e-11 + 2.500000 0.774227 1.496993 9.05e-10 6.53e-12 + 2.600000 0.756013 1.126857 1.06e-09 4.93e-11 + 2.700000 0.740246 1.727536 1.20e-09 1.01e-10 + 2.800000 0.727247 1.038393 1.33e-09 1.46e-10 + 2.900000 0.717301 1.600759 1.43e-09 2.00e-10 + 3.000000 0.710636 1.406380 1.50e-09 2.49e-10 + 3.100000 0.707412 1.214353 1.54e-09 2.95e-10 + 3.200000 0.707709 1.704026 1.55e-09 3.43e-10 + 3.300000 0.711520 1.004391 1.51e-09 3.77e-10 + 3.400000 0.718750 1.661225 1.44e-09 4.14e-10 + 3.500000 0.729227 1.310102 1.33e-09 4.38e-10 + 3.600000 0.742712 1.310080 1.21e-09 4.56e-10 + 3.700000 0.758914 1.661237 1.07e-09 4.68e-10 + 3.800000 0.777506 1.004387 9.14e-10 4.66e-10 + 3.900000 0.798144 1.704019 7.60e-10 4.65e-10 + 4.000000 0.820474 1.214374 6.06e-10 4.50e-10 + 4.100000 0.844149 1.406358 4.58e-10 4.31e-10 + 4.200000 0.868832 1.600774 3.16e-10 4.10e-10 + 4.300000 0.894204 1.038382 1.84e-10 3.81e-10 + 4.400000 0.919964 1.727533 6.02e-11 3.51e-10 + 4.500000 0.945834 1.126875 5.36e-11 3.19e-10 + 4.600000 0.971557 1.496974 1.58e-10 2.82e-10 + 4.700000 0.996898 1.525070 2.54e-10 2.47e-10 + 4.800000 1.021641 1.101030 3.41e-10 2.09e-10 + 4.900000 1.045589 1.730922 4.20e-10 1.72e-10 + 5.000000 1.068565 1.056480 4.91e-10 1.34e-10 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 1085000 + u error = 8.345e-10, v error = 2.743e-10, total error = 6.212e-10 + Total RHS evals: Fs = 15001, Ff = 3255050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out new file mode 100644 index 0000000000..292e3d4c0a --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_5_4_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK43 + fast solver: erk-4-4 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 2.23e-11 1.15e-12 + 0.200000 1.220669 1.551800 2.21e-11 1.92e-12 + 0.300000 1.215594 1.467737 2.19e-11 2.71e-12 + 0.400000 1.208524 1.154583 2.15e-11 3.14e-12 + 0.500000 1.199496 1.721908 2.10e-11 4.37e-12 + 0.600000 1.188557 1.023517 2.03e-11 4.94e-12 + 0.700000 1.175764 1.622751 1.96e-11 5.31e-12 + 0.800000 1.161186 1.374632 1.87e-11 5.82e-12 + 0.900000 1.144904 1.245763 1.77e-11 5.97e-12 + 1.000000 1.127010 1.691839 1.66e-11 6.30e-12 + 1.100000 1.107609 1.000489 1.54e-11 2.00e-12 + 1.200000 1.086821 1.677552 1.43e-11 6.20e-12 + 1.300000 1.064777 1.277775 1.29e-11 6.14e-12 + 1.400000 1.041625 1.342455 1.14e-11 1.56e-12 + 1.500000 1.017531 1.642940 9.78e-12 9.89e-12 + 1.600000 0.992673 1.012112 7.92e-12 4.47e-13 + 1.700000 0.967253 1.714058 5.88e-12 6.46e-12 + 1.800000 0.941488 1.183867 3.60e-12 7.16e-12 + 1.900000 0.915617 1.437465 1.07e-12 2.70e-12 + 2.000000 0.889903 1.577082 1.73e-12 1.16e-11 + 2.100000 0.864625 1.056467 4.78e-12 5.16e-12 + 2.200000 0.840089 1.730920 8.10e-12 6.35e-12 + 2.300000 0.816616 1.101047 1.17e-11 4.17e-12 + 2.400000 0.794546 1.525051 1.54e-11 8.29e-12 + 2.500000 0.774227 1.496993 1.93e-11 1.08e-11 + 2.600000 0.756013 1.126857 2.33e-11 1.42e-11 + 2.700000 0.740246 1.727536 2.71e-11 5.47e-12 + 2.800000 0.727247 1.038393 3.06e-11 3.03e-12 + 2.900000 0.717301 1.600759 3.37e-11 1.40e-11 + 3.000000 0.710636 1.406380 3.62e-11 7.68e-12 + 3.100000 0.707412 1.214353 3.78e-11 2.49e-11 + 3.200000 0.707709 1.704026 3.87e-11 4.61e-12 + 3.300000 0.711520 1.004391 3.87e-11 1.29e-11 + 3.400000 0.718750 1.661225 3.78e-11 1.68e-11 + 3.500000 0.729227 1.310102 3.62e-11 4.71e-12 + 3.600000 0.742712 1.310080 3.40e-11 3.30e-11 + 3.700000 0.758914 1.661237 3.14e-11 6.81e-12 + 3.800000 0.777506 1.004387 2.85e-11 2.15e-11 + 3.900000 0.798144 1.704019 2.55e-11 1.30e-11 + 4.000000 0.820474 1.214374 2.24e-11 4.33e-12 + 4.100000 0.844149 1.406358 1.83e-11 3.43e-11 + 4.200000 0.868832 1.600774 1.43e-11 5.29e-12 + 4.300000 0.894204 1.038382 1.03e-11 2.10e-11 + 4.400000 0.919964 1.727533 6.45e-12 8.06e-12 + 4.500000 0.945834 1.126875 2.75e-12 2.24e-12 + 4.600000 0.971557 1.496974 7.37e-13 1.69e-11 + 4.700000 0.996898 1.525070 4.02e-12 2.17e-13 + 4.800000 1.021641 1.101030 7.08e-12 1.01e-11 + 4.900000 1.045589 1.730922 9.91e-12 4.05e-12 + 5.000000 1.068565 1.056480 1.23e-11 3.61e-12 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 1425000 + u error = 2.136e-11, v error = 1.132e-11, total error = 1.710e-11 + Total RHS evals: Fs = 30001, Ff = 5700050 diff --git a/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out new file mode 100644 index 0000000000..3ea2bad8da --- /dev/null +++ b/examples/arkode/C_serial/ark_kpr_mri_6_5_0.001.out @@ -0,0 +1,69 @@ + +Multirate nonlinear Kvaerno-Prothero-Robinson test problem: + time domain: (0,5] + hs = 0.001 + hf = 1e-05 + G = -100 + w = 100 + e = 0.5 + slow solver: ARKODE_MERK54 + fast solver: ARKODE_DORMAND_PRINCE_7_4_5 + t u v uerr verr + ------------------------------------------------------ + 0.000000 1.224745 1.732051 0.00e+00 0.00e+00 + 0.100000 1.223725 1.077464 4.46e-13 2.08e-13 + 0.200000 1.220669 1.551800 4.42e-13 6.88e-15 + 0.300000 1.215594 1.467737 4.37e-13 7.22e-14 + 0.400000 1.208524 1.154583 4.28e-13 3.99e-13 + 0.500000 1.199496 1.721908 4.18e-13 1.65e-13 + 0.600000 1.188557 1.023517 4.07e-13 1.50e-13 + 0.700000 1.175764 1.622751 3.88e-13 2.86e-14 + 0.800000 1.161186 1.374632 3.73e-13 1.48e-13 + 0.900000 1.144904 1.245763 3.52e-13 3.93e-14 + 1.000000 1.127010 1.691839 3.32e-13 4.77e-14 + 1.100000 1.107609 1.000489 1.33e-13 4.42e-12 + 1.200000 1.086821 1.677552 1.51e-13 2.80e-13 + 1.300000 1.064777 1.277775 4.36e-13 3.47e-13 + 1.400000 1.041625 1.342455 7.76e-13 4.84e-12 + 1.500000 1.017531 1.642940 1.11e-12 3.64e-12 + 1.600000 0.992673 1.012112 1.47e-12 5.55e-12 + 1.700000 0.967253 1.714058 1.84e-12 7.75e-13 + 1.800000 0.941488 1.183867 2.19e-12 1.87e-12 + 1.900000 0.915617 1.437465 2.55e-12 7.48e-12 + 2.000000 0.889903 1.577082 2.86e-12 7.44e-12 + 2.100000 0.864625 1.056467 3.16e-12 8.63e-12 + 2.200000 0.840089 1.730920 3.42e-12 3.66e-12 + 2.300000 0.816616 1.101047 3.60e-12 2.38e-12 + 2.400000 0.794546 1.525051 3.74e-12 9.12e-12 + 2.500000 0.774227 1.496993 3.76e-12 1.11e-11 + 2.600000 0.756013 1.126857 3.70e-12 1.28e-11 + 2.700000 0.740246 1.727536 3.52e-12 8.05e-12 + 2.800000 0.727247 1.038393 3.21e-12 7.73e-13 + 2.900000 0.717301 1.600759 2.79e-12 8.96e-12 + 3.000000 0.710636 1.406380 2.21e-12 1.40e-11 + 3.100000 0.707412 1.214353 1.52e-12 1.74e-11 + 3.200000 0.707709 1.704026 7.13e-13 1.33e-11 + 3.300000 0.711520 1.004391 2.00e-13 3.30e-12 + 3.400000 0.718750 1.661225 1.16e-12 6.43e-12 + 3.500000 0.729227 1.310102 2.19e-12 1.58e-11 + 3.600000 0.742712 1.310080 3.21e-12 2.14e-11 + 3.700000 0.758914 1.661237 4.24e-12 1.86e-11 + 3.800000 0.777506 1.004387 5.23e-12 9.68e-12 + 3.900000 0.798144 1.704019 6.15e-12 1.34e-12 + 4.000000 0.820474 1.214374 7.00e-12 1.57e-11 + 4.100000 0.844149 1.406358 6.74e-12 2.33e-11 + 4.200000 0.868832 1.600774 6.28e-12 1.56e-11 + 4.300000 0.894204 1.038382 5.68e-12 1.13e-11 + 4.400000 0.919964 1.727533 4.97e-12 7.79e-13 + 4.500000 0.945834 1.126875 4.19e-12 5.77e-12 + 4.600000 0.971557 1.496974 3.36e-12 9.76e-12 + 4.700000 0.996898 1.525070 2.51e-12 6.00e-12 + 4.800000 1.021641 1.101030 1.67e-12 4.81e-12 + 4.900000 1.045589 1.730922 8.58e-13 2.44e-13 + 5.000000 1.068565 1.056480 2.51e-13 2.92e-13 + ------------------------------------------------------ + +Final Solver Statistics: + Steps: nsts = 5000, nstf = 1615000 + u error = 3.075e-12, v error = 8.987e-12, total error = 6.716e-12 + Total RHS evals: Fs = 50051, Ff = 9715100 diff --git a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001.out b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001.out index 4c33420292..c6e6142daf 100644 --- a/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001.out +++ b/examples/arkode/C_serial/ark_kpr_mri_8_3_0.001.out @@ -67,7 +67,7 @@ Multirate nonlinear Kvaerno-Prothero-Robinson test problem: Final Solver Statistics: Steps: nsts = 5000, nstf = 510000 u error = 3.803e-10, v error = 3.943e-10, total error = 3.874e-10 - Total RHS evals: Fs = 45313, Ff = 1530050 + Total RHS evals: Fs = 50313, Ff = 1530050 Slow Newton iters = 30312 Slow Newton conv fails = 0 Slow Jacobian evals = 250 diff --git a/examples/arkode/C_serial/ark_onewaycouple_mri.c b/examples/arkode/C_serial/ark_onewaycouple_mri.c index a0842f2736..d6993383fe 100644 --- a/examples/arkode/C_serial/ark_onewaycouple_mri.c +++ b/examples/arkode/C_serial/ark_onewaycouple_mri.c @@ -144,8 +144,8 @@ int main(void) if (check_retval(&retval, "ARKStepSetTableNum", 1)) { return 1; } /* Set the fast step size */ - retval = ARKStepSetFixedStep(inner_arkode_mem, hf); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(inner_arkode_mem, hf); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -165,8 +165,8 @@ int main(void) if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* * Integrate ODE @@ -181,7 +181,7 @@ int main(void) " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2), error); - /* Main time-stepping loop: calls MRIStepEvolve to perform the + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; @@ -195,8 +195,8 @@ int main(void) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* compute the analytic solution */ retval = ans(t, ytrue, NULL); @@ -226,14 +226,14 @@ int main(void) */ /* Get some slow integrator statistics */ - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_retval(&retval, "MRIStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_retval(&retval, "MRIStepGetNumRhsEvals", 1); /* Get some fast integrator statistics */ - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_retval(&retval, "ARKStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nff, &tmp); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); @@ -245,9 +245,9 @@ int main(void) /* Clean up and return */ N_VDestroy(y); /* Free y vector */ N_VDestroy(ytrue); /* Free ytrue vector */ - ARKStepFree(&inner_arkode_mem); /* Free integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ SUNContext_Free(&ctx); /* Free context */ return 0; diff --git a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c index b11cc23b61..65a4ca73bf 100644 --- a/examples/arkode/C_serial/ark_reaction_diffusion_mri.c +++ b/examples/arkode/C_serial/ark_reaction_diffusion_mri.c @@ -145,16 +145,16 @@ int main(void) if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Attach user data to fast integrator */ - retval = ARKStepSetUserData(inner_arkode_mem, (void*)udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(inner_arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the fast method */ retval = ARKStepSetTableNum(inner_arkode_mem, -1, ARKODE_KNOTH_WOLKE_3_3); if (check_retval(&retval, "ARKStepSetTableNum", 1)) { return 1; } /* Set the fast step size */ - retval = ARKStepSetFixedStep(inner_arkode_mem, hf); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(inner_arkode_mem, hf); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -174,16 +174,16 @@ int main(void) if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } /* Pass udata to user functions */ - retval = MRIStepSetUserData(arkode_mem, (void*)udata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) { return 1; } + retval = ARKodeSetUserData(arkode_mem, (void*)udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Increase max num steps */ - retval = MRIStepSetMaxNumSteps(arkode_mem, 10000); - if (check_retval(&retval, "MRIStepSetMaxNumSteps", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 10000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* * Integrate ODE @@ -202,7 +202,7 @@ int main(void) for (i = 0; i < N; i++) { fprintf(UFID, " %.16" ESYM "", data[i]); } fprintf(UFID, "\n"); - /* Main time-stepping loop: calls MRIStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; dTout = (Tf - T0) / Nt; @@ -213,8 +213,8 @@ int main(void) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* print solution stats and output results to disk */ printf(" %10.6" FSYM " %10.6f\n", t, sqrt(N_VDotProd(y, y) / N)); @@ -230,23 +230,23 @@ int main(void) /* Print final statistics to the screen */ printf("\nFinal Slow Statistics:\n"); - retval = MRIStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + retval = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); printf("\nFinal Fast Statistics:\n"); - retval = ARKStepPrintAllStats(inner_arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + retval = ARKodePrintAllStats(inner_arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); /* Print final statistics to a file in CSV format */ FID = fopen("ark_reaction_diffusion_mri_slow_stats.csv", "w"); - retval = MRIStepPrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); + retval = ARKodePrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); fclose(FID); FID = fopen("ark_reaction_diffusion_mri_fast_stats.csv", "w"); - retval = ARKStepPrintAllStats(inner_arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); + retval = ARKodePrintAllStats(inner_arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); fclose(FID); /* Clean up and return */ N_VDestroy(y); /* Free y vector */ - ARKStepFree(&inner_arkode_mem); /* Free integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ free(udata); /* Free user data */ SUNContext_Free(&ctx); /* Free context */ diff --git a/examples/arkode/C_serial/ark_robertson.c b/examples/arkode/C_serial/ark_robertson.c index b4e47e214d..833861243d 100644 --- a/examples/arkode/C_serial/ark_robertson.c +++ b/examples/arkode/C_serial/ark_robertson.c @@ -117,23 +117,23 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetInitStep(arkode_mem, h0); /* Set custom initial step */ - if (check_flag(&flag, "ARKStepSetInitStep", 1)) { return 1; } - flag = ARKStepSetMaxErrTestFails(arkode_mem, - 20); /* Increase max error test fails */ - if (check_flag(&flag, "ARKStepSetMaxErrTestFails", 1)) { return 1; } - flag = ARKStepSetMaxNonlinIters(arkode_mem, 8); /* Increase max nonlin iters */ - if (check_flag(&flag, "ARKStepSetMaxNonlinIters", 1)) { return 1; } - flag = ARKStepSetNonlinConvCoef(arkode_mem, - SUN_RCONST(1.e-7)); /* Set nonlinear convergence coeff. */ - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 100000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, - 1); /* Specify maximum-order predictor */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetInitStep(arkode_mem, h0); /* Set custom initial step */ + if (check_flag(&flag, "ARKodeSetInitStep", 1)) { return 1; } + flag = ARKodeSetMaxErrTestFails(arkode_mem, + 20); /* Increase max error test fails */ + if (check_flag(&flag, "ARKodeSetMaxErrTestFails", 1)) { return 1; } + flag = ARKodeSetMaxNonlinIters(arkode_mem, 8); /* Increase max nonlin iters */ + if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkode_mem, + SUN_RCONST(1.e-7)); /* Set nonlinear convergence coeff. */ + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 100000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, + 1); /* Specify maximum-order predictor */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Initialize dense matrix data structure and solver */ A = SUNDenseMatrix(NEQ, NEQ, ctx); @@ -142,11 +142,11 @@ int main(void) if (check_flag((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -156,7 +156,7 @@ int main(void) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -166,8 +166,8 @@ int main(void) NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.3" ESYM " %12.5" ESYM " %12.5" ESYM " %12.5" ESYM "\n", /* access/print solution */ t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); @@ -189,22 +189,22 @@ int main(void) /* Print final statistics to the screen */ printf("\nFinal Statistics:\n"); - flag = ARKStepPrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); + flag = ARKodePrintAllStats(arkode_mem, stdout, SUN_OUTPUTFORMAT_TABLE); /* Print final statistics to a file in CSV format */ FID = fopen("ark_robertson_stats.csv", "w"); - flag = ARKStepPrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); + flag = ARKodePrintAllStats(arkode_mem, FID, SUN_OUTPUTFORMAT_CSV); fclose(FID); /* check the solution error */ flag = check_ans(y, t, reltol, abstol); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free y vector */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return flag; } diff --git a/examples/arkode/C_serial/ark_robertson_constraints.c b/examples/arkode/C_serial/ark_robertson_constraints.c index 43b4718ebc..8c247dbf28 100644 --- a/examples/arkode/C_serial/ark_robertson_constraints.c +++ b/examples/arkode/C_serial/ark_robertson_constraints.c @@ -127,25 +127,25 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetInitStep(arkode_mem, h0); /* Set custom initial step */ - if (check_flag(&flag, "ARKStepSetInitStep", 1)) { return 1; } - flag = ARKStepSetMaxErrTestFails(arkode_mem, - 20); /* Increase max error test fails */ - if (check_flag(&flag, "ARKStepSetMaxErrTestFails", 1)) { return 1; } - flag = ARKStepSetMaxNonlinIters(arkode_mem, 8); /* Increase max nonlin iters */ - if (check_flag(&flag, "ARKStepSetMaxNonlinIters", 1)) { return 1; } - flag = ARKStepSetNonlinConvCoef(arkode_mem, - SUN_RCONST(1.e-7)); /* Set nonlinear convergence coeff. */ - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 100000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, - 1); /* Specify maximum-order predictor */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } - flag = ARKStepSetConstraints(arkode_mem, constraints); /* Set constraints */ - if (check_flag(&flag, "ARKStepSetConstraints", 1)) { return 1; } + flag = ARKodeSetInitStep(arkode_mem, h0); /* Set custom initial step */ + if (check_flag(&flag, "ARKodeSetInitStep", 1)) { return 1; } + flag = ARKodeSetMaxErrTestFails(arkode_mem, + 20); /* Increase max error test fails */ + if (check_flag(&flag, "ARKodeSetMaxErrTestFails", 1)) { return 1; } + flag = ARKodeSetMaxNonlinIters(arkode_mem, 8); /* Increase max nonlin iters */ + if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkode_mem, + SUN_RCONST(1.e-7)); /* Set nonlinear convergence coeff. */ + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 100000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, + 1); /* Specify maximum-order predictor */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetConstraints(arkode_mem, constraints); /* Set constraints */ + if (check_flag(&flag, "ARKodeSetConstraints", 1)) { return 1; } /* Initialize dense matrix data structure and solver */ A = SUNDenseMatrix(NEQ, NEQ, ctx); @@ -154,11 +154,11 @@ int main(void) if (check_flag((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -168,7 +168,7 @@ int main(void) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; tout = T0 + dTout; @@ -178,8 +178,8 @@ int main(void) NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); for (iout = 0; iout < Nt; iout++) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %10.3" ESYM " %12.5" ESYM " %12.5" ESYM " %12.5" ESYM "\n", /* access/print solution */ t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); @@ -200,28 +200,28 @@ int main(void) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumStepSolveFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumStepSolveFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &nnf); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); - flag = ARKStepGetNumConstrFails(arkode_mem, &nctf); - check_flag(&flag, "ARKStepGetNumConstrFails", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumStepSolveFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumStepSolveFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &nnf); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); + flag = ARKodeGetNumConstrFails(arkode_mem, &nctf); + check_flag(&flag, "ARKodeGetNumConstrFails", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -239,12 +239,12 @@ int main(void) flag = check_ans(y, t, reltol, abstol); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free y vector */ - N_VDestroy(constraints); /* Free constraints vector */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + N_VDestroy(constraints); /* Free constraints vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return flag; } diff --git a/examples/arkode/C_serial/ark_robertson_root.c b/examples/arkode/C_serial/ark_robertson_root.c index be0782279c..a4aa8fb066 100644 --- a/examples/arkode/C_serial/ark_robertson_root.c +++ b/examples/arkode/C_serial/ark_robertson_root.c @@ -129,25 +129,25 @@ int main(void) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Set routines */ - flag = ARKStepSetMaxErrTestFails(arkode_mem, - 20); /* Increase max error test fails */ - if (check_flag(&flag, "ARKStepSetMaxErrTestFails", 1)) { return 1; } - flag = ARKStepSetMaxNonlinIters(arkode_mem, 8); /* Increase max nonlin iters */ - if (check_flag(&flag, "ARKStepSetMaxNonlinIters", 1)) { return 1; } - flag = ARKStepSetNonlinConvCoef(arkode_mem, - SUN_RCONST(1.e-7)); /* Set nonlinear convergence coeff. */ - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkode_mem, 100000); /* Increase max num steps */ - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - flag = ARKStepSetPredictorMethod(arkode_mem, - 1); /* Specify maximum-order predictor */ - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } - flag = ARKStepSVtolerances(arkode_mem, reltol, atols); /* Specify tolerances */ - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSetMaxErrTestFails(arkode_mem, + 20); /* Increase max error test fails */ + if (check_flag(&flag, "ARKodeSetMaxErrTestFails", 1)) { return 1; } + flag = ARKodeSetMaxNonlinIters(arkode_mem, 8); /* Increase max nonlin iters */ + if (check_flag(&flag, "ARKodeSetMaxNonlinIters", 1)) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkode_mem, + SUN_RCONST(1.e-7)); /* Set nonlinear convergence coeff. */ + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 100000); /* Increase max num steps */ + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkode_mem, + 1); /* Specify maximum-order predictor */ + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSVtolerances(arkode_mem, reltol, atols); /* Specify tolerances */ + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Specify the root-finding function, having 2 equations */ - flag = ARKStepRootInit(arkode_mem, 2, g); - if (check_flag(&flag, "ARKStepRootInit", 1)) { return 1; } + flag = ARKodeRootInit(arkode_mem, 2, g); + if (check_flag(&flag, "ARKodeRootInit", 1)) { return 1; } /* Initialize dense matrix data structure and solver */ A = SUNDenseMatrix(NEQ, NEQ, ctx); @@ -156,11 +156,11 @@ int main(void) if (check_flag((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } /* Linear solver interface */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, - A); /* Attach matrix and linear solver */ - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, + A); /* Attach matrix and linear solver */ + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); /* Set the Jacobian routine */ + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Open output stream for results, output comment line */ UFID = fopen("solution.txt", "w"); @@ -170,7 +170,7 @@ int main(void) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls ARKStepEvolve to perform the integration, then + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; printf(" t u v w\n"); @@ -181,8 +181,8 @@ int main(void) iout = 0; while (1) { - flag = ARKStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ - if (check_flag(&flag, "ARKStepEvolve", 1)) { break; } + flag = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); /* call integrator */ + if (check_flag(&flag, "ARKodeEvolve", 1)) { break; } printf(" %12.5" ESYM " %12.5" ESYM " %12.5" ESYM " %12.5" ESYM "\n", /* access/print solution */ t, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); @@ -190,8 +190,8 @@ int main(void) NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); if (flag == ARK_ROOT_RETURN) { /* check if a root was found */ - rtflag = ARKStepGetRootInfo(arkode_mem, rootsfound); - if (check_flag(&rtflag, "ARKStepGetRootInfo", 1)) { return 1; } + rtflag = ARKodeGetRootInfo(arkode_mem, rootsfound); + if (check_flag(&rtflag, "ARKodeGetRootInfo", 1)) { return 1; } printf(" rootsfound[] = %3d %3d\n", rootsfound[0], rootsfound[1]); } if (flag >= 0) @@ -210,28 +210,28 @@ int main(void) fclose(UFID); /* Print some final statistics */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); flag = ARKStepGetNumRhsEvals(arkode_mem, &nfe, &nfi); check_flag(&flag, "ARKStepGetNumRhsEvals", 1); - flag = ARKStepGetNumLinSolvSetups(arkode_mem, &nsetups); - check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1); - flag = ARKStepGetNumErrTestFails(arkode_mem, &netf); - check_flag(&flag, "ARKStepGetNumErrTestFails", 1); - flag = ARKStepGetNumStepSolveFails(arkode_mem, &ncfn); - check_flag(&flag, "ARKStepGetNumStepSolveFails", 1); - flag = ARKStepGetNumNonlinSolvIters(arkode_mem, &nni); - check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1); - flag = ARKStepGetNumNonlinSolvConvFails(arkode_mem, &nnf); - check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1); - flag = ARKStepGetNumJacEvals(arkode_mem, &nje); - check_flag(&flag, "ARKStepGetNumJacEvals", 1); - flag = ARKStepGetNumLinRhsEvals(arkode_mem, &nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); - flag = ARKStepGetNumGEvals(arkode_mem, &nge); - check_flag(&flag, "ARKStepGetNumGEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkode_mem, &nsetups); + check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1); + flag = ARKodeGetNumErrTestFails(arkode_mem, &netf); + check_flag(&flag, "ARKodeGetNumErrTestFails", 1); + flag = ARKodeGetNumStepSolveFails(arkode_mem, &ncfn); + check_flag(&flag, "ARKodeGetNumStepSolveFails", 1); + flag = ARKodeGetNumNonlinSolvIters(arkode_mem, &nni); + check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1); + flag = ARKodeGetNumNonlinSolvConvFails(arkode_mem, &nnf); + check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1); + flag = ARKodeGetNumJacEvals(arkode_mem, &nje); + check_flag(&flag, "ARKodeGetNumJacEvals", 1); + flag = ARKodeGetNumLinRhsEvals(arkode_mem, &nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); + flag = ARKodeGetNumGEvals(arkode_mem, &nge); + check_flag(&flag, "ARKodeGetNumGEvals", 1); printf("\nFinal Solver Statistics:\n"); printf(" Internal solver steps = %li (attempted = %li)\n", nst, nst_a); @@ -246,12 +246,12 @@ int main(void) printf(" Total number of failed steps from solver failure = %li\n", ncfn); /* Clean up and return with successful completion */ - N_VDestroy(y); /* Free y vector */ - N_VDestroy(atols); /* Free atols vector */ - ARKStepFree(&arkode_mem); /* Free integrator memory */ - SUNLinSolFree(LS); /* Free linear solver */ - SUNMatDestroy(A); /* Free A matrix */ - SUNContext_Free(&ctx); /* Free context */ + N_VDestroy(y); /* Free y vector */ + N_VDestroy(atols); /* Free atols vector */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ + SUNLinSolFree(LS); /* Free linear solver */ + SUNMatDestroy(A); /* Free A matrix */ + SUNContext_Free(&ctx); /* Free context */ return 0; } diff --git a/examples/arkode/C_serial/ark_twowaycouple_mri.c b/examples/arkode/C_serial/ark_twowaycouple_mri.c index ec05170aec..d44204d38f 100644 --- a/examples/arkode/C_serial/ark_twowaycouple_mri.c +++ b/examples/arkode/C_serial/ark_twowaycouple_mri.c @@ -123,8 +123,8 @@ int main(void) if (check_retval(&retval, "ARKStepSetTableNum", 1)) { return 1; } /* Set the fast step size */ - retval = ARKStepSetFixedStep(inner_arkode_mem, hf); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(inner_arkode_mem, hf); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* Create inner stepper */ retval = ARKStepCreateMRIStepInnerStepper(inner_arkode_mem, &inner_stepper); @@ -144,8 +144,8 @@ int main(void) if (check_retval((void*)arkode_mem, "MRIStepCreate", 0)) { return 1; } /* Set the slow step size */ - retval = MRIStepSetFixedStep(arkode_mem, hs); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) { return 1; } + retval = ARKodeSetFixedStep(arkode_mem, hs); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) { return 1; } /* * Integrate ODE @@ -159,7 +159,7 @@ int main(void) fprintf(UFID, " %.16" ESYM " %.16" ESYM " %.16" ESYM " %.16" ESYM "\n", T0, NV_Ith_S(y, 0), NV_Ith_S(y, 1), NV_Ith_S(y, 2)); - /* Main time-stepping loop: calls MRIStepEvolve to perform the + /* Main time-stepping loop: calls ARKodeEvolve to perform the integration, then prints results. Stops when the final time has been reached */ t = T0; @@ -172,8 +172,8 @@ int main(void) for (iout = 0; iout < Nt; iout++) { /* call integrator */ - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { break; } + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { break; } /* access/print solution and error */ printf(" %10.6" FSYM " %10.6" FSYM " %10.6" FSYM " %10.6" FSYM "\n", t, @@ -193,14 +193,14 @@ int main(void) */ /* Get some slow integrator statistics */ - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_retval(&retval, "MRIStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_retval(&retval, "MRIStepGetNumRhsEvals", 1); /* Get some fast integrator statistics */ - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_retval(&retval, "ARKStepGetNumSteps", 1); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_retval(&retval, "ARKodeGetNumSteps", 1); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nff, &tmp); check_retval(&retval, "ARKStepGetNumRhsEvals", 1); @@ -211,9 +211,9 @@ int main(void) /* Clean up and return */ N_VDestroy(y); /* Free y vector */ - ARKStepFree(&inner_arkode_mem); /* Free integrator memory */ + ARKodeFree(&inner_arkode_mem); /* Free integrator memory */ MRIStepInnerStepper_Free(&inner_stepper); /* Free inner stepper */ - MRIStepFree(&arkode_mem); /* Free integrator memory */ + ARKodeFree(&arkode_mem); /* Free integrator memory */ SUNContext_Free(&ctx); /* Free context */ return 0; diff --git a/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 b/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 index fc1e3c3c5d..4a0a8a5911 100644 --- a/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 +++ b/examples/arkode/F2003_custom/ark_analytic_complex_f2003.f90 @@ -167,7 +167,7 @@ program main stop 1 end if - ! main time-stepping loop: calls FARKStepEvolve to perform the integration, then + ! main time-stepping loop: calls FARKodeEvolve to perform the integration, then ! prints results. Stops when the final time has been reached tcur(1) = T0 dTout = (Tf-T0)/Nt @@ -181,9 +181,9 @@ program main do iout = 1,Nt ! call integrator - ierr = FARKStepEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) + ierr = FARKodeEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) if (ierr /= 0) then - write(*,*) 'Error in FARKStepEvolve, ierr = ', ierr, '; halting' + write(*,*) 'Error in FARKodeEvolve, ierr = ', ierr, '; halting' stop 1 endif @@ -208,7 +208,7 @@ program main print *, ' ' ! clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) call FN_VDestroy(sunvec_y) ierr = FSUNContext_Free(sunctx) @@ -241,10 +241,10 @@ subroutine ARKStepStats(arkode_mem) !======= Internals ============ - ierr = FARKStepGetNumSteps(arkode_mem, nsteps) - ierr = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + ierr = FARKodeGetNumSteps(arkode_mem, nsteps) + ierr = FARKodeGetNumStepAttempts(arkode_mem, nst_a) ierr = FARKStepGetNumRhsEvals(arkode_mem, nfe, nfi) - ierr = FARKStepGetNumErrTestFails(arkode_mem, netfails) + ierr = FARKodeGetNumErrTestFails(arkode_mem, netfails) print *, ' ' print *, 'Final Solver Statistics:' diff --git a/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 b/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 index 86a7d97447..579d70479c 100644 --- a/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 +++ b/examples/arkode/F2003_custom/ark_brusselator1D_f2003.f90 @@ -328,13 +328,13 @@ program main end if ! set routines - ierr = FARKStepSStolerances(arkode_mem, reltol, abstol) + ierr = FARKodeSStolerances(arkode_mem, reltol, abstol) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSStolerances' + write(*,*) 'Error in FARKodeSStolerances' stop 1 end if - ! initialize custom matrix data structure and solver; attach to ARKStep + ! initialize custom matrix data structure and solver; attach to ARKODE sunmat_A => FSUNMatNew_Fortran(Nvar, N, sunctx) if (.not. associated(sunmat_A)) then print *,'ERROR: sunmat = NULL' @@ -348,19 +348,19 @@ program main end if ! Attach matrix, linear solver, and Jacobian routine to linear solver interface - ierr = FARKStepSetLinearSolver(arkode_mem, sunls, sunmat_A) + ierr = FARKodeSetLinearSolver(arkode_mem, sunls, sunmat_A) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSetLinearSolver' + write(*,*) 'Error in FARKodeSetLinearSolver' stop 1 end if - ierr = FARKStepSetJacFn(arkode_mem, c_funloc(JacFn)) + ierr = FARKodeSetJacFn(arkode_mem, c_funloc(JacFn)) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSetJacFn' + write(*,*) 'Error in FARKodeSetJacFn' stop 1 end if - ! main time-stepping loop: calls FARKStepEvolve to perform the integration, then + ! main time-stepping loop: calls FARKodeEvolve to perform the integration, then ! prints results. Stops when the final time has been reached tcur(1) = T0 dTout = (Tf-T0)/Nt @@ -370,9 +370,9 @@ program main do iout = 1,Nt ! call integrator - ierr = FARKStepEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) + ierr = FARKodeEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) if (ierr /= 0) then - write(*,*) 'Error in FARKStepEvolve, ierr = ', ierr, '; halting' + write(*,*) 'Error in FARKodeEvolve, ierr = ', ierr, '; halting' stop 1 endif @@ -390,7 +390,7 @@ program main call ARKStepStats(arkode_mem) ! clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) call FN_VDestroy(sunvec_y) call FSUNMatDestroy(sunmat_A) ierr = FSUNLinSolFree(sunls) @@ -432,16 +432,16 @@ subroutine ARKStepStats(arkode_mem) !======= Internals ============ - ierr = FARKStepGetNumSteps(arkode_mem, nsteps) - ierr = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + ierr = FARKodeGetNumSteps(arkode_mem, nsteps) + ierr = FARKodeGetNumStepAttempts(arkode_mem, nst_a) ierr = FARKStepGetNumRhsEvals(arkode_mem, nfe, nfi) - ierr = FARKStepGetNumLinRhsEvals(arkode_mem, nfeLS) - ierr = FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) - ierr = FARKStepGetNumJacEvals(arkode_mem, nje) - ierr = FARKStepGetNumErrTestFails(arkode_mem, netfails) - ierr = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) - ierr = FARKStepGetNumNonlinSolvConvFails(arkode_mem, nncfails) - ierr = FARKStepGetNumJacEvals(arkode_mem, njacevals) + ierr = FARKodeGetNumLinRhsEvals(arkode_mem, nfeLS) + ierr = FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) + ierr = FARKodeGetNumJacEvals(arkode_mem, nje) + ierr = FARKodeGetNumErrTestFails(arkode_mem, netfails) + ierr = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) + ierr = FARKodeGetNumNonlinSolvConvFails(arkode_mem, nncfails) + ierr = FARKodeGetNumJacEvals(arkode_mem, njacevals) print *, ' ' print *, 'Final Solver Statistics:' diff --git a/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 b/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 index 5e83ff44c7..cc1e51b503 100644 --- a/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_brusselator1D_task_local_nls_f2003.f90 @@ -545,9 +545,9 @@ integer(c_int) function TaskLocalNlsResidual(sunvec_zcor, sunvec_F, arkode_mem) !======= Inclusions =========== use, intrinsic :: iso_c_binding + use farkode_mod use farkode_arkstep_mod - use ode_mod, only : Neq, Reaction !======= Declarations ========= @@ -585,10 +585,10 @@ integer(c_int) function TaskLocalNlsResidual(sunvec_zcor, sunvec_F, arkode_mem) !======= Internals ============ ! get nonlinear residual data - ierr = FARKStepGetNonlinearSystemData(arkmem, tcur, zpred_ptr, z_ptr, & + ierr = FARKodeGetNonlinearSystemData(arkmem, tcur, zpred_ptr, z_ptr, & Fi_ptr, gam, sdata_ptr, user_data) if (ierr /= 0) then - print *, "Error: FARKStepGetNonlinearSystemData returned ",ierr + print *, "Error: FARKodeGetNonlinearSystemData returned ",ierr return end if @@ -639,12 +639,10 @@ integer(c_int) function TaskLocalLSolve(sunvec_delta, arkode_mem) & !======= Inclusions =========== use, intrinsic :: iso_c_binding + use farkode_mod use farkode_arkstep_mod - - use fsunmatrix_dense_mod - use ode_mod, only : Nvar, Npts, k2, k3, k4, k6 !======= Declarations ========= @@ -674,10 +672,10 @@ integer(c_int) function TaskLocalLSolve(sunvec_delta, arkode_mem) & !======= Internals ============ ! get nonlinear residual data - ierr = FARKStepGetNonlinearSystemData(arkmem, tcur, zpred_ptr, z_ptr, & + ierr = FARKodeGetNonlinearSystemData(arkmem, tcur, zpred_ptr, z_ptr, & Fi_ptr, gam, sdata_ptr, user_data) if (ierr /= 0) then - print *, "Error: FARKStepGetNonlinearSystemData returned ",ierr + print *, "Error: FARKodeGetNonlinearSystemData returned ",ierr return end if @@ -1239,23 +1237,23 @@ subroutine EvolveProblemIMEX(sunvec_y) end if ! Select the method order - retval = FARKStepSetOrder(arkode_mem, order) + retval = FARKodeSetOrder(arkode_mem, order) if (retval /= 0) then - print *, "Error: FARKStepSetOrder returned ",retval + print *, "Error: FARKodeSetOrder returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Specify tolerances - retval = FARKStepSStolerances(arkode_mem, rtol, atol) + retval = FARKodeSStolerances(arkode_mem, rtol, atol) if (retval /= 0) then - print *, "Error: FARKStepSStolerances returned ",retval + print *, "Error: FARKodeSStolerances returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Increase the max number of steps allowed between outputs - retval = FARKStepSetMaxNumSteps(arkode_mem, int(100000, c_long)) + retval = FARKodeSetMaxNumSteps(arkode_mem, int(100000, c_long)) if (retval /= 0) then - print *, "Error: FARKStepMaxNumSteps returned ",retval + print *, "Error: FARKodeMaxNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1270,9 +1268,9 @@ subroutine EvolveProblemIMEX(sunvec_y) end if ! Attach nonlinear solver - retval = FARKStepSetNonlinearSolver(arkode_mem, sun_NLS) + retval = FARKodeSetNonlinearSolver(arkode_mem, sun_NLS) if (retval /= 0) then - print *, "Error: FARKStepSetNonlinearSolver returned ",retval + print *, "Error: FARKodeSetNonlinearSolver returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1285,17 +1283,17 @@ subroutine EvolveProblemIMEX(sunvec_y) ! Attach linear solver sunmat_A => null() - retval = FARKStepSetLinearSolver(arkode_mem, sun_LS, sunmat_A) + retval = FARKodeSetLinearSolver(arkode_mem, sun_LS, sunmat_A) if (retval /= 0) then - print *, "Error: FARKStepSetLinearSolver returned ",retval + print *, "Error: FARKodeSetLinearSolver returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Attach preconditioner - retval = FARKStepSetPreconditioner(arkode_mem, c_funloc(PSetup), & + retval = FARKodeSetPreconditioner(arkode_mem, c_funloc(PSetup), & c_funloc(PSolve)) if (retval /= 0) then - print *, "Error: FARKStepSetPreconditioner returned ",retval + print *, "Error: FARKodeSetPreconditioner returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1314,9 +1312,9 @@ subroutine EvolveProblemIMEX(sunvec_y) end if ! Attach nonlinear solver - retval = FARKStepSetNonlinearSolver(arkode_mem, sun_NLS) + retval = FARKodeSetNonlinearSolver(arkode_mem, sun_NLS) if (retval /= 0) then - print *, "Error: FARKStepSetNonlinearSolver returned ",retval + print *, "Error: FARKodeSetNonlinearSolver returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1343,9 +1341,9 @@ subroutine EvolveProblemIMEX(sunvec_y) do while (iout < max(nout,1)) ! Integrate to output time - retval = FARKStepEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) if (retval /= 0) then - print *, "Error: FARKStepEvolve returned ",retval + print *, "Error: FARKodeEvolve returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1369,15 +1367,15 @@ subroutine EvolveProblemIMEX(sunvec_y) end if ! Get final statistics - retval = FARKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FARKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FARKStepGetNumStepAttempts returned ",retval + print *, "Error: FARKodeGetNumStepAttempts returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1387,41 +1385,41 @@ subroutine EvolveProblemIMEX(sunvec_y) call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumErrTestFails(arkode_mem, netf) + retval = FARKodeGetNumErrTestFails(arkode_mem, netf) if (retval /= 0) then - print *, "Error: FARKStepGetNumErrTestFails returned ",retval + print *, "Error: FARKodeGetNumErrTestFails returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumNonlinSolvIters(arkode_mem, nni) + retval = FARKodeGetNumNonlinSolvIters(arkode_mem, nni) if (retval /= 0) then - print *, "Error: FARKStepGetNumNonlinSolvIters returned ",retval + print *, "Error: FARKodeGetNumNonlinSolvIters returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumNonlinSolvConvFails(arkode_mem, ncfn) + retval = FARKodeGetNumNonlinSolvConvFails(arkode_mem, ncfn) if (retval /= 0) then - print *, "Error: FARKStepGetNumNonlinSolvConvFails returned ",retval + print *, "Error: FARKodeGetNumNonlinSolvConvFails returned ",retval call MPI_Abort(comm, 1, ierr) end if if (global) then - retval = FARKStepGetNumLinIters(arkode_mem, nli) + retval = FARKodeGetNumLinIters(arkode_mem, nli) if (retval /= 0) then - print *, "Error: FARKStepGetNumLinIters returned ",retval + print *, "Error: FARKodeGetNumLinIters returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumPrecEvals(arkode_mem, npre) + retval = FARKodeGetNumPrecEvals(arkode_mem, npre) if (retval /= 0) then - print *, "Error: FARKStepGetNumPrecEvals returned ",retval + print *, "Error: FARKodeGetNumPrecEvals returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumPrecSolves(arkode_mem, npsol) + retval = FARKodeGetNumPrecSolves(arkode_mem, npsol) if (retval /= 0) then - print *, "Error: FARKStepGetNumPrecSolves returned ",retval + print *, "Error: FARKodeGetNumPrecSolves returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1455,7 +1453,7 @@ subroutine EvolveProblemIMEX(sunvec_y) end if ! Clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) ! Free nonlinear solver retval = FSUNNonlinSolFree(sun_NLS) @@ -1527,23 +1525,23 @@ subroutine EvolveProblemExplicit(sunvec_y) end if ! Select the method order - retval = FERKStepSetOrder(arkode_mem, order) + retval = FARKodeSetOrder(arkode_mem, order) if (retval /= 0) then - print *, "Error: FERKStepSetOrder returned ",retval + print *, "Error: FARKodeSetOrder returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Specify tolerances - retval = FERKStepSStolerances(arkode_mem, rtol, atol) + retval = FARKodeSStolerances(arkode_mem, rtol, atol) if (retval /= 0) then - print *, "Error: FERKStepSStolerances returned ",retval + print *, "Error: FARKodeSStolerances returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Increase the max number of steps allowed between outputs - retval = FERKStepSetMaxNumSteps(arkode_mem, int(100000, c_long)) + retval = FARKodeSetMaxNumSteps(arkode_mem, int(100000, c_long)) if (retval /= 0) then - print *, "Error: FERKStepMaxNumSteps returned ",retval + print *, "Error: FARKodeMaxNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1568,9 +1566,9 @@ subroutine EvolveProblemExplicit(sunvec_y) do while (iout < nout) ! Integrate to output time - retval = FERKStepEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) if (retval /= 0) then - print *, "Error: FERKStepEvolve returned ",retval + print *, "Error: FARKodeEvolve returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1594,15 +1592,15 @@ subroutine EvolveProblemExplicit(sunvec_y) end if ! Get final statistics - retval = FERKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FERKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FERKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FERKStepGetNumStepAttempts returned ",retval + print *, "Error: FARKodeGetNumStepAttempts returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1612,9 +1610,9 @@ subroutine EvolveProblemExplicit(sunvec_y) call MPI_Abort(comm, 1, ierr) end if - retval = FERKStepGetNumErrTestFails(arkode_mem, netf) + retval = FARKodeGetNumErrTestFails(arkode_mem, netf) if (retval /= 0) then - print *, "Error: FERKStepGetNumErrTestFails returned ",retval + print *, "Error: FARKodeGetNumErrTestFails returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -1628,7 +1626,7 @@ subroutine EvolveProblemExplicit(sunvec_y) end if ! Clean up - call FERKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) end subroutine EvolveProblemExplicit @@ -1640,8 +1638,6 @@ subroutine WriteOutput(t, sunvec_y) use, intrinsic :: iso_c_binding use fsundials_core_mod use farkode_mod ! Access ARKode - use farkode_erkstep_mod ! Access ERKStep - use ode_mod, only : Nvar, nprocs, myid, Erecv, Nx, Npts, monitor, nout, & umask, vmask, wmask diff --git a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 index 7e849b7830..7cf6efd0f9 100644 --- a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.f90 @@ -268,9 +268,9 @@ program driver ! Attach the linear solver (with NULL SUNMatrix object) sunmat_A => null() - retval = FARKStepSetLinearSolver(arkode_mem, sunls, sunmat_A) + retval = FARKodeSetLinearSolver(arkode_mem, sunls, sunmat_A) if (retval /= 0) then - print *, 'Error in FARKStepSetLinearSolver, retval = ', retval + print *, 'Error in FARKodeSetLinearSolver, retval = ', retval call MPI_Abort(comm, 1, ierr) end if @@ -281,9 +281,9 @@ program driver end if ! Specify tolerances - retval = FARKStepSStolerances(arkode_mem, rtol, atol) + retval = FARKodeSStolerances(arkode_mem, rtol, atol) if (retval /= 0) then - print *, "Error: FARKStepSStolerances returned ",retval + print *, "Error: FARKodeSStolerances returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -330,7 +330,7 @@ program driver if (iPretype == 1 .and. outproc) write(6,*) " Preconditioning on left:" - ! Main time-stepping loop: calls FARKStepEvolve to perform the integration, + ! Main time-stepping loop: calls FARKodeEvolve to perform the integration, ! then prints results. Stops when the final time has been reached t(1) = T0 dTout = 0.1d0 @@ -342,22 +342,22 @@ program driver do ioutput=1,Nt ! Integrate to output time - retval = FARKStepEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) if (retval /= 0) then - print *, "Error: FARKStepEvolve returned ",retval + print *, "Error: FARKodeEvolve returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Retrieve solver statistics - retval = FARKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FARKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FARKStepGetNumStepAttempts returned ",retval + print *, "Error: FARKodeGetNumStepAttempts returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -395,15 +395,15 @@ program driver if (outproc) print '(a,es10.2)', "Max. absolute error is ", gerrmax ! Get final statistics - retval = FARKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FARKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FARKStepGetNumStepAttempts returned ", retval + print *, "Error: FARKodeGetNumStepAttempts returned ", retval call MPI_Abort(comm, 1, ierr) end if @@ -413,59 +413,59 @@ program driver call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumPrecEvals(arkode_mem, npre) + retval = FARKodeGetNumPrecEvals(arkode_mem, npre) if (retval /= 0) then - print *, "Error: FARKStepGetNumPrecEvals returned ", retval + print *, "Error: FARKodeGetNumPrecEvals returned ", retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumPrecSolves(arkode_mem, npsol) + retval = FARKodeGetNumPrecSolves(arkode_mem, npsol) if (retval /= 0) then - print *, "Error: FARKStepGetNumPrecSolves returned ", retval + print *, "Error: FARKodeGetNumPrecSolves returned ", retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumNonlinSolvIters(arkode_mem, nni) + retval = FARKodeGetNumNonlinSolvIters(arkode_mem, nni) if (retval /= 0) then - print *, "Error: FARKStepGetNumNonlinSolvIters returned ", retval + print *, "Error: FARKodeGetNumNonlinSolvIters returned ", retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumLinIters(arkode_mem, nli) + retval = FARKodeGetNumLinIters(arkode_mem, nli) if (retval /= 0) then - print *, "Error: FARKStepGetNumLinIters returned ", retval + print *, "Error: FARKodeGetNumLinIters returned ", retval call MPI_Abort(comm, 1, ierr) end if avdim = dble(nli) / dble(nni) - retval = FARKStepGetNumNonlinSolvConvFails(arkode_mem, ncfn) + retval = FARKodeGetNumNonlinSolvConvFails(arkode_mem, ncfn) if (retval /= 0) then - print *, "Error: FARKStepGetNumNonlinSolvConvFails returned ", retval + print *, "Error: FARKodeGetNumNonlinSolvConvFails returned ", retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumLinConvFails(arkode_mem, ncfl) + retval = FARKodeGetNumLinConvFails(arkode_mem, ncfl) if (retval /= 0) then - print *, "Error: FARKStepGetNumLinSolvConvFails returned ", retval + print *, "Error: FARKodeGetNumLinSolvConvFails returned ", retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumErrTestFails(arkode_mem, netf) + retval = FARKodeGetNumErrTestFails(arkode_mem, netf) if (retval /= 0) then - print *, "Error: FARKStepGetNumErrTestFails returned ",retval + print *, "Error: FARKodeGetNumErrTestFails returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetWorkSpace(arkode_mem, lenrw, leniw) + retval = FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) if (retval /= 0) then - print *, "Error: FARKStepGetWorkSpace returned ", retval + print *, "Error: FARKodeGetWorkSpace returned ", retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetLinWorkSpace(arkode_mem, lenrwls, leniwls) + retval = FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) if (retval /= 0) then - print *, "Error: FARKStepGetLinWorkSpace returned ", retval + print *, "Error: FARKodeGetLinWorkSpace returned ", retval call MPI_Abort(comm, 1, ierr) end if @@ -508,7 +508,7 @@ program driver end do ! Clean up and return with successful completion - call FARKStepFree(arkode_mem) ! free integrator memory + call FARKodeFree(arkode_mem) ! free integrator memory call FN_VDestroy(sunvec_y) ! free vector memory call MPI_Barrier(comm, ierr) call MPI_Finalize(ierr) ! Finalize MPI diff --git a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.out b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.out index 537ef428b9..0e09570888 100644 --- a/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.out +++ b/examples/arkode/F2003_parallel/ark_diag_kry_bbd_f2003.out @@ -1,4 +1,4 @@ - + Diagonal test problem: neq = 40 nlocal = 10 @@ -9,7 +9,7 @@ ydot_i = -alpha*i * y_i (i = 1,...,neq) Method is DIRK/NEWTON/SPGMR Precond is band-block-diagonal, using ARKBBDPRE - + Preconditioning on left: t steps steps att. fe fi ------------------------------------------------- @@ -25,7 +25,7 @@ 1.000000 319 319 0 3410 ------------------------------------------------- Max. absolute error is 7.52E-11 - + Final Solver Statistics: Internal solver steps = 319 (attempted = 319) Total explicit RHS evals = 0 @@ -38,13 +38,13 @@ Max. absolute error is 7.52E-11 Total Convergence Failures - Nonlinear = 0 - Linear = 0 Total number of error test failures = 0 - Main solver real/int workspace sizes = 862 267 + Main solver real/int workspace sizes = 862 279 Linear solver real/int workspace sizes = 535 126 BBD preconditioner real/int workspace sizes = 160 72 Total number of g evals = 12 - - - + + + Preconditioning on right: t steps steps att. fe fi ------------------------------------------------- @@ -60,7 +60,7 @@ Max. absolute error is 7.52E-11 1.000000 319 319 0 3410 ------------------------------------------------- Max. absolute error is 7.52E-11 - + Final Solver Statistics: Internal solver steps = 319 (attempted = 319) Total explicit RHS evals = 0 @@ -73,10 +73,7 @@ Max. absolute error is 7.52E-11 Total Convergence Failures - Nonlinear = 0 - Linear = 0 Total number of error test failures = 0 - Main solver real/int workspace sizes = 862 272 + Main solver real/int workspace sizes = 862 284 Linear solver real/int workspace sizes = 535 126 BBD preconditioner real/int workspace sizes = 160 72 Total number of g evals = 12 - - - diff --git a/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 b/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 index 0ddb06d0d1..edfcf0d3b5 100644 --- a/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_diag_non_f2003.f90 @@ -202,13 +202,13 @@ program driver end if ! Specify tolerances - retval = FERKStepSStolerances(arkode_mem, rtol, atol) + retval = FARKodeSStolerances(arkode_mem, rtol, atol) if (retval /= 0) then - print *, "Error: FERKStepSStolerances returned ",retval + print *, "Error: FARKodeSStolerances returned ",retval call MPI_Abort(comm, 1, ierr) end if - ! Main time-stepping loop: calls FERKStepEvolve to perform the + ! Main time-stepping loop: calls FARKodeEvolve to perform the ! integration, then prints results. Stops when the final time ! has been reached. t(1) = T0 @@ -221,21 +221,21 @@ program driver do ioutput=1,Nt ! Integrate to output time - retval = FERKStepEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) if (retval /= 0) then - print *, "Error: FERKStepEvolve returned ",retval + print *, "Error: FARKodeEvolve returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FERKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FERKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FERKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FERKStepGetNumStepAttempts returned ",retval + print *, "Error: FARKodeGetNumStepAttempts returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -273,15 +273,15 @@ program driver if (outproc) print '(a,es10.2)', "Max. absolute error is ", gerrmax ! Get final statistics - retval = FERKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FERKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FERKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FERKStepGetNumStepAttempts returned ",retval + print *, "Error: FARKodeGetNumStepAttempts returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -291,9 +291,9 @@ program driver call MPI_Abort(comm, 1, ierr) end if - retval = FERKStepGetNumErrTestFails(arkode_mem, netf) + retval = FARKodeGetNumErrTestFails(arkode_mem, netf) if (retval /= 0) then - print *, "Error: FERKStepGetNumErrTestFails returned ",retval + print *, "Error: FARKodeGetNumErrTestFails returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -308,7 +308,7 @@ program driver endif ! Clean up and return with successful completion - call FERKStepFree(arkode_mem) ! free integrator memory + call FARKodeFree(arkode_mem) ! free integrator memory call FN_VDestroy(sunvec_y) ! free vector memory call MPI_Barrier(comm, ierr) call MPI_Finalize(ierr) ! Finalize MPI diff --git a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 index 50c54e0211..a58e0ad2d8 100644 --- a/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 +++ b/examples/arkode/F2003_parallel/ark_heat2D_f2003.f90 @@ -766,45 +766,45 @@ program driver ! Attach linear solver sunmat_A => null() - retval = FARKStepSetLinearSolver(arkode_mem, sun_LS, sunmat_A) + retval = FARKodeSetLinearSolver(arkode_mem, sun_LS, sunmat_A) if (retval /= 0) then - print *, "Error: FARKStepSetLinearSolver returned ",retval + print *, "Error: FARKodeSetLinearSolver returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Attach preconditioner - retval = FARKStepSetPreconditioner(arkode_mem, c_funloc(PSetup), & + retval = FARKodeSetPreconditioner(arkode_mem, c_funloc(PSetup), & c_funloc(PSolve)) if (retval /= 0) then - print *, "Error: FARKStepSetPreconditioner returned ",retval + print *, "Error: FARKodeSetPreconditioner returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Specify tolerances - retval = FARKStepSStolerances(arkode_mem, rtol, atol) + retval = FARKodeSStolerances(arkode_mem, rtol, atol) if (retval /= 0) then - print *, "Error: FARKStepSStolerances returned ",retval + print *, "Error: FARKodeSStolerances returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Specify nonlinear solver convergence coefficient - retval = FARKStepSetNonlinConvCoef(arkode_mem, nlscoef) + retval = FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) if (retval /= 0) then - print *, "Error: FARKStepSetNonlinConvCoef returned ",retval + print *, "Error: FARKodeSetNonlinConvCoef returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Specify nonlinear solver predictor method - retval = FARKStepSetPredictorMethod(arkode_mem, int(1, c_int)) + retval = FARKodeSetPredictorMethod(arkode_mem, int(1, c_int)) if (retval /= 0) then - print *, "Error: FARKStepSetNonlinConvCoef returned ",retval + print *, "Error: FARKodeSetNonlinConvCoef returned ",retval call MPI_Abort(comm, 1, ierr) end if ! Specify that problem is linearly implicit - retval = FARKStepSetLinear(arkode_mem, int(0, c_int)) + retval = FARKodeSetLinear(arkode_mem, int(0, c_int)) if (retval /= 0) then - print *, "Error: FARKStepSetNonlinConvCoef returned ",retval + print *, "Error: FARKodeSetNonlinConvCoef returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -852,9 +852,9 @@ program driver do ioutput=1,Nt ! Integrate to output time - retval = FARKStepEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, t, ARK_NORMAL) if (retval /= 0) then - print *, "Error: FARKStepEvolve returned ",retval + print *, "Error: FARKodeEvolve returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -878,15 +878,15 @@ program driver close(101) ! Get final statistics - retval = FARKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, "Error: FARKStepGetNumSteps returned ",retval + print *, "Error: FARKodeGetNumSteps returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, "Error: FARKStepGetNumStepAttempts returned ",retval + print *, "Error: FARKodeGetNumStepAttempts returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -896,39 +896,39 @@ program driver call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumErrTestFails(arkode_mem, netf) + retval = FARKodeGetNumErrTestFails(arkode_mem, netf) if (retval /= 0) then - print *, "Error: FARKStepGetNumErrTestFails returned ",retval + print *, "Error: FARKodeGetNumErrTestFails returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumNonlinSolvIters(arkode_mem, nni) + retval = FARKodeGetNumNonlinSolvIters(arkode_mem, nni) if (retval /= 0) then - print *, "Error: FARKStepGetNumNonlinSolvIters returned ",retval + print *, "Error: FARKodeGetNumNonlinSolvIters returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumLinConvFails(arkode_mem, ncfn) + retval = FARKodeGetNumLinConvFails(arkode_mem, ncfn) if (retval /= 0) then - print *, "Error: FARKStepGetNumLinConvFails returned ",retval + print *, "Error: FARKodeGetNumLinConvFails returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumLinIters(arkode_mem, nli) + retval = FARKodeGetNumLinIters(arkode_mem, nli) if (retval /= 0) then - print *, "Error: FARKStepGetNumLinIters returned ",retval + print *, "Error: FARKodeGetNumLinIters returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumPrecEvals(arkode_mem, npre) + retval = FARKodeGetNumPrecEvals(arkode_mem, npre) if (retval /= 0) then - print *, "Error: FARKStepGetNumPrecEvals returned ",retval + print *, "Error: FARKodeGetNumPrecEvals returned ",retval call MPI_Abort(comm, 1, ierr) end if - retval = FARKStepGetNumPrecSolves(arkode_mem, npsol) + retval = FARKodeGetNumPrecSolves(arkode_mem, npsol) if (retval /= 0) then - print *, "Error: FARKStepGetNumPrecSolves returned ",retval + print *, "Error: FARKodeGetNumPrecSolves returned ",retval call MPI_Abort(comm, 1, ierr) end if @@ -949,7 +949,7 @@ program driver endif ! Clean up and return with successful completion - call FARKStepFree(arkode_mem) ! free integrator memory + call FARKodeFree(arkode_mem) ! free integrator memory call FN_VDestroy(sunvec_y) ! free vector memory call FN_VDestroy(sunvec_ones) retval = FSUNLinSolFree(sun_LS) ! free linear solver diff --git a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 index 877d76062b..d7378eabd0 100644 --- a/examples/arkode/F2003_serial/ark_analytic_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_analytic_f2003.f90 @@ -169,9 +169,9 @@ program main stop 1 end if - ierr = FARKStepSetLinearSolver(arkode_mem, sunls, sunmat_A) + ierr = FARKodeSetLinearSolver(arkode_mem, sunls, sunmat_A) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSetLinearSolver' + write(*,*) 'Error in FARKodeSetLinearSolver' stop 1 end if @@ -179,9 +179,9 @@ program main rtol = 1.0d-6 atol = 1.0d-10 - ierr = FARKStepSStolerances(arkode_mem, rtol, atol) + ierr = FARKodeSStolerances(arkode_mem, rtol, atol) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSStolerances, ierr = ', ierr, '; halting' + write(*,*) 'Error in FARKodeSStolerances, ierr = ', ierr, '; halting' stop 1 end if @@ -190,15 +190,15 @@ program main print *, 'ERROR: sunCtrl = NULL' stop 1 end if - ierr = FARKStepSetAdaptController(arkode_mem, sunCtrl) + ierr = FARKodeSetAdaptController(arkode_mem, sunCtrl) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSetAdaptController, ierr = ', ierr, '; halting' + write(*,*) 'Error in FARKodeSetAdaptController, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepSetNonlinConvCoef(arkode_mem, 0.01d0) + ierr = FARKodeSetNonlinConvCoef(arkode_mem, 0.01d0) if (ierr /= 0) then - write(*,*) 'Error in FARKStepSetNonlinConvCoef, ierr = ', ierr, '; halting' + write(*,*) 'Error in FARKodeSetNonlinConvCoef, ierr = ', ierr, '; halting' stop 1 end if @@ -211,9 +211,9 @@ program main print '(2x,2(es12.5,1x))', tcur, yvec(1) do outstep = 1,nout - ! call ARKStep + ! call ARKodeEvolve tout = min(tout + dtout, tend) - ierr = FARKStepEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) + ierr = FARKodeEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) if (ierr /= 0) then write(*,*) 'Error in FARKODE, ierr = ', ierr, '; halting' stop 1 @@ -228,7 +228,7 @@ program main call ARKStepStats(arkode_mem) ! clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) call FN_VDestroy(sunvec_y) call FSUNMatDestroy(sunmat_A) ierr = FSUNLinSolFree(sunls) @@ -277,15 +277,15 @@ subroutine ARKStepStats(arkode_mem) !======= Internals ============ - ierr = FARKStepGetNumSteps(arkode_mem, nsteps) + ierr = FARKodeGetNumSteps(arkode_mem, nsteps) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + ierr = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, retval = ', ierr, '; halting' stop 1 end if @@ -296,57 +296,57 @@ subroutine ARKStepStats(arkode_mem) end if nfevals=nfe+nfi - ierr = FARKStepGetActualInitStep(arkode_mem, hinused) + ierr = FARKodeGetActualInitStep(arkode_mem, hinused) if (ierr /= 0) then - print *, 'Error in FARKStepGetActualInitStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetActualInitStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetLastStep(arkode_mem, hlast) + ierr = FARKodeGetLastStep(arkode_mem, hlast) if (ierr /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentStep(arkode_mem, hcur) + ierr = FARKodeGetCurrentStep(arkode_mem, hcur) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentTime(arkode_mem, tcur) + ierr = FARKodeGetCurrentTime(arkode_mem, tcur) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentTime, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentTime, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) + ierr = FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumLinSolvSetups, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumLinSolvSetups, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumErrTestFails(arkode_mem, netfails) + ierr = FARKodeGetNumErrTestFails(arkode_mem, netfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumErrTestFails, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumErrTestFails, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) + ierr = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvIters, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvIters, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvConvFails(arkode_mem, nncfails) + ierr = FARKodeGetNumNonlinSolvConvFails(arkode_mem, nncfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvConvFails, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvConvFails, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumJacEvals(arkode_mem, njacevals) + ierr = FARKodeGetNumJacEvals(arkode_mem, njacevals) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumJacEvals, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumJacEvals, retval = ', ierr, '; halting' stop 1 end if diff --git a/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 b/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 index 6389a9e7de..f272a56644 100644 --- a/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss1D_FEM_klu_f2003.f90 @@ -1166,15 +1166,15 @@ program main stop 1 end if - ierr = FARKStepSetLinearSolver(arkode_mem, sunls_A, sunmat_A) + ierr = FARKodeSetLinearSolver(arkode_mem, sunls_A, sunmat_A) if (ierr /= 0) then - print *, 'Error in FARKStepSetLinearSolver' + print *, 'Error in FARKodeSetLinearSolver' stop 1 end if - ierr = FARKStepSetJacFn(arkode_mem, c_funloc(Jac)) + ierr = FARKodeSetJacFn(arkode_mem, c_funloc(Jac)) if (ierr /= 0) then - print *, 'Error in FARKStepSetJacFn' + print *, 'Error in FARKodeSetJacFn' stop 1 end if @@ -1185,15 +1185,15 @@ program main end if time_dep = 0 - ierr = FARKStepSetMassLinearSolver(arkode_mem, sunls_M, sunmat_M, time_dep) + ierr = FARKodeSetMassLinearSolver(arkode_mem, sunls_M, sunmat_M, time_dep) if (ierr /= 0) then - print *, 'Error in FARKStepSetMassLinearSolver' + print *, 'Error in FARKodeSetMassLinearSolver' stop 1 end if - ierr = FARKStepSetMassFn(arkode_mem, c_funloc(Mass)) + ierr = FARKodeSetMassFn(arkode_mem, c_funloc(Mass)) if (ierr /= 0) then - print *, 'Error in FARKStepSetMassFn' + print *, 'Error in FARKodeSetMassFn' stop 1 end if @@ -1201,24 +1201,24 @@ program main rtol = 1.0d-6 atol = 1.0d-11 - ierr = FARKStepSStolerances(arkode_mem, rtol, atol) + ierr = FARKodeSStolerances(arkode_mem, rtol, atol) if (ierr /= 0) then - print *, 'Error in FARKStepSStolerances, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeSStolerances, ierr = ', ierr, '; halting' stop 1 end if ! set residual tolerance with the same atol as above - ierr = FARKStepResStolerance(arkode_mem, atol) + ierr = FARKodeResStolerance(arkode_mem, atol) if (ierr /= 0) then - print *, 'Error in FARKStepResStolerance, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeResStolerance, ierr = ', ierr, '; halting' stop 1 end if ! Set maximum number of internal time steps mxsteps = 1000 - ierr = FARKStepSetMaxNumSteps(arkode_mem, mxsteps) + ierr = FARKodeSetMaxNumSteps(arkode_mem, mxsteps) if (ierr /= 0) then - print *, 'Error in FARKStepSetNonlinConvCoef' + print *, 'Error in FARKodeSetNonlinConvCoef' stop 1 end if @@ -1238,9 +1238,9 @@ program main print *, 'Error in FSUNDIALSFileOpen' stop 1 end if - ierr = FARKStepWriteParameters(arkode_mem, outstr) + ierr = FARKodeWriteParameters(arkode_mem, outstr) if (ierr /= 0) then - print *, 'Error in FARKStepWriteParameters' + print *, 'Error in FARKodeWriteParameters' stop 1 end if ierr = FSUNDIALSFileClose(outstr) @@ -1262,16 +1262,16 @@ program main ! set the next output time tout = min(tout + dtout, tend) - ierr = FARKStepSetStopTime(arkode_mem, tout) + ierr = FARKodeSetStopTime(arkode_mem, tout) if (ierr /= 0) then - print *, 'Error in FARKStepSetStopTime, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeSetStopTime, ierr = ', ierr, '; halting' stop 1 end if - ! call ARKStep - ierr = FARKStepEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) + ! call ARKodeEvolve + ierr = FARKodeEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) if (ierr < 0) then - print *, 'Error in FARKStepEvolve, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeEvolve, ierr = ', ierr, '; halting' stop 1 end if @@ -1292,7 +1292,7 @@ program main call ARKStepStats(arkode_mem) ! clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) call FN_VDestroy(sunvec_y) call FN_VDestroy(sunvec_u) call FN_VDestroy(sunvec_v) @@ -1344,15 +1344,15 @@ subroutine ARKStepStats(arkode_mem) !======= Internals ============ - ierr = FARKStepGetNumSteps(arkode_mem, nsteps) + ierr = FARKodeGetNumSteps(arkode_mem, nsteps) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + ierr = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, retval = ', ierr, '; halting' stop 1 end if @@ -1362,57 +1362,57 @@ subroutine ARKStepStats(arkode_mem) stop 1 end if - ierr = FARKStepGetLastStep(arkode_mem, hlast) + ierr = FARKodeGetLastStep(arkode_mem, hlast) if (ierr /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentStep(arkode_mem, hcur) + ierr = FARKodeGetCurrentStep(arkode_mem, hcur) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentTime(arkode_mem, tcur) + ierr = FARKodeGetCurrentTime(arkode_mem, tcur) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentTime, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentTime, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) + ierr = FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumLinSolvSetups, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumLinSolvSetups, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumErrTestFails(arkode_mem, netfails) + ierr = FARKodeGetNumErrTestFails(arkode_mem, netfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumErrTestFails, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumErrTestFails, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) + ierr = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvIters, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvIters, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvConvFails(arkode_mem, nncfails) + ierr = FARKodeGetNumNonlinSolvConvFails(arkode_mem, nncfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvConvFails, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvConvFails, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumJacEvals(arkode_mem, njacevals) + ierr = FARKodeGetNumJacEvals(arkode_mem, njacevals) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumJacEvals, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumJacEvals, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumMassSetups(arkode_mem, nmassevals) + ierr = FARKodeGetNumMassSetups(arkode_mem, nmassevals) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumMassSetups, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumMassSetups, retval = ', ierr, '; halting' stop 1 end if diff --git a/examples/arkode/F2003_serial/ark_bruss_f2003.f90 b/examples/arkode/F2003_serial/ark_bruss_f2003.f90 index cdf1ebdb0b..52a7121a88 100644 --- a/examples/arkode/F2003_serial/ark_bruss_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_bruss_f2003.f90 @@ -303,15 +303,15 @@ program main stop 1 end if - ierr = FARKStepSetLinearSolver(arkode_mem, sunls, sunmat_A) + ierr = FARKodeSetLinearSolver(arkode_mem, sunls, sunmat_A) if (ierr /= 0) then - print *, 'Error in FARKStepSetLinearSolver' + print *, 'Error in FARKodeSetLinearSolver' stop 1 end if - ierr = FARKStepSetJacFn(arkode_mem, c_funloc(Jac)) + ierr = FARKodeSetJacFn(arkode_mem, c_funloc(Jac)) if (ierr /= 0) then - print *, 'Error in FARKStepSetJacFn' + print *, 'Error in FARKodeSetJacFn' stop 1 end if @@ -319,22 +319,22 @@ program main rtol = 1.0d-6 atol = 1.0d-10 - ierr = FARKStepSStolerances(arkode_mem, rtol, atol) + ierr = FARKodeSStolerances(arkode_mem, rtol, atol) if (ierr /= 0) then - print *, 'Error in FARKStepSStolerances, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeSStolerances, ierr = ', ierr, '; halting' stop 1 end if ! Set additional method parameters - ierr = FARKStepSetOrder(arkode_mem, order) + ierr = FARKodeSetOrder(arkode_mem, order) if (ierr /= 0) then - print *, 'Error in FARKStepSetOrder' + print *, 'Error in FARKodeSetOrder' stop 1 end if - ierr = FARKStepSetNonlinConvCoef(arkode_mem, nlscoef) + ierr = FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) if (ierr /= 0) then - print *, 'Error in FARKStepSetNonlinConvCoef' + print *, 'Error in FARKodeSetNonlinConvCoef' stop 1 end if @@ -364,11 +364,11 @@ program main print '(2x,4(es12.5,1x))', tcur, yvec(1), yvec(2), yvec(3) do outstep = 1,nout - ! call ARKStepEvolve + ! call ARKodeEvolve tout = min(tout + dtout, tend) - ierr = FARKStepEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) + ierr = FARKodeEvolve(arkode_mem, tout, sunvec_y, tcur, ARK_NORMAL) if (ierr /= 0) then - print *, 'Error in FARKStepEvolve, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeEvolve, ierr = ', ierr, '; halting' stop 1 endif @@ -384,7 +384,7 @@ program main call ARKStepStats(arkode_mem) ! clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) call FN_VDestroy(sunvec_y) call FSUNMatDestroy(sunmat_A) ierr = FSUNLinSolFree(sunls) @@ -431,15 +431,15 @@ subroutine ARKStepStats(arkode_mem) !======= Internals ============ - ierr = FARKStepGetNumSteps(arkode_mem, nsteps) + ierr = FARKodeGetNumSteps(arkode_mem, nsteps) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + ierr = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, retval = ', ierr, '; halting' stop 1 end if @@ -449,57 +449,57 @@ subroutine ARKStepStats(arkode_mem) stop 1 end if - ierr = FARKStepGetActualInitStep(arkode_mem, hinused) + ierr = FARKodeGetActualInitStep(arkode_mem, hinused) if (ierr /= 0) then - print *, 'Error in FARKStepGetActualInitStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetActualInitStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetLastStep(arkode_mem, hlast) + ierr = FARKodeGetLastStep(arkode_mem, hlast) if (ierr /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentStep(arkode_mem, hcur) + ierr = FARKodeGetCurrentStep(arkode_mem, hcur) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentStep, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentStep, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentTime(arkode_mem, tcur) + ierr = FARKodeGetCurrentTime(arkode_mem, tcur) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentTime, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentTime, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) + ierr = FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumLinSolvSetups, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumLinSolvSetups, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumErrTestFails(arkode_mem, netfails) + ierr = FARKodeGetNumErrTestFails(arkode_mem, netfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumErrTestFails, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumErrTestFails, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) + ierr = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvIters, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvIters, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvConvFails(arkode_mem, nncfails) + ierr = FARKodeGetNumNonlinSolvConvFails(arkode_mem, nncfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvConvFails, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvConvFails, retval = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumJacEvals(arkode_mem, njacevals) + ierr = FARKodeGetNumJacEvals(arkode_mem, njacevals) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumJacEvals, retval = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumJacEvals, retval = ', ierr, '; halting' stop 1 end if diff --git a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 index 372cbf1642..c87583eb23 100644 --- a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.f90 @@ -295,9 +295,9 @@ program main ! Attach the linear solver (with NULL SUNMatrix object) sunmat_A => null() - ierr = FARKStepSetLinearSolver(arkode_mem, sunls, sunmat_A) + ierr = FARKodeSetLinearSolver(arkode_mem, sunls, sunmat_A) if (ierr /= 0) then - print *, 'Error in FARKStepSetLinearSolver, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeSetLinearSolver, ierr = ', ierr, '; halting' stop 1 end if @@ -316,15 +316,15 @@ program main end if ! Set additional method parameters - ierr = FARKStepSStolerances(arkode_mem, rtol, atol) + ierr = FARKodeSStolerances(arkode_mem, rtol, atol) if (ierr /= 0) then - print *, 'Error in FARKStepSStolerances, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeSStolerances, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepSetMaxNumSteps(arkode_mem, mxsteps) + ierr = FARKodeSetMaxNumSteps(arkode_mem, mxsteps) if (ierr /= 0) then - print *, 'Error in FARKStepSetMaxNumSteps' + print *, 'Error in FARKodeSetMaxNumSteps' stop 1 end if @@ -338,29 +338,29 @@ program main tout = twohr do outstep = 1,12 - ! call ARKStep - ierr = FARKStepEvolve(arkode_mem, tout, sunvec_u, tcur, ARK_NORMAL) + ! call ARKodeEvolve + ierr = FARKodeEvolve(arkode_mem, tout, sunvec_u, tcur, ARK_NORMAL) if (ierr /= 0) then - print *, 'Error in FARKStepEvolve, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeEvolve, ierr = ', ierr, '; halting' stop 1 end if ! get some solver statistics - ierr = FARKStepGetNumSteps(arkode_mem, lnst) + ierr = FARKodeGetNumSteps(arkode_mem, lnst) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumSteps, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumSteps, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumStepAttempts(arkode_mem, lnst_att) + ierr = FARKodeGetNumStepAttempts(arkode_mem, lnst_att) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetCurrentStep(arkode_mem, lh) + ierr = FARKodeGetCurrentStep(arkode_mem, lh) if (ierr /= 0) then - print *, 'Error in FARKStepGetCurrentStep, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetCurrentStep, ierr = ', ierr, '; halting' stop 1 end if @@ -378,7 +378,7 @@ program main call ARKStepStats(arkode_mem) ! clean up - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) call FN_VDestroy(sunvec_u) call FN_VDestroy(sunvec_f) ierr = FSUNLinSolFree(sunls) @@ -429,15 +429,15 @@ subroutine ARKStepStats(arkode_mem) !======= Internals ============ - ierr = FARKStepGetNumSteps(arkode_mem, nsteps) + ierr = FARKodeGetNumSteps(arkode_mem, nsteps) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumSteps, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumSteps, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + ierr = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, ierr = ', ierr, '; halting' stop 1 end if @@ -447,59 +447,59 @@ subroutine ARKStepStats(arkode_mem) stop 1 end if - ierr = FARKStepGetNumErrTestFails(arkode_mem, netfails) + ierr = FARKodeGetNumErrTestFails(arkode_mem, netfails) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumErrTestFails, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumErrTestFails, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumPrecEvals(arkode_mem, npe) + ierr = FARKodeGetNumPrecEvals(arkode_mem, npe) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumPrecEvals, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumPrecEvals, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumPrecSolves(arkode_mem, nps) + ierr = FARKodeGetNumPrecSolves(arkode_mem, nps) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumPrecSolves, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumPrecSolves, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) + ierr = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvIters, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvIters, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumLinIters(arkode_mem, nliters) + ierr = FARKodeGetNumLinIters(arkode_mem, nliters) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumLinIters, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumLinIters, ierr = ', ierr, '; halting' stop 1 end if avdim = dble(nliters)/dble(nniters) - ierr = FARKStepGetNumLinConvFails(arkode_mem, ncfl) + ierr = FARKodeGetNumLinConvFails(arkode_mem, ncfl) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumLinConvFails, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumLinConvFails, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetNumNonlinSolvConvFails(arkode_mem, ncf) + ierr = FARKodeGetNumNonlinSolvConvFails(arkode_mem, ncf) if (ierr /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvConvFails, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvConvFails, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetWorkSpace(arkode_mem, lenrw, leniw) + ierr = FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) if (ierr /= 0) then - print *, 'Error in FARKStepGetWorkSpace, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetWorkSpace, ierr = ', ierr, '; halting' stop 1 end if - ierr = FARKStepGetLinWorkSpace(arkode_mem, lenrwls, leniwls) + ierr = FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) if (ierr /= 0) then - print *, 'Error in FARKStepGetLinWorkSpace, ierr = ', ierr, '; halting' + print *, 'Error in FARKodeGetLinWorkSpace, ierr = ', ierr, '; halting' stop 1 end if diff --git a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.out b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.out index 4bc5495c61..68e0609dbb 100644 --- a/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.out +++ b/examples/arkode/F2003_serial/ark_diurnal_kry_bp_f2003.out @@ -1,6 +1,6 @@ - + Finished initialization, starting time steps - + t c1 (bottom left middle top right) | lnst lnst_att lh t c2 (bottom left middle top right) | lnst lnst_att lh ---------------------------------------------------------------------------------------- @@ -29,7 +29,7 @@ 8.640000E+04 8.946777E-06 2.191861E-15 1.700622E-10 5704 5708 6.277419E+02 5.090704E+11 5.755864E+11 5.984224E+11 ---------------------------------------------------------------------------------------- - + General Solver Stats: Total internal steps taken = 5704 Total internal steps attempts = 5708 @@ -43,8 +43,7 @@ Avg Krylov subspace dim = 1.946096E+00 Num nonlinear solver fails = 0 Num linear solver fails = 0 - main solver real/int workspace sizes = 3702 133 + main solver real/int workspace sizes = 3702 145 linear solver real/int workspace sizes = 2455 42 ARKBandPre real/int workspace sizes = 2800 622 ARKBandPre number of f evaluations = 480 - diff --git a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 index b925a5ab76..929844e792 100644 --- a/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_kpr_mri_f2003.f90 @@ -842,12 +842,12 @@ program main call check_retval(retval, "FARKStepSetTables") MATf => FSUNDenseMatrix(NEQ, NEQ, sunctx) LSf => FSUNLinSol_Dense(y, MATf, sunctx) - retval = FARKStepSetLinearSolver(inner_arkode_mem, LSf, MATf) - call check_retval(retval, "FARKStepSetLinearSolver") - retval = FARKStepSetJacFn(inner_arkode_mem, c_funloc(Jn)) - call check_retval(retval, "FARKStepSetJacFn") - retval = FARKStepSStolerances(inner_arkode_mem, reltol, abstol) - call check_retval(retval, "FARKStepSStolerances") + retval = FARKodeSetLinearSolver(inner_arkode_mem, LSf, MATf) + call check_retval(retval, "FARKodeSetLinearSolver") + retval = FARKodeSetJacFn(inner_arkode_mem, c_funloc(Jn)) + call check_retval(retval, "FARKodeSetJacFn") + retval = FARKodeSStolerances(inner_arkode_mem, reltol, abstol) + call check_retval(retval, "FARKodeSStolerances") call FARKodeButcherTable_Free(BTf) else if (solve_type == 3 .or. solve_type == 4) then ! no fast dynamics ('evolve' explicitly w/ erk-3-3) @@ -881,9 +881,9 @@ program main end if ! Set the fast step size */ - retval = FARKStepSetFixedStep(inner_arkode_mem, hf) + retval = FARKodeSetFixedStep(inner_arkode_mem, hf) if (retval /= 0) then - print *, 'ERROR: FARKStepSetFixedStep failed' + print *, 'ERROR: FARKodeSetFixedStep failed' stop 1 end if @@ -951,12 +951,12 @@ program main call check_retval(retval, "FMRIStepSetCoupling") MATs => FSUNDenseMatrix(NEQ, NEQ, sunctx) LSs => FSUNLinSol_Dense(y, MATs, sunctx) - retval = FMRIStepSetLinearSolver(arkode_mem, LSs, MATs) - call check_retval(retval, "FMRIStepSetLinearSolver") - retval = FMRIStepSetJacFn(arkode_mem, c_funloc(Jn)) - call check_retval(retval, "FMRIStepSetJacFn") - retval = FMRIStepSStolerances(arkode_mem, reltol, abstol) - call check_retval(retval, "FMRIStepSStolerances") + retval = FARKodeSetLinearSolver(arkode_mem, LSs, MATs) + call check_retval(retval, "FARKodeSetLinearSolver") + retval = FARKodeSetJacFn(arkode_mem, c_funloc(Jn)) + call check_retval(retval, "FARKodeSetJacFn") + retval = FARKodeSStolerances(arkode_mem, reltol, abstol) + call check_retval(retval, "FARKodeSStolerances") else if (solve_type == 7) then ! MRI-GARK-ESDIRK34a, solve-decoupled slow solver arkode_mem = FMRIStepCreate(c_null_funptr, c_funloc(fs), T0, y, inner_stepper, sunctx) @@ -965,12 +965,12 @@ program main call check_retval(retval, "FMRIStepSetCoupling") MATs => FSUNDenseMatrix(NEQ, NEQ, sunctx) LSs => FSUNLinSol_Dense(y, MATs, sunctx) - retval = FMRIStepSetLinearSolver(arkode_mem, LSs, MATs) - call check_retval(retval, "FMRIStepSetLinearSolver") - retval = FMRIStepSetJacFn(arkode_mem, c_funloc(Js)) - call check_retval(retval, "FMRIStepSetJacFn") - retval = FMRIStepSStolerances(arkode_mem, reltol, abstol) - call check_retval(retval, "FMRIStepSStolerances") + retval = FARKodeSetLinearSolver(arkode_mem, LSs, MATs) + call check_retval(retval, "FARKodeSetLinearSolver") + retval = FARKodeSetJacFn(arkode_mem, c_funloc(Js)) + call check_retval(retval, "FARKodeSetJacFn") + retval = FARKodeSStolerances(arkode_mem, reltol, abstol) + call check_retval(retval, "FARKodeSStolerances") else if (solve_type == 8) then ! IMEX-MRI-GARK3b, solve-decoupled slow solver arkode_mem = FMRIStepCreate(c_funloc(fse), c_funloc(fsi), T0, y, inner_stepper, sunctx) @@ -979,12 +979,12 @@ program main call check_retval(retval, "FMRIStepSetCoupling") MATs => FSUNDenseMatrix(NEQ, NEQ, sunctx) LSs => FSUNLinSol_Dense(y, MATs, sunctx) - retval = FMRIStepSetLinearSolver(arkode_mem, LSs, MATs) - call check_retval(retval, "FMRIStepSetLinearSolver") - retval = FMRIStepSetJacFn(arkode_mem, c_funloc(Jsi)) - call check_retval(retval, "FMRIStepSetJacFn") - retval = FMRIStepSStolerances(arkode_mem, reltol, abstol) - call check_retval(retval, "FMRIStepSStolerances") + retval = FARKodeSetLinearSolver(arkode_mem, LSs, MATs) + call check_retval(retval, "FARKodeSetLinearSolver") + retval = FARKodeSetJacFn(arkode_mem, c_funloc(Jsi)) + call check_retval(retval, "FARKodeSetJacFn") + retval = FARKodeSStolerances(arkode_mem, reltol, abstol) + call check_retval(retval, "FARKodeSStolerances") else if (solve_type == 9) then ! IMEX-MRI-GARK4, solve-decoupled slow solver arkode_mem = FMRIStepCreate(c_funloc(fse), c_funloc(fsi), T0, y, inner_stepper, sunctx) @@ -992,12 +992,12 @@ program main retval = FMRIStepSetCoupling(arkode_mem, SC) MATs => FSUNDenseMatrix(NEQ, NEQ, sunctx) LSs => FSUNLinSol_Dense(y, MATs, sunctx) - retval = FMRIStepSetLinearSolver(arkode_mem, LSs, MATs) - call check_retval(retval, "FMRIStepSetLinearSolver") - retval = FMRIStepSetJacFn(arkode_mem, c_funloc(Jsi)) - call check_retval(retval, "FMRIStepSetJacFn") - retval = FMRIStepSStolerances(arkode_mem, reltol, abstol) - call check_retval(retval, "FMRIStepSStolerances") + retval = FARKodeSetLinearSolver(arkode_mem, LSs, MATs) + call check_retval(retval, "FARKodeSetLinearSolver") + retval = FARKodeSetJacFn(arkode_mem, c_funloc(Jsi)) + call check_retval(retval, "FARKodeSetJacFn") + retval = FARKodeSStolerances(arkode_mem, reltol, abstol) + call check_retval(retval, "FARKodeSStolerances") end if if (.not. c_associated(arkode_mem)) then @@ -1006,14 +1006,14 @@ program main end if ! Set the slow step size - retval = FMRIStepSetFixedStep(arkode_mem, hs) - call check_retval(retval, "FMRIStepSetFixedStep") + retval = FARKodeSetFixedStep(arkode_mem, hs) + call check_retval(retval, "FARKodeSetFixedStep") ! ! Integrate ODE ! - ! Main time-stepping loop: calls MRIStepEvolve to perform the + ! Main time-stepping loop: calls ARKodeEvolve to perform the ! integration, then prints results. Stops when the final time ! has been reached t = T0 @@ -1030,8 +1030,8 @@ program main do iout = 1, Nt ! call integrator - retval = FMRIStepEvolve(arkode_mem, tout, y, tret, ARK_NORMAL) - call check_retval(retval, "FMRIStepEvolve") + retval = FARKodeEvolve(arkode_mem, tout, y, tret, ARK_NORMAL) + call check_retval(retval, "FARKodeEvolve") ! access/print solution and error uerr = abs(yarr(1)-utrue(tret(1))) @@ -1058,11 +1058,11 @@ program main ! ! Get some slow integrator statistics - retval = FMRIStepGetNumSteps(arkode_mem, nsts) + retval = FARKodeGetNumSteps(arkode_mem, nsts) retval = FMRIStepGetNumRhsEvals(arkode_mem, nfse, nfsi) ! Get some fast integrator statistics - retval = FARKStepGetNumSteps(inner_arkode_mem, nstf) + retval = FARKodeGetNumSteps(inner_arkode_mem, nstf) retval = FARKStepGetNumRhsEvals(inner_arkode_mem, nff, tmp) ! Print some final statistics @@ -1080,10 +1080,10 @@ program main ! Get/print slow integrator decoupled implicit solver statistics if ((solve_type == 4) .or. (solve_type == 7) .or. & (solve_type == 8) .or. (solve_type == 9)) then - retval = FMRIStepGetNonlinSolvStats(arkode_mem, nnis, nncs) - call check_retval(retval, "MRIStepGetNonlinSolvStats") - retval = FMRIStepGetNumJacEvals(arkode_mem, njes) - call check_retval(retval, "MRIStepGetNumJacEvals") + retval = FARKodeGetNonlinSolvStats(arkode_mem, nnis, nncs) + call check_retval(retval, "ARKodeGetNonlinSolvStats") + retval = FARKodeGetNumJacEvals(arkode_mem, njes) + call check_retval(retval, "ARKodeGetNumJacEvals") print '(A, I7)', " Slow Newton iters = ", nnis print '(A, I7)', " Slow Newton conv fails = ", nncs print '(A, I7)', " Slow Jacobian evals = ", njes @@ -1091,10 +1091,10 @@ program main ! Get/print fast integrator implicit solver statistics if (solve_type == 2) then - retval = FARKStepGetNonlinSolvStats(inner_arkode_mem, nnif, nncf) - call check_retval(retval, "ARKStepGetNonlinSolvStats") - retval = FARKStepGetNumJacEvals(inner_arkode_mem, njef) - call check_retval(retval, "ARKStepGetNumJacEvals") + retval = FARKodeGetNonlinSolvStats(inner_arkode_mem, nnif, nncf) + call check_retval(retval, "ARKodeGetNonlinSolvStats") + retval = FARKodeGetNumJacEvals(inner_arkode_mem, njef) + call check_retval(retval, "ARKodeGetNumJacEvals") print '(A, I7)', " Fast Newton iters = ", nnif print '(A, I7)', " Fast Newton conv fails = ", nncf print '(A, I7)', " Fast Jacobian evals = ", njef @@ -1116,9 +1116,9 @@ program main if (associated(LSf)) retval = FSUNLinSolFree(LSf) ! Free fast linear solver if (associated(MATs)) call FSUNMatDestroy(MATs) ! Free slow matrix if (associated(LSs)) retval = FSUNLinSolFree(LSs) ! Free slow linear solver - call FARKStepFree(inner_arkode_mem) ! Free fast integrator memory + call FARKodeFree(inner_arkode_mem) ! Free fast integrator memory retval = FMRIStepInnerStepper_Free(inner_stepper) ! Free inner stepper - call FMRIStepFree(arkode_mem) ! Free slow integrator memory + call FARKodeFree(arkode_mem) ! Free slow integrator memory retval = FSUNContext_Free(sunctx) ! Free context end program main diff --git a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 index a57dd5f9c6..fb58aee07f 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dnsL_f2003.f90 @@ -275,18 +275,18 @@ program main arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(fcnirob), t0, sunvec_y, sunctx) if (.not. c_associated(arkode_mem)) print *, 'ERROR: arkode_mem = NULL' - ! Call FARKStepSVtolerances to set tolerances - retval = FARKStepSVtolerances(arkode_mem, rtol, sunvec_av) + ! Call FARKodeSVtolerances to set tolerances + retval = FARKodeSVtolerances(arkode_mem, rtol, sunvec_av) if (retval /= 0) then - print *, 'Error in FARKStepSVtolerances, retval = ', retval, '; halting' + print *, 'Error in FARKodeSVtolerances, retval = ', retval, '; halting' stop 1 end if - ! Call FARKStepRootInit to specify the root function grob with 2 components + ! Call FARKodeRootInit to specify the root function grob with 2 components nrtfn = 2 - retval = FARKStepRootInit(arkode_mem, nrtfn, c_funloc(grob)) + retval = FARKodeRootInit(arkode_mem, nrtfn, c_funloc(grob)) if (retval /= 0) then - print *, 'Error in FARKStepRootInit, retval = ', retval, '; halting' + print *, 'Error in FARKodeRootInit, retval = ', retval, '; halting' stop 1 end if @@ -305,59 +305,59 @@ program main end if ! Attach the matrix and linear solver - retval = FARKStepSetLinearSolver(arkode_mem, sunlinsol_LS, sunmat_A); + retval = FARKodeSetLinearSolver(arkode_mem, sunlinsol_LS, sunmat_A); if (retval /= 0) then - print *, 'Error in FARKStepSetLinearSolver, retval = ', retval, '; halting' + print *, 'Error in FARKodeSetLinearSolver, retval = ', retval, '; halting' stop 1 end if ! Set the user-supplied Jacobian routine - retval = FARKStepSetJacFn(arkode_mem, c_funloc(jacrob)) + retval = FARKodeSetJacFn(arkode_mem, c_funloc(jacrob)) if (retval /= 0) then - print *, 'Error in FARKStepSetJacFn, retval = ', retval, '; halting' + print *, 'Error in FARKodeSetJacFn, retval = ', retval, '; halting' stop 1 end if ! Set additional method parameters mxsteps = 10000 - retval = FARKStepSetMaxNumSteps(arkode_mem, mxsteps) + retval = FARKodeSetMaxNumSteps(arkode_mem, mxsteps) if (retval /= 0) then - print *, 'Error in FARKStepSetMaxNumSteps' + print *, 'Error in FARKodeSetMaxNumSteps' stop 1 end if initsize = 1.d-4 * rtol - retval = FARKStepSetInitStep(arkode_mem, initsize) + retval = FARKodeSetInitStep(arkode_mem, initsize) if (retval /= 0) then - print *, 'Error in FARKStepSetInitStep' + print *, 'Error in FARKodeSetInitStep' stop 1 end if nlscoef = 1.d-7 - retval = FARKStepSetNonlinConvCoef(arkode_mem, nlscoef) + retval = FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) if (retval /= 0) then - print *, 'Error in FARKStepSetNonlinConvCoef' + print *, 'Error in FARKodeSetNonlinConvCoef' stop 1 end if nliters = 8 - retval = FARKStepSetMaxNonlinIters(arkode_mem, nliters) + retval = FARKodeSetMaxNonlinIters(arkode_mem, nliters) if (retval /= 0) then - print *, 'Error in FARKStepSetMaxNonlinIters' + print *, 'Error in FARKodeSetMaxNonlinIters' stop 1 end if pmethod = 1 - retval = FARKStepSetPredictorMethod(arkode_mem, pmethod) + retval = FARKodeSetPredictorMethod(arkode_mem, pmethod) if (retval /= 0) then - print *, 'Error in FARKStepSetPredictorMethod' + print *, 'Error in FARKodeSetPredictorMethod' stop 1 end if maxetf = 20 - retval = FARKStepSetMaxErrTestFails(arkode_mem, maxetf) + retval = FARKodeSetMaxErrTestFails(arkode_mem, maxetf) if (retval /= 0) then - print *, 'Error in FARKStepSetMaxErrTestFails' + print *, 'Error in FARKodeSetMaxErrTestFails' stop 1 end if @@ -372,29 +372,29 @@ program main end if ! Attach the nonlinear solver - retval = FARKStepSetNonlinearSolver(arkode_mem, sunnonlin_NLS) + retval = FARKodeSetNonlinearSolver(arkode_mem, sunnonlin_NLS) if (retval /= 0) then - print *, 'Error in FARKStepSetNonlinearSolver, retval = ', retval, '; halting' + print *, 'Error in FARKodeSetNonlinearSolver, retval = ', retval, '; halting' stop 1 end if - ! In loop, call ARKStepEvolve, print results, and test for error. + ! In loop, call ARKodeEvolve, print results, and test for error. iout = 0 tout = tout1 do while(iout < nout) - retval = FARKStepEvolve(arkode_mem, tout, sunvec_y, tret(1), ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, tret(1), ARK_NORMAL) if (retval < 0) then - print *, 'Error in FARKStepEvolve, retval = ', retval, '; halting' + print *, 'Error in FARKodeEvolve, retval = ', retval, '; halting' stop 1 endif call PrintOutput(arkode_mem, tret(1), yval) if (retval .eq. ARK_ROOT_RETURN) then - retvalr = FARKStepGetRootInfo(arkode_mem, rootsfound) + retvalr = FARKodeGetRootInfo(arkode_mem, rootsfound) if (retvalr < 0) then - print *, 'Error in FARKStepGetRootInfo, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetRootInfo, retval = ', retval, '; halting' stop 1 endif print '(a,2(i2,2x))', " rootsfound[] = ", rootsfound(1), rootsfound(2) @@ -413,9 +413,9 @@ program main stop 1 end if - retval = FARKStepGetDky(arkode_mem, tret(1), 1, sunvec_dky) + retval = FARKodeGetDky(arkode_mem, tret(1), 1, sunvec_dky) if (retval /= 0) then - print *, 'Error in ARKStepGetDky' + print *, 'Error in ARKodeGetDky' stop 1 end if print *, " " @@ -428,7 +428,7 @@ program main call PrintFinalStats(arkode_mem) ! free memory - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) retval = FSUNNonlinSolFree(sunnonlin_NLS) retval = FSUNLinSolFree(sunlinsol_LS) call FSUNMatDestroy(sunmat_A) @@ -503,15 +503,15 @@ subroutine PrintOutput(arkode_mem, t, y) !======= Internals ============ - retval = FARKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetLastStep(arkode_mem, hused) + retval = FARKodeGetLastStep(arkode_mem, hused) if (retval /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', retval, '; halting' stop 1 end if @@ -559,15 +559,15 @@ subroutine PrintFinalStats(arkode_mem) !======= Internals ============ - retval = FARKStepGetNumSteps(arkode_mem, nsteps) + retval = FARKodeGetNumSteps(arkode_mem, nsteps) if (retval /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, retval = ', retval, '; halting' stop 1 end if @@ -577,57 +577,57 @@ subroutine PrintFinalStats(arkode_mem) stop 1 end if - retval = FARKStepGetActualInitStep(arkode_mem, hinused) + retval = FARKodeGetActualInitStep(arkode_mem, hinused) if (retval /= 0) then - print *, 'Error in FARKStepGetActualInitStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetActualInitStep, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetLastStep(arkode_mem, hlast) + retval = FARKodeGetLastStep(arkode_mem, hlast) if (retval /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetCurrentStep(arkode_mem, hcur) + retval = FARKodeGetCurrentStep(arkode_mem, hcur) if (retval /= 0) then - print *, 'Error in FARKStepGetCurrentStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetCurrentStep, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetCurrentTime(arkode_mem, tcur) + retval = FARKodeGetCurrentTime(arkode_mem, tcur) if (retval /= 0) then - print *, 'Error in FARKStepGetCurrentTime, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetCurrentTime, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) + retval = FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) if (retval /= 0) then - print *, 'Error in FARKStepGetNumLinSolvSetups, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumLinSolvSetups, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumErrTestFails(arkode_mem, netfails) + retval = FARKodeGetNumErrTestFails(arkode_mem, netfails) if (retval /= 0) then - print *, 'Error in FARKStepGetNumErrTestFails, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumErrTestFails, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) + retval = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) if (retval /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvIters, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvIters, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumNonlinSolvConvFails(arkode_mem, nncfails) + retval = FARKodeGetNumNonlinSolvConvFails(arkode_mem, nncfails) if (retval /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvConvFails, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvConvFails, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumJacEvals(arkode_mem, njacevals) + retval = FARKodeGetNumJacEvals(arkode_mem, njacevals) if (retval /= 0) then - print *, 'Error in FARKStepGetNumJacEvals, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumJacEvals, retval = ', retval, '; halting' stop 1 end if diff --git a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 index 30b41329ee..379f7a23ea 100644 --- a/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 +++ b/examples/arkode/F2003_serial/ark_roberts_dns_f2003.f90 @@ -278,18 +278,18 @@ program main arkode_mem = FARKStepCreate(c_null_funptr, c_funloc(fcnirob), t0, sunvec_y, sunctx) if (.not. c_associated(arkode_mem)) print *, 'ERROR: arkode_mem = NULL' - ! Call FARKStepSVtolerances to set tolerances - retval = FARKStepSVtolerances(arkode_mem, rtol, sunvec_av) + ! Call FARKodeSVtolerances to set tolerances + retval = FARKodeSVtolerances(arkode_mem, rtol, sunvec_av) if (retval /= 0) then - print *, 'Error in FARKStepSVtolerances, retval = ', retval, '; halting' + print *, 'Error in FARKodeSVtolerances, retval = ', retval, '; halting' stop 1 end if - ! Call FARKStepRootInit to specify the root function grob with 2 components + ! Call FARKodeRootInit to specify the root function grob with 2 components nrtfn = 2 - retval = FARKStepRootInit(arkode_mem, nrtfn, c_funloc(grob)) + retval = FARKodeRootInit(arkode_mem, nrtfn, c_funloc(grob)) if (retval /= 0) then - print *, 'Error in FARKStepRootInit, retval = ', retval, '; halting' + print *, 'Error in FARKodeRootInit, retval = ', retval, '; halting' stop 1 end if @@ -308,59 +308,59 @@ program main end if ! Attach the matrix and linear solver - retval = FARKStepSetLinearSolver(arkode_mem, sunlinsol_LS, sunmat_A); + retval = FARKodeSetLinearSolver(arkode_mem, sunlinsol_LS, sunmat_A); if (retval /= 0) then - print *, 'Error in FARKStepSetLinearSolver, retval = ', retval, '; halting' + print *, 'Error in FARKodeSetLinearSolver, retval = ', retval, '; halting' stop 1 end if ! Set the user-supplied Jacobian routine - retval = FARKStepSetJacFn(arkode_mem, c_funloc(jacrob)) + retval = FARKodeSetJacFn(arkode_mem, c_funloc(jacrob)) if (retval /= 0) then - print *, 'Error in FARKStepSetJacFn, retval = ', retval, '; halting' + print *, 'Error in FARKodeSetJacFn, retval = ', retval, '; halting' stop 1 end if ! Set additional method parameters mxsteps = 10000 - retval = FARKStepSetMaxNumSteps(arkode_mem, mxsteps) + retval = FARKodeSetMaxNumSteps(arkode_mem, mxsteps) if (retval /= 0) then - print *, 'Error in FARKStepSetMaxNumSteps' + print *, 'Error in FARKodeSetMaxNumSteps' stop 1 end if initsize = 1.d-4 * rtol - retval = FARKStepSetInitStep(arkode_mem, initsize) + retval = FARKodeSetInitStep(arkode_mem, initsize) if (retval /= 0) then - print *, 'Error in FARKStepSetInitStep' + print *, 'Error in FARKodeSetInitStep' stop 1 end if nlscoef = 1.d-7 - retval = FARKStepSetNonlinConvCoef(arkode_mem, nlscoef) + retval = FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) if (retval /= 0) then - print *, 'Error in FARKStepSetNonlinConvCoef' + print *, 'Error in FARKodeSetNonlinConvCoef' stop 1 end if nliters = 8 - retval = FARKStepSetMaxNonlinIters(arkode_mem, nliters) + retval = FARKodeSetMaxNonlinIters(arkode_mem, nliters) if (retval /= 0) then - print *, 'Error in FARKStepSetMaxNonlinIters' + print *, 'Error in FARKodeSetMaxNonlinIters' stop 1 end if pmethod = 1 - retval = FARKStepSetPredictorMethod(arkode_mem, pmethod) + retval = FARKodeSetPredictorMethod(arkode_mem, pmethod) if (retval /= 0) then - print *, 'Error in FARKStepSetPredictorMethod' + print *, 'Error in FARKodeSetPredictorMethod' stop 1 end if maxetf = 20 - retval = FARKStepSetMaxErrTestFails(arkode_mem, maxetf) + retval = FARKodeSetMaxErrTestFails(arkode_mem, maxetf) if (retval /= 0) then - print *, 'Error in FARKStepSetMaxErrTestFails' + print *, 'Error in FARKodeSetMaxErrTestFails' stop 1 end if @@ -375,29 +375,29 @@ program main end if ! Attach the nonlinear solver - retval = FARKStepSetNonlinearSolver(arkode_mem, sunnonlin_NLS) + retval = FARKodeSetNonlinearSolver(arkode_mem, sunnonlin_NLS) if (retval /= 0) then - print *, 'Error in FARKStepSetNonlinearSolver, retval = ', retval, '; halting' + print *, 'Error in FARKodeSetNonlinearSolver, retval = ', retval, '; halting' stop 1 end if - ! In loop, call ARKStepEvolve, print results, and test for error. + ! In loop, call ARKodeEvolve, print results, and test for error. iout = 0 tout = tout1 do while(iout < nout) - retval = FARKStepEvolve(arkode_mem, tout, sunvec_y, tret(1), ARK_NORMAL) + retval = FARKodeEvolve(arkode_mem, tout, sunvec_y, tret(1), ARK_NORMAL) if (retval < 0) then - print *, 'Error in FARKStepEvolve, retval = ', retval, '; halting' + print *, 'Error in FARKodeEvolve, retval = ', retval, '; halting' stop 1 endif call PrintOutput(arkode_mem, tret(1), yval) if (retval .eq. ARK_ROOT_RETURN) then - retvalr = FARKStepGetRootInfo(arkode_mem, rootsfound) + retvalr = FARKodeGetRootInfo(arkode_mem, rootsfound) if (retvalr < 0) then - print *, 'Error in FARKStepGetRootInfo, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetRootInfo, retval = ', retval, '; halting' stop 1 endif print '(a,2(i2,2x))', " rootsfound[] = ", rootsfound(1), rootsfound(2) @@ -416,9 +416,9 @@ program main stop 1 end if - retval = FARKStepGetDky(arkode_mem, tret(1), 1, sunvec_dky) + retval = FARKodeGetDky(arkode_mem, tret(1), 1, sunvec_dky) if (retval /= 0) then - print *, 'Error in ARKStepGetDky' + print *, 'Error in ARKodeGetDky' stop 1 end if print *, " " @@ -431,7 +431,7 @@ program main call PrintFinalStats(arkode_mem) ! free memory - call FARKStepFree(arkode_mem) + call FARKodeFree(arkode_mem) retval = FSUNNonlinSolFree(sunnonlin_NLS) retval = FSUNLinSolFree(sunlinsol_LS) call FSUNMatDestroy(sunmat_A) @@ -506,15 +506,15 @@ subroutine PrintOutput(arkode_mem, t, y) !======= Internals ============ - retval = FARKStepGetNumSteps(arkode_mem, nst) + retval = FARKodeGetNumSteps(arkode_mem, nst) if (retval /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetLastStep(arkode_mem, hused) + retval = FARKodeGetLastStep(arkode_mem, hused) if (retval /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', retval, '; halting' stop 1 end if @@ -562,15 +562,15 @@ subroutine PrintFinalStats(arkode_mem) !======= Internals ============ - retval = FARKStepGetNumSteps(arkode_mem, nsteps) + retval = FARKodeGetNumSteps(arkode_mem, nsteps) if (retval /= 0) then - print *, 'Error in FARKStepGetNumSteps, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumSteps, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumStepAttempts(arkode_mem, nst_a) + retval = FARKodeGetNumStepAttempts(arkode_mem, nst_a) if (retval /= 0) then - print *, 'Error in FARKStepGetNumStepAttempts, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumStepAttempts, retval = ', retval, '; halting' stop 1 end if @@ -580,57 +580,57 @@ subroutine PrintFinalStats(arkode_mem) stop 1 end if - retval = FARKStepGetActualInitStep(arkode_mem, hinused) + retval = FARKodeGetActualInitStep(arkode_mem, hinused) if (retval /= 0) then - print *, 'Error in FARKStepGetActualInitStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetActualInitStep, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetLastStep(arkode_mem, hlast) + retval = FARKodeGetLastStep(arkode_mem, hlast) if (retval /= 0) then - print *, 'Error in FARKStepGetLastStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetLastStep, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetCurrentStep(arkode_mem, hcur) + retval = FARKodeGetCurrentStep(arkode_mem, hcur) if (retval /= 0) then - print *, 'Error in FARKStepGetCurrentStep, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetCurrentStep, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetCurrentTime(arkode_mem, tcur) + retval = FARKodeGetCurrentTime(arkode_mem, tcur) if (retval /= 0) then - print *, 'Error in FARKStepGetCurrentTime, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetCurrentTime, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) + retval = FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) if (retval /= 0) then - print *, 'Error in FARKStepGetNumLinSolvSetups, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumLinSolvSetups, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumErrTestFails(arkode_mem, netfails) + retval = FARKodeGetNumErrTestFails(arkode_mem, netfails) if (retval /= 0) then - print *, 'Error in FARKStepGetNumErrTestFails, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumErrTestFails, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumNonlinSolvIters(arkode_mem, nniters) + retval = FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) if (retval /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvIters, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvIters, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumNonlinSolvConvFails(arkode_mem, nncfails) + retval = FARKodeGetNumNonlinSolvConvFails(arkode_mem, nncfails) if (retval /= 0) then - print *, 'Error in FARKStepGetNumNonlinSolvConvFails, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumNonlinSolvConvFails, retval = ', retval, '; halting' stop 1 end if - retval = FARKStepGetNumJacEvals(arkode_mem, njacevals) + retval = FARKodeGetNumJacEvals(arkode_mem, njacevals) if (retval /= 0) then - print *, 'Error in FARKStepGetNumJacEvals, retval = ', retval, '; halting' + print *, 'Error in FARKodeGetNumJacEvals, retval = ', retval, '; halting' stop 1 end if diff --git a/include/arkode/arkode.h b/include/arkode/arkode.h index f0265db008..979dff09d8 100644 --- a/include/arkode/arkode.h +++ b/include/arkode/arkode.h @@ -11,17 +11,17 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the header file for the main ARKode infrastructure. + * This is the header file for the main ARKODE infrastructure. * ----------------------------------------------------------------- - * ARKode is used to numerically solve the ordinary initial value - * problems using one-step methods. Users do not call ARKode + * ARKODE is used to numerically solve the ordinary initial value + * problems using one-step methods. Users do not call ARKODE * infrastructure routines directly; they instead interact with - * one of the time stepping modules built on top of ARKode. + * one of the time stepping modules built on top of ARKODE. * These time step modules define their supported problem types, * solver options, etc. * * This file serves to define constants and provide function - * prototypes for use across ARKode-based time integration + * prototypes for use across ARKODE-based time integration * modules. * -----------------------------------------------------------------*/ @@ -37,7 +37,7 @@ extern "C" { #endif /* ----------------- - * ARKode Constants + * ARKODE Constants * ----------------- */ /* usage modes (itask) */ @@ -137,6 +137,8 @@ extern "C" { #define ARK_CONTROLLER_ERR -47 +#define ARK_STEPPER_UNSUPPORTED -48 + #define ARK_UNRECOGNIZED_ERROR -99 /* ------------------------------ @@ -171,9 +173,9 @@ typedef int (*ARKRelaxFn)(N_Vector y, sunrealtype* r, void* user_data); typedef int (*ARKRelaxJacFn)(N_Vector y, N_Vector J, void* user_data); -/* -------------------------- - * MRIStep Inner Stepper Type - * -------------------------- */ +/* ------------------------------------------------ + * MRIStep Inner Stepper Type (forward declaration) + * ------------------------------------------------ */ typedef _SUNDIALS_STRUCT_ _MRIStepInnerStepper* MRIStepInnerStepper; @@ -187,6 +189,231 @@ typedef enum ARK_RELAX_NEWTON } ARKRelaxSolver; +/* -------------------------- + * Shared API routines + * -------------------------- */ + +/* Resize and Reset functions */ +SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew, + sunrealtype hscale, sunrealtype t0, + ARKVecResizeFn resize, void* resize_data); +SUNDIALS_EXPORT int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR); + +/* Tolerance input functions */ +SUNDIALS_EXPORT int ARKodeSStolerances(void* arkode_mem, sunrealtype reltol, + sunrealtype abstol); +SUNDIALS_EXPORT int ARKodeSVtolerances(void* arkode_mem, sunrealtype reltol, + N_Vector abstol); +SUNDIALS_EXPORT int ARKodeWFtolerances(void* arkode_mem, ARKEwtFn efun); + +/* Residual tolerance input functions */ +SUNDIALS_EXPORT int ARKodeResStolerance(void* arkode_mem, sunrealtype rabstol); +SUNDIALS_EXPORT int ARKodeResVtolerance(void* arkode_mem, N_Vector rabstol); +SUNDIALS_EXPORT int ARKodeResFtolerance(void* arkode_mem, ARKRwtFn rfun); + +/* Rootfinding */ +SUNDIALS_EXPORT int ARKodeRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); +SUNDIALS_EXPORT int ARKodeSetRootDirection(void* arkode_mem, int* rootdir); +SUNDIALS_EXPORT int ARKodeSetNoInactiveRootWarn(void* arkode_mem); + +/* Optional input functions (general) */ +SUNDIALS_EXPORT int ARKodeSetDefaults(void* arkode_mem); +SUNDIALS_EXPORT int ARKodeSetOrder(void* arkode_mem, int maxord); +SUNDIALS_EXPORT int ARKodeSetInterpolantType(void* arkode_mem, int itype); +SUNDIALS_EXPORT int ARKodeSetInterpolantDegree(void* arkode_mem, int degree); +SUNDIALS_EXPORT int ARKodeSetMaxNumSteps(void* arkode_mem, long int mxsteps); +SUNDIALS_EXPORT int ARKodeSetInterpolateStopTime(void* arkode_mem, + sunbooleantype interp); +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 ARKodeSetUserData(void* arkode_mem, void* user_data); +SUNDIALS_EXPORT int ARKodeSetPostprocessStepFn(void* arkode_mem, + ARKPostProcessFn ProcessStep); +SUNDIALS_EXPORT int ARKodeSetPostprocessStageFn(void* arkode_mem, + ARKPostProcessFn ProcessStage); + +/* Optional input functions (implicit solver) */ +SUNDIALS_EXPORT int ARKodeSetNonlinearSolver(void* arkode_mem, + SUNNonlinearSolver NLS); +SUNDIALS_EXPORT int ARKodeSetLinear(void* arkode_mem, int timedepend); +SUNDIALS_EXPORT int ARKodeSetNonlinear(void* arkode_mem); +SUNDIALS_EXPORT int ARKodeSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi); +SUNDIALS_EXPORT int ARKodeSetDeduceImplicitRhs(void* arkode_mem, + sunbooleantype deduce); +SUNDIALS_EXPORT int ARKodeSetNonlinCRDown(void* arkode_mem, sunrealtype crdown); +SUNDIALS_EXPORT int ARKodeSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); +SUNDIALS_EXPORT int ARKodeSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); +SUNDIALS_EXPORT int ARKodeSetLSetupFrequency(void* arkode_mem, int msbp); +SUNDIALS_EXPORT int ARKodeSetPredictorMethod(void* arkode_mem, int method); +SUNDIALS_EXPORT int ARKodeSetMaxNonlinIters(void* arkode_mem, int maxcor); +SUNDIALS_EXPORT int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf); +SUNDIALS_EXPORT int ARKodeSetNonlinConvCoef(void* arkode_mem, + sunrealtype nlscoef); +SUNDIALS_EXPORT int ARKodeSetStagePredictFn(void* arkode_mem, + ARKStagePredictFn PredictStage); + +/* Optional input functions (temporal adaptivity) */ +SUNDIALS_EXPORT int ARKodeSetAdaptController(void* arkode_mem, + SUNAdaptController C); +SUNDIALS_EXPORT int ARKodeSetAdaptivityAdjustment(void* arkode_mem, int adjust); +SUNDIALS_EXPORT int ARKodeSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac); +SUNDIALS_EXPORT int ARKodeSetErrorBias(void* arkode_mem, sunrealtype bias); +SUNDIALS_EXPORT int ARKodeSetSafetyFactor(void* arkode_mem, sunrealtype safety); +SUNDIALS_EXPORT int ARKodeSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth); +SUNDIALS_EXPORT int ARKodeSetMinReduction(void* arkode_mem, sunrealtype eta_min); +SUNDIALS_EXPORT int ARKodeSetFixedStepBounds(void* arkode_mem, sunrealtype lb, + sunrealtype ub); +SUNDIALS_EXPORT int ARKodeSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1); +SUNDIALS_EXPORT int ARKodeSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf); +SUNDIALS_EXPORT int ARKodeSetSmallNumEFails(void* arkode_mem, int small_nef); +SUNDIALS_EXPORT int ARKodeSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf); +SUNDIALS_EXPORT int ARKodeSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, + void* estab_data); +SUNDIALS_EXPORT int ARKodeSetMaxErrTestFails(void* arkode_mem, int maxnef); +SUNDIALS_EXPORT int ARKodeSetConstraints(void* arkode_mem, N_Vector constraints); +SUNDIALS_EXPORT int ARKodeSetMaxHnilWarns(void* arkode_mem, int mxhnil); +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, + int 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, + N_Vector yout, sunrealtype* tret, int itask); + +/* Computes the kth derivative of the y function at time t */ +SUNDIALS_EXPORT int ARKodeGetDky(void* arkode_mem, sunrealtype t, int k, + N_Vector dky); + +/* Utility function to update/compute y based on zcor */ +SUNDIALS_EXPORT int ARKodeComputeState(void* arkode_mem, N_Vector zcor, + N_Vector z); + +/* Optional output functions (general) */ +SUNDIALS_EXPORT int ARKodeGetNumStepAttempts(void* arkode_mem, + long int* step_attempts); +SUNDIALS_EXPORT int ARKodeGetWorkSpace(void* arkode_mem, long int* lenrw, + long int* leniw); +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 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); +SUNDIALS_EXPORT int ARKodeGetUserData(void* arkode_mem, void** user_data); +SUNDIALS_EXPORT int ARKodePrintAllStats(void* arkode_mem, FILE* outfile, + SUNOutputFormat fmt); +SUNDIALS_EXPORT char* ARKodeGetReturnFlagName(long int flag); +SUNDIALS_EXPORT int ARKodeWriteParameters(void* arkode_mem, FILE* fp); + +/* Optional output functions (temporal adaptivity) */ +SUNDIALS_EXPORT int ARKodeGetNumExpSteps(void* arkode_mem, long int* expsteps); +SUNDIALS_EXPORT int ARKodeGetNumAccSteps(void* arkode_mem, long int* accsteps); +SUNDIALS_EXPORT int ARKodeGetNumErrTestFails(void* arkode_mem, + long int* netfails); +SUNDIALS_EXPORT int ARKodeGetEstLocalErrors(void* arkode_mem, N_Vector ele); +SUNDIALS_EXPORT int ARKodeGetActualInitStep(void* arkode_mem, + sunrealtype* hinused); +SUNDIALS_EXPORT int ARKodeGetTolScaleFactor(void* arkode_mem, + sunrealtype* tolsfac); +SUNDIALS_EXPORT int ARKodeGetNumConstrFails(void* arkode_mem, + long int* nconstrfails); +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, + long int* nlinsetups); +SUNDIALS_EXPORT int ARKodeGetCurrentTime(void* arkode_mem, sunrealtype* tcur); +SUNDIALS_EXPORT int ARKodeGetCurrentState(void* arkode_mem, N_Vector* state); +SUNDIALS_EXPORT int ARKodeGetCurrentGamma(void* arkode_mem, sunrealtype* gamma); +SUNDIALS_EXPORT int ARKodeGetNonlinearSystemData( + void* arkode_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, + N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data); +SUNDIALS_EXPORT int ARKodeGetNumNonlinSolvIters(void* arkode_mem, + long int* nniters); +SUNDIALS_EXPORT int ARKodeGetNumNonlinSolvConvFails(void* arkode_mem, + long int* nnfails); +SUNDIALS_EXPORT int ARKodeGetNonlinSolvStats(void* arkode_mem, long int* nniters, + long int* nnfails); +SUNDIALS_EXPORT int ARKodeGetNumStepSolveFails(void* arkode_mem, + long int* nncfails); +SUNDIALS_EXPORT int ARKodeGetJac(void* arkode_mem, SUNMatrix* J); +SUNDIALS_EXPORT int ARKodeGetJacTime(void* arkode_mem, sunrealtype* t_J); +SUNDIALS_EXPORT int ARKodeGetJacNumSteps(void* arkode_mem, long int* nst_J); +SUNDIALS_EXPORT int ARKodeGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, + long int* leniwLS); +SUNDIALS_EXPORT int ARKodeGetNumJacEvals(void* arkode_mem, long int* njevals); +SUNDIALS_EXPORT int ARKodeGetNumPrecEvals(void* arkode_mem, long int* npevals); +SUNDIALS_EXPORT int ARKodeGetNumPrecSolves(void* arkode_mem, long int* npsolves); +SUNDIALS_EXPORT int ARKodeGetNumLinIters(void* arkode_mem, long int* nliters); +SUNDIALS_EXPORT int ARKodeGetNumLinConvFails(void* arkode_mem, + long int* nlcfails); +SUNDIALS_EXPORT int ARKodeGetNumJTSetupEvals(void* arkode_mem, + long int* njtsetups); +SUNDIALS_EXPORT int ARKodeGetNumJtimesEvals(void* arkode_mem, long int* njvevals); +SUNDIALS_EXPORT int ARKodeGetNumLinRhsEvals(void* arkode_mem, + long int* nfevalsLS); +SUNDIALS_EXPORT int ARKodeGetLastLinFlag(void* arkode_mem, long int* flag); +SUNDIALS_EXPORT char* ARKodeGetLinReturnFlagName(long int flag); + +/* Optional output functions (non-identity mass matrices) */ +SUNDIALS_EXPORT int ARKodeGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M); +SUNDIALS_EXPORT int ARKodeGetResWeights(void* arkode_mem, N_Vector rweight); +SUNDIALS_EXPORT int ARKodeGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, + long int* leniwMLS); +SUNDIALS_EXPORT int ARKodeGetNumMassSetups(void* arkode_mem, long int* nmsetups); +SUNDIALS_EXPORT int ARKodeGetNumMassMultSetups(void* arkode_mem, + long int* nmvsetups); +SUNDIALS_EXPORT int ARKodeGetNumMassMult(void* arkode_mem, long int* nmvevals); +SUNDIALS_EXPORT int ARKodeGetNumMassSolves(void* arkode_mem, long int* nmsolves); +SUNDIALS_EXPORT int ARKodeGetNumMassPrecEvals(void* arkode_mem, + long int* nmpevals); +SUNDIALS_EXPORT int ARKodeGetNumMassPrecSolves(void* arkode_mem, + long int* nmpsolves); +SUNDIALS_EXPORT int ARKodeGetNumMassIters(void* arkode_mem, long int* nmiters); +SUNDIALS_EXPORT int ARKodeGetNumMassConvFails(void* arkode_mem, + long int* nmcfails); +SUNDIALS_EXPORT int ARKodeGetNumMTSetups(void* arkode_mem, long int* nmtsetups); +SUNDIALS_EXPORT int ARKodeGetLastMassFlag(void* arkode_mem, long int* flag); + +/* Free function */ +SUNDIALS_EXPORT void ARKodeFree(void** arkode_mem); + +/* Output the ARKODE memory structure (useful when debugging) */ +SUNDIALS_EXPORT void ARKodePrintMem(void* arkode_mem, FILE* outfile); + +/* Relaxation functions */ +SUNDIALS_EXPORT int ARKodeSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, + ARKRelaxJacFn rjac); +SUNDIALS_EXPORT int ARKodeSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf); +SUNDIALS_EXPORT int ARKodeSetRelaxLowerBound(void* arkode_mem, sunrealtype lower); +SUNDIALS_EXPORT int ARKodeSetRelaxMaxFails(void* arkode_mem, int max_fails); +SUNDIALS_EXPORT int ARKodeSetRelaxMaxIters(void* arkode_mem, int max_iters); +SUNDIALS_EXPORT int ARKodeSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver); +SUNDIALS_EXPORT int ARKodeSetRelaxResTol(void* arkode_mem, sunrealtype res_tol); +SUNDIALS_EXPORT int ARKodeSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, + sunrealtype abs_tol); +SUNDIALS_EXPORT int ARKodeSetRelaxUpperBound(void* arkode_mem, sunrealtype upper); +SUNDIALS_EXPORT int ARKodeGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals); +SUNDIALS_EXPORT int ARKodeGetNumRelaxJacEvals(void* arkode_mem, + long int* J_evals); +SUNDIALS_EXPORT int ARKodeGetNumRelaxFails(void* arkode_mem, + long int* relax_fails); +SUNDIALS_EXPORT int ARKodeGetNumRelaxBoundFails(void* arkode_mem, + long int* fails); +SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveFails(void* arkode_mem, + long int* fails); +SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveIters(void* arkode_mem, + long int* iters); + #ifdef __cplusplus } #endif diff --git a/include/arkode/arkode_arkstep.h b/include/arkode/arkode_arkstep.h index e0871b4533..ffbe12460e 100644 --- a/include/arkode/arkode_arkstep.h +++ b/include/arkode/arkode_arkstep.h @@ -11,7 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the header file for the ARKode ARKStep module. + * This is the header file for the ARKODE ARKStep module. * -----------------------------------------------------------------*/ #ifndef _ARKSTEP_H @@ -64,58 +64,16 @@ static const int ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5; * Exported Functions * ------------------- */ -/* Create, Resize, and Reinitialization functions */ +/* Creation and Reinitialization functions */ SUNDIALS_EXPORT void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, SUNContext sunctx); - -SUNDIALS_EXPORT int ARKStepResize(void* arkode_mem, N_Vector ynew, - sunrealtype hscale, sunrealtype t0, - ARKVecResizeFn resize, void* resize_data); - SUNDIALS_EXPORT int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0); -SUNDIALS_EXPORT int ARKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); - -/* Tolerance input functions */ -SUNDIALS_EXPORT int ARKStepSStolerances(void* arkode_mem, sunrealtype reltol, - sunrealtype abstol); -SUNDIALS_EXPORT int ARKStepSVtolerances(void* arkode_mem, sunrealtype reltol, - N_Vector abstol); -SUNDIALS_EXPORT int ARKStepWFtolerances(void* arkode_mem, ARKEwtFn efun); - -/* Residual tolerance input functions */ -SUNDIALS_EXPORT int ARKStepResStolerance(void* arkode_mem, sunrealtype rabstol); -SUNDIALS_EXPORT int ARKStepResVtolerance(void* arkode_mem, N_Vector rabstol); -SUNDIALS_EXPORT int ARKStepResFtolerance(void* arkode_mem, ARKRwtFn rfun); - -/* Linear solver set functions */ -SUNDIALS_EXPORT int ARKStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, - SUNMatrix A); -SUNDIALS_EXPORT int ARKStepSetMassLinearSolver(void* arkode_mem, - SUNLinearSolver LS, SUNMatrix M, - sunbooleantype time_dep); - -/* Rootfinding initialization */ -SUNDIALS_EXPORT int ARKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); - /* Optional input functions -- must be called AFTER ARKStepCreate */ -SUNDIALS_EXPORT int ARKStepSetDefaults(void* arkode_mem); -SUNDIALS_EXPORT int ARKStepSetOptimalParams(void* arkode_mem); -SUNDIALS_EXPORT int ARKStepSetOrder(void* arkode_mem, int maxord); -SUNDIALS_EXPORT int ARKStepSetInterpolantType(void* arkode_mem, int itype); -SUNDIALS_EXPORT int ARKStepSetInterpolantDegree(void* arkode_mem, int degree); -SUNDIALS_EXPORT int ARKStepSetDenseOrder(void* arkode_mem, int dord); -SUNDIALS_EXPORT int ARKStepSetNonlinearSolver(void* arkode_mem, - SUNNonlinearSolver NLS); -SUNDIALS_EXPORT int ARKStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi); -SUNDIALS_EXPORT int ARKStepSetLinear(void* arkode_mem, int timedepend); -SUNDIALS_EXPORT int ARKStepSetNonlinear(void* arkode_mem); SUNDIALS_EXPORT int ARKStepSetExplicit(void* arkode_mem); SUNDIALS_EXPORT int ARKStepSetImplicit(void* arkode_mem); SUNDIALS_EXPORT int ARKStepSetImEx(void* arkode_mem); -SUNDIALS_EXPORT int ARKStepSetDeduceImplicitRhs(void* arkode_mem, - sunbooleantype deduce); SUNDIALS_EXPORT int ARKStepSetTables(void* arkode_mem, int q, int p, ARKodeButcherTable Bi, ARKodeButcherTable Be); @@ -124,255 +82,352 @@ SUNDIALS_EXPORT int ARKStepSetTableNum(void* arkode_mem, ARKODE_ERKTableID etable); SUNDIALS_EXPORT int ARKStepSetTableName(void* arkode_mem, const char* itable, const char* etable); -SUNDIALS_EXPORT int ARKStepSetAdaptController(void* arkode_mem, - SUNAdaptController C); -SUNDIALS_EXPORT int ARKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust); -SUNDIALS_EXPORT int ARKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac); -SUNDIALS_EXPORT int ARKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety); -SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") -int ARKStepSetErrorBias(void* arkode_mem, sunrealtype bias); -SUNDIALS_EXPORT int ARKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth); -SUNDIALS_EXPORT int ARKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min); -SUNDIALS_EXPORT int ARKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, - sunrealtype ub); -SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") -int ARKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, - int pq, sunrealtype adapt_params[3]); -SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") -int ARKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); -SUNDIALS_EXPORT int ARKStepSetMaxFirstGrowth(void* arkode_mem, - sunrealtype etamx1); -SUNDIALS_EXPORT int ARKStepSetMaxEFailGrowth(void* arkode_mem, - sunrealtype etamxf); -SUNDIALS_EXPORT int ARKStepSetSmallNumEFails(void* arkode_mem, int small_nef); -SUNDIALS_EXPORT int ARKStepSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf); -SUNDIALS_EXPORT int ARKStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown); -SUNDIALS_EXPORT int ARKStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); -SUNDIALS_EXPORT int ARKStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); -SUNDIALS_EXPORT int ARKStepSetLSetupFrequency(void* arkode_mem, int msbp); -SUNDIALS_EXPORT int ARKStepSetPredictorMethod(void* arkode_mem, int method); -SUNDIALS_EXPORT int ARKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, - void* estab_data); -SUNDIALS_EXPORT int ARKStepSetMaxErrTestFails(void* arkode_mem, int maxnef); -SUNDIALS_EXPORT int ARKStepSetMaxNonlinIters(void* arkode_mem, int maxcor); -SUNDIALS_EXPORT int ARKStepSetMaxConvFails(void* arkode_mem, int maxncf); -SUNDIALS_EXPORT int ARKStepSetNonlinConvCoef(void* arkode_mem, - sunrealtype nlscoef); -SUNDIALS_EXPORT int ARKStepSetConstraints(void* arkode_mem, N_Vector constraints); -SUNDIALS_EXPORT int ARKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); -SUNDIALS_EXPORT int ARKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil); -SUNDIALS_EXPORT int ARKStepSetInitStep(void* arkode_mem, sunrealtype hin); -SUNDIALS_EXPORT int ARKStepSetMinStep(void* arkode_mem, sunrealtype hmin); -SUNDIALS_EXPORT int ARKStepSetMaxStep(void* arkode_mem, sunrealtype hmax); -SUNDIALS_EXPORT int ARKStepSetInterpolateStopTime(void* arkode_mem, - sunbooleantype interp); -SUNDIALS_EXPORT int ARKStepSetStopTime(void* arkode_mem, sunrealtype tstop); -SUNDIALS_EXPORT int ARKStepClearStopTime(void* arkode_mem); -SUNDIALS_EXPORT int ARKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); -SUNDIALS_EXPORT int ARKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails); - -SUNDIALS_EXPORT int ARKStepSetRootDirection(void* arkode_mem, int* rootdir); -SUNDIALS_EXPORT int ARKStepSetNoInactiveRootWarn(void* arkode_mem); - -SUNDIALS_EXPORT int ARKStepSetUserData(void* arkode_mem, void* user_data); - -SUNDIALS_EXPORT int ARKStepSetPostprocessStepFn(void* arkode_mem, - ARKPostProcessFn ProcessStep); -SUNDIALS_EXPORT int ARKStepSetPostprocessStageFn(void* arkode_mem, - ARKPostProcessFn ProcessStage); -SUNDIALS_EXPORT int ARKStepSetStagePredictFn(void* arkode_mem, - ARKStagePredictFn PredictStage); - -/* Linear solver interface optional input functions -- must be called - AFTER ARKStepSetLinearSolver and/or ARKStepSetMassLinearSolver */ -SUNDIALS_EXPORT int ARKStepSetJacFn(void* arkode_mem, ARKLsJacFn jac); -SUNDIALS_EXPORT int ARKStepSetMassFn(void* arkode_mem, ARKLsMassFn mass); -SUNDIALS_EXPORT int ARKStepSetJacEvalFrequency(void* arkode_mem, long int msbj); -SUNDIALS_EXPORT int ARKStepSetLinearSolutionScaling(void* arkode_mem, - sunbooleantype onoff); -SUNDIALS_EXPORT int ARKStepSetEpsLin(void* arkode_mem, sunrealtype eplifac); -SUNDIALS_EXPORT int ARKStepSetMassEpsLin(void* arkode_mem, sunrealtype eplifac); -SUNDIALS_EXPORT int ARKStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac); -SUNDIALS_EXPORT int ARKStepSetMassLSNormFactor(void* arkode_mem, - sunrealtype nrmfac); -SUNDIALS_EXPORT int ARKStepSetPreconditioner(void* arkode_mem, - ARKLsPrecSetupFn psetup, - ARKLsPrecSolveFn psolve); -SUNDIALS_EXPORT int ARKStepSetMassPreconditioner(void* arkode_mem, - ARKLsMassPrecSetupFn psetup, - ARKLsMassPrecSolveFn psolve); -SUNDIALS_EXPORT int ARKStepSetJacTimes(void* arkode_mem, - ARKLsJacTimesSetupFn jtsetup, - ARKLsJacTimesVecFn jtimes); -SUNDIALS_EXPORT int ARKStepSetJacTimesRhsFn(void* arkode_mem, - ARKRhsFn jtimesRhsFn); -SUNDIALS_EXPORT int ARKStepSetMassTimes(void* arkode_mem, - ARKLsMassTimesSetupFn msetup, - ARKLsMassTimesVecFn mtimes, - void* mtimes_data); -SUNDIALS_EXPORT int ARKStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys); - -/* Integrate the ODE over an interval in t */ -SUNDIALS_EXPORT int ARKStepEvolve(void* arkode_mem, sunrealtype tout, - N_Vector yout, sunrealtype* tret, int itask); - -/* Computes the kth derivative of the y function at time t */ -SUNDIALS_EXPORT int ARKStepGetDky(void* arkode_mem, sunrealtype t, int k, - N_Vector dky); - -/* Utility function to update/compute y based on zcor */ -SUNDIALS_EXPORT int ARKStepComputeState(void* arkode_mem, N_Vector zcor, - N_Vector z); - -/* Utility functions to reset/get accumulated temporal error estimate */ -SUNDIALS_EXPORT int ARKStepSetAccumulatedErrorType(void* arkode_mem, - int accum_type); -SUNDIALS_EXPORT int ARKStepResetAccumulatedError(void* arkode_mem); -SUNDIALS_EXPORT int ARKStepGetAccumulatedError(void* arkode_mem, - sunrealtype* accum_error); /* Optional output functions */ -SUNDIALS_EXPORT int ARKStepGetNumExpSteps(void* arkode_mem, long int* expsteps); -SUNDIALS_EXPORT int ARKStepGetNumAccSteps(void* arkode_mem, long int* accsteps); -SUNDIALS_EXPORT int ARKStepGetNumStepAttempts(void* arkode_mem, - long int* step_attempts); SUNDIALS_EXPORT int ARKStepGetNumRhsEvals(void* arkode_mem, long int* nfe_evals, long int* nfi_evals); -SUNDIALS_EXPORT int ARKStepGetNumLinSolvSetups(void* arkode_mem, - long int* nlinsetups); -SUNDIALS_EXPORT int ARKStepGetNumErrTestFails(void* arkode_mem, - long int* netfails); SUNDIALS_EXPORT int ARKStepGetCurrentButcherTables(void* arkode_mem, ARKodeButcherTable* Bi, ARKodeButcherTable* Be); -SUNDIALS_EXPORT int ARKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele); -SUNDIALS_EXPORT int ARKStepGetWorkSpace(void* arkode_mem, long int* lenrw, - long int* leniw); -SUNDIALS_EXPORT int ARKStepGetNumSteps(void* arkode_mem, long int* nsteps); -SUNDIALS_EXPORT int ARKStepGetActualInitStep(void* arkode_mem, - sunrealtype* hinused); -SUNDIALS_EXPORT int ARKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); -SUNDIALS_EXPORT int ARKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); -SUNDIALS_EXPORT int ARKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); -SUNDIALS_EXPORT int ARKStepGetCurrentState(void* arkode_mem, N_Vector* state); -SUNDIALS_EXPORT int ARKStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma); -SUNDIALS_EXPORT int ARKStepGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M); -SUNDIALS_EXPORT int ARKStepGetTolScaleFactor(void* arkode_mem, - sunrealtype* tolsfac); -SUNDIALS_EXPORT int ARKStepGetErrWeights(void* arkode_mem, N_Vector eweight); -SUNDIALS_EXPORT int ARKStepGetResWeights(void* arkode_mem, N_Vector rweight); -SUNDIALS_EXPORT int ARKStepGetNumGEvals(void* arkode_mem, long int* ngevals); -SUNDIALS_EXPORT int ARKStepGetRootInfo(void* arkode_mem, int* rootsfound); -SUNDIALS_EXPORT int ARKStepGetNumConstrFails(void* arkode_mem, - long int* nconstrfails); -SUNDIALS_EXPORT int ARKStepGetUserData(void* arkode_mem, void** user_data); -SUNDIALS_EXPORT int ARKStepPrintAllStats(void* arkode_mem, FILE* outfile, - SUNOutputFormat fmt); -SUNDIALS_EXPORT char* ARKStepGetReturnFlagName(long int flag); - -SUNDIALS_EXPORT int ARKStepWriteParameters(void* arkode_mem, FILE* fp); - -SUNDIALS_EXPORT int ARKStepWriteButcher(void* arkode_mem, FILE* fp); - -/* Grouped optional output functions */ SUNDIALS_EXPORT int ARKStepGetTimestepperStats( void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nfe_evals, long int* nfi_evals, long int* nlinsetups, long int* netfails); -SUNDIALS_EXPORT int ARKStepGetStepStats(void* arkode_mem, long int* nsteps, - sunrealtype* hinused, sunrealtype* hlast, - sunrealtype* hcur, sunrealtype* tcur); - -/* Nonlinear solver optional output functions */ -SUNDIALS_EXPORT int ARKStepGetNonlinearSystemData( - void* arkode_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, - N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data); - -SUNDIALS_EXPORT int ARKStepGetNumNonlinSolvIters(void* arkode_mem, - long int* nniters); -SUNDIALS_EXPORT int ARKStepGetNumNonlinSolvConvFails(void* arkode_mem, - long int* nnfails); -SUNDIALS_EXPORT int ARKStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, - long int* nnfails); -SUNDIALS_EXPORT int ARKStepGetNumStepSolveFails(void* arkode_mem, - long int* nncfails); - -/* Linear solver optional output functions */ -SUNDIALS_EXPORT int ARKStepGetJac(void* arkode_mem, SUNMatrix* J); -SUNDIALS_EXPORT int ARKStepGetJacTime(void* arkode_mem, sunrealtype* t_J); -SUNDIALS_EXPORT int ARKStepGetJacNumSteps(void* arkode_mem, long int* nst_J); -SUNDIALS_EXPORT int ARKStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, - long int* leniwLS); -SUNDIALS_EXPORT int ARKStepGetNumJacEvals(void* arkode_mem, long int* njevals); -SUNDIALS_EXPORT int ARKStepGetNumPrecEvals(void* arkode_mem, long int* npevals); -SUNDIALS_EXPORT int ARKStepGetNumPrecSolves(void* arkode_mem, long int* npsolves); -SUNDIALS_EXPORT int ARKStepGetNumLinIters(void* arkode_mem, long int* nliters); -SUNDIALS_EXPORT int ARKStepGetNumLinConvFails(void* arkode_mem, - long int* nlcfails); -SUNDIALS_EXPORT int ARKStepGetNumJTSetupEvals(void* arkode_mem, - long int* njtsetups); -SUNDIALS_EXPORT int ARKStepGetNumJtimesEvals(void* arkode_mem, - long int* njvevals); -SUNDIALS_EXPORT int ARKStepGetNumLinRhsEvals(void* arkode_mem, - long int* nfevalsLS); -SUNDIALS_EXPORT int ARKStepGetLastLinFlag(void* arkode_mem, long int* flag); - -SUNDIALS_EXPORT int ARKStepGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, - long int* leniwMLS); -SUNDIALS_EXPORT int ARKStepGetNumMassSetups(void* arkode_mem, long int* nmsetups); -SUNDIALS_EXPORT int ARKStepGetNumMassMultSetups(void* arkode_mem, - long int* nmvsetups); -SUNDIALS_EXPORT int ARKStepGetNumMassMult(void* arkode_mem, long int* nmvevals); -SUNDIALS_EXPORT int ARKStepGetNumMassSolves(void* arkode_mem, long int* nmsolves); -SUNDIALS_EXPORT int ARKStepGetNumMassPrecEvals(void* arkode_mem, - long int* nmpevals); -SUNDIALS_EXPORT int ARKStepGetNumMassPrecSolves(void* arkode_mem, - long int* nmpsolves); -SUNDIALS_EXPORT int ARKStepGetNumMassIters(void* arkode_mem, long int* nmiters); -SUNDIALS_EXPORT int ARKStepGetNumMassConvFails(void* arkode_mem, - long int* nmcfails); -SUNDIALS_EXPORT int ARKStepGetNumMTSetups(void* arkode_mem, long int* nmtsetups); -SUNDIALS_EXPORT int ARKStepGetLastMassFlag(void* arkode_mem, long int* flag); - -SUNDIALS_EXPORT char* ARKStepGetLinReturnFlagName(long int flag); - -/* Free function */ -SUNDIALS_EXPORT void ARKStepFree(void** arkode_mem); - -/* Output the ARKStep memory structure (useful when debugging) */ -SUNDIALS_EXPORT void ARKStepPrintMem(void* arkode_mem, FILE* outfile); /* Utility to wrap ARKStep as an MRIStepInnerStepper */ SUNDIALS_EXPORT int ARKStepCreateMRIStepInnerStepper(void* arkode_mem, MRIStepInnerStepper* stepper); -/* Relaxation functions */ -SUNDIALS_EXPORT int ARKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, - ARKRelaxJacFn rjac); -SUNDIALS_EXPORT int ARKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf); -SUNDIALS_EXPORT int ARKStepSetRelaxLowerBound(void* arkode_mem, - sunrealtype lower); -SUNDIALS_EXPORT int ARKStepSetRelaxMaxFails(void* arkode_mem, int max_fails); -SUNDIALS_EXPORT int ARKStepSetRelaxMaxIters(void* arkode_mem, int max_iters); -SUNDIALS_EXPORT int ARKStepSetRelaxSolver(void* arkode_mem, - ARKRelaxSolver solver); -SUNDIALS_EXPORT int ARKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol); -SUNDIALS_EXPORT int ARKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, - sunrealtype abs_tol); -SUNDIALS_EXPORT int ARKStepSetRelaxUpperBound(void* arkode_mem, - sunrealtype upper); -SUNDIALS_EXPORT int ARKStepGetNumRelaxFnEvals(void* arkode_mem, - long int* r_evals); -SUNDIALS_EXPORT int ARKStepGetNumRelaxJacEvals(void* arkode_mem, - long int* J_evals); -SUNDIALS_EXPORT int ARKStepGetNumRelaxFails(void* arkode_mem, - long int* relax_fails); -SUNDIALS_EXPORT int ARKStepGetNumRelaxBoundFails(void* arkode_mem, - long int* fails); -SUNDIALS_EXPORT int ARKStepGetNumRelaxSolveFails(void* arkode_mem, - long int* fails); -SUNDIALS_EXPORT int ARKStepGetNumRelaxSolveIters(void* arkode_mem, - long int* iters); +/* -------------------------------------------------------------------------- + * Deprecated Functions -- all are superseded by shared ARKODE-level routines + * -------------------------------------------------------------------------- */ + +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResize instead") +int ARKStepResize(void* arkode_mem, N_Vector ynew, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeReset instead") +int ARKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSStolerances instead") +int ARKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSVtolerances instead") +int ARKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWFtolerances instead") +int ARKStepWFtolerances(void* arkode_mem, ARKEwtFn efun); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResStolerance instead") +int ARKStepResStolerance(void* arkode_mem, sunrealtype rabstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResVtolerance instead") +int ARKStepResVtolerance(void* arkode_mem, N_Vector rabstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResFtolerance instead") +int ARKStepResFtolerance(void* arkode_mem, ARKRwtFn rfun); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinearSolver instead") +int ARKStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMassLinearSolver instead") +int ARKStepSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, + SUNMatrix M, sunbooleantype time_dep); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeRootInit instead") +int ARKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDefaults instead") +int ARKStepSetDefaults(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("adjust parameters individually instead") +int ARKStepSetOptimalParams(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetOrder instead") +int ARKStepSetOrder(void* arkode_mem, int maxord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantType instead") +int ARKStepSetInterpolantType(void* arkode_mem, int itype); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int ARKStepSetInterpolantDegree(void* arkode_mem, int degree); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int ARKStepSetDenseOrder(void* arkode_mem, int dord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinearSolver instead") +int ARKStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNlsRhsFn instead") +int ARKStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinear instead") +int ARKStepSetLinear(void* arkode_mem, int timedepend); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinear instead") +int ARKStepSetNonlinear(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDeduceImplicitRhs instead") +int ARKStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetAdaptController instead") +int ARKStepSetAdaptController(void* arkode_mem, SUNAdaptController C); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetAdaptivityAdjustment instead") +int ARKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetCFLFraction instead") +int ARKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetSafetyFactor instead") +int ARKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ARKStepSetErrorBias(void* arkode_mem, sunrealtype bias); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxGrowth instead") +int ARKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMinReduction instead") +int ARKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStepBounds instead") +int ARKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ARKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, + int pq, sunrealtype adapt_params[3]); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ARKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxFirstGrowth instead") +int ARKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxEFailGrowth instead") +int ARKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetSmallNumEFails instead") +int ARKStepSetSmallNumEFails(void* arkode_mem, int small_nef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxCFailGrowth instead") +int ARKStepSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinCRDown instead") +int ARKStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinRDiv instead") +int ARKStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDeltaGammaMax instead") +int ARKStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLSetupFrequency instead") +int ARKStepSetLSetupFrequency(void* arkode_mem, int msbp); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPredictorMethod instead") +int ARKStepSetPredictorMethod(void* arkode_mem, int method); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStabilityFn instead") +int ARKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxErrTestFails instead") +int ARKStepSetMaxErrTestFails(void* arkode_mem, int maxnef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNonlinIters instead") +int ARKStepSetMaxNonlinIters(void* arkode_mem, int maxcor); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxConvFails instead") +int ARKStepSetMaxConvFails(void* arkode_mem, int maxncf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinConvCoef instead") +int ARKStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetConstraints instead") +int ARKStepSetConstraints(void* arkode_mem, N_Vector constraints); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumSteps instead") +int ARKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxHnilWarns instead") +int ARKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInitStep instead") +int ARKStepSetInitStep(void* arkode_mem, sunrealtype hin); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMinStep instead") +int ARKStepSetMinStep(void* arkode_mem, sunrealtype hmin); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxStep instead") +int ARKStepSetMaxStep(void* arkode_mem, sunrealtype hmax); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolateStopTime instead") +int ARKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStopTime instead") +int ARKStepSetStopTime(void* arkode_mem, sunrealtype tstop); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeClearStopTime instead") +int ARKStepClearStopTime(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStep instead") +int ARKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumConstrFails instead") +int ARKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRootDirection instead") +int ARKStepSetRootDirection(void* arkode_mem, int* rootdir); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNoInactiveRootWarn instead") +int ARKStepSetNoInactiveRootWarn(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetUserData instead") +int ARKStepSetUserData(void* arkode_mem, void* user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStepFn instead") +int ARKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead") +int ARKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStagePredictFn instead") +int ARKStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacFn instead") +int ARKStepSetJacFn(void* arkode_mem, ARKLsJacFn jac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMassFn instead") +int ARKStepSetMassFn(void* arkode_mem, ARKLsMassFn mass); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacEvalFrequency instead") +int ARKStepSetJacEvalFrequency(void* arkode_mem, long int msbj); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinearSolutionScaling instead") +int ARKStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetEpsLin instead") +int ARKStepSetEpsLin(void* arkode_mem, sunrealtype eplifac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMassEpsLin instead") +int ARKStepSetMassEpsLin(void* arkode_mem, sunrealtype eplifac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLSNormFactor instead") +int ARKStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMassLSNormFactor instead") +int ARKStepSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPreconditioner instead") +int ARKStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, + ARKLsPrecSolveFn psolve); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMassPreconditioner instead") +int ARKStepSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, + ARKLsMassPrecSolveFn psolve); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacTimes instead") +int ARKStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, + ARKLsJacTimesVecFn jtimes); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacTimesRhsFn instead") +int ARKStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMassTimes instead") +int ARKStepSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn msetup, + ARKLsMassTimesVecFn mtimes, void* mtimes_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinSysFn instead") +int ARKStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeEvolve instead") +int ARKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetDky instead") +int ARKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeComputeState instead") +int ARKStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumExpSteps instead") +int ARKStepGetNumExpSteps(void* arkode_mem, long int* expsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumAccSteps instead") +int ARKStepGetNumAccSteps(void* arkode_mem, long int* accsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumStepAttempts instead") +int ARKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinSolvSetups instead") +int ARKStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumErrTestFails instead") +int ARKStepGetNumErrTestFails(void* arkode_mem, long int* netfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetEstLocalErrors instead") +int ARKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetWorkSpace instead") +int ARKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumSteps instead") +int ARKStepGetNumSteps(void* arkode_mem, long int* nsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetActualInitStep instead") +int ARKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastStep instead") +int ARKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentStep instead") +int ARKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead") +int ARKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentState instead") +int ARKStepGetCurrentState(void* arkode_mem, N_Vector* state); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentGamma instead") +int ARKStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentMassMatrix instead") +int ARKStepGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetTolScaleFactor instead") +int ARKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetErrWeights instead") +int ARKStepGetErrWeights(void* arkode_mem, N_Vector eweight); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetResWeights instead") +int ARKStepGetResWeights(void* arkode_mem, N_Vector rweight); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumGEvals instead") +int ARKStepGetNumGEvals(void* arkode_mem, long int* ngevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetRootInfo instead") +int ARKStepGetRootInfo(void* arkode_mem, int* rootsfound); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumConstrFails instead") +int ARKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetUserData instead") +int ARKStepGetUserData(void* arkode_mem, void** user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintAllStats instead") +int ARKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetReturnFlagName instead") +char* ARKStepGetReturnFlagName(long int flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWriteParameters instead") +int ARKStepWriteParameters(void* arkode_mem, FILE* fp); +SUNDIALS_DEPRECATED_EXPORT_MSG( + "use ARKStepGetCurrentButcherTables and ARKodeButcherTable_Write instead") +int ARKStepWriteButcher(void* arkode_mem, FILE* fp); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetStepStats instead") +int ARKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, + sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNonlinearSystemData instead") +int ARKStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumNonlinSolvIters instead") +int ARKStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumNonlinSolvConvFails instead") +int ARKStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNonlinSolvStats instead") +int ARKStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, + long int* nnfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumStepSolveFails instead") +int ARKStepGetNumStepSolveFails(void* arkode_mem, long int* nncfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetJac instead") +int ARKStepGetJac(void* arkode_mem, SUNMatrix* J); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetJacTime instead") +int ARKStepGetJacTime(void* arkode_mem, sunrealtype* t_J); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetJacNumSteps instead") +int ARKStepGetJacNumSteps(void* arkode_mem, long int* nst_J); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLinWorkSpace instead") +int ARKStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, + long int* leniwLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumJacEvals instead") +int ARKStepGetNumJacEvals(void* arkode_mem, long int* njevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumPrecEvals instead") +int ARKStepGetNumPrecEvals(void* arkode_mem, long int* npevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumPrecSolves instead") +int ARKStepGetNumPrecSolves(void* arkode_mem, long int* npsolves); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinIters instead") +int ARKStepGetNumLinIters(void* arkode_mem, long int* nliters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinConvFails instead") +int ARKStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumJTSetupEvals instead") +int ARKStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumJtimesEvals instead") +int ARKStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinRhsEvals instead") +int ARKStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastLinFlag instead") +int ARKStepGetLastLinFlag(void* arkode_mem, long int* flag); + +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetMassWorkSpace instead") +int ARKStepGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, + long int* leniwMLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassSetups instead") +int ARKStepGetNumMassSetups(void* arkode_mem, long int* nmsetups); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassMultSetups instead") +int ARKStepGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassMult instead") +int ARKStepGetNumMassMult(void* arkode_mem, long int* nmvevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassSolves instead") +int ARKStepGetNumMassSolves(void* arkode_mem, long int* nmsolves); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassPrecEvals instead") +int ARKStepGetNumMassPrecEvals(void* arkode_mem, long int* nmpevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassPrecSolves instead") +int ARKStepGetNumMassPrecSolves(void* arkode_mem, long int* nmpsolves); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassIters instead") +int ARKStepGetNumMassIters(void* arkode_mem, long int* nmiters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMassConvFails instead") +int ARKStepGetNumMassConvFails(void* arkode_mem, long int* nmcfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumMTSetups instead") +int ARKStepGetNumMTSetups(void* arkode_mem, long int* nmtsetups); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastMassFlag instead") +int ARKStepGetLastMassFlag(void* arkode_mem, long int* flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLinReturnFlagName instead") +char* ARKStepGetLinReturnFlagName(long int flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead") +void ARKStepFree(void** arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintMem instead") +void ARKStepPrintMem(void* arkode_mem, FILE* outfile); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxFn instead") +int ARKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxEtaFail instead") +int ARKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxLowerBound instead") +int ARKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxMaxFails instead") +int ARKStepSetRelaxMaxFails(void* arkode_mem, int max_fails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxMaxIters instead") +int ARKStepSetRelaxMaxIters(void* arkode_mem, int max_iters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxSolver instead") +int ARKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxResTol instead") +int ARKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxTol instead") +int ARKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, + sunrealtype abs_tol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxUpperBound instead") +int ARKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxFnEvals instead") +int ARKStepGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxJacEvals instead") +int ARKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxFails instead") +int ARKStepGetNumRelaxFails(void* arkode_mem, long int* relax_fails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxBoundFails instead") +int ARKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails); +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); #ifdef __cplusplus } diff --git a/include/arkode/arkode_erkstep.h b/include/arkode/arkode_erkstep.h index 84406d27c7..73f2a474c6 100644 --- a/include/arkode/arkode_erkstep.h +++ b/include/arkode/arkode_erkstep.h @@ -11,7 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the header file for the ARKode ERKStep module. + * This is the header file for the ARKODE ERKStep module. * -----------------------------------------------------------------*/ #ifndef _ERKSTEP_H @@ -45,181 +45,204 @@ static const int ERKSTEP_DEFAULT_9 = ARKODE_VERNER_16_8_9; * Exported Functions * ------------------- */ -/* Create, Resize, and Reinitialization functions */ +/* Creation and Reinitialization functions */ SUNDIALS_EXPORT void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx); - -SUNDIALS_EXPORT int ERKStepResize(void* arkode_mem, N_Vector ynew, - sunrealtype hscale, sunrealtype t0, - ARKVecResizeFn resize, void* resize_data); - SUNDIALS_EXPORT int ERKStepReInit(void* arkode_mem, ARKRhsFn f, sunrealtype t0, N_Vector y0); -SUNDIALS_EXPORT int ERKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); - -/* Tolerance input functions */ -SUNDIALS_EXPORT int ERKStepSStolerances(void* arkode_mem, sunrealtype reltol, - sunrealtype abstol); -SUNDIALS_EXPORT int ERKStepSVtolerances(void* arkode_mem, sunrealtype reltol, - N_Vector abstol); -SUNDIALS_EXPORT int ERKStepWFtolerances(void* arkode_mem, ARKEwtFn efun); - -/* Rootfinding initialization */ -SUNDIALS_EXPORT int ERKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); - /* Optional input functions -- must be called AFTER ERKStepCreate */ -SUNDIALS_EXPORT int ERKStepSetDefaults(void* arkode_mem); -SUNDIALS_EXPORT int ERKStepSetOrder(void* arkode_mem, int maxord); -SUNDIALS_EXPORT int ERKStepSetInterpolantType(void* arkode_mem, int itype); -SUNDIALS_EXPORT int ERKStepSetInterpolantDegree(void* arkode_mem, int degree); -SUNDIALS_EXPORT int ERKStepSetDenseOrder(void* arkode_mem, int dord); SUNDIALS_EXPORT int ERKStepSetTable(void* arkode_mem, ARKodeButcherTable B); SUNDIALS_EXPORT int ERKStepSetTableNum(void* arkode_mem, ARKODE_ERKTableID etable); SUNDIALS_EXPORT int ERKStepSetTableName(void* arkode_mem, const char* etable); -SUNDIALS_EXPORT int ERKStepSetAdaptController(void* arkode_mem, - SUNAdaptController C); -SUNDIALS_EXPORT int ERKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust); -SUNDIALS_EXPORT int ERKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac); -SUNDIALS_EXPORT int ERKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety); -SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") -int ERKStepSetErrorBias(void* arkode_mem, sunrealtype bias); -SUNDIALS_EXPORT int ERKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth); -SUNDIALS_EXPORT int ERKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min); -SUNDIALS_EXPORT 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, - int pq, sunrealtype adapt_params[3]); -SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") -int ERKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); -SUNDIALS_EXPORT int ERKStepSetMaxFirstGrowth(void* arkode_mem, - sunrealtype etamx1); -SUNDIALS_EXPORT int ERKStepSetMaxEFailGrowth(void* arkode_mem, - sunrealtype etamxf); -SUNDIALS_EXPORT int ERKStepSetSmallNumEFails(void* arkode_mem, int small_nef); -SUNDIALS_EXPORT int ERKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, - void* estab_data); -SUNDIALS_EXPORT int ERKStepSetMaxErrTestFails(void* arkode_mem, int maxnef); -SUNDIALS_EXPORT int ERKStepSetConstraints(void* arkode_mem, N_Vector constraints); -SUNDIALS_EXPORT int ERKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); -SUNDIALS_EXPORT int ERKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil); -SUNDIALS_EXPORT int ERKStepSetInitStep(void* arkode_mem, sunrealtype hin); -SUNDIALS_EXPORT int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin); -SUNDIALS_EXPORT int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax); -SUNDIALS_EXPORT int ERKStepSetInterpolateStopTime(void* arkode_mem, - sunbooleantype interp); -SUNDIALS_EXPORT int ERKStepSetStopTime(void* arkode_mem, sunrealtype tstop); -SUNDIALS_EXPORT int ERKStepClearStopTime(void* arkode_mem); -SUNDIALS_EXPORT int ERKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); -SUNDIALS_EXPORT int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails); - -SUNDIALS_EXPORT int ERKStepSetRootDirection(void* arkode_mem, int* rootdir); -SUNDIALS_EXPORT int ERKStepSetNoInactiveRootWarn(void* arkode_mem); - -SUNDIALS_EXPORT int ERKStepSetUserData(void* arkode_mem, void* user_data); - -SUNDIALS_EXPORT int ERKStepSetPostprocessStepFn(void* arkode_mem, - ARKPostProcessFn ProcessStep); -SUNDIALS_EXPORT int ERKStepSetPostprocessStageFn(void* arkode_mem, - ARKPostProcessFn ProcessStage); - -/* Integrate the ODE over an interval in t */ -SUNDIALS_EXPORT int ERKStepEvolve(void* arkode_mem, sunrealtype tout, - N_Vector yout, sunrealtype* tret, int itask); - -/* Computes the kth derivative of the y function at time t */ -SUNDIALS_EXPORT int ERKStepGetDky(void* arkode_mem, sunrealtype t, int k, - N_Vector dky); - -/* Utility functions to reset/get accumulated temporal error estimate */ -SUNDIALS_EXPORT int ERKStepSetAccumulatedErrorType(void* arkode_mem, - int accum_type); -SUNDIALS_EXPORT int ERKStepResetAccumulatedError(void* arkode_mem); -SUNDIALS_EXPORT int ERKStepGetAccumulatedError(void* arkode_mem, - sunrealtype* accum_error); /* Optional output functions */ -SUNDIALS_EXPORT int ERKStepGetNumExpSteps(void* arkode_mem, long int* expsteps); -SUNDIALS_EXPORT int ERKStepGetNumAccSteps(void* arkode_mem, long int* accsteps); -SUNDIALS_EXPORT int ERKStepGetNumStepAttempts(void* arkode_mem, - long int* step_attempts); SUNDIALS_EXPORT int ERKStepGetNumRhsEvals(void* arkode_mem, long int* nfevals); -SUNDIALS_EXPORT int ERKStepGetNumErrTestFails(void* arkode_mem, - long int* netfails); SUNDIALS_EXPORT int ERKStepGetCurrentButcherTable(void* arkode_mem, ARKodeButcherTable* B); -SUNDIALS_EXPORT int ERKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele); -SUNDIALS_EXPORT int ERKStepGetWorkSpace(void* arkode_mem, long int* lenrw, - long int* leniw); -SUNDIALS_EXPORT int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps); -SUNDIALS_EXPORT int ERKStepGetActualInitStep(void* arkode_mem, - sunrealtype* hinused); -SUNDIALS_EXPORT int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); -SUNDIALS_EXPORT int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); -SUNDIALS_EXPORT int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); -SUNDIALS_EXPORT int ERKStepGetTolScaleFactor(void* arkode_mem, - sunrealtype* tolsfac); -SUNDIALS_EXPORT int ERKStepGetErrWeights(void* arkode_mem, N_Vector eweight); -SUNDIALS_EXPORT int ERKStepGetNumGEvals(void* arkode_mem, long int* ngevals); -SUNDIALS_EXPORT int ERKStepGetRootInfo(void* arkode_mem, int* rootsfound); -SUNDIALS_EXPORT int ERKStepGetNumConstrFails(void* arkode_mem, - long int* nconstrfails); -SUNDIALS_EXPORT int ERKStepGetUserData(void* arkode_mem, void** user_data); -SUNDIALS_EXPORT int ERKStepPrintAllStats(void* arkode_mem, FILE* outfile, - SUNOutputFormat fmt); -SUNDIALS_EXPORT char* ERKStepGetReturnFlagName(long int flag); - -SUNDIALS_EXPORT int ERKStepWriteParameters(void* arkode_mem, FILE* fp); - -SUNDIALS_EXPORT int ERKStepWriteButcher(void* arkode_mem, FILE* fp); /* Grouped optional output functions */ SUNDIALS_EXPORT int ERKStepGetTimestepperStats( void* arkode_mem, long int* expsteps, long int* accsteps, long int* step_attempts, long int* nfevals, long int* netfails); -SUNDIALS_EXPORT int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, - sunrealtype* hinused, sunrealtype* hlast, - sunrealtype* hcur, sunrealtype* tcur); - -/* Free function */ -SUNDIALS_EXPORT void ERKStepFree(void** arkode_mem); - -/* Output the ERKStep memory structure (useful when debugging) */ -SUNDIALS_EXPORT void ERKStepPrintMem(void* arkode_mem, FILE* outfile); - -/* Utility to wrap ERKStep as an MRIStepInnerStepper */ -SUNDIALS_EXPORT int ERKStepCreateMRIStepInnerStepper(void* arkode_mem, - MRIStepInnerStepper* stepper); -/* Relaxation functions */ -SUNDIALS_EXPORT int ERKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, - ARKRelaxJacFn rjac); -SUNDIALS_EXPORT int ERKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf); -SUNDIALS_EXPORT int ERKStepSetRelaxLowerBound(void* arkode_mem, - sunrealtype lower); -SUNDIALS_EXPORT int ERKStepSetRelaxMaxFails(void* arkode_mem, int max_fails); -SUNDIALS_EXPORT int ERKStepSetRelaxMaxIters(void* arkode_mem, int max_iters); -SUNDIALS_EXPORT int ERKStepSetRelaxSolver(void* arkode_mem, - ARKRelaxSolver solver); -SUNDIALS_EXPORT int ERKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol); -SUNDIALS_EXPORT int ERKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, - sunrealtype abs_tol); -SUNDIALS_EXPORT int ERKStepSetRelaxUpperBound(void* arkode_mem, - sunrealtype upper); -SUNDIALS_EXPORT int ERKStepGetNumRelaxFnEvals(void* arkode_mem, - long int* r_evals); -SUNDIALS_EXPORT int ERKStepGetNumRelaxJacEvals(void* arkode_mem, - long int* J_evals); -SUNDIALS_EXPORT int ERKStepGetNumRelaxFails(void* arkode_mem, - long int* relax_fails); -SUNDIALS_EXPORT int ERKStepGetNumRelaxBoundFails(void* arkode_mem, - long int* fails); -SUNDIALS_EXPORT int ERKStepGetNumRelaxSolveFails(void* arkode_mem, - long int* fails); -SUNDIALS_EXPORT int ERKStepGetNumRelaxSolveIters(void* arkode_mem, - long int* iters); +/* -------------------------------------------------------------------------- + * Deprecated Functions -- all are superseded by shared ARKODE-level routines + * -------------------------------------------------------------------------- */ + +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResize instead") +int ERKStepResize(void* arkode_mem, N_Vector ynew, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeReset instead") +int ERKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSStolerances instead") +int ERKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSVtolerances instead") +int ERKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWFtolerances instead") +int ERKStepWFtolerances(void* arkode_mem, ARKEwtFn efun); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeRootInit instead") +int ERKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDefaults instead") +int ERKStepSetDefaults(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetOrder instead") +int ERKStepSetOrder(void* arkode_mem, int maxord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantType instead") +int ERKStepSetInterpolantType(void* arkode_mem, int itype); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int ERKStepSetInterpolantDegree(void* arkode_mem, int degree); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int ERKStepSetDenseOrder(void* arkode_mem, int dord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetAdaptController instead") +int ERKStepSetAdaptController(void* arkode_mem, SUNAdaptController C); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetAdaptivityAdjustment instead") +int ERKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetCFLFraction instead") +int ERKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetSafetyFactor instead") +int ERKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ERKStepSetErrorBias(void* arkode_mem, sunrealtype bias); +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") +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, + int pq, sunrealtype adapt_params[3]); +SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead") +int ERKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxFirstGrowth instead") +int ERKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxEFailGrowth instead") +int ERKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetSmallNumEFails instead") +int ERKStepSetSmallNumEFails(void* arkode_mem, int small_nef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStabilityFn instead") +int ERKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data); +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") +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") +int ERKStepSetInitStep(void* arkode_mem, sunrealtype hin); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetARKode instead") +int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetARKode instead") +int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolateStopTime instead") +int ERKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp); +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") +int ERKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumConstrFails instead") +int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRootDirection instead") +int ERKStepSetRootDirection(void* arkode_mem, int* rootdir); +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") +int ERKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead") +int ERKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeEvolve instead") +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") +int ERKStepGetNumExpSteps(void* arkode_mem, long int* expsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetNumARKodes instead") +int ERKStepGetNumAccSteps(void* arkode_mem, long int* accsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetARKodeAttempts 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); +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") +int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetActualIARKode instead") +int ERKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetLARKode instead") +int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetCurrARKode instead") +int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead") +int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetTolScaleFactor instead") +int ERKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetErrWeights instead") +int ERKStepGetErrWeights(void* arkode_mem, N_Vector eweight); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumGEvals instead") +int ERKStepGetNumGEvals(void* arkode_mem, long int* ngevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetRootInfo instead") +int ERKStepGetRootInfo(void* arkode_mem, int* rootsfound); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumConstrFails instead") +int ERKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetUserData instead") +int ERKStepGetUserData(void* arkode_mem, void** user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintAllStats instead") +int ERKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetReturnFlagName instead") +char* ERKStepGetReturnFlagName(long int flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWriteParameters instead") +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") +int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, + sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead") +void ERKStepFree(void** arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintMem instead") +void ERKStepPrintMem(void* arkode_mem, FILE* outfile); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxFn instead") +int ERKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxEtaFail instead") +int ERKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxLowerBound instead") +int ERKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxMaxFails instead") +int ERKStepSetRelaxMaxFails(void* arkode_mem, int max_fails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxMaxIters instead") +int ERKStepSetRelaxMaxIters(void* arkode_mem, int max_iters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxSolver instead") +int ERKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxResTol instead") +int ERKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxTol instead") +int ERKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, + sunrealtype abs_tol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRelaxUpperBound instead") +int ERKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxFnEvals instead") +int ERKStepGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxJacEvals instead") +int ERKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxFails instead") +int ERKStepGetNumRelaxFails(void* arkode_mem, long int* relax_fails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxBoundFails instead") +int ERKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails); +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); #ifdef __cplusplus } diff --git a/include/arkode/arkode_ls.h b/include/arkode/arkode_ls.h index 8973e53ea5..ce5a6928fa 100644 --- a/include/arkode/arkode_ls.h +++ b/include/arkode/arkode_ls.h @@ -87,6 +87,42 @@ typedef int (*ARKLsMassPrecSetupFn)(sunrealtype t, void* user_data); typedef int (*ARKLsMassPrecSolveFn)(sunrealtype t, N_Vector r, N_Vector z, sunrealtype delta, int lr, void* user_data); +/* Linear solver set functions */ +SUNDIALS_EXPORT int ARKodeSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, + SUNMatrix A); +SUNDIALS_EXPORT int ARKodeSetMassLinearSolver(void* arkode_mem, + SUNLinearSolver LS, SUNMatrix M, + sunbooleantype time_dep); + +/* Linear solver interface optional input functions -- must be called + AFTER ARKodeSetLinearSolver and/or ARKodeSetMassLinearSolver */ +SUNDIALS_EXPORT int ARKodeSetJacFn(void* arkode_mem, ARKLsJacFn jac); +SUNDIALS_EXPORT int ARKodeSetMassFn(void* arkode_mem, ARKLsMassFn mass); +SUNDIALS_EXPORT int ARKodeSetJacEvalFrequency(void* arkode_mem, long int msbj); +SUNDIALS_EXPORT int ARKodeSetLinearSolutionScaling(void* arkode_mem, + sunbooleantype onoff); +SUNDIALS_EXPORT int ARKodeSetEpsLin(void* arkode_mem, sunrealtype eplifac); +SUNDIALS_EXPORT int ARKodeSetMassEpsLin(void* arkode_mem, sunrealtype eplifac); +SUNDIALS_EXPORT int ARKodeSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac); +SUNDIALS_EXPORT int ARKodeSetMassLSNormFactor(void* arkode_mem, + sunrealtype nrmfac); +SUNDIALS_EXPORT int ARKodeSetPreconditioner(void* arkode_mem, + ARKLsPrecSetupFn psetup, + ARKLsPrecSolveFn psolve); +SUNDIALS_EXPORT int ARKodeSetMassPreconditioner(void* arkode_mem, + ARKLsMassPrecSetupFn psetup, + ARKLsMassPrecSolveFn psolve); +SUNDIALS_EXPORT int ARKodeSetJacTimes(void* arkode_mem, + ARKLsJacTimesSetupFn jtsetup, + ARKLsJacTimesVecFn jtimes); +SUNDIALS_EXPORT int ARKodeSetJacTimesRhsFn(void* arkode_mem, + ARKRhsFn jtimesRhsFn); +SUNDIALS_EXPORT int ARKodeSetMassTimes(void* arkode_mem, + ARKLsMassTimesSetupFn msetup, + ARKLsMassTimesVecFn mtimes, + void* mtimes_data); +SUNDIALS_EXPORT int ARKodeSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys); + #ifdef __cplusplus } #endif diff --git a/include/arkode/arkode_mristep.h b/include/arkode/arkode_mristep.h index 969fec85b9..fd6f63032a 100644 --- a/include/arkode/arkode_mristep.h +++ b/include/arkode/arkode_mristep.h @@ -12,7 +12,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the header file for the ARKode MRIStep module. + * This is the header file for the ARKODE MRIStep module. * -----------------------------------------------------------------*/ #ifndef _MRISTEP_H @@ -22,7 +22,6 @@ #include #include #include -#include #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { @@ -122,8 +121,8 @@ struct MRIStepCouplingMem 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) */ + int ngroup; /* number of stage groups (MERK-specific) */ + int** group; /* stages to integrate together (MERK-specific) */ }; typedef _SUNDIALS_STRUCT_ MRIStepCouplingMem* MRIStepCoupling; @@ -163,251 +162,244 @@ typedef int (*MRIStepPostInnerFn)(sunrealtype t, N_Vector y, void* user_data); * Exported Functions * ------------------- */ -/* Create, Resize, and Reinitialization functions */ +/* Creation and Reinitialization functions */ SUNDIALS_EXPORT void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, MRIStepInnerStepper stepper, SUNContext sunctx); - -SUNDIALS_EXPORT int MRIStepResize(void* arkode_mem, N_Vector ynew, sunrealtype t0, - ARKVecResizeFn resize, void* resize_data); - SUNDIALS_EXPORT int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0); -SUNDIALS_EXPORT int MRIStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); - -/* Tolerance input functions */ -SUNDIALS_EXPORT int MRIStepSStolerances(void* arkode_mem, sunrealtype reltol, - sunrealtype abstol); -SUNDIALS_EXPORT int MRIStepSVtolerances(void* arkode_mem, sunrealtype reltol, - N_Vector abstol); -SUNDIALS_EXPORT int MRIStepWFtolerances(void* arkode_mem, ARKEwtFn efun); - -/* Linear solver set function */ -SUNDIALS_EXPORT int MRIStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, - SUNMatrix A); - -/* Rootfinding initialization */ -SUNDIALS_EXPORT int MRIStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); - /* Optional input functions -- must be called AFTER MRIStepCreate */ -SUNDIALS_EXPORT int MRIStepSetDefaults(void* arkode_mem); -SUNDIALS_EXPORT int MRIStepSetOrder(void* arkode_mem, int ord); -SUNDIALS_EXPORT int MRIStepSetInterpolantType(void* arkode_mem, int itype); -SUNDIALS_EXPORT int MRIStepSetInterpolantDegree(void* arkode_mem, int degree); -SUNDIALS_EXPORT int MRIStepSetDenseOrder(void* arkode_mem, int dord); -SUNDIALS_EXPORT int MRIStepSetNonlinearSolver(void* arkode_mem, - SUNNonlinearSolver NLS); -SUNDIALS_EXPORT int MRIStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fs); -SUNDIALS_EXPORT int MRIStepSetLinear(void* arkode_mem, int timedepend); -SUNDIALS_EXPORT int MRIStepSetNonlinear(void* arkode_mem); SUNDIALS_EXPORT int MRIStepSetCoupling(void* arkode_mem, MRIStepCoupling MRIC); -SUNDIALS_EXPORT int MRIStepSetAdaptController(void* arkode_mem, - SUNAdaptController C); -SUNDIALS_EXPORT int MRIStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); -SUNDIALS_EXPORT int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown); -SUNDIALS_EXPORT int MRIStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); -SUNDIALS_EXPORT int MRIStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); -SUNDIALS_EXPORT int MRIStepSetLSetupFrequency(void* arkode_mem, int msbp); -SUNDIALS_EXPORT int MRIStepSetPredictorMethod(void* arkode_mem, int method); -SUNDIALS_EXPORT int MRIStepSetMaxNonlinIters(void* arkode_mem, int maxcor); -SUNDIALS_EXPORT int MRIStepSetNonlinConvCoef(void* arkode_mem, - sunrealtype nlscoef); -SUNDIALS_EXPORT int MRIStepSetMaxHnilWarns(void* arkode_mem, int mxhnil); -SUNDIALS_EXPORT int MRIStepSetStopTime(void* arkode_mem, sunrealtype tstop); -SUNDIALS_EXPORT int MRIStepSetInterpolateStopTime(void* arkode_mem, - sunbooleantype interp); -SUNDIALS_EXPORT int MRIStepClearStopTime(void* arkode_mem); -SUNDIALS_EXPORT int MRIStepSetFixedStep(void* arkode_mem, sunrealtype hsfixed); -SUNDIALS_EXPORT int MRIStepSetRootDirection(void* arkode_mem, int* rootdir); -SUNDIALS_EXPORT int MRIStepSetNoInactiveRootWarn(void* arkode_mem); -SUNDIALS_EXPORT int MRIStepSetUserData(void* arkode_mem, void* user_data); -SUNDIALS_EXPORT int MRIStepSetMaxErrTestFails(void* arkode_mem, int maxnef); -SUNDIALS_EXPORT int MRIStepSetMaxConvFails(void* arkode_mem, int maxncf); -SUNDIALS_EXPORT int MRIStepSetConstraints(void* arkode_mem, N_Vector constraints); -SUNDIALS_EXPORT int MRIStepSetMaxNumConstrFails(void* arkode_mem, int maxfails); -SUNDIALS_EXPORT int MRIStepSetInitStep(void* arkode_mem, sunrealtype hin); -SUNDIALS_EXPORT int MRIStepSetPostprocessStepFn(void* arkode_mem, - ARKPostProcessFn ProcessStep); -SUNDIALS_EXPORT int MRIStepSetPostprocessStageFn(void* arkode_mem, - ARKPostProcessFn ProcessStage); SUNDIALS_EXPORT int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn); SUNDIALS_EXPORT int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn); -SUNDIALS_EXPORT int MRIStepSetStagePredictFn(void* arkode_mem, - ARKStagePredictFn PredictStage); -SUNDIALS_EXPORT int MRIStepSetDeduceImplicitRhs(void* arkode_mem, - sunbooleantype deduce); SUNDIALS_EXPORT int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor); - -/* Linear solver interface optional input functions -- must be called - AFTER MRIStepSetLinearSolver */ -SUNDIALS_EXPORT int MRIStepSetJacFn(void* arkode_mem, ARKLsJacFn jac); -SUNDIALS_EXPORT int MRIStepSetJacEvalFrequency(void* arkode_mem, long int msbj); -SUNDIALS_EXPORT int MRIStepSetLinearSolutionScaling(void* arkode_mem, - sunbooleantype onoff); -SUNDIALS_EXPORT int MRIStepSetEpsLin(void* arkode_mem, sunrealtype eplifac); -SUNDIALS_EXPORT int MRIStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac); -SUNDIALS_EXPORT int MRIStepSetPreconditioner(void* arkode_mem, - ARKLsPrecSetupFn psetup, - ARKLsPrecSolveFn psolve); -SUNDIALS_EXPORT int MRIStepSetJacTimes(void* arkode_mem, - ARKLsJacTimesSetupFn jtsetup, - ARKLsJacTimesVecFn jtimes); -SUNDIALS_EXPORT int MRIStepSetJacTimesRhsFn(void* arkode_mem, - ARKRhsFn jtimesRhsFn); -SUNDIALS_EXPORT int MRIStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys); - -/* Integrate the ODE over an interval in t */ -SUNDIALS_EXPORT int MRIStepEvolve(void* arkode_mem, sunrealtype tout, - N_Vector yout, sunrealtype* tret, int itask); - -/* Computes the kth derivative of the y function at time t */ -SUNDIALS_EXPORT int MRIStepGetDky(void* arkode_mem, sunrealtype t, int k, - N_Vector dky); - -/* Utility function to update/compute y based on zcor */ -SUNDIALS_EXPORT int MRIStepComputeState(void* arkode_mem, N_Vector zcor, - N_Vector z); - -/* Utility functions to reset/get accumulated temporal error estimate */ -SUNDIALS_EXPORT int MRIStepSetAccumulatedErrorType(void* arkode_mem, - int accum_type); -SUNDIALS_EXPORT int MRIStepResetAccumulatedError(void* arkode_mem); -SUNDIALS_EXPORT int MRIStepGetAccumulatedError(void* arkode_mem, - sunrealtype* accum_error); - -/* Utility functions to reset/get accumulated temporal error estimate */ -SUNDIALS_EXPORT int MRIStepSetAccumulatedErrorType(void* arkode_mem, - int accum_type); -SUNDIALS_EXPORT int MRIStepResetAccumulatedError(void* arkode_mem); -SUNDIALS_EXPORT int MRIStepGetAccumulatedError(void* arkode_mem, - sunrealtype* accum_error); +SUNDIALS_EXPORT int MRIStepSetAdaptController(void* arkode_mem, + SUNAdaptController C); /* Optional output functions */ -SUNDIALS_EXPORT int MRIStepGetNumExpSteps(void* arkode_mem, long int* expsteps); -SUNDIALS_EXPORT int MRIStepGetNumAccSteps(void* arkode_mem, long int* accsteps); -SUNDIALS_EXPORT int MRIStepGetNumStepAttempts(void* arkode_mem, - long int* step_attempts); SUNDIALS_EXPORT int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, long int* nfsi_evals); -SUNDIALS_EXPORT int MRIStepGetNumLinSolvSetups(void* arkode_mem, - long int* nlinsetups); -SUNDIALS_EXPORT int MRIStepGetNumErrTestFails(void* arkode_mem, - long int* netfails); SUNDIALS_EXPORT int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC); -SUNDIALS_EXPORT int MRIStepGetEstLocalErrors(void* arkode_mem, N_Vector ele); -SUNDIALS_EXPORT int MRIStepGetWorkSpace(void* arkode_mem, long int* lenrw, - long int* leniw); -SUNDIALS_EXPORT int MRIStepGetNumSteps(void* arkode_mem, long int* nssteps); -SUNDIALS_EXPORT int MRIStepGetActualInitStep(void* arkode_mem, - sunrealtype* hinused); -SUNDIALS_EXPORT int MRIStepGetLastStep(void* arkode_mem, sunrealtype* hlast); -SUNDIALS_EXPORT int MRIStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); -SUNDIALS_EXPORT int MRIStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); -SUNDIALS_EXPORT int MRIStepGetCurrentState(void* arkode_mem, N_Vector* state); -SUNDIALS_EXPORT int MRIStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma); -SUNDIALS_EXPORT int MRIStepGetTolScaleFactor(void* arkode_mem, - sunrealtype* tolsfac); -SUNDIALS_EXPORT int MRIStepGetErrWeights(void* arkode_mem, N_Vector eweight); -SUNDIALS_EXPORT int MRIStepGetNumGEvals(void* arkode_mem, long int* ngevals); -SUNDIALS_EXPORT int MRIStepGetRootInfo(void* arkode_mem, int* rootsfound); -SUNDIALS_EXPORT int MRIStepGetNumConstrFails(void* arkode_mem, - long int* nconstrfails); SUNDIALS_EXPORT int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag); -SUNDIALS_EXPORT int MRIStepGetUserData(void* arkode_mem, void** user_data); -SUNDIALS_EXPORT int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, - SUNOutputFormat fmt); -SUNDIALS_EXPORT char* MRIStepGetReturnFlagName(long int flag); - -SUNDIALS_EXPORT int MRIStepWriteParameters(void* arkode_mem, FILE* fp); - -SUNDIALS_EXPORT int MRIStepWriteCoupling(void* arkode_mem, FILE* fp); - -/* Nonlinear solver optional output functions */ -SUNDIALS_EXPORT int MRIStepGetNonlinearSystemData( - void* arkode_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, - N_Vector* F, sunrealtype* gamma, N_Vector* sdata, void** user_data); -SUNDIALS_EXPORT int MRIStepGetNumNonlinSolvIters(void* arkode_mem, - long int* nniters); -SUNDIALS_EXPORT int MRIStepGetNumNonlinSolvConvFails(void* arkode_mem, - long int* nnfails); -SUNDIALS_EXPORT int MRIStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, - long int* nnfails); -SUNDIALS_EXPORT int MRIStepGetNumStepSolveFails(void* arkode_mem, - long int* nncfails); - -/* Linear solver optional output functions */ -SUNDIALS_EXPORT int MRIStepGetJac(void* arkode_mem, SUNMatrix* J); -SUNDIALS_EXPORT int MRIStepGetJacTime(void* arkode_mem, sunrealtype* t_J); -SUNDIALS_EXPORT int MRIStepGetJacNumSteps(void* arkode_mem, long* nst_J); -SUNDIALS_EXPORT int MRIStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, - long int* leniwLS); -SUNDIALS_EXPORT int MRIStepGetNumJacEvals(void* arkode_mem, long int* njevals); -SUNDIALS_EXPORT int MRIStepGetNumPrecEvals(void* arkode_mem, long int* npevals); -SUNDIALS_EXPORT int MRIStepGetNumPrecSolves(void* arkode_mem, long int* npsolves); -SUNDIALS_EXPORT int MRIStepGetNumLinIters(void* arkode_mem, long int* nliters); -SUNDIALS_EXPORT int MRIStepGetNumLinConvFails(void* arkode_mem, - long int* nlcfails); -SUNDIALS_EXPORT int MRIStepGetNumJTSetupEvals(void* arkode_mem, - long int* njtsetups); -SUNDIALS_EXPORT int MRIStepGetNumJtimesEvals(void* arkode_mem, - long int* njvevals); -SUNDIALS_EXPORT int MRIStepGetNumLinRhsEvals(void* arkode_mem, - long int* nfevalsLS); -SUNDIALS_EXPORT int MRIStepGetLastLinFlag(void* arkode_mem, long int* flag); - -SUNDIALS_EXPORT char* MRIStepGetLinReturnFlagName(long int flag); - -/* Free function */ -SUNDIALS_EXPORT void MRIStepFree(void** arkode_mem); - -/* Output the MRIStep memory structure (useful when debugging) */ -SUNDIALS_EXPORT void MRIStepPrintMem(void* arkode_mem, FILE* outfile); /* Custom inner stepper functions */ SUNDIALS_EXPORT int MRIStepInnerStepper_Create(SUNContext sunctx, MRIStepInnerStepper* stepper); - SUNDIALS_EXPORT int MRIStepInnerStepper_Free(MRIStepInnerStepper* stepper); - SUNDIALS_EXPORT int MRIStepInnerStepper_SetContent(MRIStepInnerStepper stepper, void* content); - SUNDIALS_EXPORT int MRIStepInnerStepper_GetContent(MRIStepInnerStepper stepper, void** content); - SUNDIALS_EXPORT int MRIStepInnerStepper_SetEvolveFn(MRIStepInnerStepper stepper, MRIStepInnerEvolveFn fn); - 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_SetFixedStepFn( MRIStepInnerStepper stepper, MRIStepInnerSetFixedStep 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( MRIStepInnerStepper stepper, sunrealtype* tshift, sunrealtype* tscale, N_Vector** forcing, int* nforcing); +/* -------------------------------------------------------------------------- + * Deprecated Functions -- all are superseded by shared ARKODE-level routines + * -------------------------------------------------------------------------- */ + +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResize instead") +int MRIStepResize(void* arkode_mem, N_Vector ynew, sunrealtype t0, + ARKVecResizeFn resize, void* resize_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeReset instead") +int MRIStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSStolerances instead") +int MRIStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSVtolerances instead") +int MRIStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWFtolerances instead") +int MRIStepWFtolerances(void* arkode_mem, ARKEwtFn efun); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinearSolver instead") +int MRIStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeRootInit instead") +int MRIStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDefaults instead") +int MRIStepSetDefaults(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetOrder instead") +int MRIStepSetOrder(void* arkode_mem, int ord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantType instead") +int MRIStepSetInterpolantType(void* arkode_mem, int itype); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int MRIStepSetInterpolantDegree(void* arkode_mem, int degree); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int MRIStepSetDenseOrder(void* arkode_mem, int dord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinearSolver instead") +int MRIStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNlsRhsFn instead") +int MRIStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fs); +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") +int MRIStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinCRDown instead") +int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinRDiv instead") +int MRIStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDeltaGammaMax instead") +int MRIStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLSetupFrequency instead") +int MRIStepSetLSetupFrequency(void* arkode_mem, int msbp); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPredictorMethod instead") +int MRIStepSetPredictorMethod(void* arkode_mem, int method); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNonlinIters instead") +int MRIStepSetMaxNonlinIters(void* arkode_mem, int maxcor); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNonlinConvCoef instead") +int MRIStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxHnilWarns instead") +int MRIStepSetMaxHnilWarns(void* arkode_mem, int mxhnil); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolateStopTime instead") +int MRIStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp); +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") +int MRIStepSetFixedStep(void* arkode_mem, sunrealtype hsfixed); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRootDirection instead") +int MRIStepSetRootDirection(void* arkode_mem, int* rootdir); +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") +int MRIStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead") +int MRIStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStagePredictFn instead") +int MRIStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDeduceImplicitRhs instead") +int MRIStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacFn instead") +int MRIStepSetJacFn(void* arkode_mem, ARKLsJacFn jac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacEvalFrequency instead") +int MRIStepSetJacEvalFrequency(void* arkode_mem, long int msbj); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinearSolutionScaling instead") +int MRIStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetEpsLin instead") +int MRIStepSetEpsLin(void* arkode_mem, sunrealtype eplifac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLSNormFactor instead") +int MRIStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPreconditioner instead") +int MRIStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, + ARKLsPrecSolveFn psolve); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacTimes instead") +int MRIStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, + ARKLsJacTimesVecFn jtimes); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetJacTimesRhsFn instead") +int MRIStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetLinSysFn instead") +int MRIStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeEvolve instead") +int MRIStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetDky instead") +int MRIStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeComputeState instead") +int MRIStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z); +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") +int MRIStepGetNumSteps(void* arkode_mem, long int* nssteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use MRIStepGetLARKode instead") +int MRIStepGetLastStep(void* arkode_mem, sunrealtype* hlast); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead") +int MRIStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentState instead") +int MRIStepGetCurrentState(void* arkode_mem, N_Vector* state); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentGamma instead") +int MRIStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetTolScaleFactor instead") +int MRIStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetErrWeights instead") +int MRIStepGetErrWeights(void* arkode_mem, N_Vector eweight); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumGEvals instead") +int MRIStepGetNumGEvals(void* arkode_mem, long int* ngevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetRootInfo instead") +int MRIStepGetRootInfo(void* arkode_mem, int* rootsfound); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetUserData instead") +int MRIStepGetUserData(void* arkode_mem, void** user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintAllStats instead") +int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetReturnFlagName instead") +char* MRIStepGetReturnFlagName(long int flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWriteParameters instead") +int MRIStepWriteParameters(void* arkode_mem, FILE* fp); +SUNDIALS_DEPRECATED_EXPORT_MSG( + "use MRIStepGetCurrentCoupling and MRIStepCoupling_Write instead") +int MRIStepWriteCoupling(void* arkode_mem, FILE* fp); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNonlinearSystemData instead") +int MRIStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* F, + sunrealtype* gamma, N_Vector* sdata, + void** user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumNonlinSolvIters instead") +int MRIStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumNonlinSolvConvFails instead") +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") +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") +int MRIStepGetJacNumSteps(void* arkode_mem, long* nst_J); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLinWorkSpace instead") +int MRIStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, + long int* leniwLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumJacEvals instead") +int MRIStepGetNumJacEvals(void* arkode_mem, long int* njevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumPrecEvals instead") +int MRIStepGetNumPrecEvals(void* arkode_mem, long int* npevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumPrecSolves instead") +int MRIStepGetNumPrecSolves(void* arkode_mem, long int* npsolves); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinIters instead") +int MRIStepGetNumLinIters(void* arkode_mem, long int* nliters); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinConvFails instead") +int MRIStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumJTSetupEvals instead") +int MRIStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumJtimesEvals instead") +int MRIStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumLinRhsEvals instead") +int MRIStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastLinFlag instead") +int MRIStepGetLastLinFlag(void* arkode_mem, long int* flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLinReturnFlagName instead") +char* MRIStepGetLinReturnFlagName(long int flag); +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); + #ifdef __cplusplus } #endif diff --git a/include/arkode/arkode_sprkstep.h b/include/arkode/arkode_sprkstep.h index a8f6c3a4df..3e4519cd40 100644 --- a/include/arkode/arkode_sprkstep.h +++ b/include/arkode/arkode_sprkstep.h @@ -11,7 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End * ----------------------------------------------------------------- - * This is the header file for the ARKode SPRKStep module. + * This is the header file for the ARKODE SPRKStep module. * -----------------------------------------------------------------*/ #ifndef _ARKODE_SPRKSTEP_H @@ -41,74 +41,91 @@ static const int SPRKSTEP_DEFAULT_10 = ARKODE_SPRK_SOFRONIOU_10_36; * Exported Functions * ------------------- */ -/* Create, Resize, and Reinitialization functions */ +/* Creation and Reinitialization functions */ SUNDIALS_EXPORT void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, SUNContext sunctx); - SUNDIALS_EXPORT int SPRKStepReInit(void* arkode_mem, ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0); -SUNDIALS_EXPORT int SPRKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); - -/* Rootfinding functions */ - -/* Rootfinding initialization */ -SUNDIALS_EXPORT int SPRKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); - /* Optional input functions -- must be called AFTER SPRKStepCreate */ -SUNDIALS_EXPORT int SPRKStepSetDefaults(void* arkode_mem); SUNDIALS_EXPORT int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff); SUNDIALS_EXPORT int SPRKStepSetMethod(void* arkode_mem, ARKodeSPRKTable sprk_storage); SUNDIALS_EXPORT int SPRKStepSetMethodName(void* arkode_mem, const char* method); -SUNDIALS_EXPORT int SPRKStepSetOrder(void* arkode_mem, int maxord); -SUNDIALS_EXPORT int SPRKStepSetInterpolantType(void* arkode_mem, int itype); -SUNDIALS_EXPORT int SPRKStepSetInterpolantDegree(void* arkode_mem, int degree); -SUNDIALS_EXPORT int SPRKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); -SUNDIALS_EXPORT int SPRKStepSetStopTime(void* arkode_mem, sunrealtype tstop); -SUNDIALS_EXPORT int SPRKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); -SUNDIALS_EXPORT int SPRKStepSetUserData(void* arkode_mem, void* user_data); - -SUNDIALS_EXPORT int SPRKStepSetPostprocessStepFn(void* arkode_mem, - ARKPostProcessFn ProcessStep); -SUNDIALS_EXPORT int SPRKStepSetPostprocessStageFn(void* arkode_mem, - ARKPostProcessFn ProcessStage); - -/* Integrate the ODE over an interval in t */ -SUNDIALS_EXPORT int SPRKStepEvolve(void* arkode_mem, sunrealtype tout, - N_Vector yout, sunrealtype* tret, int itask); - -/* Computes the kth derivative of the y function at time t */ -SUNDIALS_EXPORT int SPRKStepGetDky(void* arkode_mem, sunrealtype t, int k, - N_Vector dky); /* Optional output functions */ -SUNDIALS_EXPORT char* SPRKStepGetReturnFlagName(long int flag); SUNDIALS_EXPORT int SPRKStepGetCurrentMethod(void* arkode_mem, ARKodeSPRKTable* sprk_storage); -SUNDIALS_EXPORT int SPRKStepGetCurrentState(void* arkode_mem, N_Vector* state); -SUNDIALS_EXPORT int SPRKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); -SUNDIALS_EXPORT int SPRKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); -SUNDIALS_EXPORT int SPRKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); SUNDIALS_EXPORT int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2); -SUNDIALS_EXPORT int SPRKStepGetNumStepAttempts(void* arkode_mem, - long int* step_attempts); -SUNDIALS_EXPORT int SPRKStepGetNumSteps(void* arkode_mem, long int* nsteps); -SUNDIALS_EXPORT int SPRKStepGetRootInfo(void* arkode_mem, int* rootsfound); -SUNDIALS_EXPORT int SPRKStepGetUserData(void* arkode_mem, void** user_data); -SUNDIALS_EXPORT int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, - SUNOutputFormat fmt); -SUNDIALS_EXPORT int SPRKStepWriteParameters(void* arkode_mem, FILE* fp); - -/* Grouped optional output functions */ -SUNDIALS_EXPORT int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps, - sunrealtype* hinused, sunrealtype* hlast, - sunrealtype* hcur, sunrealtype* tcur); -/* Free function */ -SUNDIALS_EXPORT void SPRKStepFree(void** arkode_mem); +/* -------------------------------------------------------------------------- + * Deprecated Functions -- all are superseded by shared ARKODE-level routines + * -------------------------------------------------------------------------- */ + +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeReset instead") +int SPRKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeRootInit instead") +int SPRKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetRootDirection instead") +int SPRKStepSetRootDirection(void* arkode_mem, int* rootdir); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNoInactiveRootWarn instead") +int SPRKStepSetNoInactiveRootWarn(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetDefaults instead") +int SPRKStepSetDefaults(void* arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetOrder instead") +int SPRKStepSetOrder(void* arkode_mem, int maxord); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantType instead") +int SPRKStepSetInterpolantType(void* arkode_mem, int itype); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolantDegree instead") +int SPRKStepSetInterpolantDegree(void* arkode_mem, int degree); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumSteps instead") +int SPRKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStopTime instead") +int SPRKStepSetStopTime(void* arkode_mem, sunrealtype tstop); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStep instead") +int SPRKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetUserData instead") +int SPRKStepSetUserData(void* arkode_mem, void* user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStepFn instead") +int SPRKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead") +int SPRKStepSetPostprocessStageFn(void* arkode_mem, + ARKPostProcessFn ProcessStage); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeEvolve instead") +int SPRKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetDky instead") +int SPRKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetReturnFlagName instead") +char* SPRKStepGetReturnFlagName(long int flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentState instead") +int SPRKStepGetCurrentState(void* arkode_mem, N_Vector* state); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentStep instead") +int SPRKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead") +int SPRKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastStep instead") +int SPRKStepGetLastStep(void* arkode_mem, sunrealtype* hlast); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumStepAttempts instead") +int SPRKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumSteps instead") +int SPRKStepGetNumSteps(void* arkode_mem, long int* nsteps); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetRootInfo instead") +int SPRKStepGetRootInfo(void* arkode_mem, int* rootsfound); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetUserData instead") +int SPRKStepGetUserData(void* arkode_mem, void** user_data); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodePrintAllStats instead") +int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeWriteParameters instead") +int SPRKStepWriteParameters(void* arkode_mem, FILE* fp); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetStepStats instead") +int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps, + sunrealtype* hinused, sunrealtype* hlast, + sunrealtype* hcur, sunrealtype* tcur); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead") +void SPRKStepFree(void** arkode_mem); #ifdef __cplusplus } diff --git a/include/arkode/arkode_xbraid.h b/include/arkode/arkode_xbraid.h index e3cf93c213..6ce4df639d 100644 --- a/include/arkode/arkode_xbraid.h +++ b/include/arkode/arkode_xbraid.h @@ -57,13 +57,19 @@ SUNDIALS_EXPORT int ARKBraid_SetAccessFn(braid_App app, braid_PtFcnAccess access SUNDIALS_EXPORT int ARKBraid_GetVecTmpl(braid_App app, N_Vector* tmpl); -SUNDIALS_EXPORT int ARKBraid_GetARKStepMem(braid_App app, void** arkode_mem); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKBraid_GetARKodeMem instead") +int ARKBraid_GetARKStepMem(braid_App app, void** arkode_mem); + +SUNDIALS_EXPORT int ARKBraid_GetARKodeMem(braid_App app, void** arkode_mem); SUNDIALS_EXPORT int ARKBraid_GetUserData(braid_App app, void** user_data); SUNDIALS_EXPORT int ARKBraid_GetLastBraidFlag(braid_App app, int* last_flag); -SUNDIALS_EXPORT int ARKBraid_GetLastARKStepFlag(braid_App app, int* last_flag); +SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKBraid_GetLastARKodeFlag instead") +int ARKBraid_GetLastARKStepFlag(braid_App app, int* last_flag); + +SUNDIALS_EXPORT int ARKBraid_GetLastARKodeFlag(braid_App app, int* last_flag); SUNDIALS_EXPORT int ARKBraid_GetSolution(braid_App app, sunrealtype* tout, N_Vector yout); diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 7198709db2..fed6aa44a8 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -17,9 +17,6 @@ * use. *--------------------------------------------------------------*/ -/*=============================================================== - Import Header Files - ===============================================================*/ #include "arkode/arkode.h" #include @@ -39,171 +36,19 @@ #include "sundials_utils.h" /*=============================================================== - EXPORTED FUNCTIONS + Exported functions ===============================================================*/ /*--------------------------------------------------------------- - arkCreate: - - arkCreate creates an internal memory block for a problem to - be solved by a time step module built on ARKODE. If successful, - arkCreate returns a pointer to the problem memory. If an - initialization error occurs, arkCreate prints an error message - to standard err and returns NULL. - ---------------------------------------------------------------*/ -ARKodeMem arkCreate(SUNContext sunctx) -{ - int iret; - long int lenrw, leniw; - ARKodeMem ark_mem; - - if (!sunctx) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_NULL_SUNCTX); - return (NULL); - } - - ark_mem = NULL; - ark_mem = (ARKodeMem)malloc(sizeof(struct ARKodeMemRec)); - if (ark_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_ARKMEM_FAIL); - return (NULL); - } - - /* Zero out ark_mem */ - memset(ark_mem, 0, sizeof(struct ARKodeMemRec)); - - /* Set the context */ - ark_mem->sunctx = sunctx; - - /* Set uround */ - ark_mem->uround = SUN_UNIT_ROUNDOFF; - - /* Initialize time step module to NULL */ - ark_mem->step_attachlinsol = NULL; - ark_mem->step_attachmasssol = NULL; - ark_mem->step_disablelsetup = NULL; - ark_mem->step_disablemsetup = NULL; - ark_mem->step_getlinmem = NULL; - ark_mem->step_getmassmem = NULL; - ark_mem->step_getimplicitrhs = NULL; - ark_mem->step_mmult = NULL; - ark_mem->step_getgammas = NULL; - ark_mem->step_init = NULL; - ark_mem->step_fullrhs = NULL; - ark_mem->step = NULL; - ark_mem->step_mem = NULL; - - /* Initialize root finding variables */ - ark_mem->root_mem = NULL; - - /* Initialize inequality constraints variables */ - ark_mem->constraintsSet = SUNFALSE; - ark_mem->constraints = NULL; - - /* Initialize relaxation variables */ - ark_mem->relax_enabled = SUNFALSE; - ark_mem->relax_mem = NULL; - - /* Initialize lrw and liw */ - ark_mem->lrw = 18; - ark_mem->liw = 41; /* fcn/data ptr, int, long int, sunindextype, sunbooleantype */ - - /* No mallocs have been done yet */ - ark_mem->VabstolMallocDone = SUNFALSE; - ark_mem->VRabstolMallocDone = SUNFALSE; - ark_mem->MallocDone = SUNFALSE; - - /* No user-supplied step postprocessing function yet */ - ark_mem->ProcessStep = NULL; - ark_mem->ps_data = NULL; - - /* No user-supplied stage postprocessing function yet */ - ark_mem->ProcessStage = NULL; - - /* No user_data pointer yet */ - ark_mem->user_data = NULL; - - /* Allocate step adaptivity structure and note storage */ - ark_mem->hadapt_mem = arkAdaptInit(); - if (ark_mem->hadapt_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Allocation of step adaptivity structure failed"); - arkFree((void**)&ark_mem); - return (NULL); - } - ark_mem->lrw += ARK_ADAPT_LRW; - ark_mem->liw += ARK_ADAPT_LIW; - - /* Allocate default step controller (PID) and note storage */ - ark_mem->hadapt_mem->hcontroller = SUNAdaptController_PID(sunctx); - if (ark_mem->hadapt_mem->hcontroller == NULL) - { - arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Allocation of step controller object failed"); - arkFree((void**)&ark_mem); - return (NULL); - } - ark_mem->hadapt_mem->owncontroller = SUNTRUE; - (void)SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, - &leniw); - ark_mem->lrw += lenrw; - ark_mem->liw += leniw; - - /* Initialize the interpolation structure to NULL */ - ark_mem->interp = NULL; - ark_mem->interp_type = -1; - - /* Initially, rwt should point to ewt */ - ark_mem->rwt_is_ewt = SUNTRUE; - - /* Indicate that calling the full RHS function is not required, this flag is - updated to SUNTRUE by the interpolation module initialization function - and/or the stepper initialization function in arkInitialSetup */ - ark_mem->call_fullrhs = SUNFALSE; - - /* Indicate that the problem needs to be initialized */ - ark_mem->initsetup = SUNTRUE; - ark_mem->init_type = FIRST_INIT; - ark_mem->firststage = SUNTRUE; - ark_mem->initialized = SUNFALSE; - - /* Initial step size has not been determined yet */ - ark_mem->h = ZERO; - ark_mem->h0u = ZERO; - - /* Accumulated error estimation strategy */ - ark_mem->AccumErrorType = -1; - ark_mem->AccumError = ZERO; - - /* Set default values for integrator optional inputs */ - iret = arkSetDefaults(ark_mem); - if (iret != ARK_SUCCESS) - { - arkProcessError(NULL, 0, __LINE__, __func__, __FILE__, - "Error setting default solver options"); - arkFree((void**)&ark_mem); - return (NULL); - } - - /* Return pointer to ARKODE memory block */ - return (ark_mem); -} - -/*--------------------------------------------------------------- - arkResize: + ARKodeResize: - arkResize re-initializes ARKODE's memory for a problem with a + ARKodeResize re-initializes ARKODE's memory for a problem with a changing vector size. It is assumed that the problem dynamics before and after the vector resize will be comparable, so that - all time-stepping heuristics prior to calling arkResize + all time-stepping heuristics prior to calling ARKodeResize remain valid after the call. If instead the dynamics should be re-calibrated, the ARKODE memory structure should be deleted - with a call to *StepFree, and re-created with a call to + with a call to ARKodeFree, and re-created with a call to *StepCreate. To aid in the vector-resize operation, the user can supply a @@ -231,20 +76,22 @@ ARKodeMem arkCreate(SUNContext sunctx) The return value is ARK_SUCCESS = 0 if no errors occurred, or a negative value otherwise. ---------------------------------------------------------------*/ -int arkResize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +int ARKodeResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { sunbooleantype resizeOK; sunindextype lrw1, liw1, lrw_diff, liw_diff; int retval; + ARKodeMem ark_mem; /* Check ark_mem */ - if (ark_mem == NULL) + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; /* Check if ark_mem was allocated */ if (ark_mem->MallocDone == SUNFALSE) @@ -331,37 +178,81 @@ int arkResize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, ark_mem->init_type = RESIZE_INIT; ark_mem->firststage = SUNTRUE; + /* Call the stepper-specific resize (if provided) */ + if (ark_mem->step_resize) + { + return (ark_mem->step_resize(ark_mem, y0, hscale, t0, resize, resize_data)); + } + /* Problem has been successfully re-sized */ return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSStolerances, arkSVtolerances, arkWFtolerances: + ARKodeReset: + + This routine resets an ARKode module to solve the same + problem from the given time with the input state (all counter + values are retained). + ---------------------------------------------------------------*/ +int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +{ + ARKodeMem ark_mem; + int retval; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Reset main ARKODE infrastructure */ + retval = arkInit(ark_mem, tR, yR, RESET_INIT); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "ARKode reset failure"); + return (retval); + } + + /* Call stepper routine to perform remaining reset operations (if provided) */ + if (ark_mem->step_reset) { return (ark_mem->step_reset(ark_mem, tR, yR)); } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSStolerances, ARKodeSVtolerances, ARKodeWFtolerances: These functions specify the integration tolerances. One of them - SHOULD be called before the first call to arkEvolve; otherwise + SHOULD be called before the first call to ARKodeEvolve; otherwise default values of reltol=1e-4 and abstol=1e-9 will be used, which may be entirely incorrect for a specific problem. - arkSStolerances specifies scalar relative and absolute + ARKodeSStolerances specifies scalar relative and absolute tolerances. - arkSVtolerances specifies scalar relative tolerance and a + ARKodeSVtolerances specifies scalar relative tolerance and a vector absolute tolerance (a potentially different absolute tolerance for each vector component). - arkWFtolerances specifies a user-provides function (of type + ARKodeWFtolerances specifies a user-provides function (of type ARKEwtFn) which will be called to set the error weight vector. ---------------------------------------------------------------*/ -int arkSStolerances(ARKodeMem ark_mem, sunrealtype reltol, sunrealtype abstol) +int ARKodeSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) { - /* Check inputs */ - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + + /* Check inputs */ if (ark_mem->MallocDone == SUNFALSE) { arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, @@ -397,18 +288,22 @@ int arkSStolerances(ARKodeMem ark_mem, sunrealtype reltol, sunrealtype abstol) return (ARK_SUCCESS); } -int arkSVtolerances(ARKodeMem ark_mem, sunrealtype reltol, N_Vector abstol) +int ARKodeSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) { /* local variables */ sunrealtype abstolmin; - /* Check inputs */ - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + + /* Check inputs */ if (ark_mem->MallocDone == SUNFALSE) { arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, @@ -467,14 +362,18 @@ int arkSVtolerances(ARKodeMem ark_mem, sunrealtype reltol, N_Vector abstol) return (ARK_SUCCESS); } -int arkWFtolerances(ARKodeMem ark_mem, ARKEwtFn efun) +int ARKodeWFtolerances(void* arkode_mem, ARKEwtFn efun) { - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + if (ark_mem->MallocDone == SUNFALSE) { arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, @@ -492,7 +391,7 @@ int arkWFtolerances(ARKodeMem ark_mem, ARKEwtFn efun) } /*--------------------------------------------------------------- - arkResStolerance, arkResVtolerance, arkResFtolerance: + ARKodeResStolerance, ARKodeResVtolerance, ARKodeResFtolerance: These functions specify the absolute residual tolerance. Specification of the absolute residual tolerance is only @@ -503,25 +402,37 @@ int arkWFtolerances(ARKodeMem ark_mem, ARKEwtFn efun) ARKODE; otherwise the default value of rabstol=1e-9 will be used, which may be entirely incorrect for a specific problem. - arkResStolerances specifies a scalar residual tolerance. + ARKodeResStolerances specifies a scalar residual tolerance. - arkResVtolerances specifies a vector residual tolerance + ARKodeResVtolerances specifies a vector residual tolerance (a potentially different absolute residual tolerance for each vector component). - arkResFtolerances specifies a user-provides function (of + ARKodeResFtolerances specifies a user-provides function (of type ARKRwtFn) which will be called to set the residual weight vector. ---------------------------------------------------------------*/ -int arkResStolerance(ARKodeMem ark_mem, sunrealtype rabstol) +int ARKodeResStolerance(void* arkode_mem, sunrealtype rabstol) { - /* Check inputs */ - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Check inputs */ if (ark_mem->MallocDone == SUNFALSE) { arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, @@ -563,18 +474,30 @@ int arkResStolerance(ARKodeMem ark_mem, sunrealtype rabstol) return (ARK_SUCCESS); } -int arkResVtolerance(ARKodeMem ark_mem, N_Vector rabstol) +int ARKodeResVtolerance(void* arkode_mem, N_Vector rabstol) { /* local variables */ sunrealtype rabstolmin; - /* Check inputs */ - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Check inputs */ if (ark_mem->MallocDone == SUNFALSE) { arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, @@ -639,14 +562,26 @@ int arkResVtolerance(ARKodeMem ark_mem, N_Vector rabstol) return (ARK_SUCCESS); } -int arkResFtolerance(ARKodeMem ark_mem, ARKRwtFn rfun) +int ARKodeResFtolerance(void* arkode_mem, ARKRwtFn rfun) { - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (ark_mem->MallocDone == SUNFALSE) { arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, @@ -677,17 +612,17 @@ int arkResFtolerance(ARKodeMem ark_mem, ARKRwtFn rfun) } /*--------------------------------------------------------------- - arkEvolve: + ARKodeEvolve: This routine is the main driver of ARKODE-based integrators. It integrates over a time interval defined by the user, by calling the time step module to do internal time steps. - The first time that arkEvolve is called for a successfully + The first time that ARKodeEvolve is called for a successfully initialized problem, it computes a tentative initial step size. - arkEvolve supports two modes as specified by itask: ARK_NORMAL and + ARKodeEvolve supports two modes as specified by itask: ARK_NORMAL and ARK_ONE_STEP. In the ARK_NORMAL mode, the solver steps until it reaches or passes tout and then interpolates to obtain y(tout). In the ARK_ONE_STEP mode, it takes one internal step @@ -698,8 +633,8 @@ int arkResFtolerance(ARKodeMem ark_mem, ARKRwtFn rfun) exactly the specified stop time, and hence interpolation of y(tout) is not required. ---------------------------------------------------------------*/ -int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask) +int ARKodeEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask) { long int nstloc; int retval, kflag, istate, ir; @@ -709,16 +644,18 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, sunrealtype dsm; int nflag, attempts, ncf, nef, constrfails; int relax_fails; + ARKodeMem ark_mem; /* Check and process inputs */ /* Check if ark_mem exists */ - if (ark_mem == NULL) + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; /* Check if ark_mem was allocated */ if (ark_mem->MallocDone == SUNFALSE) @@ -752,6 +689,9 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, return (ARK_ILL_INPUT); } + /* start profiler */ + SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); + /* store copy of itask if using root-finding */ if (ark_mem->root_mem != NULL) { @@ -769,7 +709,11 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, { ark_mem->tretlast = *tret = ark_mem->tcur; retval = arkInitialSetup(ark_mem, tout); - if (retval != ARK_SUCCESS) { return (retval); } + if (retval != ARK_SUCCESS) + { + SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); + return (retval); + } } /* perform stopping tests */ @@ -777,6 +721,7 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, { if (arkStopTests(ark_mem, tout, yout, tret, itask, &retval)) { + SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); return (retval); } } @@ -930,7 +875,7 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, ark_mem->nst_attempts++; #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG - SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::arkEvolve", + SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::ARKodeEvolve", "start-step", "step = %li, attempt = %i, h = %" RSYM ", tcur = %" RSYM, @@ -995,6 +940,7 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, /* unsuccessful step, if |h| = hmin, return ARK_ERR_FAILURE */ if (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM) { + SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); return (ARK_ERR_FAILURE); } @@ -1079,7 +1025,7 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, { if (ark_mem->tstopinterp) { - retval = arkGetDky(ark_mem, ark_mem->tstop, 0, yout); + retval = ARKodeGetDky(ark_mem, ark_mem->tstop, 0, yout); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -1108,7 +1054,7 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, /* In NORMAL mode, check if tout reached */ if ((itask == ARK_NORMAL) && (ark_mem->tcur - tout) * ark_mem->h >= ZERO) { - retval = arkGetDky(ark_mem, tout, 0, yout); + retval = ARKodeGetDky(ark_mem, tout, 0, yout); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, @@ -1134,11 +1080,13 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, } /* end looping for internal steps */ + /* stop profiler and return */ + SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); return (istate); } /*--------------------------------------------------------------- - arkGetDky: + ARKodeGetDky: This routine computes the k-th derivative of the interpolating polynomial at the time t and stores the result in the vector @@ -1150,25 +1098,29 @@ int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, the user through deg, unless higher-order derivatives are requested. - This function is called by arkEvolve with k=0 and t=tout to + This function is called by ARKodeEvolve with k=0 and t=tout to perform interpolation of outputs, but may also be called indirectly by the user via time step module *StepGetDky calls. Note: in all cases it will be called after ark_tcur has been updated to correspond with the end time of the last successful step. ---------------------------------------------------------------*/ -int arkGetDky(ARKodeMem ark_mem, sunrealtype t, int k, N_Vector dky) +int ARKodeGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) { sunrealtype s, tfuzz, tp, tn1; int retval; + ARKodeMem ark_mem; - /* Check all inputs for legality */ - if (ark_mem == NULL) + /* Check if ark_mem exists */ + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; + + /* Check all inputs for legality */ if (dky == NULL) { arkProcessError(ark_mem, ARK_BAD_DKY, __LINE__, __func__, __FILE__, @@ -1210,11 +1162,11 @@ int arkGetDky(ARKodeMem ark_mem, sunrealtype t, int k, N_Vector dky) } /*--------------------------------------------------------------- - arkFree: + ARKodeFree: This routine frees the ARKODE infrastructure memory. ---------------------------------------------------------------*/ -void arkFree(void** arkode_mem) +void ARKodeFree(void** arkode_mem) { ARKodeMem ark_mem; @@ -1222,6 +1174,9 @@ void arkFree(void** arkode_mem) ark_mem = (ARKodeMem)(*arkode_mem); + /* free the time-stepper module memory (if provided) */ + if (ark_mem->step_free) { ark_mem->step_free(ark_mem); } + /* free vector storage */ arkFreeVectors(ark_mem); @@ -1248,7 +1203,7 @@ void arkFree(void** arkode_mem) /* free the root-finding module */ if (ark_mem->root_mem != NULL) { - (void)arkRootFree(*arkode_mem); + (void)arkRootFree(ark_mem); ark_mem->root_mem = NULL; } @@ -1263,233 +1218,28 @@ void arkFree(void** arkode_mem) *arkode_mem = NULL; } -/*=============================================================== - Internal functions that may be replaced by the user - ===============================================================*/ - /*--------------------------------------------------------------- - arkRwtSet - - This routine is responsible for setting the residual weight - vector rwt, according to tol_type, as follows: - - (1) rwt[i] = 1 / (reltol * SUNRabs(M*ycur[i]) + rabstol), i=0,...,neq-1 - if tol_type = ARK_SS - (2) rwt[i] = 1 / (reltol * SUNRabs(M*ycur[i]) + rabstol[i]), i=0,...,neq-1 - if tol_type = ARK_SV - (3) unset if tol_type is any other value (occurs rwt=ewt) - - arkRwtSet returns 0 if rwt is successfully set as above to a - positive vector and -1 otherwise. In the latter case, rwt is - considered undefined. + ARKodePrintMem: - All the real work is done in the routines arkRwtSetSS, arkRwtSetSV. + This routine outputs the ark_mem structure to a specified file + pointer. ---------------------------------------------------------------*/ -int arkRwtSet(N_Vector y, N_Vector weight, void* data) +void ARKodePrintMem(void* arkode_mem, FILE* outfile) { ARKodeMem ark_mem; - N_Vector My; - int flag = 0; - /* data points to ark_mem here */ - ark_mem = (ARKodeMem)data; + /* Check if ark_mem exists */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return; + } + ark_mem = (ARKodeMem)arkode_mem; - /* return if rwt is just ewt */ - if (ark_mem->rwt_is_ewt) { return (0); } + /* if outfile==NULL, set it to stdout */ + if (outfile == NULL) { outfile = stdout; } - /* put M*y into ark_tempv1 */ - My = ark_mem->tempv1; - if (ark_mem->step_mmult != NULL) - { - flag = ark_mem->step_mmult((void*)ark_mem, y, My); - if (flag != ARK_SUCCESS) { return (ARK_MASSMULT_FAIL); } - } - else - { /* this condition should not apply, but just in case */ - N_VScale(ONE, y, My); - } - - /* call appropriate routine to fill rwt */ - switch (ark_mem->ritol) - { - case ARK_SS: flag = arkRwtSetSS(ark_mem, My, weight); break; - case ARK_SV: flag = arkRwtSetSV(ark_mem, My, weight); break; - } - - return (flag); -} - -/*=============================================================== - Private Helper Functions - ===============================================================*/ - -/*--------------------------------------------------------------- - arkInit: - - arkInit allocates and initializes memory for a problem. All - inputs are checked for errors. If any error occurs during - initialization, an error flag is returned. Otherwise, it returns - ARK_SUCCESS. This routine should be called by an ARKODE - timestepper module (not by the user). This routine must be - called prior to calling arkEvolve to evolve the problem. The - initialization type indicates if the values of internal counters - should be reinitialized (FIRST_INIT) or retained (RESET_INIT). - ---------------------------------------------------------------*/ -int arkInit(ARKodeMem ark_mem, sunrealtype t0, N_Vector y0, int init_type) -{ - sunbooleantype stepperOK, nvectorOK, allocOK; - int retval; - sunindextype lrw1, liw1; - - /* Check ark_mem */ - if (ark_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - - /* Check for legal input parameters */ - if (y0 == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_NULL_Y0); - return (ARK_ILL_INPUT); - } - - /* Check if reset was called before the first Evolve call */ - if (init_type == RESET_INIT && !(ark_mem->initialized)) - { - init_type = FIRST_INIT; - } - - /* Check if allocations have been done i.e., is this first init call */ - if (ark_mem->MallocDone == SUNFALSE) - { - /* Test if all required time stepper operations are implemented */ - stepperOK = arkCheckTimestepper(ark_mem); - if (!stepperOK) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Time stepper module is missing required functionality"); - return (ARK_ILL_INPUT); - } - - /* Test if all required vector operations are implemented */ - nvectorOK = arkCheckNvector(y0); - if (!nvectorOK) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_NVECTOR); - return (ARK_ILL_INPUT); - } - - /* Set space requirements for one N_Vector */ - if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } - else - { - lrw1 = 0; - liw1 = 0; - } - ark_mem->lrw1 = lrw1; - ark_mem->liw1 = liw1; - - /* Allocate the solver vectors (using y0 as a template) */ - allocOK = arkAllocVectors(ark_mem, y0); - if (!allocOK) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_MEM_FAIL); - return (ARK_MEM_FAIL); - } - - /* Create default Hermite interpolation module */ - if (!(ark_mem->interp)) - { - ark_mem->interp = arkInterpCreate_Hermite(ark_mem, ARK_INTERP_MAX_DEGREE); - if (ark_mem->interp == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to allocate interpolation module"); - return (ARK_MEM_FAIL); - } - ark_mem->interp_type = ARK_INTERP_HERMITE; - } - - /* All allocations are complete */ - ark_mem->MallocDone = SUNTRUE; - } - - /* All allocation and error checking is complete at this point */ - - /* Copy the input parameters into ARKODE state */ - ark_mem->tcur = t0; - ark_mem->tn = t0; - - /* Initialize yn */ - N_VScale(ONE, y0, ark_mem->yn); - ark_mem->fn_is_current = SUNFALSE; - - /* Clear any previous 'tstop' */ - ark_mem->tstopset = SUNFALSE; - - /* Initializations on (re-)initialization call, skip on reset */ - if (init_type == FIRST_INIT) - { - /* Counters */ - ark_mem->nst_attempts = 0; - ark_mem->nst = 0; - ark_mem->nhnil = 0; - ark_mem->ncfn = 0; - ark_mem->netf = 0; - ark_mem->nconstrfails = 0; - - /* Initial, old, and next step sizes */ - ark_mem->h0u = ZERO; - ark_mem->hold = ZERO; - ark_mem->next_h = ZERO; - - /* Tolerance scale factor */ - ark_mem->tolsf = ONE; - - /* Reset error controller object */ - retval = SUNAdaptController_Reset(ark_mem->hadapt_mem->hcontroller); - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, __FILE__, - "Unable to reset error controller object"); - return (ARK_CONTROLLER_ERR); - } - - /* Adaptivity counters */ - ark_mem->hadapt_mem->nst_acc = 0; - ark_mem->hadapt_mem->nst_exp = 0; - - /* Indicate that calling the full RHS function is not required, this flag is - updated to SUNTRUE by the interpolation module initialization function - and/or the stepper initialization function in arkInitialSetup */ - ark_mem->call_fullrhs = SUNFALSE; - - /* Indicate that initialization has not been done before */ - ark_mem->initialized = SUNFALSE; - } - - /* Indicate initialization is needed */ - ark_mem->initsetup = SUNTRUE; - ark_mem->init_type = init_type; - ark_mem->firststage = SUNTRUE; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - arkPrintMem: - - This routine outputs the ark_mem structure to a specified file - pointer. - ---------------------------------------------------------------*/ -void arkPrintMem(ARKodeMem ark_mem, FILE* outfile) -{ /* output general values */ fprintf(outfile, "itol = %i\n", ark_mem->itol); fprintf(outfile, "ritol = %i\n", ark_mem->ritol); @@ -1583,363 +1333,448 @@ void arkPrintMem(ARKodeMem ark_mem, FILE* outfile) fprintf(outfile, "constraints:\n"); N_VPrintFile(ark_mem->constraints, outfile); #endif + + /* Call stepper PrintMem function (if provided) */ + if (ark_mem->step_printmem) { ark_mem->step_printmem(ark_mem, outfile); } } +/*=============================================================== + Private internal functions + ===============================================================*/ + /*--------------------------------------------------------------- - arkCheckTimestepper: + arkCreate: - This routine checks if all required time stepper function - pointers have been supplied. If any of them is missing it - returns SUNFALSE. + arkCreate creates an internal memory block for a problem to + be solved by a time step module built on ARKODE. If successful, + arkCreate returns a pointer to the problem memory. If an + initialization error occurs, arkCreate prints an error message + to standard err and returns NULL. ---------------------------------------------------------------*/ -sunbooleantype arkCheckTimestepper(ARKodeMem ark_mem) +ARKodeMem arkCreate(SUNContext sunctx) { - if ((ark_mem->step_init == NULL) || (ark_mem->step == NULL) || - (ark_mem->step_mem == NULL)) + int iret; + long int lenrw, leniw; + ARKodeMem ark_mem; + + if (!sunctx) { - return (SUNFALSE); + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NULL_SUNCTX); + return (NULL); } - return (SUNTRUE); -} - -/*--------------------------------------------------------------- - arkCheckNvector: - This routine checks if all required vector operations are - present. If any of them is missing it returns SUNFALSE. - ---------------------------------------------------------------*/ -sunbooleantype arkCheckNvector(N_Vector tmpl) /* to be updated?? */ -{ - if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || - (tmpl->ops->nvlinearsum == NULL) || (tmpl->ops->nvconst == NULL) || - (tmpl->ops->nvdiv == NULL) || (tmpl->ops->nvscale == NULL) || - (tmpl->ops->nvabs == NULL) || (tmpl->ops->nvinv == NULL) || - (tmpl->ops->nvaddconst == NULL) || (tmpl->ops->nvmaxnorm == NULL) || - (tmpl->ops->nvwrmsnorm == NULL)) + ark_mem = NULL; + ark_mem = (ARKodeMem)malloc(sizeof(struct ARKodeMemRec)); + if (ark_mem == NULL) { - return (SUNFALSE); + arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_ARKMEM_FAIL); + return (NULL); } - else { return (SUNTRUE); } -} -/*--------------------------------------------------------------- - arkAllocVec and arkAllocVecArray: + /* Zero out ark_mem */ + memset(ark_mem, 0, sizeof(struct ARKodeMemRec)); - These routines allocate (respectively) single vector or a vector - array based on a template vector. If the target vector or vector - array already exists it is left alone; otherwise it is allocated - by cloning the input vector. + /* Set the context */ + ark_mem->sunctx = sunctx; - This routine also updates the optional outputs lrw and liw, which - are (respectively) the lengths of the overall ARKODE real and - integer work spaces. + /* Set uround */ + ark_mem->uround = SUN_UNIT_ROUNDOFF; - SUNTRUE is returned if the allocation is successful (or if the - target vector or vector array already exists) otherwise SUNFALSE - is retured. - ---------------------------------------------------------------*/ -sunbooleantype arkAllocVec(ARKodeMem ark_mem, N_Vector tmpl, N_Vector* v) -{ - /* allocate the new vector if necessary */ - if (*v == NULL) + /* Initialize time step module to NULL */ + ark_mem->step_attachlinsol = NULL; + ark_mem->step_attachmasssol = NULL; + ark_mem->step_disablelsetup = NULL; + ark_mem->step_disablemsetup = NULL; + ark_mem->step_getlinmem = NULL; + ark_mem->step_getmassmem = NULL; + ark_mem->step_getimplicitrhs = NULL; + ark_mem->step_mmult = NULL; + ark_mem->step_getgammas = NULL; + ark_mem->step_init = NULL; + ark_mem->step_fullrhs = NULL; + ark_mem->step = NULL; + ark_mem->step_setuserdata = NULL; + ark_mem->step_printallstats = NULL; + ark_mem->step_writeparameters = NULL; + ark_mem->step_resize = NULL; + ark_mem->step_reset = NULL; + ark_mem->step_free = NULL; + ark_mem->step_printmem = NULL; + ark_mem->step_setdefaults = NULL; + ark_mem->step_computestate = NULL; + ark_mem->step_setrelaxfn = NULL; + ark_mem->step_setorder = NULL; + ark_mem->step_setnonlinearsolver = NULL; + ark_mem->step_setlinear = NULL; + ark_mem->step_setnonlinear = NULL; + ark_mem->step_setnlsrhsfn = NULL; + ark_mem->step_setdeduceimplicitrhs = NULL; + ark_mem->step_setnonlincrdown = NULL; + ark_mem->step_setnonlinrdiv = NULL; + ark_mem->step_setdeltagammamax = NULL; + ark_mem->step_setlsetupfrequency = NULL; + ark_mem->step_setpredictormethod = NULL; + ark_mem->step_setmaxnonliniters = NULL; + ark_mem->step_setnonlinconvcoef = NULL; + ark_mem->step_setstagepredictfn = NULL; + ark_mem->step_getnumlinsolvsetups = NULL; + ark_mem->step_getestlocalerrors = NULL; + ark_mem->step_getcurrentgamma = NULL; + ark_mem->step_getnonlinearsystemdata = NULL; + ark_mem->step_getnumnonlinsolviters = NULL; + ark_mem->step_getnumnonlinsolvconvfails = NULL; + ark_mem->step_getnonlinsolvstats = NULL; + ark_mem->step_mem = NULL; + ark_mem->step_supports_adaptive = SUNFALSE; + ark_mem->step_supports_implicit = SUNFALSE; + ark_mem->step_supports_massmatrix = SUNFALSE; + ark_mem->step_supports_relaxation = SUNFALSE; + + /* Initialize root finding variables */ + ark_mem->root_mem = NULL; + + /* Initialize inequality constraints variables */ + ark_mem->constraintsSet = SUNFALSE; + ark_mem->constraints = NULL; + + /* Initialize relaxation variables */ + ark_mem->relax_enabled = SUNFALSE; + ark_mem->relax_mem = NULL; + + /* Initialize lrw and liw */ + ark_mem->lrw = 18; + ark_mem->liw = 53; /* fcn/data ptr, int, long int, sunindextype, sunbooleantype */ + + /* No mallocs have been done yet */ + ark_mem->VabstolMallocDone = SUNFALSE; + ark_mem->VRabstolMallocDone = SUNFALSE; + ark_mem->MallocDone = SUNFALSE; + + /* No user-supplied step postprocessing function yet */ + ark_mem->ProcessStep = NULL; + ark_mem->ps_data = NULL; + + /* No user-supplied stage postprocessing function yet */ + ark_mem->ProcessStage = NULL; + + /* No user_data pointer yet */ + ark_mem->user_data = NULL; + + /* Allocate step adaptivity structure and note storage */ + ark_mem->hadapt_mem = arkAdaptInit(); + if (ark_mem->hadapt_mem == NULL) { - *v = N_VClone(tmpl); - if (*v == NULL) - { - arkFreeVectors(ark_mem); - return (SUNFALSE); - } - else - { - ark_mem->lrw += ark_mem->lrw1; - ark_mem->liw += ark_mem->liw1; - } + arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Allocation of step adaptivity structure failed"); + ARKodeFree((void**)&ark_mem); + return (NULL); } - return (SUNTRUE); -} + ark_mem->lrw += ARK_ADAPT_LRW; + ark_mem->liw += ARK_ADAPT_LIW; -sunbooleantype arkAllocVecArray(int count, N_Vector tmpl, N_Vector** v, - sunindextype lrw1, long int* lrw, - sunindextype liw1, long int* liw) -{ - /* allocate the new vector array if necessary */ - if (*v == NULL) + /* Allocate default step controller (PID) and note storage */ + ark_mem->hadapt_mem->hcontroller = SUNAdaptController_PID(sunctx); + if (ark_mem->hadapt_mem->hcontroller == NULL) { - *v = N_VCloneVectorArray(count, tmpl); - if (*v == NULL) { return (SUNFALSE); } - *lrw += count * lrw1; - *liw += count * liw1; + arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Allocation of step controller object failed"); + ARKodeFree((void**)&ark_mem); + return (NULL); } - return (SUNTRUE); + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + (void)SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + ark_mem->lrw += lenrw; + ark_mem->liw += leniw; + + /* Initialize the interpolation structure to NULL */ + ark_mem->interp = NULL; + ark_mem->interp_type = -1; + + /* Initially, rwt should point to ewt */ + ark_mem->rwt_is_ewt = SUNTRUE; + + /* Indicate that calling the full RHS function is not required, this flag is + updated to SUNTRUE by the interpolation module initialization function + and/or the stepper initialization function in arkInitialSetup */ + ark_mem->call_fullrhs = SUNFALSE; + + /* Indicate that the problem needs to be initialized */ + ark_mem->initsetup = SUNTRUE; + ark_mem->init_type = FIRST_INIT; + ark_mem->firststage = SUNTRUE; + ark_mem->initialized = SUNFALSE; + + /* Initial step size has not been determined yet */ + ark_mem->h = ZERO; + ark_mem->h0u = ZERO; + + /* Accumulated error estimation strategy */ + ark_mem->AccumErrorType = -1; + ark_mem->AccumError = ZERO; + + /* Set default values for integrator optional inputs */ + iret = ARKodeSetDefaults(ark_mem); + if (iret != ARK_SUCCESS) + { + arkProcessError(NULL, 0, __LINE__, __func__, __FILE__, + "Error setting default solver options"); + ARKodeFree((void**)&ark_mem); + return (NULL); + } + + /* Return pointer to ARKODE memory block */ + return (ark_mem); } /*--------------------------------------------------------------- - arkFreeVec and arkFreeVecArray: + arkRwtSet - These routines (respectively) free a single vector or a vector - array. If the target vector or vector array is already NULL it - is left alone; otherwise it is freed and the optional outputs - lrw and liw are updated accordingly. + This routine is responsible for setting the residual weight + vector rwt, according to tol_type, as follows: + + (1) rwt[i] = 1 / (reltol * SUNRabs(M*ycur[i]) + rabstol), i=0,...,neq-1 + if tol_type = ARK_SS + (2) rwt[i] = 1 / (reltol * SUNRabs(M*ycur[i]) + rabstol[i]), i=0,...,neq-1 + if tol_type = ARK_SV + (3) unset if tol_type is any other value (occurs rwt=ewt) + + arkRwtSet returns 0 if rwt is successfully set as above to a + positive vector and -1 otherwise. In the latter case, rwt is + considered undefined. + + All the real work is done in the routines arkRwtSetSS, arkRwtSetSV. ---------------------------------------------------------------*/ -void arkFreeVec(ARKodeMem ark_mem, N_Vector* v) +int arkRwtSet(N_Vector y, N_Vector weight, void* data) { - if (*v != NULL) + ARKodeMem ark_mem; + N_Vector My; + int flag = 0; + + /* data points to ark_mem here */ + ark_mem = (ARKodeMem)data; + + /* return if rwt is just ewt */ + if (ark_mem->rwt_is_ewt) { return (0); } + + /* put M*y into ark_tempv1 */ + My = ark_mem->tempv1; + if (ark_mem->step_mmult != NULL) { - N_VDestroy(*v); - *v = NULL; - ark_mem->lrw -= ark_mem->lrw1; - ark_mem->liw -= ark_mem->liw1; + flag = ark_mem->step_mmult((void*)ark_mem, y, My); + if (flag != ARK_SUCCESS) { return (ARK_MASSMULT_FAIL); } + } + else + { /* this condition should not apply, but just in case */ + N_VScale(ONE, y, My); } -} -void arkFreeVecArray(int count, N_Vector** v, sunindextype lrw1, long int* lrw, - sunindextype liw1, long int* liw) -{ - if (*v != NULL) + /* call appropriate routine to fill rwt */ + switch (ark_mem->ritol) { - N_VDestroyVectorArray(*v, count); - *v = NULL; - *lrw -= count * lrw1; - *liw -= count * liw1; + case ARK_SS: flag = arkRwtSetSS(ark_mem, My, weight); break; + case ARK_SV: flag = arkRwtSetSV(ark_mem, My, weight); break; } + + return (flag); } /*--------------------------------------------------------------- - arkResizeVec and arkResizeVecArray: - - This routines (respectively) resize a single vector or a vector - array based on a template vector. If the ARKVecResizeFn function - is non-NULL, then it calls that routine to perform the resize; - otherwise it deallocates and reallocates the target vector or - vector array based on the template vector. These routines also - updates the optional outputs lrw and liw, which are - (respectively) the lengths of the overall ARKODE real and - integer work spaces. + arkInit: - SUNTRUE is returned if the resize is successful otherwise - SUNFALSE is retured. + arkInit allocates and initializes memory for a problem. All + inputs are checked for errors. If any error occurs during + initialization, an error flag is returned. Otherwise, it returns + ARK_SUCCESS. This routine should be called by an ARKODE + timestepper module (not by the user). This routine must be + called prior to calling ARKodeEvolve to evolve the problem. The + initialization type indicates if the values of internal counters + should be reinitialized (FIRST_INIT) or retained (RESET_INIT). ---------------------------------------------------------------*/ -sunbooleantype arkResizeVec(ARKodeMem ark_mem, ARKVecResizeFn resize, - void* resize_data, sunindextype lrw_diff, - sunindextype liw_diff, N_Vector tmpl, N_Vector* v) +int arkInit(ARKodeMem ark_mem, sunrealtype t0, N_Vector y0, int init_type) { - if (*v != NULL) + sunbooleantype stepperOK, nvectorOK, allocOK; + int retval; + sunindextype lrw1, liw1; + + /* Check ark_mem */ + if (ark_mem == NULL) { - if (resize == NULL) + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + + /* Check for legal input parameters */ + if (y0 == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NULL_Y0); + return (ARK_ILL_INPUT); + } + + /* Check if reset was called before the first Evolve call */ + if (init_type == RESET_INIT && !(ark_mem->initialized)) + { + init_type = FIRST_INIT; + } + + /* Check if allocations have been done i.e., is this first init call */ + if (ark_mem->MallocDone == SUNFALSE) + { + /* Test if all required time stepper operations are implemented */ + stepperOK = arkCheckTimestepper(ark_mem); + if (!stepperOK) { - N_VDestroy(*v); - *v = NULL; - *v = N_VClone(tmpl); - if (*v == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to clone vector"); - return (SUNFALSE); - } + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Time stepper module is missing required functionality"); + return (ARK_ILL_INPUT); } - else + + /* Test if all required vector operations are implemented */ + nvectorOK = arkCheckNvector(y0); + if (!nvectorOK) { - if (resize(*v, tmpl, resize_data)) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - MSG_ARK_RESIZE_FAIL); - return (SUNFALSE); - } + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_NVECTOR); + return (ARK_ILL_INPUT); } - ark_mem->lrw += lrw_diff; - ark_mem->liw += liw_diff; - } - return (SUNTRUE); -} -sunbooleantype arkResizeVecArray(ARKVecResizeFn resize, void* resize_data, - int count, N_Vector tmpl, N_Vector** v, - sunindextype lrw_diff, long int* lrw, - sunindextype liw_diff, long int* liw) -{ - int i; + /* Set space requirements for one N_Vector */ + if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } + else + { + lrw1 = 0; + liw1 = 0; + } + ark_mem->lrw1 = lrw1; + ark_mem->liw1 = liw1; - if (*v != NULL) - { - if (resize == NULL) + /* Allocate the solver vectors (using y0 as a template) */ + allocOK = arkAllocVectors(ark_mem, y0); + if (!allocOK) { - N_VDestroyVectorArray(*v, count); - *v = NULL; - *v = N_VCloneVectorArray(count, tmpl); - if (*v == NULL) { return (SUNFALSE); } + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_MEM_FAIL); + return (ARK_MEM_FAIL); } - else + + /* Create default Hermite interpolation module */ + if (!(ark_mem->interp)) { - for (i = 0; i < count; i++) + ark_mem->interp = arkInterpCreate_Hermite(ark_mem, ARK_INTERP_MAX_DEGREE); + if (ark_mem->interp == NULL) { - if (resize((*v)[i], tmpl, resize_data)) { return (SUNFALSE); } + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to allocate interpolation module"); + return (ARK_MEM_FAIL); } + ark_mem->interp_type = ARK_INTERP_HERMITE; } - *lrw += count * lrw_diff; - *liw += count * liw_diff; - } - return (SUNTRUE); -} - -/*--------------------------------------------------------------- - arkAllocVectors: - - This routine allocates the ARKODE vectors ewt, yn, tempv* and - ftemp. If any of these vectors already exist, they are left - alone. Otherwise, it will allocate each vector by cloning the - input vector. This routine also updates the optional outputs - lrw and liw, which are (respectively) the lengths of the real - and integer work spaces. - - If all memory allocations are successful, arkAllocVectors - returns SUNTRUE, otherwise it returns SUNFALSE. - ---------------------------------------------------------------*/ -sunbooleantype arkAllocVectors(ARKodeMem ark_mem, N_Vector tmpl) -{ - /* Allocate ewt if needed */ - if (!arkAllocVec(ark_mem, tmpl, &ark_mem->ewt)) { return (SUNFALSE); } - /* Set rwt to point at ewt */ - if (ark_mem->rwt_is_ewt) { ark_mem->rwt = ark_mem->ewt; } - - /* Allocate yn if needed */ - if (!arkAllocVec(ark_mem, tmpl, &ark_mem->yn)) { return (SUNFALSE); } - - /* Allocate tempv1 if needed */ - if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv1)) { return (SUNFALSE); } - - /* Allocate tempv2 if needed */ - if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv2)) { return (SUNFALSE); } - - /* Allocate tempv3 if needed */ - if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv3)) { return (SUNFALSE); } + /* All allocations are complete */ + ark_mem->MallocDone = SUNTRUE; + } - /* Allocate tempv4 if needed */ - if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv4)) { return (SUNFALSE); } + /* All allocation and error checking is complete at this point */ - return (SUNTRUE); -} + /* Copy the input parameters into ARKODE state */ + ark_mem->tcur = t0; + ark_mem->tn = t0; -/*--------------------------------------------------------------- - arkResizeVectors: + /* Initialize yn */ + N_VScale(ONE, y0, ark_mem->yn); + ark_mem->fn_is_current = SUNFALSE; - This routine resizes all ARKODE vectors if they exist, - otherwise they are left alone. If a resize function is provided - it is called to resize the vectors otherwise the vector is - freed and a new vector is created by cloning in input vector. - This routine also updates the optional outputs lrw and liw, - which are (respectively) the lengths of the real and integer - work spaces. + /* Clear any previous 'tstop' */ + ark_mem->tstopset = SUNFALSE; - If all memory allocations are successful, arkResizeVectors - returns SUNTRUE, otherwise it returns SUNFALSE. - ---------------------------------------------------------------*/ -sunbooleantype arkResizeVectors(ARKodeMem ark_mem, ARKVecResizeFn resize, - void* resize_data, sunindextype lrw_diff, - sunindextype liw_diff, N_Vector tmpl) -{ - /* Vabstol */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->Vabstol)) + /* Initializations on (re-)initialization call, skip on reset */ + if (init_type == FIRST_INIT) { - return (SUNFALSE); - } + /* Counters */ + ark_mem->nst_attempts = 0; + ark_mem->nst = 0; + ark_mem->nhnil = 0; + ark_mem->ncfn = 0; + ark_mem->netf = 0; + ark_mem->nconstrfails = 0; - /* VRabstol */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->VRabstol)) - { - return (SUNFALSE); - } + /* Initial, old, and next step sizes */ + ark_mem->h0u = ZERO; + ark_mem->hold = ZERO; + ark_mem->next_h = ZERO; - /* ewt */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->ewt)) - { - return (SUNFALSE); - } + /* Tolerance scale factor */ + ark_mem->tolsf = ONE; - /* rwt */ - if (ark_mem->rwt_is_ewt) - { /* update pointer to ewt */ - ark_mem->rwt = ark_mem->ewt; - } - else - { /* resize if distinct from ewt */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->rwt)) + /* Reset error controller object */ + retval = SUNAdaptController_Reset(ark_mem->hadapt_mem->hcontroller); + if (retval != SUN_SUCCESS) { - return (SUNFALSE); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, __FILE__, + "Unable to reset error controller object"); + return (ARK_CONTROLLER_ERR); } - } - /* yn */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->yn)) - { - return (SUNFALSE); - } + /* Adaptivity counters */ + ark_mem->hadapt_mem->nst_acc = 0; + ark_mem->hadapt_mem->nst_exp = 0; - /* fn */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->fn)) - { - return (SUNFALSE); - } + /* Indicate that calling the full RHS function is not required, this flag is + updated to SUNTRUE by the interpolation module initialization function + and/or the stepper initialization function in arkInitialSetup */ + ark_mem->call_fullrhs = SUNFALSE; - /* tempv* */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->tempv1)) - { - return (SUNFALSE); + /* Indicate that initialization has not been done before */ + ark_mem->initialized = SUNFALSE; } - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->tempv2)) - { - return (SUNFALSE); - } + /* Indicate initialization is needed */ + ark_mem->initsetup = SUNTRUE; + ark_mem->init_type = init_type; + ark_mem->firststage = SUNTRUE; - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->tempv3)) - { - return (SUNFALSE); - } + return (ARK_SUCCESS); +} - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->tempv4)) - { - return (SUNFALSE); - } +/*--------------------------------------------------------------- + arkCheckTimestepper: - /* constraints */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, - &ark_mem->constraints)) + This routine checks if all required time stepper function + pointers have been supplied. If any of them is missing it + returns SUNFALSE. + ---------------------------------------------------------------*/ +sunbooleantype arkCheckTimestepper(ARKodeMem ark_mem) +{ + if ((ark_mem->step_init == NULL) || (ark_mem->step == NULL) || + (ark_mem->step_mem == NULL)) { return (SUNFALSE); } - return (SUNTRUE); } /*--------------------------------------------------------------- - arkFreeVectors + arkCheckNvector: - This routine frees the ARKODE vectors allocated in both - arkAllocVectors and arkAllocRKVectors. + This routine checks if all required vector operations are + present. If any of them is missing it returns SUNFALSE. ---------------------------------------------------------------*/ -void arkFreeVectors(ARKodeMem ark_mem) +sunbooleantype arkCheckNvector(N_Vector tmpl) /* to be updated?? */ { - arkFreeVec(ark_mem, &ark_mem->ewt); - if (!ark_mem->rwt_is_ewt) { arkFreeVec(ark_mem, &ark_mem->rwt); } - arkFreeVec(ark_mem, &ark_mem->tempv1); - arkFreeVec(ark_mem, &ark_mem->tempv2); - arkFreeVec(ark_mem, &ark_mem->tempv3); - arkFreeVec(ark_mem, &ark_mem->tempv4); - arkFreeVec(ark_mem, &ark_mem->yn); - arkFreeVec(ark_mem, &ark_mem->fn); - arkFreeVec(ark_mem, &ark_mem->Vabstol); - arkFreeVec(ark_mem, &ark_mem->constraints); + if ((tmpl->ops->nvclone == NULL) || (tmpl->ops->nvdestroy == NULL) || + (tmpl->ops->nvlinearsum == NULL) || (tmpl->ops->nvconst == NULL) || + (tmpl->ops->nvdiv == NULL) || (tmpl->ops->nvscale == NULL) || + (tmpl->ops->nvabs == NULL) || (tmpl->ops->nvinv == NULL) || + (tmpl->ops->nvaddconst == NULL) || (tmpl->ops->nvmaxnorm == NULL) || + (tmpl->ops->nvwrmsnorm == NULL)) + { + return (SUNFALSE); + } + else { return (SUNTRUE); } } /*--------------------------------------------------------------- @@ -2327,7 +2162,7 @@ int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, { if (ark_mem->tstopinterp) { - *ier = arkGetDky(ark_mem, ark_mem->tstop, 0, yout); + *ier = ARKodeGetDky(ark_mem, ark_mem->tstop, 0, yout); if (*ier != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -2357,7 +2192,7 @@ int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, if ((itask == ARK_NORMAL) && ((ark_mem->tcur - tout) * ark_mem->h >= ZERO)) { ark_mem->tretlast = *tret = tout; - *ier = arkGetDky(ark_mem, tout, 0, yout); + *ier = ARKodeGetDky(ark_mem, tout, 0, yout); if (*ier != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -2388,7 +2223,7 @@ int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, This routine computes a tentative initial step size h0. If tout is too close to tn (= t0), then arkHin returns ARK_TOO_CLOSE and h remains uninitialized. Note that here tout - is either the value passed to arkEvolve at the first call or the + is either the value passed to ARKodeEvolve at the first call or the value of tstop (if tstop is enabled and it is closer to t0=tn than tout). If the RHS function fails unrecoverably, arkHin returns ARK_RHSFUNC_FAIL. If the RHS function fails recoverably @@ -3055,257 +2890,577 @@ int arkPredict_CutoffOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess) if (tau <= tau_tol) { ord = ARK_INTERP_MAX_DEGREE; } else { ord = 1; } - /* call the interpolation module to do the work */ - return (arkInterpEvaluate(ark_mem, ark_mem->interp, tau, 0, ord, yguess)); + /* call the interpolation module to do the work */ + return (arkInterpEvaluate(ark_mem, ark_mem->interp, tau, 0, ord, yguess)); +} + +/*--------------------------------------------------------------- + arkPredict_Bootstrap + + This routine predicts the nonlinear implicit stage solution + using a quadratic Hermite interpolating polynomial, based on + the data {y_n, f(t_n,y_n), f(t_n+hj,z_j)}. + + Note: we assume that ftemp = f(t_n+hj,z_j) can be computed via + N_VLinearCombination(nvec, cvals, Xvecs, ftemp), + i.e. the inputs cvals[0:nvec-1] and Xvecs[0:nvec-1] may be + combined to form f(t_n+hj,z_j). + ---------------------------------------------------------------*/ +int arkPredict_Bootstrap(ARKodeMem ark_mem, sunrealtype hj, sunrealtype tau, + int nvec, sunrealtype* cvals, N_Vector* Xvecs, + N_Vector yguess) +{ + sunrealtype a0, a1, a2; + int i, retval; + + /* verify that ark_mem and interpolation structure are provided */ + if (ark_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "ARKodeMem structure is NULL"); + return (ARK_MEM_NULL); + } + if (ark_mem->interp == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "ARKodeInterpMem structure is NULL"); + return (ARK_MEM_NULL); + } + + /* set coefficients for Hermite interpolant */ + a0 = ONE; + a2 = tau * tau / TWO / hj; + a1 = tau - a2; + + /* set arrays for fused vector operation; shift inputs for + f(t_n+hj,z_j) to end of queue */ + for (i = 0; i < nvec; i++) + { + cvals[2 + i] = a2 * cvals[i]; + Xvecs[2 + i] = Xvecs[i]; + } + cvals[0] = a0; + Xvecs[0] = ark_mem->yn; + cvals[1] = a1; + Xvecs[1] = ark_mem->fn; + + /* call fused vector operation to compute prediction */ + retval = N_VLinearCombination(nvec + 2, cvals, Xvecs, yguess); + if (retval != 0) { return (ARK_VECTOROP_ERR); } + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + arkCheckConvergence + + This routine checks the return flag from the time-stepper's + "step" routine for algebraic solver convergence issues. + + Returns ARK_SUCCESS (0) if successful, PREDICT_AGAIN (>0) + on a recoverable convergence failure, or a relevant + nonrecoverable failure flag (<0). + --------------------------------------------------------------*/ +int arkCheckConvergence(ARKodeMem ark_mem, int* nflagPtr, int* ncfPtr) +{ + ARKodeHAdaptMem hadapt_mem; + + /* If nonlinear solver succeeded, return with ARK_SUCCESS */ + if (*nflagPtr == ARK_SUCCESS) { return (ARK_SUCCESS); } + + /* The nonlinear soln. failed; increment ncfn */ + ark_mem->ncfn++; + + /* If fixed time stepping, then return with convergence failure */ + if (ark_mem->fixedstep) { return (ARK_CONV_FAILURE); } + + /* Otherwise, access adaptivity structure */ + if (ark_mem->hadapt_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARKADAPT_NO_MEM); + return (ARK_MEM_NULL); + } + hadapt_mem = ark_mem->hadapt_mem; + + /* Return if lsetup, lsolve, or rhs failed unrecoverably */ + if (*nflagPtr < 0) + { + if (*nflagPtr == ARK_LSETUP_FAIL) { return (ARK_LSETUP_FAIL); } + else if (*nflagPtr == ARK_LSOLVE_FAIL) { return (ARK_LSOLVE_FAIL); } + else if (*nflagPtr == ARK_RHSFUNC_FAIL) { return (ARK_RHSFUNC_FAIL); } + else { return (ARK_NLS_OP_ERR); } + } + + /* At this point, nflag = CONV_FAIL or RHSFUNC_RECVR; increment ncf */ + (*ncfPtr)++; + hadapt_mem->etamax = ONE; + + /* If we had maxncf failures, or if |h| = hmin, + return ARK_CONV_FAILURE or ARK_REPTD_RHSFUNC_ERR. */ + if ((*ncfPtr == ark_mem->maxncf) || + (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM)) + { + if (*nflagPtr == CONV_FAIL) { return (ARK_CONV_FAILURE); } + if (*nflagPtr == RHSFUNC_RECVR) { return (ARK_REPTD_RHSFUNC_ERR); } + } + + /* Reduce step size due to convergence failure */ + ark_mem->eta = hadapt_mem->etacf; + + /* Signal for Jacobian/preconditioner setup */ + *nflagPtr = PREV_CONV_FAIL; + + /* Return to reattempt the step */ + return (PREDICT_AGAIN); +} + +/*--------------------------------------------------------------- + arkCheckConstraints + + This routine determines if the constraints of the problem + are satisfied by the proposed step + + Returns ARK_SUCCESS if successful, otherwise CONSTR_RECVR + --------------------------------------------------------------*/ +int arkCheckConstraints(ARKodeMem ark_mem, int* constrfails, int* nflag) +{ + sunbooleantype constraintsPassed; + N_Vector mm = ark_mem->tempv4; + N_Vector tmp = ark_mem->tempv3; + + /* Check constraints and get mask vector mm for where constraints failed */ + constraintsPassed = N_VConstrMask(ark_mem->constraints, ark_mem->ycur, mm); + if (constraintsPassed) { return (ARK_SUCCESS); } + + /* Constraints not met */ + + /* Update total fails and fails in current step */ + ark_mem->nconstrfails++; + (*constrfails)++; + + /* Return with error if reached max fails in a step */ + if (*constrfails == ark_mem->maxconstrfails) { return (ARK_CONSTR_FAIL); } + + /* Return with error if using fixed step sizes */ + if (ark_mem->fixedstep) { return (ARK_CONSTR_FAIL); } + + /* Return with error if |h| == hmin */ + if (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM) + { + return (ARK_CONSTR_FAIL); + } + + /* Reduce h by computing eta = h'/h */ + N_VLinearSum(ONE, ark_mem->yn, -ONE, ark_mem->ycur, tmp); + N_VProd(mm, tmp, tmp); + ark_mem->eta = SUN_RCONST(0.9) * N_VMinQuotient(ark_mem->yn, tmp); + ark_mem->eta = SUNMAX(ark_mem->eta, TENTH); + + /* Signal for Jacobian/preconditioner setup */ + *nflag = PREV_CONV_FAIL; + + /* Return to reattempt the step */ + return (CONSTR_RECVR); } /*--------------------------------------------------------------- - arkPredict_Bootstrap + arkCheckTemporalError - This routine predicts the nonlinear implicit stage solution - using a quadratic Hermite interpolating polynomial, based on - the data {y_n, f(t_n,y_n), f(t_n+hj,z_j)}. + This routine performs the local error test for the method. + The weighted local error norm dsm is passed in. This value is + used to predict the next step to attempt based on dsm. + The test dsm <= 1 is made, and if this fails then additional + checks are performed based on the number of successive error + test failures. - Note: we assume that ftemp = f(t_n+hj,z_j) can be computed via - N_VLinearCombination(nvec, cvals, Xvecs, ftemp), - i.e. the inputs cvals[0:nvec-1] and Xvecs[0:nvec-1] may be - combined to form f(t_n+hj,z_j). - ---------------------------------------------------------------*/ -int arkPredict_Bootstrap(ARKodeMem ark_mem, sunrealtype hj, sunrealtype tau, - int nvec, sunrealtype* cvals, N_Vector* Xvecs, - N_Vector yguess) + Returns ARK_SUCCESS if the test passes. + + If the test fails: + - if maxnef error test failures have occurred or if + SUNRabs(h) = hmin, we return ARK_ERR_FAILURE. + - otherwise: set *nflagPtr to PREV_ERR_FAIL, and + return TRY_AGAIN. + --------------------------------------------------------------*/ +int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, + sunrealtype dsm) { - sunrealtype a0, a1, a2; - int i, retval; + int retval; + sunrealtype ttmp; + long int nsttmp; + ARKodeHAdaptMem hadapt_mem; - /* verify that ark_mem and interpolation structure are provided */ - if (ark_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "ARKodeMem structure is NULL"); - return (ARK_MEM_NULL); - } - if (ark_mem->interp == NULL) + /* Access hadapt_mem structure */ + if (ark_mem->hadapt_mem == NULL) { arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "ARKodeInterpMem structure is NULL"); + MSG_ARKADAPT_NO_MEM); return (ARK_MEM_NULL); } + hadapt_mem = ark_mem->hadapt_mem; - /* set coefficients for Hermite interpolant */ - a0 = ONE; - a2 = tau * tau / TWO / hj; - a1 = tau - a2; + /* consider change of step size for next step attempt (may be + larger/smaller than current step, depending on dsm) */ + ttmp = (dsm <= ONE) ? ark_mem->tn + ark_mem->h : ark_mem->tn; + nsttmp = (dsm <= ONE) ? ark_mem->nst + 1 : ark_mem->nst; + retval = arkAdapt(ark_mem, hadapt_mem, ark_mem->ycur, ttmp, ark_mem->h, dsm, + nsttmp); + if (retval != ARK_SUCCESS) { return (ARK_ERR_FAILURE); } - /* set arrays for fused vector operation; shift inputs for - f(t_n+hj,z_j) to end of queue */ - for (i = 0; i < nvec; i++) + /* if we've made it here then no nonrecoverable failures occurred; someone above + has recommended an 'eta' value for the next step -- enforce bounds on that value + and set upcoming step size */ + ark_mem->eta = SUNMIN(ark_mem->eta, ark_mem->hadapt_mem->etamax); + ark_mem->eta = SUNMAX(ark_mem->eta, ark_mem->hmin / SUNRabs(ark_mem->h)); + ark_mem->eta /= + SUNMAX(ONE, SUNRabs(ark_mem->h) * ark_mem->hmax_inv * ark_mem->eta); + + /* If est. local error norm dsm passes test, return ARK_SUCCESS */ + if (dsm <= ONE) { return (ARK_SUCCESS); } + + /* Test failed; increment counters, set nflag */ + (*nefPtr)++; + ark_mem->netf++; + *nflagPtr = PREV_ERR_FAIL; + + /* At maxnef failures, return ARK_ERR_FAILURE */ + if (*nefPtr == ark_mem->maxnef) { return (ARK_ERR_FAILURE); } + + /* Set etamax=1 to prevent step size increase at end of this step */ + hadapt_mem->etamax = ONE; + + /* Enforce failure bounds on eta */ + if (*nefPtr >= hadapt_mem->small_nef) { - cvals[2 + i] = a2 * cvals[i]; - Xvecs[2 + i] = Xvecs[i]; + ark_mem->eta = SUNMIN(ark_mem->eta, hadapt_mem->etamxf); } - cvals[0] = a0; - Xvecs[0] = ark_mem->yn; - cvals[1] = a1; - Xvecs[1] = ark_mem->fn; - /* call fused vector operation to compute prediction */ - retval = N_VLinearCombination(nvec + 2, cvals, Xvecs, yguess); - if (retval != 0) { return (ARK_VECTOROP_ERR); } - return (ARK_SUCCESS); + /* Enforce min/max step bounds once again due to adjustments above */ + ark_mem->eta = SUNMIN(ark_mem->eta, ark_mem->hadapt_mem->etamax); + ark_mem->eta = SUNMAX(ark_mem->eta, ark_mem->hmin / SUNRabs(ark_mem->h)); + ark_mem->eta /= + SUNMAX(ONE, SUNRabs(ark_mem->h) * ark_mem->hmax_inv * ark_mem->eta); + + return (TRY_AGAIN); } /*--------------------------------------------------------------- - arkCheckConvergence + arkAllocVec and arkAllocVecArray: - This routine checks the return flag from the time-stepper's - "step" routine for algebraic solver convergence issues. + These routines allocate (respectively) single vector or a vector + array based on a template vector. If the target vector or vector + array already exists it is left alone; otherwise it is allocated + by cloning the input vector. - Returns ARK_SUCCESS (0) if successful, PREDICT_AGAIN (>0) - on a recoverable convergence failure, or a relevant - nonrecoverable failure flag (<0). - --------------------------------------------------------------*/ -int arkCheckConvergence(ARKodeMem ark_mem, int* nflagPtr, int* ncfPtr) -{ - ARKodeHAdaptMem hadapt_mem; + This routine also updates the optional outputs lrw and liw, which + are (respectively) the lengths of the overall ARKODE real and + integer work spaces. - /* If nonlinear solver succeeded, return with ARK_SUCCESS */ - if (*nflagPtr == ARK_SUCCESS) { return (ARK_SUCCESS); } + SUNTRUE is returned if the allocation is successful (or if the + target vector or vector array already exists) otherwise SUNFALSE + is retured. + ---------------------------------------------------------------*/ +sunbooleantype arkAllocVec(ARKodeMem ark_mem, N_Vector tmpl, N_Vector* v) +{ + /* allocate the new vector if necessary */ + if (*v == NULL) + { + *v = N_VClone(tmpl); + if (*v == NULL) + { + arkFreeVectors(ark_mem); + return (SUNFALSE); + } + else + { + ark_mem->lrw += ark_mem->lrw1; + ark_mem->liw += ark_mem->liw1; + } + } + return (SUNTRUE); +} - /* The nonlinear soln. failed; increment ncfn */ - ark_mem->ncfn++; +sunbooleantype arkAllocVecArray(int count, N_Vector tmpl, N_Vector** v, + sunindextype lrw1, long int* lrw, + sunindextype liw1, long int* liw) +{ + /* allocate the new vector array if necessary */ + if (*v == NULL) + { + *v = N_VCloneVectorArray(count, tmpl); + if (*v == NULL) { return (SUNFALSE); } + *lrw += count * lrw1; + *liw += count * liw1; + } + return (SUNTRUE); +} - /* If fixed time stepping, then return with convergence failure */ - if (ark_mem->fixedstep) { return (ARK_CONV_FAILURE); } +/*--------------------------------------------------------------- + arkFreeVec and arkFreeVecArray: - /* Otherwise, access adaptivity structure */ - if (ark_mem->hadapt_mem == NULL) + These routines (respectively) free a single vector or a vector + array. If the target vector or vector array is already NULL it + is left alone; otherwise it is freed and the optional outputs + lrw and liw are updated accordingly. + ---------------------------------------------------------------*/ +void arkFreeVec(ARKodeMem ark_mem, N_Vector* v) +{ + if (*v != NULL) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARKADAPT_NO_MEM); - return (ARK_MEM_NULL); + N_VDestroy(*v); + *v = NULL; + ark_mem->lrw -= ark_mem->lrw1; + ark_mem->liw -= ark_mem->liw1; } - hadapt_mem = ark_mem->hadapt_mem; +} - /* Return if lsetup, lsolve, or rhs failed unrecoverably */ - if (*nflagPtr < 0) +void arkFreeVecArray(int count, N_Vector** v, sunindextype lrw1, long int* lrw, + sunindextype liw1, long int* liw) +{ + if (*v != NULL) { - if (*nflagPtr == ARK_LSETUP_FAIL) { return (ARK_LSETUP_FAIL); } - else if (*nflagPtr == ARK_LSOLVE_FAIL) { return (ARK_LSOLVE_FAIL); } - else if (*nflagPtr == ARK_RHSFUNC_FAIL) { return (ARK_RHSFUNC_FAIL); } - else { return (ARK_NLS_OP_ERR); } + N_VDestroyVectorArray(*v, count); + *v = NULL; + *lrw -= count * lrw1; + *liw -= count * liw1; } +} - /* At this point, nflag = CONV_FAIL or RHSFUNC_RECVR; increment ncf */ - (*ncfPtr)++; - hadapt_mem->etamax = ONE; +/*--------------------------------------------------------------- + arkResizeVec and arkResizeVecArray: - /* If we had maxncf failures, or if |h| = hmin, - return ARK_CONV_FAILURE or ARK_REPTD_RHSFUNC_ERR. */ - if ((*ncfPtr == ark_mem->maxncf) || - (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM)) + This routines (respectively) resize a single vector or a vector + array based on a template vector. If the ARKVecResizeFn function + is non-NULL, then it calls that routine to perform the resize; + otherwise it deallocates and reallocates the target vector or + vector array based on the template vector. These routines also + updates the optional outputs lrw and liw, which are + (respectively) the lengths of the overall ARKODE real and + integer work spaces. + + SUNTRUE is returned if the resize is successful otherwise + SUNFALSE is retured. + ---------------------------------------------------------------*/ +sunbooleantype arkResizeVec(ARKodeMem ark_mem, ARKVecResizeFn resize, + void* resize_data, sunindextype lrw_diff, + sunindextype liw_diff, N_Vector tmpl, N_Vector* v) +{ + if (*v != NULL) { - if (*nflagPtr == CONV_FAIL) { return (ARK_CONV_FAILURE); } - if (*nflagPtr == RHSFUNC_RECVR) { return (ARK_REPTD_RHSFUNC_ERR); } + if (resize == NULL) + { + N_VDestroy(*v); + *v = NULL; + *v = N_VClone(tmpl); + if (*v == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to clone vector"); + return (SUNFALSE); + } + } + else + { + if (resize(*v, tmpl, resize_data)) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + MSG_ARK_RESIZE_FAIL); + return (SUNFALSE); + } + } + ark_mem->lrw += lrw_diff; + ark_mem->liw += liw_diff; } + return (SUNTRUE); +} - /* Reduce step size due to convergence failure */ - ark_mem->eta = hadapt_mem->etacf; - - /* Signal for Jacobian/preconditioner setup */ - *nflagPtr = PREV_CONV_FAIL; +sunbooleantype arkResizeVecArray(ARKVecResizeFn resize, void* resize_data, + int count, N_Vector tmpl, N_Vector** v, + sunindextype lrw_diff, long int* lrw, + sunindextype liw_diff, long int* liw) +{ + int i; - /* Return to reattempt the step */ - return (PREDICT_AGAIN); + if (*v != NULL) + { + if (resize == NULL) + { + N_VDestroyVectorArray(*v, count); + *v = NULL; + *v = N_VCloneVectorArray(count, tmpl); + if (*v == NULL) { return (SUNFALSE); } + } + else + { + for (i = 0; i < count; i++) + { + if (resize((*v)[i], tmpl, resize_data)) { return (SUNFALSE); } + } + } + *lrw += count * lrw_diff; + *liw += count * liw_diff; + } + return (SUNTRUE); } /*--------------------------------------------------------------- - arkCheckConstraints + arkAllocVectors: - This routine determines if the constraints of the problem - are satisfied by the proposed step + This routine allocates the ARKODE vectors ewt, yn, tempv* and + ftemp. If any of these vectors already exist, they are left + alone. Otherwise, it will allocate each vector by cloning the + input vector. This routine also updates the optional outputs + lrw and liw, which are (respectively) the lengths of the real + and integer work spaces. - Returns ARK_SUCCESS if successful, otherwise CONSTR_RECVR - --------------------------------------------------------------*/ -int arkCheckConstraints(ARKodeMem ark_mem, int* constrfails, int* nflag) + If all memory allocations are successful, arkAllocVectors + returns SUNTRUE, otherwise it returns SUNFALSE. + ---------------------------------------------------------------*/ +sunbooleantype arkAllocVectors(ARKodeMem ark_mem, N_Vector tmpl) { - sunbooleantype constraintsPassed; - N_Vector mm = ark_mem->tempv4; - N_Vector tmp = ark_mem->tempv1; - - /* Check constraints and get mask vector mm for where constraints failed */ - constraintsPassed = N_VConstrMask(ark_mem->constraints, ark_mem->ycur, mm); - if (constraintsPassed) { return (ARK_SUCCESS); } - - /* Constraints not met */ + /* Allocate ewt if needed */ + if (!arkAllocVec(ark_mem, tmpl, &ark_mem->ewt)) { return (SUNFALSE); } - /* Update total fails and fails in current step */ - ark_mem->nconstrfails++; - (*constrfails)++; + /* Set rwt to point at ewt */ + if (ark_mem->rwt_is_ewt) { ark_mem->rwt = ark_mem->ewt; } - /* Return with error if reached max fails in a step */ - if (*constrfails == ark_mem->maxconstrfails) { return (ARK_CONSTR_FAIL); } + /* Allocate yn if needed */ + if (!arkAllocVec(ark_mem, tmpl, &ark_mem->yn)) { return (SUNFALSE); } - /* Return with error if using fixed step sizes */ - if (ark_mem->fixedstep) { return (ARK_CONSTR_FAIL); } + /* Allocate tempv1 if needed */ + if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv1)) { return (SUNFALSE); } - /* Return with error if |h| == hmin */ - if (SUNRabs(ark_mem->h) <= ark_mem->hmin * ONEPSM) - { - return (ARK_CONSTR_FAIL); - } + /* Allocate tempv2 if needed */ + if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv2)) { return (SUNFALSE); } - /* Reduce h by computing eta = h'/h */ - N_VLinearSum(ONE, ark_mem->yn, -ONE, ark_mem->ycur, tmp); - N_VProd(mm, tmp, tmp); - ark_mem->eta = SUN_RCONST(0.9) * N_VMinQuotient(ark_mem->yn, tmp); - ark_mem->eta = SUNMAX(ark_mem->eta, TENTH); + /* Allocate tempv3 if needed */ + if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv3)) { return (SUNFALSE); } - /* Signal for Jacobian/preconditioner setup */ - *nflag = PREV_CONV_FAIL; + /* Allocate tempv4 if needed */ + if (!arkAllocVec(ark_mem, tmpl, &ark_mem->tempv4)) { return (SUNFALSE); } - /* Return to reattempt the step */ - return (CONSTR_RECVR); + return (SUNTRUE); } /*--------------------------------------------------------------- - arkCheckTemporalError - - This routine performs the local error test for the method. - The weighted local error norm dsm is passed in. This value is - used to predict the next step to attempt based on dsm. - The test dsm <= 1 is made, and if this fails then additional - checks are performed based on the number of successive error - test failures. + arkResizeVectors: - Returns ARK_SUCCESS if the test passes. + This routine resizes all ARKODE vectors if they exist, + otherwise they are left alone. If a resize function is provided + it is called to resize the vectors otherwise the vector is + freed and a new vector is created by cloning in input vector. + This routine also updates the optional outputs lrw and liw, + which are (respectively) the lengths of the real and integer + work spaces. - If the test fails: - - if maxnef error test failures have occurred or if - SUNRabs(h) = hmin, we return ARK_ERR_FAILURE. - - otherwise: set *nflagPtr to PREV_ERR_FAIL, and - return TRY_AGAIN. - --------------------------------------------------------------*/ -int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, - sunrealtype dsm) + If all memory allocations are successful, arkResizeVectors + returns SUNTRUE, otherwise it returns SUNFALSE. + ---------------------------------------------------------------*/ +sunbooleantype arkResizeVectors(ARKodeMem ark_mem, ARKVecResizeFn resize, + void* resize_data, sunindextype lrw_diff, + sunindextype liw_diff, N_Vector tmpl) { - int retval; - sunrealtype ttmp; - long int nsttmp; - ARKodeHAdaptMem hadapt_mem; + /* Vabstol */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->Vabstol)) + { + return (SUNFALSE); + } - /* Access hadapt_mem structure */ - if (ark_mem->hadapt_mem == NULL) + /* VRabstol */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->VRabstol)) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARKADAPT_NO_MEM); - return (ARK_MEM_NULL); + return (SUNFALSE); } - hadapt_mem = ark_mem->hadapt_mem; - /* consider change of step size for next step attempt (may be - larger/smaller than current step, depending on dsm) */ - ttmp = (dsm <= ONE) ? ark_mem->tn + ark_mem->h : ark_mem->tn; - nsttmp = (dsm <= ONE) ? ark_mem->nst + 1 : ark_mem->nst; - retval = arkAdapt((void*)ark_mem, hadapt_mem, ark_mem->ycur, ttmp, ark_mem->h, - dsm, nsttmp); - if (retval != ARK_SUCCESS) { return (ARK_ERR_FAILURE); } + /* ewt */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->ewt)) + { + return (SUNFALSE); + } - /* if we've made it here then no nonrecoverable failures occurred; someone above - has recommended an 'eta' value for the next step -- enforce bounds on that value - and set upcoming step size */ - ark_mem->eta = SUNMIN(ark_mem->eta, ark_mem->hadapt_mem->etamax); - ark_mem->eta = SUNMAX(ark_mem->eta, ark_mem->hmin / SUNRabs(ark_mem->h)); - ark_mem->eta /= - SUNMAX(ONE, SUNRabs(ark_mem->h) * ark_mem->hmax_inv * ark_mem->eta); + /* rwt */ + if (ark_mem->rwt_is_ewt) + { /* update pointer to ewt */ + ark_mem->rwt = ark_mem->ewt; + } + else + { /* resize if distinct from ewt */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->rwt)) + { + return (SUNFALSE); + } + } - /* If est. local error norm dsm passes test, return ARK_SUCCESS */ - if (dsm <= ONE) { return (ARK_SUCCESS); } + /* yn */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->yn)) + { + return (SUNFALSE); + } - /* Test failed; increment counters, set nflag */ - (*nefPtr)++; - ark_mem->netf++; - *nflagPtr = PREV_ERR_FAIL; + /* fn */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->fn)) + { + return (SUNFALSE); + } - /* At maxnef failures, return ARK_ERR_FAILURE */ - if (*nefPtr == ark_mem->maxnef) { return (ARK_ERR_FAILURE); } + /* tempv* */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->tempv1)) + { + return (SUNFALSE); + } - /* Set etamax=1 to prevent step size increase at end of this step */ - hadapt_mem->etamax = ONE; + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->tempv2)) + { + return (SUNFALSE); + } - /* Enforce failure bounds on eta */ - if (*nefPtr >= hadapt_mem->small_nef) + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->tempv3)) { - ark_mem->eta = SUNMIN(ark_mem->eta, hadapt_mem->etamxf); + return (SUNFALSE); } - /* Enforce min/max step bounds once again due to adjustments above */ - ark_mem->eta = SUNMIN(ark_mem->eta, ark_mem->hadapt_mem->etamax); - ark_mem->eta = SUNMAX(ark_mem->eta, ark_mem->hmin / SUNRabs(ark_mem->h)); - ark_mem->eta /= - SUNMAX(ONE, SUNRabs(ark_mem->h) * ark_mem->hmax_inv * ark_mem->eta); + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->tempv4)) + { + return (SUNFALSE); + } - return (TRY_AGAIN); + /* constraints */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, tmpl, + &ark_mem->constraints)) + { + return (SUNFALSE); + } + + return (SUNTRUE); +} + +/*--------------------------------------------------------------- + arkFreeVectors + + This routine frees the ARKODE vectors allocated in both + arkAllocVectors and arkAllocRKVectors. + ---------------------------------------------------------------*/ +void arkFreeVectors(ARKodeMem ark_mem) +{ + arkFreeVec(ark_mem, &ark_mem->ewt); + if (!ark_mem->rwt_is_ewt) { arkFreeVec(ark_mem, &ark_mem->rwt); } + arkFreeVec(ark_mem, &ark_mem->tempv1); + arkFreeVec(ark_mem, &ark_mem->tempv2); + arkFreeVec(ark_mem, &ark_mem->tempv3); + arkFreeVec(ark_mem, &ark_mem->tempv4); + arkFreeVec(ark_mem, &ark_mem->yn); + arkFreeVec(ark_mem, &ark_mem->fn); + arkFreeVec(ark_mem, &ark_mem->Vabstol); + arkFreeVec(ark_mem, &ark_mem->constraints); } /*--------------------------------------------------------------- diff --git a/src/arkode/arkode_adapt.c b/src/arkode/arkode_adapt.c index e10db72d5a..5d6896a46f 100644 --- a/src/arkode/arkode_adapt.c +++ b/src/arkode/arkode_adapt.c @@ -37,7 +37,7 @@ ARKodeHAdaptMem arkAdaptInit(void) hadapt_mem = (ARKodeHAdaptMem)malloc(sizeof(struct ARKodeHAdaptMemRec)); if (hadapt_mem == NULL) { return (NULL); } - /* initialize values (default parameters are set in arkSetDefaults) */ + /* initialize values (default parameters are set in ARKodeSetDefaults) */ memset(hadapt_mem, 0, sizeof(struct ARKodeHAdaptMemRec)); hadapt_mem->nst_acc = 0; hadapt_mem->nst_exp = 0; @@ -91,20 +91,12 @@ void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile) computes and sets the value of ark_eta inside of the ARKodeMem data structure. ---------------------------------------------------------------*/ -int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, +int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, sunrealtype tcur, sunrealtype hcur, sunrealtype dsm, long int nst) { int retval; sunrealtype h_acc, h_cfl, int_dir; - ARKodeMem ark_mem; int controller_order; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; /* Request error-based step size from adaptivity controller */ if (hadapt_mem->pq == 0) diff --git a/src/arkode/arkode_adapt_impl.h b/src/arkode/arkode_adapt_impl.h index 9f96027ca4..3d86d9e385 100644 --- a/src/arkode/arkode_adapt_impl.h +++ b/src/arkode/arkode_adapt_impl.h @@ -22,6 +22,8 @@ #include #include +#include "arkode_types_impl.h" + #ifdef __cplusplus /* wrapper to enable C++ usage */ extern "C" { #endif @@ -41,26 +43,24 @@ extern "C" { #define HFIXED_LB SUN_RCONST(1.0) /* CVODE uses 1.0 */ #define HFIXED_UB SUN_RCONST(1.5) /* CVODE uses 1.5 */ -#define ETAMX1 SUN_RCONST(10000.0) /* maximum step size change on first step */ -#define ETAMXF \ - SUN_RCONST(0.3) /* step size reduction factor on multiple error - test failures (multiple implies >= SMALL_NEF) */ -#define ETAMIN \ - SUN_RCONST(0.1) /* smallest allowable step size reduction factor - on an error test failure */ -#define ETACF \ - SUN_RCONST(0.25) /* step size reduction factor on nonlinear - convergence failure */ -#define SMALL_NEF \ - 2 /* if an error failure occurs and SMALL_NEF <= nef, - then reset eta = MIN(eta, ETAMXF) */ -#define PQ \ - 0 /* order to use for controller: 0=embedding, - 1=method, otherwise min(method,embedding) - REMOVE AT SAME TIME AS ARKStepSetAdaptivityMethod */ -#define ADJUST \ - -1 /* adjustment to apply within controller to method - order of accuracy */ +/* maximum step size change on first step */ +#define ETAMX1 SUN_RCONST(10000.0) +/* step size reduction factor on multiple error test failures (multiple implies >= SMALL_NEF) */ +#define ETAMXF SUN_RCONST(0.3) +/* smallest allowable step size reduction factor on an error test failure */ +#define ETAMIN SUN_RCONST(0.1) +/* step size reduction factor on nonlinear convergence failure */ +#define ETACF SUN_RCONST(0.25) +/* if an error failure occurs and SMALL_NEF <= nef, then reset eta = MIN(eta, ETAMXF) */ +#define SMALL_NEF 2 +/* order to use for controller: + 0=embedding, + 1=method, + otherwise min(method,embedding) + DEPRECATED, REMOVE AT SAME TIME AS ARKStepSetAdaptivityMethod */ +#define PQ 0 +/* adjustment to apply within controller to method order of accuracy */ +#define ADJUST -1 /*=============================================================== ARKODE Time Step Adaptivity Data Structure @@ -108,7 +108,7 @@ typedef struct ARKodeHAdaptMemRec ARKodeHAdaptMem arkAdaptInit(void); void arkPrintAdaptMem(ARKodeHAdaptMem hadapt_mem, FILE* outfile); -int arkAdapt(void* arkode_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, +int arkAdapt(ARKodeMem ark_mem, ARKodeHAdaptMem hadapt_mem, N_Vector ycur, sunrealtype tcur, sunrealtype hcur, sunrealtype dsm, long int nst); #ifdef __cplusplus diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 145bcc8531..68a7fc8299 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -29,7 +29,7 @@ #define FIXED_LIN_TOL /*=============================================================== - ARKStep Exported functions -- Required + Exported functions ===============================================================*/ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, @@ -89,33 +89,67 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_ARKMEM_FAIL); - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } memset(step_mem, 0, sizeof(struct ARKodeARKStepMemRec)); /* Attach step_mem structure and function pointers to ark_mem */ - ark_mem->step_attachlinsol = arkStep_AttachLinsol; - ark_mem->step_attachmasssol = arkStep_AttachMasssol; - ark_mem->step_disablelsetup = arkStep_DisableLSetup; - ark_mem->step_disablemsetup = arkStep_DisableMSetup; - ark_mem->step_getlinmem = arkStep_GetLmem; - ark_mem->step_getmassmem = arkStep_GetMassMem; - ark_mem->step_getimplicitrhs = arkStep_GetImplicitRHS; - ark_mem->step_mmult = NULL; - ark_mem->step_getgammas = arkStep_GetGammas; - ark_mem->step_init = arkStep_Init; - ark_mem->step_fullrhs = arkStep_FullRHS; - ark_mem->step = arkStep_TakeStep_Z; - ark_mem->step_mem = (void*)step_mem; - - /* Set default values for ARKStep optional inputs */ - retval = ARKStepSetDefaults((void*)ark_mem); + ark_mem->step_attachlinsol = arkStep_AttachLinsol; + ark_mem->step_attachmasssol = arkStep_AttachMasssol; + ark_mem->step_disablelsetup = arkStep_DisableLSetup; + ark_mem->step_disablemsetup = arkStep_DisableMSetup; + ark_mem->step_getlinmem = arkStep_GetLmem; + ark_mem->step_getmassmem = arkStep_GetMassMem; + ark_mem->step_getimplicitrhs = arkStep_GetImplicitRHS; + ark_mem->step_mmult = NULL; + ark_mem->step_getgammas = arkStep_GetGammas; + ark_mem->step_init = arkStep_Init; + ark_mem->step_fullrhs = arkStep_FullRHS; + ark_mem->step = arkStep_TakeStep_Z; + ark_mem->step_setuserdata = arkStep_SetUserData; + ark_mem->step_printallstats = arkStep_PrintAllStats; + ark_mem->step_writeparameters = arkStep_WriteParameters; + ark_mem->step_resize = arkStep_Resize; + ark_mem->step_free = arkStep_Free; + ark_mem->step_printmem = arkStep_PrintMem; + ark_mem->step_setdefaults = arkStep_SetDefaults; + ark_mem->step_computestate = arkStep_ComputeState; + ark_mem->step_setrelaxfn = arkStep_SetRelaxFn; + ark_mem->step_setorder = arkStep_SetOrder; + ark_mem->step_setnonlinearsolver = arkStep_SetNonlinearSolver; + ark_mem->step_setlinear = arkStep_SetLinear; + ark_mem->step_setnonlinear = arkStep_SetNonlinear; + ark_mem->step_setnlsrhsfn = arkStep_SetNlsRhsFn; + ark_mem->step_setdeduceimplicitrhs = arkStep_SetDeduceImplicitRhs; + ark_mem->step_setnonlincrdown = arkStep_SetNonlinCRDown; + ark_mem->step_setnonlinrdiv = arkStep_SetNonlinRDiv; + ark_mem->step_setdeltagammamax = arkStep_SetDeltaGammaMax; + ark_mem->step_setlsetupfrequency = arkStep_SetLSetupFrequency; + ark_mem->step_setpredictormethod = arkStep_SetPredictorMethod; + ark_mem->step_setmaxnonliniters = arkStep_SetMaxNonlinIters; + ark_mem->step_setnonlinconvcoef = arkStep_SetNonlinConvCoef; + ark_mem->step_setstagepredictfn = arkStep_SetStagePredictFn; + ark_mem->step_getnumlinsolvsetups = arkStep_GetNumLinSolvSetups; + ark_mem->step_getcurrentgamma = arkStep_GetCurrentGamma; + ark_mem->step_getestlocalerrors = arkStep_GetEstLocalErrors; + ark_mem->step_getnonlinearsystemdata = arkStep_GetNonlinearSystemData; + ark_mem->step_getnumnonlinsolviters = arkStep_GetNumNonlinSolvIters; + ark_mem->step_getnumnonlinsolvconvfails = arkStep_GetNumNonlinSolvConvFails; + ark_mem->step_getnonlinsolvstats = arkStep_GetNonlinSolvStats; + ark_mem->step_supports_adaptive = SUNTRUE; + ark_mem->step_supports_implicit = SUNTRUE; + ark_mem->step_supports_massmatrix = SUNTRUE; + ark_mem->step_supports_relaxation = SUNTRUE; + ark_mem->step_mem = (void*)step_mem; + + /* Set default values for optional inputs */ + retval = arkStep_SetDefaults((void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Error setting default solver options"); - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -130,17 +164,17 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, /* Clone the input vector to create sdata, zpred and zcor */ if (!arkAllocVec(ark_mem, y0, &(step_mem->sdata))) { - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } if (!arkAllocVec(ark_mem, y0, &(step_mem->zpred))) { - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } if (!arkAllocVec(ark_mem, y0, &(step_mem->zcor))) { - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -161,15 +195,15 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, "Error creating default Newton solver"); - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } - retval = ARKStepSetNonlinearSolver(ark_mem, NLS); + retval = ARKodeSetNonlinearSolver(ark_mem, NLS); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, "Error attaching default Newton solver"); - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } step_mem->ownNLS = SUNTRUE; @@ -221,141 +255,13 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Unable to initialize main ARKODE infrastructure"); - ARKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } return ((void*)ark_mem); } -/*--------------------------------------------------------------- - ARKStepResize: - - This routine resizes the memory within the ARKStep module. - It first resizes the main ARKODE infrastructure memory, and - then resizes its own data. - ---------------------------------------------------------------*/ -int ARKStepResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) -{ - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - SUNNonlinearSolver NLS; - sunindextype lrw1, liw1, lrw_diff, liw_diff; - int i, retval; - - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Determing change in vector sizes */ - lrw1 = liw1 = 0; - if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } - lrw_diff = lrw1 - ark_mem->lrw1; - liw_diff = liw1 - ark_mem->liw1; - ark_mem->lrw1 = lrw1; - ark_mem->liw1 = liw1; - - /* resize ARKODE infrastructure memory */ - retval = arkResize(ark_mem, y0, hscale, t0, resize, resize_data); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to resize main ARKODE infrastructure"); - return (retval); - } - - /* Resize the sdata, zpred and zcor vectors */ - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, - &step_mem->sdata)) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to resize vector"); - return (ARK_MEM_FAIL); - } - - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, - &step_mem->zpred)) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to resize vector"); - return (ARK_MEM_FAIL); - } - - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, - &step_mem->zcor)) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to resize vector"); - return (ARK_MEM_FAIL); - } - - /* Resize the ARKStep vectors */ - /* Fe */ - if (step_mem->Fe != NULL) - { - for (i = 0; i < step_mem->stages; i++) - { - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, - &step_mem->Fe[i])) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to resize vector"); - return (ARK_MEM_FAIL); - } - } - } - /* Fi */ - if (step_mem->Fi != NULL) - { - for (i = 0; i < step_mem->stages; i++) - { - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, - &step_mem->Fi[i])) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to resize vector"); - return (ARK_MEM_FAIL); - } - } - } - - /* If a NLS object was previously used, destroy and recreate default Newton - NLS object (can be replaced by user-defined object if desired) */ - if ((step_mem->NLS != NULL) && (step_mem->ownNLS)) - { - /* destroy existing NLS object */ - retval = SUNNonlinSolFree(step_mem->NLS); - if (retval != ARK_SUCCESS) { return (retval); } - step_mem->NLS = NULL; - step_mem->ownNLS = SUNFALSE; - - /* create new Newton NLS object */ - NLS = SUNNonlinSol_Newton(y0, ark_mem->sunctx); - if (NLS == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Error creating default Newton solver"); - return (ARK_MEM_FAIL); - } - - /* attach new Newton NLS object to ARKStep */ - retval = ARKStepSetNonlinearSolver(ark_mem, NLS); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Error attaching default Newton solver"); - return (ARK_MEM_FAIL); - } - step_mem->ownNLS = SUNTRUE; - } - - /* reset nonlinear solver counters */ - if (step_mem->NLS != NULL) { step_mem->nsetups = 0; } - - return (ARK_SUCCESS); -} - /*--------------------------------------------------------------- ARKStepReInit: @@ -374,8 +280,8 @@ int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -431,210 +337,196 @@ int ARKStepReInit(void* arkode_mem, ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - ARKStepReset: +/*------------------------------------------------------------------------------ + ARKStepCreateMRIStepInnerStepper - This routine resets the ARKStep module state to solve the same - problem from the given time with the input state (all counter - values are retained). - ---------------------------------------------------------------*/ -int ARKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) + Wraps an ARKStep memory structure as an MRIStep inner stepper. + ----------------------------------------------------------------------------*/ +int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, + MRIStepInnerStepper* stepper) { + int retval; ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessARKODEStepMem(inner_arkode_mem, + "ARKStepCreateMRIStepInnerStepper", + &ark_mem, &step_mem); + if (retval) + { + arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "The ARKStep memory pointer is NULL"); + return ARK_ILL_INPUT; + } + + retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); if (retval != ARK_SUCCESS) { return (retval); } - /* Initialize main ARKODE infrastructure */ - retval = arkInit(ark_mem, tR, yR, RESET_INIT); + retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); + if (retval != ARK_SUCCESS) { return (retval); } - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to initialize main ARKODE infrastructure"); - return (retval); - } + retval = MRIStepInnerStepper_SetEvolveFn(*stepper, arkStep_MRIStepInnerEvolve); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, + arkStep_MRIStepInnerFullRhs); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetResetFn(*stepper, arkStep_MRIStepInnerReset); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, + arkStep_MRIStepInnerGetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = + MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, + arkStep_MRIStepInnerResetAccumulatedError); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, + arkStep_MRIStepInnerSetFixedStep); + if (retval != ARK_SUCCESS) { return (retval); } + + retval = MRIStepInnerStepper_SetRTolFn(*stepper, arkStep_MRIStepInnerSetRTol); + if (retval != ARK_SUCCESS) { return (retval); } return (ARK_SUCCESS); } +/*=============================================================== + Interface routines supplied to ARKODE + ===============================================================*/ + /*--------------------------------------------------------------- - ARKStepSStolerances, ARKStepSVtolerances, ARKStepWFtolerances, - ARKStepResStolerance, ARKStepResVtolerance, ARKStepResFtolerance: + arkStep_Resize: - These routines set integration tolerances (wrappers for general - ARKODE utility routines) + This routine resizes the memory within the ARKStep module. ---------------------------------------------------------------*/ -int ARKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) +int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - /* unpack ark_mem, call arkSStolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkSStolerances(ark_mem, reltol, abstol)); -} + ARKodeARKStepMem step_mem; + SUNNonlinearSolver NLS; + sunindextype lrw1, liw1, lrw_diff, liw_diff; + int i, retval; -int ARKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) -{ - /* unpack ark_mem, call arkSVtolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Determine change in vector sizes */ + lrw1 = liw1 = 0; + if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } + lrw_diff = lrw1 - ark_mem->lrw1; + liw_diff = liw1 - ark_mem->liw1; + ark_mem->lrw1 = lrw1; + ark_mem->liw1 = liw1; + + /* Resize the sdata, zpred and zcor vectors */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->sdata)) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); } - ark_mem = (ARKodeMem)arkode_mem; - return (arkSVtolerances(ark_mem, reltol, abstol)); -} -int ARKStepWFtolerances(void* arkode_mem, ARKEwtFn efun) -{ - /* unpack ark_mem, call arkWFtolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->zpred)) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); } - ark_mem = (ARKodeMem)arkode_mem; - return (arkWFtolerances(ark_mem, efun)); -} -int ARKStepResStolerance(void* arkode_mem, sunrealtype rabstol) -{ - /* unpack ark_mem, call arkResStolerance, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->zcor)) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); } - ark_mem = (ARKodeMem)arkode_mem; - return (arkResStolerance(ark_mem, rabstol)); -} -int ARKStepResVtolerance(void* arkode_mem, N_Vector rabstol) -{ - /* unpack ark_mem, call arkResVtolerance, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + /* Resize the ARKStep vectors */ + /* Fe */ + if (step_mem->Fe != NULL) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + for (i = 0; i < step_mem->stages; i++) + { + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->Fe[i])) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); + } + } } - ark_mem = (ARKodeMem)arkode_mem; - return (arkResVtolerance(ark_mem, rabstol)); -} - -int ARKStepResFtolerance(void* arkode_mem, ARKRwtFn rfun) -{ - /* unpack ark_mem, call arkResFtolerance, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + /* Fi */ + if (step_mem->Fi != NULL) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + for (i = 0; i < step_mem->stages; i++) + { + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->Fi[i])) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); + } + } } - ark_mem = (ARKodeMem)arkode_mem; - return (arkResFtolerance(ark_mem, rfun)); -} - -/*--------------------------------------------------------------- - ARKStepRootInit: - Initialize (attach) a rootfinding problem to the stepper - (wrappers for general ARKODE utility routine) - ---------------------------------------------------------------*/ -int ARKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) -{ - /* unpack ark_mem, call arkRootInit, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + /* If a NLS object was previously used, destroy and recreate default Newton + NLS object (can be replaced by user-defined object if desired) */ + if ((step_mem->NLS != NULL) && (step_mem->ownNLS)) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkRootInit(ark_mem, nrtfn, g)); -} + /* destroy existing NLS object */ + retval = SUNNonlinSolFree(step_mem->NLS); + if (retval != ARK_SUCCESS) { return (retval); } + step_mem->NLS = NULL; + step_mem->ownNLS = SUNFALSE; -/*--------------------------------------------------------------- - ARKStepEvolve: + /* create new Newton NLS object */ + NLS = SUNNonlinSol_Newton(y0, ark_mem->sunctx); + if (NLS == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Error creating default Newton solver"); + return (ARK_MEM_FAIL); + } - This is the main time-integration driver (wrappers for general - ARKODE utility routine) - ---------------------------------------------------------------*/ -int ARKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask) -{ - /* unpack ark_mem, call arkEvolve, and return */ - int retval; - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + /* attach new Newton NLS object */ + retval = ARKodeSetNonlinearSolver(ark_mem, NLS); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Error attaching default Newton solver"); + return (ARK_MEM_FAIL); + } + step_mem->ownNLS = SUNTRUE; } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkEvolve(ark_mem, tout, yout, tret, itask); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); -} -/*--------------------------------------------------------------- - ARKStepGetDky: + /* reset nonlinear solver counters */ + if (step_mem->NLS != NULL) { step_mem->nsetups = 0; } - This returns interpolated output of the solution or its - derivatives over the most-recently-computed step (wrapper for - generic ARKODE utility routine) - ---------------------------------------------------------------*/ -int ARKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) -{ - /* unpack ark_mem, call arkGetDky, and return */ - int retval; - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkGetDky(ark_mem, t, k, dky); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepComputeState: + arkStep_ComputeState: Computes y based on the current prediction and given correction. ---------------------------------------------------------------*/ -int ARKStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) +int arkStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z) { int retval; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } N_VLinearSum(ONE, step_mem->zpred, ONE, zcor, z); @@ -643,21 +535,18 @@ int ARKStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) } /*--------------------------------------------------------------- - ARKStepFree frees all ARKStep memory, and then calls an ARKODE - utility routine to free the ARKODE infrastructure memory. + arkStep_Free frees all ARKStep memory. ---------------------------------------------------------------*/ -void ARKStepFree(void** arkode_mem) +void arkStep_Free(ARKodeMem ark_mem) { int j; sunindextype Bliw, Blrw; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - /* nothing to do if arkode_mem is already NULL */ - if (*arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL ARKStep module */ - ark_mem = (ARKodeMem)(*arkode_mem); if (ark_mem->step_mem != NULL) { step_mem = (ARKodeARKStepMem)ark_mem->step_mem; @@ -787,21 +676,16 @@ void ARKStepFree(void** arkode_mem) free(ark_mem->step_mem); ark_mem->step_mem = NULL; } - - /* free memory for overall ARKODE infrastructure */ - arkFree(arkode_mem); } /*--------------------------------------------------------------- - ARKStepPrintMem: + arkStep_PrintMem: - This routine outputs the memory from the ARKStep structure and - the main ARKODE infrastructure to a specified file pointer - (useful when debugging). + This routine outputs the memory from the ARKStep structure to + a specified file pointer (useful when debugging). ---------------------------------------------------------------*/ -void ARKStepPrintMem(void* arkode_mem, FILE* outfile) +void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; @@ -810,15 +694,9 @@ void ARKStepPrintMem(void* arkode_mem, FILE* outfile) #endif /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } - /* if outfile==NULL, set it to stdout */ - if (outfile == NULL) { outfile = stdout; } - - /* output data from main ARKODE infrastructure */ - arkPrintMem(ark_mem, outfile); - /* output integer quantities */ fprintf(outfile, "ARKStep: q = %i\n", step_mem->q); fprintf(outfile, "ARKStep: p = %i\n", step_mem->p); @@ -889,14 +767,6 @@ void ARKStepPrintMem(void* arkode_mem, FILE* outfile) #endif } -/*=============================================================== - ARKStep Private functions - ===============================================================*/ - -/*--------------------------------------------------------------- - Interface routines supplied to ARKODE - ---------------------------------------------------------------*/ - /*--------------------------------------------------------------- arkStep_AttachLinsol: @@ -904,21 +774,20 @@ void ARKStepPrintMem(void* arkode_mem, FILE* outfile) interface routines, data structure, and solver type to the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int arkStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* free any existing system solver */ - if (step_mem->lfree != NULL) { step_mem->lfree(arkode_mem); } + if (step_mem->lfree != NULL) { step_mem->lfree(ark_mem); } /* Attach the provided routines, data structure and solve type */ step_mem->linit = linit; @@ -942,22 +811,21 @@ int arkStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, interface routines, data structure, and solver type to the ARKStep module. ---------------------------------------------------------------*/ -int arkStep_AttachMasssol(void* arkode_mem, ARKMassInitFn minit, +int arkStep_AttachMasssol(ARKodeMem ark_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, ARKMassMultFn mmult, ARKMassSolveFn msolve, ARKMassFreeFn mfree, sunbooleantype time_dep, SUNLinearSolver_Type msolve_type, void* mass_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* free any existing mass matrix solver */ - if (step_mem->mfree != NULL) { step_mem->mfree(arkode_mem); } + if (step_mem->mfree != NULL) { step_mem->mfree(ark_mem); } /* Attach the provided routines, data structure and solve type */ step_mem->minit = minit; @@ -981,14 +849,11 @@ int arkStep_AttachMasssol(void* arkode_mem, ARKMassInitFn minit, This routine NULLifies the lsetup function pointer in the ARKStep module. ---------------------------------------------------------------*/ -void arkStep_DisableLSetup(void* arkode_mem) +void arkStep_DisableLSetup(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; /* access ARKodeARKStepMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem == NULL) { return; } step_mem = (ARKodeARKStepMem)ark_mem->step_mem; @@ -1002,14 +867,11 @@ void arkStep_DisableLSetup(void* arkode_mem) This routine NULLifies the msetup function pointer in the ARKStep module. ---------------------------------------------------------------*/ -void arkStep_DisableMSetup(void* arkode_mem) +void arkStep_DisableMSetup(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; /* access ARKodeARKStepMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; if (ark_mem->step_mem == NULL) { return; } step_mem = (ARKodeARKStepMem)ark_mem->step_mem; @@ -1023,14 +885,13 @@ void arkStep_DisableMSetup(void* arkode_mem) This routine returns the system linear solver interface memory structure, lmem. ---------------------------------------------------------------*/ -void* arkStep_GetLmem(void* arkode_mem) +void* arkStep_GetLmem(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure, and return lmem */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->lmem); } @@ -1041,14 +902,13 @@ void* arkStep_GetLmem(void* arkode_mem) This routine returns the mass matrix solver interface memory structure, mass_mem. ---------------------------------------------------------------*/ -void* arkStep_GetMassMem(void* arkode_mem) +void* arkStep_GetMassMem(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure, and return mass_mem */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->mass_mem); } @@ -1058,14 +918,13 @@ void* arkStep_GetMassMem(void* arkode_mem) This routine returns the implicit RHS function pointer, fi. ---------------------------------------------------------------*/ -ARKRhsFn arkStep_GetImplicitRHS(void* arkode_mem) +ARKRhsFn arkStep_GetImplicitRHS(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure, and return fi */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->fi); } @@ -1076,15 +935,14 @@ ARKRhsFn arkStep_GetImplicitRHS(void* arkode_mem) This routine fills the current value of gamma, and states whether the gamma ratio fails the dgmax criteria. ---------------------------------------------------------------*/ -int arkStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set outputs */ @@ -1131,15 +989,14 @@ int arkStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int arkStep_Init(void* arkode_mem, int init_type) +int arkStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int j, retval; sunbooleantype reset_efun; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if reset */ @@ -1449,10 +1306,9 @@ int arkStep_Init(void* arkode_mem, int init_type) when estimating the initial time step size, so we strive to store the intermediate parts so that they do not interfere with the other two modes. ----------------------------------------------------------------------------*/ -int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int nvec, retval; sunbooleantype recomputeRHS; @@ -1461,7 +1317,7 @@ int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, sunrealtype stage_coefs = ONE; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* local shortcuts for use with fused vector operations */ @@ -1819,19 +1675,18 @@ int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int arkStep_TakeStep_Z(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { int retval, is, is_start, mode; sunbooleantype implicit_stage; sunbooleantype deduce_stage; sunbooleantype save_stages; sunbooleantype stiffly_accurate; - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; N_Vector zcor0; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if problem will involve no algebraic solvers, initialize nflagPtr to success */ @@ -2189,18 +2044,18 @@ int arkStep_TakeStep_Z(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== Internal utility routines - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- - arkStep_AccessStepMem: + arkStep_AccessARKODEStepMem: Shortcut routine to unpack ark_mem and step_mem structures from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int arkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem) +int arkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -2210,6 +2065,8 @@ int arkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeARKStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -2220,6 +2077,26 @@ int arkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + arkStep_AccessStepMem: + + Shortcut routine to unpack ark_mem and step_mem structures from + void* pointer. If either is missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int arkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeARKStepMem* step_mem) +{ + /* access ARKodeARKStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_ARKSTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeARKStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- arkStep_CheckNVector: @@ -3223,66 +3100,9 @@ int arkStep_ComputeSolutions_MassFixed(ARKodeMem ark_mem, sunrealtype* dsmPtr) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - Utility routines for ARKStep to serve as an MRIStepInnerStepper - ---------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------ - ARKStepCreateMRIStepInnerStepper - - Wraps an ARKStep memory structure as an MRIStep inner stepper. - ----------------------------------------------------------------------------*/ - -int ARKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, - MRIStepInnerStepper* stepper) -{ - int retval; - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - - retval = arkStep_AccessStepMem(inner_arkode_mem, __func__, &ark_mem, &step_mem); - if (retval) - { - arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "The ARKStep memory pointer is NULL"); - return ARK_ILL_INPUT; - } - - retval = MRIStepInnerStepper_Create(ark_mem->sunctx, stepper); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetContent(*stepper, inner_arkode_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetEvolveFn(*stepper, arkStep_MRIStepInnerEvolve); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetFullRhsFn(*stepper, - arkStep_MRIStepInnerFullRhs); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetResetFn(*stepper, arkStep_MRIStepInnerReset); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorGetFn(*stepper, - arkStep_MRIStepInnerGetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = - MRIStepInnerStepper_SetAccumulatedErrorResetFn(*stepper, - arkStep_MRIStepInnerResetAccumulatedError); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetFixedStepFn(*stepper, - arkStep_MRIStepInnerSetFixedStep); - if (retval != ARK_SUCCESS) { return (retval); } - - retval = MRIStepInnerStepper_SetRTolFn(*stepper, arkStep_MRIStepInnerSetRTol); - if (retval != ARK_SUCCESS) { return (retval); } - - return (ARK_SUCCESS); -} +/*=============================================================== + Internal utility routines for interacting with MRIStep + ===============================================================*/ /*------------------------------------------------------------------------------ arkStep_MRIStepInnerEvolve @@ -3315,11 +3135,11 @@ int arkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, if (retval != ARK_SUCCESS) { return (retval); } /* set the stop time */ - retval = ARKStepSetStopTime(arkode_mem, tout); + retval = ARKodeSetStopTime(arkode_mem, tout); if (retval != ARK_SUCCESS) { return (retval); } /* evolve inner ODE */ - retval = ARKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); if (retval < 0) { return (retval); } /* disable inner forcing */ @@ -3366,7 +3186,7 @@ int arkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ARKStepReset(arkode_mem, tR, yR)); + return (ARKodeReset(arkode_mem, tR, yR)); } /*------------------------------------------------------------------------------ @@ -3386,7 +3206,7 @@ int arkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ARKStepGetAccumulatedError(arkode_mem, accum_error)); + return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); } /*------------------------------------------------------------------------------ @@ -3405,7 +3225,7 @@ int arkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ARKStepResetAccumulatedError(arkode_mem)); + return (ARKodeResetAccumulatedError(arkode_mem)); } /*------------------------------------------------------------------------------ @@ -3424,7 +3244,7 @@ int arkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ARKStepSetFixedStep(arkode_mem, h)); + return (ARKodeSetFixedStep(arkode_mem, h)); } /*------------------------------------------------------------------------------ @@ -3542,8 +3362,8 @@ int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) @@ -3617,6 +3437,10 @@ int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, return (0); } +/*=============================================================== + Internal utility routines for relaxation + ===============================================================*/ + /* ----------------------------------------------------------------------------- * arkStep_RelaxDeltaE * @@ -3635,7 +3459,6 @@ int arkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, * be necessary to compute the delta_e estimate along the way with explicit * methods to avoid storing additional RHS or stage values. * ---------------------------------------------------------------------------*/ - int arkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, long int* num_relax_jac_evals, sunrealtype* delta_e_out) { @@ -3756,7 +3579,6 @@ int arkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, * * Returns the method order * ---------------------------------------------------------------------------*/ - int arkStep_GetOrder(ARKodeMem ark_mem) { ARKodeARKStepMem step_mem = (ARKodeARKStepMem)(ark_mem->step_mem); diff --git a/src/arkode/arkode_arkstep_impl.h b/src/arkode/arkode_arkstep_impl.h index 38976f34ea..c300f48497 100644 --- a/src/arkode/arkode_arkstep_impl.h +++ b/src/arkode/arkode_arkstep_impl.h @@ -19,7 +19,6 @@ #define _ARKODE_ARKSTEP_IMPL_H #include -/* access to MRIStepInnerStepper_Create */ #include #include "arkode_impl.h" @@ -33,13 +32,16 @@ extern "C" { ARK time step module constants ===============================================================*/ -#define MAXCOR 3 /* max number of nonlinear iterations */ -#define CRDOWN \ - SUN_RCONST(0.3) /* constant to estimate the convergence - rate for the nonlinear equation */ -#define DGMAX SUN_RCONST(0.2) /* if |gamma/gammap-1| > DGMAX then call lsetup */ -#define RDIV SUN_RCONST(2.3) /* declare divergence if ratio del/delp > RDIV */ -#define MSBP 20 /* max no. of steps between lsetup calls */ +/* max number of nonlinear iterations */ +#define MAXCOR 3 +/* constant to estimate the convergence rate for the nonlinear equation */ +#define CRDOWN SUN_RCONST(0.3) +/* if |gamma/gammap-1| > DGMAX then call lsetup */ +#define DGMAX SUN_RCONST(0.2) +/* declare divergence if ratio del/delp > RDIV */ +#define RDIV SUN_RCONST(2.3) +/* max no. of steps between lsetup calls */ +#define MSBP 20 /* Default solver tolerance factor */ /* #define NLSCOEF SUN_RCONST(0.003) */ /* Hairer & Wanner constant */ @@ -166,30 +168,67 @@ typedef struct ARKodeARKStepMemRec ===============================================================*/ /* Interface routines supplied to ARKODE */ -int arkStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int arkStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); -int arkStep_AttachMasssol(void* arkode_mem, ARKMassInitFn minit, +int arkStep_AttachMasssol(ARKodeMem ark_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, ARKMassMultFn mmult, ARKMassSolveFn msolve, ARKMassFreeFn lfree, sunbooleantype time_dep, SUNLinearSolver_Type msolve_type, void* mass_mem); -void arkStep_DisableLSetup(void* arkode_mem); -void arkStep_DisableMSetup(void* arkode_mem); -int arkStep_Init(void* arkode_mem, int init_type); -void* arkStep_GetLmem(void* arkode_mem); -void* arkStep_GetMassMem(void* arkode_mem); -ARKRhsFn arkStep_GetImplicitRHS(void* arkode_mem); -int arkStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +void arkStep_DisableLSetup(ARKodeMem ark_mem); +void arkStep_DisableMSetup(ARKodeMem ark_mem); +int arkStep_Init(ARKodeMem ark_mem, int init_type); +void* arkStep_GetLmem(ARKodeMem ark_mem); +void* arkStep_GetMassMem(ARKodeMem ark_mem); +ARKRhsFn arkStep_GetImplicitRHS(ARKodeMem ark_mem); +int arkStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail); -int arkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int arkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int arkStep_TakeStep_Z(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); +int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int arkStep_SetDefaults(ARKodeMem ark_mem); +int arkStep_SetOrder(ARKodeMem ark_mem, int ord); +int arkStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS); +int arkStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fi); +int arkStep_SetLinear(ARKodeMem ark_mem, int timedepend); +int arkStep_SetNonlinear(ARKodeMem ark_mem); +int arkStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown); +int arkStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv); +int arkStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax); +int arkStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp); +int arkStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method); +int arkStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor); +int arkStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef); +int arkStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage); +int arkStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce); +int arkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); +int arkStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma); +int arkStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data); +int arkStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups); +int arkStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters); +int arkStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails); +int arkStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, + long int* nnfails); +int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int arkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int arkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int arkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data); +int arkStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); +void arkStep_Free(ARKodeMem ark_mem); +void arkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int arkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem); +int arkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeARKStepMem* step_mem); +int arkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeARKStepMem* step_mem); sunbooleantype arkStep_CheckNVector(N_Vector tmpl); int arkStep_SetButcherTables(ARKodeMem ark_mem); int arkStep_CheckButcherTables(ARKodeMem ark_mem); @@ -231,6 +270,7 @@ int arkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) int arkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ +int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); int arkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, long int* relax_jac_fn_evals, sunrealtype* delta_e_out); int arkStep_GetOrder(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_arkstep_io.c b/src/arkode/arkode_arkstep_io.c index 57c951c223..a95ddf9f30 100644 --- a/src/arkode/arkode_arkstep_io.c +++ b/src/arkode/arkode_arkstep_io.c @@ -27,2249 +27,2111 @@ #include "arkode_arkstep_impl.h" /*=============================================================== - ARKStep Optional input functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. + Exported optional input functions. ===============================================================*/ -int ARKStepSetDenseOrder(void* arkode_mem, int dord) -{ - return (ARKStepSetInterpolantDegree(arkode_mem, dord)); -} -int ARKStepSetInterpolantDegree(void* arkode_mem, int degree) -{ - if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; } - return (arkSetInterpolantDegree(arkode_mem, degree)); -} +/*--------------------------------------------------------------- + ARKStepSetExplicit: -int ARKStepSetInterpolantType(void* arkode_mem, int itype) + Specifies that the implicit portion of the problem is disabled, + and to use an explicit RK method. + ---------------------------------------------------------------*/ +int ARKStepSetExplicit(void* arkode_mem) { - return (arkSetInterpolantType(arkode_mem, itype)); -} + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + int retval; -int ARKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) -{ - return (arkSetMaxNumSteps(arkode_mem, mxsteps)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) -{ - return (arkSetMaxHnilWarns(arkode_mem, mxhnil)); -} + /* ensure that fe is defined */ + if (step_mem->fe == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_MISSING_FE); + return (ARK_ILL_INPUT); + } -int ARKStepSetInitStep(void* arkode_mem, sunrealtype hin) -{ - return (arkSetInitStep(arkode_mem, hin)); -} + /* set the relevant parameters */ + step_mem->explicit = SUNTRUE; + step_mem->implicit = SUNFALSE; -int ARKStepSetMinStep(void* arkode_mem, sunrealtype hmin) -{ - return (arkSetMinStep(arkode_mem, hmin)); + return (ARK_SUCCESS); } -int ARKStepSetMaxStep(void* arkode_mem, sunrealtype hmax) -{ - return (arkSetMaxStep(arkode_mem, hmax)); -} +/*--------------------------------------------------------------- + ARKStepSetImplicit: -int ARKStepSetStopTime(void* arkode_mem, sunrealtype tstop) + Specifies that the explicit portion of the problem is disabled, + and to use an implicit RK method. + ---------------------------------------------------------------*/ +int ARKStepSetImplicit(void* arkode_mem) { - return (arkSetStopTime(arkode_mem, tstop)); -} + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + int retval; -int ARKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) -{ - return (arkSetInterpolateStopTime(arkode_mem, interp)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepClearStopTime(void* arkode_mem) -{ - return (arkClearStopTime(arkode_mem)); -} + /* ensure that fi is defined */ + if (step_mem->fi == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_MISSING_FI); + return (ARK_ILL_INPUT); + } -int ARKStepSetRootDirection(void* arkode_mem, int* rootdir) -{ - return (arkSetRootDirection(arkode_mem, rootdir)); -} + /* set the relevant parameters */ + step_mem->implicit = SUNTRUE; + step_mem->explicit = SUNFALSE; -int ARKStepSetNoInactiveRootWarn(void* arkode_mem) -{ - return (arkSetNoInactiveRootWarn(arkode_mem)); -} + /* re-attach internal error weight functions if necessary */ + if (!ark_mem->user_efun) + { + if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) + { + retval = ARKodeSVtolerances(ark_mem, ark_mem->reltol, ark_mem->Vabstol); + } + else + { + retval = ARKodeSStolerances(ark_mem, ark_mem->reltol, ark_mem->Sabstol); + } + if (retval != ARK_SUCCESS) { return (retval); } + } -int ARKStepSetConstraints(void* arkode_mem, N_Vector constraints) -{ - return (arkSetConstraints(arkode_mem, constraints)); + return (ARK_SUCCESS); } -int ARKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) -{ - return (arkSetMaxNumConstrFails(arkode_mem, maxfails)); -} +/*--------------------------------------------------------------- + ARKStepSetImEx: -int ARKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) + Specifies that the specifies that problem has both implicit and + explicit parts, and to use an ARK method (this is the default). + ---------------------------------------------------------------*/ +int ARKStepSetImEx(void* arkode_mem) { - return (arkSetPostprocessStepFn(arkode_mem, ProcessStep)); -} + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + int retval; -int ARKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) -{ - return (arkSetPostprocessStageFn(arkode_mem, ProcessStage)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust) -{ - return (arkSetAdaptivityAdjustment(arkode_mem, adjust)); -} + /* ensure that fe and fi are defined */ + if (step_mem->fe == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_MISSING_FE); + return (ARK_ILL_INPUT); + } + if (step_mem->fi == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_MISSING_FI); + return (ARK_ILL_INPUT); + } -int ARKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) -{ - return (arkSetCFLFraction(arkode_mem, cfl_frac)); -} + /* set the relevant parameters */ + step_mem->explicit = SUNTRUE; + step_mem->implicit = SUNTRUE; -int ARKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety) -{ - return (arkSetSafetyFactor(arkode_mem, safety)); -} + /* re-attach internal error weight functions if necessary */ + if (!ark_mem->user_efun) + { + if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) + { + retval = ARKodeSVtolerances(ark_mem, ark_mem->reltol, ark_mem->Vabstol); + } + else + { + retval = ARKodeSStolerances(ark_mem, ark_mem->reltol, ark_mem->Sabstol); + } + if (retval != ARK_SUCCESS) { return (retval); } + } -int ARKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) -{ - return (arkSetMaxGrowth(arkode_mem, mx_growth)); + return (ARK_SUCCESS); } -int ARKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min) -{ - return (arkSetMinReduction(arkode_mem, eta_min)); -} +/*--------------------------------------------------------------- + ARKStepSetTables: -int ARKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) -{ - return (arkSetFixedStepBounds(arkode_mem, lb, ub)); -} + Specifies to use customized Butcher tables for the system. -int ARKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) -{ - return (arkSetMaxFirstGrowth(arkode_mem, etamx1)); -} + If Bi is NULL, then this sets the integrator in 'explicit' mode. -int ARKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) -{ - return (arkSetMaxEFailGrowth(arkode_mem, etamxf)); -} + If Be is NULL, then this sets the integrator in 'implicit' mode. -int ARKStepSetSmallNumEFails(void* arkode_mem, int small_nef) + Returns ARK_ILL_INPUT if both Butcher tables are not supplied. + ---------------------------------------------------------------*/ +int ARKStepSetTables(void* arkode_mem, int q, int p, ARKodeButcherTable Bi, + ARKodeButcherTable Be) { - return (arkSetSmallNumEFails(arkode_mem, small_nef)); -} + int retval; + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + sunindextype Blrw, Bliw; -int ARKStepSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) -{ - return (arkSetMaxCFailGrowth(arkode_mem, etacf)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) -{ - return (arkSetStabilityFn(arkode_mem, EStab, estab_data)); -} + /* check for illegal inputs */ + if ((Bi == NULL) && (Be == NULL)) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "At least one complete table must be supplied"); + return (ARK_ILL_INPUT); + } -int ARKStepSetMaxErrTestFails(void* arkode_mem, int maxnef) -{ - return (arkSetMaxErrTestFails(arkode_mem, maxnef)); -} + /* if both tables are set, check that they have the same number of stages */ + if ((Bi != NULL) && (Be != NULL)) + { + if (Bi->stages != Be->stages) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Both tables must have the same number of stages"); + return (ARK_ILL_INPUT); + } + } -int ARKStepSetMaxConvFails(void* arkode_mem, int maxncf) -{ - return (arkSetMaxConvFails(arkode_mem, maxncf)); -} + /* clear any existing parameters and Butcher tables */ + step_mem->stages = 0; + step_mem->q = 0; + step_mem->p = 0; -int ARKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) -{ - return (arkSetAdaptController(arkode_mem, C)); -} + ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->Be); + step_mem->Be = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ARKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) -{ - return (arkSetFixedStep(arkode_mem, hfixed)); -} + ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->Bi); + step_mem->Bi = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -/*--------------------------------------------------------------- - Wrapper functions for accumulated temporal error estimation. - ---------------------------------------------------------------*/ -int ARKStepSetAccumulatedErrorType(void* arkode_mem, int accum_type) -{ - return (arkSetAccumulatedErrorType(arkode_mem, accum_type)); -} + /* + * determine mode (implicit/explicit/ImEx), and perform appropriate actions + */ -int ARKStepResetAccumulatedError(void* arkode_mem) -{ - return (arkResetAccumulatedError(arkode_mem)); -} + /* explicit */ + if (Bi == NULL) + { + /* set the relevant parameters (use table q and p) */ + step_mem->stages = Be->stages; + step_mem->q = Be->q; + step_mem->p = Be->p; -int ARKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) -{ - return (arkGetAccumulatedError(arkode_mem, accum_error)); -} + /* copy the table in step memory */ + step_mem->Be = ARKodeButcherTable_Copy(Be); + if (step_mem->Be == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } -/*--------------------------------------------------------------- - These wrappers for ARKLs module 'set' routines all are - documented in arkode_arkstep.h. - ---------------------------------------------------------------*/ -int ARKStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) -{ - return (arkLSSetLinearSolver(arkode_mem, LS, A)); -} + /* set method as purely explicit */ + retval = ARKStepSetExplicit(arkode_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Error in ARKStepSetExplicit"); + return (retval); + } -int ARKStepSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, - SUNMatrix M, sunbooleantype time_dep) -{ - return (arkLSSetMassLinearSolver(arkode_mem, LS, M, time_dep)); -} + /* implicit */ + } + else if (Be == NULL) + { + /* set the relevant parameters (use table q and p) */ + step_mem->stages = Bi->stages; + step_mem->q = Bi->q; + step_mem->p = Bi->p; -int ARKStepSetJacFn(void* arkode_mem, ARKLsJacFn jac) -{ - return (arkLSSetJacFn(arkode_mem, jac)); -} + /* copy the table in step memory */ + step_mem->Bi = ARKodeButcherTable_Copy(Bi); + if (step_mem->Bi == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } -int ARKStepSetMassFn(void* arkode_mem, ARKLsMassFn mass) -{ - return (arkLSSetMassFn(arkode_mem, mass)); -} + /* set method as purely implicit */ + retval = ARKStepSetImplicit(arkode_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Error in ARKStepSetImplicit"); + return (ARK_ILL_INPUT); + } -int ARKStepSetJacEvalFrequency(void* arkode_mem, long int msbj) -{ - return (arkLSSetJacEvalFrequency(arkode_mem, msbj)); -} + /* ImEx */ + } + else + { + /* set the relevant parameters (use input q and p) */ + step_mem->stages = Bi->stages; + step_mem->q = q; + step_mem->p = p; -int ARKStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) -{ - return (arkLSSetLinearSolutionScaling(arkode_mem, onoff)); -} + /* copy the explicit table into step memory */ + step_mem->Be = ARKodeButcherTable_Copy(Be); + if (step_mem->Be == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } -int ARKStepSetEpsLin(void* arkode_mem, sunrealtype eplifac) -{ - return (arkLSSetEpsLin(arkode_mem, eplifac)); -} + /* copy the implicit table into step memory */ + step_mem->Bi = ARKodeButcherTable_Copy(Bi); + if (step_mem->Bi == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } -int ARKStepSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) -{ - return (arkLSSetMassEpsLin(arkode_mem, eplifac)); -} + /* set method as ImEx */ + retval = ARKStepSetImEx(arkode_mem); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Error in ARKStepSetImEx"); + return (ARK_ILL_INPUT); + } + } -int ARKStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) -{ - return (arkLSSetNormFactor(arkode_mem, nrmfac)); -} + /* note Butcher table space requirements */ + ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); + ark_mem->liw += Bliw; + ark_mem->lrw += Blrw; -int ARKStepSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac) -{ - return (arkLSSetMassNormFactor(arkode_mem, nrmfac)); -} + ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); + ark_mem->liw += Bliw; + ark_mem->lrw += Blrw; -int ARKStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, - ARKLsPrecSolveFn psolve) -{ - return (arkLSSetPreconditioner(arkode_mem, psetup, psolve)); + return (ARK_SUCCESS); } -int ARKStepSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, - ARKLsMassPrecSolveFn psolve) -{ - return (arkLSSetMassPreconditioner(arkode_mem, psetup, psolve)); -} +/*--------------------------------------------------------------- + ARKStepSetTableNum: -int ARKStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, - ARKLsJacTimesVecFn jtimes) -{ - return (arkLSSetJacTimes(arkode_mem, jtsetup, jtimes)); -} + Specifies to use pre-existing Butcher tables for the system, + based on the integer flags passed to + ARKodeButcherTable_LoadERK() and ARKodeButcherTable_LoadDIRK() + within the files arkode_butcher_erk.c and arkode_butcher_dirk.c + (automatically calls ARKStepSetImEx). -int ARKStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) -{ - return (arkLSSetJacTimesRhsFn(arkode_mem, jtimesRhsFn)); -} + If either argument is negative (illegal), then this disables the + corresponding table (e.g. itable = -1 -> explicit) -int ARKStepSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn msetup, - ARKLsMassTimesVecFn mtimes, void* mtimes_data) + Note: this routine should NOT be used in conjunction with + ARKodeSetOrder. + ---------------------------------------------------------------*/ +int ARKStepSetTableNum(void* arkode_mem, ARKODE_DIRKTableID itable, + ARKODE_ERKTableID etable) { - return (arkLSSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data)); -} + int flag, retval; + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + sunindextype Blrw, Bliw; -int ARKStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) -{ - return (arkLSSetLinSysFn(arkode_mem, linsys)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -/*=============================================================== - ARKStep Optional output functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. - ===============================================================*/ -int ARKStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) -{ - return (arkGetNumStepAttempts(arkode_mem, nstep_attempts)); -} + /* clear any existing parameters and Butcher tables */ + step_mem->stages = 0; + step_mem->q = 0; + step_mem->p = 0; -int ARKStepGetNumSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumSteps(arkode_mem, nsteps)); -} + ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->Be); + step_mem->Be = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ARKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) -{ - return (arkGetActualInitStep(arkode_mem, hinused)); -} + ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->Bi); + step_mem->Bi = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ARKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) -{ - return (arkGetLastStep(arkode_mem, hlast)); -} + /* determine mode (implicit/explicit/ImEx), and perform + appropriate actions */ -int ARKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) -{ - return (arkGetCurrentStep(arkode_mem, hcur)); -} + /* illegal inputs */ + if ((itable < 0) && (etable < 0)) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "At least one valid table number must be supplied"); + return (ARK_ILL_INPUT); -int ARKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) -{ - return (arkGetCurrentTime(arkode_mem, tcur)); -} + /* explicit */ + } + else if (itable < 0) + { + /* check that argument specifies an explicit table */ + if (etable < ARKODE_MIN_ERK_NUM || etable > ARKODE_MAX_ERK_NUM) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Illegal ERK table number"); + return (ARK_ILL_INPUT); + } -int ARKStepGetCurrentState(void* arkode_mem, N_Vector* state) -{ - return (arkGetCurrentState(arkode_mem, state)); -} + /* fill in table based on argument */ + step_mem->Be = ARKodeButcherTable_LoadERK(etable); + if (step_mem->Be == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Error setting explicit table with that index"); + return (ARK_ILL_INPUT); + } + step_mem->stages = step_mem->Be->stages; + step_mem->q = step_mem->Be->q; + step_mem->p = step_mem->Be->p; -int ARKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) -{ - return (arkGetTolScaleFactor(arkode_mem, tolsfact)); -} + /* set method as purely explicit */ + flag = ARKStepSetExplicit(arkode_mem); + if (flag != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Error in ARKStepSetExplicit"); + return (flag); + } -int ARKStepGetErrWeights(void* arkode_mem, N_Vector eweight) -{ - return (arkGetErrWeights(arkode_mem, eweight)); -} + /* implicit */ + } + else if (etable < 0) + { + /* check that argument specifies an implicit table */ + if (itable < ARKODE_MIN_DIRK_NUM || itable > ARKODE_MAX_DIRK_NUM) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Illegal IRK table number"); + return (ARK_ILL_INPUT); + } -int ARKStepGetResWeights(void* arkode_mem, N_Vector rweight) -{ - return (arkGetResWeights(arkode_mem, rweight)); -} + /* fill in table based on argument */ + step_mem->Bi = ARKodeButcherTable_LoadDIRK(itable); + if (step_mem->Bi == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Error setting table with that index"); + return (ARK_ILL_INPUT); + } + step_mem->stages = step_mem->Bi->stages; + step_mem->q = step_mem->Bi->q; + step_mem->p = step_mem->Bi->p; -int ARKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) -{ - return (arkGetEstLocalErrors(arkode_mem, ele)); -} + /* set method as purely implicit */ + flag = ARKStepSetImplicit(arkode_mem); + if (flag != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Error in ARKStepSetImplicit"); + return (flag); + } -int ARKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) -{ - return (arkGetWorkSpace(arkode_mem, lenrw, leniw)); -} - -int ARKStepGetNumGEvals(void* arkode_mem, long int* ngevals) -{ - return (arkGetNumGEvals(arkode_mem, ngevals)); -} - -int ARKStepGetRootInfo(void* arkode_mem, int* rootsfound) -{ - return (arkGetRootInfo(arkode_mem, rootsfound)); -} - -int ARKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, - sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) -{ - return (arkGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); -} - -int ARKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) -{ - return (arkGetNumConstrFails(arkode_mem, nconstrfails)); -} - -int ARKStepGetNumExpSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumExpSteps(arkode_mem, nsteps)); -} + /* ImEx */ + } + else + { + /* ensure that tables match */ + if (!((etable == ARKODE_ARK324L2SA_ERK_4_2_3) && + (itable == ARKODE_ARK324L2SA_DIRK_4_2_3)) && + !((etable == ARKODE_ARK436L2SA_ERK_6_3_4) && + (itable == ARKODE_ARK436L2SA_DIRK_6_3_4)) && + !((etable == ARKODE_ARK437L2SA_ERK_7_3_4) && + (itable == ARKODE_ARK437L2SA_DIRK_7_3_4)) && + !((etable == ARKODE_ARK548L2SA_ERK_8_4_5) && + (itable == ARKODE_ARK548L2SA_DIRK_8_4_5)) && + !((etable == ARKODE_ARK548L2SAb_ERK_8_4_5) && + (itable == ARKODE_ARK548L2SAb_DIRK_8_4_5)) && + !((etable == ARKODE_ARK2_ERK_3_1_2) && (itable == ARKODE_ARK2_DIRK_3_1_2))) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Incompatible Butcher tables for ARK method"); + return (ARK_ILL_INPUT); + } -int ARKStepGetNumAccSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumAccSteps(arkode_mem, nsteps)); -} + /* fill in tables based on arguments */ + step_mem->Bi = ARKodeButcherTable_LoadDIRK(itable); + step_mem->Be = ARKodeButcherTable_LoadERK(etable); + if (step_mem->Bi == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Illegal IRK table number"); + return (ARK_ILL_INPUT); + } + if (step_mem->Be == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Illegal ERK table number"); + return (ARK_ILL_INPUT); + } + step_mem->stages = step_mem->Bi->stages; + step_mem->q = step_mem->Bi->q; + step_mem->p = step_mem->Bi->p; -int ARKStepGetNumErrTestFails(void* arkode_mem, long int* netfails) -{ - return (arkGetNumErrTestFails(arkode_mem, netfails)); -} + /* set method as ImEx */ + if (ARKStepSetImEx(arkode_mem) != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_MISSING_F); + return (ARK_ILL_INPUT); + } + } -int ARKStepGetNumStepSolveFails(void* arkode_mem, long int* nncfails) -{ - return (arkGetNumStepSolveFails(arkode_mem, nncfails)); + return (ARK_SUCCESS); } -int ARKStepGetUserData(void* arkode_mem, void** user_data) -{ - return (arkGetUserData(arkode_mem, user_data)); -} +/*--------------------------------------------------------------- + ARKStepSetTableName: -char* ARKStepGetReturnFlagName(long int flag) -{ - return (arkGetReturnFlagName(flag)); -} + Specifies to use pre-existing Butcher tables for the system, + based on the string passed to + ARKodeButcherTable_LoadERKByName() and + ARKodeButcherTable_LoadDIRKByName() within the files + arkode_butcher_erk.c and arkode_butcher_dirk.c (automatically + calls ARKStepSetImEx). -/*--------------------------------------------------------------- - These wrappers for ARKLs module 'get' routines all are - documented in arkode_arkstep.h. + If itable is "ARKODE_DIRK_NONE" or etable is "ARKODE_ERK_NONE", + then this disables the corresponding table. ---------------------------------------------------------------*/ -int ARKStepGetJac(void* arkode_mem, SUNMatrix* J) +int ARKStepSetTableName(void* arkode_mem, const char* itable, const char* etable) { - return arkLSGetJac(arkode_mem, J); + return (ARKStepSetTableNum(arkode_mem, arkButcherTableDIRKNameToID(itable), + arkButcherTableERKNameToID(etable))); } -int ARKStepGetJacTime(void* arkode_mem, sunrealtype* t_J) -{ - return arkLSGetJacTime(arkode_mem, t_J); -} +/*=============================================================== + Exported optional output functions. + ===============================================================*/ -int ARKStepGetJacNumSteps(void* arkode_mem, long* nst_J) -{ - return arkLSGetJacNumSteps(arkode_mem, nst_J); -} +/*--------------------------------------------------------------- + ARKStepGetNumRhsEvals: -int ARKStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) + Returns the current number of calls to fe and fi + ---------------------------------------------------------------*/ +int ARKStepGetNumRhsEvals(void* arkode_mem, long int* fe_evals, long int* fi_evals) { - return (arkLSGetWorkSpace(arkode_mem, lenrwLS, leniwLS)); -} + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + int retval; -int ARKStepGetNumJacEvals(void* arkode_mem, long int* njevals) -{ - return (arkLSGetNumJacEvals(arkode_mem, njevals)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepGetNumPrecEvals(void* arkode_mem, long int* npevals) -{ - return (arkLSGetNumPrecEvals(arkode_mem, npevals)); -} + /* get values from step_mem */ + *fe_evals = step_mem->nfe; + *fi_evals = step_mem->nfi; -int ARKStepGetNumPrecSolves(void* arkode_mem, long int* npsolves) -{ - return (arkLSGetNumPrecSolves(arkode_mem, npsolves)); + return (ARK_SUCCESS); } -int ARKStepGetNumLinIters(void* arkode_mem, long int* nliters) -{ - return (arkLSGetNumLinIters(arkode_mem, nliters)); -} +/*--------------------------------------------------------------- + ARKStepGetCurrentButcherTables: -int ARKStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails) + Sets pointers to the explicit and implicit Butcher tables + currently in use. + ---------------------------------------------------------------*/ +int ARKStepGetCurrentButcherTables(void* arkode_mem, ARKodeButcherTable* Bi, + ARKodeButcherTable* Be) { - return (arkLSGetNumConvFails(arkode_mem, nlcfails)); -} + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + int retval; -int ARKStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) -{ - return (arkLSGetNumJTSetupEvals(arkode_mem, njtsetups)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals) -{ - return (arkLSGetNumJtimesEvals(arkode_mem, njvevals)); + /* get tables from step_mem */ + *Bi = step_mem->Bi; + *Be = step_mem->Be; + return (ARK_SUCCESS); } -int ARKStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) -{ - return (arkLSGetNumRhsEvals(arkode_mem, nfevalsLS)); -} +/*--------------------------------------------------------------- + ARKStepGetTimestepperStats: -int ARKStepGetLastLinFlag(void* arkode_mem, long int* flag) + Returns integrator statistics + ---------------------------------------------------------------*/ +int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, + long int* accsteps, long int* step_attempts, + long int* fe_evals, long int* fi_evals, + long int* nlinsetups, long int* netfails) { - return (arkLSGetLastFlag(arkode_mem, flag)); -} + ARKodeMem ark_mem; + ARKodeARKStepMem step_mem; + int retval; -int ARKStepGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, - long int* leniwMLS) -{ - return (arkLSGetMassWorkSpace(arkode_mem, lenrwMLS, leniwMLS)); -} + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepGetNumMassSetups(void* arkode_mem, long int* nmsetups) -{ - return (arkLSGetNumMassSetups(arkode_mem, nmsetups)); -} + /* set expsteps and accsteps from adaptivity structure */ + *expsteps = ark_mem->hadapt_mem->nst_exp; + *accsteps = ark_mem->hadapt_mem->nst_acc; -int ARKStepGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups) -{ - return (arkLSGetNumMassMatvecSetups(arkode_mem, nmvsetups)); -} + /* set remaining outputs */ + *step_attempts = ark_mem->nst_attempts; + *fe_evals = step_mem->nfe; + *fi_evals = step_mem->nfi; + *nlinsetups = step_mem->nsetups; + *netfails = ark_mem->netf; -int ARKStepGetNumMassMult(void* arkode_mem, long int* nmvevals) -{ - return (arkLSGetNumMassMult(arkode_mem, nmvevals)); + return (ARK_SUCCESS); } -int ARKStepGetNumMassSolves(void* arkode_mem, long int* nmsolves) -{ - return (arkLSGetNumMassSolves(arkode_mem, nmsolves)); -} +/*=============================================================== + Private functions attached to ARKODE + ===============================================================*/ -int ARKStepGetNumMassPrecEvals(void* arkode_mem, long int* nmpevals) -{ - return (arkLSGetNumMassPrecEvals(arkode_mem, nmpevals)); -} +/*--------------------------------------------------------------- + arkStep_SetRelaxFn: -int ARKStepGetNumMassPrecSolves(void* arkode_mem, long int* nmpsolves) + Sets up the relaxation module using ARKStep's utility routines. + ---------------------------------------------------------------*/ +int arkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) { - return (arkLSGetNumMassPrecSolves(arkode_mem, nmpsolves)); + return ( + arkRelaxCreate(ark_mem, rfn, rjac, arkStep_RelaxDeltaE, arkStep_GetOrder)); } -int ARKStepGetNumMassIters(void* arkode_mem, long int* nmiters) -{ - return (arkLSGetNumMassIters(arkode_mem, nmiters)); -} +/*--------------------------------------------------------------- + arkStep_SetUserData: -int ARKStepGetNumMassConvFails(void* arkode_mem, long int* nmcfails) + Passes user-data pointer to attached linear solver modules. + ---------------------------------------------------------------*/ +int arkStep_SetUserData(ARKodeMem ark_mem, void* user_data) { - return (arkLSGetNumMassConvFails(arkode_mem, nmcfails)); -} + ARKodeARKStepMem step_mem; + int retval; -int ARKStepGetNumMTSetups(void* arkode_mem, long int* nmtsetups) -{ - return (arkLSGetNumMTSetups(arkode_mem, nmtsetups)); -} + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M) -{ - return (arkLSGetCurrentMassMatrix(arkode_mem, M)); -} + /* set user data in ARKODE LS mem */ + if (step_mem->lmem != NULL) + { + retval = arkLSSetUserData(ark_mem, user_data); + if (retval != ARKLS_SUCCESS) { return (retval); } + } -int ARKStepGetLastMassFlag(void* arkode_mem, long int* flag) -{ - return (arkLSGetLastMassFlag(arkode_mem, flag)); -} + /* set user data in ARKODE LSMass mem */ + if (step_mem->mass_mem != NULL) + { + retval = arkLSSetMassUserData(ark_mem, user_data); + if (retval != ARKLS_SUCCESS) { return (retval); } + } -char* ARKStepGetLinReturnFlagName(long int flag) -{ - return (arkLSGetReturnFlagName(flag)); + return (ARK_SUCCESS); } -/* ----------------------------------------------------------------------------- - * Wrappers for the ARKODE relaxation module - * ---------------------------------------------------------------------------*/ +/*--------------------------------------------------------------- + arkStep_SetDefaults: -int ARKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) + Resets all ARKStep optional inputs to their default values. + Does not change problem-defining function pointers or + user_data pointer. Also leaves alone any data + structures/options related to the ARKODE infrastructure itself + (e.g., root-finding and post-process step). + ---------------------------------------------------------------*/ +int arkStep_SetDefaults(ARKodeMem ark_mem) { - return arkRelaxCreate(arkode_mem, rfn, rjac, arkStep_RelaxDeltaE, - arkStep_GetOrder); -} + ARKodeARKStepMem step_mem; + int retval; -int ARKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf) -{ - return arkRelaxSetEtaFail(arkode_mem, eta_rf); -} + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) -{ - return arkRelaxSetLowerBound(arkode_mem, lower); -} - -int ARKStepSetRelaxMaxFails(void* arkode_mem, int max_fails) -{ - return arkRelaxSetMaxFails(arkode_mem, max_fails); + /* Set default values for integrator optional inputs */ + step_mem->q = Q_DEFAULT; /* method order */ + step_mem->p = 0; /* embedding order */ + step_mem->predictor = 0; /* trivial predictor */ + step_mem->linear = SUNFALSE; /* nonlinear problem */ + step_mem->linear_timedep = SUNTRUE; /* dfi/dy depends on t */ + step_mem->explicit = SUNTRUE; /* fe(t,y) will be used */ + step_mem->implicit = SUNTRUE; /* fi(t,y) will be used */ + step_mem->deduce_rhs = SUNFALSE; /* deduce fi on result of NLS */ + step_mem->maxcor = MAXCOR; /* max nonlinear iters/stage */ + step_mem->nlscoef = NLSCOEF; /* nonlinear tolerance coefficient */ + step_mem->crdown = CRDOWN; /* nonlinear convergence estimate coeff. */ + step_mem->rdiv = RDIV; /* nonlinear divergence tolerance */ + step_mem->dgmax = DGMAX; /* max step change before recomputing J or P */ + step_mem->msbp = MSBP; /* max steps between updates to J or P */ + step_mem->stages = 0; /* no stages */ + step_mem->istage = 0; /* current stage */ + step_mem->Be = NULL; /* no Butcher tables */ + step_mem->Bi = NULL; + step_mem->NLS = NULL; /* no nonlinear solver object */ + step_mem->jcur = SUNFALSE; + step_mem->convfail = ARK_NO_FAILURES; + step_mem->stage_predict = NULL; /* no user-supplied stage predictor */ + return (ARK_SUCCESS); } -int ARKStepSetRelaxMaxIters(void* arkode_mem, int max_iters) -{ - return arkRelaxSetMaxIters(arkode_mem, max_iters); -} +/*--------------------------------------------------------------- + arkStep_SetOrder: -int ARKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) + Specifies the method order + ---------------------------------------------------------------*/ +int arkStep_SetOrder(ARKodeMem ark_mem, int ord) { - return arkRelaxSetSolver(arkode_mem, solver); -} + ARKodeARKStepMem step_mem; + sunindextype Blrw, Bliw; + int retval; -int ARKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) -{ - return arkRelaxSetResTol(arkode_mem, res_tol); -} + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ARKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) -{ - return arkRelaxSetTol(arkode_mem, rel_tol, abs_tol); -} + /* set user-provided value, or default, depending on argument */ + if (ord <= 0) { step_mem->q = Q_DEFAULT; } + else { step_mem->q = ord; } -int ARKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) -{ - return arkRelaxSetUpperBound(arkode_mem, upper); -} + /* clear Butcher tables, since user is requesting a change in method + or a reset to defaults. Tables will be set in ARKInitialSetup. */ + step_mem->stages = 0; + step_mem->istage = 0; + step_mem->p = 0; -int ARKStepGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) -{ - return arkRelaxGetNumRelaxFnEvals(arkode_mem, r_evals); -} + ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->Be); + step_mem->Be = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ARKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) -{ - return arkRelaxGetNumRelaxJacEvals(arkode_mem, J_evals); -} + ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->Bi); + step_mem->Bi = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ARKStepGetNumRelaxFails(void* arkode_mem, long int* relax_fails) -{ - return arkRelaxGetNumRelaxFails(arkode_mem, relax_fails); + return (ARK_SUCCESS); } -int ARKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails) -{ - return arkRelaxGetNumRelaxBoundFails(arkode_mem, fails); -} +/*--------------------------------------------------------------- + arkStep_SetLinear: -int ARKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails) -{ - return arkRelaxGetNumRelaxSolveFails(arkode_mem, fails); -} + Specifies that the implicit portion of the problem is linear, + and to tighten the linear solver tolerances while taking only + one Newton iteration. DO NOT USE IN COMBINATION WITH THE + FIXED-POINT SOLVER. Automatically tightens DeltaGammaMax + to ensure that step size changes cause Jacobian recomputation. -int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) + The argument should be 1 or 0, where 1 indicates that the + Jacobian of fi with respect to y depends on time, and + 0 indicates that it is not time dependent. Alternately, when + using an iterative linear solver this flag denotes time + dependence of the preconditioner. + ---------------------------------------------------------------*/ +int arkStep_SetLinear(ARKodeMem ark_mem, int timedepend) { - return arkRelaxGetNumRelaxSolveIters(arkode_mem, iters); -} + ARKodeARKStepMem step_mem; + int retval; -/*=============================================================== - DEPRECATED ARKStep optional input/output functions - ===============================================================*/ + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set parameters */ + step_mem->linear = SUNTRUE; + step_mem->linear_timedep = (timedepend == 1); + step_mem->dgmax = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; + + return (ARK_SUCCESS); +} /*--------------------------------------------------------------- - ARKStepSetAdaptivityMethod: user should create/attach a - specific SUNAdaptController object. + arkStep_SetNonlinear: + + Specifies that the implicit portion of the problem is nonlinear. + Used to undo a previous call to arkStep_SetLinear. Automatically + loosens DeltaGammaMax back to default value. ---------------------------------------------------------------*/ -int ARKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, - int pq, sunrealtype adapt_params[3]) +int arkStep_SetNonlinear(ARKodeMem ark_mem) { - return (arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); + ARKodeARKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* set parameters */ + step_mem->linear = SUNFALSE; + step_mem->linear_timedep = SUNTRUE; + step_mem->dgmax = DGMAX; + + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetAdaptivityFn: user should create/attach a custom - SUNAdaptController object. + arkStep_SetNonlinCRDown: + + Specifies the user-provided nonlinear convergence constant + crdown. Legal values are strictly positive; illegal values + imply a reset to the default. ---------------------------------------------------------------*/ -int ARKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) +int arkStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown) { - return (arkSetAdaptivityFn(arkode_mem, hfun, h_data)); + ARKodeARKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* if argument legal set it, otherwise set default */ + if (crdown <= ZERO) { step_mem->crdown = CRDOWN; } + else { step_mem->crdown = crdown; } + + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetErrorBias: user should set this value directly in the - SUNAdaptController object. + arkStep_SetNonlinRDiv: + + Specifies the user-provided nonlinear convergence constant + rdiv. Legal values are strictly positive; illegal values + imply a reset to the default. ---------------------------------------------------------------*/ -int ARKStepSetErrorBias(void* arkode_mem, sunrealtype bias) +int arkStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv) { - return (arkSetErrorBias(arkode_mem, bias)); -} + ARKodeARKStepMem step_mem; + int retval; -/*=============================================================== - ARKStep optional input functions -- stepper-specific - ===============================================================*/ + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* if argument legal set it, otherwise set default */ + if (rdiv <= ZERO) { step_mem->rdiv = RDIV; } + else { step_mem->rdiv = rdiv; } + + return (ARK_SUCCESS); +} /*--------------------------------------------------------------- - ARKStepSetUserData: + arkStep_SetDeltaGammaMax: - Wrapper for generic arkSetUserData and arkLSSetUserData - routines. + Specifies the user-provided linear setup decision constant + dgmax. Legal values are strictly positive; illegal values imply + a reset to the default. ---------------------------------------------------------------*/ -int ARKStepSetUserData(void* arkode_mem, void* user_data) +int arkStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* set user_data in ARKODE mem */ - retval = arkSetUserData(arkode_mem, user_data); - if (retval != ARK_SUCCESS) { return (retval); } + /* if argument legal set it, otherwise set default */ + if (dgmax <= ZERO) { step_mem->dgmax = DGMAX; } + else { step_mem->dgmax = dgmax; } - /* set user data in ARKODE LS mem */ - if (step_mem->lmem != NULL) - { - retval = arkLSSetUserData(arkode_mem, user_data); - if (retval != ARKLS_SUCCESS) { return (retval); } - } + return (ARK_SUCCESS); +} - /* set user data in ARKODE LSMass mem */ - if (step_mem->mass_mem != NULL) - { - retval = arkLSSetMassUserData(arkode_mem, user_data); - if (retval != ARKLS_SUCCESS) { return (retval); } - } +/*--------------------------------------------------------------- + arkStep_SetLSetupFrequency: + + Specifies the user-provided linear setup decision constant + msbp. Positive values give the frequency for calling lsetup; + negative values imply recomputation of lsetup at each nonlinear + solve; a zero value implies a reset to the default. + ---------------------------------------------------------------*/ +int arkStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp) +{ + ARKodeARKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* if argument legal set it, otherwise set default */ + if (msbp == 0) { step_mem->msbp = MSBP; } + else { step_mem->msbp = msbp; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetDefaults: + arkStep_SetPredictorMethod: - Resets all ARKStep optional inputs to their default values. - Does not change problem-defining function pointers or - user_data pointer. Also leaves alone any data - structures/options related to the ARKODE infrastructure itself - (e.g., root-finding and post-process step). + Specifies the method to use for predicting implicit solutions. + Non-default choices are {1,2,3,4}, all others will use default + (trivial) predictor. ---------------------------------------------------------------*/ -int ARKStepSetDefaults(void* arkode_mem) +int arkStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Set default ARKODE infrastructure parameters */ - retval = arkSetDefaults(ark_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error setting ARKODE infrastructure defaults"); - return (retval); - } + /* set parameter */ + step_mem->predictor = pred_method; - /* Set default values for integrator optional inputs */ - step_mem->q = Q_DEFAULT; /* method order */ - step_mem->p = 0; /* embedding order */ - step_mem->predictor = 0; /* trivial predictor */ - step_mem->linear = SUNFALSE; /* nonlinear problem */ - step_mem->linear_timedep = SUNTRUE; /* dfi/dy depends on t */ - step_mem->explicit = SUNTRUE; /* fe(t,y) will be used */ - step_mem->implicit = SUNTRUE; /* fi(t,y) will be used */ - step_mem->deduce_rhs = SUNFALSE; /* deduce fi on result of NLS */ - step_mem->maxcor = MAXCOR; /* max nonlinear iters/stage */ - step_mem->nlscoef = NLSCOEF; /* nonlinear tolerance coefficient */ - step_mem->crdown = CRDOWN; /* nonlinear convergence estimate coeff. */ - step_mem->rdiv = RDIV; /* nonlinear divergence tolerance */ - step_mem->dgmax = DGMAX; /* max step change before recomputing J or P */ - step_mem->msbp = MSBP; /* max steps between updates to J or P */ - step_mem->stages = 0; /* no stages */ - step_mem->istage = 0; /* current stage */ - step_mem->Be = NULL; /* no Butcher tables */ - step_mem->Bi = NULL; - step_mem->NLS = NULL; /* no nonlinear solver object */ - step_mem->jcur = SUNFALSE; - step_mem->convfail = ARK_NO_FAILURES; - step_mem->stage_predict = NULL; /* no user-supplied stage predictor */ return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetOptimalParams: - - Sets all adaptivity and solver parameters to our 'best guess' - values, for a given ARKStep integration method (ERK, DIRK, ARK), - a given method order, and a given nonlinear solver type. Should - only be called after the method order, solver, and integration - method have been set, and only if time step adaptivity is - enabled. + arkStep_SetMaxNonlinIters: + + Specifies the maximum number of nonlinear iterations during + one solve. A non-positive input implies a reset to the + default value. ---------------------------------------------------------------*/ -int ARKStepSetOptimalParams(void* arkode_mem) +int arkStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - ARKodeHAdaptMem hadapt_mem; int retval; - long int lenrw, leniw; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* access ARKodeHAdaptMem structure */ - if (ark_mem->hadapt_mem == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARKADAPT_NO_MEM); - return (ARK_MEM_NULL); - } - hadapt_mem = ark_mem->hadapt_mem; + SUNFunctionBegin(ark_mem->sunctx); - /* Remove current SUNAdaptController object */ - retval = SUNAdaptController_Space(hadapt_mem->hcontroller, &lenrw, &leniw); - if (retval == SUN_SUCCESS) - { - ark_mem->liw -= leniw; - ark_mem->lrw -= lenrw; - } - if (hadapt_mem->owncontroller) + /* Return error message if no NLS module is present */ + if (step_mem->NLS == NULL) { - retval = SUNAdaptController_Destroy(hadapt_mem->hcontroller); - ark_mem->hadapt_mem->owncontroller = SUNFALSE; - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_Destroy failure"); - return (ARK_MEM_FAIL); - } + arkProcessError(ark_mem, ARK_NLS_OP_ERR, __LINE__, __func__, __FILE__, + "No SUNNonlinearSolver object is present"); + return (ARK_ILL_INPUT); } - hadapt_mem->hcontroller = NULL; - - /* Choose values based on method, order */ - - /* explicit */ - if (step_mem->explicit && !step_mem->implicit) - { - hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PI allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(1.2)); - (void)SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, - SUN_RCONST(0.8), -SUN_RCONST(0.31)); - hadapt_mem->safety = SUN_RCONST(0.99); - hadapt_mem->growth = SUN_RCONST(25.0); - hadapt_mem->etamxf = SUN_RCONST(0.3); - hadapt_mem->pq = PQ; - /* implicit */ - } - else if (step_mem->implicit && !step_mem->explicit) - { - switch (step_mem->q) - { - case 2: /* just use standard defaults since better ones unknown */ - hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - hadapt_mem->safety = SAFETY; - hadapt_mem->growth = GROWTH; - hadapt_mem->etamxf = ETAMXF; - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.001); - step_mem->maxcor = 5; - step_mem->crdown = CRDOWN; - step_mem->rdiv = RDIV; - step_mem->dgmax = DGMAX; - step_mem->msbp = MSBP; - break; - case 3: - hadapt_mem->hcontroller = SUNAdaptController_I(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_I allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(1.9)); - hadapt_mem->safety = SUN_RCONST(0.957); - hadapt_mem->growth = SUN_RCONST(17.6); - hadapt_mem->etamxf = SUN_RCONST(0.45); - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.22); - step_mem->crdown = SUN_RCONST(0.17); - step_mem->rdiv = SUN_RCONST(2.3); - step_mem->dgmax = SUN_RCONST(0.19); - step_mem->msbp = 60; - break; - case 4: - hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(1.2)); - (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, - SUN_RCONST(0.535), - -SUN_RCONST(0.209), - SUN_RCONST(0.148)); - hadapt_mem->safety = SUN_RCONST(0.988); - hadapt_mem->growth = SUN_RCONST(31.5); - hadapt_mem->etamxf = SUN_RCONST(0.33); - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.24); - step_mem->crdown = SUN_RCONST(0.26); - step_mem->rdiv = SUN_RCONST(2.3); - step_mem->dgmax = SUN_RCONST(0.16); - step_mem->msbp = 31; - break; - case 5: - hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(3.3)); - (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, - SUN_RCONST(0.56), -SUN_RCONST(0.338), - SUN_RCONST(0.14)); - hadapt_mem->safety = SUN_RCONST(0.937); - hadapt_mem->growth = SUN_RCONST(22.0); - hadapt_mem->etamxf = SUN_RCONST(0.44); - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.25); - step_mem->crdown = SUN_RCONST(0.4); - step_mem->rdiv = SUN_RCONST(2.3); - step_mem->dgmax = SUN_RCONST(0.32); - step_mem->msbp = 31; - break; - } + /* argument <= 0 sets default, otherwise set input */ + if (maxcor <= 0) { step_mem->maxcor = MAXCOR; } + else { step_mem->maxcor = maxcor; } - /* imex */ - } - else + /* send argument to NLS structure */ + retval = SUNNonlinSolSetMaxIters(step_mem->NLS, step_mem->maxcor); + if (retval != SUN_SUCCESS) { - switch (step_mem->q) - { - case 2: /* just use standard defaults since better ones unknown */ - hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - hadapt_mem->safety = SAFETY; - hadapt_mem->growth = GROWTH; - hadapt_mem->etamxf = ETAMXF; - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.001); - step_mem->maxcor = 5; - step_mem->crdown = CRDOWN; - step_mem->rdiv = RDIV; - step_mem->dgmax = DGMAX; - step_mem->msbp = MSBP; - break; - case 3: - hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(1.42)); - (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, - SUN_RCONST(0.54), -SUN_RCONST(0.36), - SUN_RCONST(0.14)); - hadapt_mem->safety = SUN_RCONST(0.965); - hadapt_mem->growth = SUN_RCONST(28.7); - hadapt_mem->etamxf = SUN_RCONST(0.46); - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.22); - step_mem->crdown = SUN_RCONST(0.17); - step_mem->rdiv = SUN_RCONST(2.3); - step_mem->dgmax = SUN_RCONST(0.19); - step_mem->msbp = 60; - break; - case 4: - hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(1.35)); - (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, - SUN_RCONST(0.543), - -SUN_RCONST(0.297), - SUN_RCONST(0.14)); - hadapt_mem->safety = SUN_RCONST(0.97); - hadapt_mem->growth = SUN_RCONST(25.0); - hadapt_mem->etamxf = SUN_RCONST(0.47); - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.24); - step_mem->crdown = SUN_RCONST(0.26); - step_mem->rdiv = SUN_RCONST(2.3); - step_mem->dgmax = SUN_RCONST(0.16); - step_mem->msbp = 31; - break; - case 5: - hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); - if (hadapt_mem->hcontroller == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PI allocation failure"); - return (ARK_MEM_FAIL); - } - (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, - SUN_RCONST(1.15)); - (void)SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, - SUN_RCONST(0.8), -SUN_RCONST(0.35)); - hadapt_mem->safety = SUN_RCONST(0.993); - hadapt_mem->growth = SUN_RCONST(28.5); - hadapt_mem->etamxf = SUN_RCONST(0.3); - hadapt_mem->small_nef = SMALL_NEF; - hadapt_mem->etacf = ETACF; - hadapt_mem->pq = PQ; - step_mem->nlscoef = SUN_RCONST(0.25); - step_mem->crdown = SUN_RCONST(0.4); - step_mem->rdiv = SUN_RCONST(2.3); - step_mem->dgmax = SUN_RCONST(0.32); - step_mem->msbp = 31; - break; - } - hadapt_mem->owncontroller = SUNTRUE; - - retval = SUNAdaptController_Space(hadapt_mem->hcontroller, &lenrw, &leniw); - if (retval == SUN_SUCCESS) - { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; - } + arkProcessError(ark_mem, ARK_NLS_OP_ERR, __LINE__, __func__, __FILE__, + "Error setting maxcor in SUNNonlinearSolver object"); + return (ARK_NLS_OP_ERR); } + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetOrder: - - Specifies the method order + arkStep_SetNonlinConvCoef: - ** Note in documentation that this should not be called along - with ARKStepSetTable or ARKStepSetTableNum. This routine - is used to specify a desired method order using default Butcher - tables, whereas any user-supplied table will have their own - order associated with them. + Specifies the coefficient in the nonlinear solver convergence + test. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int ARKStepSetOrder(void* arkode_mem, int ord) +int arkStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - sunindextype Blrw, Bliw; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* set user-provided value, or default, depending on argument */ - if (ord <= 0) { step_mem->q = Q_DEFAULT; } - else { step_mem->q = ord; } + /* argument <= 0 sets default, otherwise set input */ + if (nlscoef <= ZERO) { step_mem->nlscoef = NLSCOEF; } + else { step_mem->nlscoef = nlscoef; } - /* clear Butcher tables, since user is requesting a change in method - or a reset to defaults. Tables will be set in ARKInitialSetup. */ - step_mem->stages = 0; - step_mem->istage = 0; - step_mem->p = 0; + return (ARK_SUCCESS); +} - ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->Be); - step_mem->Be = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; +/*--------------------------------------------------------------- + arkStep_SetStagePredictFn: Specifies a user-provided step + predictor function having type ARKStagePredictFn. A + NULL input function disables calls to this routine. + ---------------------------------------------------------------*/ +int arkStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage) +{ + ARKodeARKStepMem step_mem; + int retval; - ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->Bi); - step_mem->Bi = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; + /* access ARKodeARKStepMem structure and set function pointer */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + step_mem->stage_predict = PredictStage; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetLinear: + arkStep_SetDeduceImplicitRhs: - Specifies that the implicit portion of the problem is linear, - and to tighten the linear solver tolerances while taking only - one Newton iteration. DO NOT USE IN COMBINATION WITH THE - FIXED-POINT SOLVER. Automatically tightens DeltaGammaMax - to ensure that step size changes cause Jacobian recomputation. + Specifies if an optimization is used to avoid an evaluation of + fi after a nonlinear solve for an implicit stage. If stage + postprocessecing in enabled, this option is ignored, and fi is + never deduced. - The argument should be 1 or 0, where 1 indicates that the - Jacobian of fi with respect to y depends on time, and - 0 indicates that it is not time dependent. Alternately, when - using an iterative linear solver this flag denotes time - dependence of the preconditioner. + An argument of SUNTRUE indicates that fi is deduced to compute + fi(z_i), and SUNFALSE indicates that fi(z_i) is computed with + an additional evaluation of fi. ---------------------------------------------------------------*/ -int ARKStepSetLinear(void* arkode_mem, int timedepend) +int arkStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce) +{ + ARKodeARKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure and set function pointer */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + step_mem->deduce_rhs = deduce; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + arkStep_GetCurrentGamma: Returns the current value of gamma + ---------------------------------------------------------------*/ +int arkStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma) +{ + int retval; + ARKodeARKStepMem step_mem; + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + *gamma = step_mem->gamma; + return (retval); +} + +/*--------------------------------------------------------------- + arkStep_GetEstLocalErrors: Returns the current local truncation + error estimate vector + ---------------------------------------------------------------*/ +int arkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) +{ + int retval; + ARKodeARKStepMem step_mem; + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* return an error if local truncation error is not computed */ + if (ark_mem->fixedstep) { return (ARK_STEPPER_UNSUPPORTED); } + + /* otherwise, copy local truncation error vector to output */ + N_VScale(ONE, ark_mem->tempv1, ele); + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + arkStep_GetNumLinSolvSetups: + + Returns the current number of calls to the lsetup routine + ---------------------------------------------------------------*/ +int arkStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* set parameters */ - step_mem->linear = SUNTRUE; - step_mem->linear_timedep = (timedepend == 1); - step_mem->dgmax = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; + /* get value from step_mem */ + *nlinsetups = step_mem->nsetups; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetNonlinear: + arkStep_GetNumNonlinSolvIters: - Specifies that the implicit portion of the problem is nonlinear. - Used to undo a previous call to ARKStepSetLinear. Automatically - loosens DeltaGammaMax back to default value. + Returns the current number of nonlinear solver iterations ---------------------------------------------------------------*/ -int ARKStepSetNonlinear(void* arkode_mem) +int arkStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* set parameters */ - step_mem->linear = SUNFALSE; - step_mem->linear_timedep = SUNTRUE; - step_mem->dgmax = DGMAX; + *nniters = step_mem->nls_iters; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetExplicit: + arkStep_GetNumNonlinSolvConvFails: - Specifies that the implicit portion of the problem is disabled, - and to use an explicit RK method. + Returns the current number of nonlinear solver convergence fails ---------------------------------------------------------------*/ -int ARKStepSetExplicit(void* arkode_mem) +int arkStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* ensure that fe is defined */ - if (step_mem->fe == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_MISSING_FE); - return (ARK_ILL_INPUT); - } + /* set output from step_mem */ + *nnfails = step_mem->nls_fails; - /* set the relevant parameters */ - step_mem->explicit = SUNTRUE; - step_mem->implicit = SUNFALSE; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + arkStep_GetNonlinSolvStats: + + Returns nonlinear solver statistics + ---------------------------------------------------------------*/ +int arkStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, + long int* nnfails) +{ + ARKodeARKStepMem step_mem; + int retval; + + /* access ARKodeARKStepMem structure */ + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + *nniters = step_mem->nls_iters; + *nnfails = step_mem->nls_fails; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetImplicit: + arkStep_PrintAllStats: - Specifies that the explicit portion of the problem is disabled, - and to use an implicit RK method. + Prints integrator statistics ---------------------------------------------------------------*/ -int ARKStepSetImplicit(void* arkode_mem) +int arkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; + ARKLsMem arkls_mem; + ARKLsMassMem arklsm_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* ensure that fi is defined */ - if (step_mem->fi == NULL) + switch (fmt) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_MISSING_FI); - return (ARK_ILL_INPUT); - } + case SUN_OUTPUTFORMAT_TABLE: + /* function evaluations */ + fprintf(outfile, "Explicit RHS fn evals = %ld\n", step_mem->nfe); + fprintf(outfile, "Implicit RHS fn evals = %ld\n", step_mem->nfi); - /* set the relevant parameters */ - step_mem->implicit = SUNTRUE; - step_mem->explicit = SUNFALSE; + /* nonlinear solver stats */ + fprintf(outfile, "NLS iters = %ld\n", step_mem->nls_iters); + fprintf(outfile, "NLS fails = %ld\n", step_mem->nls_fails); + if (ark_mem->nst > 0) + { + fprintf(outfile, "NLS iters per step = %" RSYM "\n", + (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); + } - /* re-attach internal error weight functions if necessary */ - if (!ark_mem->user_efun) - { - if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) + /* linear solver stats */ + fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); + if (ark_mem->step_getlinmem(ark_mem)) + { + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); + fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); + fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); + fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); + fprintf(outfile, "Prec solves = %ld\n", arkls_mem->nps); + fprintf(outfile, "LS iters = %ld\n", arkls_mem->nli); + fprintf(outfile, "LS fails = %ld\n", arkls_mem->ncfl); + fprintf(outfile, "Jac-times setups = %ld\n", + arkls_mem->njtsetup); + fprintf(outfile, "Jac-times evals = %ld\n", + arkls_mem->njtimes); + if (step_mem->nls_iters > 0) + { + fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", + (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); + fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", + (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); + fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", + (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); + } + } + + /* mass solve stats */ + if (ark_mem->step_getmassmem(ark_mem)) + { + arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); + fprintf(outfile, "Mass setups = %ld\n", + arklsm_mem->nmsetups); + fprintf(outfile, "Mass solves = %ld\n", + arklsm_mem->nmsolves); + fprintf(outfile, "Mass Prec setup evals = %ld\n", arklsm_mem->npe); + fprintf(outfile, "Mass Prec solves = %ld\n", arklsm_mem->nps); + fprintf(outfile, "Mass LS iters = %ld\n", arklsm_mem->nli); + fprintf(outfile, "Mass LS fails = %ld\n", arklsm_mem->ncfl); + fprintf(outfile, "Mass-times setups = %ld\n", + arklsm_mem->nmtsetup); + fprintf(outfile, "Mass-times evals = %ld\n", + arklsm_mem->nmtimes); + } + break; + + case SUN_OUTPUTFORMAT_CSV: + /* function evaluations */ + fprintf(outfile, ",Explicit RHS fn evals,%ld", step_mem->nfe); + fprintf(outfile, ",Implicit RHS fn evals,%ld", step_mem->nfi); + + /* nonlinear solver stats */ + fprintf(outfile, ",NLS iters,%ld", step_mem->nls_iters); + fprintf(outfile, ",NLS fails,%ld", step_mem->nls_fails); + if (ark_mem->nst > 0) + { + fprintf(outfile, ",NLS iters per step,%" RSYM, + (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); + } + else { fprintf(outfile, ",NLS iters per step,0"); } + + /* linear solver stats */ + fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); + if (ark_mem->step_getlinmem(ark_mem)) { - retval = arkSVtolerances(ark_mem, ark_mem->reltol, ark_mem->Vabstol); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); + fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); + fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); + fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); + fprintf(outfile, ",Prec solves,%ld", arkls_mem->nps); + fprintf(outfile, ",LS iters,%ld", arkls_mem->nli); + fprintf(outfile, ",LS fails,%ld", arkls_mem->ncfl); + fprintf(outfile, ",Jac-times setups,%ld", arkls_mem->njtsetup); + fprintf(outfile, ",Jac-times evals,%ld", arkls_mem->njtimes); + if (step_mem->nls_iters > 0) + { + fprintf(outfile, ",LS iters per NLS iter,%" RSYM, + (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); + fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, + (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); + fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, + (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); + } + else + { + fprintf(outfile, ",LS iters per NLS iter,0"); + fprintf(outfile, ",Jac evals per NLS iter,0"); + fprintf(outfile, ",Prec evals per NLS iter,0"); + } } - else + + /* mass solve stats */ + if (ark_mem->step_getmassmem(ark_mem)) { - retval = arkSStolerances(ark_mem, ark_mem->reltol, ark_mem->Sabstol); + arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(ark_mem)); + fprintf(outfile, ",Mass setups,%ld", arklsm_mem->nmsetups); + fprintf(outfile, ",Mass solves,%ld", arklsm_mem->nmsolves); + fprintf(outfile, ",Mass Prec setup evals,%ld", arklsm_mem->npe); + fprintf(outfile, ",Mass Prec solves,%ld", arklsm_mem->nps); + fprintf(outfile, ",Mass LS iters,%ld", arklsm_mem->nli); + fprintf(outfile, ",Mass LS fails,%ld", arklsm_mem->ncfl); + fprintf(outfile, ",Mass-times setups,%ld", arklsm_mem->nmtsetup); + fprintf(outfile, ",Mass-times evals,%ld", arklsm_mem->nmtimes); } - if (retval != ARK_SUCCESS) { return (retval); } + fprintf(outfile, "\n"); + break; + + default: + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid formatting option."); + return (ARK_ILL_INPUT); } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ARKStepSetImEx: + arkStep_WriteParameters: - Specifies that the specifies that problem has both implicit and - explicit parts, and to use an ARK method (this is the default). + Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int ARKStepSetImEx(void* arkode_mem) +int arkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* ensure that fe and fi are defined */ - if (step_mem->fe == NULL) + /* print integrator parameters to file */ + fprintf(fp, "ARKStep time step module parameters:\n"); + fprintf(fp, " Method order %i\n", step_mem->q); + if (step_mem->linear) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_MISSING_FE); - return (ARK_ILL_INPUT); + fprintf(fp, " Linear implicit problem"); + if (step_mem->linear_timedep) + { + fprintf(fp, " (time-dependent Jacobian)\n"); + } + else { fprintf(fp, " (time-independent Jacobian)\n"); } } - if (step_mem->fi == NULL) + if (step_mem->explicit && step_mem->implicit) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_MISSING_FI); - return (ARK_ILL_INPUT); + fprintf(fp, " ImEx integrator\n"); } + else if (step_mem->implicit) { fprintf(fp, " Implicit integrator\n"); } + else { fprintf(fp, " Explicit integrator\n"); } - /* set the relevant parameters */ - step_mem->explicit = SUNTRUE; - step_mem->implicit = SUNTRUE; - - /* re-attach internal error weight functions if necessary */ - if (!ark_mem->user_efun) + if (step_mem->implicit) { - if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) - { - retval = arkSVtolerances(ark_mem, ark_mem->reltol, ark_mem->Vabstol); - } - else - { - retval = arkSStolerances(ark_mem, ark_mem->reltol, ark_mem->Sabstol); - } - if (retval != ARK_SUCCESS) { return (retval); } + fprintf(fp, " Implicit predictor method = %i\n", step_mem->predictor); + fprintf(fp, " Implicit solver tolerance coefficient = %" RSYM "\n", + step_mem->nlscoef); + fprintf(fp, " Maximum number of nonlinear corrections = %i\n", + step_mem->maxcor); + fprintf(fp, " Nonlinear convergence rate constant = %" RSYM "\n", + step_mem->crdown); + fprintf(fp, " Nonlinear divergence tolerance = %" RSYM "\n", step_mem->rdiv); + fprintf(fp, " Gamma factor LSetup tolerance = %" RSYM "\n", step_mem->dgmax); + fprintf(fp, " Number of steps between LSetup calls = %i\n", step_mem->msbp); } + fprintf(fp, "\n"); return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - ARKStepSetTables: - - Specifies to use customized Butcher tables for the system. - - If Bi is NULL, then this sets the integrator in 'explicit' mode. - - If Be is NULL, then this sets the integrator in 'implicit' mode. +/*=============================================================== + Exported-but-deprecated user-callable functions. + ===============================================================*/ - Returns ARK_ILL_INPUT if both Butcher tables are not supplied. - ---------------------------------------------------------------*/ -int ARKStepSetTables(void* arkode_mem, int q, int p, ARKodeButcherTable Bi, - ARKodeButcherTable Be) +int ARKStepResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - int retval; - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - sunindextype Blrw, Bliw; - - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* check for illegal inputs */ - if ((Bi == NULL) && (Be == NULL)) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "At least one complete table must be supplied"); - return (ARK_ILL_INPUT); - } - - /* if both tables are set, check that they have the same number of stages */ - if ((Bi != NULL) && (Be != NULL)) - { - if (Bi->stages != Be->stages) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Both tables must have the same number of stages"); - return (ARK_ILL_INPUT); - } - } - - /* clear any existing parameters and Butcher tables */ - step_mem->stages = 0; - step_mem->q = 0; - step_mem->p = 0; - - ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->Be); - step_mem->Be = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; - - ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->Bi); - step_mem->Bi = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; - - /* - * determine mode (implicit/explicit/ImEx), and perform appropriate actions - */ - - /* explicit */ - if (Bi == NULL) - { - /* set the relevant parameters (use table q and p) */ - step_mem->stages = Be->stages; - step_mem->q = Be->q; - step_mem->p = Be->p; - - /* copy the table in step memory */ - step_mem->Be = ARKodeButcherTable_Copy(Be); - if (step_mem->Be == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - - /* set method as purely explicit */ - retval = ARKStepSetExplicit(arkode_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Error in ARKStepSetExplicit"); - return (retval); - } - - /* implicit */ - } - else if (Be == NULL) - { - /* set the relevant parameters (use table q and p) */ - step_mem->stages = Bi->stages; - step_mem->q = Bi->q; - step_mem->p = Bi->p; + return (ARKodeResize(arkode_mem, y0, hscale, t0, resize, resize_data)); +} - /* copy the table in step memory */ - step_mem->Bi = ARKodeButcherTable_Copy(Bi); - if (step_mem->Bi == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } +int ARKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +{ + return (ARKodeReset(arkode_mem, tR, yR)); +} - /* set method as purely implicit */ - retval = ARKStepSetImplicit(arkode_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Error in ARKStepSetImplicit"); - return (ARK_ILL_INPUT); - } +int ARKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) +{ + return (ARKodeSStolerances(arkode_mem, reltol, abstol)); +} - /* ImEx */ - } - else - { - /* set the relevant parameters (use input q and p) */ - step_mem->stages = Bi->stages; - step_mem->q = q; - step_mem->p = p; +int ARKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) +{ + return (ARKodeSVtolerances(arkode_mem, reltol, abstol)); +} - /* copy the explicit table into step memory */ - step_mem->Be = ARKodeButcherTable_Copy(Be); - if (step_mem->Be == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } +int ARKStepWFtolerances(void* arkode_mem, ARKEwtFn efun) +{ + return (ARKodeWFtolerances(arkode_mem, efun)); +} - /* copy the implicit table into step memory */ - step_mem->Bi = ARKodeButcherTable_Copy(Bi); - if (step_mem->Bi == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } +int ARKStepResStolerance(void* arkode_mem, sunrealtype rabstol) +{ + return (ARKodeResStolerance(arkode_mem, rabstol)); +} - /* set method as ImEx */ - retval = ARKStepSetImEx(arkode_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Error in ARKStepSetImEx"); - return (ARK_ILL_INPUT); - } - } +int ARKStepResVtolerance(void* arkode_mem, N_Vector rabstol) +{ + return (ARKodeResVtolerance(arkode_mem, rabstol)); +} - /* note Butcher table space requirements */ - ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); - ark_mem->liw += Bliw; - ark_mem->lrw += Blrw; +int ARKStepResFtolerance(void* arkode_mem, ARKRwtFn rfun) +{ + return (ARKodeResFtolerance(arkode_mem, rfun)); +} - ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); - ark_mem->liw += Bliw; - ark_mem->lrw += Blrw; +int ARKStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) +{ + return (ARKodeSetLinearSolver(arkode_mem, LS, A)); +} - return (ARK_SUCCESS); +int ARKStepSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, + SUNMatrix M, sunbooleantype time_dep) +{ + return (ARKodeSetMassLinearSolver(arkode_mem, LS, M, time_dep)); } -/*--------------------------------------------------------------- - ARKStepSetTableNum: +int ARKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) +{ + return (ARKodeRootInit(arkode_mem, nrtfn, g)); +} - Specifies to use pre-existing Butcher tables for the system, - based on the integer flags passed to - ARKodeButcherTable_LoadERK() and ARKodeButcherTable_LoadDIRK() - within the files arkode_butcher_erk.c and arkode_butcher_dirk.c - (automatically calls ARKStepSetImEx). +int ARKStepSetDefaults(void* arkode_mem) +{ + return (ARKodeSetDefaults(arkode_mem)); +} - If either argument is negative (illegal), then this disables the - corresponding table (e.g. itable = -1 -> explicit) - ---------------------------------------------------------------*/ -int ARKStepSetTableNum(void* arkode_mem, ARKODE_DIRKTableID itable, - ARKODE_ERKTableID etable) +int ARKStepSetOptimalParams(void* arkode_mem) { - int flag, retval; ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - sunindextype Blrw, Bliw; + ARKodeHAdaptMem hadapt_mem; + int retval; + long int lenrw, leniw; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* clear any existing parameters and Butcher tables */ - step_mem->stages = 0; - step_mem->q = 0; - step_mem->p = 0; - - ARKodeButcherTable_Space(step_mem->Be, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->Be); - step_mem->Be = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; - - ARKodeButcherTable_Space(step_mem->Bi, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->Bi); - step_mem->Bi = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; - - /* determine mode (implicit/explicit/ImEx), and perform - appropriate actions */ - - /* illegal inputs */ - if ((itable < 0) && (etable < 0)) + /* access ARKodeHAdaptMem structure */ + if (ark_mem->hadapt_mem == NULL) { arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "At least one valid table number must be supplied"); - return (ARK_ILL_INPUT); - - /* explicit */ + MSG_ARKADAPT_NO_MEM); + return (ARK_MEM_NULL); } - else if (itable < 0) - { - /* check that argument specifies an explicit table */ - if (etable < ARKODE_MIN_ERK_NUM || etable > ARKODE_MAX_ERK_NUM) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Illegal ERK table number"); - return (ARK_ILL_INPUT); - } - - /* fill in table based on argument */ - step_mem->Be = ARKodeButcherTable_LoadERK(etable); - if (step_mem->Be == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error setting explicit table with that index"); - return (ARK_ILL_INPUT); - } - step_mem->stages = step_mem->Be->stages; - step_mem->q = step_mem->Be->q; - step_mem->p = step_mem->Be->p; - - /* set method as purely explicit */ - flag = ARKStepSetExplicit(arkode_mem); - if (flag != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Error in ARKStepSetExplicit"); - return (flag); - } + hadapt_mem = ark_mem->hadapt_mem; - /* implicit */ + /* Remove current SUNAdaptController object */ + retval = SUNAdaptController_Space(hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; } - else if (etable < 0) + if (hadapt_mem->owncontroller) { - /* check that argument specifies an implicit table */ - if (itable < ARKODE_MIN_DIRK_NUM || itable > ARKODE_MAX_DIRK_NUM) + retval = SUNAdaptController_Destroy(hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; + if (retval != SUN_SUCCESS) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Illegal IRK table number"); - return (ARK_ILL_INPUT); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_Destroy failure"); + return (ARK_MEM_FAIL); } + } + hadapt_mem->hcontroller = NULL; - /* fill in table based on argument */ - step_mem->Bi = ARKodeButcherTable_LoadDIRK(itable); - if (step_mem->Bi == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error setting table with that index"); - return (ARK_ILL_INPUT); - } - step_mem->stages = step_mem->Bi->stages; - step_mem->q = step_mem->Bi->q; - step_mem->p = step_mem->Bi->p; + /* Choose values based on method, order */ - /* set method as purely implicit */ - flag = ARKStepSetImplicit(arkode_mem); - if (flag != ARK_SUCCESS) + /* explicit */ + if (step_mem->explicit && !step_mem->implicit) + { + hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Error in ARKStepSetImplicit"); - return (flag); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PI allocation failure"); + return (ARK_MEM_FAIL); } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(1.2)); + (void)SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, + SUN_RCONST(0.8), -SUN_RCONST(0.31)); + hadapt_mem->safety = SUN_RCONST(0.99); + hadapt_mem->growth = SUN_RCONST(25.0); + hadapt_mem->etamxf = SUN_RCONST(0.3); + hadapt_mem->pq = PQ; - /* ImEx */ + /* implicit */ } - else + else if (step_mem->implicit && !step_mem->explicit) { - /* ensure that tables match */ - if (!((etable == ARKODE_ARK324L2SA_ERK_4_2_3) && - (itable == ARKODE_ARK324L2SA_DIRK_4_2_3)) && - !((etable == ARKODE_ARK436L2SA_ERK_6_3_4) && - (itable == ARKODE_ARK436L2SA_DIRK_6_3_4)) && - !((etable == ARKODE_ARK437L2SA_ERK_7_3_4) && - (itable == ARKODE_ARK437L2SA_DIRK_7_3_4)) && - !((etable == ARKODE_ARK548L2SA_ERK_8_4_5) && - (itable == ARKODE_ARK548L2SA_DIRK_8_4_5)) && - !((etable == ARKODE_ARK548L2SAb_ERK_8_4_5) && - (itable == ARKODE_ARK548L2SAb_DIRK_8_4_5)) && - !((etable == ARKODE_ARK2_ERK_3_1_2) && (itable == ARKODE_ARK2_DIRK_3_1_2))) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Incompatible Butcher tables for ARK method"); - return (ARK_ILL_INPUT); - } - - /* fill in tables based on arguments */ - step_mem->Bi = ARKodeButcherTable_LoadDIRK(itable); - step_mem->Be = ARKodeButcherTable_LoadERK(etable); - if (step_mem->Bi == NULL) + switch (step_mem->q) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Illegal IRK table number"); - return (ARK_ILL_INPUT); + case 2: /* just use standard defaults since better ones unknown */ + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + hadapt_mem->safety = SAFETY; + hadapt_mem->growth = GROWTH; + hadapt_mem->etamxf = ETAMXF; + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.001); + step_mem->maxcor = 5; + step_mem->crdown = CRDOWN; + step_mem->rdiv = RDIV; + step_mem->dgmax = DGMAX; + step_mem->msbp = MSBP; + break; + case 3: + hadapt_mem->hcontroller = SUNAdaptController_I(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_I allocation failure"); + return (ARK_MEM_FAIL); + } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(1.9)); + hadapt_mem->safety = SUN_RCONST(0.957); + hadapt_mem->growth = SUN_RCONST(17.6); + hadapt_mem->etamxf = SUN_RCONST(0.45); + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.22); + step_mem->crdown = SUN_RCONST(0.17); + step_mem->rdiv = SUN_RCONST(2.3); + step_mem->dgmax = SUN_RCONST(0.19); + step_mem->msbp = 60; + break; + case 4: + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(1.2)); + (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, + SUN_RCONST(0.535), + -SUN_RCONST(0.209), + SUN_RCONST(0.148)); + hadapt_mem->safety = SUN_RCONST(0.988); + hadapt_mem->growth = SUN_RCONST(31.5); + hadapt_mem->etamxf = SUN_RCONST(0.33); + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.24); + step_mem->crdown = SUN_RCONST(0.26); + step_mem->rdiv = SUN_RCONST(2.3); + step_mem->dgmax = SUN_RCONST(0.16); + step_mem->msbp = 31; + break; + case 5: + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(3.3)); + (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, + SUN_RCONST(0.56), -SUN_RCONST(0.338), + SUN_RCONST(0.14)); + hadapt_mem->safety = SUN_RCONST(0.937); + hadapt_mem->growth = SUN_RCONST(22.0); + hadapt_mem->etamxf = SUN_RCONST(0.44); + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.25); + step_mem->crdown = SUN_RCONST(0.4); + step_mem->rdiv = SUN_RCONST(2.3); + step_mem->dgmax = SUN_RCONST(0.32); + step_mem->msbp = 31; + break; } - if (step_mem->Be == NULL) + + /* imex */ + } + else + { + switch (step_mem->q) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Illegal ERK table number"); - return (ARK_ILL_INPUT); + case 2: /* just use standard defaults since better ones unknown */ + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + hadapt_mem->safety = SAFETY; + hadapt_mem->growth = GROWTH; + hadapt_mem->etamxf = ETAMXF; + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.001); + step_mem->maxcor = 5; + step_mem->crdown = CRDOWN; + step_mem->rdiv = RDIV; + step_mem->dgmax = DGMAX; + step_mem->msbp = MSBP; + break; + case 3: + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(1.42)); + (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, + SUN_RCONST(0.54), -SUN_RCONST(0.36), + SUN_RCONST(0.14)); + hadapt_mem->safety = SUN_RCONST(0.965); + hadapt_mem->growth = SUN_RCONST(28.7); + hadapt_mem->etamxf = SUN_RCONST(0.46); + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.22); + step_mem->crdown = SUN_RCONST(0.17); + step_mem->rdiv = SUN_RCONST(2.3); + step_mem->dgmax = SUN_RCONST(0.19); + step_mem->msbp = 60; + break; + case 4: + hadapt_mem->hcontroller = SUNAdaptController_PID(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(1.35)); + (void)SUNAdaptController_SetParams_PID(hadapt_mem->hcontroller, + SUN_RCONST(0.543), + -SUN_RCONST(0.297), + SUN_RCONST(0.14)); + hadapt_mem->safety = SUN_RCONST(0.97); + hadapt_mem->growth = SUN_RCONST(25.0); + hadapt_mem->etamxf = SUN_RCONST(0.47); + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.24); + step_mem->crdown = SUN_RCONST(0.26); + step_mem->rdiv = SUN_RCONST(2.3); + step_mem->dgmax = SUN_RCONST(0.16); + step_mem->msbp = 31; + break; + case 5: + hadapt_mem->hcontroller = SUNAdaptController_PI(ark_mem->sunctx); + if (hadapt_mem->hcontroller == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PI allocation failure"); + return (ARK_MEM_FAIL); + } + (void)SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, + SUN_RCONST(1.15)); + (void)SUNAdaptController_SetParams_PI(hadapt_mem->hcontroller, + SUN_RCONST(0.8), -SUN_RCONST(0.35)); + hadapt_mem->safety = SUN_RCONST(0.993); + hadapt_mem->growth = SUN_RCONST(28.5); + hadapt_mem->etamxf = SUN_RCONST(0.3); + hadapt_mem->small_nef = SMALL_NEF; + hadapt_mem->etacf = ETACF; + hadapt_mem->pq = PQ; + step_mem->nlscoef = SUN_RCONST(0.25); + step_mem->crdown = SUN_RCONST(0.4); + step_mem->rdiv = SUN_RCONST(2.3); + step_mem->dgmax = SUN_RCONST(0.32); + step_mem->msbp = 31; + break; } - step_mem->stages = step_mem->Bi->stages; - step_mem->q = step_mem->Bi->q; - step_mem->p = step_mem->Bi->p; + hadapt_mem->owncontroller = SUNTRUE; - /* set method as ImEx */ - if (ARKStepSetImEx(arkode_mem) != ARK_SUCCESS) + retval = SUNAdaptController_Space(hadapt_mem->hcontroller, &lenrw, &leniw); + if (retval == SUN_SUCCESS) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_MISSING_F); - return (ARK_ILL_INPUT); + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; } } - return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - ARKStepSetTableName: - - Specifies to use pre-existing Butcher tables for the system, - based on the string passed to - ARKodeButcherTable_LoadERKByName() and - ARKodeButcherTable_LoadDIRKByName() within the files - arkode_butcher_erk.c and arkode_butcher_dirk.c (automatically - calls ARKStepSetImEx). - - If itable is "ARKODE_DIRK_NONE" or etable is "ARKODE_ERK_NONE", - then this disables the corresponding table. - ---------------------------------------------------------------*/ -int ARKStepSetTableName(void* arkode_mem, const char* itable, const char* etable) +int ARKStepSetOrder(void* arkode_mem, int ord) { - return ARKStepSetTableNum(arkode_mem, arkButcherTableDIRKNameToID(itable), - arkButcherTableERKNameToID(etable)); + return (ARKodeSetOrder(arkode_mem, ord)); } -/*--------------------------------------------------------------- - ARKStepSetNonlinCRDown: - - Specifies the user-provided nonlinear convergence constant - crdown. Legal values are strictly positive; illegal values - imply a reset to the default. - ---------------------------------------------------------------*/ -int ARKStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) +int ARKStepSetInterpolantType(void* arkode_mem, int itype) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; - - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* if argument legal set it, otherwise set default */ - if (crdown <= ZERO) { step_mem->crdown = CRDOWN; } - else { step_mem->crdown = crdown; } - - return (ARK_SUCCESS); + return (ARKodeSetInterpolantType(arkode_mem, itype)); } -/*--------------------------------------------------------------- - ARKStepSetNonlinRDiv: - - Specifies the user-provided nonlinear convergence constant - rdiv. Legal values are strictly positive; illegal values - imply a reset to the default. - ---------------------------------------------------------------*/ -int ARKStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) +int ARKStepSetInterpolantDegree(void* arkode_mem, int degree) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; - - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* if argument legal set it, otherwise set default */ - if (rdiv <= ZERO) { step_mem->rdiv = RDIV; } - else { step_mem->rdiv = rdiv; } - - return (ARK_SUCCESS); + return (ARKodeSetInterpolantDegree(arkode_mem, degree)); } -/*--------------------------------------------------------------- - ARKStepSetDeltaGammaMax: - - Specifies the user-provided linear setup decision constant - dgmax. Legal values are strictly positive; illegal values imply - a reset to the default. - ---------------------------------------------------------------*/ -int ARKStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) +int ARKStepSetDenseOrder(void* arkode_mem, int dord) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; - - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* if argument legal set it, otherwise set default */ - if (dgmax <= ZERO) { step_mem->dgmax = DGMAX; } - else { step_mem->dgmax = dgmax; } - - return (ARK_SUCCESS); + return (ARKodeSetInterpolantDegree(arkode_mem, dord)); } -/*--------------------------------------------------------------- - ARKStepSetLSetupFrequency: - - Specifies the user-provided linear setup decision constant - msbp. Positive values give the frequency for calling lsetup; - negative values imply recomputation of lsetup at each nonlinear - solve; a zero value implies a reset to the default. - ---------------------------------------------------------------*/ -int ARKStepSetLSetupFrequency(void* arkode_mem, int msbp) +int ARKStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; - - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* if argument legal set it, otherwise set default */ - if (msbp == 0) { step_mem->msbp = MSBP; } - else { step_mem->msbp = msbp; } - - return (ARK_SUCCESS); + return (ARKodeSetNonlinearSolver(arkode_mem, NLS)); } -/*--------------------------------------------------------------- - ARKStepSetPredictorMethod: +int ARKStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) +{ + return (ARKodeSetNlsRhsFn(arkode_mem, nls_fi)); +} - Specifies the method to use for predicting implicit solutions. - Non-default choices are {1,2,3,4}, all others will use default - (trivial) predictor. - ---------------------------------------------------------------*/ -int ARKStepSetPredictorMethod(void* arkode_mem, int pred_method) +int ARKStepSetLinear(void* arkode_mem, int timedepend) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetLinear(arkode_mem, timedepend)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetNonlinear(void* arkode_mem) +{ + return (ARKodeSetNonlinear(arkode_mem)); +} - /* set parameter */ - step_mem->predictor = pred_method; +int ARKStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) +{ + return (ARKodeSetDeduceImplicitRhs(arkode_mem, deduce)); +} - return (ARK_SUCCESS); +int ARKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) +{ + return (ARKodeSetAdaptController(arkode_mem, C)); } -/*--------------------------------------------------------------- - ARKStepSetMaxNonlinIters: +int ARKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust) +{ + return (ARKodeSetAdaptivityAdjustment(arkode_mem, adjust)); +} - Specifies the maximum number of nonlinear iterations during - one solve. A non-positive input implies a reset to the - default value. - ---------------------------------------------------------------*/ -int ARKStepSetMaxNonlinIters(void* arkode_mem, int maxcor) +int ARKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetCFLFraction(arkode_mem, cfl_frac)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety) +{ + return (ARKodeSetSafetyFactor(arkode_mem, safety)); +} - SUNFunctionBegin(ark_mem->sunctx); +int ARKStepSetErrorBias(void* arkode_mem, sunrealtype bias) +{ + return (ARKodeSetErrorBias(arkode_mem, bias)); +} - /* Return error message if no NLS module is present */ - if (step_mem->NLS == NULL) - { - arkProcessError(ark_mem, ARK_NLS_OP_ERR, __LINE__, __func__, __FILE__, - "No SUNNonlinearSolver object is present"); - return (ARK_ILL_INPUT); - } +int ARKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) +{ + return (ARKodeSetMaxGrowth(arkode_mem, mx_growth)); +} - /* argument <= 0 sets default, otherwise set input */ - if (maxcor <= 0) { step_mem->maxcor = MAXCOR; } - else { step_mem->maxcor = maxcor; } +int ARKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min) +{ + return (ARKodeSetMinReduction(arkode_mem, eta_min)); +} - /* send argument to NLS structure */ - retval = SUNNonlinSolSetMaxIters(step_mem->NLS, step_mem->maxcor); - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, ARK_NLS_OP_ERR, __LINE__, __func__, __FILE__, - "Error setting maxcor in SUNNonlinearSolver object"); - return (ARK_NLS_OP_ERR); - } +int ARKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) +{ + return (ARKodeSetFixedStepBounds(arkode_mem, lb, ub)); +} - return (ARK_SUCCESS); +int ARKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, + int pq, sunrealtype adapt_params[3]) +{ + return (arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); } -/*--------------------------------------------------------------- - ARKStepSetNonlinConvCoef: +int ARKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) +{ + return (arkSetAdaptivityFn(arkode_mem, hfun, h_data)); +} - Specifies the coefficient in the nonlinear solver convergence - test. A non-positive input implies a reset to the default value. - ---------------------------------------------------------------*/ -int ARKStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) +int ARKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetMaxFirstGrowth(arkode_mem, etamx1)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) +{ + return (ARKodeSetMaxEFailGrowth(arkode_mem, etamxf)); +} - /* argument <= 0 sets default, otherwise set input */ - if (nlscoef <= ZERO) { step_mem->nlscoef = NLSCOEF; } - else { step_mem->nlscoef = nlscoef; } +int ARKStepSetSmallNumEFails(void* arkode_mem, int small_nef) +{ + return (ARKodeSetSmallNumEFails(arkode_mem, small_nef)); +} - return (ARK_SUCCESS); +int ARKStepSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) +{ + return (ARKodeSetMaxCFailGrowth(arkode_mem, etacf)); } -/*--------------------------------------------------------------- - ARKStepSetStagePredictFn: Specifies a user-provided step - predictor function having type ARKStagePredictFn. A - NULL input function disables calls to this routine. - ---------------------------------------------------------------*/ -int ARKStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) +int ARKStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetNonlinCRDown(arkode_mem, crdown)); +} - /* access ARKodeARKStepMem structure and set function pointer */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) +{ + return (ARKodeSetNonlinRDiv(arkode_mem, rdiv)); +} - step_mem->stage_predict = PredictStage; - return (ARK_SUCCESS); +int ARKStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) +{ + return (ARKodeSetDeltaGammaMax(arkode_mem, dgmax)); } -/*--------------------------------------------------------------- - ARKStepSetDeduceImplicitRhs: +int ARKStepSetLSetupFrequency(void* arkode_mem, int msbp) +{ + return (ARKodeSetLSetupFrequency(arkode_mem, msbp)); +} - Specifies if an optimization is used to avoid an evaluation of - fi after a nonlinear solve for an implicit stage. If stage - postprocessecing in enabled, this option is ignored, and fi is - never deduced. +int ARKStepSetPredictorMethod(void* arkode_mem, int pred_method) +{ + return (ARKodeSetPredictorMethod(arkode_mem, pred_method)); +} - An argument of SUNTRUE indicates that fi is deduced to compute - fi(z_i), and SUNFALSE indicates that fi(z_i) is computed with - an additional evaluation of fi. - ---------------------------------------------------------------*/ -int ARKStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) +int ARKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetStabilityFn(arkode_mem, EStab, estab_data)); +} - /* access ARKodeARKStepMem structure and set function pointer */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetMaxErrTestFails(void* arkode_mem, int maxnef) +{ + return (ARKodeSetMaxErrTestFails(arkode_mem, maxnef)); +} - step_mem->deduce_rhs = deduce; - return (ARK_SUCCESS); +int ARKStepSetMaxNonlinIters(void* arkode_mem, int maxcor) +{ + return (ARKodeSetMaxNonlinIters(arkode_mem, maxcor)); } -/*=============================================================== - ARKStep optional output functions -- stepper-specific - ===============================================================*/ +int ARKStepSetMaxConvFails(void* arkode_mem, int maxncf) +{ + return (ARKodeSetMaxConvFails(arkode_mem, maxncf)); +} -/*--------------------------------------------------------------- - ARKStepGetCurrentGamma: Returns the current value of gamma - ---------------------------------------------------------------*/ -int ARKStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma) +int ARKStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) { - int retval; - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - *gamma = step_mem->gamma; - return (retval); + return (ARKodeSetNonlinConvCoef(arkode_mem, nlscoef)); } -/*--------------------------------------------------------------- - ARKStepGetNumRhsEvals: +int ARKStepSetConstraints(void* arkode_mem, N_Vector constraints) +{ + return (ARKodeSetConstraints(arkode_mem, constraints)); +} - Returns the current number of calls to fe and fi - ---------------------------------------------------------------*/ -int ARKStepGetNumRhsEvals(void* arkode_mem, long int* fe_evals, long int* fi_evals) +int ARKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetMaxNumSteps(arkode_mem, mxsteps)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) +{ + return (ARKodeSetMaxHnilWarns(arkode_mem, mxhnil)); +} - /* get values from step_mem */ - *fe_evals = step_mem->nfe; - *fi_evals = step_mem->nfi; +int ARKStepSetInitStep(void* arkode_mem, sunrealtype hin) +{ + return (ARKodeSetInitStep(arkode_mem, hin)); +} - return (ARK_SUCCESS); +int ARKStepSetMinStep(void* arkode_mem, sunrealtype hmin) +{ + return (ARKodeSetMinStep(arkode_mem, hmin)); } -/*--------------------------------------------------------------- - ARKStepGetNumLinSolvSetups: +int ARKStepSetMaxStep(void* arkode_mem, sunrealtype hmax) +{ + return (ARKodeSetMaxStep(arkode_mem, hmax)); +} - Returns the current number of calls to the lsetup routine - ---------------------------------------------------------------*/ -int ARKStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) +int ARKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetInterpolateStopTime(arkode_mem, interp)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetStopTime(void* arkode_mem, sunrealtype tstop) +{ + return (ARKodeSetStopTime(arkode_mem, tstop)); +} - /* get value from step_mem */ - *nlinsetups = step_mem->nsetups; +int ARKStepClearStopTime(void* arkode_mem) +{ + return (ARKodeClearStopTime(arkode_mem)); +} - return (ARK_SUCCESS); +int ARKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) +{ + return (ARKodeSetFixedStep(arkode_mem, hfixed)); } -/*--------------------------------------------------------------- - ARKStepGetCurrentButcherTables: +int ARKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) +{ + return (ARKodeSetMaxNumConstrFails(arkode_mem, maxfails)); +} - Sets pointers to the explicit and implicit Butcher tables - currently in use. - ---------------------------------------------------------------*/ -int ARKStepGetCurrentButcherTables(void* arkode_mem, ARKodeButcherTable* Bi, - ARKodeButcherTable* Be) +int ARKStepSetRootDirection(void* arkode_mem, int* rootdir) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetRootDirection(arkode_mem, rootdir)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetNoInactiveRootWarn(void* arkode_mem) +{ + return (ARKodeSetNoInactiveRootWarn(arkode_mem)); +} - /* get tables from step_mem */ - *Bi = step_mem->Bi; - *Be = step_mem->Be; - return (ARK_SUCCESS); +int ARKStepSetUserData(void* arkode_mem, void* user_data) +{ + return (ARKodeSetUserData(arkode_mem, user_data)); } -/*--------------------------------------------------------------- - ARKStepGetTimestepperStats: +int ARKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) +{ + return (ARKodeSetPostprocessStepFn(arkode_mem, ProcessStep)); +} - Returns integrator statistics - ---------------------------------------------------------------*/ -int ARKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, - long int* accsteps, long int* step_attempts, - long int* fe_evals, long int* fi_evals, - long int* nlinsetups, long int* netfails) +int ARKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetPostprocessStageFn(arkode_mem, ProcessStage)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) +{ + return (ARKodeSetStagePredictFn(arkode_mem, PredictStage)); +} - /* set expsteps and accsteps from adaptivity structure */ - *expsteps = ark_mem->hadapt_mem->nst_exp; - *accsteps = ark_mem->hadapt_mem->nst_acc; +int ARKStepSetJacFn(void* arkode_mem, ARKLsJacFn jac) +{ + return (ARKodeSetJacFn(arkode_mem, jac)); +} - /* set remaining outputs */ - *step_attempts = ark_mem->nst_attempts; - *fe_evals = step_mem->nfe; - *fi_evals = step_mem->nfi; - *nlinsetups = step_mem->nsetups; - *netfails = ark_mem->netf; +int ARKStepSetMassFn(void* arkode_mem, ARKLsMassFn mass) +{ + return (ARKodeSetMassFn(arkode_mem, mass)); +} + +int ARKStepSetJacEvalFrequency(void* arkode_mem, long int msbj) +{ + return (ARKodeSetJacEvalFrequency(arkode_mem, msbj)); +} - return (ARK_SUCCESS); +int ARKStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) +{ + return (ARKodeSetLinearSolutionScaling(arkode_mem, onoff)); } -/*--------------------------------------------------------------- - ARKStepGetNumNonlinSolvIters: +int ARKStepSetEpsLin(void* arkode_mem, sunrealtype eplifac) +{ + return (ARKodeSetEpsLin(arkode_mem, eplifac)); +} - Returns the current number of nonlinear solver iterations - ---------------------------------------------------------------*/ -int ARKStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) +int ARKStepSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetMassEpsLin(arkode_mem, eplifac)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) +{ + return (ARKodeSetLSNormFactor(arkode_mem, nrmfac)); +} - *nniters = step_mem->nls_iters; +int ARKStepSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac) +{ + return (ARKodeSetMassLSNormFactor(arkode_mem, nrmfac)); +} - return (ARK_SUCCESS); +int ARKStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, + ARKLsPrecSolveFn psolve) +{ + return (ARKodeSetPreconditioner(arkode_mem, psetup, psolve)); } -/*--------------------------------------------------------------- - ARKStepGetNumNonlinSolvConvFails: +int ARKStepSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, + ARKLsMassPrecSolveFn psolve) +{ + return (ARKodeSetMassPreconditioner(arkode_mem, psetup, psolve)); +} - Returns the current number of nonlinear solver convergence fails - ---------------------------------------------------------------*/ -int ARKStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) +int ARKStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, + ARKLsJacTimesVecFn jtimes) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeSetJacTimes(arkode_mem, jtsetup, jtimes)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) +{ + return (ARKodeSetJacTimesRhsFn(arkode_mem, jtimesRhsFn)); +} - /* set output from step_mem */ - *nnfails = step_mem->nls_fails; +int ARKStepSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn msetup, + ARKLsMassTimesVecFn mtimes, void* mtimes_data) +{ + return (ARKodeSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data)); +} - return (ARK_SUCCESS); +int ARKStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) +{ + return (ARKodeSetLinSysFn(arkode_mem, linsys)); } -/*--------------------------------------------------------------- - ARKStepGetNonlinSolvStats: +int ARKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask) +{ + return (ARKodeEvolve(arkode_mem, tout, yout, tret, itask)); +} - Returns nonlinear solver statistics - ---------------------------------------------------------------*/ -int ARKStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, - long int* nnfails) +int ARKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int retval; + return (ARKodeGetDky(arkode_mem, t, k, dky)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) +{ + return (ARKodeComputeState(arkode_mem, zcor, z)); +} - *nniters = step_mem->nls_iters; - *nnfails = step_mem->nls_fails; +int ARKStepGetNumExpSteps(void* arkode_mem, long int* nsteps) +{ + return (ARKodeGetNumExpSteps(arkode_mem, nsteps)); +} - return (ARK_SUCCESS); +int ARKStepGetNumAccSteps(void* arkode_mem, long int* nsteps) +{ + return (ARKodeGetNumAccSteps(arkode_mem, nsteps)); } -/*--------------------------------------------------------------- - ARKStepPrintAllStats: +int ARKStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) +{ + return (ARKodeGetNumStepAttempts(arkode_mem, nstep_attempts)); +} - Prints integrator statistics - ---------------------------------------------------------------*/ -int ARKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int ARKStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - ARKLsMem arkls_mem; - ARKLsMassMem arklsm_mem; - int retval; + return (ARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepGetNumErrTestFails(void* arkode_mem, long int* netfails) +{ + return (ARKodeGetNumErrTestFails(arkode_mem, netfails)); +} - /* step and rootfinding stats */ - retval = arkPrintAllStats(arkode_mem, outfile, fmt); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) +{ + return (ARKodeGetEstLocalErrors(arkode_mem, ele)); +} - switch (fmt) - { - case SUN_OUTPUTFORMAT_TABLE: - /* function evaluations */ - fprintf(outfile, "Explicit RHS fn evals = %ld\n", step_mem->nfe); - fprintf(outfile, "Implicit RHS fn evals = %ld\n", step_mem->nfi); +int ARKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) +{ + return (ARKodeGetWorkSpace(arkode_mem, lenrw, leniw)); +} - /* nonlinear solver stats */ - fprintf(outfile, "NLS iters = %ld\n", step_mem->nls_iters); - fprintf(outfile, "NLS fails = %ld\n", step_mem->nls_fails); - if (ark_mem->nst > 0) - { - fprintf(outfile, "NLS iters per step = %" RSYM "\n", - (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); - } +int ARKStepGetNumSteps(void* arkode_mem, long int* nsteps) +{ + return (ARKodeGetNumSteps(arkode_mem, nsteps)); +} - /* linear solver stats */ - fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) - { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); - fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); - fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); - fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); - fprintf(outfile, "Prec solves = %ld\n", arkls_mem->nps); - fprintf(outfile, "LS iters = %ld\n", arkls_mem->nli); - fprintf(outfile, "LS fails = %ld\n", arkls_mem->ncfl); - fprintf(outfile, "Jac-times setups = %ld\n", - arkls_mem->njtsetup); - fprintf(outfile, "Jac-times evals = %ld\n", - arkls_mem->njtimes); - if (step_mem->nls_iters > 0) - { - fprintf(outfile, "LS iters per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, "Jac evals per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, "Prec evals per NLS iter = %" RSYM "\n", - (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); - } - } +int ARKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) +{ + return (ARKodeGetActualInitStep(arkode_mem, hinused)); +} - /* mass solve stats */ - if (ark_mem->step_getmassmem(arkode_mem)) - { - arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(arkode_mem)); - fprintf(outfile, "Mass setups = %ld\n", - arklsm_mem->nmsetups); - fprintf(outfile, "Mass solves = %ld\n", - arklsm_mem->nmsolves); - fprintf(outfile, "Mass Prec setup evals = %ld\n", arklsm_mem->npe); - fprintf(outfile, "Mass Prec solves = %ld\n", arklsm_mem->nps); - fprintf(outfile, "Mass LS iters = %ld\n", arklsm_mem->nli); - fprintf(outfile, "Mass LS fails = %ld\n", arklsm_mem->ncfl); - fprintf(outfile, "Mass-times setups = %ld\n", - arklsm_mem->nmtsetup); - fprintf(outfile, "Mass-times evals = %ld\n", - arklsm_mem->nmtimes); - } - break; +int ARKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) +{ + return (ARKodeGetLastStep(arkode_mem, hlast)); +} - case SUN_OUTPUTFORMAT_CSV: - /* function evaluations */ - fprintf(outfile, ",Explicit RHS fn evals,%ld", step_mem->nfe); - fprintf(outfile, ",Implicit RHS fn evals,%ld", step_mem->nfi); +int ARKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) +{ + return (ARKodeGetCurrentStep(arkode_mem, hcur)); +} - /* nonlinear solver stats */ - fprintf(outfile, ",NLS iters,%ld", step_mem->nls_iters); - fprintf(outfile, ",NLS fails,%ld", step_mem->nls_fails); - if (ark_mem->nst > 0) - { - fprintf(outfile, ",NLS iters per step,%" RSYM, - (sunrealtype)step_mem->nls_iters / (sunrealtype)ark_mem->nst); - } - else { fprintf(outfile, ",NLS iters per step,0"); } +int ARKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) +{ + return (ARKodeGetCurrentTime(arkode_mem, tcur)); +} - /* linear solver stats */ - fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) - { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); - fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); - fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); - fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); - fprintf(outfile, ",Prec solves,%ld", arkls_mem->nps); - fprintf(outfile, ",LS iters,%ld", arkls_mem->nli); - fprintf(outfile, ",LS fails,%ld", arkls_mem->ncfl); - fprintf(outfile, ",Jac-times setups,%ld", arkls_mem->njtsetup); - fprintf(outfile, ",Jac-times evals,%ld", arkls_mem->njtimes); - if (step_mem->nls_iters > 0) - { - fprintf(outfile, ",LS iters per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->nli / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, ",Jac evals per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->nje / (sunrealtype)step_mem->nls_iters); - fprintf(outfile, ",Prec evals per NLS iter,%" RSYM, - (sunrealtype)arkls_mem->npe / (sunrealtype)step_mem->nls_iters); - } - else - { - fprintf(outfile, ",LS iters per NLS iter,0"); - fprintf(outfile, ",Jac evals per NLS iter,0"); - fprintf(outfile, ",Prec evals per NLS iter,0"); - } - } +int ARKStepGetCurrentState(void* arkode_mem, N_Vector* state) +{ + return (ARKodeGetCurrentState(arkode_mem, state)); +} - /* mass solve stats */ - if (ark_mem->step_getmassmem(arkode_mem)) - { - arklsm_mem = (ARKLsMassMem)(ark_mem->step_getmassmem(arkode_mem)); - fprintf(outfile, ",Mass setups,%ld", arklsm_mem->nmsetups); - fprintf(outfile, ",Mass solves,%ld", arklsm_mem->nmsolves); - fprintf(outfile, ",Mass Prec setup evals,%ld", arklsm_mem->npe); - fprintf(outfile, ",Mass Prec solves,%ld", arklsm_mem->nps); - fprintf(outfile, ",Mass LS iters,%ld", arklsm_mem->nli); - fprintf(outfile, ",Mass LS fails,%ld", arklsm_mem->ncfl); - fprintf(outfile, ",Mass-times setups,%ld", arklsm_mem->nmtsetup); - fprintf(outfile, ",Mass-times evals,%ld", arklsm_mem->nmtimes); - } - fprintf(outfile, "\n"); - break; +int ARKStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma) +{ + return (ARKodeGetCurrentGamma(arkode_mem, gamma)); +} - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return (ARK_ILL_INPUT); - } +int ARKStepGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M) +{ + return (ARKodeGetCurrentMassMatrix(arkode_mem, M)); +} - return (ARK_SUCCESS); +int ARKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) +{ + return (ARKodeGetTolScaleFactor(arkode_mem, tolsfact)); } -/*=============================================================== - ARKStep parameter output - ===============================================================*/ +int ARKStepGetErrWeights(void* arkode_mem, N_Vector eweight) +{ + return (ARKodeGetErrWeights(arkode_mem, eweight)); +} -/*--------------------------------------------------------------- - ARKStepWriteParameters: +int ARKStepGetResWeights(void* arkode_mem, N_Vector rweight) +{ + return (ARKodeGetResWeights(arkode_mem, rweight)); +} - Outputs all solver parameters to the provided file pointer. - ---------------------------------------------------------------*/ -int ARKStepWriteParameters(void* arkode_mem, FILE* fp) +int ARKStepGetNumGEvals(void* arkode_mem, long int* ngevals) { - ARKodeMem ark_mem; - ARKodeARKStepMem step_mem; - int flag, retval; + return (ARKodeGetNumGEvals(arkode_mem, ngevals)); +} - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ARKStepGetRootInfo(void* arkode_mem, int* rootsfound) +{ + return (ARKodeGetRootInfo(arkode_mem, rootsfound)); +} - /* output ARKODE infrastructure parameters first */ - flag = arkWriteParameters(ark_mem, fp); - if (flag != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error writing ARKODE infrastructure parameters"); - return (flag); - } +int ARKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) +{ + return (ARKodeGetNumConstrFails(arkode_mem, nconstrfails)); +} - /* print integrator parameters to file */ - fprintf(fp, "ARKStep time step module parameters:\n"); - fprintf(fp, " Method order %i\n", step_mem->q); - if (step_mem->linear) - { - fprintf(fp, " Linear implicit problem"); - if (step_mem->linear_timedep) - { - fprintf(fp, " (time-dependent Jacobian)\n"); - } - else { fprintf(fp, " (time-independent Jacobian)\n"); } - } - if (step_mem->explicit && step_mem->implicit) - { - fprintf(fp, " ImEx integrator\n"); - } - else if (step_mem->implicit) { fprintf(fp, " Implicit integrator\n"); } - else { fprintf(fp, " Explicit integrator\n"); } +int ARKStepGetUserData(void* arkode_mem, void** user_data) +{ + return (ARKodeGetUserData(arkode_mem, user_data)); +} - if (step_mem->implicit) - { - fprintf(fp, " Implicit predictor method = %i\n", step_mem->predictor); - fprintf(fp, " Implicit solver tolerance coefficient = %" RSYM "\n", - step_mem->nlscoef); - fprintf(fp, " Maximum number of nonlinear corrections = %i\n", - step_mem->maxcor); - fprintf(fp, " Nonlinear convergence rate constant = %" RSYM "\n", - step_mem->crdown); - fprintf(fp, " Nonlinear divergence tolerance = %" RSYM "\n", step_mem->rdiv); - fprintf(fp, " Gamma factor LSetup tolerance = %" RSYM "\n", step_mem->dgmax); - fprintf(fp, " Number of steps between LSetup calls = %i\n", step_mem->msbp); - } - fprintf(fp, "\n"); +int ARKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +{ + return (ARKodePrintAllStats(arkode_mem, outfile, fmt)); +} - return (ARK_SUCCESS); +char* ARKStepGetReturnFlagName(long int flag) +{ + return (ARKodeGetReturnFlagName(flag)); } -/*--------------------------------------------------------------- - ARKStepWriteButcher: +int ARKStepWriteParameters(void* arkode_mem, FILE* fp) +{ + return (ARKodeWriteParameters(arkode_mem, fp)); +} - Outputs Butcher tables to the provided file pointer. - ---------------------------------------------------------------*/ int ARKStepWriteButcher(void* arkode_mem, FILE* fp) { int retval; ARKodeMem ark_mem; ARKodeARKStepMem step_mem; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that Butcher table is non-NULL (otherwise report error) */ @@ -2298,6 +2160,250 @@ int ARKStepWriteButcher(void* arkode_mem, FILE* fp) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +int ARKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, + sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) +{ + return (ARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); +} + +int ARKStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data) +{ + return (ARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, Fi, gamma, + sdata, user_data)); +} + +int ARKStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) +{ + return (ARKodeGetNumNonlinSolvIters(arkode_mem, nniters)); +} + +int ARKStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) +{ + return (ARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails)); +} + +int ARKStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, + long int* nnfails) +{ + return (ARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails)); +} + +int ARKStepGetNumStepSolveFails(void* arkode_mem, long int* nncfails) +{ + return (ARKodeGetNumStepSolveFails(arkode_mem, nncfails)); +} + +int ARKStepGetJac(void* arkode_mem, SUNMatrix* J) +{ + return (ARKodeGetJac(arkode_mem, J)); +} + +int ARKStepGetJacTime(void* arkode_mem, sunrealtype* t_J) +{ + return (ARKodeGetJacTime(arkode_mem, t_J)); +} + +int ARKStepGetJacNumSteps(void* arkode_mem, long* nst_J) +{ + return (ARKodeGetJacNumSteps(arkode_mem, nst_J)); +} + +int ARKStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) +{ + return (ARKodeGetLinWorkSpace(arkode_mem, lenrwLS, leniwLS)); +} + +int ARKStepGetNumJacEvals(void* arkode_mem, long int* njevals) +{ + return (ARKodeGetNumJacEvals(arkode_mem, njevals)); +} + +int ARKStepGetNumPrecEvals(void* arkode_mem, long int* npevals) +{ + return (ARKodeGetNumPrecEvals(arkode_mem, npevals)); +} + +int ARKStepGetNumPrecSolves(void* arkode_mem, long int* npsolves) +{ + return (ARKodeGetNumPrecSolves(arkode_mem, npsolves)); +} + +int ARKStepGetNumLinIters(void* arkode_mem, long int* nliters) +{ + return (ARKodeGetNumLinIters(arkode_mem, nliters)); +} + +int ARKStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails) +{ + return (ARKodeGetNumLinConvFails(arkode_mem, nlcfails)); +} + +int ARKStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) +{ + return (ARKodeGetNumJTSetupEvals(arkode_mem, njtsetups)); +} + +int ARKStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals) +{ + return (ARKodeGetNumJtimesEvals(arkode_mem, njvevals)); +} + +int ARKStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) +{ + return (ARKodeGetNumLinRhsEvals(arkode_mem, nfevalsLS)); +} + +int ARKStepGetLastLinFlag(void* arkode_mem, long int* flag) +{ + return (ARKodeGetLastLinFlag(arkode_mem, flag)); +} + +int ARKStepGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, + long int* leniwMLS) +{ + return (ARKodeGetMassWorkSpace(arkode_mem, lenrwMLS, leniwMLS)); +} + +int ARKStepGetNumMassSetups(void* arkode_mem, long int* nmsetups) +{ + return (ARKodeGetNumMassSetups(arkode_mem, nmsetups)); +} + +int ARKStepGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups) +{ + return (ARKodeGetNumMassMultSetups(arkode_mem, nmvsetups)); +} + +int ARKStepGetNumMassMult(void* arkode_mem, long int* nmvevals) +{ + return (ARKodeGetNumMassMult(arkode_mem, nmvevals)); +} + +int ARKStepGetNumMassSolves(void* arkode_mem, long int* nmsolves) +{ + return (ARKodeGetNumMassSolves(arkode_mem, nmsolves)); +} + +int ARKStepGetNumMassPrecEvals(void* arkode_mem, long int* nmpevals) +{ + return (ARKodeGetNumMassPrecEvals(arkode_mem, nmpevals)); +} + +int ARKStepGetNumMassPrecSolves(void* arkode_mem, long int* nmpsolves) +{ + return (ARKodeGetNumMassPrecSolves(arkode_mem, nmpsolves)); +} + +int ARKStepGetNumMassIters(void* arkode_mem, long int* nmiters) +{ + return (ARKodeGetNumMassIters(arkode_mem, nmiters)); +} + +int ARKStepGetNumMassConvFails(void* arkode_mem, long int* nmcfails) +{ + return (ARKodeGetNumMassConvFails(arkode_mem, nmcfails)); +} + +int ARKStepGetNumMTSetups(void* arkode_mem, long int* nmtsetups) +{ + return (ARKodeGetNumMTSetups(arkode_mem, nmtsetups)); +} + +int ARKStepGetLastMassFlag(void* arkode_mem, long int* flag) +{ + return (ARKodeGetLastMassFlag(arkode_mem, flag)); +} + +char* ARKStepGetLinReturnFlagName(long int flag) +{ + return (ARKodeGetLinReturnFlagName(flag)); +} + +void ARKStepFree(void** arkode_mem) { ARKodeFree(arkode_mem); } + +void ARKStepPrintMem(void* arkode_mem, FILE* outfile) +{ + ARKodePrintMem(arkode_mem, outfile); +} + +int ARKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) +{ + return (ARKodeSetRelaxFn(arkode_mem, rfn, rjac)); +} + +int ARKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf) +{ + return (ARKodeSetRelaxEtaFail(arkode_mem, eta_rf)); +} + +int ARKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) +{ + return (ARKodeSetRelaxLowerBound(arkode_mem, lower)); +} + +int ARKStepSetRelaxMaxFails(void* arkode_mem, int max_fails) +{ + return (ARKodeSetRelaxMaxFails(arkode_mem, max_fails)); +} + +int ARKStepSetRelaxMaxIters(void* arkode_mem, int max_iters) +{ + return (ARKodeSetRelaxMaxIters(arkode_mem, max_iters)); +} + +int ARKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) +{ + return (ARKodeSetRelaxSolver(arkode_mem, solver)); +} + +int ARKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) +{ + return (ARKodeSetRelaxResTol(arkode_mem, res_tol)); +} + +int ARKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) +{ + return (ARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol)); +} + +int ARKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) +{ + return (ARKodeSetRelaxUpperBound(arkode_mem, upper)); +} + +int ARKStepGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) +{ + return (ARKodeGetNumRelaxFnEvals(arkode_mem, r_evals)); +} + +int ARKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) +{ + return (ARKodeGetNumRelaxJacEvals(arkode_mem, J_evals)); +} + +int ARKStepGetNumRelaxFails(void* arkode_mem, long int* relax_fails) +{ + return (ARKodeGetNumRelaxFails(arkode_mem, relax_fails)); +} + +int ARKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails) +{ + return (ARKodeGetNumRelaxBoundFails(arkode_mem, fails)); +} + +int ARKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails) +{ + return (ARKodeGetNumRelaxSolveFails(arkode_mem, fails)); +} + +int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) +{ + return (ARKodeGetNumRelaxSolveIters(arkode_mem, iters)); +} + +/*=============================================================== EOF - ---------------------------------------------------------------*/ + ===============================================================*/ diff --git a/src/arkode/arkode_arkstep_nls.c b/src/arkode/arkode_arkstep_nls.c index f52325b487..7cfe1f14f1 100644 --- a/src/arkode/arkode_arkstep_nls.c +++ b/src/arkode/arkode_arkstep_nls.c @@ -24,23 +24,22 @@ #include "arkode_impl.h" /*=============================================================== - Exported functions + Interface routines supplied to ARKODE ===============================================================*/ /*--------------------------------------------------------------- - ARKStepSetNonlinearSolver: + arkStep_SetNonlinearSolver: This routine attaches a SUNNonlinearSolver object to the ARKStep module. ---------------------------------------------------------------*/ -int ARKStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) +int arkStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if NLS input is NULL */ @@ -102,20 +101,19 @@ int ARKStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) } /*--------------------------------------------------------------- - ARKStepSetNlsRhsFn: + arkStep_SetNlsRhsFn: This routine sets an alternative user-supplied implicit ODE right-hand side function to use in the evaluation of nonlinear system functions. ---------------------------------------------------------------*/ -int ARKStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) +int arkStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fi) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nls_fi) { step_mem->nls_fi = nls_fi; } @@ -125,22 +123,21 @@ int ARKStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) } /*--------------------------------------------------------------- - ARKStepGetNonlinearSystemData: + arkStep_GetNonlinearSystemData: This routine provides access to the relevant data needed to compute the nonlinear system function. ---------------------------------------------------------------*/ -int ARKStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, - N_Vector* zpred, N_Vector* z, N_Vector* Fi, - sunrealtype* gamma, N_Vector* sdata, - void** user_data) +int arkStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data) { - ARKodeMem ark_mem; ARKodeARKStepMem step_mem; int retval; /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = arkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *tcur = ark_mem->tcur; @@ -154,9 +151,9 @@ int ARKStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== Utility routines called by ARKStep - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- arkStep_NlsInit: @@ -388,9 +385,9 @@ int arkStep_Nls(ARKodeMem ark_mem, int nflag) return (retval); } -/*--------------------------------------------------------------- +/*=============================================================== Interface routines supplied to the SUNNonlinearSolver module - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- arkStep_NlsLSetup: @@ -404,8 +401,8 @@ int arkStep_NlsLSetup(sunbooleantype jbad, sunbooleantype* jcur, void* arkode_me ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update convfail based on jbad flag */ @@ -446,8 +443,8 @@ int arkStep_NlsLSolve(N_Vector b, void* arkode_mem) ARKodeARKStepMem step_mem; int retval, nonlin_iter; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* retrieve nonlinear solver iteration from module */ @@ -501,8 +498,8 @@ int arkStep_NlsResidual_MassIdent(N_Vector zcor, N_Vector r, void* arkode_mem) sunrealtype c[3]; N_Vector X[3]; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -563,8 +560,8 @@ int arkStep_NlsResidual_MassFixed(N_Vector zcor, N_Vector r, void* arkode_mem) sunrealtype c[3]; N_Vector X[3]; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -631,8 +628,8 @@ int arkStep_NlsResidual_MassTDep(N_Vector zcor, N_Vector r, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -696,8 +693,8 @@ int arkStep_NlsFPFunction_MassIdent(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -759,8 +756,8 @@ int arkStep_NlsFPFunction_MassFixed(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -828,8 +825,8 @@ int arkStep_NlsFPFunction_MassTDep(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeARKStepMem step_mem; int retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -884,8 +881,8 @@ int arkStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, sunrealtype delnrm, dcon; int m, retval; - /* access ARKodeARKStepMem structure */ - retval = arkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeARKStepMem structures */ + retval = arkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if the problem is linearly implicit, just return success */ diff --git a/src/arkode/arkode_bandpre.c b/src/arkode/arkode_bandpre.c index 6eb5f576da..ad1d72e2b1 100644 --- a/src/arkode/arkode_bandpre.c +++ b/src/arkode/arkode_bandpre.c @@ -62,8 +62,8 @@ int ARKBandPrecInit(void* arkode_mem, sunindextype N, sunindextype mu, sunindextype mup, mlp, storagemu; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Test compatibility of NVECTOR package with the BAND preconditioner */ @@ -187,7 +187,8 @@ int ARKBandPrecInit(void* arkode_mem, sunindextype N, sunindextype mu, arkls_mem->pfree = ARKBandPrecFree; /* Attach preconditioner solve and setup functions */ - retval = arkLSSetPreconditioner(arkode_mem, ARKBandPrecSetup, ARKBandPrecSolve); + retval = ARKodeSetPreconditioner(arkode_mem, ARKBandPrecSetup, + ARKBandPrecSolve); return (retval); } @@ -200,8 +201,8 @@ int ARKBandPrecGetWorkSpace(void* arkode_mem, long int* lenrwBP, long int* leniw long int lrw, liw; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if ARKBandPrecData is NULL */ @@ -260,8 +261,8 @@ int ARKBandPrecGetNumRhsEvals(void* arkode_mem, long int* nfevalsBP) ARKBandPrecData pdata; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if ARKBandPrecData is NULL */ diff --git a/src/arkode/arkode_bbdpre.c b/src/arkode/arkode_bbdpre.c index 52f2ee29d9..aa2c2fb652 100644 --- a/src/arkode/arkode_bbdpre.c +++ b/src/arkode/arkode_bbdpre.c @@ -60,8 +60,8 @@ int ARKBBDPrecInit(void* arkode_mem, sunindextype Nlocal, sunindextype mudq, long int lrw, liw; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Test compatibility of NVECTOR package with the BBD preconditioner */ @@ -282,7 +282,7 @@ int ARKBBDPrecInit(void* arkode_mem, sunindextype Nlocal, sunindextype mudq, arkls_mem->pfree = ARKBBDPrecFree; /* Attach preconditioner solve and setup functions */ - retval = arkLSSetPreconditioner(arkode_mem, ARKBBDPrecSetup, ARKBBDPrecSolve); + retval = ARKodeSetPreconditioner(arkode_mem, ARKBBDPrecSetup, ARKBBDPrecSolve); return (retval); } @@ -297,8 +297,8 @@ int ARKBBDPrecReInit(void* arkode_mem, sunindextype mudq, sunindextype mldq, sunindextype Nlocal; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately ARKBBDPrecData is NULL */ @@ -333,8 +333,8 @@ int ARKBBDPrecGetWorkSpace(void* arkode_mem, long int* lenrwBBDP, ARKBBDPrecData pdata; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately ARKBBDPrecData is NULL */ @@ -361,8 +361,8 @@ int ARKBBDPrecGetNumGfnEvals(void* arkode_mem, long int* ngevalsBBDP) ARKBBDPrecData pdata; int retval; - /* access ARKMilsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structure */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if ARKBBDPrecData is NULL */ diff --git a/src/arkode/arkode_butcher.c b/src/arkode/arkode_butcher.c index 0807d05fca..a6321cf16f 100644 --- a/src/arkode/arkode_butcher.c +++ b/src/arkode/arkode_butcher.c @@ -25,102 +25,137 @@ #define TOL (SUNRsqrt(SUN_UNIT_ROUNDOFF)) /* Private utility functions for checking method order */ -static int __mv(sunrealtype** A, sunrealtype* x, int s, sunrealtype* b); -static int __vv(sunrealtype* x, sunrealtype* y, int s, sunrealtype* z); -static int __vp(sunrealtype* x, int l, int s, sunrealtype* z); -static int __dot(sunrealtype* x, sunrealtype* y, int s, sunrealtype* d); -static sunbooleantype __rowsum(sunrealtype** A, sunrealtype* c, int s); -static sunbooleantype __order1(sunrealtype* b, int s); -static sunbooleantype __order2(sunrealtype* b, sunrealtype* c, int s); -static sunbooleantype __order3a(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, int s); -static sunbooleantype __order3b(sunrealtype* b, sunrealtype** A, sunrealtype* c, - int s); -static sunbooleantype __order4a(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, int s); -static sunbooleantype __order4b(sunrealtype* b, sunrealtype* c1, - sunrealtype** A, sunrealtype* c2, int s); -static sunbooleantype __order4c(sunrealtype* b, sunrealtype** A, - sunrealtype* c1, sunrealtype* c2, int s); -static sunbooleantype __order4d(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c, int s); -static sunbooleantype __order5a(sunrealtype* b, sunrealtype* c1, sunrealtype* c2, - sunrealtype* c3, sunrealtype* c4, int s); -static sunbooleantype __order5b(sunrealtype* b, sunrealtype* c1, sunrealtype* c2, - sunrealtype** A, sunrealtype* c3, int s); -static sunbooleantype __order5c(sunrealtype* b, sunrealtype** A1, sunrealtype* c1, - sunrealtype** A2, sunrealtype* c2, int s); -static sunbooleantype __order5d(sunrealtype* b, sunrealtype* c1, sunrealtype** A, - sunrealtype* c2, sunrealtype* c3, int s); -static sunbooleantype __order5e(sunrealtype* b, sunrealtype** A, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, int s); -static sunbooleantype __order5f(sunrealtype* b, sunrealtype* c1, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c2, int s); -static sunbooleantype __order5g(sunrealtype* b, sunrealtype** A1, sunrealtype* c1, - sunrealtype** A2, sunrealtype* c2, int s); -static sunbooleantype __order5h(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype* c2, int s); -static sunbooleantype __order5i(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype** A3, - sunrealtype* c, int s); -static sunbooleantype __order6a(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, - sunrealtype* c4, sunrealtype* c5, int s); -static sunbooleantype __order6b(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, - sunrealtype** A, sunrealtype* c4, int s); -static sunbooleantype __order6c(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype* c2, - sunrealtype** A2, sunrealtype* c3, int s); -static sunbooleantype __order6d(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype** A, - sunrealtype* c3, sunrealtype* c4, int s); -static sunbooleantype __order6e(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c3, int s); -static sunbooleantype __order6f(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype** A3, sunrealtype* c2, int s); -static sunbooleantype __order6g(sunrealtype* b, sunrealtype* c1, - sunrealtype** A, sunrealtype* c2, - sunrealtype* c3, sunrealtype* c4, int s); -static sunbooleantype __order6h(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype* c2, - sunrealtype** A2, sunrealtype* c3, int s); -static sunbooleantype __order6i(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype** A2, - sunrealtype* c2, sunrealtype* c3, int s); -static sunbooleantype __order6j(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype** A2, - sunrealtype** A3, sunrealtype* c2, int s); -static sunbooleantype __order6k(sunrealtype* b, sunrealtype** A, - sunrealtype* c1, sunrealtype* c2, - sunrealtype* c3, sunrealtype* c4, int s); -static sunbooleantype __order6l(sunrealtype* b, sunrealtype** A1, - sunrealtype* c1, sunrealtype* c2, - sunrealtype** A2, sunrealtype* c3, int s); -static sunbooleantype __order6m(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype** A3, sunrealtype* c2, int s); -static sunbooleantype __order6n(sunrealtype* b, sunrealtype** A1, - sunrealtype* c1, sunrealtype** A2, - sunrealtype* c2, sunrealtype* c3, int s); -static sunbooleantype __order6o(sunrealtype* b, sunrealtype** A1, - sunrealtype* c1, sunrealtype** A2, - sunrealtype** A3, sunrealtype* c2, int s); -static sunbooleantype __order6p(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, int s); -static sunbooleantype __order6q(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype** A3, sunrealtype* c2, int s); -static sunbooleantype __order6r(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype** A3, - sunrealtype* c1, sunrealtype* c2, int s); -static sunbooleantype __order6s(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype** A3, - sunrealtype** A4, sunrealtype* c, int s); +static int arkode_butcher_mv(sunrealtype** A, sunrealtype* x, int s, + sunrealtype* b); +static int arkode_butcher_vv(sunrealtype* x, sunrealtype* y, int s, + sunrealtype* z); +static int arkode_butcher_vp(sunrealtype* x, int l, int s, sunrealtype* z); +static int arkode_butcher_dot(sunrealtype* x, sunrealtype* y, int s, + sunrealtype* d); +static sunbooleantype arkode_butcher_rowsum(sunrealtype** A, sunrealtype* c, + int s); +static sunbooleantype arkode_butcher_order1(sunrealtype* b, int s); +static sunbooleantype arkode_butcher_order2(sunrealtype* b, sunrealtype* c, + int s); +static sunbooleantype arkode_butcher_order3a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, int s); +static sunbooleantype arkode_butcher_order3b(sunrealtype* b, sunrealtype** A, + sunrealtype* c, int s); +static sunbooleantype arkode_butcher_order4a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order4b(sunrealtype* b, sunrealtype* c1, + sunrealtype** A, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order4c(sunrealtype* b, sunrealtype** A, + sunrealtype* c1, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order4d(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c, + int s); +static sunbooleantype arkode_butcher_order5a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + sunrealtype* c4, int s); +static sunbooleantype arkode_butcher_order5b(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype** A, + sunrealtype* c3, int s); +static sunbooleantype arkode_butcher_order5c(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype* c2, int s); +static sunbooleantype arkode_butcher_order5d(sunrealtype* b, sunrealtype* c1, + sunrealtype** A, sunrealtype* c2, + sunrealtype* c3, int s); +static sunbooleantype arkode_butcher_order5e(sunrealtype* b, sunrealtype** A, + sunrealtype* c1, sunrealtype* c2, + sunrealtype* c3, int s); +static sunbooleantype arkode_butcher_order5f(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype** A2, + sunrealtype* c2, int s); +static sunbooleantype arkode_butcher_order5g(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype* c2, int s); +static sunbooleantype arkode_butcher_order5h(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype* c2, int s); +static sunbooleantype arkode_butcher_order5i(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype** A3, + sunrealtype* c, int s); +static sunbooleantype arkode_butcher_order6a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + sunrealtype* c4, sunrealtype* c5, + int s); +static sunbooleantype arkode_butcher_order6b(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + sunrealtype** A, sunrealtype* c4, + int s); +static sunbooleantype arkode_butcher_order6c(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype* c2, + sunrealtype** A2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6d(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype** A, + sunrealtype* c3, sunrealtype* c4, + int s); +static sunbooleantype arkode_butcher_order6e(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6f(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype** A3, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order6g(sunrealtype* b, sunrealtype* c1, + sunrealtype** A, sunrealtype* c2, + sunrealtype* c3, sunrealtype* c4, + int s); +static sunbooleantype arkode_butcher_order6h(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype* c2, + sunrealtype** A2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6i(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype** A2, + sunrealtype* c2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6j(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype** A2, + sunrealtype** A3, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order6k(sunrealtype* b, sunrealtype** A, + sunrealtype* c1, sunrealtype* c2, + sunrealtype* c3, sunrealtype* c4, + int s); +static sunbooleantype arkode_butcher_order6l(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype* c2, + sunrealtype** A2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6m(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype** A3, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order6n(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype* c2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6o(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype** A3, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order6p(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + int s); +static sunbooleantype arkode_butcher_order6q(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype** A3, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order6r(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype** A3, + sunrealtype* c1, sunrealtype* c2, + int s); +static sunbooleantype arkode_butcher_order6s(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype** A3, + sunrealtype** A4, sunrealtype* c, + int s); static int __ButcherSimplifyingAssumptions(sunrealtype** A, sunrealtype* b, sunrealtype* c, int s); @@ -453,7 +488,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if (outfile) { fprintf(outfile, "ARKodeButcherTable_CheckOrder:\n"); } /* row sum condition */ - if (__rowsum(A, c, s)) { (*q) = 0; } + if (arkode_butcher_rowsum(A, c, s)) { (*q) = 0; } else { (*q) = -1; @@ -462,7 +497,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, /* order 1 condition */ if ((*q) == 0) { - if (__order1(b, s)) { (*q) = 1; } + if (arkode_butcher_order1(b, s)) { (*q) = 1; } else { if (outfile) { fprintf(outfile, " method fails order 1 condition\n"); } @@ -471,7 +506,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, /* order 2 condition */ if ((*q) == 1) { - if (__order2(b, c, s)) { (*q) = 2; } + if (arkode_butcher_order2(b, c, s)) { (*q) = 2; } else { if (outfile) { fprintf(outfile, " method fails order 2 condition\n"); } @@ -481,12 +516,12 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*q) == 2) { alltrue = SUNTRUE; - if (!__order3a(b, c, c, s)) + if (!arkode_butcher_order3a(b, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 3 condition A\n"); } } - if (!__order3b(b, A, c, s)) + if (!arkode_butcher_order3b(b, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 3 condition B\n"); } @@ -497,22 +532,22 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*q) == 3) { alltrue = SUNTRUE; - if (!__order4a(b, c, c, c, s)) + if (!arkode_butcher_order4a(b, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 4 condition A\n"); } } - if (!__order4b(b, c, A, c, s)) + if (!arkode_butcher_order4b(b, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 4 condition B\n"); } } - if (!__order4c(b, A, c, c, s)) + if (!arkode_butcher_order4c(b, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 4 condition C\n"); } } - if (!__order4d(b, A, A, c, s)) + if (!arkode_butcher_order4d(b, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 4 condition D\n"); } @@ -523,47 +558,47 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*q) == 4) { alltrue = SUNTRUE; - if (!__order5a(b, c, c, c, c, s)) + if (!arkode_butcher_order5a(b, c, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition A\n"); } } - if (!__order5b(b, c, c, A, c, s)) + if (!arkode_butcher_order5b(b, c, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition B\n"); } } - if (!__order5c(b, A, c, A, c, s)) + if (!arkode_butcher_order5c(b, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition C\n"); } } - if (!__order5d(b, c, A, c, c, s)) + if (!arkode_butcher_order5d(b, c, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition D\n"); } } - if (!__order5e(b, A, c, c, c, s)) + if (!arkode_butcher_order5e(b, A, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition E\n"); } } - if (!__order5f(b, c, A, A, c, s)) + if (!arkode_butcher_order5f(b, c, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition F\n"); } } - if (!__order5g(b, A, c, A, c, s)) + if (!arkode_butcher_order5g(b, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition G\n"); } } - if (!__order5h(b, A, A, c, c, s)) + if (!arkode_butcher_order5h(b, A, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition H\n"); } } - if (!__order5i(b, A, A, A, c, s)) + if (!arkode_butcher_order5i(b, A, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 5 condition I\n"); } @@ -574,97 +609,97 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*q) == 5) { alltrue = SUNTRUE; - if (!__order6a(b, c, c, c, c, c, s)) + if (!arkode_butcher_order6a(b, c, c, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition A\n"); } } - if (!__order6b(b, c, c, c, A, c, s)) + if (!arkode_butcher_order6b(b, c, c, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition B\n"); } } - if (!__order6c(b, c, A, c, A, c, s)) + if (!arkode_butcher_order6c(b, c, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition C\n"); } } - if (!__order6d(b, c, c, A, c, c, s)) + if (!arkode_butcher_order6d(b, c, c, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition D\n"); } } - if (!__order6e(b, c, c, A, A, c, s)) + if (!arkode_butcher_order6e(b, c, c, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition E\n"); } } - if (!__order6f(b, A, A, c, A, c, s)) + if (!arkode_butcher_order6f(b, A, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition F\n"); } } - if (!__order6g(b, c, A, c, c, c, s)) + if (!arkode_butcher_order6g(b, c, A, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition G\n"); } } - if (!__order6h(b, c, A, c, A, c, s)) + if (!arkode_butcher_order6h(b, c, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition H\n"); } } - if (!__order6i(b, c, A, A, c, c, s)) + if (!arkode_butcher_order6i(b, c, A, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition I\n"); } } - if (!__order6j(b, c, A, A, A, c, s)) + if (!arkode_butcher_order6j(b, c, A, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition J\n"); } } - if (!__order6k(b, A, c, c, c, c, s)) + if (!arkode_butcher_order6k(b, A, c, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition K\n"); } } - if (!__order6l(b, A, c, c, A, c, s)) + if (!arkode_butcher_order6l(b, A, c, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition L\n"); } } - if (!__order6m(b, A, A, c, A, c, s)) + if (!arkode_butcher_order6m(b, A, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition M\n"); } } - if (!__order6n(b, A, c, A, c, c, s)) + if (!arkode_butcher_order6n(b, A, c, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition N\n"); } } - if (!__order6o(b, A, c, A, A, c, s)) + if (!arkode_butcher_order6o(b, A, c, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition O\n"); } } - if (!__order6p(b, A, A, c, c, c, s)) + if (!arkode_butcher_order6p(b, A, A, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition P\n"); } } - if (!__order6q(b, A, A, c, A, c, s)) + if (!arkode_butcher_order6q(b, A, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition Q\n"); } } - if (!__order6r(b, A, A, A, c, c, s)) + if (!arkode_butcher_order6r(b, A, A, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition R\n"); } } - if (!__order6s(b, A, A, A, A, c, s)) + if (!arkode_butcher_order6s(b, A, A, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) { fprintf(outfile, " method fails order 6 condition S\n"); } @@ -691,7 +726,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, b = d; /* row sum condition */ - if (__rowsum(A, c, s)) { (*p) = 0; } + if (arkode_butcher_rowsum(A, c, s)) { (*p) = 0; } else { (*p) = -1; @@ -703,7 +738,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, /* order 1 condition */ if ((*p) == 0) { - if (__order1(b, s)) { (*p) = 1; } + if (arkode_butcher_order1(b, s)) { (*p) = 1; } else { if (outfile) @@ -715,7 +750,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, /* order 2 condition */ if ((*p) == 1) { - if (__order2(b, c, s)) { (*p) = 2; } + if (arkode_butcher_order2(b, c, s)) { (*p) = 2; } else { if (outfile) @@ -728,7 +763,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*p) == 2) { alltrue = SUNTRUE; - if (!__order3a(b, c, c, s)) + if (!arkode_butcher_order3a(b, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -736,7 +771,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 3 condition A\n"); } } - if (!__order3b(b, A, c, s)) + if (!arkode_butcher_order3b(b, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -750,7 +785,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*p) == 3) { alltrue = SUNTRUE; - if (!__order4a(b, c, c, c, s)) + if (!arkode_butcher_order4a(b, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -758,7 +793,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 4 condition A\n"); } } - if (!__order4b(b, c, A, c, s)) + if (!arkode_butcher_order4b(b, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -766,7 +801,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 4 condition B\n"); } } - if (!__order4c(b, A, c, c, s)) + if (!arkode_butcher_order4c(b, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -774,7 +809,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 4 condition C\n"); } } - if (!__order4d(b, A, A, c, s)) + if (!arkode_butcher_order4d(b, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -788,7 +823,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*p) == 4) { alltrue = SUNTRUE; - if (!__order5a(b, c, c, c, c, s)) + if (!arkode_butcher_order5a(b, c, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -796,7 +831,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition A\n"); } } - if (!__order5b(b, c, c, A, c, s)) + if (!arkode_butcher_order5b(b, c, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -804,7 +839,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition B\n"); } } - if (!__order5c(b, A, c, A, c, s)) + if (!arkode_butcher_order5c(b, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -812,7 +847,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition C\n"); } } - if (!__order5d(b, c, A, c, c, s)) + if (!arkode_butcher_order5d(b, c, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -820,7 +855,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition D\n"); } } - if (!__order5e(b, A, c, c, c, s)) + if (!arkode_butcher_order5e(b, A, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -828,7 +863,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition E\n"); } } - if (!__order5f(b, c, A, A, c, s)) + if (!arkode_butcher_order5f(b, c, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -836,7 +871,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition F\n"); } } - if (!__order5g(b, A, c, A, c, s)) + if (!arkode_butcher_order5g(b, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -844,7 +879,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition G\n"); } } - if (!__order5h(b, A, A, c, c, s)) + if (!arkode_butcher_order5h(b, A, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -852,7 +887,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 5 condition H\n"); } } - if (!__order5i(b, A, A, A, c, s)) + if (!arkode_butcher_order5i(b, A, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -866,7 +901,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, if ((*p) == 5) { alltrue = SUNTRUE; - if (!__order6a(b, c, c, c, c, c, s)) + if (!arkode_butcher_order6a(b, c, c, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -874,7 +909,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition A\n"); } } - if (!__order6b(b, c, c, c, A, c, s)) + if (!arkode_butcher_order6b(b, c, c, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -882,7 +917,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition B\n"); } } - if (!__order6c(b, c, A, c, A, c, s)) + if (!arkode_butcher_order6c(b, c, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -890,7 +925,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition C\n"); } } - if (!__order6d(b, c, c, A, c, c, s)) + if (!arkode_butcher_order6d(b, c, c, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -898,7 +933,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition D\n"); } } - if (!__order6e(b, c, c, A, A, c, s)) + if (!arkode_butcher_order6e(b, c, c, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -906,7 +941,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition E\n"); } } - if (!__order6f(b, A, A, c, A, c, s)) + if (!arkode_butcher_order6f(b, A, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -914,7 +949,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition F\n"); } } - if (!__order6g(b, c, A, c, c, c, s)) + if (!arkode_butcher_order6g(b, c, A, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -922,7 +957,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition G\n"); } } - if (!__order6h(b, c, A, c, A, c, s)) + if (!arkode_butcher_order6h(b, c, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -930,7 +965,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition H\n"); } } - if (!__order6i(b, c, A, A, c, c, s)) + if (!arkode_butcher_order6i(b, c, A, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -938,7 +973,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition I\n"); } } - if (!__order6j(b, c, A, A, A, c, s)) + if (!arkode_butcher_order6j(b, c, A, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -946,7 +981,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition J\n"); } } - if (!__order6k(b, A, c, c, c, c, s)) + if (!arkode_butcher_order6k(b, A, c, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -954,7 +989,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition K\n"); } } - if (!__order6l(b, A, c, c, A, c, s)) + if (!arkode_butcher_order6l(b, A, c, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -962,7 +997,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition L\n"); } } - if (!__order6m(b, A, A, c, A, c, s)) + if (!arkode_butcher_order6m(b, A, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -970,7 +1005,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition M\n"); } } - if (!__order6n(b, A, c, A, c, c, s)) + if (!arkode_butcher_order6n(b, A, c, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -978,7 +1013,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition N\n"); } } - if (!__order6o(b, A, c, A, A, c, s)) + if (!arkode_butcher_order6o(b, A, c, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -986,7 +1021,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition O\n"); } } - if (!__order6p(b, A, A, c, c, c, s)) + if (!arkode_butcher_order6p(b, A, A, c, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -994,7 +1029,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition P\n"); } } - if (!__order6q(b, A, A, c, A, c, s)) + if (!arkode_butcher_order6q(b, A, A, c, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -1002,7 +1037,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition Q\n"); } } - if (!__order6r(b, A, A, A, c, c, s)) + if (!arkode_butcher_order6r(b, A, A, A, c, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -1010,7 +1045,7 @@ int ARKodeButcherTable_CheckOrder(ARKodeButcherTable B, int* q, int* p, fprintf(outfile, " embedding fails order 6 condition R\n"); } } - if (!__order6s(b, A, A, A, A, c, s)) + if (!arkode_butcher_order6s(b, A, A, A, A, c, s)) { alltrue = SUNFALSE; if (outfile) @@ -1128,7 +1163,10 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B if (outfile) { fprintf(outfile, "ARKodeButcherTable_CheckARKOrder:\n"); } /* row sum conditions */ - if (__rowsum(A[0], c[0], s) && __rowsum(A[1], c[1], s)) { (*q) = 0; } + if (arkode_butcher_rowsum(A[0], c[0], s) && arkode_butcher_rowsum(A[1], c[1], s)) + { + (*q) = 0; + } else { (*q) = -1; @@ -1137,7 +1175,10 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B /* order 1 conditions */ if ((*q) == 0) { - if (__order1(b[0], s) && __order1(b[1], s)) { (*q) = 1; } + if (arkode_butcher_order1(b[0], s) && arkode_butcher_order1(b[1], s)) + { + (*q) = 1; + } else { if (outfile) { fprintf(outfile, " method fails order 1 conditions\n"); } @@ -1151,7 +1192,7 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (j = 0; j < 2; j++) { - alltrue = (alltrue && __order2(b[i], c[j], s)); + alltrue = (alltrue && arkode_butcher_order2(b[i], c[j], s)); } } if (alltrue) { (*q) = 2; } @@ -1170,7 +1211,7 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (k = 0; k < 2; k++) { - alltrue = (alltrue && __order3a(b[i], c[j], c[k], s)); + alltrue = (alltrue && arkode_butcher_order3a(b[i], c[j], c[k], s)); } } } @@ -1184,7 +1225,7 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (k = 0; k < 2; k++) { - alltrue = (alltrue && __order3b(b[i], A[j], c[k], s)); + alltrue = (alltrue && arkode_butcher_order3b(b[i], A[j], c[k], s)); } } } @@ -1206,7 +1247,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4a(b[i], c[j], c[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4a(b[i], c[j], c[k], c[l], s)); } } } @@ -1223,7 +1265,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4b(b[i], c[j], A[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4b(b[i], c[j], A[k], c[l], s)); } } } @@ -1240,7 +1283,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4c(b[i], A[j], c[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4c(b[i], A[j], c[k], c[l], s)); } } } @@ -1257,7 +1301,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4d(b[i], A[j], A[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4d(b[i], A[j], A[k], c[l], s)); } } } @@ -1282,7 +1327,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5a(b[i], c[j], c[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5a(b[i], c[j], c[k], + c[l], c[m], s)); } } } @@ -1302,7 +1348,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5b(b[i], c[j], c[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5b(b[i], c[j], c[k], + A[l], c[m], s)); } } } @@ -1322,7 +1369,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5c(b[i], A[j], c[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5c(b[i], A[j], c[k], + A[l], c[m], s)); } } } @@ -1342,7 +1390,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5d(b[i], c[j], A[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5d(b[i], c[j], A[k], + c[l], c[m], s)); } } } @@ -1362,7 +1411,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5e(b[i], A[j], c[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5e(b[i], A[j], c[k], + c[l], c[m], s)); } } } @@ -1382,7 +1432,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5f(b[i], c[j], A[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5f(b[i], c[j], A[k], + A[l], c[m], s)); } } } @@ -1402,7 +1453,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5g(b[i], A[j], c[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5g(b[i], A[j], c[k], + A[l], c[m], s)); } } } @@ -1422,7 +1474,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5h(b[i], A[j], A[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5h(b[i], A[j], A[k], + c[l], c[m], s)); } } } @@ -1442,7 +1495,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5i(b[i], A[j], A[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5i(b[i], A[j], A[k], + A[l], c[m], s)); } } } @@ -1470,8 +1524,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6a(b[i], c[j], c[k], c[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6a(b[i], c[j], c[k], + c[l], c[m], c[n], s)); } } } @@ -1494,8 +1548,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6b(b[i], c[j], c[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6b(b[i], c[j], c[k], + c[l], A[m], c[n], s)); } } } @@ -1518,8 +1572,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6c(b[i], c[j], A[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6c(b[i], c[j], A[k], + c[l], A[m], c[n], s)); } } } @@ -1542,8 +1596,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6d(b[i], c[j], c[k], A[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6d(b[i], c[j], c[k], + A[l], c[m], c[n], s)); } } } @@ -1566,8 +1620,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6e(b[i], c[j], c[k], A[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6e(b[i], c[j], c[k], + A[l], A[m], c[n], s)); } } } @@ -1590,8 +1644,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6f(b[i], A[j], A[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6f(b[i], A[j], A[k], + c[l], A[m], c[n], s)); } } } @@ -1614,8 +1668,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6g(b[i], c[j], A[k], c[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6g(b[i], c[j], A[k], + c[l], c[m], c[n], s)); } } } @@ -1638,8 +1692,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6h(b[i], c[j], A[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6h(b[i], c[j], A[k], + c[l], A[m], c[n], s)); } } } @@ -1662,8 +1716,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6i(b[i], c[j], A[k], A[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6i(b[i], c[j], A[k], + A[l], c[m], c[n], s)); } } } @@ -1686,8 +1740,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6j(b[i], c[j], A[k], A[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6j(b[i], c[j], A[k], + A[l], A[m], c[n], s)); } } } @@ -1710,8 +1764,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6k(b[i], A[j], c[k], c[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6k(b[i], A[j], c[k], + c[l], c[m], c[n], s)); } } } @@ -1734,8 +1788,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6l(b[i], A[j], c[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6l(b[i], A[j], c[k], + c[l], A[m], c[n], s)); } } } @@ -1758,8 +1812,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6m(b[i], A[j], A[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6m(b[i], A[j], A[k], + c[l], A[m], c[n], s)); } } } @@ -1782,8 +1836,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6n(b[i], A[j], c[k], A[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6n(b[i], A[j], c[k], + A[l], c[m], c[n], s)); } } } @@ -1806,8 +1860,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6o(b[i], A[j], c[k], A[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6o(b[i], A[j], c[k], + A[l], A[m], c[n], s)); } } } @@ -1830,8 +1884,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6p(b[i], A[j], A[k], c[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6p(b[i], A[j], A[k], + c[l], c[m], c[n], s)); } } } @@ -1854,8 +1908,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6q(b[i], A[j], A[k], c[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6q(b[i], A[j], A[k], + c[l], A[m], c[n], s)); } } } @@ -1878,8 +1932,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6r(b[i], A[j], A[k], A[l], c[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6r(b[i], A[j], A[k], + A[l], c[m], c[n], s)); } } } @@ -1902,8 +1956,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (n = 0; n < 2; n++) { - alltrue = (alltrue && - __order6s(b[i], A[j], A[k], A[l], A[m], c[n], s)); + alltrue = (alltrue && arkode_butcher_order6s(b[i], A[j], A[k], + A[l], A[m], c[n], s)); } } } @@ -1923,7 +1977,11 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B if (outfile) { fprintf(outfile, "\n"); } /* row sum conditions */ - if (__rowsum(A[0], c[0], s) && __rowsum(A[1], c[1], s)) { (*p) = 0; } + if (arkode_butcher_rowsum(A[0], c[0], s) && + arkode_butcher_rowsum(A[1], c[1], s)) + { + (*p) = 0; + } else { (*p) = -1; @@ -1935,7 +1993,10 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B /* order 1 conditions */ if ((*p) == 0) { - if (__order1(d[0], s) && __order1(d[1], s)) { (*p) = 1; } + if (arkode_butcher_order1(d[0], s) && arkode_butcher_order1(d[1], s)) + { + (*p) = 1; + } else { if (outfile) @@ -1952,7 +2013,7 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (j = 0; j < 2; j++) { - alltrue = (alltrue && __order2(d[i], c[j], s)); + alltrue = (alltrue && arkode_butcher_order2(d[i], c[j], s)); } } if (alltrue) { (*p) = 2; } @@ -1974,7 +2035,7 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (k = 0; k < 2; k++) { - alltrue = (alltrue && __order3a(d[i], c[j], c[k], s)); + alltrue = (alltrue && arkode_butcher_order3a(d[i], c[j], c[k], s)); } } } @@ -1988,7 +2049,7 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (k = 0; k < 2; k++) { - alltrue = (alltrue && __order3b(d[i], A[j], c[k], s)); + alltrue = (alltrue && arkode_butcher_order3b(d[i], A[j], c[k], s)); } } } @@ -2010,7 +2071,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4a(d[i], c[j], c[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4a(d[i], c[j], c[k], c[l], s)); } } } @@ -2027,7 +2089,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4b(d[i], c[j], A[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4b(d[i], c[j], A[k], c[l], s)); } } } @@ -2044,7 +2107,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4c(d[i], A[j], c[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4c(d[i], A[j], c[k], c[l], s)); } } } @@ -2061,7 +2125,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (l = 0; l < 2; l++) { - alltrue = (alltrue && __order4d(d[i], A[j], A[k], c[l], s)); + alltrue = (alltrue && + arkode_butcher_order4d(d[i], A[j], A[k], c[l], s)); } } } @@ -2086,7 +2151,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5a(d[i], c[j], c[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5a(d[i], c[j], c[k], + c[l], c[m], s)); } } } @@ -2106,7 +2172,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5b(d[i], c[j], c[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5b(d[i], c[j], c[k], + A[l], c[m], s)); } } } @@ -2126,7 +2193,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5c(d[i], A[j], c[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5c(d[i], A[j], c[k], + A[l], c[m], s)); } } } @@ -2146,7 +2214,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5d(d[i], c[j], A[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5d(d[i], c[j], A[k], + c[l], c[m], s)); } } } @@ -2166,7 +2235,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5e(d[i], A[j], c[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5e(d[i], A[j], c[k], + c[l], c[m], s)); } } } @@ -2186,7 +2256,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5f(d[i], c[j], A[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5f(d[i], c[j], A[k], + A[l], c[m], s)); } } } @@ -2206,7 +2277,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5g(d[i], A[j], c[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5g(d[i], A[j], c[k], + A[l], c[m], s)); } } } @@ -2226,7 +2298,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5h(d[i], A[j], A[k], c[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5h(d[i], A[j], A[k], + c[l], c[m], s)); } } } @@ -2246,7 +2319,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B { for (m = 0; m < 2; m++) { - alltrue = (alltrue && __order5i(d[i], A[j], A[k], A[l], c[m], s)); + alltrue = (alltrue && arkode_butcher_order5i(d[i], A[j], A[k], + A[l], c[m], s)); } } } @@ -2275,7 +2349,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6a(d[i], c[j], c[k], c[l], c[m], c[n], s)); + arkode_butcher_order6a(d[i], c[j], c[k], c[l], + c[m], c[n], s)); } } } @@ -2299,7 +2374,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6b(d[i], c[j], c[k], c[l], A[m], c[n], s)); + arkode_butcher_order6b(d[i], c[j], c[k], c[l], + A[m], c[n], s)); } } } @@ -2323,7 +2399,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6c(d[i], c[j], A[k], c[l], A[m], c[n], s)); + arkode_butcher_order6c(d[i], c[j], A[k], c[l], + A[m], c[n], s)); } } } @@ -2347,7 +2424,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6d(d[i], c[j], c[k], A[l], c[m], c[n], s)); + arkode_butcher_order6d(d[i], c[j], c[k], A[l], + c[m], c[n], s)); } } } @@ -2371,7 +2449,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6e(d[i], c[j], c[k], A[l], A[m], c[n], s)); + arkode_butcher_order6e(d[i], c[j], c[k], A[l], + A[m], c[n], s)); } } } @@ -2395,7 +2474,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6f(d[i], A[j], A[k], c[l], A[m], c[n], s)); + arkode_butcher_order6f(d[i], A[j], A[k], c[l], + A[m], c[n], s)); } } } @@ -2419,7 +2499,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6g(d[i], c[j], A[k], c[l], c[m], c[n], s)); + arkode_butcher_order6g(d[i], c[j], A[k], c[l], + c[m], c[n], s)); } } } @@ -2443,7 +2524,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6h(d[i], c[j], A[k], c[l], A[m], c[n], s)); + arkode_butcher_order6h(d[i], c[j], A[k], c[l], + A[m], c[n], s)); } } } @@ -2467,7 +2549,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6i(d[i], c[j], A[k], A[l], c[m], c[n], s)); + arkode_butcher_order6i(d[i], c[j], A[k], A[l], + c[m], c[n], s)); } } } @@ -2491,7 +2574,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6j(d[i], c[j], A[k], A[l], A[m], c[n], s)); + arkode_butcher_order6j(d[i], c[j], A[k], A[l], + A[m], c[n], s)); } } } @@ -2515,7 +2599,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6k(d[i], A[j], c[k], c[l], c[m], c[n], s)); + arkode_butcher_order6k(d[i], A[j], c[k], c[l], + c[m], c[n], s)); } } } @@ -2539,7 +2624,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6l(d[i], A[j], c[k], c[l], A[m], c[n], s)); + arkode_butcher_order6l(d[i], A[j], c[k], c[l], + A[m], c[n], s)); } } } @@ -2563,7 +2649,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6m(d[i], A[j], A[k], c[l], A[m], c[n], s)); + arkode_butcher_order6m(d[i], A[j], A[k], c[l], + A[m], c[n], s)); } } } @@ -2587,7 +2674,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6n(d[i], A[j], c[k], A[l], c[m], c[n], s)); + arkode_butcher_order6n(d[i], A[j], c[k], A[l], + c[m], c[n], s)); } } } @@ -2611,7 +2699,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6o(d[i], A[j], c[k], A[l], A[m], c[n], s)); + arkode_butcher_order6o(d[i], A[j], c[k], A[l], + A[m], c[n], s)); } } } @@ -2635,7 +2724,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6p(d[i], A[j], A[k], c[l], c[m], c[n], s)); + arkode_butcher_order6p(d[i], A[j], A[k], c[l], + c[m], c[n], s)); } } } @@ -2659,7 +2749,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6q(d[i], A[j], A[k], c[l], A[m], c[n], s)); + arkode_butcher_order6q(d[i], A[j], A[k], c[l], + A[m], c[n], s)); } } } @@ -2683,7 +2774,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6r(d[i], A[j], A[k], A[l], c[m], c[n], s)); + arkode_butcher_order6r(d[i], A[j], A[k], A[l], + c[m], c[n], s)); } } } @@ -2707,7 +2799,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B for (n = 0; n < 2; n++) { alltrue = (alltrue && - __order6s(d[i], A[j], A[k], A[l], A[m], c[n], s)); + arkode_butcher_order6s(d[i], A[j], A[k], A[l], + A[m], c[n], s)); } } } @@ -2754,7 +2847,8 @@ int ARKodeButcherTable_CheckARKOrder(ARKodeButcherTable B1, ARKodeButcherTable B Here A is (s x s), x and b are (s x 1). Returns 0 on success, nonzero on failure. ---------------------------------------------------------------*/ -static int __mv(sunrealtype** A, sunrealtype* x, int s, sunrealtype* b) +static int arkode_butcher_mv(sunrealtype** A, sunrealtype* x, int s, + sunrealtype* b) { int i, j; if ((A == NULL) || (x == NULL) || (b == NULL) || (s < 1)) { return (1); } @@ -2772,7 +2866,7 @@ static int __mv(sunrealtype** A, sunrealtype* x, int s, sunrealtype* b) Here all vectors are (s x 1). Returns 0 on success, nonzero on failure. ---------------------------------------------------------------*/ -static int __vv(sunrealtype* x, sunrealtype* y, int s, sunrealtype* z) +static int arkode_butcher_vv(sunrealtype* x, sunrealtype* y, int s, sunrealtype* z) { int i; if ((x == NULL) || (y == NULL) || (z == NULL) || (s < 1)) { return (1); } @@ -2786,7 +2880,7 @@ static int __vv(sunrealtype* x, sunrealtype* y, int s, sunrealtype* z) Here all vectors are (s x 1). Returns 0 on success, nonzero on failure. ---------------------------------------------------------------*/ -static int __vp(sunrealtype* x, int l, int s, sunrealtype* z) +static int arkode_butcher_vp(sunrealtype* x, int l, int s, sunrealtype* z) { int i; if ((x == NULL) || (z == NULL) || (s < 1) || (s < 0)) { return (1); } @@ -2800,7 +2894,8 @@ static int __vp(sunrealtype* x, int l, int s, sunrealtype* z) Here x and y are (s x 1), and d is scalar. Returns 0 on success, nonzero on failure. ---------------------------------------------------------------*/ -static int __dot(sunrealtype* x, sunrealtype* y, int s, sunrealtype* d) +static int arkode_butcher_dot(sunrealtype* x, sunrealtype* y, int s, + sunrealtype* d) { int i; if ((x == NULL) || (y == NULL) || (d == NULL) || (s < 1)) { return (1); } @@ -2812,17 +2907,17 @@ static int __dot(sunrealtype* x, sunrealtype* y, int s, sunrealtype* d) /*--------------------------------------------------------------- Utility routines to check specific order conditions. Each returns SUNTRUE on success, SUNFALSE on failure. - Order 0: __rowsum - Order 1: __order1 - Order 2: __order2 - Order 3: __order3a and __order3b - Order 4: __order4a through __order4d - Order 5: __order5a through __order5i - Order 6: __order6a through __order6s + Order 0: arkode_butcher_rowsum + Order 1: arkode_butcher_order1 + Order 2: arkode_butcher_order2 + Order 3: arkode_butcher_order3a and arkode_butcher_order3b + Order 4: arkode_butcher_order4a through arkode_butcher_order4d + Order 5: arkode_butcher_order5a through arkode_butcher_order5i + Order 6: arkode_butcher_order6a through arkode_butcher_order6s ---------------------------------------------------------------*/ /* c(i) = sum(A(i,:)) */ -static sunbooleantype __rowsum(sunrealtype** A, sunrealtype* c, int s) +static sunbooleantype arkode_butcher_rowsum(sunrealtype** A, sunrealtype* c, int s) { int i, j; sunrealtype rsum; @@ -2836,7 +2931,7 @@ static sunbooleantype __rowsum(sunrealtype** A, sunrealtype* c, int s) } /* b'*e = 1 */ -static sunbooleantype __order1(sunrealtype* b, int s) +static sunbooleantype arkode_butcher_order1(sunrealtype* b, int s) { int i; sunrealtype err = SUN_RCONST(1.0); @@ -2845,117 +2940,120 @@ static sunbooleantype __order1(sunrealtype* b, int s) } /* b'*c = 1/2 */ -static sunbooleantype __order2(sunrealtype* b, sunrealtype* c, int s) +static sunbooleantype arkode_butcher_order2(sunrealtype* b, sunrealtype* c, int s) { sunrealtype bc; - if (__dot(b, c, s, &bc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, c, s, &bc)) { return (SUNFALSE); } return (SUNRabs(bc - SUN_RCONST(0.5)) > TOL) ? SUNFALSE : SUNTRUE; } /* b'*(c1.*c2) = 1/3 */ -static sunbooleantype __order3a(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order3a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, int s) { sunrealtype bcc; sunrealtype* tmp = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp)) + if (arkode_butcher_vv(c1, c2, s, tmp)) { free(tmp); return (SUNFALSE); } - if (__dot(b, tmp, s, &bcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp, s, &bcc)) { return (SUNFALSE); } free(tmp); return (SUNRabs(bcc - SUN_RCONST(1.0) / SUN_RCONST(3.0)) > TOL) ? SUNFALSE : SUNTRUE; } /* b'*(A*c) = 1/6 */ -static sunbooleantype __order3b(sunrealtype* b, sunrealtype** A, sunrealtype* c, - int s) +static sunbooleantype arkode_butcher_order3b(sunrealtype* b, sunrealtype** A, + sunrealtype* c, int s) { sunrealtype bAc; sunrealtype* tmp = calloc(s, sizeof(sunrealtype)); - if (__mv(A, c, s, tmp)) + if (arkode_butcher_mv(A, c, s, tmp)) { free(tmp); return (SUNFALSE); } - if (__dot(b, tmp, s, &bAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp, s, &bAc)) { return (SUNFALSE); } free(tmp); return (SUNRabs(bAc - SUN_RCONST(1.0) / SUN_RCONST(6.0)) > TOL) ? SUNFALSE : SUNTRUE; } /* b'*(c1.*c2.*c3) = 1/4 */ -static sunbooleantype __order4a(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order4a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + int s) { sunrealtype bccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp1, s, tmp2)) + if (arkode_butcher_vv(c3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bccc - SUN_RCONST(0.25)) > TOL) ? SUNFALSE : SUNTRUE; } /* (b.*c1)'*(A*c2) = 1/8 */ -static sunbooleantype __order4b(sunrealtype* b, sunrealtype* c1, - sunrealtype** A, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order4b(sunrealtype* b, sunrealtype* c1, + sunrealtype** A, sunrealtype* c2, + int s) { sunrealtype bcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(b, c1, s, tmp1)) + if (arkode_butcher_vv(b, c1, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, c2, s, tmp2)) + if (arkode_butcher_mv(A, c2, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(tmp1, tmp2, s, &bcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp1, tmp2, s, &bcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAc - SUN_RCONST(0.125)) > TOL) ? SUNFALSE : SUNTRUE; } /* b'*A*(c1.*c2) = 1/12 */ -static sunbooleantype __order4c(sunrealtype* b, sunrealtype** A, - sunrealtype* c1, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order4c(sunrealtype* b, sunrealtype** A, + sunrealtype* c1, sunrealtype* c2, + int s) { sunrealtype bAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, tmp1, s, tmp2)) + if (arkode_butcher_mv(A, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAcc - SUN_RCONST(1.0) / SUN_RCONST(12.0)) > TOL) ? SUNFALSE @@ -2963,25 +3061,26 @@ static sunbooleantype __order4c(sunrealtype* b, sunrealtype** A, } /* b'*A1*A2*c = 1/24 */ -static sunbooleantype __order4d(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c, int s) +static sunbooleantype arkode_butcher_order4d(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c, + int s) { sunrealtype bAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c, s, tmp1)) + if (arkode_butcher_mv(A2, c, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAc - SUN_RCONST(1.0) / SUN_RCONST(24.0)) > TOL) ? SUNFALSE @@ -2989,97 +3088,100 @@ static sunbooleantype __order4d(sunrealtype* b, sunrealtype** A1, } /* b'*(c1.*c2.*c3.*c4) = 1/5 */ -static sunbooleantype __order5a(sunrealtype* b, sunrealtype* c1, sunrealtype* c2, - sunrealtype* c3, sunrealtype* c4, int s) +static sunbooleantype arkode_butcher_order5a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + sunrealtype* c4, int s) { sunrealtype bcccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp1, s, tmp2)) + if (arkode_butcher_vv(c3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c4, tmp2, s, tmp1)) + if (arkode_butcher_vv(c4, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bcccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bcccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcccc - SUN_RCONST(0.2)) > TOL) ? SUNFALSE : SUNTRUE; } /* (b.*c1.*c2)'*(A*c3) = 1/10 */ -static sunbooleantype __order5b(sunrealtype* b, sunrealtype* c1, sunrealtype* c2, - sunrealtype** A, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order5b(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype** A, + sunrealtype* c3, int s) { sunrealtype bccAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(b, tmp1, s, tmp2)) + if (arkode_butcher_vv(b, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, c3, s, tmp1)) + if (arkode_butcher_mv(A, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(tmp1, tmp2, s, &bccAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp1, tmp2, s, &bccAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bccAc - SUN_RCONST(0.1)) > TOL) ? SUNFALSE : SUNTRUE; } /* b'*((A1*c1).*(A2*c2)) = 1/20 */ -static sunbooleantype __order5c(sunrealtype* b, sunrealtype** A1, sunrealtype* c1, - sunrealtype** A2, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order5c(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype* c2, int s) { sunrealtype bAcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp3 = calloc(s, sizeof(sunrealtype)); - if (__mv(A1, c1, s, tmp1)) + if (arkode_butcher_mv(A1, c1, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A2, c2, s, tmp2)) + if (arkode_butcher_mv(A2, c2, s, tmp2)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(tmp1, tmp2, s, tmp3)) + if (arkode_butcher_vv(tmp1, tmp2, s, tmp3)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__dot(b, tmp3, s, &bAcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp3, s, &bAcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); free(tmp3); @@ -3087,31 +3189,32 @@ static sunbooleantype __order5c(sunrealtype* b, sunrealtype** A1, sunrealtype* c } /* (b.*c1)'*A*(c2.*c3) = 1/15 */ -static sunbooleantype __order5d(sunrealtype* b, sunrealtype* c1, sunrealtype** A, - sunrealtype* c2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order5d(sunrealtype* b, sunrealtype* c1, + sunrealtype** A, sunrealtype* c2, + sunrealtype* c3, int s) { sunrealtype bcAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c2, c3, s, tmp1)) + if (arkode_butcher_vv(c2, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, tmp1, s, tmp2)) + if (arkode_butcher_mv(A, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(b, c1, s, tmp1)) + if (arkode_butcher_vv(b, c1, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(tmp1, tmp2, s, &bcAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp1, tmp2, s, &bcAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAcc - SUN_RCONST(1.0) / SUN_RCONST(15.0)) > TOL) ? SUNFALSE @@ -3119,62 +3222,64 @@ static sunbooleantype __order5d(sunrealtype* b, sunrealtype* c1, sunrealtype** A } /* b'*A*(c1.*c2.*c3) = 1/20 */ -static sunbooleantype __order5e(sunrealtype* b, sunrealtype** A, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order5e(sunrealtype* b, sunrealtype** A, + sunrealtype* c1, sunrealtype* c2, + sunrealtype* c3, int s) { sunrealtype bAccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp1, s, tmp2)) + if (arkode_butcher_vv(c3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, tmp2, s, tmp1)) + if (arkode_butcher_mv(A, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bAccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bAccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAccc - SUN_RCONST(0.05)) > TOL) ? SUNFALSE : SUNTRUE; } /* (b.*c1)'*A1*A2*c2 = 1/30 */ -static sunbooleantype __order5f(sunrealtype* b, sunrealtype* c1, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order5f(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype** A2, + sunrealtype* c2, int s) { sunrealtype bcAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c2, s, tmp1)) + if (arkode_butcher_mv(A2, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(b, c1, s, tmp1)) + if (arkode_butcher_vv(b, c1, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(tmp1, tmp2, s, &bcAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp1, tmp2, s, &bcAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAAc - SUN_RCONST(1.0) / SUN_RCONST(30.0)) > TOL) ? SUNFALSE @@ -3182,31 +3287,32 @@ static sunbooleantype __order5f(sunrealtype* b, sunrealtype* c1, sunrealtype** A } /* b'*A1*(c1.*(A2*c2)) = 1/40 */ -static sunbooleantype __order5g(sunrealtype* b, sunrealtype** A1, sunrealtype* c1, - sunrealtype** A2, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order5g(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype* c2, int s) { sunrealtype bAcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c2, s, tmp1)) + if (arkode_butcher_mv(A2, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp1, s, tmp2)) + if (arkode_butcher_vv(c1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp2, s, tmp1)) + if (arkode_butcher_mv(A1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bAcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bAcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAcAc - SUN_RCONST(1.0) / SUN_RCONST(40.0)) > TOL) ? SUNFALSE @@ -3214,32 +3320,32 @@ static sunbooleantype __order5g(sunrealtype* b, sunrealtype** A1, sunrealtype* c } /* b'*A1*A2*(c1.*c2) = 1/60 */ -static sunbooleantype __order5h(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order5h(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype* c2, int s) { sunrealtype bAAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp2, s, tmp1)) + if (arkode_butcher_mv(A1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bAAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bAAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAcc - SUN_RCONST(1.0) / SUN_RCONST(60.0)) > TOL) ? SUNFALSE @@ -3247,32 +3353,32 @@ static sunbooleantype __order5h(sunrealtype* b, sunrealtype** A1, } /* b'*A1*A2*A3*c = 1/120 */ -static sunbooleantype __order5i(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype** A3, - sunrealtype* c, int s) +static sunbooleantype arkode_butcher_order5i(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype** A3, + sunrealtype* c, int s) { sunrealtype bAAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A3, c, s, tmp1)) + if (arkode_butcher_mv(A3, c, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp2, s, tmp1)) + if (arkode_butcher_mv(A1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bAAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bAAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAAc - SUN_RCONST(1.0) / SUN_RCONST(120.0)) > TOL) ? SUNFALSE @@ -3280,38 +3386,39 @@ static sunbooleantype __order5i(sunrealtype* b, sunrealtype** A1, } /* b'*(c1.*c2.*c3.*c4.*c5) = 1/6 */ -static sunbooleantype __order6a(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, - sunrealtype* c4, sunrealtype* c5, int s) +static sunbooleantype arkode_butcher_order6a(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + sunrealtype* c4, sunrealtype* c5, + int s) { sunrealtype bccccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp1, s, tmp2)) + if (arkode_butcher_vv(c3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c4, tmp2, s, tmp1)) + if (arkode_butcher_vv(c4, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c5, tmp1, s, tmp2)) + if (arkode_butcher_vv(c5, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bccccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bccccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bccccc - SUN_RCONST(1.0) / SUN_RCONST(6.0)) > TOL) ? SUNFALSE @@ -3319,38 +3426,39 @@ static sunbooleantype __order6a(sunrealtype* b, sunrealtype* c1, } /* (b.*c1.*c2.*c3)'*(A*c4) = 1/12 */ -static sunbooleantype __order6b(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, - sunrealtype** A, sunrealtype* c4, int s) +static sunbooleantype arkode_butcher_order6b(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + sunrealtype** A, sunrealtype* c4, + int s) { sunrealtype bcccAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(b, c1, s, tmp1)) + if (arkode_butcher_vv(b, c1, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c2, tmp1, s, tmp2)) + if (arkode_butcher_vv(c2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp2, s, tmp1)) + if (arkode_butcher_vv(c3, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, c4, s, tmp2)) + if (arkode_butcher_mv(A, c4, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(tmp1, tmp2, s, &bcccAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp1, tmp2, s, &bcccAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcccAc - SUN_RCONST(1.0) / SUN_RCONST(12.0)) > TOL) ? SUNFALSE @@ -3358,43 +3466,44 @@ static sunbooleantype __order6b(sunrealtype* b, sunrealtype* c1, } /* b'*(c1.*(A1*c2).*(A2*c3)) = 1/24 */ -static sunbooleantype __order6c(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype* c2, - sunrealtype** A2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6c(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype* c2, + sunrealtype** A2, sunrealtype* c3, + int s) { sunrealtype bcAc2; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp3 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c3, s, tmp1)) + if (arkode_butcher_mv(A2, c3, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A1, c2, s, tmp2)) + if (arkode_butcher_mv(A1, c2, s, tmp2)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(tmp1, tmp2, s, tmp3)) + if (arkode_butcher_vv(tmp1, tmp2, s, tmp3)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(c1, tmp3, s, tmp1)) + if (arkode_butcher_vv(c1, tmp3, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bcAc2)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bcAc2)) { return (SUNFALSE); } free(tmp1); free(tmp2); free(tmp3); @@ -3403,43 +3512,44 @@ static sunbooleantype __order6c(sunrealtype* b, sunrealtype* c1, } /* (b.*c1.*c2)'*A*(c3.*c4) = 1/18 */ -static sunbooleantype __order6d(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype** A, - sunrealtype* c3, sunrealtype* c4, int s) +static sunbooleantype arkode_butcher_order6d(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype** A, + sunrealtype* c3, sunrealtype* c4, + int s) { sunrealtype bccAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp3 = calloc(s, sizeof(sunrealtype)); - if (__vv(c3, c4, s, tmp1)) + if (arkode_butcher_vv(c3, c4, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A, tmp1, s, tmp2)) + if (arkode_butcher_mv(A, tmp1, s, tmp2)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(b, tmp1, s, tmp3)) + if (arkode_butcher_vv(b, tmp1, s, tmp3)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__dot(tmp2, tmp3, s, &bccAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp2, tmp3, s, &bccAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); free(tmp3); @@ -3448,43 +3558,44 @@ static sunbooleantype __order6d(sunrealtype* b, sunrealtype* c1, } /* (b.*(c1.*c2))'*A1*A2*c3 = 1/36 */ -static sunbooleantype __order6e(sunrealtype* b, sunrealtype* c1, - sunrealtype* c2, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6e(sunrealtype* b, sunrealtype* c1, + sunrealtype* c2, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c3, + int s) { sunrealtype bccAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp3 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(b, tmp1, s, tmp2)) + if (arkode_butcher_vv(b, tmp1, s, tmp2)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A2, c3, s, tmp1)) + if (arkode_butcher_mv(A2, c3, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp3)) + if (arkode_butcher_mv(A1, tmp1, s, tmp3)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__dot(tmp2, tmp3, s, &bccAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(tmp2, tmp3, s, &bccAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); free(tmp3); @@ -3493,43 +3604,44 @@ static sunbooleantype __order6e(sunrealtype* b, sunrealtype* c1, } /* b'*((A1*A2*c1).*(A3*c2)) = 1/72 */ -static sunbooleantype __order6f(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype** A3, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order6f(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype** A3, sunrealtype* c2, + int s) { sunrealtype bAAcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp3 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c1, s, tmp1)) + if (arkode_butcher_mv(A2, c1, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A3, c2, s, tmp1)) + if (arkode_butcher_mv(A3, c2, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(tmp1, tmp2, s, tmp3)) + if (arkode_butcher_vv(tmp1, tmp2, s, tmp3)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__dot(b, tmp3, s, &bAAcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp3, s, &bAAcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); free(tmp3); @@ -3538,38 +3650,39 @@ static sunbooleantype __order6f(sunrealtype* b, sunrealtype** A1, } /* b'*(c1.*(A*(c2.*c3.*c4))) = 1/24 */ -static sunbooleantype __order6g(sunrealtype* b, sunrealtype* c1, - sunrealtype** A, sunrealtype* c2, - sunrealtype* c3, sunrealtype* c4, int s) +static sunbooleantype arkode_butcher_order6g(sunrealtype* b, sunrealtype* c1, + sunrealtype** A, sunrealtype* c2, + sunrealtype* c3, sunrealtype* c4, + int s) { sunrealtype bcAccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c2, c3, s, tmp1)) + if (arkode_butcher_vv(c2, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c4, tmp1, s, tmp2)) + if (arkode_butcher_vv(c4, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, tmp2, s, tmp1)) + if (arkode_butcher_mv(A, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp1, s, tmp2)) + if (arkode_butcher_vv(c1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bcAccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bcAccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAccc - SUN_RCONST(1.0) / SUN_RCONST(24.0)) > TOL) ? SUNFALSE @@ -3577,38 +3690,39 @@ static sunbooleantype __order6g(sunrealtype* b, sunrealtype* c1, } /* b'*(c1.*(A1*(c2.*(A2*c3)))) = 1/48 */ -static sunbooleantype __order6h(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype* c2, - sunrealtype** A2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6h(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype* c2, + sunrealtype** A2, sunrealtype* c3, + int s) { sunrealtype bcAcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c3, s, tmp1)) + if (arkode_butcher_mv(A2, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c2, tmp1, s, tmp2)) + if (arkode_butcher_vv(c2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp2, s, tmp1)) + if (arkode_butcher_mv(A1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp1, s, tmp2)) + if (arkode_butcher_vv(c1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bcAcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bcAcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAcAc - SUN_RCONST(1.0) / SUN_RCONST(48.0)) > TOL) ? SUNFALSE @@ -3616,38 +3730,39 @@ static sunbooleantype __order6h(sunrealtype* b, sunrealtype* c1, } /* b'*(c1.*(A1*A2*(c2.*c3))) = 1/72 */ -static sunbooleantype __order6i(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype** A2, - sunrealtype* c2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6i(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype** A2, + sunrealtype* c2, sunrealtype* c3, + int s) { sunrealtype bcAAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c2, c3, s, tmp1)) + if (arkode_butcher_vv(c2, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp2, s, tmp1)) + if (arkode_butcher_mv(A1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp1, s, tmp2)) + if (arkode_butcher_vv(c1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bcAAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bcAAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAAcc - SUN_RCONST(1.0) / SUN_RCONST(72.0)) > TOL) ? SUNFALSE @@ -3655,38 +3770,39 @@ static sunbooleantype __order6i(sunrealtype* b, sunrealtype* c1, } /* b'*(c1.*(A1*A2*A3*c2)) = 1/144 */ -static sunbooleantype __order6j(sunrealtype* b, sunrealtype* c1, - sunrealtype** A1, sunrealtype** A2, - sunrealtype** A3, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order6j(sunrealtype* b, sunrealtype* c1, + sunrealtype** A1, sunrealtype** A2, + sunrealtype** A3, sunrealtype* c2, + int s) { sunrealtype bcAAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A3, c2, s, tmp1)) + if (arkode_butcher_mv(A3, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp2, s, tmp1)) + if (arkode_butcher_mv(A1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp1, s, tmp2)) + if (arkode_butcher_vv(c1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bcAAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bcAAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bcAAAc - SUN_RCONST(1.0) / SUN_RCONST(144.0)) > TOL) ? SUNFALSE @@ -3694,38 +3810,39 @@ static sunbooleantype __order6j(sunrealtype* b, sunrealtype* c1, } /* b'*A*(c1.*c2.*c3.*c4) = 1/30 */ -static sunbooleantype __order6k(sunrealtype* b, sunrealtype** A, - sunrealtype* c1, sunrealtype* c2, - sunrealtype* c3, sunrealtype* c4, int s) +static sunbooleantype arkode_butcher_order6k(sunrealtype* b, sunrealtype** A, + sunrealtype* c1, sunrealtype* c2, + sunrealtype* c3, sunrealtype* c4, + int s) { sunrealtype bAcccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp1, s, tmp2)) + if (arkode_butcher_vv(c3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c4, tmp2, s, tmp1)) + if (arkode_butcher_vv(c4, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A, tmp1, s, tmp2)) + if (arkode_butcher_mv(A, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAcccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAcccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAcccc - SUN_RCONST(1.0) / SUN_RCONST(30.0)) > TOL) ? SUNFALSE @@ -3733,38 +3850,39 @@ static sunbooleantype __order6k(sunrealtype* b, sunrealtype** A, } /* b'*A1*(c1.*c2.*(A2*c3)) = 1/60 */ -static sunbooleantype __order6l(sunrealtype* b, sunrealtype** A1, - sunrealtype* c1, sunrealtype* c2, - sunrealtype** A2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6l(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype* c2, + sunrealtype** A2, sunrealtype* c3, + int s) { sunrealtype bAccAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A2, c3, s, tmp1)) + if (arkode_butcher_mv(A2, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c2, tmp1, s, tmp2)) + if (arkode_butcher_vv(c2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp2, s, tmp1)) + if (arkode_butcher_vv(c1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAccAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAccAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAccAc - SUN_RCONST(1.0) / SUN_RCONST(60.0)) > TOL) ? SUNFALSE @@ -3772,42 +3890,43 @@ static sunbooleantype __order6l(sunrealtype* b, sunrealtype** A1, } /* b'*A1*((A2*c1).*(A3*c2)) = 1/120 */ -static sunbooleantype __order6m(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype** A3, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order6m(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype** A3, sunrealtype* c2, + int s) { sunrealtype bAAcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp3 = calloc(s, sizeof(sunrealtype)); - if (__mv(A3, c2, s, tmp1)) + if (arkode_butcher_mv(A3, c2, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__mv(A2, c1, s, tmp2)) + if (arkode_butcher_mv(A2, c1, s, tmp2)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__vv(tmp1, tmp2, s, tmp3)) + if (arkode_butcher_vv(tmp1, tmp2, s, tmp3)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp3, s, tmp1)) + if (arkode_butcher_mv(A1, tmp3, s, tmp1)) { free(tmp1); free(tmp2); free(tmp3); return (SUNFALSE); } - if (__dot(b, tmp1, s, &bAAcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp1, s, &bAAcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); free(tmp3); @@ -3816,38 +3935,39 @@ static sunbooleantype __order6m(sunrealtype* b, sunrealtype** A1, } /* b'*A1*(c1.*(A2*(c2.*c3))) = 1/90 */ -static sunbooleantype __order6n(sunrealtype* b, sunrealtype** A1, - sunrealtype* c1, sunrealtype** A2, - sunrealtype* c2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6n(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype* c2, sunrealtype* c3, + int s) { sunrealtype bAcAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c2, c3, s, tmp1)) + if (arkode_butcher_vv(c2, c3, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp2, s, tmp1)) + if (arkode_butcher_vv(c1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAcAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAcAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAcAcc - SUN_RCONST(1.0) / SUN_RCONST(90.0)) > TOL) ? SUNFALSE @@ -3855,38 +3975,39 @@ static sunbooleantype __order6n(sunrealtype* b, sunrealtype** A1, } /* b'*A1*(c1.*(A2*A3*c2)) = 1/180 */ -static sunbooleantype __order6o(sunrealtype* b, sunrealtype** A1, - sunrealtype* c1, sunrealtype** A2, - sunrealtype** A3, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order6o(sunrealtype* b, sunrealtype** A1, + sunrealtype* c1, sunrealtype** A2, + sunrealtype** A3, sunrealtype* c2, + int s) { sunrealtype bAcAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A3, c2, s, tmp1)) + if (arkode_butcher_mv(A3, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp2, s, tmp1)) + if (arkode_butcher_vv(c1, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAcAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAcAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAcAAc - SUN_RCONST(1.0) / SUN_RCONST(180.0)) > TOL) ? SUNFALSE @@ -3894,38 +4015,39 @@ static sunbooleantype __order6o(sunrealtype* b, sunrealtype** A1, } /* b'*A1*A2*(c1.*c2.*c3) = 1/120 */ -static sunbooleantype __order6p(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype* c2, sunrealtype* c3, int s) +static sunbooleantype arkode_butcher_order6p(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype* c2, sunrealtype* c3, + int s) { sunrealtype bAAccc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c3, tmp1, s, tmp2)) + if (arkode_butcher_vv(c3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp2, s, tmp1)) + if (arkode_butcher_mv(A2, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAAccc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAAccc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAccc - SUN_RCONST(1.0) / SUN_RCONST(120.0)) > TOL) ? SUNFALSE @@ -3933,38 +4055,39 @@ static sunbooleantype __order6p(sunrealtype* b, sunrealtype** A1, } /* b'*A1*A2*(c1.*(A3*c2)) = 1/240 */ -static sunbooleantype __order6q(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype* c1, - sunrealtype** A3, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order6q(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype* c1, + sunrealtype** A3, sunrealtype* c2, + int s) { sunrealtype bAAcAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A3, c2, s, tmp1)) + if (arkode_butcher_mv(A3, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__vv(c1, tmp1, s, tmp2)) + if (arkode_butcher_vv(c1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp2, s, tmp1)) + if (arkode_butcher_mv(A2, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAAcAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAAcAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAcAc - SUN_RCONST(1.0) / SUN_RCONST(240.0)) > TOL) ? SUNFALSE @@ -3972,38 +4095,39 @@ static sunbooleantype __order6q(sunrealtype* b, sunrealtype** A1, } /* b'*A1*A2*A3*(c1.*c2) = 1/360 */ -static sunbooleantype __order6r(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype** A3, - sunrealtype* c1, sunrealtype* c2, int s) +static sunbooleantype arkode_butcher_order6r(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype** A3, + sunrealtype* c1, sunrealtype* c2, + int s) { sunrealtype bAAAcc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__vv(c1, c2, s, tmp1)) + if (arkode_butcher_vv(c1, c2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A3, tmp1, s, tmp2)) + if (arkode_butcher_mv(A3, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp2, s, tmp1)) + if (arkode_butcher_mv(A2, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAAAcc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAAAcc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAAcc - SUN_RCONST(1.0) / SUN_RCONST(360.0)) > TOL) ? SUNFALSE @@ -4011,38 +4135,39 @@ static sunbooleantype __order6r(sunrealtype* b, sunrealtype** A1, } /* b'*A1*A2*A3*A4*c = 1/720 */ -static sunbooleantype __order6s(sunrealtype* b, sunrealtype** A1, - sunrealtype** A2, sunrealtype** A3, - sunrealtype** A4, sunrealtype* c, int s) +static sunbooleantype arkode_butcher_order6s(sunrealtype* b, sunrealtype** A1, + sunrealtype** A2, sunrealtype** A3, + sunrealtype** A4, sunrealtype* c, + int s) { sunrealtype bAAAAc; sunrealtype* tmp1 = calloc(s, sizeof(sunrealtype)); sunrealtype* tmp2 = calloc(s, sizeof(sunrealtype)); - if (__mv(A4, c, s, tmp1)) + if (arkode_butcher_mv(A4, c, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp1, s, tmp2)) + if (arkode_butcher_mv(A2, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A2, tmp2, s, tmp1)) + if (arkode_butcher_mv(A2, tmp2, s, tmp1)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__mv(A1, tmp1, s, tmp2)) + if (arkode_butcher_mv(A1, tmp1, s, tmp2)) { free(tmp1); free(tmp2); return (SUNFALSE); } - if (__dot(b, tmp2, s, &bAAAAc)) { return (SUNFALSE); } + if (arkode_butcher_dot(b, tmp2, s, &bAAAAc)) { return (SUNFALSE); } free(tmp1); free(tmp2); return (SUNRabs(bAAAAc - SUN_RCONST(1.0) / SUN_RCONST(720.0)) > TOL) ? SUNFALSE @@ -4065,12 +4190,12 @@ static int __ButcherSimplifyingAssumptions(sunrealtype** A, sunrealtype* b, P = 0; for (i = 1; i < 1000; i++) { - if (__vp(c, i - 1, s, tmp)) + if (arkode_butcher_vp(c, i - 1, s, tmp)) { free(tmp); return (0); } - if (__dot(b, tmp, s, &LHS)) + if (arkode_butcher_dot(b, tmp, s, &LHS)) { free(tmp); return (0); @@ -4087,12 +4212,12 @@ static int __ButcherSimplifyingAssumptions(sunrealtype** A, sunrealtype* b, alltrue = SUNTRUE; for (i = 0; i < s; i++) { - if (__vp(c, k - 1, s, tmp)) + if (arkode_butcher_vp(c, k - 1, s, tmp)) { free(tmp); return (0); } - if (__dot(A[i], tmp, s, &LHS)) + if (arkode_butcher_dot(A[i], tmp, s, &LHS)) { free(tmp); return (0); diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 1974add380..5948a222b4 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -27,7 +27,7 @@ #include "arkode_interp_impl.h" /*=============================================================== - ERKStep Exported functions -- Required + Exported functions ===============================================================*/ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) @@ -85,24 +85,35 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_ARKMEM_FAIL); - ERKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } memset(step_mem, 0, sizeof(struct ARKodeERKStepMemRec)); /* Attach step_mem structure and function pointers to ark_mem */ - ark_mem->step_init = erkStep_Init; - ark_mem->step_fullrhs = erkStep_FullRHS; - ark_mem->step = erkStep_TakeStep; - ark_mem->step_mem = (void*)step_mem; - - /* Set default values for ERKStep optional inputs */ - retval = ERKStepSetDefaults((void*)ark_mem); + ark_mem->step_init = erkStep_Init; + ark_mem->step_fullrhs = erkStep_FullRHS; + ark_mem->step = erkStep_TakeStep; + ark_mem->step_printallstats = erkStep_PrintAllStats; + ark_mem->step_writeparameters = erkStep_WriteParameters; + ark_mem->step_resize = erkStep_Resize; + ark_mem->step_free = erkStep_Free; + ark_mem->step_printmem = erkStep_PrintMem; + ark_mem->step_setdefaults = erkStep_SetDefaults; + ark_mem->step_setrelaxfn = erkStep_SetRelaxFn; + ark_mem->step_setorder = erkStep_SetOrder; + ark_mem->step_getestlocalerrors = erkStep_GetEstLocalErrors; + ark_mem->step_supports_adaptive = SUNTRUE; + ark_mem->step_supports_relaxation = SUNTRUE; + ark_mem->step_mem = (void*)step_mem; + + /* Set default values for optional inputs */ + retval = erkStep_SetDefaults((void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Error setting default solver options"); - ERKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -119,6 +130,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) /* Initialize all the counters */ step_mem->nfe = 0; + /* Initialize fused op work space */ step_mem->cvals = NULL; step_mem->Xvecs = NULL; @@ -134,64 +146,13 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Unable to initialize main ARKODE infrastructure"); - ERKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } return ((void*)ark_mem); } -/*--------------------------------------------------------------- - ERKStepResize: - - This routine resizes the memory within the ERKStep module. - It first resizes the main ARKODE infrastructure memory, and - then resizes its own data. - ---------------------------------------------------------------*/ -int ERKStepResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data) -{ - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - sunindextype lrw1, liw1, lrw_diff, liw_diff; - int i, retval; - - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Determing change in vector sizes */ - lrw1 = liw1 = 0; - if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } - lrw_diff = lrw1 - ark_mem->lrw1; - liw_diff = liw1 - ark_mem->liw1; - ark_mem->lrw1 = lrw1; - ark_mem->liw1 = liw1; - - /* resize ARKODE infrastructure memory */ - retval = arkResize(ark_mem, y0, hscale, t0, resize, resize_data); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to resize main ARKODE infrastructure"); - return (retval); - } - - /* Resize the RHS vectors */ - for (i = 0; i < step_mem->stages; i++) - { - if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, - &step_mem->F[i])) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Unable to resize vector"); - return (ARK_MEM_FAIL); - } - } - - return (ARK_SUCCESS); -} - /*--------------------------------------------------------------- ERKStepReInit: @@ -210,7 +171,7 @@ int ERKStepReInit(void* arkode_mem, ARKRhsFn f, sunrealtype t0, N_Vector y0) int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -255,151 +216,62 @@ int ERKStepReInit(void* arkode_mem, ARKRhsFn f, sunrealtype t0, N_Vector y0) return (ARK_SUCCESS); } +/*=============================================================== + Interface routines supplied to ARKODE + ===============================================================*/ + /*--------------------------------------------------------------- - ERKStepReset: + erkStep_Resize: - This routine resets the ERKStep module state to solve the same - problem from the given time with the input state (all counter - values are retained). + This routine resizes the memory within the ERKStep module. ---------------------------------------------------------------*/ -int ERKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - int retval; + sunindextype lrw1, liw1, lrw_diff, liw_diff; + int i, retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Initialize main ARKODE infrastructure */ - retval = arkInit(ark_mem, tR, yR, RESET_INIT); + /* Determine change in vector sizes */ + lrw1 = liw1 = 0; + if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } + lrw_diff = lrw1 - ark_mem->lrw1; + liw_diff = liw1 - ark_mem->liw1; + ark_mem->lrw1 = lrw1; + ark_mem->liw1 = liw1; - if (retval != ARK_SUCCESS) + /* Resize the RHS vectors */ + for (i = 0; i < step_mem->stages; i++) { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to initialize main ARKODE infrastructure"); - return (retval); + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->F[i])) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); + } } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ERKStepSStolerances, ERKStepSVtolerances, ERKStepWFtolerances: - - These routines set integration tolerances (wrappers for general - ARKODE utility routines) - ---------------------------------------------------------------*/ -int ERKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) -{ - /* unpack ark_mem, call arkSStolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkSStolerances(ark_mem, reltol, abstol)); -} - -int ERKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) -{ - /* unpack ark_mem, call arkSVtolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkSVtolerances(ark_mem, reltol, abstol)); -} - -int ERKStepWFtolerances(void* arkode_mem, ARKEwtFn efun) -{ - /* unpack ark_mem, call arkWFtolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkWFtolerances(ark_mem, efun)); -} - -int ERKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) -{ - /* unpack ark_mem, call arkRootInit, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkRootInit(ark_mem, nrtfn, g)); -} - -int ERKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask) -{ - /* unpack ark_mem, call arkEvolve, and return */ - int retval; - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkEvolve(ark_mem, tout, yout, tret, itask); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); -} - -int ERKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) -{ - /* unpack ark_mem, call arkGetDky, and return */ - int retval; - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkGetDky(ark_mem, t, k, dky); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); -} - -/*--------------------------------------------------------------- - ERKStepFree frees all ERKStep memory, and then calls an ARKODE - utility routine to free the ARKODE infrastructure memory. + erkStep_Free frees all ERKStep memory. ---------------------------------------------------------------*/ -void ERKStepFree(void** arkode_mem) +void erkStep_Free(ARKodeMem ark_mem) { int j; sunindextype Bliw, Blrw; - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - /* nothing to do if arkode_mem is already NULL */ - if (*arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL ERKStep module */ - ark_mem = (ARKodeMem)(*arkode_mem); if (ark_mem->step_mem != NULL) { step_mem = (ARKodeERKStepMem)ark_mem->step_mem; @@ -445,21 +317,16 @@ void ERKStepFree(void** arkode_mem) free(ark_mem->step_mem); ark_mem->step_mem = NULL; } - - /* free memory for overall ARKODE infrastructure */ - arkFree(arkode_mem); } /*--------------------------------------------------------------- - ERKStepPrintMem: + erkStep_PrintMem: - This routine outputs the memory from the ERKStep structure and - the main ARKODE infrastructure to a specified file pointer - (useful when debugging). + This routine outputs the memory from the ERKStep structure to + a specified file pointer (useful when debugging). ---------------------------------------------------------------*/ -void ERKStepPrintMem(void* arkode_mem, FILE* outfile) +void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; @@ -468,12 +335,9 @@ void ERKStepPrintMem(void* arkode_mem, FILE* outfile) #endif /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } - /* output data from main ARKODE infrastructure */ - arkPrintMem(ark_mem, outfile); - /* output integer quantities */ fprintf(outfile, "ERKStep: q = %i\n", step_mem->q); fprintf(outfile, "ERKStep: p = %i\n", step_mem->p); @@ -496,14 +360,6 @@ void ERKStepPrintMem(void* arkode_mem, FILE* outfile) #endif } -/*=============================================================== - ERKStep Private functions - ===============================================================*/ - -/*--------------------------------------------------------------- - Interface routines supplied to ARKODE - ---------------------------------------------------------------*/ - /*--------------------------------------------------------------- erkStep_Init: @@ -519,15 +375,14 @@ void ERKStepPrintMem(void* arkode_mem, FILE* outfile) With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int erkStep_Init(void* arkode_mem, int init_type) +int erkStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; sunbooleantype reset_efun; int retval, j; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if resize or reset */ @@ -672,18 +527,17 @@ int erkStep_Init(void* arkode_mem, int init_type) when estimating the initial time step size, so we strive to store the intermediate parts so that they do not interfere with the other two modes. ----------------------------------------------------------------------------*/ -int erkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { int nvec, retval; - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; sunbooleantype recomputeRHS; sunrealtype* cvals; N_Vector* Xvecs; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* local shortcuts for use with fused vector operations */ cvals = step_mem->cvals; @@ -815,19 +669,18 @@ int erkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { int retval, is, js, nvec, mode; sunrealtype* cvals; N_Vector* Xvecs; - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; /* initialize algebraic solver convergence flag to success */ *nflagPtr = ARK_SUCCESS; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* local shortcuts for fused vector operations */ @@ -909,6 +762,7 @@ int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) step_mem->nfe++; if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } + /* apply external polynomial forcing */ if (step_mem->nforcing > 0) { @@ -946,18 +800,18 @@ int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== Internal utility routines - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- - erkStep_AccessStepMem: + erkStep_AccessARKODEStepMem: - Shortcut routine to unpack ark_mem and step_mem structures from - void* pointer. If either is missing it returns ARK_MEM_NULL. + Shortcut routine to unpack both ark_mem and step_mem structures + from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int erkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem) +int erkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -967,6 +821,8 @@ int erkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeERKStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -977,6 +833,26 @@ int erkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + erkStep_AccessStepMem: + + Shortcut routine to unpack the step_mem structure from + ark_mem. If missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int erkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeERKStepMem* step_mem) +{ + /* access ARKodeERKStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_ERKSTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeERKStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- erkStep_CheckNVector: @@ -1243,13 +1119,16 @@ int erkStep_ComputeSolutions(ARKodeMem ark_mem, sunrealtype* dsmPtr) return (ARK_SUCCESS); } +/*=============================================================== + Internal utility routines for relaxation + ===============================================================*/ + /* ----------------------------------------------------------------------------- * erkStep_RelaxDeltaE * * Computes the change in the relaxation functions for use in relaxation methods * delta_e = h * sum_i b_i * * ---------------------------------------------------------------------------*/ - int erkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, long int* num_relax_jac_evals, sunrealtype* delta_e_out) { @@ -1329,7 +1208,6 @@ int erkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, * * Returns the method order * ---------------------------------------------------------------------------*/ - int erkStep_GetOrder(ARKodeMem ark_mem) { ARKodeERKStepMem step_mem = (ARKodeERKStepMem)(ark_mem->step_mem); @@ -1353,7 +1231,8 @@ int ERKStepCreateMRIStepInnerStepper(void* inner_arkode_mem, ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - retval = erkStep_AccessStepMem(inner_arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessARKODEStepMem(inner_arkode_mem, __func__, &ark_mem, + &step_mem); if (retval) { arkProcessError(NULL, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -1428,11 +1307,11 @@ int erkStep_MRIStepInnerEvolve(MRIStepInnerStepper stepper, sunrealtype t0, if (retval != ARK_SUCCESS) { return (retval); } /* set the stop time */ - retval = ERKStepSetStopTime(arkode_mem, tout); + retval = ARKodeSetStopTime(arkode_mem, tout); if (retval != ARK_SUCCESS) { return (retval); } /* evolve inner ODE */ - retval = ERKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + retval = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); if (retval < 0) { return (retval); } /* disable inner forcing */ @@ -1479,7 +1358,7 @@ int erkStep_MRIStepInnerReset(MRIStepInnerStepper stepper, sunrealtype tR, retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ERKStepReset(arkode_mem, tR, yR)); + return (ARKodeReset(arkode_mem, tR, yR)); } /*------------------------------------------------------------------------------ @@ -1499,7 +1378,7 @@ int erkStep_MRIStepInnerGetAccumulatedError(MRIStepInnerStepper stepper, retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ERKStepGetAccumulatedError(arkode_mem, accum_error)); + return (ARKodeGetAccumulatedError(arkode_mem, accum_error)); } /*------------------------------------------------------------------------------ @@ -1518,7 +1397,7 @@ int erkStep_MRIStepInnerResetAccumulatedError(MRIStepInnerStepper stepper) retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ERKStepResetAccumulatedError(arkode_mem)); + return (ARKodeResetAccumulatedError(arkode_mem)); } /*------------------------------------------------------------------------------ @@ -1537,7 +1416,7 @@ int erkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) retval = MRIStepInnerStepper_GetContent(stepper, &arkode_mem); if (retval != ARK_SUCCESS) { return (retval); } - return (ERKStepSetFixedStep(arkode_mem, h)); + return (ARKodeSetFixedStep(arkode_mem, h)); } /*------------------------------------------------------------------------------ @@ -1558,7 +1437,7 @@ int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol) if (retval != ARK_SUCCESS) { return (retval); } if (arkode_mem == NULL) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ERKSTEP_NO_MEM); return ARK_MEM_NULL; } @@ -1629,8 +1508,8 @@ int erkStep_SetInnerForcing(void* arkode_mem, sunrealtype tshift, int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, "erkStep_SetInnerForcing", - &ark_mem, &step_mem); + retval = erkStep_AccessARKODEStepMem(arkode_mem, "erkStep_SetInnerForcing", + &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nvecs > 0) diff --git a/src/arkode/arkode_erkstep_impl.h b/src/arkode/arkode_erkstep_impl.h index 7f3b907a1a..de00958c28 100644 --- a/src/arkode/arkode_erkstep_impl.h +++ b/src/arkode/arkode_erkstep_impl.h @@ -77,14 +77,27 @@ typedef struct ARKodeERKStepMemRec ===============================================================*/ /* Interface routines supplied to ARKODE */ -int erkStep_Init(void* arkode_mem, int init_type); -int erkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int erkStep_Init(ARKodeMem ark_mem, int init_type); +int erkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int erkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); +int erkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int erkStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int erkStep_SetDefaults(ARKodeMem ark_mem); +int erkStep_SetOrder(ARKodeMem ark_mem, int ord); +int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int erkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int erkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int erkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data); +void erkStep_Free(ARKodeMem ark_mem); +void erkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); +int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele); /* Internal utility routines */ -int erkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem); +int erkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeERKStepMem* step_mem); +int erkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeERKStepMem* step_mem); sunbooleantype erkStep_CheckNVector(N_Vector tmpl); int erkStep_SetButcherTable(ARKodeMem ark_mem); int erkStep_CheckButcherTable(ARKodeMem ark_mem); @@ -108,6 +121,7 @@ int erkStep_MRIStepInnerSetFixedStep(MRIStepInnerStepper stepper, sunrealtype h) int erkStep_MRIStepInnerSetRTol(MRIStepInnerStepper stepper, sunrealtype rtol); /* private functions for relaxation */ +int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac); int erkStep_RelaxDeltaE(ARKodeMem ark_mem, ARKRelaxJacFn relax_jac_fn, long int* relax_jac_fn_evals, sunrealtype* delta_e_out); int erkStep_GetOrder(ARKodeMem ark_mem); diff --git a/src/arkode/arkode_erkstep_io.c b/src/arkode/arkode_erkstep_io.c index 5764c8fe6b..ffbf9a18fb 100644 --- a/src/arkode/arkode_erkstep_io.c +++ b/src/arkode/arkode_erkstep_io.c @@ -27,427 +27,245 @@ #include "arkode_erkstep_impl.h" /*=============================================================== - ERKStep Optional input functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. + Exported optional input functions. ===============================================================*/ -int ERKStepSetDenseOrder(void* arkode_mem, int dord) -{ - return (ERKStepSetInterpolantDegree(arkode_mem, dord)); -} - -int ERKStepSetInterpolantDegree(void* arkode_mem, int degree) -{ - if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; } - return (arkSetInterpolantDegree(arkode_mem, degree)); -} - -int ERKStepSetInterpolantType(void* arkode_mem, int itype) -{ - return (arkSetInterpolantType(arkode_mem, itype)); -} - -int ERKStepSetUserData(void* arkode_mem, void* user_data) -{ - return (arkSetUserData(arkode_mem, user_data)); -} - -int ERKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) -{ - return (arkSetMaxNumSteps(arkode_mem, mxsteps)); -} - -int ERKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) -{ - return (arkSetMaxHnilWarns(arkode_mem, mxhnil)); -} - -int ERKStepSetInitStep(void* arkode_mem, sunrealtype hin) -{ - return (arkSetInitStep(arkode_mem, hin)); -} - -int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin) -{ - return (arkSetMinStep(arkode_mem, hmin)); -} - -int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax) -{ - return (arkSetMaxStep(arkode_mem, hmax)); -} - -int ERKStepSetStopTime(void* arkode_mem, sunrealtype tstop) -{ - return (arkSetStopTime(arkode_mem, tstop)); -} - -int ERKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) -{ - return (arkSetInterpolateStopTime(arkode_mem, interp)); -} -int ERKStepClearStopTime(void* arkode_mem) -{ - return (arkClearStopTime(arkode_mem)); -} +/*--------------------------------------------------------------- + ERKStepSetTable: -int ERKStepSetRootDirection(void* arkode_mem, int* rootdir) -{ - return (arkSetRootDirection(arkode_mem, rootdir)); -} + Specifies to use a customized Butcher table for the explicit + portion of the system. -int ERKStepSetNoInactiveRootWarn(void* arkode_mem) + If d==NULL, then the method is automatically flagged as a + fixed-step method; a user MUST also call either + ERKStepSetFixedStep or ERKStepSetInitStep to set the desired + time step size. + ---------------------------------------------------------------*/ +int ERKStepSetTable(void* arkode_mem, ARKodeButcherTable B) { - return (arkSetNoInactiveRootWarn(arkode_mem)); -} + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + sunindextype Blrw, Bliw; + int retval; -int ERKStepSetConstraints(void* arkode_mem, N_Vector constraints) -{ - return (arkSetConstraints(arkode_mem, constraints)); -} + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) -{ - return (arkSetMaxNumConstrFails(arkode_mem, maxfails)); -} + /* check for legal inputs */ + if (B == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } -int ERKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) -{ - return (arkSetPostprocessStepFn(arkode_mem, ProcessStep)); -} + /* clear any existing parameters and Butcher tables */ + step_mem->stages = 0; + step_mem->q = 0; + step_mem->p = 0; -int ERKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) -{ - return (arkSetPostprocessStageFn(arkode_mem, ProcessStage)); -} + ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->B); + step_mem->B = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ERKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust) -{ - return (arkSetAdaptivityAdjustment(arkode_mem, adjust)); -} + /* set the relevant parameters */ + step_mem->stages = B->stages; + step_mem->q = B->q; + step_mem->p = B->p; -int ERKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) -{ - return (arkSetCFLFraction(arkode_mem, cfl_frac)); -} + /* copy the table into step memory */ + step_mem->B = ARKodeButcherTable_Copy(B); + if (step_mem->B == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } -int ERKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety) -{ - return (arkSetSafetyFactor(arkode_mem, safety)); -} + ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); + ark_mem->liw += Bliw; + ark_mem->lrw += Blrw; -int ERKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) -{ - return (arkSetMaxGrowth(arkode_mem, mx_growth)); + return (ARK_SUCCESS); } -int ERKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min) -{ - return (arkSetMinReduction(arkode_mem, eta_min)); -} +/*--------------------------------------------------------------- + ERKStepSetTableNum: -int ERKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) + Specifies to use a pre-existing Butcher table for the problem, + based on the integer flag passed to ARKodeButcherTable_LoadERK() + within the file arkode_butcher_erk.c. + ---------------------------------------------------------------*/ +int ERKStepSetTableNum(void* arkode_mem, ARKODE_ERKTableID etable) { - return (arkSetFixedStepBounds(arkode_mem, lb, ub)); -} + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + sunindextype Blrw, Bliw; + int retval; -int ERKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) -{ - return (arkSetMaxFirstGrowth(arkode_mem, etamx1)); -} + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ERKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) -{ - return (arkSetMaxEFailGrowth(arkode_mem, etamxf)); -} + /* check that argument specifies an explicit table */ + if (etable < ARKODE_MIN_ERK_NUM || etable > ARKODE_MAX_ERK_NUM) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Illegal ERK table number"); + return (ARK_ILL_INPUT); + } -int ERKStepSetSmallNumEFails(void* arkode_mem, int small_nef) -{ - return (arkSetSmallNumEFails(arkode_mem, small_nef)); -} + /* clear any existing parameters and Butcher tables */ + step_mem->stages = 0; + step_mem->q = 0; + step_mem->p = 0; -int ERKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) -{ - return (arkSetStabilityFn(arkode_mem, EStab, estab_data)); -} + ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); + ARKodeButcherTable_Free(step_mem->B); + step_mem->B = NULL; + ark_mem->liw -= Bliw; + ark_mem->lrw -= Blrw; -int ERKStepSetMaxErrTestFails(void* arkode_mem, int maxnef) -{ - return (arkSetMaxErrTestFails(arkode_mem, maxnef)); -} + /* fill in table based on argument */ + step_mem->B = ARKodeButcherTable_LoadERK(etable); + if (step_mem->B == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + "Error setting table with that index"); + return (ARK_ILL_INPUT); + } + step_mem->stages = step_mem->B->stages; + step_mem->q = step_mem->B->q; + step_mem->p = step_mem->B->p; -int ERKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) -{ - return (arkSetFixedStep(arkode_mem, hfixed)); -} + ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); + ark_mem->liw += Bliw; + ark_mem->lrw += Blrw; -int ERKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) -{ - return (arkSetAdaptController(arkode_mem, C)); + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - Wrapper functions for accumulated temporal error estimation. - ---------------------------------------------------------------*/ -int ERKStepSetAccumulatedErrorType(void* arkode_mem, int accum_type) -{ - return (arkSetAccumulatedErrorType(arkode_mem, accum_type)); -} - -int ERKStepResetAccumulatedError(void* arkode_mem) -{ - return (arkResetAccumulatedError(arkode_mem)); -} + ERKStepSetTableName: -int ERKStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) + Specifies to use a pre-existing Butcher table for the problem, + based on the string passed to ARKodeButcherTable_LoadERKByNmae() + within the file arkode_butcher_erk.c. + ---------------------------------------------------------------*/ +int ERKStepSetTableName(void* arkode_mem, const char* etable) { - return (arkGetAccumulatedError(arkode_mem, accum_error)); + return ERKStepSetTableNum(arkode_mem, arkButcherTableERKNameToID(etable)); } /*=============================================================== - ERKStep Optional output functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. + Exported optional output functions. ===============================================================*/ -int ERKStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) -{ - return (arkGetNumStepAttempts(arkode_mem, nstep_attempts)); -} - -int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumSteps(arkode_mem, nsteps)); -} - -int ERKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) -{ - return (arkGetActualInitStep(arkode_mem, hinused)); -} - -int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) -{ - return (arkGetLastStep(arkode_mem, hlast)); -} - -int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) -{ - return (arkGetCurrentStep(arkode_mem, hcur)); -} - -int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) -{ - return (arkGetCurrentTime(arkode_mem, tcur)); -} - -int ERKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) -{ - return (arkGetTolScaleFactor(arkode_mem, tolsfact)); -} - -int ERKStepGetErrWeights(void* arkode_mem, N_Vector eweight) -{ - return (arkGetErrWeights(arkode_mem, eweight)); -} - -int ERKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) -{ - return (arkGetEstLocalErrors(arkode_mem, ele)); -} - -int ERKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) -{ - return (arkGetWorkSpace(arkode_mem, lenrw, leniw)); -} - -int ERKStepGetNumGEvals(void* arkode_mem, long int* ngevals) -{ - return (arkGetNumGEvals(arkode_mem, ngevals)); -} - -int ERKStepGetRootInfo(void* arkode_mem, int* rootsfound) -{ - return (arkGetRootInfo(arkode_mem, rootsfound)); -} - -int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, - sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) -{ - return (arkGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); -} - -int ERKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) -{ - return (arkGetNumConstrFails(arkode_mem, nconstrfails)); -} - -int ERKStepGetNumExpSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumExpSteps(arkode_mem, nsteps)); -} - -int ERKStepGetNumAccSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumAccSteps(arkode_mem, nsteps)); -} - -int ERKStepGetNumErrTestFails(void* arkode_mem, long int* netfails) -{ - return (arkGetNumErrTestFails(arkode_mem, netfails)); -} - -int ERKStepGetUserData(void* arkode_mem, void** user_data) -{ - return (arkGetUserData(arkode_mem, user_data)); -} - -char* ERKStepGetReturnFlagName(long int flag) -{ - return (arkGetReturnFlagName(flag)); -} - -/* ----------------------------------------------------------------------------- - * Wrappers for the ARKODE relaxation module - * ---------------------------------------------------------------------------*/ - -int ERKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) -{ - return arkRelaxCreate(arkode_mem, rfn, rjac, erkStep_RelaxDeltaE, - erkStep_GetOrder); -} - -int ERKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf) -{ - return arkRelaxSetEtaFail(arkode_mem, eta_rf); -} - -int ERKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) -{ - return arkRelaxSetLowerBound(arkode_mem, lower); -} - -int ERKStepSetRelaxMaxFails(void* arkode_mem, int max_fails) -{ - return arkRelaxSetMaxFails(arkode_mem, max_fails); -} - -int ERKStepSetRelaxMaxIters(void* arkode_mem, int max_iters) -{ - return arkRelaxSetMaxIters(arkode_mem, max_iters); -} +/*--------------------------------------------------------------- + ERKStepGetNumRhsEvals: -int ERKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) + Returns the current number of calls to f + ---------------------------------------------------------------*/ +int ERKStepGetNumRhsEvals(void* arkode_mem, long int* fevals) { - return arkRelaxSetSolver(arkode_mem, solver); -} + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + int retval; -int ERKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) -{ - return arkRelaxSetResTol(arkode_mem, res_tol); -} + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ERKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) -{ - return arkRelaxSetTol(arkode_mem, rel_tol, abs_tol); -} + /* get values from step_mem */ + *fevals = step_mem->nfe; -int ERKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) -{ - return arkRelaxSetUpperBound(arkode_mem, upper); + return (ARK_SUCCESS); } -int ERKStepGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) -{ - return arkRelaxGetNumRelaxFnEvals(arkode_mem, r_evals); -} +/*--------------------------------------------------------------- + ERKStepGetCurrentButcherTable: -int ERKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) + Sets pointers to the Butcher table currently in use. + ---------------------------------------------------------------*/ +int ERKStepGetCurrentButcherTable(void* arkode_mem, ARKodeButcherTable* B) { - return arkRelaxGetNumRelaxJacEvals(arkode_mem, J_evals); -} + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + int retval; -int ERKStepGetNumRelaxFails(void* arkode_mem, long int* relax_fails) -{ - return arkRelaxGetNumRelaxFails(arkode_mem, relax_fails); -} + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int ERKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails) -{ - return arkRelaxGetNumRelaxBoundFails(arkode_mem, fails); + /* get tables from step_mem */ + *B = step_mem->B; + return (ARK_SUCCESS); } -int ERKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails) -{ - return arkRelaxGetNumRelaxSolveFails(arkode_mem, fails); -} +/*--------------------------------------------------------------- + ERKStepGetTimestepperStats: -int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) + Returns integrator statistics + ---------------------------------------------------------------*/ +int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, + long int* accsteps, long int* attempts, + long int* fevals, long int* netfails) { - return arkRelaxGetNumRelaxSolveIters(arkode_mem, iters); -} + ARKodeMem ark_mem; + ARKodeERKStepMem step_mem; + int retval; -/*=============================================================== - DEPRECATED ERKStep optional input/output functions - ===============================================================*/ + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -/*--------------------------------------------------------------- - ERKStepSetAdaptivityMethod: user should create/attach a - specific SUNAdaptController object. - ---------------------------------------------------------------*/ -int ERKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, - int pq, sunrealtype adapt_params[3]) -{ - return (arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); -} + /* set expsteps and accsteps from adaptivity structure */ + *expsteps = ark_mem->hadapt_mem->nst_exp; + *accsteps = ark_mem->hadapt_mem->nst_acc; -/*--------------------------------------------------------------- - ERKStepSetAdaptivityFn: user should create/attach a custom - SUNAdaptController object. - ---------------------------------------------------------------*/ -int ERKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) -{ - return (arkSetAdaptivityFn(arkode_mem, hfun, h_data)); + /* set remaining outputs */ + *attempts = ark_mem->nst_attempts; + *fevals = step_mem->nfe; + *netfails = ark_mem->netf; + + return (ARK_SUCCESS); } +/*=============================================================== + Private functions attached to ARKODE + ===============================================================*/ + /*--------------------------------------------------------------- - ERKStepSetErrorBias: user should set this value directly in the - SUNAdaptController object. + erkStep_SetRelaxFn: + + Sets up the relaxation module using ERKStep's utility routines. ---------------------------------------------------------------*/ -int ERKStepSetErrorBias(void* arkode_mem, sunrealtype bias) +int erkStep_SetRelaxFn(ARKodeMem ark_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) { - return (arkSetErrorBias(arkode_mem, bias)); + return ( + arkRelaxCreate(ark_mem, rfn, rjac, erkStep_RelaxDeltaE, erkStep_GetOrder)); } -/*=============================================================== - ERKStep optional input functions -- stepper-specific - ===============================================================*/ - /*--------------------------------------------------------------- - ERKStepSetDefaults: + erkStep_SetDefaults: Resets all ERKStep optional inputs to their default values. Does not change problem-defining function pointers or user_data pointer. ---------------------------------------------------------------*/ -int ERKStepSetDefaults(void* arkode_mem) +int erkStep_SetDefaults(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; int retval; long int lenrw, leniw; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Set default ARKODE infrastructure parameters */ - retval = arkSetDefaults(arkode_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error setting ARKODE infrastructure defaults"); - return (retval); - } - /* Remove current SUNAdaptController object, and replace with "PI" */ retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, &leniw); @@ -501,19 +319,18 @@ int ERKStepSetDefaults(void* arkode_mem) } /*--------------------------------------------------------------- - ERKStepSetOrder: + erkStep_SetOrder: Specifies the method order ---------------------------------------------------------------*/ -int ERKStepSetOrder(void* arkode_mem, int ord) +int erkStep_SetOrder(ARKodeMem ark_mem, int ord) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; sunindextype Blrw, Bliw; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set user-provided value, or default, depending on argument */ @@ -535,294 +352,413 @@ int ERKStepSetOrder(void* arkode_mem, int ord) } /*--------------------------------------------------------------- - ERKStepSetTable: + erkStep_GetEstLocalErrors: Returns the current local truncation + error estimate vector + ---------------------------------------------------------------*/ +int erkStep_GetEstLocalErrors(ARKodeMem ark_mem, N_Vector ele) +{ + int retval; + ARKodeERKStepMem step_mem; + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } - Specifies to use a customized Butcher table for the explicit - portion of the system. + /* return an error if local truncation error is not computed */ + if (ark_mem->fixedstep) { return (ARK_STEPPER_UNSUPPORTED); } - If d==NULL, then the method is automatically flagged as a - fixed-step method; a user MUST also call either - ERKStepSetFixedStep or ERKStepSetInitStep to set the desired - time step size. + /* otherwise, copy local truncation error vector to output */ + N_VScale(ONE, ark_mem->tempv1, ele); + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + erkStep_PrintAllStats: + + Prints integrator statistics ---------------------------------------------------------------*/ -int ERKStepSetTable(void* arkode_mem, ARKodeButcherTable B) +int erkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - sunindextype Blrw, Bliw; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* check for legal inputs */ - if (B == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - - /* clear any existing parameters and Butcher tables */ - step_mem->stages = 0; - step_mem->q = 0; - step_mem->p = 0; - - ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->B); - step_mem->B = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; - - /* set the relevant parameters */ - step_mem->stages = B->stages; - step_mem->q = B->q; - step_mem->p = B->p; - - /* copy the table into step memory */ - step_mem->B = ARKodeButcherTable_Copy(B); - if (step_mem->B == NULL) + switch (fmt) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + case SUN_OUTPUTFORMAT_TABLE: + fprintf(outfile, "RHS fn evals = %ld\n", step_mem->nfe); + break; + case SUN_OUTPUTFORMAT_CSV: + fprintf(outfile, ",RHS fn evals,%ld", step_mem->nfe); + fprintf(outfile, "\n"); + break; + default: + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid formatting option."); + return (ARK_ILL_INPUT); } - ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); - ark_mem->liw += Bliw; - ark_mem->lrw += Blrw; - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - ERKStepSetTableNum: + erkStep_WriteParameters: - Specifies to use a pre-existing Butcher table for the problem, - based on the integer flag passed to ARKodeButcherTable_LoadERK() - within the file arkode_butcher_erk.c. + Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int ERKStepSetTableNum(void* arkode_mem, ARKODE_ERKTableID etable) +int erkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - sunindextype Blrw, Bliw; int retval; /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = erkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* check that argument specifies an explicit table */ - if (etable < ARKODE_MIN_ERK_NUM || etable > ARKODE_MAX_ERK_NUM) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Illegal ERK table number"); - return (ARK_ILL_INPUT); - } + /* print integrator parameters to file */ + fprintf(fp, "ERKStep time step module parameters:\n"); + fprintf(fp, " Method order %i\n", step_mem->q); + fprintf(fp, "\n"); - /* clear any existing parameters and Butcher tables */ - step_mem->stages = 0; - step_mem->q = 0; - step_mem->p = 0; + return (ARK_SUCCESS); +} - ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); - ARKodeButcherTable_Free(step_mem->B); - step_mem->B = NULL; - ark_mem->liw -= Bliw; - ark_mem->lrw -= Blrw; +/*=============================================================== + Exported-but-deprecated user-callable functions. + ===============================================================*/ - /* fill in table based on argument */ - step_mem->B = ARKodeButcherTable_LoadERK(etable); - if (step_mem->B == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error setting table with that index"); - return (ARK_ILL_INPUT); - } - step_mem->stages = step_mem->B->stages; - step_mem->q = step_mem->B->q; - step_mem->p = step_mem->B->p; +int ERKStepResize(void* arkode_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +{ + return (ARKodeResize(arkode_mem, y0, hscale, t0, resize, resize_data)); +} - ARKodeButcherTable_Space(step_mem->B, &Bliw, &Blrw); - ark_mem->liw += Bliw; - ark_mem->lrw += Blrw; +int ERKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +{ + return (ARKodeReset(arkode_mem, tR, yR)); +} - return (ARK_SUCCESS); +int ERKStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) +{ + return (ARKodeSStolerances(arkode_mem, reltol, abstol)); +} + +int ERKStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) +{ + return (ARKodeSVtolerances(arkode_mem, reltol, abstol)); +} + +int ERKStepWFtolerances(void* arkode_mem, ARKEwtFn efun) +{ + return (ARKodeWFtolerances(arkode_mem, efun)); +} + +int ERKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) +{ + return (ARKodeRootInit(arkode_mem, nrtfn, g)); +} + +int ERKStepSetDefaults(void* arkode_mem) +{ + return (ARKodeSetDefaults(arkode_mem)); +} + +int ERKStepSetOrder(void* arkode_mem, int ord) +{ + return (ARKodeSetOrder(arkode_mem, ord)); +} + +int ERKStepSetInterpolantType(void* arkode_mem, int itype) +{ + return (ARKodeSetInterpolantType(arkode_mem, itype)); +} + +int ERKStepSetInterpolantDegree(void* arkode_mem, int degree) +{ + return (ARKodeSetInterpolantDegree(arkode_mem, degree)); +} + +int ERKStepSetDenseOrder(void* arkode_mem, int dord) +{ + return (ARKodeSetInterpolantDegree(arkode_mem, dord)); +} + +int ERKStepSetAdaptController(void* arkode_mem, SUNAdaptController C) +{ + return (ARKodeSetAdaptController(arkode_mem, C)); +} + +int ERKStepSetAdaptivityAdjustment(void* arkode_mem, int adjust) +{ + return (ARKodeSetAdaptivityAdjustment(arkode_mem, adjust)); +} + +int ERKStepSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) +{ + return (ARKodeSetCFLFraction(arkode_mem, cfl_frac)); +} + +int ERKStepSetSafetyFactor(void* arkode_mem, sunrealtype safety) +{ + return (ARKodeSetSafetyFactor(arkode_mem, safety)); +} + +int ERKStepSetErrorBias(void* arkode_mem, sunrealtype bias) +{ + return (ARKodeSetErrorBias(arkode_mem, bias)); +} + +int ERKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) +{ + return (ARKodeSetMaxGrowth(arkode_mem, mx_growth)); +} + +int ERKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min) +{ + return (ARKodeSetMinReduction(arkode_mem, eta_min)); +} + +int ERKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) +{ + return (ARKodeSetFixedStepBounds(arkode_mem, lb, ub)); +} + +int ERKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, + int pq, sunrealtype adapt_params[3]) +{ + return (arkSetAdaptivityMethod(arkode_mem, imethod, idefault, pq, adapt_params)); +} + +int ERKStepSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) +{ + return (arkSetAdaptivityFn(arkode_mem, hfun, h_data)); +} + +int ERKStepSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) +{ + return (ARKodeSetMaxFirstGrowth(arkode_mem, etamx1)); +} + +int ERKStepSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) +{ + return (ARKodeSetMaxEFailGrowth(arkode_mem, etamxf)); +} + +int ERKStepSetSmallNumEFails(void* arkode_mem, int small_nef) +{ + return (ARKodeSetSmallNumEFails(arkode_mem, small_nef)); +} + +int ERKStepSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) +{ + return (ARKodeSetStabilityFn(arkode_mem, EStab, estab_data)); +} + +int ERKStepSetMaxErrTestFails(void* arkode_mem, int maxnef) +{ + return (ARKodeSetMaxErrTestFails(arkode_mem, maxnef)); +} + +int ERKStepSetConstraints(void* arkode_mem, N_Vector constraints) +{ + return (ARKodeSetConstraints(arkode_mem, constraints)); +} + +int ERKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) +{ + return (ARKodeSetMaxNumSteps(arkode_mem, mxsteps)); +} + +int ERKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) +{ + return (ARKodeSetMaxHnilWarns(arkode_mem, mxhnil)); +} + +int ERKStepSetInitStep(void* arkode_mem, sunrealtype hin) +{ + return (ARKodeSetInitStep(arkode_mem, hin)); +} + +int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin) +{ + return (ARKodeSetMinStep(arkode_mem, hmin)); +} + +int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax) +{ + return (ARKodeSetMaxStep(arkode_mem, hmax)); +} + +int ERKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) +{ + return (ARKodeSetInterpolateStopTime(arkode_mem, interp)); } -/*--------------------------------------------------------------- - ERKStepSetTableName: - - Specifies to use a pre-existing Butcher table for the problem, - based on the string passed to ARKodeButcherTable_LoadERKByNmae() - within the file arkode_butcher_erk.c. - ---------------------------------------------------------------*/ -int ERKStepSetTableName(void* arkode_mem, const char* etable) +int ERKStepSetStopTime(void* arkode_mem, sunrealtype tstop) { - return ERKStepSetTableNum(arkode_mem, arkButcherTableERKNameToID(etable)); + return (ARKodeSetStopTime(arkode_mem, tstop)); } -/*=============================================================== - ERKStep optional output functions -- stepper-specific - ===============================================================*/ +int ERKStepClearStopTime(void* arkode_mem) +{ + return (ARKodeClearStopTime(arkode_mem)); +} -/*--------------------------------------------------------------- - ERKStepGetNumRhsEvals: +int ERKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) +{ + return (ARKodeSetFixedStep(arkode_mem, hfixed)); +} - Returns the current number of calls to fe and fi - ---------------------------------------------------------------*/ -int ERKStepGetNumRhsEvals(void* arkode_mem, long int* fevals) +int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) { - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - int retval; + return (ARKodeSetMaxNumConstrFails(arkode_mem, maxfails)); +} - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ERKStepSetRootDirection(void* arkode_mem, int* rootdir) +{ + return (ARKodeSetRootDirection(arkode_mem, rootdir)); +} - /* get values from step_mem */ - *fevals = step_mem->nfe; +int ERKStepSetNoInactiveRootWarn(void* arkode_mem) +{ + return (ARKodeSetNoInactiveRootWarn(arkode_mem)); +} - return (ARK_SUCCESS); +int ERKStepSetUserData(void* arkode_mem, void* user_data) +{ + return (ARKodeSetUserData(arkode_mem, user_data)); } -/*--------------------------------------------------------------- - ERKStepGetCurrentButcherTable: +int ERKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) +{ + return (ARKodeSetPostprocessStepFn(arkode_mem, ProcessStep)); +} - Sets pointers to the Butcher table currently in use. - ---------------------------------------------------------------*/ -int ERKStepGetCurrentButcherTable(void* arkode_mem, ARKodeButcherTable* B) +int ERKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) { - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - int retval; + return (ARKodeSetPostprocessStageFn(arkode_mem, ProcessStage)); +} - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ERKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask) +{ + return (ARKodeEvolve(arkode_mem, tout, yout, tret, itask)); +} - /* get tables from step_mem */ - *B = step_mem->B; - return (ARK_SUCCESS); +int ERKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) +{ + return (ARKodeGetDky(arkode_mem, t, k, dky)); } -/*--------------------------------------------------------------- - ERKStepGetTimestepperStats: +int ERKStepGetNumExpSteps(void* arkode_mem, long int* nsteps) +{ + return (ARKodeGetNumExpSteps(arkode_mem, nsteps)); +} - Returns integrator statistics - ---------------------------------------------------------------*/ -int ERKStepGetTimestepperStats(void* arkode_mem, long int* expsteps, - long int* accsteps, long int* attempts, - long int* fevals, long int* netfails) +int ERKStepGetNumAccSteps(void* arkode_mem, long int* nsteps) { - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - int retval; + return (ARKodeGetNumAccSteps(arkode_mem, nsteps)); +} - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ERKStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) +{ + return (ARKodeGetNumStepAttempts(arkode_mem, nstep_attempts)); +} - /* set expsteps and accsteps from adaptivity structure */ - *expsteps = ark_mem->hadapt_mem->nst_exp; - *accsteps = ark_mem->hadapt_mem->nst_acc; +int ERKStepGetNumErrTestFails(void* arkode_mem, long int* netfails) +{ + return (ARKodeGetNumErrTestFails(arkode_mem, netfails)); +} - /* set remaining outputs */ - *attempts = ark_mem->nst_attempts; - *fevals = step_mem->nfe; - *netfails = ark_mem->netf; +int ERKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) +{ + return (ARKodeGetEstLocalErrors(arkode_mem, ele)); +} - return (ARK_SUCCESS); +int ERKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) +{ + return (ARKodeGetWorkSpace(arkode_mem, lenrw, leniw)); } -/*--------------------------------------------------------------- - ERKStepPrintAllStats: +int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps) +{ + return (ARKodeGetNumSteps(arkode_mem, nsteps)); +} - Prints integrator statistics - ---------------------------------------------------------------*/ -int ERKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int ERKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) { - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - int retval; + return (ARKodeGetActualInitStep(arkode_mem, hinused)); +} - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) +{ + return (ARKodeGetLastStep(arkode_mem, hlast)); +} - retval = arkPrintAllStats(arkode_mem, outfile, fmt); - if (retval != ARK_SUCCESS) { return (retval); } +int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) +{ + return (ARKodeGetCurrentStep(arkode_mem, hcur)); +} - switch (fmt) - { - case SUN_OUTPUTFORMAT_TABLE: - fprintf(outfile, "RHS fn evals = %ld\n", step_mem->nfe); - break; - case SUN_OUTPUTFORMAT_CSV: - fprintf(outfile, ",RHS fn evals,%ld", step_mem->nfe); - fprintf(outfile, "\n"); - break; - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return (ARK_ILL_INPUT); - } +int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) +{ + return (ARKodeGetCurrentTime(arkode_mem, tcur)); +} - return (ARK_SUCCESS); +int ERKStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) +{ + return (ARKodeGetTolScaleFactor(arkode_mem, tolsfact)); } -/*=============================================================== - ERKStep parameter output - ===============================================================*/ +int ERKStepGetErrWeights(void* arkode_mem, N_Vector eweight) +{ + return (ARKodeGetErrWeights(arkode_mem, eweight)); +} -/*--------------------------------------------------------------- - ERKStepWriteParameters: +int ERKStepGetNumGEvals(void* arkode_mem, long int* ngevals) +{ + return (ARKodeGetNumGEvals(arkode_mem, ngevals)); +} - Outputs all solver parameters to the provided file pointer. - ---------------------------------------------------------------*/ -int ERKStepWriteParameters(void* arkode_mem, FILE* fp) +int ERKStepGetRootInfo(void* arkode_mem, int* rootsfound) { - ARKodeMem ark_mem; - ARKodeERKStepMem step_mem; - int retval; + return (ARKodeGetRootInfo(arkode_mem, rootsfound)); +} - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } +int ERKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) +{ + return (ARKodeGetNumConstrFails(arkode_mem, nconstrfails)); +} - /* output ARKODE infrastructure parameters first */ - retval = arkWriteParameters(arkode_mem, fp); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error writing ARKODE infrastructure parameters"); - return (retval); - } +int ERKStepGetUserData(void* arkode_mem, void** user_data) +{ + return (ARKodeGetUserData(arkode_mem, user_data)); +} - /* print integrator parameters to file */ - fprintf(fp, "ERKStep time step module parameters:\n"); - fprintf(fp, " Method order %i\n", step_mem->q); - fprintf(fp, "\n"); +int ERKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +{ + return (ARKodePrintAllStats(arkode_mem, outfile, fmt)); +} - return (ARK_SUCCESS); +char* ERKStepGetReturnFlagName(long int flag) +{ + return (ARKodeGetReturnFlagName(flag)); } -/*--------------------------------------------------------------- - ERKStepWriteButcher: +int ERKStepWriteParameters(void* arkode_mem, FILE* fp) +{ + return (ARKodeWriteParameters(arkode_mem, fp)); +} - Outputs Butcher tables to the provided file pointer. - ---------------------------------------------------------------*/ int ERKStepWriteButcher(void* arkode_mem, FILE* fp) { int retval; ARKodeMem ark_mem; ARKodeERKStepMem step_mem; - /* access ARKodeERKStepMem structure */ - retval = erkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeERKStepMem structures */ + retval = erkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that Butcher table is non-NULL (otherwise report error) */ @@ -841,6 +777,94 @@ int ERKStepWriteButcher(void* arkode_mem, FILE* fp) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, + sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) +{ + return (ARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); +} + +void ERKStepFree(void** arkode_mem) { ARKodeFree(arkode_mem); } + +void ERKStepPrintMem(void* arkode_mem, FILE* outfile) +{ + ARKodePrintMem(arkode_mem, outfile); +} + +int ERKStepSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) +{ + return (ARKodeSetRelaxFn(arkode_mem, rfn, rjac)); +} + +int ERKStepSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_rf) +{ + return (ARKodeSetRelaxEtaFail(arkode_mem, eta_rf)); +} + +int ERKStepSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) +{ + return (ARKodeSetRelaxLowerBound(arkode_mem, lower)); +} + +int ERKStepSetRelaxMaxFails(void* arkode_mem, int max_fails) +{ + return (ARKodeSetRelaxMaxFails(arkode_mem, max_fails)); +} + +int ERKStepSetRelaxMaxIters(void* arkode_mem, int max_iters) +{ + return (ARKodeSetRelaxMaxIters(arkode_mem, max_iters)); +} + +int ERKStepSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) +{ + return (ARKodeSetRelaxSolver(arkode_mem, solver)); +} + +int ERKStepSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) +{ + return (ARKodeSetRelaxResTol(arkode_mem, res_tol)); +} + +int ERKStepSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) +{ + return (ARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol)); +} + +int ERKStepSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) +{ + return (ARKodeSetRelaxUpperBound(arkode_mem, upper)); +} + +int ERKStepGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) +{ + return (ARKodeGetNumRelaxFnEvals(arkode_mem, r_evals)); +} + +int ERKStepGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) +{ + return (ARKodeGetNumRelaxJacEvals(arkode_mem, J_evals)); +} + +int ERKStepGetNumRelaxFails(void* arkode_mem, long int* relax_fails) +{ + return (ARKodeGetNumRelaxFails(arkode_mem, relax_fails)); +} + +int ERKStepGetNumRelaxBoundFails(void* arkode_mem, long int* fails) +{ + return (ARKodeGetNumRelaxBoundFails(arkode_mem, fails)); +} + +int ERKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails) +{ + return (ARKodeGetNumRelaxSolveFails(arkode_mem, fails)); +} + +int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters) +{ + return (ARKodeGetNumRelaxSolveIters(arkode_mem, iters)); +} + +/*=============================================================== EOF - ---------------------------------------------------------------*/ + ===============================================================*/ diff --git a/src/arkode/arkode_impl.h b/src/arkode/arkode_impl.h index 737ce3d463..f9e906959a 100644 --- a/src/arkode/arkode_impl.h +++ b/src/arkode/arkode_impl.h @@ -66,23 +66,29 @@ extern "C" { ===============================================================*/ /* Basic ARKODE defaults */ -#define Q_DEFAULT 4 /* method order */ -#define MXSTEP_DEFAULT 500 /* max steps between returns */ -#define MAXNEF 7 /* max number of error failures */ -#define MAXNCF 10 /* max number of convergence failures */ -#define MAXCONSTRFAILS 10 /* max number of constraint failures */ -#define MXHNIL 10 /* max number of t+h==h warnings */ +/* method order */ +#define Q_DEFAULT 4 +/* max steps between returns */ +#define MXSTEP_DEFAULT 500 +/* max number of error failures */ +#define MAXNEF 7 +/* max number of convergence failures */ +#define MAXNCF 10 +/* max number of constraint failures */ +#define MAXCONSTRFAILS 10 +/* max number of t+h==h warnings */ +#define MXHNIL 10 /* Numeric constants */ -#define ZERO SUN_RCONST(0.0) /* real 0.0 */ -#define TINY SUN_RCONST(1.0e-10) /* small number */ -#define TENTH SUN_RCONST(0.1) /* real 0.1 */ -#define HALF SUN_RCONST(0.5) /* real 0.5 */ -#define ONE SUN_RCONST(1.0) /* real 1.0 */ -#define TWO SUN_RCONST(2.0) /* real 2.0 */ -#define THREE SUN_RCONST(3.0) /* real 3.0 */ -#define FOUR SUN_RCONST(4.0) /* real 4.0 */ -#define FIVE SUN_RCONST(5.0) /* real 5.0 */ +#define ZERO SUN_RCONST(0.0) +#define TINY SUN_RCONST(1.0e-10) +#define TENTH SUN_RCONST(0.1) +#define HALF SUN_RCONST(0.5) +#define ONE SUN_RCONST(1.0) +#define TWO SUN_RCONST(2.0) +#define THREE SUN_RCONST(3.0) +#define FOUR SUN_RCONST(4.0) +#define FIVE SUN_RCONST(5.0) /* Control constants for tolerances */ #define ARK_SS 0 @@ -139,56 +145,143 @@ extern "C" { #define ONEPSM SUN_RCONST(1.000001) #define ONEMSM SUN_RCONST(0.999999) +/*--------------------------------------------------------------- + Input flag to linear solver setup routine: CONVFAIL + + ARK_NO_FAILURES : Either this is the first lsetup call for + this step, or the local error test failed + on the previous attempt at this step (but + the Newton iteration converged). + + ARK_FAIL_BAD_J : This value is passed to lsetup if + + (a) The previous Newton corrector + iteration did not converge and the + linear solver's setup routine + indicated that its Jacobian-related + data is not current + or + + (b) During the previous Newton corrector + iteration, the linear solver's solve + routine failed in a recoverable manner + and the linear solver's setup routine + indicated that its Jacobian-related + data is not current. + + ARK_FAIL_OTHER : During the current internal step try, the + previous Newton iteration failed to + converge even though the linear solver was + using current Jacobian-related data. + --------------------------------------------------------------*/ +#define ARK_NO_FAILURES 0 +#define ARK_FAIL_BAD_J 1 +#define ARK_FAIL_OTHER 2 + /*=============================================================== ARKODE Interface function definitions ===============================================================*/ -/* NOTE: documentation for the purpose of these functions is - located at the end of this file */ +/* NOTE: documentation for the purpose of these internal interface + functions is located at the end of this file */ /* linear solver interface functions */ -typedef int (*ARKLinsolInitFn)(void* arkode_mem); -typedef int (*ARKLinsolSetupFn)(void* arkode_mem, int convfail, +typedef int (*ARKLinsolInitFn)(ARKodeMem ark_mem); +typedef int (*ARKLinsolSetupFn)(ARKodeMem ark_mem, int convfail, sunrealtype tpred, N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); -typedef int (*ARKLinsolSolveFn)(void* arkode_mem, N_Vector b, sunrealtype tcur, +typedef int (*ARKLinsolSolveFn)(ARKodeMem ark_mem, N_Vector b, sunrealtype tcur, N_Vector ycur, N_Vector fcur, sunrealtype client_tol, int mnewt); -typedef int (*ARKLinsolFreeFn)(void* arkode_mem); +typedef int (*ARKLinsolFreeFn)(ARKodeMem ark_mem); -/* mass-matrix solver interface functions */ -typedef int (*ARKMassInitFn)(void* arkode_mem); -typedef int (*ARKMassSetupFn)(void* arkode_mem, sunrealtype t, N_Vector vtemp1, +/* mass matrix solver interface functions */ +typedef int (*ARKMassInitFn)(ARKodeMem ark_mem); +typedef int (*ARKMassSetupFn)(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); typedef int (*ARKMassMultFn)(void* arkode_mem, N_Vector v, N_Vector Mv); -typedef int (*ARKMassSolveFn)(void* arkode_mem, N_Vector b, +typedef int (*ARKMassSolveFn)(ARKodeMem ark_mem, N_Vector b, sunrealtype client_tol); -typedef int (*ARKMassFreeFn)(void* arkode_mem); - -/* time stepper interface functions */ -typedef int (*ARKTimestepInitFn)(void* arkode_mem, int init_type); -typedef int (*ARKTimestepAttachLinsolFn)(void* arkode_mem, ARKLinsolInitFn linit, +typedef int (*ARKMassFreeFn)(ARKodeMem ark_mem); + +/* time stepper interface functions -- general */ +typedef int (*ARKTimestepInitFn)(ARKodeMem ark_mem, int init_type); +typedef int (*ARKTimestepFullRHSFn)(ARKodeMem ark_mem, sunrealtype t, + N_Vector y, N_Vector f, int mode); +typedef int (*ARKTimestepStepFn)(ARKodeMem ark_mem, sunrealtype* dsm, int* nflag); +typedef int (*ARKTimetepSetUserDataFn)(ARKodeMem ark_mem, void* user_data); +typedef int (*ARKTimestepPrintAllStats)(ARKodeMem ark_mem, FILE* outfile, + SUNOutputFormat fmt); +typedef int (*ARKTimestepWriteParameters)(ARKodeMem ark_mem, FILE* fp); +typedef int (*ARKTimestepResize)(ARKodeMem ark_mem, N_Vector ynew, + sunrealtype hscale, sunrealtype t0, + ARKVecResizeFn resize, void* resize_data); +typedef int (*ARKTimestepReset)(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +typedef void (*ARKTimestepFree)(ARKodeMem ark_mem); +typedef void (*ARKTimestepPrintMem)(ARKodeMem ark_mem, FILE* outfile); +typedef int (*ARKTimestepSetDefaults)(ARKodeMem ark_mem); +typedef int (*ARKTimestepSetOrder)(ARKodeMem ark_mem, int maxord); + +/* time stepper interface functions -- temporal adaptivity */ +typedef int (*ARKTimestepGetEstLocalErrors)(ARKodeMem ark_mem, N_Vector ele); + +/* time stepper interface functions -- relaxation */ +typedef int (*ARKTimestepSetRelaxFn)(ARKodeMem ark_mem, ARKRelaxFn rfn, + ARKRelaxJacFn rjac); + +/* time stepper interface functions -- implicit solvers */ +typedef int (*ARKTimestepAttachLinsolFn)(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); +typedef void (*ARKTimestepDisableLSetup)(ARKodeMem ark_mem); +typedef void* (*ARKTimestepGetLinMemFn)(ARKodeMem ark_mem); +typedef ARKRhsFn (*ARKTimestepGetImplicitRHSFn)(ARKodeMem ark_mem); +typedef int (*ARKTimestepGetGammasFn)(ARKodeMem ark_mem, sunrealtype* gamma, + sunrealtype* gamrat, sunbooleantype** jcur, + sunbooleantype* dgamma_fail); +typedef int (*ARKTimestepComputeState)(ARKodeMem ark_mem, N_Vector zcor, + N_Vector z); +typedef int (*ARKTimestepSetNonlinearSolver)(ARKodeMem ark_mem, + SUNNonlinearSolver NLS); +typedef int (*ARKTimestepSetLinear)(ARKodeMem ark_mem, int timedepend); +typedef int (*ARKTimestepSetNonlinear)(ARKodeMem ark_mem); +typedef int (*ARKTimestepSetNlsRhsFn)(ARKodeMem ark_mem, ARKRhsFn nls_fi); +typedef int (*ARKTimestepSetDeduceImplicitRhs)(ARKodeMem ark_mem, + sunbooleantype deduce); +typedef int (*ARKTimestepSetNonlinCRDown)(ARKodeMem ark_mem, sunrealtype crdown); +typedef int (*ARKTimestepSetNonlinRDiv)(ARKodeMem ark_mem, sunrealtype rdiv); +typedef int (*ARKTimestepSetDeltaGammaMax)(ARKodeMem ark_mem, sunrealtype dgmax); +typedef int (*ARKTimestepSetLSetupFrequency)(ARKodeMem ark_mem, int msbp); +typedef int (*ARKTimestepSetPredictorMethod)(ARKodeMem ark_mem, int method); +typedef int (*ARKTimestepSetMaxNonlinIters)(ARKodeMem ark_mem, int maxcor); +typedef int (*ARKTimestepSetNonlinConvCoef)(ARKodeMem ark_mem, + sunrealtype nlscoef); +typedef int (*ARKTimestepSetStagePredictFn)(ARKodeMem ark_mem, + ARKStagePredictFn PredictStage); +typedef int (*ARKTimestepGetNumLinSolvSetups)(ARKodeMem ark_mem, + long int* nlinsetups); +typedef int (*ARKTimestepGetCurrentGamma)(ARKodeMem ark_mem, sunrealtype* gamma); +typedef int (*ARKTimestepGetNonlinearSystemData)( + ARKodeMem ark_mem, sunrealtype* tcur, N_Vector* zpred, N_Vector* z, + N_Vector* Fi, sunrealtype* gamma, N_Vector* sdata, void** user_data); +typedef int (*ARKTimestepGetNumNonlinSolvIters)(ARKodeMem ark_mem, + long int* nniters); +typedef int (*ARKTimestepGetNumNonlinSolvConvFails)(ARKodeMem ark_mem, + long int* nnfails); +typedef int (*ARKTimestepGetNonlinSolvStats)(ARKodeMem ark_mem, long int* nniters, + long int* nnfails); + +/* time stepper interface functions -- non-identity mass matrices */ typedef int (*ARKTimestepAttachMasssolFn)( - void* arkode_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, + ARKodeMem ark_mem, ARKMassInitFn minit, ARKMassSetupFn msetup, ARKMassMultFn mmult, ARKMassSolveFn msolve, ARKMassFreeFn mfree, sunbooleantype time_dep, SUNLinearSolver_Type msolve_type, void* mass_mem); -typedef void (*ARKTimestepDisableLSetup)(void* arkode_mem); -typedef void (*ARKTimestepDisableMSetup)(void* arkode_mem); -typedef void* (*ARKTimestepGetLinMemFn)(void* arkode_mem); -typedef void* (*ARKTimestepGetMassMemFn)(void* arkode_mem); -typedef ARKRhsFn (*ARKTimestepGetImplicitRHSFn)(void* arkode_mem); -typedef int (*ARKTimestepGetGammasFn)(void* arkode_mem, sunrealtype* gamma, - sunrealtype* gamrat, sunbooleantype** jcur, - sunbooleantype* dgamma_fail); -typedef int (*ARKTimestepFullRHSFn)(void* arkode_mem, sunrealtype t, N_Vector y, - N_Vector f, int mode); -typedef int (*ARKTimestepStepFn)(void* arkode_mem, sunrealtype* dsm, int* nflag); +typedef void (*ARKTimestepDisableMSetup)(ARKodeMem ark_mem); +typedef void* (*ARKTimestepGetMassMemFn)(ARKodeMem ark_mem); /*=============================================================== ARKODE interpolation module definition @@ -203,15 +296,15 @@ typedef struct _generic_ARKInterp* ARKInterp; /* Structure containing function pointers to interpolation operations */ struct _generic_ARKInterpOps { - int (*resize)(void* arkode_mem, ARKInterp interp, ARKVecResizeFn resize, + int (*resize)(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); - void (*free)(void* arkode_mem, ARKInterp interp); + void (*free)(ARKodeMem ark_mem, ARKInterp interp); void (*print)(ARKInterp interp, FILE* outfile); - int (*setdegree)(void* arkode_mem, ARKInterp interp, int degree); - int (*init)(void* arkode_mem, ARKInterp interp, sunrealtype tnew); - int (*update)(void* arkode_mem, ARKInterp interp, sunrealtype tnew); - int (*evaluate)(void* arkode_mem, ARKInterp interp, sunrealtype tau, int d, + int (*setdegree)(ARKodeMem ark_mem, ARKInterp interp, int degree); + int (*init)(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); + int (*update)(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); + int (*evaluate)(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); }; @@ -224,15 +317,15 @@ struct _generic_ARKInterp }; /* ARKInterp module functions */ -int arkInterpResize(void* arkode_mem, ARKInterp interp, ARKVecResizeFn resize, +int arkInterpResize(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); -void arkInterpFree(void* arkode_mem, ARKInterp interp); +void arkInterpFree(ARKodeMem ark_mem, ARKInterp interp); void arkInterpPrintMem(ARKInterp interp, FILE* outfile); -int arkInterpSetDegree(void* arkode_mem, ARKInterp interp, int degree); -int arkInterpInit(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpUpdate(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, sunrealtype tau, +int arkInterpSetDegree(ARKodeMem ark_mem, ARKInterp interp, int degree); +int arkInterpInit(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpUpdate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpEvaluate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); /*=============================================================== @@ -295,20 +388,63 @@ struct ARKodeMemRec void* r_data; /* user pointer passed to rfun */ sunbooleantype constraintsSet; /* check inequality constraints */ - /* Time stepper module */ + /* Time stepper module -- general */ + void* step_mem; + ARKTimestepInitFn step_init; + ARKTimestepFullRHSFn step_fullrhs; + ARKTimestepStepFn step; + ARKTimetepSetUserDataFn step_setuserdata; + ARKTimestepPrintAllStats step_printallstats; + ARKTimestepWriteParameters step_writeparameters; + ARKTimestepResize step_resize; + ARKTimestepReset step_reset; + ARKTimestepFree step_free; + ARKTimestepPrintMem step_printmem; + ARKTimestepSetDefaults step_setdefaults; + ARKTimestepSetOrder step_setorder; + + /* Time stepper module -- temporal adaptivity */ + sunbooleantype step_supports_adaptive; + ARKTimestepGetEstLocalErrors step_getestlocalerrors; + + /* Time stepper module -- relaxation */ + sunbooleantype step_supports_relaxation; + ARKTimestepSetRelaxFn step_setrelaxfn; + + /* Time stepper module -- implcit solvers */ + sunbooleantype step_supports_implicit; ARKTimestepAttachLinsolFn step_attachlinsol; - ARKTimestepAttachMasssolFn step_attachmasssol; ARKTimestepDisableLSetup step_disablelsetup; - ARKTimestepDisableMSetup step_disablemsetup; ARKTimestepGetLinMemFn step_getlinmem; - ARKTimestepGetMassMemFn step_getmassmem; ARKTimestepGetImplicitRHSFn step_getimplicitrhs; - ARKMassMultFn step_mmult; ARKTimestepGetGammasFn step_getgammas; - ARKTimestepInitFn step_init; - ARKTimestepFullRHSFn step_fullrhs; - ARKTimestepStepFn step; - void* step_mem; + ARKTimestepComputeState step_computestate; + ARKTimestepSetNonlinearSolver step_setnonlinearsolver; + ARKTimestepSetLinear step_setlinear; + ARKTimestepSetNonlinear step_setnonlinear; + ARKTimestepSetNlsRhsFn step_setnlsrhsfn; + ARKTimestepSetDeduceImplicitRhs step_setdeduceimplicitrhs; + ARKTimestepSetNonlinCRDown step_setnonlincrdown; + ARKTimestepSetNonlinRDiv step_setnonlinrdiv; + ARKTimestepSetDeltaGammaMax step_setdeltagammamax; + ARKTimestepSetLSetupFrequency step_setlsetupfrequency; + ARKTimestepSetPredictorMethod step_setpredictormethod; + ARKTimestepSetMaxNonlinIters step_setmaxnonliniters; + ARKTimestepSetNonlinConvCoef step_setnonlinconvcoef; + ARKTimestepSetStagePredictFn step_setstagepredictfn; + ARKTimestepGetNumLinSolvSetups step_getnumlinsolvsetups; + ARKTimestepGetCurrentGamma step_getcurrentgamma; + ARKTimestepGetNonlinearSystemData step_getnonlinearsystemdata; + ARKTimestepGetNumNonlinSolvIters step_getnumnonlinsolviters; + ARKTimestepGetNumNonlinSolvConvFails step_getnumnonlinsolvconvfails; + ARKTimestepGetNonlinSolvStats step_getnonlinsolvstats; + + /* Time stepper module -- non-identity mass matrices */ + sunbooleantype step_supports_massmatrix; + ARKTimestepAttachMasssolFn step_attachmasssol; + ARKTimestepDisableMSetup step_disablemsetup; + ARKTimestepGetMassMemFn step_getmassmem; + ARKMassMultFn step_mmult; /* N_Vector storage */ N_Vector ewt; /* error weight vector */ @@ -425,179 +561,383 @@ struct ARKodeMemRec }; /*=============================================================== - Interface To Linear Solvers + ARKODE PROTOTYPE FUNCTIONS (MAY BE REPLACED BY USER) ===============================================================*/ -/*--------------------------------------------------------------- - Communication between ARKODE and a ARKODE Linear Solver - ----------------------------------------------------------------- - convfail (input to lsetup) - - ARK_NO_FAILURES : Either this is the first lsetup call for - this step, or the local error test failed on - the previous attempt at this step (but the - Newton iteration converged). - - ARK_FAIL_BAD_J : This value is passed to lsetup if - - (a) The previous Newton corrector iteration - did not converge and the linear solver's - setup routine indicated that its Jacobian- - related data is not current - or - (b) During the previous Newton corrector - iteration, the linear solver's solve - routine failed in a recoverable manner - and the linear solver's setup routine - indicated that its Jacobian-related data - is not current. - - ARK_FAIL_OTHER : During the current internal step try, the - previous Newton iteration failed to converge - even though the linear solver was using - current Jacobian-related data. - --------------------------------------------------------------*/ - -/* Constants for convfail (input to lsetup) */ -#define ARK_NO_FAILURES 0 -#define ARK_FAIL_BAD_J 1 -#define ARK_FAIL_OTHER 2 - -/*--------------------------------------------------------------- - ARKLinsolInitFn - --------------------------------------------------------------- - This function should complete initializations for a specific - ARKODE linear solver interface, such as counters and statistics. - This should return 0 if it has successfully initialized the - ARKODE linear solver interface and a negative value otherwise. - If an error does occur, an appropriate message should be sent - to the error handler function. - ---------------------------------------------------------------*/ +/* Prototype of internal rwtSet function */ +int arkRwtSet(N_Vector ycur, N_Vector weight, void* data); -/*--------------------------------------------------------------- - ARKLinsolSetupFn - --------------------------------------------------------------- - This function should prepare the linear solver interface for - subsequent calls to the ARKLinsolSolveFn routine. It may - recompute Jacobian-related data is it deems necessary. Its - parameters are as follows: +/* Prototype of internal explicit stability estimation function */ +int arkExpStab(N_Vector y, sunrealtype t, sunrealtype* hstab, void* user_data); - arkode_mem - void* problem memory pointer of type ARKodeMem. See - the typedef earlier in this file. +/*=============================================================== + HIGH LEVEL ERROR HANDLER, USED THROUGHOUT ARKODE + ===============================================================*/ - convfail - a flag to indicate any problem that occurred during - the solution of the nonlinear equation on the - current time step for which the linear solver is - being used. This flag can be used to help decide - whether the Jacobian data kept by a ARKODE linear - solver needs to be updated or not. - Its possible values have been documented above. +void arkProcessError(ARKodeMem ark_mem, int error_code, int line, + const char* func, const char* file, const char* msgfmt, ...); - tpred - the time for the current ARKODE internal step. +/*=============================================================== + ARKODE PRIVATE FUNCTION PROTOTYPES + ===============================================================*/ - ypred - the predicted y vector for the current ARKODE internal - step. +ARKodeMem arkCreate(SUNContext sunctx); +int arkInit(ARKodeMem ark_mem, sunrealtype t0, N_Vector y0, int init_type); +sunbooleantype arkAllocVec(ARKodeMem ark_mem, N_Vector tmpl, N_Vector* v); +sunbooleantype arkAllocVecArray(int count, N_Vector tmpl, N_Vector** v, + sunindextype lrw1, long int* lrw, + sunindextype liw1, long int* liw); +sunbooleantype arkAllocVectors(ARKodeMem ark_mem, N_Vector tmpl); +sunbooleantype arkResizeVectors(ARKodeMem ark_mem, ARKVecResizeFn resize, + void* resize_data, sunindextype lrw_diff, + sunindextype liw_diff, N_Vector tmpl); +sunbooleantype arkResizeVec(ARKodeMem ark_mem, ARKVecResizeFn resize, + void* resize_data, sunindextype lrw_diff, + sunindextype liw_diff, N_Vector tmpl, N_Vector* v); +sunbooleantype arkResizeVecArray(ARKVecResizeFn resize, void* resize_data, + int count, N_Vector tmpl, N_Vector** v, + sunindextype lrw_diff, long int* lrw, + sunindextype liw_diff, long int* liw); +void arkFreeVec(ARKodeMem ark_mem, N_Vector* v); +void arkFreeVecArray(int count, N_Vector** v, sunindextype lrw1, long int* lrw, + sunindextype liw1, long int* liw); +void arkFreeVectors(ARKodeMem ark_mem); +sunbooleantype arkCheckTimestepper(ARKodeMem ark_mem); +sunbooleantype arkCheckNvector(N_Vector tmpl); - fpred - f(tpred, ypred). +int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout); +int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask, int* ier); +int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, + N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, + ARKTimestepFullRHSFn rhs, sunrealtype* h); +sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, + N_Vector f, N_Vector temp1, N_Vector temp2); +int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype t, N_Vector y, + N_Vector f, N_Vector ycur, N_Vector temp1, + ARKTimestepFullRHSFn rhs, sunrealtype* yddnrm); - jcurPtr - a pointer to a boolean to be filled in by lsetup. - The function should set *jcurPtr=SUNTRUE if its Jacobian - data is current after the call and should set - *jcurPtr=SUNFALSE if its Jacobian data is not current. - Note: If lsetup calls for re-evaluation of - Jacobian data (based on convfail and ARKODE state - data), it should return *jcurPtr=SUNTRUE always; - otherwise an infinite loop can result. +int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm); +int arkHandleFailure(ARKodeMem ark_mem, int flag); - vtemp1 - temporary N_Vector provided for use by lsetup. +int arkEwtSetSS(N_Vector ycur, N_Vector weight, void* arkode_mem); +int arkEwtSetSV(N_Vector ycur, N_Vector weight, void* arkode_mem); +int arkEwtSetSmallReal(N_Vector ycur, N_Vector weight, void* arkode_mem); +int arkRwtSetSS(ARKodeMem ark_mem, N_Vector My, N_Vector weight); +int arkRwtSetSV(ARKodeMem ark_mem, N_Vector My, N_Vector weight); - vtemp3 - temporary N_Vector provided for use by lsetup. +int arkPredict_MaximumOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess); +int arkPredict_VariableOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess); +int arkPredict_CutoffOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess); +int arkPredict_Bootstrap(ARKodeMem ark_mem, sunrealtype hj, sunrealtype tau, + int nvec, sunrealtype* cvals, N_Vector* Xvecs, + N_Vector yguess); +int arkCheckConvergence(ARKodeMem ark_mem, int* nflagPtr, int* ncfPtr); +int arkCheckConstraints(ARKodeMem ark_mem, int* nflag, int* constrfails); +int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, + sunrealtype dsm); +int arkAccessHAdaptMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, + ARKodeHAdaptMem* hadapt_mem); - vtemp3 - temporary N_Vector provided for use by lsetup. +int arkSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, + sunrealtype adapt_params[3]); +int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); - This routine should return 0 if successful, a positive value - for a recoverable error, and a negative value for an - unrecoverable error. - ---------------------------------------------------------------*/ +ARKODE_DIRKTableID arkButcherTableDIRKNameToID(const char* imethod); +ARKODE_ERKTableID arkButcherTableERKNameToID(const char* emethod); -/*--------------------------------------------------------------- - ARKLinsolSolveFn - --------------------------------------------------------------- - This routine must solve the linear equation P x = b, where - P is some approximation to (M - gamma J), M is the system mass - matrix, J = (df/dy)(tcur,ycur), and the RHS vector b is input. The - N-vector ycur contains the solver's current approximation to - y(tcur) and the vector fcur contains the N_Vector f(tcur,ycur). - The input client_tol contains the desired accuracy (in the wrms - norm) of the routine calling the solver; the ARKDLS solver - ignores this value and the ARKSPILS solver tightens it by the - factor eplifac. The input mnewt is the current nonlinear - iteration index (ignored by ARKDLS, used by ARKSPILS). +/* XBraid interface functions */ +int arkSetForcePass(void* arkode_mem, sunbooleantype force_pass); +int arkGetLastKFlag(void* arkode_mem, int* last_kflag); - Additional vectors that are set within the ARKODE memory - structure, and that may be of use within an iterative linear - solver, include: +/*=============================================================== + Reusable ARKODE Error Messages + ===============================================================*/ - ewt - the error weight vector (scaling for solution vector) +#if defined(SUNDIALS_EXTENDED_PRECISION) - rwt - the residual weight vector (scaling for rhs vector) +#define MSG_TIME "t = %Lg" +#define MSG_TIME_H "t = %Lg and h = %Lg" +#define MSG_TIME_INT "t = %Lg is not between tcur - hold = %Lg and tcur = %Lg." +#define MSG_TIME_TOUT "tout = %Lg" +#define MSG_TIME_TSTOP "tstop = %Lg" - The solution is to be returned in the vector b. This should - return a positive value for a recoverable error and a - negative value for an unrecoverable error. Success is - indicated by a 0 return value. - ---------------------------------------------------------------*/ +#elif defined(SUNDIALS_DOUBLE_PRECISION) -/*--------------------------------------------------------------- - ARKLinsolFreeFn - --------------------------------------------------------------- - This should free up any memory allocated by the linear solver - interface. This routine is called once a problem has been - completed and the linear solver is no longer needed. It should - return 0 upon success, or a nonzero on failure. - ---------------------------------------------------------------*/ +#define MSG_TIME "t = %lg" +#define MSG_TIME_H "t = %lg and h = %lg" +#define MSG_TIME_INT "t = %lg is not between tcur - hold = %lg and tcur = %lg." +#define MSG_TIME_TOUT "tout = %lg" +#define MSG_TIME_TSTOP "tstop = %lg" -/*--------------------------------------------------------------- - ARKMassInitFn - --------------------------------------------------------------- - This function should complete initializations for a specific - mass matrix linear solver interface, such as counters and - statistics. A function of this type should return 0 if it - has successfully initialized the mass matrix linear solver and - a negative value otherwise. If an error does occur, an - appropriate message should be sent to the error handler function. - ---------------------------------------------------------------*/ +#else -/*--------------------------------------------------------------- - ARKMassSetupFn - --------------------------------------------------------------- - This should prepare the mass matrix solver interface for - subsequent calls to the ARKMassMultFn and ARKMassSolveFn - routines. It may recompute mass matrix related data is it deems - necessary. Its parameters are as follows: +#define MSG_TIME "t = %g" +#define MSG_TIME_H "t = %g and h = %g" +#define MSG_TIME_INT "t = %g is not between tcur - hold = %g and tcur = %g." +#define MSG_TIME_TOUT "tout = %g" +#define MSG_TIME_TSTOP "tstop = %g" - arkode_mem - void* problem memory pointer of type ARKodeMem. See - the typedef earlier in this file. - t - the 'time' at which to setup the mass matrix - vtemp1, vtemp2, vtemp3 - temporary N_Vectors +#endif - This routine should return 0 if successful, and a negative - value for an unrecoverable error. - ---------------------------------------------------------------*/ +/* Initialization and I/O error messages */ +#define MSG_ARK_NO_MEM "arkode_mem = NULL illegal." +#define MSG_ARK_ARKMEM_FAIL "Allocation of arkode_mem failed." +#define MSG_ARK_MEM_FAIL "A memory request failed." +#define MSG_ARK_NO_MALLOC "Attempt to call before ARKodeInit." +#define MSG_ARK_BAD_HMIN_HMAX "Inconsistent step size limits: hmin > hmax." +#define MSG_ARK_BAD_RELTOL "reltol < 0 illegal." +#define MSG_ARK_BAD_ABSTOL "abstol has negative component(s) (illegal)." +#define MSG_ARK_NULL_ABSTOL "abstol = NULL illegal." +#define MSG_ARK_BAD_RABSTOL "rabstol has negative component(s) (illegal)." +#define MSG_ARK_NULL_RABSTOL "rabstol = NULL illegal." +#define MSG_ARK_NULL_Y0 "y0 = NULL illegal." +#define MSG_ARK_Y0_FAIL_CONSTR "y0 fails to satisfy constraints." +#define MSG_ARK_NULL_F "Must specify at least one of fe, fi (both NULL)." +#define MSG_ARK_NULL_G "g = NULL illegal." +#define MSG_ARK_BAD_NVECTOR "A required vector operation is not implemented." +#define MSG_ARK_BAD_CONSTR "Illegal values in constraints vector." +#define MSG_ARK_NULL_DKY "dky = NULL illegal." +#define MSG_ARK_BAD_T "Illegal value for t. " MSG_TIME_INT +#define MSG_ARK_NO_ROOT "Rootfinding was not initialized." -/*--------------------------------------------------------------- - ARKMassMultFn - --------------------------------------------------------------- - This must compute the matrix-vector product, z = M*v, where M is - the system mass matrix the vector v is input, and the vector z - is output. The mmult routine returns a positive value for a - recoverable error and a negative value for an unrecoverable - error. Success is indicated by a 0 return value. - ---------------------------------------------------------------*/ +/* ARKODE Error Messages */ +#define MSG_ARK_YOUT_NULL "yout = NULL illegal." +#define MSG_ARK_TRET_NULL "tret = NULL illegal." +#define MSG_ARK_BAD_EWT "Initial ewt has component(s) equal to zero (illegal)." +#define MSG_ARK_EWT_NOW_BAD \ + "At " MSG_TIME ", a component of ewt has become <= 0." +#define MSG_ARK_BAD_RWT "Initial rwt has component(s) equal to zero (illegal)." +#define MSG_ARK_RWT_NOW_BAD \ + "At " MSG_TIME ", a component of rwt has become <= 0." +#define MSG_ARK_BAD_ITASK "Illegal value for itask." +#define MSG_ARK_BAD_H0 "h0 and tout - t0 inconsistent." +#define MSG_ARK_BAD_TOUT \ + "Trouble interpolating at " MSG_TIME_TOUT \ + ". tout too far back in direction of integration" +#define MSG_ARK_EWT_FAIL "The user-provide EwtSet function failed." +#define MSG_ARK_EWT_NOW_FAIL \ + "At " MSG_TIME ", the user-provide EwtSet function failed." +#define MSG_ARK_RWT_FAIL "The user-provide RwtSet function failed." +#define MSG_ARK_RWT_NOW_FAIL \ + "At " MSG_TIME ", the user-provide RwtSet function failed." +#define MSG_ARK_LINIT_FAIL "The linear solver's init routine failed." +#define MSG_ARK_HNIL_DONE \ + "The above warning has been issued mxhnil times and will not be issued " \ + "again for this problem." +#define MSG_ARK_TOO_CLOSE "tout too close to t0 to start integration." +#define MSG_ARK_MAX_STEPS \ + "At " MSG_TIME ", mxstep steps taken before reaching tout." +#define MSG_ARK_TOO_MUCH_ACC "At " MSG_TIME ", too much accuracy requested." +#define MSG_ARK_HNIL \ + "Internal " MSG_TIME_H " are such that t + h = t on the next step. The " \ + "solver will continue anyway." +#define MSG_ARK_ERR_FAILS \ + "At " MSG_TIME_H ", the error test failed repeatedly or with |h| = hmin." +#define MSG_ARK_CONV_FAILS \ + "At " MSG_TIME_H \ + ", the solver convergence test failed repeatedly or with |h| = hmin." +#define MSG_ARK_SETUP_FAILED \ + "At " MSG_TIME ", the setup routine failed in an unrecoverable manner." +#define MSG_ARK_SOLVE_FAILED \ + "At " MSG_TIME ", the solve routine failed in an unrecoverable manner." +#define MSG_ARK_FAILED_CONSTR \ + "At " MSG_TIME ", unable to satisfy inequality constraints." +#define MSG_ARK_RHSFUNC_FAILED \ + "At " MSG_TIME \ + ", the right-hand side routine failed in an unrecoverable manner." +#define MSG_ARK_RHSFUNC_UNREC \ + "At " MSG_TIME ", the right-hand side failed in a recoverable manner, but " \ + "no recovery is possible." +#define MSG_ARK_RHSFUNC_REPTD \ + "At " MSG_TIME " repeated recoverable right-hand side function errors." +#define MSG_ARK_RTFUNC_FAILED \ + "At " MSG_TIME ", the rootfinding routine failed in an unrecoverable " \ + "manner." +#define MSG_ARK_CLOSE_ROOTS "Root found at and very near " MSG_TIME "." +#define MSG_ARK_BAD_TSTOP \ + "The value " MSG_TIME_TSTOP " is behind current " MSG_TIME \ + " in the direction of integration." +#define MSG_ARK_INACTIVE_ROOTS \ + "At the end of the first step, there are still some root functions " \ + "identically 0. This warning will not be issued again." +#define MSG_ARK_RESIZE_FAIL "Error in user-supplied resize() function." +#define MSG_ARK_MASSINIT_FAIL "The mass matrix solver's init routine failed." +#define MSG_ARK_MASSSETUP_FAIL "The mass matrix solver's setup routine failed." +#define MSG_ARK_MASSSOLVE_FAIL "The mass matrix solver failed." +#define MSG_ARK_NLS_FAIL \ + "At " MSG_TIME " the nonlinear solver failed in an unrecoverable manner." +#define MSG_ARK_USER_PREDICT_FAIL \ + "At " MSG_TIME \ + " the user-supplied predictor failed in an unrecoverable manner." +#define MSG_ARKADAPT_NO_MEM "Adaptivity memory structure not allocated." +#define MSG_ARK_VECTOROP_ERR "At " MSG_TIME ", a vector operation failed." +#define MSG_ARK_INNERSTEP_FAILED \ + "At " MSG_TIME ", the inner stepper failed in an unrecoverable manner." +#define MSG_ARK_POSTPROCESS_STEP_FAIL \ + "At " MSG_TIME \ + ", the step postprocessing routine failed in an unrecoverable manner." +#define MSG_ARK_POSTPROCESS_STAGE_FAIL \ + "At " MSG_TIME \ + ", the stage postprocessing routine failed in an unrecoverable manner." +#define MSG_ARK_NULL_SUNCTX "sunctx = NULL illegal." +#define MSG_ARK_CONTEXT_MISMATCH \ + "Outer and inner steppers have different contexts." +#define MSG_ARK_MISSING_FULLRHS \ + "Time-stepping module missing fullrhs routine (required by requested " \ + "solver configuration)." +#define MSG_ARK_INTERPOLATION_FAIL \ + "At " MSG_TIME ", interpolating the solution failed." + +/*=============================================================== + + Documentation for internal ARKODE interfaces + + =============================================================== + + Interfaces To Implicit Solvers + + --------------------------------------------------------------- + + ARKLinsolInitFn + + This function should complete initializations for a specific + ARKODE linear solver interface, such as counters and statistics. + This should return 0 if it has successfully initialized the + ARKODE linear solver interface and a negative value otherwise. + If an error does occur, an appropriate message should be sent + to the error handler function. + + --------------------------------------------------------------- + + ARKLinsolSetupFn + + This function should prepare the linear solver interface for + subsequent calls to the ARKLinsolSolveFn routine. It may + recompute Jacobian-related data is it deems necessary. Its + parameters are as follows: + + arkode_mem - void* problem memory pointer of type ARKodeMem. See + the typedef earlier in this file. + + convfail - a flag to indicate any problem that occurred during + the solution of the nonlinear equation on the + current time step for which the linear solver is + being used. This flag can be used to help decide + whether the Jacobian data kept by a ARKODE linear + solver needs to be updated or not. + Its possible values have been documented above. + + tpred - the time for the current ARKODE internal step. + + ypred - the predicted y vector for the current ARKODE internal + step. + + fpred - f(tpred, ypred). + + jcurPtr - a pointer to a boolean to be filled in by lsetup. + The function should set *jcurPtr=SUNTRUE if its Jacobian + data is current after the call and should set + *jcurPtr=SUNFALSE if its Jacobian data is not current. + Note: If lsetup calls for re-evaluation of + Jacobian data (based on convfail and ARKODE state + data), it should return *jcurPtr=SUNTRUE always; + otherwise an infinite loop can result. + + vtemp1 - temporary N_Vector provided for use by lsetup. + + vtemp3 - temporary N_Vector provided for use by lsetup. + + vtemp3 - temporary N_Vector provided for use by lsetup. + + This routine should return 0 if successful, a positive value + for a recoverable error, and a negative value for an + unrecoverable error. + + --------------------------------------------------------------- + + ARKLinsolSolveFn + + This routine must solve the linear equation P x = b, where + P is some approximation to (M - gamma J), M is the system mass + matrix, J = (df/dy)(tcur,ycur), and the RHS vector b is input. The + N-vector ycur contains the solver's current approximation to + y(tcur) and the vector fcur contains the N_Vector f(tcur,ycur). + The input client_tol contains the desired accuracy (in the wrms + norm) of the routine calling the solver; the direct solvers + ignore this value and iterative solvers tighten it by the + factor eplifac. The input mnewt is the current nonlinear + iteration index (ignored by direct solvers, used by iterative + solvers). + + Additional vectors that are set within the ARKODE memory + structure, and that may be of use within an iterative linear + solver, include: + + ewt - the error weight vector (scaling for solution vector) + + rwt - the residual weight vector (scaling for rhs vector) + + The solution is to be returned in the vector b. This should + return a positive value for a recoverable error and a + negative value for an unrecoverable error. Success is + indicated by a 0 return value. + + --------------------------------------------------------------- + + ARKLinsolFreeFn + + This should free up any memory allocated by the linear solver + interface. This routine is called once a problem has been + completed and the linear solver is no longer needed. It should + return 0 upon success, or a nonzero on failure. + + =============================================================== + + Interfaces For Non-Identity Mass Matrix Support + + --------------------------------------------------------------- + + ARKMassInitFn + + This function should complete initializations for a specific + mass matrix linear solver interface, such as counters and + statistics. A function of this type should return 0 if it + has successfully initialized the mass matrix linear solver and + a negative value otherwise. If an error does occur, an + appropriate message should be sent to the error handler function. + + --------------------------------------------------------------- + + ARKMassSetupFn + + This should prepare the mass matrix solver interface for + subsequent calls to the ARKMassMultFn and ARKMassSolveFn + routines. It may recompute mass matrix related data is it deems + necessary. Its parameters are as follows: + + arkode_mem - void* problem memory pointer of type ARKodeMem. See + the typedef earlier in this file. + t - the 'time' at which to setup the mass matrix + vtemp1, vtemp2, vtemp3 - temporary N_Vectors + + This routine should return 0 if successful, and a negative + value for an unrecoverable error. + + --------------------------------------------------------------- + + ARKMassMultFn + + This must compute the matrix-vector product, z = M*v, where M is + the system mass matrix the vector v is input, and the vector z + is output. The mmult routine returns a positive value for a + recoverable error and a negative value for an unrecoverable + error. Success is indicated by a 0 return value. -/*--------------------------------------------------------------- - ARKMassSolveFn --------------------------------------------------------------- + + ARKMassSolveFn + This must solve the linear equation M x = b, where M is the system mass matrix, and the RHS vector b is input. The sunrealtype client_tol contains the desired accuracy (in the wrms @@ -616,143 +956,24 @@ struct ARKodeMemRec This routine should return a positive value for a recoverable error and a negative value for an unrecoverable error. Success is indicated by a 0 return value. - ---------------------------------------------------------------*/ -/*--------------------------------------------------------------- - ARKMassFreeFn --------------------------------------------------------------- + + ARKMassFreeFn + This should free up any memory allocated by the mass matrix solver interface. This routine is called once a problem has been completed and the solver is no longer needed. It should return 0 upon success, or a nonzero on failure. - ---------------------------------------------------------------*/ -/*=============================================================== - Interface to Time Steppers - ===============================================================*/ + =============================================================== + + Internal Interface to Time Steppers -- General -/*--------------------------------------------------------------- - ARKTimestepAttachLinsolFn --------------------------------------------------------------- - This routine should attach the various set of system linear - solver interface routines, linear solver interface data - structure, and system linear solver type to the ARKODE time - stepping module pointed to in ark_mem->step_mem. This will - be called by the ARKODE linear solver interface. - This routine should return 0 if it has successfully attached - these items and a negative value otherwise. If an error does - occur, an appropriate message should be sent to the ARKODE - error handler function. - ---------------------------------------------------------------*/ + ARKTimestepInitFn -/*--------------------------------------------------------------- - ARKTimestepAttachMasssolFn - --------------------------------------------------------------- - This routine should attach the various set of mass matrix - linear solver interface routines, data structure, mass matrix - type, and solver type to the ARKODE time stepping module - pointed to in ark_mem->step_mem. This will be called by the - ARKODE linear solver interface. - - This routine should return 0 if it has successfully attached - these items, and a negative value otherwise. If an error does - occur, an appropriate message should be sent to the ARKODE - error handler function. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepDisableLSetup - --------------------------------------------------------------- - This routine should NULLify any ARKLinsolSetupFn function - pointer stored in the ARKODE time stepping module (initially set - in a call to ARKTimestepAttachLinsolFn). - - This routine has no return value. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepDisableMSetup - --------------------------------------------------------------- - This routine should NULLify any ARKMassSetupFn function pointer - stored in the ARKODE time stepping module (initially set in a - call to ARKTimestepAttachMasssolFn). - - This routine has no return value. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepGetLinMemFn - --------------------------------------------------------------- - This routine should return the linear solver memory structure - used by the ARKODE time stepping module pointed to in - ark_mem->step_mem. This will be called by the ARKODE linear - solver interface. - - This routine should return NULL if no linear solver memory - structure is attached. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepGetMassMemFn - --------------------------------------------------------------- - This routine should return the mass matrix linear solver memory - structure used by the ARKODE time stepping module pointed to in - ark_mem->step_mem. This will be called the ARKODE mass matrix - solver interface. - - This routine should return NULL if no mass matrix solver memory - structure is attached. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepGetImplicitRHSFn - --------------------------------------------------------------- - This routine should return the implicit RHS function pointer for - the current nonlinear solve (if there are multiple); it is used - inside the linear solver interfaces for approximation of - Jacobian matrix elements and/or matrix-vector products. - - This routine should return NULL if no implicit RHS function is - active. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepGetGammasFn - --------------------------------------------------------------- - This routine should fill the current value of gamma, the ratio - of the current gamma value to the gamma value when the - Jacobian/preconditioner was last updated, a pointer to the - time step module internal sunbooleantype variable indicating - whether the preconditioner is current, and a logic value - indicating whether the gamma value is sufficiently stale - to cause recomputation of Jacobian/preconditioner data. Here, - gamma is the coefficient preceding the RHS Jacobian - matrix, J, in the full nonlinear system Jacobian, - A = M - gamma*J. - - The time step module must contain a sunbooleantype variable to - provide for the boolentype pointer (jcur). This is only used - by iterative linear solvers, so could be NULL for time step - modules that only work with direct linear solvers. Optionally, - the value of this parameter could be set to SUNFALSE prior to - return from the ARKTimestepGetGammasFn to force recalculation - of preconditioner information. - - The value of the logic flag is used as follows: if a previous - Newton iteration failed due to a bad Jacobian/preconditioner, - and this flag is SUNFALSE, this will trigger recalculation of - the Jacobian/preconditioner. - - This routine should return 0 if it has successfully attached - these items, and a negative value otherwise. If an error does - occur, an appropriate message should be sent to the ARKODE - error handler function. - ---------------------------------------------------------------*/ - -/*--------------------------------------------------------------- - ARKTimestepInitFn - --------------------------------------------------------------- This routine is called just prior to performing internal time steps (after all user "set" routines have been called) from within arkInitialSetup. It should complete initializations for @@ -765,11 +986,11 @@ struct ARKodeMemRec the ARKODE time stepper module and a negative value otherwise. If an error does occur, an appropriate message should be sent to the error handler function. - ---------------------------------------------------------------*/ -/*--------------------------------------------------------------- - ARKTimestepFullRHSFn --------------------------------------------------------------- + + ARKTimestepFullRHSFn + This routine must compute the full ODE right-hand side function at the inputs (t,y), and store the result in the N_Vector f. Depending on the type of stepper, this may be just the single @@ -802,11 +1023,11 @@ struct ARKodeMemRec This routine should return 0 if successful, and a negative value otherwise. If an error does occur, an appropriate message should be sent to the error handler function. - ---------------------------------------------------------------*/ -/*--------------------------------------------------------------- - ARKTimestepStepFn --------------------------------------------------------------- + + ARKTimestepStepFn + This routine serves the primary purpose of any ARKODE time-stepping module: it performs a single time step of the method (with embedding, if possible). @@ -849,320 +1070,390 @@ struct ARKodeMemRec >0 => step encountered recoverable failure; reduce step and retry (if possible) <0 => step encountered unrecoverable failure - ---------------------------------------------------------------*/ -/*=============================================================== - ARKODE PROTOTYPE FUNCTIONS (MAY BE REPLACED BY USER) - ===============================================================*/ + --------------------------------------------------------------- -/* Prototype of internal rwtSet function */ -int arkRwtSet(N_Vector ycur, N_Vector weight, void* data); + ARKTimetepSetUserDataFn -/* Prototype of internal explicit stability estimation function */ -int arkExpStab(N_Vector y, sunrealtype t, sunrealtype* hstab, void* user_data); + This optional routine provides the input from ARKodeSetUserData + to the stepper. -/*=============================================================== - HIGH LEVEL ERROR HANDLER, USED THROUGHOUT ARKODE - ===============================================================*/ + --------------------------------------------------------------- -void arkProcessError(ARKodeMem ark_mem, int error_code, int line, - const char* func, const char* file, const char* msgfmt, ...); + ARKTimestepPrintAllStats -/*=============================================================== - ARKODE PRIVATE FUNCTION PROTOTYPES - ===============================================================*/ -#ifdef __GNUC__ -#define SUNDIALS_UNUSED __attribute__((unused)) -#else -#define SUNDIALS_UNUSED -#endif + This optional routine allows the stepper to optionally print + out any internally-stored solver statistics when + ARKodePrintAllStats is called. -int arkInit(ARKodeMem ark_mem, sunrealtype t0, N_Vector y0, int init_type); -sunbooleantype arkAllocVec(ARKodeMem ark_mem, N_Vector tmpl, N_Vector* v); -sunbooleantype arkAllocVecArray(int count, N_Vector tmpl, N_Vector** v, - sunindextype lrw1, long int* lrw, - sunindextype liw1, long int* liw); -void arkFreeVec(ARKodeMem ark_mem, N_Vector* v); -void arkFreeVecArray(int count, N_Vector** v, sunindextype lrw1, long int* lrw, - sunindextype liw1, long int* liw); -sunbooleantype arkResizeVec(ARKodeMem ark_mem, ARKVecResizeFn resize, - void* resize_data, sunindextype lrw_diff, - sunindextype liw_diff, N_Vector tmpl, N_Vector* v); -sunbooleantype arkResizeVecArray(ARKVecResizeFn resize, void* resize_data, - int count, N_Vector tmpl, N_Vector** v, - sunindextype lrw_diff, long int* lrw, - sunindextype liw_diff, long int* liw); -void arkPrintMem(ARKodeMem ark_mem, FILE* outfile); -sunbooleantype arkCheckTimestepper(ARKodeMem ark_mem); -sunbooleantype arkCheckNvector(N_Vector tmpl); -sunbooleantype arkAllocVectors(ARKodeMem ark_mem, N_Vector tmpl); -sunbooleantype arkResizeVectors(ARKodeMem ark_mem, ARKVecResizeFn resize, - void* resize_data, sunindextype lrw_diff, - sunindextype liw_diff, N_Vector tmpl); -void arkFreeVectors(ARKodeMem ark_mem); + --------------------------------------------------------------- -int arkInitialSetup(ARKodeMem ark_mem, sunrealtype tout); -int arkStopTests(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask, int* ier); -int arkHin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, - N_Vector fcur, N_Vector ytmp, N_Vector temp1, N_Vector temp2, - ARKTimestepFullRHSFn rhs, sunrealtype* h); -sunrealtype arkUpperBoundH0(ARKodeMem ark_mem, sunrealtype tdist, N_Vector y, - N_Vector f, N_Vector temp1, N_Vector temp2); -int arkYddNorm(ARKodeMem ark_mem, sunrealtype hg, sunrealtype t, N_Vector y, - N_Vector f, N_Vector ycur, N_Vector temp1, - ARKTimestepFullRHSFn rhs, sunrealtype* yddnrm); + ARKTimestepWriteParameters -int arkCompleteStep(ARKodeMem ark_mem, sunrealtype dsm); -int arkHandleFailure(ARKodeMem ark_mem, int flag); + This optional routine allows the stepper to optionally print + out any solver parameters when ARKodeWriteParameters is called. -int arkEwtSetSS(N_Vector ycur, N_Vector weight, void* arkode_mem); -int arkEwtSetSV(N_Vector ycur, N_Vector weight, void* arkode_mem); -int arkEwtSetSmallReal(N_Vector ycur, N_Vector weight, void* arkode_mem); -int arkRwtSetSS(ARKodeMem ark_mem, N_Vector My, N_Vector weight); -int arkRwtSetSV(ARKodeMem ark_mem, N_Vector My, N_Vector weight); + --------------------------------------------------------------- -ARKodeMem arkCreate(SUNContext sunctx); -int arkResize(ARKodeMem ark_mem, N_Vector ynew, sunrealtype hscale, - sunrealtype t0, ARKVecResizeFn resize, void* resize_data); -int arkSStolerances(ARKodeMem ark_mem, sunrealtype reltol, sunrealtype abstol); -int arkSVtolerances(ARKodeMem ark_mem, sunrealtype reltol, N_Vector abstol); -int arkWFtolerances(ARKodeMem ark_mem, ARKEwtFn efun); -int arkResStolerance(ARKodeMem ark_mem, sunrealtype rabstol); -int arkResVtolerance(ARKodeMem ark_mem, N_Vector rabstol); -int arkResFtolerance(ARKodeMem ark_mem, ARKRwtFn rfun); -int arkRootInit(ARKodeMem ark_mem, int nrtfn, ARKRootFn g); -int arkEvolve(ARKodeMem ark_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask); -int arkGetDky(ARKodeMem ark_mem, sunrealtype t, int k, N_Vector dky); -void arkFree(void** arkode_mem); - -int arkWriteParameters(ARKodeMem ark_mem, FILE* fp); -int arkPredict_MaximumOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess); -int arkPredict_VariableOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess); -int arkPredict_CutoffOrder(ARKodeMem ark_mem, sunrealtype tau, N_Vector yguess); -int arkPredict_Bootstrap(ARKodeMem ark_mem, sunrealtype hj, sunrealtype tau, - int nvec, sunrealtype* cvals, N_Vector* Xvecs, - N_Vector yguess); -int arkCheckConvergence(ARKodeMem ark_mem, int* nflagPtr, int* ncfPtr); -int arkCheckConstraints(ARKodeMem ark_mem, int* nflag, int* constrfails); -int arkCheckTemporalError(ARKodeMem ark_mem, int* nflagPtr, int* nefPtr, - sunrealtype dsm); -int arkAccessHAdaptMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKodeHAdaptMem* hadapt_mem); + ARKTimestepResize -int arkSetAdaptController(void* arkode_mem, SUNAdaptController C); -int arkSetDefaults(void* arkode_mem); -int arkSetDenseOrder(void* arkode_mem, int dord); -int arkSetInterpolantType(void* arkode_mem, int itype); -int arkSetInterpolantDegree(void* arkode_mem, int degree); -int arkSetUserData(void* arkode_mem, void* user_data); -int arkSetMaxNumSteps(void* arkode_mem, long int mxsteps); -int arkSetMaxHnilWarns(void* arkode_mem, int mxhnil); -int arkSetInitStep(void* arkode_mem, sunrealtype hin); -int arkSetMinStep(void* arkode_mem, sunrealtype hmin); -int arkSetMaxStep(void* arkode_mem, sunrealtype hmax); -int arkSetStopTime(void* arkode_mem, sunrealtype tstop); -int arkSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp); -int arkClearStopTime(void* arkode_mem); -int arkSetFixedStep(void* arkode_mem, sunrealtype hfixed); -int arkSetRootDirection(void* arkode_mem, int* rootdir); -int arkSetNoInactiveRootWarn(void* arkode_mem); -int arkSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep); -int arkSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage); -int arkSetConstraints(void* arkode_mem, N_Vector constraints); -int arkSetMaxNumConstrFails(void* arkode_mem, int maxfails); -int arkSetAdaptivityAdjustment(void* arkode_mem, int adjust); -int arkSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac); -int arkSetSafetyFactor(void* arkode_mem, sunrealtype safety); -int arkSetErrorBias(void* arkode_mem, sunrealtype bias); -int arkSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth); -int arkSetMinReduction(void* arkode_mem, sunrealtype eta_min); -int arkSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub); -int arkSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, - sunrealtype adapt_params[3]); -int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data); -int arkSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1); -int arkSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf); -int arkSetSmallNumEFails(void* arkode_mem, int small_nef); -int arkSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf); -int arkSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data); -int arkSetMaxErrTestFails(void* arkode_mem, int maxnef); -int arkSetMaxConvFails(void* arkode_mem, int maxncf); -int arkSetAccumulatedErrorType(void* arkode_mem, int accum_type); -int arkResetAccumulatedError(void* arkode_mem); -int arkGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error); -int arkSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff); -int arkGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw); -int arkGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts); -int arkGetNumSteps(void* arkode_mem, long int* nsteps); -int arkGetActualInitStep(void* arkode_mem, sunrealtype* hinused); -int arkGetLastStep(void* arkode_mem, sunrealtype* hlast); -int arkGetCurrentStep(void* arkode_mem, sunrealtype* hcur); -int arkGetCurrentState(void* arkode_mem, N_Vector* ycur); -int arkGetCurrentTime(void* arkode_mem, sunrealtype* tcur); -int arkGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfac); -int arkGetErrWeights(void* arkode_mem, N_Vector eweight); -int arkGetResWeights(void* arkode_mem, N_Vector rweight); -int arkGetEstLocalErrors(void* arkode_mem, N_Vector ele); -int arkGetNumGEvals(void* arkode_mem, long int* ngevals); -int arkGetRootInfo(void* arkode_mem, int* rootsfound); -int arkGetNumConstrFails(void* arkode_mem, long int* nconstrfails); -int arkGetNumExpSteps(void* arkode_mem, long int* nsteps); -int arkGetNumAccSteps(void* arkode_mem, long int* nsteps); -int arkGetNumErrTestFails(void* arkode_mem, long int* netfails); -int arkGetNumStepSolveFails(void* arkode_mem, long int* nncfails); -int arkGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, - sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur); -int arkGetUserData(void* arkode_mem, void** user_data); -int arkPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); -char* arkGetReturnFlagName(long int flag); + This optional routine allows the stepper to optionally resize + any internal vector storage when ARKodeResize is called. -ARKODE_DIRKTableID arkButcherTableDIRKNameToID(const char* imethod); -ARKODE_ERKTableID arkButcherTableERKNameToID(const char* emethod); + --------------------------------------------------------------- -/* XBraid interface functions */ -int arkSetForcePass(void* arkode_mem, sunbooleantype force_pass); -int arkGetLastKFlag(void* arkode_mem, int* last_kflag); + ARKTimestepReset -/*=============================================================== - Reusable ARKODE Error Messages - ===============================================================*/ + This optional routine allows the stepper to reset any internal + data when ARKodeReset is called. -#if defined(SUNDIALS_EXTENDED_PRECISION) + --------------------------------------------------------------- -#define MSG_TIME "t = %Lg" -#define MSG_TIME_H "t = %Lg and h = %Lg" -#define MSG_TIME_INT "t = %Lg is not between tcur - hold = %Lg and tcur = %Lg." -#define MSG_TIME_TOUT "tout = %Lg" -#define MSG_TIME_TSTOP "tstop = %Lg" + ARKTimestepFree -#elif defined(SUNDIALS_DOUBLE_PRECISION) + This optional routine allows the stepper the free any + interally-stored memory when ARKodeFree is called. -#define MSG_TIME "t = %lg" -#define MSG_TIME_H "t = %lg and h = %lg" -#define MSG_TIME_INT "t = %lg is not between tcur - hold = %lg and tcur = %lg." -#define MSG_TIME_TOUT "tout = %lg" -#define MSG_TIME_TSTOP "tstop = %lg" + --------------------------------------------------------------- -#else + ARKTimestepPrintMem -#define MSG_TIME "t = %g" -#define MSG_TIME_H "t = %g and h = %g" -#define MSG_TIME_INT "t = %g is not between tcur - hold = %g and tcur = %g." -#define MSG_TIME_TOUT "tout = %g" -#define MSG_TIME_TSTOP "tstop = %g" + This optional routine allows the stepper to output any internal + memory (typically for debugging purposes) when ARKodePrintMem is + called. -#endif + --------------------------------------------------------------- -/* Initialization and I/O error messages */ -#define MSG_ARK_NO_MEM "arkode_mem = NULL illegal." -#define MSG_ARK_ARKMEM_FAIL "Allocation of arkode_mem failed." -#define MSG_ARK_MEM_FAIL "A memory request failed." -#define MSG_ARK_NO_MALLOC "Attempt to call before ARKodeInit." -#define MSG_ARK_BAD_HMIN_HMAX "Inconsistent step size limits: hmin > hmax." -#define MSG_ARK_BAD_RELTOL "reltol < 0 illegal." -#define MSG_ARK_BAD_ABSTOL "abstol has negative component(s) (illegal)." -#define MSG_ARK_NULL_ABSTOL "abstol = NULL illegal." -#define MSG_ARK_BAD_RABSTOL "rabstol has negative component(s) (illegal)." -#define MSG_ARK_NULL_RABSTOL "rabstol = NULL illegal." -#define MSG_ARK_NULL_Y0 "y0 = NULL illegal." -#define MSG_ARK_Y0_FAIL_CONSTR "y0 fails to satisfy constraints." -#define MSG_ARK_NULL_F "Must specify at least one of fe, fi (both NULL)." -#define MSG_ARK_NULL_G "g = NULL illegal." -#define MSG_ARK_BAD_NVECTOR "A required vector operation is not implemented." -#define MSG_ARK_BAD_CONSTR "Illegal values in constraints vector." -#define MSG_ARK_NULL_DKY "dky = NULL illegal." -#define MSG_ARK_BAD_T "Illegal value for t. " MSG_TIME_INT -#define MSG_ARK_NO_ROOT "Rootfinding was not initialized." + ARKTimestepSetDefaults -/* ARKODE Error Messages */ -#define MSG_ARK_YOUT_NULL "yout = NULL illegal." -#define MSG_ARK_TRET_NULL "tret = NULL illegal." -#define MSG_ARK_BAD_EWT "Initial ewt has component(s) equal to zero (illegal)." -#define MSG_ARK_EWT_NOW_BAD \ - "At " MSG_TIME ", a component of ewt has become <= 0." -#define MSG_ARK_BAD_RWT "Initial rwt has component(s) equal to zero (illegal)." -#define MSG_ARK_RWT_NOW_BAD \ - "At " MSG_TIME ", a component of rwt has become <= 0." -#define MSG_ARK_BAD_ITASK "Illegal value for itask." -#define MSG_ARK_BAD_H0 "h0 and tout - t0 inconsistent." -#define MSG_ARK_BAD_TOUT \ - "Trouble interpolating at " MSG_TIME_TOUT \ - ". tout too far back in direction of integration" -#define MSG_ARK_EWT_FAIL "The user-provide EwtSet function failed." -#define MSG_ARK_EWT_NOW_FAIL \ - "At " MSG_TIME ", the user-provide EwtSet function failed." -#define MSG_ARK_RWT_FAIL "The user-provide RwtSet function failed." -#define MSG_ARK_RWT_NOW_FAIL \ - "At " MSG_TIME ", the user-provide RwtSet function failed." -#define MSG_ARK_LINIT_FAIL "The linear solver's init routine failed." -#define MSG_ARK_HNIL_DONE \ - "The above warning has been issued mxhnil times and will not be issued " \ - "again for this problem." -#define MSG_ARK_TOO_CLOSE "tout too close to t0 to start integration." -#define MSG_ARK_MAX_STEPS \ - "At " MSG_TIME ", mxstep steps taken before reaching tout." -#define MSG_ARK_TOO_MUCH_ACC "At " MSG_TIME ", too much accuracy requested." -#define MSG_ARK_HNIL \ - "Internal " MSG_TIME_H " are such that t + h = t on the next step. The " \ - "solver will continue anyway." -#define MSG_ARK_ERR_FAILS \ - "At " MSG_TIME_H ", the error test failed repeatedly or with |h| = hmin." -#define MSG_ARK_CONV_FAILS \ - "At " MSG_TIME_H \ - ", the solver convergence test failed repeatedly or with |h| = hmin." -#define MSG_ARK_SETUP_FAILED \ - "At " MSG_TIME ", the setup routine failed in an unrecoverable manner." -#define MSG_ARK_SOLVE_FAILED \ - "At " MSG_TIME ", the solve routine failed in an unrecoverable manner." -#define MSG_ARK_FAILED_CONSTR \ - "At " MSG_TIME ", unable to satisfy inequality constraints." -#define MSG_ARK_RHSFUNC_FAILED \ - "At " MSG_TIME \ - ", the right-hand side routine failed in an unrecoverable manner." -#define MSG_ARK_RHSFUNC_UNREC \ - "At " MSG_TIME ", the right-hand side failed in a recoverable manner, but " \ - "no recovery is possible." -#define MSG_ARK_RHSFUNC_REPTD \ - "At " MSG_TIME " repeated recoverable right-hand side function errors." -#define MSG_ARK_RTFUNC_FAILED \ - "At " MSG_TIME ", the rootfinding routine failed in an unrecoverable " \ - "manner." -#define MSG_ARK_CLOSE_ROOTS "Root found at and very near " MSG_TIME "." -#define MSG_ARK_BAD_TSTOP \ - "The value " MSG_TIME_TSTOP " is behind current " MSG_TIME \ - " in the direction of integration." -#define MSG_ARK_INACTIVE_ROOTS \ - "At the end of the first step, there are still some root functions " \ - "identically 0. This warning will not be issued again." -#define MSG_ARK_RESIZE_FAIL "Error in user-supplied resize() function." -#define MSG_ARK_MASSINIT_FAIL "The mass matrix solver's init routine failed." -#define MSG_ARK_MASSSETUP_FAIL "The mass matrix solver's setup routine failed." -#define MSG_ARK_MASSSOLVE_FAIL "The mass matrix solver failed." -#define MSG_ARK_NLS_FAIL \ - "At " MSG_TIME " the nonlinear solver failed in an unrecoverable manner." -#define MSG_ARK_USER_PREDICT_FAIL \ - "At " MSG_TIME \ - " the user-supplied predictor failed in an unrecoverable manner." -#define MSG_ARKADAPT_NO_MEM "Adaptivity memory structure not allocated." -#define MSG_ARK_VECTOROP_ERR "At " MSG_TIME ", a vector operation failed." -#define MSG_ARK_INNERSTEP_FAILED \ - "At " MSG_TIME ", the inner stepper failed in an unrecoverable manner." -#define MSG_ARK_POSTPROCESS_STEP_FAIL \ - "At " MSG_TIME \ - ", the step postprocessing routine failed in an unrecoverable manner." -#define MSG_ARK_POSTPROCESS_STAGE_FAIL \ - "At " MSG_TIME \ - ", the stage postprocessing routine failed in an unrecoverable manner." -#define MSG_ARK_NULL_SUNCTX "sunctx = NULL illegal." -#define MSG_ARK_CONTEXT_MISMATCH \ - "Outer and inner steppers have different contexts." -#define MSG_ARK_MISSING_FULLRHS \ - "Time-stepping module missing fullrhs routine (required by requested " \ - "solver configuration)." -#define MSG_ARK_INTERPOLATION_FAIL \ - "At " MSG_TIME ", interpolating the solution failed." + This optional routine allows the stepper to reset any internal + solver parameters to their default values, and is called by + ARKodeSetDefaults. + + --------------------------------------------------------------- + + ARKTimestepSetOrder + + This optional routine allows the stepper to accept any user- + requested method order parameter that was passed to + ARKodeSetOrder. + + =============================================================== + + Internal Interface to Time Steppers -- Temporal Adaptivity + + These should only be provided if the stepper supports temporal + adaptivity, and should be indicated by setting the flag + "step_supports_adaptive" to SUNTRUE. + + --------------------------------------------------------------- + + ARKTimestepGetEstLocalErrors + + This routine requests the stepper to copy its internal + estimate of the local trunction error to the output (called by + ARKodeGetEstLocalErrors). + + =============================================================== + + Internal Interface to Time Steppers -- Relaxation + + These should only be provided if the stepper supports + "relaxation Runge--Kutta methods" (or similar), and should be + indicated by setting the flag "step_supports_relaxation" to SUNTRUE. + + --------------------------------------------------------------- + + ARKTimestepSetRelaxFn + + This routine is called by ARKodeSetRelaxFn, and expects the + stepper to call ARKODE's "arkRelaxCreate" routine with the + appropriate stepper-specific function pointers. + + =============================================================== + + Internal Interface to Time Steppers -- Implicit Solvers + + These should only be provided if the stepper uses implicit + linear/nonlinear solvers, and should be indicated by setting + the flag "step_supports_implicit" to SUNTRUE. + + --------------------------------------------------------------- + + ARKTimestepAttachLinsolFn + + This routine should attach the various set of system linear + solver interface routines, linear solver interface data + structure, and system linear solver type to the ARKODE time + stepping module pointed to in ark_mem->step_mem. This will + be called by the ARKODE linear solver interface. + + This routine should return 0 if it has successfully attached + these items and a negative value otherwise. If an error does + occur, an appropriate message should be sent to the ARKODE + error handler function. + + --------------------------------------------------------------- + + ARKTimestepDisableLSetup + + This routine should NULLify any ARKLinsolSetupFn function + pointer stored in the ARKODE time stepping module (initially set + in a call to ARKTimestepAttachLinsolFn). + + This routine has no return value. + + --------------------------------------------------------------- + + ARKTimestepGetLinMemFn + + This routine should return the linear solver memory structure + used by the ARKODE time stepping module pointed to in + ark_mem->step_mem. This will be called by the ARKODE linear + solver interface. + + This routine should return NULL if no linear solver memory + structure is attached. + + --------------------------------------------------------------- + + ARKTimestepGetImplicitRHSFn + + This routine should return the implicit RHS function pointer for + the current nonlinear solve (if there are multiple); it is used + inside the linear solver interfaces for approximation of + Jacobian matrix elements and/or matrix-vector products. + + This routine should return NULL if no implicit RHS function is + active. + + --------------------------------------------------------------- + + ARKTimestepGetGammasFn + + This routine should fill the current value of gamma, the ratio + of the current gamma value to the gamma value when the + Jacobian/preconditioner was last updated, a pointer to the + time step module internal sunbooleantype variable indicating + whether the preconditioner is current, and a logic value + indicating whether the gamma value is sufficiently stale + to cause recomputation of Jacobian/preconditioner data. Here, + gamma is the coefficient preceding the RHS Jacobian + matrix, J, in the full nonlinear system Jacobian, + A = M - gamma*J. + + The time step module must contain a sunbooleantype variable to + provide for the boolentype pointer (jcur). This is only used + by iterative linear solvers, so could be NULL for time step + modules that only work with direct linear solvers. Optionally, + the value of this parameter could be set to SUNFALSE prior to + return from the ARKTimestepGetGammasFn to force recalculation + of preconditioner information. + + The value of the logic flag is used as follows: if a previous + Newton iteration failed due to a bad Jacobian/preconditioner, + and this flag is SUNFALSE, this will trigger recalculation of + the Jacobian/preconditioner. + + This routine should return 0 if it has successfully attached + these items, and a negative value otherwise. If an error does + occur, an appropriate message should be sent to the ARKODE + error handler function. + + --------------------------------------------------------------- + + ARKTimestepComputeState + + This routine should combine any stepper-stored prediction with + the input correction to fill the current state vector within + an implicit solve (called by ARKodeComputeState). + + --------------------------------------------------------------- + + ARKTimestepSetNonlinearSolver + + This routine is called by ARKodeSetNonlinearSolver, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetLinear + + This routine is called by ARKodeSetLinear, and allows the + stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetNonlinear + + This routine is called by ARKodeSetNonlinear, and allows the + stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetNlsRhsFn + + This routine is called by ARKodeSetNlsRhsFn, and allows the + stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetDeduceImplicitRhs + + This routine is called by ARKodeSetDeduceImplicitRhs, and + allows the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetNonlinCRDown + + This routine is called by ARKodeSetNonlinCRDown, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetNonlinRDiv + + This routine is called by ARKodeSetNonlinRDiv, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetDeltaGammaMax + + This routine is called by ARKodeSetDeltaGammaMax, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetLSetupFrequency + + This routine is called by ARKodeSetLSetupFrequency, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetPredictorMethod + + This routine is called by ARKodeSetPredictorMethod, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetMaxNonlinIters + + This routine is called by ARKodeSetMaxNonlinIters, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetNonlinConvCoef + + This routine is called by ARKodeSetNonlinConvCoef, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepSetStagePredictFn + + This routine is called by ARKodeSetStagePredictFn, and allows + the stepper to store the corresponding user input. + + --------------------------------------------------------------- + + ARKTimestepGetNumLinSolvSetups + + This routine is called by ARKodeGetNumLinSolvSetups, and + requests that the stepper return the corresponding output + value. + + --------------------------------------------------------------- + + ARKTimestepGetCurrentGamma + + This routine is called by ARKodeGetCurrentGamma, and + requests that the stepper return the corresponding output + value. + + --------------------------------------------------------------- + + ARKTimestepGetNonlinearSystemData + + This routine is called by ARKodeGetNonlinearSystemData, and + requests that the stepper return the corresponding output + values. + + --------------------------------------------------------------- + + ARKTimestepGetNumNonlinSolvIters + + This routine is called by ARKodeGetNumNonlinSolvIters, and + requests that the stepper return the corresponding output + value. + + --------------------------------------------------------------- + + ARKTimestepGetNumNonlinSolvConvFails + + This routine is called by ARKodeGetNumNonlinSolvConvFails, and + requests that the stepper return the corresponding output + value. + + --------------------------------------------------------------- + + ARKTimestepGetNonlinSolvStats + + This routine is called by ARKodeGetNonlinSolvStats, and + requests that the stepper return the corresponding output + values. + + =============================================================== + + Internal Interface to Time Steppers -- Non-identity Mass + Matrices + + These should only be provided if the stepper supports problems + with non-identity mass matrices, and should be indicated by + setting the flag "step_supports_massmatrix" to SUNTRUE. + + --------------------------------------------------------------- + + ARKTimestepAttachMasssolFn + + This routine should attach the various set of mass matrix + linear solver interface routines, data structure, mass matrix + type, and solver type to the ARKODE time stepping module + pointed to in ark_mem->step_mem. This will be called by the + ARKODE linear solver interface. + + This routine should return 0 if it has successfully attached + these items, and a negative value otherwise. If an error does + occur, an appropriate message should be sent to the ARKODE + error handler function. + + --------------------------------------------------------------- + + ARKTimestepDisableMSetup + + This routine should NULLify any ARKMassSetupFn function pointer + stored in the ARKODE time stepping module (initially set in a + call to ARKTimestepAttachMasssolFn). + + This routine has no return value. + + --------------------------------------------------------------- + + ARKTimestepGetMassMemFn + + This routine should return the mass matrix linear solver memory + structure used by the ARKODE time stepping module pointed to in + ark_mem->step_mem. This will be called the ARKODE mass matrix + solver interface. + + This routine should return NULL if no mass matrix solver memory + structure is attached. + + ===============================================================*/ #ifdef __cplusplus } diff --git a/src/arkode/arkode_interp.c b/src/arkode/arkode_interp.c index c481e465df..2d61283c7a 100644 --- a/src/arkode/arkode_interp.c +++ b/src/arkode/arkode_interp.c @@ -31,19 +31,19 @@ interpolation modules ---------------------------------------------------------------*/ -int arkInterpResize(void* arkode_mem, ARKInterp interp, ARKVecResizeFn resize, +int arkInterpResize(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->resize(arkode_mem, interp, resize, resize_data, + return ((int)interp->ops->resize(ark_mem, interp, resize, resize_data, lrw_diff, liw_diff, tmpl)); } -void arkInterpFree(void* arkode_mem, ARKInterp interp) +void arkInterpFree(ARKodeMem ark_mem, ARKInterp interp) { if (interp == NULL) { return; } - interp->ops->free(arkode_mem, interp); + interp->ops->free(ark_mem, interp); return; } @@ -54,29 +54,29 @@ void arkInterpPrintMem(ARKInterp interp, FILE* outfile) return; } -int arkInterpSetDegree(void* arkode_mem, ARKInterp interp, int degree) +int arkInterpSetDegree(ARKodeMem ark_mem, ARKInterp interp, int degree) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->setdegree(arkode_mem, interp, degree)); + return ((int)interp->ops->setdegree(ark_mem, interp, degree)); } -int arkInterpInit(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpInit(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->init(arkode_mem, interp, tnew)); + return ((int)interp->ops->init(ark_mem, interp, tnew)); } -int arkInterpUpdate(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpUpdate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->update(arkode_mem, interp, tnew)); + return ((int)interp->ops->update(ark_mem, interp, tnew)); } -int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, sunrealtype tau, +int arkInterpEvaluate(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout) { if (interp == NULL) { return (ARK_SUCCESS); } - return ((int)interp->ops->evaluate(arkode_mem, interp, tau, d, order, yout)); + return ((int)interp->ops->evaluate(ark_mem, interp, tau, d, order, yout)); } /*--------------------------------------------------------------- @@ -90,16 +90,11 @@ int arkInterpEvaluate(void* arkode_mem, ARKInterp interp, sunrealtype tau, cloning an input template N_Vector. This returns a non-NULL structure if no errors occurred, or a NULL value otherwise. ---------------------------------------------------------------*/ -ARKInterp arkInterpCreate_Hermite(void* arkode_mem, int degree) +ARKInterp arkInterpCreate_Hermite(ARKodeMem ark_mem, int degree) { ARKInterp interp; ARKInterpContent_Hermite content; ARKInterpOps ops; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* check for valid degree */ if (degree < 0 || degree > ARK_INTERP_MAX_DEGREE) { return (NULL); } @@ -168,17 +163,11 @@ ARKInterp arkInterpCreate_Hermite(void* arkode_mem, int degree) This routine resizes the internal vectors. ---------------------------------------------------------------*/ -int arkInterpResize_Hermite(void* arkode_mem, ARKInterp interp, +int arkInterpResize_Hermite(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector y0) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* resize vectors */ if (interp == NULL) { return (ARK_SUCCESS); } @@ -219,14 +208,8 @@ int arkInterpResize_Hermite(void* arkode_mem, ARKInterp interp, This routine frees the Hermite ARKInterp structure. ---------------------------------------------------------------*/ -void arkInterpFree_Hermite(void* arkode_mem, ARKInterp interp) +void arkInterpFree_Hermite(ARKodeMem ark_mem, ARKInterp interp) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; - /* if interpolation structure is NULL, just return */ if (interp == NULL) { return; } @@ -321,20 +304,13 @@ void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile) polynomial]. Return values: - ARK_MEM_NULL -- if either arkode_mem or interp are NULL ARK_ILL_INPUT -- if the input is outside of allowable bounds ARK_INTERP_FAIL -- if the interpolation module has already been initialized, ARK_SUCCESS -- successful completion. ---------------------------------------------------------------*/ -int arkInterpSetDegree_Hermite(void* arkode_mem, ARKInterp interp, int degree) +int arkInterpSetDegree_Hermite(ARKodeMem ark_mem, ARKInterp interp, int degree) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* if this degree is already stored, just return */ if (abs(degree) == HINT_DEGREE(interp)) { return (ARK_SUCCESS); } @@ -370,14 +346,8 @@ int arkInterpSetDegree_Hermite(void* arkode_mem, ARKInterp interp, int degree) 4. Calls the full RHS routine to fill fnew 5. Copies fnew into fold ---------------------------------------------------------------*/ -int arkInterpInit_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpInit_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* initialize time values */ HINT_TOLD(interp) = tnew; HINT_TNEW(interp) = tnew; @@ -430,14 +400,9 @@ int arkInterpInit_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew) This routine copies ynew into yold, and fnew into fold, so that yold and fold contain the previous values. ---------------------------------------------------------------*/ -int arkInterpUpdate_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew) +int arkInterpUpdate_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew) { int retval; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* call full RHS if needed -- called just BEFORE the end of a step, so yn has NOT been updated to ycur yet */ @@ -491,7 +456,7 @@ int arkInterpUpdate_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew where h = tnew-told, i.e. values -1 ARK_INTERP_MAX_DEGREE) { return (NULL); } @@ -932,16 +887,12 @@ ARKInterp arkInterpCreate_Lagrange(void* arkode_mem, int degree) This routine resizes the internal vectors. ---------------------------------------------------------------*/ -int arkInterpResize_Lagrange(void* arkode_mem, ARKInterp I, ARKVecResizeFn resize, - void* resize_data, sunindextype lrw_diff, - sunindextype liw_diff, N_Vector y0) +int arkInterpResize_Lagrange(ARKodeMem ark_mem, ARKInterp I, + ARKVecResizeFn resize, void* resize_data, + sunindextype lrw_diff, sunindextype liw_diff, + N_Vector y0) { int i; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* resize vectors */ if (I == NULL) { return (ARK_SUCCESS); } @@ -968,14 +919,9 @@ int arkInterpResize_Lagrange(void* arkode_mem, ARKInterp I, ARKVecResizeFn resiz This routine frees the Lagrange ARKInterp structure. ---------------------------------------------------------------*/ -void arkInterpFree_Lagrange(void* arkode_mem, ARKInterp I) +void arkInterpFree_Lagrange(ARKodeMem ark_mem, ARKInterp I) { int i; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return; } - ark_mem = (ARKodeMem)arkode_mem; /* if interpolation structure is NULL, just return */ if (I == NULL) { return; } @@ -1083,20 +1029,13 @@ void arkInterpPrintMem_Lagrange(ARKInterp I, FILE* outfile) polynomial]. Return values: - ARK_MEM_NULL -- if either arkode_mem or interp are NULL ARK_ILL_INPUT -- if the input is outside of allowable bounds ARK_INTERP_FAIL -- if the interpolation module has already been initialized, ARK_SUCCESS -- successful completion. ---------------------------------------------------------------*/ -int arkInterpSetDegree_Lagrange(void* arkode_mem, ARKInterp I, int degree) +int arkInterpSetDegree_Lagrange(ARKodeMem ark_mem, ARKInterp I, int degree) { - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* if this degree is already stored, just return */ if (abs(degree) + 1 == LINT_NMAX(I)) { return (ARK_SUCCESS); } @@ -1131,14 +1070,9 @@ int arkInterpSetDegree_Lagrange(void* arkode_mem, ARKInterp I, int degree) 3. copies current (t,y) from main ARKODE memory into history 4. updates the 'active' history counter to 1 ---------------------------------------------------------------*/ -int arkInterpInit_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) +int arkInterpInit_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tnew) { int i; - ARKodeMem ark_mem; - - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; /* check if storage has increased since the last init */ if (LINT_NMAX(I) > LINT_NMAXALLOC(I)) @@ -1224,20 +1158,15 @@ int arkInterpInit_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) into the first history vector Otherwise it just returns with success. ---------------------------------------------------------------*/ -int arkInterpUpdate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) +int arkInterpUpdate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tnew) { int i; - ARKodeMem ark_mem; sunrealtype tdiff; N_Vector ytmp; int nhist, nmax; sunrealtype* thist; N_Vector* yhist; - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* set readability shortcuts */ nhist = LINT_NHIST(I); nmax = LINT_NMAX(I); @@ -1298,7 +1227,7 @@ int arkInterpUpdate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tnew) fixed step sizes, otherwise the stated lower bound is only approximate). ---------------------------------------------------------------*/ -int arkInterpEvaluate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tau, +int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp I, sunrealtype tau, int deriv, int degree, N_Vector yout) { /* local variables */ @@ -1306,15 +1235,10 @@ int arkInterpEvaluate_Lagrange(void* arkode_mem, ARKInterp I, sunrealtype tau, sunrealtype tval; sunrealtype a[6]; N_Vector X[6]; - ARKodeMem ark_mem; int nhist; sunrealtype* thist; N_Vector* yhist; - /* access ARKodeMem structure */ - if (arkode_mem == NULL) { return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - /* set readability shortcuts */ nhist = LINT_NHIST(I); thist = LINT_THIST(I); diff --git a/src/arkode/arkode_interp_impl.h b/src/arkode/arkode_interp_impl.h index 502817746e..9bbe3dd505 100644 --- a/src/arkode/arkode_interp_impl.h +++ b/src/arkode/arkode_interp_impl.h @@ -71,18 +71,18 @@ typedef struct _ARKInterpContent_Hermite* ARKInterpContent_Hermite; /* Hermite structure operations */ -ARKInterp arkInterpCreate_Hermite(void* arkode_mem, int degree); - -int arkInterpResize_Hermite(void* arkode_mem, ARKInterp interp, +ARKInterp arkInterpCreate_Hermite(ARKodeMem ark_mem, int degree); +int arkInterpResize_Hermite(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); -void arkInterpFree_Hermite(void* arkode_mem, ARKInterp interp); +void arkInterpFree_Hermite(ARKodeMem ark_mem, ARKInterp interp); void arkInterpPrintMem_Hermite(ARKInterp interp, FILE* outfile); -int arkInterpSetDegree_Hermite(void* arkode_mem, ARKInterp interp, int degree); -int arkInterpInit_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpUpdate_Hermite(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpEvaluate_Hermite(void* arkode_mem, ARKInterp interp, +int arkInterpSetDegree_Hermite(ARKodeMem ark_mem, ARKInterp interp, int degree); +int arkInterpInit_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpUpdate_Hermite(ARKodeMem ark_mem, ARKInterp interp, + sunrealtype tnew); +int arkInterpEvaluate_Hermite(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); /*=============================================================== @@ -117,19 +117,18 @@ typedef struct _ARKInterpContent_Lagrange* ARKInterpContent_Lagrange; /* Lagrange structure operations */ -ARKInterp arkInterpCreate_Lagrange(void* arkode_mem, int degree); - -int arkInterpResize_Lagrange(void* arkode_mem, ARKInterp interp, +ARKInterp arkInterpCreate_Lagrange(ARKodeMem ark_mem, int degree); +int arkInterpResize_Lagrange(ARKodeMem ark_mem, ARKInterp interp, ARKVecResizeFn resize, void* resize_data, sunindextype lrw_diff, sunindextype liw_diff, N_Vector tmpl); -void arkInterpFree_Lagrange(void* arkode_mem, ARKInterp interp); +void arkInterpFree_Lagrange(ARKodeMem ark_mem, ARKInterp interp); void arkInterpPrintMem_Lagrange(ARKInterp interp, FILE* outfile); -int arkInterpSetDegree_Lagrange(void* arkode_mem, ARKInterp interp, int degree); -int arkInterpInit_Lagrange(void* arkode_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpUpdate_Lagrange(void* arkode_mem, ARKInterp interp, +int arkInterpSetDegree_Lagrange(ARKodeMem ark_mem, ARKInterp interp, int degree); +int arkInterpInit_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); +int arkInterpUpdate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tnew); -int arkInterpEvaluate_Lagrange(void* arkode_mem, ARKInterp interp, +int arkInterpEvaluate_Lagrange(ARKodeMem ark_mem, ARKInterp interp, sunrealtype tau, int d, int order, N_Vector yout); /* Lagrange structure utility routines */ diff --git a/src/arkode/arkode_io.c b/src/arkode/arkode_io.c index 54898ed866..9cd68a76d2 100644 --- a/src/arkode/arkode_io.c +++ b/src/arkode/arkode_io.c @@ -30,11 +30,11 @@ #include "arkode_user_controller.h" /*=============================================================== - ARKODE optional input utility functions + ARKODE optional input functions ===============================================================*/ /*--------------------------------------------------------------- - arkSetDefaults: + ARKodeSetDefaults: Resets all optional inputs to ARKODE default values. Does not change problem-defining function pointers fe and fi or @@ -42,9 +42,10 @@ structures/options related to root-finding (those can be reset using ARKodeRootInit) or post-processing a step (ProcessStep). ---------------------------------------------------------------*/ -int arkSetDefaults(void* arkode_mem) +int ARKodeSetDefaults(void* arkode_mem) { ARKodeMem ark_mem; + int retval; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -53,6 +54,13 @@ int arkSetDefaults(void* arkode_mem) } ark_mem = (ARKodeMem)arkode_mem; + /* Set stepper defaults (if provided) */ + if (ark_mem->step_setdefaults) + { + retval = ark_mem->step_setdefaults(arkode_mem); + if (retval != ARK_SUCCESS) { return retval; } + } + /* Set default values for integrator optional inputs */ ark_mem->use_compensated_sums = SUNFALSE; ark_mem->fixedstep = SUNFALSE; /* default to use adaptive steps */ @@ -101,7 +109,37 @@ int arkSetDefaults(void* arkode_mem) } /*--------------------------------------------------------------- - arkSetInterpolantType: + ARKodeSetOrder: + + Specifies the method order + ---------------------------------------------------------------*/ +int ARKodeSetOrder(void* arkode_mem, int ord) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Call stepper routine (if provided) */ + if (ark_mem->step_setorder) + { + return (ark_mem->step_setorder(arkode_mem, ord)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } +} + +/*--------------------------------------------------------------- + ARKodeSetInterpolantType: Specifies use of the Lagrange or Hermite interpolation modules. itype == ARK_INTERP_HERMITE specifies the Hermite (nonstiff) @@ -115,7 +153,7 @@ int arkSetDefaults(void* arkode_mem) ARK_MEM_FAIL if the interpolation module cannot be allocated. ARK_ILL_INPUT if the itype argument is not recognized. ---------------------------------------------------------------*/ -int arkSetInterpolantType(void* arkode_mem, int itype) +int ARKodeSetInterpolantType(void* arkode_mem, int itype) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -177,7 +215,7 @@ int arkSetInterpolantType(void* arkode_mem, int itype) } /*--------------------------------------------------------------- - arkSetInterpolantDegree: + ARKodeSetInterpolantDegree: Specifies the polynomial degree for the dense output interpolation module. @@ -190,7 +228,7 @@ int arkSetInterpolantType(void* arkode_mem, int itype) initialized. ARK_ILL_INPUT if the degree is illegal. ---------------------------------------------------------------*/ -int arkSetInterpolantDegree(void* arkode_mem, int degree) +int ARKodeSetInterpolantDegree(void* arkode_mem, int degree) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -217,15 +255,17 @@ int arkSetInterpolantDegree(void* arkode_mem, int degree) } /* pass 'degree' to interpolation module, returning its value */ + if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; } return (arkInterpSetDegree(ark_mem, ark_mem->interp, degree)); } /*--------------------------------------------------------------- - arkSetUserData: + ARKodeSetNonlinearSolver: - Specifies the user data pointer for f + This routine attaches a SUNNonlinearSolver object to the + time-stepping module. ---------------------------------------------------------------*/ -int arkSetUserData(void* arkode_mem, void* user_data) +int ARKodeSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -234,35 +274,47 @@ int arkSetUserData(void* arkode_mem, void* user_data) MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - ark_mem->user_data = user_data; - - /* Set data for efun */ - if (ark_mem->user_efun) { ark_mem->e_data = user_data; } - - /* Set data for rfun */ - if (ark_mem->user_rfun) { ark_mem->r_data = user_data; } - - /* Set data for root finding */ - if (ark_mem->root_mem != NULL) { ark_mem->root_mem->root_data = user_data; } + ark_mem = (ARKodeMem)arkode_mem; - /* Set data for post-processing a step */ - if (ark_mem->ProcessStep != NULL) { ark_mem->ps_data = user_data; } + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } - return (ARK_SUCCESS); + /* Call stepper routine (if provided) */ + if (ark_mem->step_setnonlinearsolver) + { + return (ark_mem->step_setnonlinearsolver(arkode_mem, NLS)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetAdaptController: + ARKodeSetLinear: - Specifies a non-default SUNAdaptController time step controller - object. If a NULL-valued SUNAdaptController is input, the - default will be re-enabled. + Specifies that the implicit portion of the problem is linear, + and to tighten the linear solver tolerances while taking only + one Newton iteration. DO NOT USE IN COMBINATION WITH THE + FIXED-POINT SOLVER. Automatically tightens DeltaGammaMax + to ensure that step size changes cause Jacobian recomputation. + + The argument should be 1 or 0, where 1 indicates that the + Jacobian of fi with respect to y depends on time, and + 0 indicates that it is not time dependent. Alternately, when + using an iterative linear solver this flag denotes time + dependence of the preconditioner. ---------------------------------------------------------------*/ -int arkSetAdaptController(void* arkode_mem, SUNAdaptController C) +int ARKodeSetLinear(void* arkode_mem, int timedepend) { - int retval; - long int lenrw, leniw; ARKodeMem ark_mem; if (arkode_mem == NULL) { @@ -272,60 +324,35 @@ int arkSetAdaptController(void* arkode_mem, SUNAdaptController C) } ark_mem = (ARKodeMem)arkode_mem; - /* Remove current SUNAdaptController object - (delete if owned, and then nullify pointer) */ - retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, - &leniw); - if (retval == SUN_SUCCESS) - { - ark_mem->liw -= leniw; - ark_mem->lrw -= lenrw; - } - if (ark_mem->hadapt_mem->owncontroller) + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); - ark_mem->hadapt_mem->owncontroller = SUNFALSE; - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_Destroy failure"); - return (ARK_MEM_FAIL); - } + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); } - ark_mem->hadapt_mem->hcontroller = NULL; - /* On NULL-valued input, create default SUNAdaptController object */ - if (C == NULL) + /* Call stepper routine (if provided) */ + if (ark_mem->step_setlinear) { - C = SUNAdaptController_PID(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptControllerPID allocation failure"); - return (ARK_MEM_FAIL); - } - ark_mem->hadapt_mem->owncontroller = SUNTRUE; + return (ark_mem->step_setlinear(arkode_mem, timedepend)); } - else { ark_mem->hadapt_mem->owncontroller = SUNFALSE; } - - /* Attach new SUNAdaptController object */ - retval = SUNAdaptController_Space(C, &lenrw, &leniw); - if (retval == SUN_SUCCESS) + else { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); } - ark_mem->hadapt_mem->hcontroller = C; - - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxNumSteps: + ARKodeSetNonlinear: - Specifies the maximum number of integration steps + Specifies that the implicit portion of the problem is nonlinear. + Used to undo a previous call to ARKodeSetLinear. ---------------------------------------------------------------*/ -int arkSetMaxNumSteps(void* arkode_mem, long int mxsteps) +int ARKodeSetNonlinear(void* arkode_mem) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -336,19 +363,36 @@ int arkSetMaxNumSteps(void* arkode_mem, long int mxsteps) } ark_mem = (ARKodeMem)arkode_mem; - /* Passing mxsteps=0 sets the default. Passing mxsteps<0 disables the test. */ - if (mxsteps == 0) { ark_mem->mxstep = MXSTEP_DEFAULT; } - else { ark_mem->mxstep = mxsteps; } + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } - return (ARK_SUCCESS); + /* Call stepper routine (if provided) */ + if (ark_mem->step_setnonlinear) + { + return (ark_mem->step_setnonlinear(arkode_mem)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetMaxHnilWarns: + ARKodeSetNlsRhsFn: - Specifies the maximum number of warnings for small h + This routine sets an alternative user-supplied implicit ODE + right-hand side function to use in the evaluation of nonlinear + system functions. ---------------------------------------------------------------*/ -int arkSetMaxHnilWarns(void* arkode_mem, int mxhnil) +int ARKodeSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -359,22 +403,43 @@ int arkSetMaxHnilWarns(void* arkode_mem, int mxhnil) } ark_mem = (ARKodeMem)arkode_mem; - /* Passing mxhnil=0 sets the default, otherwise use input. */ - if (mxhnil == 0) { ark_mem->mxhnil = 10; } - else { ark_mem->mxhnil = mxhnil; } + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } - return (ARK_SUCCESS); + /* Call stepper routine (if provided) */ + if (ark_mem->step_setnlsrhsfn) + { + return (ark_mem->step_setnlsrhsfn(arkode_mem, nls_fi)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetInitStep: + ARKodeSetDeduceImplicitRhs: - Specifies the initial step size + Specifies if an optimization is used to avoid an evaluation of + fi after a nonlinear solve for an implicit stage. If stage + postprocessecing in enabled, this option is ignored, and the + RHS is never deduced. + + An argument of SUNTRUE indicates that the RHS should be deduced, + and SUNFALSE indicates that the RHS should be computed with + an additional evaluation. ---------------------------------------------------------------*/ -int arkSetInitStep(void* arkode_mem, sunrealtype hin) +int ARKodeSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) { ARKodeMem ark_mem; - int retval; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -383,26 +448,36 @@ int arkSetInitStep(void* arkode_mem, sunrealtype hin) } ark_mem = (ARKodeMem)arkode_mem; - /* Passing hin=0 sets the default, otherwise use input. */ - if (hin == ZERO) { ark_mem->hin = ZERO; } - else { ark_mem->hin = hin; } - - /* Clear previous initial step */ - ark_mem->h0u = ZERO; - - /* Reset error controller (e.g., error and step size history) */ - retval = SUNAdaptController_Reset(ark_mem->hadapt_mem->hcontroller); - if (retval != SUN_SUCCESS) { return (ARK_CONTROLLER_ERR); } + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } - return (ARK_SUCCESS); + /* Call stepper routine (if provided) */ + if (ark_mem->step_setdeduceimplicitrhs) + { + return (ark_mem->step_setdeduceimplicitrhs(arkode_mem, deduce)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetMinStep: + ARKodeSetNonlinCRDown: - Specifies the minimum step size + Specifies the user-provided nonlinear convergence constant + crdown. Legal values are strictly positive; illegal values + imply a reset to the default. ---------------------------------------------------------------*/ -int arkSetMinStep(void* arkode_mem, sunrealtype hmin) +int ARKodeSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -413,35 +488,37 @@ int arkSetMinStep(void* arkode_mem, sunrealtype hmin) } ark_mem = (ARKodeMem)arkode_mem; - /* Passing a value <= 0 sets hmin = 0 */ - if (hmin <= ZERO) + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - ark_mem->hmin = ZERO; - return (ARK_SUCCESS); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); } - /* check that hmin and hmax are agreeable */ - if (hmin * ark_mem->hmax_inv > ONE) + /* Call stepper routine (if provided) */ + if (ark_mem->step_setnonlincrdown) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_HMIN_HMAX); - return (ARK_ILL_INPUT); + return (ark_mem->step_setnonlincrdown(arkode_mem, crdown)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); } - - /* set the value */ - ark_mem->hmin = hmin; - - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxStep: + ARKodeSetNonlinRDiv: - Specifies the maximum step size + Specifies the user-provided nonlinear convergence constant + rdiv. Legal values are strictly positive; illegal values + imply a reset to the default. ---------------------------------------------------------------*/ -int arkSetMaxStep(void* arkode_mem, sunrealtype hmax) +int ARKodeSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) { - sunrealtype hmax_inv; ARKodeMem ark_mem; if (arkode_mem == NULL) { @@ -451,34 +528,36 @@ int arkSetMaxStep(void* arkode_mem, sunrealtype hmax) } ark_mem = (ARKodeMem)arkode_mem; - /* Passing a value <= 0 sets hmax = infinity */ - if (hmax <= ZERO) + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - ark_mem->hmax_inv = ZERO; - return (ARK_SUCCESS); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); } - /* check that hmax and hmin are agreeable */ - hmax_inv = ONE / hmax; - if (hmax_inv * ark_mem->hmin > ONE) + /* Call stepper routine (if provided) */ + if (ark_mem->step_setnonlinrdiv) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_HMIN_HMAX); - return (ARK_ILL_INPUT); + return (ark_mem->step_setnonlinrdiv(arkode_mem, rdiv)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); } - - /* set the value */ - ark_mem->hmax_inv = hmax_inv; - - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetStopTime: + ARKodeSetDeltaGammaMax: - Specifies the time beyond which the integration is not to proceed. + Specifies the user-provided linear setup decision constant + dgmax. Legal values are strictly positive; illegal values imply + a reset to the default. ---------------------------------------------------------------*/ -int arkSetStopTime(void* arkode_mem, sunrealtype tstop) +int ARKodeSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -489,33 +568,37 @@ int arkSetStopTime(void* arkode_mem, sunrealtype tstop) } ark_mem = (ARKodeMem)arkode_mem; - /* If ARKODE was called at least once, test if tstop is legal - (i.e. if it was not already passed). - If arkSetStopTime is called before the first call to ARKODE, - tstop will be checked in ARKODE. */ - if (ark_mem->nst > 0) + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - if ((tstop - ark_mem->tcur) * ark_mem->h < ZERO) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_TSTOP, tstop, ark_mem->tcur); - return (ARK_ILL_INPUT); - } + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); } - ark_mem->tstop = tstop; - ark_mem->tstopset = SUNTRUE; - - return (ARK_SUCCESS); + /* Call stepper routine (if provided) */ + if (ark_mem->step_setdeltagammamax) + { + return (ark_mem->step_setdeltagammamax(arkode_mem, dgmax)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetInterpolateStopTime: + ARKodeSetLSetupFrequency: - Specifies to use interpolation to fill the solution output at - the stop time (instead of a copy). + Specifies the user-provided linear setup decision constant + msbp. Positive values give the frequency for calling lsetup; + negative values imply recomputation of lsetup at each nonlinear + solve; a zero value implies a reset to the default. ---------------------------------------------------------------*/ -int arkSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) +int ARKodeSetLSetupFrequency(void* arkode_mem, int msbp) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -524,17 +607,36 @@ int arkSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - ark_mem->tstopinterp = interp; - return (ARK_SUCCESS); + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Call stepper routine (if provided) */ + if (ark_mem->step_setlsetupfrequency) + { + return (ark_mem->step_setlsetupfrequency(arkode_mem, msbp)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkClearStopTime: + ARKodeSetPredictorMethod: - Disable the stop time. + Specifies the method to use for predicting implicit solutions. ---------------------------------------------------------------*/ -int arkClearStopTime(void* arkode_mem) +int ARKodeSetPredictorMethod(void* arkode_mem, int pred_method) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -545,28 +647,37 @@ int arkClearStopTime(void* arkode_mem) } ark_mem = (ARKodeMem)arkode_mem; - ark_mem->tstopset = SUNFALSE; + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } - return (ARK_SUCCESS); + /* Call stepper routine (if provided) */ + if (ark_mem->step_setpredictormethod) + { + return (ark_mem->step_setpredictormethod(arkode_mem, pred_method)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetFixedStep: - - Specifies to use a fixed time step size instead of performing - any form of temporal adaptivity. ARKODE will use this step size - for all steps (unless tstop is set, in which case it may need to - modify that last step approaching tstop. If any solver failure - occurs in the timestepping module, ARKODE will typically - immediately return with an error message indicating that the - selected step size cannot be used. + ARKodeSetMaxNonlinIters: - Any nonzero argument will result in the use of that fixed step - size; an argument of 0 will re-enable temporal adaptivity. + Specifies the maximum number of nonlinear iterations during + one solve. A non-positive input implies a reset to the + default value. ---------------------------------------------------------------*/ -int arkSetFixedStep(void* arkode_mem, sunrealtype hfixed) +int ARKodeSetMaxNonlinIters(void* arkode_mem, int maxcor) { - int retval; ARKodeMem ark_mem; if (arkode_mem == NULL) { @@ -576,46 +687,37 @@ int arkSetFixedStep(void* arkode_mem, sunrealtype hfixed) } ark_mem = (ARKodeMem)arkode_mem; - /* re-attach internal error weight functions if necessary */ - if ((hfixed == ZERO) && (!ark_mem->user_efun)) + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) - { - retval = arkSVtolerances(ark_mem, ark_mem->reltol, ark_mem->Vabstol); - } - else - { - retval = arkSStolerances(ark_mem, ark_mem->reltol, ark_mem->Sabstol); - } - if (retval != ARK_SUCCESS) { return (retval); } + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); } - /* set ark_mem "fixedstep" entry */ - if (hfixed != ZERO) + /* Call stepper routine (if provided) */ + if (ark_mem->step_setmaxnonliniters) { - ark_mem->fixedstep = SUNTRUE; - ark_mem->hin = hfixed; + return (ark_mem->step_setmaxnonliniters(arkode_mem, maxcor)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); } - else { ark_mem->fixedstep = SUNFALSE; } - - /* Notify ARKODE to use hfixed as the initial step size, and return */ - retval = arkSetInitStep(arkode_mem, hfixed); - - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetRootDirection: + ARKodeSetNonlinConvCoef: - Specifies the direction of zero-crossings to be monitored. - The default is to monitor both crossings. + Specifies the coefficient in the nonlinear solver convergence + test. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int arkSetRootDirection(void* arkode_mem, int* rootdir) +int ARKodeSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) { ARKodeMem ark_mem; - ARKodeRootMem ark_root_mem; - int i; - if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -623,37 +725,37 @@ int arkSetRootDirection(void* arkode_mem, int* rootdir) return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; - if (ark_mem->root_mem == NULL) + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); } - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - if (ark_root_mem->nrtfn == 0) + /* Call stepper routine (if provided) */ + if (ark_mem->step_setnonlinconvcoef) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_NO_ROOT); - return (ARK_ILL_INPUT); + return (ark_mem->step_setnonlinconvcoef(arkode_mem, nlscoef)); } - for (i = 0; i < ark_root_mem->nrtfn; i++) + else { - ark_root_mem->rootdir[i] = rootdir[i]; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); } - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetNoInactiveRootWarn: - - Disables issuing a warning if some root function appears - to be identically zero at the beginning of the integration + ARKodeSetStagePredictFn: Specifies a user-provided step + predictor function having type ARKStagePredictFn. A + NULL input function disables calls to this routine. ---------------------------------------------------------------*/ -int arkSetNoInactiveRootWarn(void* arkode_mem) +int ARKodeSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) { ARKodeMem ark_mem; - ARKodeRootMem ark_root_mem; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -661,30 +763,78 @@ int arkSetNoInactiveRootWarn(void* arkode_mem) return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; - if (ark_mem->root_mem == NULL) + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Call stepper routine (if provided) */ + if (ark_mem->step_setstagepredictfn) + { + return (ark_mem->step_setstagepredictfn(arkode_mem, PredictStage)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } +} + +/*--------------------------------------------------------------- + ARKodeSetUserData: + + Specifies the user data pointer for f + ---------------------------------------------------------------*/ +int ARKodeSetUserData(void* arkode_mem, void* user_data) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - ark_root_mem->mxgnull = 0; + ark_mem = (ARKodeMem)arkode_mem; + ark_mem->user_data = user_data; + + /* Set data for efun */ + if (ark_mem->user_efun) { ark_mem->e_data = user_data; } + + /* Set data for rfun */ + if (ark_mem->user_rfun) { ark_mem->r_data = user_data; } + + /* Set data for root finding */ + if (ark_mem->root_mem != NULL) { ark_mem->root_mem->root_data = user_data; } + + /* Set data for post-processing a step */ + if (ark_mem->ProcessStep != NULL) { ark_mem->ps_data = user_data; } + + /* Set user data into stepper (if provided) */ + if (ark_mem->step_setuserdata) + { + return (ark_mem->step_setuserdata(arkode_mem, user_data)); + } + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetPostprocessStepFn: - - Specifies a user-provided step postprocessing function having - type ARKPostProcessFn. A NULL input function disables step - postprocessing. + ARKodeSetAdaptController: - IF THE SUPPLIED FUNCTION MODIFIES ANY OF THE ACTIVE STATE DATA, - THEN ALL THEORETICAL GUARANTEES OF SOLUTION ACCURACY AND - STABILITY ARE LOST. + Specifies a non-default SUNAdaptController time step controller + object. If a NULL-valued SUNAdaptController is input, the + default will be re-enabled. ---------------------------------------------------------------*/ -int arkSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) +int ARKodeSetAdaptController(void* arkode_mem, SUNAdaptController C) { + int retval; + long int lenrw, leniw; ARKodeMem ark_mem; if (arkode_mem == NULL) { @@ -694,32 +844,68 @@ int arkSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) } ark_mem = (ARKodeMem)arkode_mem; - /* NULL argument sets default, otherwise set inputs */ - ark_mem->ProcessStep = ProcessStep; - ark_mem->ps_data = ark_mem->user_data; + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) + { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; + if (retval != SUN_SUCCESS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_Destroy failure"); + return (ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; + + /* On NULL-valued input, create default SUNAdaptController object */ + if (C == NULL) + { + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptControllerPID allocation failure"); + return (ARK_MEM_FAIL); + } + ark_mem->hadapt_mem->owncontroller = SUNTRUE; + } + else { ark_mem->hadapt_mem->owncontroller = SUNFALSE; } + + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; + } + ark_mem->hadapt_mem->hcontroller = C; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetPostprocessStageFn: - - Specifies a user-provided stage postprocessing function having - type ARKPostProcessFn. A NULL input function disables - stage postprocessing. + ARKodeSetMaxNumSteps: - IF THE SUPPLIED FUNCTION MODIFIES ANY OF THE ACTIVE STATE DATA, - THEN ALL THEORETICAL GUARANTEES OF SOLUTION ACCURACY AND - STABILITY ARE LOST. - - While it is possible to perform postprocessing when - ARKStepSetDeduceImplicitRhs is enabled, this can cause implicit - RHS evaluations to be inconsistent with the postprocessed stage - values. It is strongly recommended to disable - ARKStepSetDeduceImplicitRhs in order to guarantee - postprocessing constraints are enforced. + Specifies the maximum number of integration steps ---------------------------------------------------------------*/ -int arkSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) +int ARKodeSetMaxNumSteps(void* arkode_mem, long int mxsteps) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -730,20 +916,20 @@ int arkSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) } ark_mem = (ARKodeMem)arkode_mem; - /* NULL argument sets default, otherwise set inputs */ - ark_mem->ProcessStage = ProcessStage; + /* Passing mxsteps=0 sets the default. Passing mxsteps<0 disables the test. */ + if (mxsteps == 0) { ark_mem->mxstep = MXSTEP_DEFAULT; } + else { ark_mem->mxstep = mxsteps; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetConstraints: + ARKodeSetMaxHnilWarns: - Activates or Deactivates inequality constraint checking. + Specifies the maximum number of warnings for small h ---------------------------------------------------------------*/ -int arkSetConstraints(void* arkode_mem, N_Vector constraints) +int ARKodeSetMaxHnilWarns(void* arkode_mem, int mxhnil) { - sunrealtype temptest; ARKodeMem ark_mem; if (arkode_mem == NULL) { @@ -753,54 +939,66 @@ int arkSetConstraints(void* arkode_mem, N_Vector constraints) } ark_mem = (ARKodeMem)arkode_mem; - /* If there are no constraints, destroy data structures */ - if (constraints == NULL) + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - arkFreeVec(ark_mem, &ark_mem->constraints); - ark_mem->constraintsSet = SUNFALSE; - return (ARK_SUCCESS); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - /* Test if required vector ops. are defined */ - if (constraints->ops->nvdiv == NULL || constraints->ops->nvmaxnorm == NULL || - constraints->ops->nvcompare == NULL || - constraints->ops->nvconstrmask == NULL || - constraints->ops->nvminquotient == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_NVECTOR); - return (ARK_ILL_INPUT); - } + /* Passing mxhnil=0 sets the default, otherwise use input. */ + if (mxhnil == 0) { ark_mem->mxhnil = 10; } + else { ark_mem->mxhnil = mxhnil; } - /* Check the constraints vector */ - temptest = N_VMaxNorm(constraints); - if ((temptest > SUN_RCONST(2.5)) || (temptest < HALF)) + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetInitStep: + + Specifies the initial step size + ---------------------------------------------------------------*/ +int ARKodeSetInitStep(void* arkode_mem, sunrealtype hin) +{ + ARKodeMem ark_mem; + int retval; + if (arkode_mem == NULL) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_BAD_CONSTR); - return (ARK_ILL_INPUT); + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; - /* Allocate the internal constrains vector (if necessary) */ - if (!arkAllocVec(ark_mem, constraints, &ark_mem->constraints)) + /* Guard against hin==0 for non-adaptive time stepper modules */ + if ((!ark_mem->step_supports_adaptive) && (hin == ZERO)) { - return (ARK_MEM_FAIL); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - /* Load the constraints vector */ - N_VScale(ONE, constraints, ark_mem->constraints); - ark_mem->constraintsSet = SUNTRUE; + /* Passing hin=0 sets the default, otherwise use input. */ + if (hin == ZERO) { ark_mem->hin = ZERO; } + else { ark_mem->hin = hin; } + + /* Clear previous initial step */ + ark_mem->h0u = ZERO; + + /* Reset error controller (e.g., error and step size history) */ + retval = SUNAdaptController_Reset(ark_mem->hadapt_mem->hcontroller); + if (retval != SUN_SUCCESS) { return (ARK_CONTROLLER_ERR); } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxNumConstrFails: + ARKodeSetMinStep: - Set max number of allowed constraint failures in a step before - returning an error + Specifies the minimum step size ---------------------------------------------------------------*/ -int arkSetMaxNumConstrFails(void* arkode_mem, int maxfails) +int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -811,32 +1009,44 @@ int arkSetMaxNumConstrFails(void* arkode_mem, int maxfails) } ark_mem = (ARKodeMem)arkode_mem; - /* Passing maxfails = 0 sets the default, otherwise set to input */ - if (maxfails <= 0) { ark_mem->maxconstrfails = MAXCONSTRFAILS; } - else { ark_mem->maxconstrfails = maxfails; } + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Passing a value <= 0 sets hmin = 0 */ + if (hmin <= ZERO) + { + ark_mem->hmin = ZERO; + return (ARK_SUCCESS); + } + + /* check that hmin and hmax are agreeable */ + if (hmin * ark_mem->hmax_inv > ONE) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_HMIN_HMAX); + return (ARK_ILL_INPUT); + } + + /* set the value */ + ark_mem->hmin = hmin; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetAdaptivityMethod: ***DEPRECATED*** - - Specifies the built-in time step adaptivity algorithm (and - optionally, its associated parameters) to use. All parameters - will be checked for validity when used by the solver. + ARKodeSetMaxStep: - Users should transition to constructing non-default SUNAdaptController - objects directly, and providing those directly to the integrator - via the time-stepping module *SetController routines. + Specifies the maximum step size ---------------------------------------------------------------*/ -int arkSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, - sunrealtype adapt_params[3]) +int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax) { - int retval; - long int lenrw, leniw; - sunrealtype k1, k2, k3; + sunrealtype hmax_inv; ARKodeMem ark_mem; - SUNAdaptController C; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -845,207 +1055,131 @@ int arkSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, } ark_mem = (ARKodeMem)arkode_mem; - /* Check for illegal inputs */ - if ((idefault != 1) && (adapt_params == NULL)) + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "NULL-valued adapt_params provided"); - return (ARK_ILL_INPUT); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - /* Remove current SUNAdaptController object - (delete if owned, and then nullify pointer) */ - retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, - &leniw); - if (retval == SUN_SUCCESS) + /* Passing a value <= 0 sets hmax = infinity */ + if (hmax <= ZERO) { - ark_mem->liw -= leniw; - ark_mem->lrw -= lenrw; - } - if (ark_mem->hadapt_mem->owncontroller) + ark_mem->hmax_inv = ZERO; + return (ARK_SUCCESS); + } + + /* check that hmax and hmin are agreeable */ + hmax_inv = ONE / hmax; + if (hmax_inv * ark_mem->hmin > ONE) { - retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); - ark_mem->hadapt_mem->owncontroller = SUNFALSE; - if (retval != SUN_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_Destroy failure"); - return (ARK_MEM_FAIL); - } + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_HMIN_HMAX); + return (ARK_ILL_INPUT); } - ark_mem->hadapt_mem->hcontroller = NULL; - /* set adaptivity parameters from inputs */ - k1 = k2 = k3 = ZERO; - if (idefault != 1) + /* set the value */ + ark_mem->hmax_inv = hmax_inv; + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetStopTime: + + Specifies the time beyond which the integration is not to proceed. + ---------------------------------------------------------------*/ +int ARKodeSetStopTime(void* arkode_mem, sunrealtype tstop) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { - k1 = adapt_params[0]; - k2 = adapt_params[1]; - k3 = adapt_params[2]; + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } - ark_mem->hadapt_mem->pq = pq; + ark_mem = (ARKodeMem)arkode_mem; - /* Create new SUNAdaptController object based on "imethod" input, optionally setting - the specified controller parameters */ - C = NULL; - switch (imethod) + /* If ARKODE was called at least once, test if tstop is legal + (i.e. if it was not already passed). + If ARKodeSetStopTime is called before the first call to ARKODE, + tstop will be checked in ARKODE. */ + if (ark_mem->nst > 0) { - case (ARK_ADAPT_PID): - C = SUNAdaptController_PID(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } - if (idefault != 1) - { - retval = SUNAdaptController_SetParams_PID(C, k1, -k2, k3); - if (retval != SUN_SUCCESS) - { - (void)SUNAdaptController_Destroy(C); - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, - __FILE__, "SUNAdaptController_SetParams_PID failure"); - return (ARK_CONTROLLER_ERR); - } - } - break; - case (ARK_ADAPT_PI): - C = SUNAdaptController_PI(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PI allocation failure"); - return (ARK_MEM_FAIL); - } - if (idefault != 1) - { - retval = SUNAdaptController_SetParams_PI(C, k1, -k2); - if (retval != SUN_SUCCESS) - { - (void)SUNAdaptController_Destroy(C); - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, - __FILE__, "SUNAdaptController_SetParams_PI failure"); - return (ARK_CONTROLLER_ERR); - } - } - break; - case (ARK_ADAPT_I): - C = SUNAdaptController_I(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_I allocation failure"); - return (ARK_MEM_FAIL); - } - if (idefault != 1) - { - retval = SUNAdaptController_SetParams_I(C, k1); - if (retval != SUN_SUCCESS) - { - (void)SUNAdaptController_Destroy(C); - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, - __FILE__, "SUNAdaptController_SetParams_I failure"); - return (ARK_CONTROLLER_ERR); - } - } - break; - case (ARK_ADAPT_EXP_GUS): - C = SUNAdaptController_ExpGus(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_ExpGus allocation failure"); - return (ARK_MEM_FAIL); - } - if (idefault != 1) - { - retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); - if (retval != SUN_SUCCESS) - { - (void)SUNAdaptController_Destroy(C); - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, - __FILE__, "SUNAdaptController_SetParams_ExpGus failure"); - return (ARK_CONTROLLER_ERR); - } - } - break; - case (ARK_ADAPT_IMP_GUS): - C = SUNAdaptController_ImpGus(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_ImpGus allocation failure"); - return (ARK_MEM_FAIL); - } - if (idefault != 1) - { - retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); - if (retval != SUN_SUCCESS) - { - (void)SUNAdaptController_Destroy(C); - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, - __FILE__, "SUNAdaptController_SetParams_ImpGus failure"); - return (ARK_CONTROLLER_ERR); - } - } - break; - case (ARK_ADAPT_IMEX_GUS): - C = SUNAdaptController_ImExGus(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_ImExGus allocation failure"); - return (ARK_MEM_FAIL); - } - if (idefault != 1) + if ((tstop - ark_mem->tcur) * ark_mem->h < ZERO) { - retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); - if (retval != SUN_SUCCESS) - { - (void)SUNAdaptController_Destroy(C); - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, - __FILE__, "SUNAdaptController_SetParams_ImExGus failure"); - return (ARK_CONTROLLER_ERR); - } + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_TSTOP, tstop, ark_mem->tcur); + return (ARK_ILL_INPUT); } - break; - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Illegal imethod"); - return (ARK_ILL_INPUT); } - /* Attach new SUNAdaptController object */ - retval = SUNAdaptController_Space(C, &lenrw, &leniw); - if (retval == SUN_SUCCESS) + ark_mem->tstop = tstop; + ark_mem->tstopset = SUNTRUE; + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetInterpolateStopTime: + + Specifies to use interpolation to fill the solution output at + the stop time (instead of a copy). + ---------------------------------------------------------------*/ +int ARKodeSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } - ark_mem->hadapt_mem->hcontroller = C; - ark_mem->hadapt_mem->owncontroller = SUNTRUE; + ark_mem = (ARKodeMem)arkode_mem; + ark_mem->tstopinterp = interp; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeClearStopTime: + + Disable the stop time. + ---------------------------------------------------------------*/ +int ARKodeClearStopTime(void* arkode_mem) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + ark_mem->tstopset = SUNFALSE; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetAdaptivityFn: ***DEPRECATED*** + ARKodeSetFixedStep: - Specifies the user-provided time step adaptivity function to use. - If 'hfun' is NULL-valued, then the default PID controller will - be used instead. + Specifies to use a fixed time step size instead of performing + any form of temporal adaptivity. ARKODE will use this step size + for all steps (unless tstop is set, in which case it may need to + modify that last step approaching tstop. If any solver failure + occurs in the timestepping module, ARKODE will typically + immediately return with an error message indicating that the + selected step size cannot be used. - Users should transition to constructing a custom SUNAdaptController - object, and providing this directly to the integrator - via the time-stepping module *SetController routines. + Any nonzero argument will result in the use of that fixed step + size; an argument of 0 will re-enable temporal adaptivity. ---------------------------------------------------------------*/ -int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) +int ARKodeSetFixedStep(void* arkode_mem, sunrealtype hfixed) { int retval; - long int lenrw, leniw; ARKodeMem ark_mem; - SUNAdaptController C; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -1054,73 +1188,559 @@ int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) } ark_mem = (ARKodeMem)arkode_mem; - /* Remove current SUNAdaptController object - (delete if owned, and then nullify pointer) */ - retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, - &leniw); - if (retval == SUN_SUCCESS) + /* ensure that when hfixed=0, the time step module supports adaptivity */ + if ((hfixed == ZERO) && (!ark_mem->step_supports_adaptive)) { - ark_mem->liw -= leniw; - ark_mem->lrw -= lenrw; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "temporal adaptivity is not supported by this time step module"); + return (ARK_STEPPER_UNSUPPORTED); } - if (ark_mem->hadapt_mem->owncontroller) + + /* re-attach internal error weight functions if necessary */ + if ((hfixed == ZERO) && (!ark_mem->user_efun)) { - retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); - ark_mem->hadapt_mem->owncontroller = SUNFALSE; - if (retval != SUN_SUCCESS) + if (ark_mem->itol == ARK_SV && ark_mem->Vabstol != NULL) { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_Destroy failure"); - return (ARK_MEM_FAIL); + retval = ARKodeSVtolerances(ark_mem, ark_mem->reltol, ark_mem->Vabstol); + } + else + { + retval = ARKodeSStolerances(ark_mem, ark_mem->reltol, ark_mem->Sabstol); } + if (retval != ARK_SUCCESS) { return (retval); } } - ark_mem->hadapt_mem->hcontroller = NULL; - /* Create new SUNAdaptController object depending on NULL-ity of 'hfun' */ - C = NULL; - if (hfun == NULL) + /* set ark_mem "fixedstep" entry */ + if (hfixed != ZERO) { - C = SUNAdaptController_PID(ark_mem->sunctx); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "SUNAdaptController_PID allocation failure"); - return (ARK_MEM_FAIL); - } + ark_mem->fixedstep = SUNTRUE; + ark_mem->hin = hfixed; + } + else { ark_mem->fixedstep = SUNFALSE; } + + /* Notify ARKODE to use hfixed as the initial step size, and return */ + retval = ARKodeSetInitStep(arkode_mem, hfixed); + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetRootDirection: + + Specifies the direction of zero-crossings to be monitored. + The default is to monitor both crossings. + ---------------------------------------------------------------*/ +int ARKodeSetRootDirection(void* arkode_mem, int* rootdir) +{ + ARKodeMem ark_mem; + ARKodeRootMem ark_root_mem; + int i; + + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + if (ark_mem->root_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + + if (ark_root_mem->nrtfn == 0) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NO_ROOT); + return (ARK_ILL_INPUT); + } + for (i = 0; i < ark_root_mem->nrtfn; i++) + { + ark_root_mem->rootdir[i] = rootdir[i]; + } + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetNoInactiveRootWarn: + + Disables issuing a warning if some root function appears + to be identically zero at the beginning of the integration + ---------------------------------------------------------------*/ +int ARKodeSetNoInactiveRootWarn(void* arkode_mem) +{ + ARKodeMem ark_mem; + ARKodeRootMem ark_root_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + if (ark_mem->root_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + ark_root_mem->mxgnull = 0; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetPostprocessStepFn: + + Specifies a user-provided step postprocessing function having + type ARKPostProcessFn. A NULL input function disables step + postprocessing. + + IF THE SUPPLIED FUNCTION MODIFIES ANY OF THE ACTIVE STATE DATA, + THEN ALL THEORETICAL GUARANTEES OF SOLUTION ACCURACY AND + STABILITY ARE LOST. + ---------------------------------------------------------------*/ +int ARKodeSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* NULL argument sets default, otherwise set inputs */ + ark_mem->ProcessStep = ProcessStep; + ark_mem->ps_data = ark_mem->user_data; + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetPostprocessStageFn: + + Specifies a user-provided stage postprocessing function having + type ARKPostProcessFn. A NULL input function disables + stage postprocessing. + + IF THE SUPPLIED FUNCTION MODIFIES ANY OF THE ACTIVE STATE DATA, + THEN ALL THEORETICAL GUARANTEES OF SOLUTION ACCURACY AND + STABILITY ARE LOST. + + While it is possible to perform postprocessing when + ARKodeSetDeduceImplicitRhs is enabled, this can cause implicit + RHS evaluations to be inconsistent with the postprocessed stage + values. It is strongly recommended to disable + ARKodeSetDeduceImplicitRhs in order to guarantee + postprocessing constraints are enforced. + ---------------------------------------------------------------*/ +int ARKodeSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* NULL argument sets default, otherwise set inputs */ + ark_mem->ProcessStage = ProcessStage; + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetConstraints: + + Activates or Deactivates inequality constraint checking. + ---------------------------------------------------------------*/ +int ARKodeSetConstraints(void* arkode_mem, N_Vector constraints) +{ + sunrealtype temptest; + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive && (constraints != NULL)) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* If there are no constraints, destroy data structures */ + if (constraints == NULL) + { + arkFreeVec(ark_mem, &ark_mem->constraints); + ark_mem->constraintsSet = SUNFALSE; + return (ARK_SUCCESS); + } + + /* Test if required vector ops. are defined */ + if (constraints->ops->nvdiv == NULL || constraints->ops->nvmaxnorm == NULL || + constraints->ops->nvcompare == NULL || + constraints->ops->nvconstrmask == NULL || + constraints->ops->nvminquotient == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_NVECTOR); + return (ARK_ILL_INPUT); + } + + /* Check the constraints vector */ + temptest = N_VMaxNorm(constraints); + if ((temptest > SUN_RCONST(2.5)) || (temptest < HALF)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_BAD_CONSTR); + return (ARK_ILL_INPUT); + } + + /* Allocate the internal constrains vector (if necessary) */ + if (!arkAllocVec(ark_mem, constraints, &ark_mem->constraints)) + { + return (ARK_MEM_FAIL); + } + + /* Load the constraints vector */ + N_VScale(ONE, constraints, ark_mem->constraints); + ark_mem->constraintsSet = SUNTRUE; + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetMaxNumConstrFails: + + Set max number of allowed constraint failures in a step before + returning an error + ---------------------------------------------------------------*/ +int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Passing maxfails = 0 sets the default, otherwise set to input */ + if (maxfails <= 0) { ark_mem->maxconstrfails = MAXCONSTRFAILS; } + else { ark_mem->maxconstrfails = maxfails; } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetCFLFraction: + + Specifies the safety factor to use on the maximum explicitly- + stable step size. Allowable values must be within the open + interval (0,1). A non-positive input implies a reset to + the default value. + ---------------------------------------------------------------*/ +int ARKodeSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* check for allowable parameters */ + if (cfl_frac >= ONE) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Illegal CFL fraction"); + return (ARK_ILL_INPUT); + } + + /* set positive-valued parameters, otherwise set default */ + if (cfl_frac <= ZERO) { hadapt_mem->cfl = CFLFAC; } + else { hadapt_mem->cfl = cfl_frac; } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetAdaptivityAdjustment: + + Adjusts the method order supplied to the temporal adaptivity + controller. For example, if the user expects order reduction + due to problem stiffness, they may request that the controller + assume a reduced order of accuracy for the method by specifying + a value adjust < 0. + ---------------------------------------------------------------*/ +int ARKodeSetAdaptivityAdjustment(void* arkode_mem, int adjust) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* store requested adjustment */ + hadapt_mem->adjust = adjust; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetSafetyFactor: + + Specifies the safety factor to use on the error-based predicted + time step size. Allowable values must be within the open + interval (0,1). A non-positive input implies a reset to the + default value. + ---------------------------------------------------------------*/ +int ARKodeSetSafetyFactor(void* arkode_mem, sunrealtype safety) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* check for allowable parameters */ + if (safety >= ONE) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Illegal safety factor"); + return (ARK_ILL_INPUT); + } + + /* set positive-valued parameters, otherwise set default */ + if (safety <= ZERO) { hadapt_mem->safety = SAFETY; } + else { hadapt_mem->safety = safety; } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetErrorBias: + + Specifies the error bias to use when performing adaptive-step + error control. Allowable values must be >= 1.0. Any illegal + value implies a reset to the default value. + ---------------------------------------------------------------*/ +int ARKodeSetErrorBias(void* arkode_mem, sunrealtype bias) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* set allowed value, otherwise set default */ + if (bias < ONE) + { + retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, -1.0); } else { - C = ARKUserControl(ark_mem->sunctx, arkode_mem, hfun, h_data); - if (C == NULL) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "ARKUserControl allocation failure"); - return (ARK_MEM_FAIL); - } + retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, bias); } + if (retval != SUN_SUCCESS) + { + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, __FILE__, + "SUNAdaptController_SetErrorBias failure"); + return (ARK_CONTROLLER_ERR); + } + return (ARK_SUCCESS); +} - /* Attach new SUNAdaptController object */ - retval = SUNAdaptController_Space(C, &lenrw, &leniw); - if (retval == SUN_SUCCESS) +/*--------------------------------------------------------------- + ARKodeSetMaxGrowth: + + Specifies the maximum step size growth factor to be allowed + between successive integration steps. Note: the first step uses + a separate maximum growth factor. Allowable values must be + > 1.0. Any illegal value implies a reset to the default. + ---------------------------------------------------------------*/ +int ARKodeSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - ark_mem->liw += leniw; - ark_mem->lrw += lenrw; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - ark_mem->hadapt_mem->hcontroller = C; - ark_mem->hadapt_mem->owncontroller = SUNTRUE; + + /* set allowed value, otherwise set default */ + if (mx_growth <= ONE) { hadapt_mem->growth = GROWTH; } + else { hadapt_mem->growth = mx_growth; } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetMinReduction: + + Specifies the minimum possible step size reduction factor to be + allowed between successive integration steps. Allowable values + must be > 0.0 and < 1.0. Any illegal value implies a reset to + the default. + ---------------------------------------------------------------*/ +int ARKodeSetMinReduction(void* arkode_mem, sunrealtype eta_min) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* set allowed value, otherwise set default */ + if (eta_min >= ONE || eta_min <= ZERO) { hadapt_mem->etamin = ETAMIN; } + else { hadapt_mem->etamin = eta_min; } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetFixedStepBounds: + + Specifies the step size growth interval within which the step + size will remain unchanged. Allowable values must enclose the + value 1.0. Any illegal interval implies a reset to the default. + ---------------------------------------------------------------*/ +int ARKodeSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* set allowable interval, otherwise set defaults */ + if ((lb <= ONE) && (ub >= ONE)) + { + hadapt_mem->lbound = lb; + hadapt_mem->ubound = ub; + } + else + { + hadapt_mem->lbound = HFIXED_LB; + hadapt_mem->ubound = HFIXED_UB; + } + + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeSetMaxFirstGrowth: + + Specifies the user-provided time step adaptivity constant + etamx1. Legal values are greater than 1.0. Illegal values + imply a reset to the default value. + ---------------------------------------------------------------*/ +int ARKodeSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) +{ + int retval; + ARKodeHAdaptMem hadapt_mem; + ARKodeMem ark_mem; + retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* if argument legal set it, otherwise set default */ + if (etamx1 <= ONE) { hadapt_mem->etamx1 = ETAMX1; } + else { hadapt_mem->etamx1 = etamx1; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetCFLFraction: + ARKodeSetMaxEFailGrowth: - Specifies the safety factor to use on the maximum explicitly- - stable step size. Allowable values must be within the open - interval (0,1). A non-positive input implies a reset to - the default value. + Specifies the user-provided time step adaptivity constant + etamxf. Legal values are in the interval (0,1]. Illegal values + imply a reset to the default value. ---------------------------------------------------------------*/ -int arkSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) +int ARKodeSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) { int retval; ARKodeHAdaptMem hadapt_mem; @@ -1128,31 +1748,29 @@ int arkSetCFLFraction(void* arkode_mem, sunrealtype cfl_frac) retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* check for allowable parameters */ - if (cfl_frac >= ONE) + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Illegal CFL fraction"); - return (ARK_ILL_INPUT); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - /* set positive-valued parameters, otherwise set default */ - if (cfl_frac <= ZERO) { hadapt_mem->cfl = CFLFAC; } - else { hadapt_mem->cfl = cfl_frac; } + /* if argument legal set it, otherwise set default */ + if ((etamxf <= ZERO) || (etamxf > ONE)) { hadapt_mem->etamxf = ETAMXF; } + else { hadapt_mem->etamxf = etamxf; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetAdaptivityAdjustment: + ARKodeSetSmallNumEFails: - Adjusts the method order supplied to the temporal adaptivity - controller. For example, if the user expects order reduction - due to problem stiffness, they may request that the controller - assume a reduced order of accuracy for the method by specifying - a value adjust < 0. + Specifies the user-provided time step adaptivity constant + small_nef. Legal values are > 0. Illegal values + imply a reset to the default value. ---------------------------------------------------------------*/ -int arkSetAdaptivityAdjustment(void* arkode_mem, int adjust) +int ARKodeSetSmallNumEFails(void* arkode_mem, int small_nef) { int retval; ARKodeHAdaptMem hadapt_mem; @@ -1160,20 +1778,29 @@ int arkSetAdaptivityAdjustment(void* arkode_mem, int adjust) retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* store requested adjustment */ - hadapt_mem->adjust = adjust; + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* if argument legal set it, otherwise set default */ + if (small_nef <= 0) { hadapt_mem->small_nef = SMALL_NEF; } + else { hadapt_mem->small_nef = small_nef; } + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetSafetyFactor: + ARKodeSetMaxCFailGrowth: - Specifies the safety factor to use on the error-based predicted - time step size. Allowable values must be within the open - interval (0,1). A non-positive input implies a reset to the - default value. + Specifies the user-provided time step adaptivity constant + etacf. Legal values are in the interval (0,1]. Illegal values + imply a reset to the default value. ---------------------------------------------------------------*/ -int arkSetSafetyFactor(void* arkode_mem, sunrealtype safety) +int ARKodeSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) { int retval; ARKodeHAdaptMem hadapt_mem; @@ -1181,29 +1808,29 @@ int arkSetSafetyFactor(void* arkode_mem, sunrealtype safety) retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* check for allowable parameters */ - if (safety >= ONE) + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Illegal safety factor"); - return (ARK_ILL_INPUT); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - /* set positive-valued parameters, otherwise set default */ - if (safety <= ZERO) { hadapt_mem->safety = SAFETY; } - else { hadapt_mem->safety = safety; } + /* if argument legal set it, otherwise set default */ + if ((etacf <= ZERO) || (etacf > ONE)) { hadapt_mem->etacf = ETACF; } + else { hadapt_mem->etacf = etacf; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetErrorBias: + ARKodeSetStabilityFn: - Specifies the error bias to use when performing adaptive-step - error control. Allowable values must be >= 1.0. Any illegal - value implies a reset to the default value. + Specifies the user-provided explicit time step stability + function to use. A NULL input function implies a reset to + the default function (empty). ---------------------------------------------------------------*/ -int arkSetErrorBias(void* arkode_mem, sunrealtype bias) +int ARKodeSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) { int retval; ARKodeHAdaptMem hadapt_mem; @@ -1211,226 +1838,321 @@ int arkSetErrorBias(void* arkode_mem, sunrealtype bias) retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* set allowed value, otherwise set default */ - if (bias < ONE) + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, -1.0); + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - else + + /* NULL argument sets default, otherwise set inputs */ + if (EStab == NULL) { - retval = SUNAdaptController_SetErrorBias(hadapt_mem->hcontroller, bias); + hadapt_mem->expstab = arkExpStab; + hadapt_mem->estab_data = ark_mem; } - if (retval != SUN_SUCCESS) + else { - arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, __FILE__, - "SUNAdaptController_SetErrorBias failure"); - return (ARK_CONTROLLER_ERR); + hadapt_mem->expstab = EStab; + hadapt_mem->estab_data = estab_data; } + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxGrowth: + ARKodeSetMaxErrTestFails: - Specifies the maximum step size growth factor to be allowed - between successive integration steps. Note: the first step uses - a separate maximum growth factor. Allowable values must be - > 1.0. Any illegal value implies a reset to the default. + Specifies the maximum number of error test failures during one + step try. A non-positive input implies a reset to + the default value. ---------------------------------------------------------------*/ -int arkSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth) +int ARKodeSetMaxErrTestFails(void* arkode_mem, int maxnef) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; - /* set allowed value, otherwise set default */ - if (mx_growth <= ONE) { hadapt_mem->growth = GROWTH; } - else { hadapt_mem->growth = mx_growth; } + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* argument <= 0 sets default, otherwise set input */ + if (maxnef <= 0) { ark_mem->maxnef = MAXNEF; } + else { ark_mem->maxnef = maxnef; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMinReduction: + ARKodeSetMaxConvFails: - Specifies the minimum possible step size reduction factor to be - allowed between successive integration steps. Allowable values - must be > 0.0 and < 1.0. Any illegal value implies a reset to - the default. + Specifies the maximum number of nonlinear convergence failures + during one step try. A non-positive input implies a reset to + the default value. ---------------------------------------------------------------*/ -int arkSetMinReduction(void* arkode_mem, sunrealtype eta_min) +int ARKodeSetMaxConvFails(void* arkode_mem, int maxncf) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; - /* set allowed value, otherwise set default */ - if (eta_min >= ONE || eta_min <= ZERO) { hadapt_mem->etamin = ETAMIN; } - else { hadapt_mem->etamin = eta_min; } + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* argument <= 0 sets default, otherwise set input */ + if (maxncf <= 0) { ark_mem->maxncf = MAXNCF; } + else { ark_mem->maxncf = maxncf; } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetFixedStepBounds: + ARKodeSetAccumulatedErrorType: - Specifies the step size growth interval within which the step - size will remain unchanged. Allowable values must enclose the - value 1.0. Any illegal interval implies a reset to the default. + This routine sets the accumulated temporal error estimation + strategy: + 0 => scalar 'max' accumulation + 1 => scalar 'mean' accumulation + -1 => no accumulation ---------------------------------------------------------------*/ -int arkSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub) +int ARKodeSetAccumulatedErrorType(void* arkode_mem, int accum_type) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; - /* set allowable interval, otherwise set defaults */ - if ((lb <= ONE) && (ub >= ONE)) + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) { - hadapt_mem->lbound = lb; - hadapt_mem->ubound = ub; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } - else + + /* Check for valid accumulation type (set to none on illegal input) */ + if ((accum_type < 0) || (accum_type > 1)) { accum_type = -1; } + + /* Store type, reset accumulated error value and counter, and return */ + ark_mem->AccumErrorType = accum_type; + ark_mem->AccumErrorStep = ark_mem->nst; + ark_mem->AccumError = ZERO; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeResetAccumulatedError: + + This routine resets the accumulated temporal error estimate. + ---------------------------------------------------------------*/ +int ARKodeResetAccumulatedError(void* arkode_mem) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { - hadapt_mem->lbound = HFIXED_LB; - hadapt_mem->ubound = HFIXED_UB; + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for non-adaptive time stepper modules */ + if (!ark_mem->step_supports_adaptive) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support temporal adaptivity"); + return (ARK_STEPPER_UNSUPPORTED); } + /* Reset value and counter, and return */ + ark_mem->AccumErrorStep = ark_mem->nst; + ark_mem->AccumError = ZERO; return (ARK_SUCCESS); } +/*=============================================================== + ARKODE optional output utility functions + ===============================================================*/ + /*--------------------------------------------------------------- - arkSetMaxFirstGrowth: + ARKodeGetNumStepAttempts: - Specifies the user-provided time step adaptivity constant - etamx1. Legal values are greater than 1.0. Illegal values - imply a reset to the default value. + Returns the current number of steps attempted by the solver ---------------------------------------------------------------*/ -int arkSetMaxFirstGrowth(void* arkode_mem, sunrealtype etamx1) +int ARKodeGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; - /* if argument legal set it, otherwise set default */ - if (etamx1 <= ONE) { hadapt_mem->etamx1 = ETAMX1; } - else { hadapt_mem->etamx1 = etamx1; } + *nstep_attempts = ark_mem->nst_attempts; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeGetNumSteps: + + Returns the current number of integration steps + ---------------------------------------------------------------*/ +int ARKodeGetNumSteps(void* arkode_mem, long int* nsteps) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + *nsteps = ark_mem->nst; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxEFailGrowth: + ARKodeGetActualInitStep: - Specifies the user-provided time step adaptivity constant - etamxf. Legal values are in the interval (0,1]. Illegal values - imply a reset to the default value. + Returns the step size used on the first step ---------------------------------------------------------------*/ -int arkSetMaxEFailGrowth(void* arkode_mem, sunrealtype etamxf) +int ARKodeGetActualInitStep(void* arkode_mem, sunrealtype* hinused) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; - /* if argument legal set it, otherwise set default */ - if ((etamxf <= ZERO) || (etamxf > ONE)) { hadapt_mem->etamxf = ETAMXF; } - else { hadapt_mem->etamxf = etamxf; } + *hinused = ark_mem->h0u; + return (ARK_SUCCESS); +} + +/*--------------------------------------------------------------- + ARKodeGetLastStep: + + Returns the step size used on the last successful step + ---------------------------------------------------------------*/ +int ARKodeGetLastStep(void* arkode_mem, sunrealtype* hlast) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + *hlast = ark_mem->hold; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetSmallNumEFails: + ARKodeGetCurrentStep: - Specifies the user-provided time step adaptivity constant - small_nef. Legal values are > 0. Illegal values - imply a reset to the default value. + Returns the step size to be attempted on the next step ---------------------------------------------------------------*/ -int arkSetSmallNumEFails(void* arkode_mem, int small_nef) +int ARKodeGetCurrentStep(void* arkode_mem, sunrealtype* hcur) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* if argument legal set it, otherwise set default */ - if (small_nef <= 0) { hadapt_mem->small_nef = SMALL_NEF; } - else { hadapt_mem->small_nef = small_nef; } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + *hcur = ark_mem->next_h; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxCFailGrowth: + ARKodeGetCurrentState: - Specifies the user-provided time step adaptivity constant - etacf. Legal values are in the interval (0,1]. Illegal values - imply a reset to the default value. + Returns the current solution (before or after as step) or + stage value (during step solve). ---------------------------------------------------------------*/ -int arkSetMaxCFailGrowth(void* arkode_mem, sunrealtype etacf) +int ARKodeGetCurrentState(void* arkode_mem, N_Vector* state) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* if argument legal set it, otherwise set default */ - if ((etacf <= ZERO) || (etacf > ONE)) { hadapt_mem->etacf = ETACF; } - else { hadapt_mem->etacf = etacf; } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + *state = ark_mem->ycur; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetStabilityFn: + ARKodeGetEstLocalErrors: - Specifies the user-provided explicit time step stability - function to use. A NULL input function implies a reset to - the default function (empty). + Returns an estimate of the local error ---------------------------------------------------------------*/ -int arkSetStabilityFn(void* arkode_mem, ARKExpStabFn EStab, void* estab_data) +int ARKodeGetEstLocalErrors(void* arkode_mem, N_Vector ele) { - int retval; - ARKodeHAdaptMem hadapt_mem; ARKodeMem ark_mem; - retval = arkAccessHAdaptMem(arkode_mem, __func__, &ark_mem, &hadapt_mem); - if (retval != ARK_SUCCESS) { return (retval); } + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; - /* NULL argument sets default, otherwise set inputs */ - if (EStab == NULL) + /* Call stepper-specific routine (if provided); otherwise return an error */ + if (ark_mem->step_getestlocalerrors) { - hadapt_mem->expstab = arkExpStab; - hadapt_mem->estab_data = ark_mem; + return (ark_mem->step_getestlocalerrors(ark_mem, ele)); } else { - hadapt_mem->expstab = EStab; - hadapt_mem->estab_data = estab_data; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does provide a temporal error estimate"); + return (ARK_STEPPER_UNSUPPORTED); } - - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxErrTestFails: + ARKodeGetCurrentTime: - Specifies the maximum number of error test failures during one - step try. A non-positive input implies a reset to - the default value. + Returns the current value of the independent variable ---------------------------------------------------------------*/ -int arkSetMaxErrTestFails(void* arkode_mem, int maxnef) +int ARKodeGetCurrentTime(void* arkode_mem, sunrealtype* tcur) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1441,20 +2163,14 @@ int arkSetMaxErrTestFails(void* arkode_mem, int maxnef) } ark_mem = (ARKodeMem)arkode_mem; - /* argument <= 0 sets default, otherwise set input */ - if (maxnef <= 0) { ark_mem->maxnef = MAXNEF; } - else { ark_mem->maxnef = maxnef; } + *tcur = ark_mem->tcur; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetMaxConvFails: - - Specifies the maximum number of nonlinear convergence failures - during one step try. A non-positive input implies a reset to - the default value. + ARKodeGetCurrentGamma: Returns the current value of gamma ---------------------------------------------------------------*/ -int arkSetMaxConvFails(void* arkode_mem, int maxncf) +int ARKodeGetCurrentGamma(void* arkode_mem, sunrealtype* gamma) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1465,19 +2181,34 @@ int arkSetMaxConvFails(void* arkode_mem, int maxncf) } ark_mem = (ARKodeMem)arkode_mem; - /* argument <= 0 sets default, otherwise set input */ - if (maxncf <= 0) { ark_mem->maxncf = MAXNCF; } - else { ark_mem->maxncf = maxncf; } - return (ARK_SUCCESS); + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getcurrentgamma) + { + return (ark_mem->step_getcurrentgamma(ark_mem, gamma)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkSetUseCompensatedSums: + ARKodeGetTolScaleFactor: - Specifies that ARKODE should use compensated (Kahan) summation - where relevant to mitigate roundoff error. + Returns a suggested factor for scaling tolerances ---------------------------------------------------------------*/ -int arkSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) +int ARKodeGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1488,22 +2219,25 @@ int arkSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) } ark_mem = (ARKodeMem)arkode_mem; - if (onoff) { ark_mem->use_compensated_sums = SUNTRUE; } - else { ark_mem->use_compensated_sums = SUNFALSE; } + /* Guard against use for time steppers that do not use tolerances + (i.e., neither supports adaptivity nor needs an algebraic solver) */ + if ((!ark_mem->step_supports_implicit) && (!ark_mem->step_supports_adaptive)) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not use tolerances"); + return (ARK_STEPPER_UNSUPPORTED); + } + *tolsfact = ark_mem->tolsf; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkSetAccumulatedErrorType: + ARKodeGetErrWeights: - This routine sets the accumulated temporal error estimation - strategy: - 0 => scalar 'max' accumulation - 1 => scalar 'mean' accumulation - -1 => no accumulation + This routine returns the current error weight vector. ---------------------------------------------------------------*/ -int arkSetAccumulatedErrorType(void* arkode_mem, int accum_type) +int ARKodeGetErrWeights(void* arkode_mem, N_Vector eweight) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1514,22 +2248,25 @@ int arkSetAccumulatedErrorType(void* arkode_mem, int accum_type) } ark_mem = (ARKodeMem)arkode_mem; - /* Check for valid accumulation type (set to none on illegal input) */ - if ((accum_type < 0) || (accum_type > 1)) { accum_type = -1; } + /* Guard against use for time steppers that do not use tolerances + (i.e., neither supports adaptivity nor needs an algebraic solver) */ + if ((!ark_mem->step_supports_implicit) && (!ark_mem->step_supports_adaptive)) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not use tolerances"); + return (ARK_STEPPER_UNSUPPORTED); + } - /* Store type, reset accumulated error value and counter, and return */ - ark_mem->AccumErrorType = accum_type; - ark_mem->AccumErrorStep = ark_mem->nst; - ark_mem->AccumError = ZERO; + N_VScale(ONE, ark_mem->ewt, eweight); return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkResetAccumulatedError: + ARKodeGetResWeights: - This routine resets the accumulated temporal error estimate. + This routine returns the current residual weight vector. ---------------------------------------------------------------*/ -int arkResetAccumulatedError(void* arkode_mem) +int ARKodeGetResWeights(void* arkode_mem, N_Vector rweight) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1540,22 +2277,24 @@ int arkResetAccumulatedError(void* arkode_mem) } ark_mem = (ARKodeMem)arkode_mem; - /* Reset value and counter, and return */ - ark_mem->AccumErrorStep = ark_mem->nst; - ark_mem->AccumError = ZERO; + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + + N_VScale(ONE, ark_mem->rwt, rweight); return (ARK_SUCCESS); } -/*=============================================================== - ARKODE optional output utility functions - ===============================================================*/ - /*--------------------------------------------------------------- - arkGetAccumulatedError: + ARKodeGetWorkSpace: - This routine returns the accumulated temporal error estimate. + Returns integrator work space requirements ---------------------------------------------------------------*/ -int arkGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) +int ARKodeGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1566,32 +2305,48 @@ int arkGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) } ark_mem = (ARKodeMem)arkode_mem; - /* Get number of steps since last accumulated error reset - (set floor of 1 to safeguard against division-by-zero) */ - long int steps = SUNMAX(1, ark_mem->nst - ark_mem->AccumErrorStep); + *leniw = ark_mem->liw; + *lenrw = ark_mem->lrw; + return (ARK_SUCCESS); +} - /* Fill output based on error accumulation type */ - if (ark_mem->AccumErrorType == 0) +/*--------------------------------------------------------------- + ARKodeGetNumGEvals: + + Returns the current number of calls to g (for rootfinding) + ---------------------------------------------------------------*/ +int ARKodeGetNumGEvals(void* arkode_mem, long int* ngevals) +{ + ARKodeMem ark_mem; + ARKodeRootMem ark_root_mem; + if (arkode_mem == NULL) { - *accum_error = ark_mem->AccumError * ark_mem->reltol; + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } - else if (ark_mem->AccumErrorType == 1) + ark_mem = (ARKodeMem)arkode_mem; + if (ark_mem->root_mem == NULL) { - *accum_error = ark_mem->AccumError * ark_mem->reltol / steps; + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } - else { *accum_error = ZERO; } - + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + *ngevals = ark_root_mem->nge; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetNumStepAttempts: + ARKodeGetRootInfo: - Returns the current number of steps attempted by the solver + Returns pointer to array rootsfound showing roots found ---------------------------------------------------------------*/ -int arkGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) +int ARKodeGetRootInfo(void* arkode_mem, int* rootsfound) { + int i; ARKodeMem ark_mem; + ARKodeRootMem ark_root_mem; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -1599,17 +2354,27 @@ int arkGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; - - *nstep_attempts = ark_mem->nst_attempts; + if (ark_mem->root_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + for (i = 0; i < ark_root_mem->nrtfn; i++) + { + rootsfound[i] = ark_root_mem->iroots[i]; + } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetNumSteps: + ARKodeGetStepStats: - Returns the current number of integration steps + Returns step statistics ---------------------------------------------------------------*/ -int arkGetNumSteps(void* arkode_mem, long int* nsteps) +int ARKodeGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, + sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1620,16 +2385,20 @@ int arkGetNumSteps(void* arkode_mem, long int* nsteps) } ark_mem = (ARKodeMem)arkode_mem; - *nsteps = ark_mem->nst; + *nsteps = ark_mem->nst; + *hinused = ark_mem->h0u; + *hlast = ark_mem->hold; + *hcur = ark_mem->next_h; + *tcur = ark_mem->tcur; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetActualInitStep: + ARKodeGetAccumulatedError: - Returns the step size used on the first step + This routine returns the accumulated temporal error estimate. ---------------------------------------------------------------*/ -int arkGetActualInitStep(void* arkode_mem, sunrealtype* hinused) +int ARKodeGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1640,16 +2409,30 @@ int arkGetActualInitStep(void* arkode_mem, sunrealtype* hinused) } ark_mem = (ARKodeMem)arkode_mem; - *hinused = ark_mem->h0u; + /* Get number of steps since last accumulated error reset + (set floor of 1 to safeguard against division-by-zero) */ + long int steps = SUNMAX(1, ark_mem->nst - ark_mem->AccumErrorStep); + + /* Fill output based on error accumulation type */ + if (ark_mem->AccumErrorType == 0) + { + *accum_error = ark_mem->AccumError * ark_mem->reltol; + } + else if (ark_mem->AccumErrorType == 1) + { + *accum_error = ark_mem->AccumError * ark_mem->reltol / steps; + } + else { *accum_error = ZERO; } + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetLastStep: + ARKodeGetNumConstrFails: - Returns the step size used on the last successful step + Returns the current number of constraint fails ---------------------------------------------------------------*/ -int arkGetLastStep(void* arkode_mem, sunrealtype* hlast) +int ARKodeGetNumConstrFails(void* arkode_mem, long int* nconstrfails) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1660,16 +2443,16 @@ int arkGetLastStep(void* arkode_mem, sunrealtype* hlast) } ark_mem = (ARKodeMem)arkode_mem; - *hlast = ark_mem->hold; + *nconstrfails = ark_mem->nconstrfails; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetCurrentStep: + ARKodeGetNumExpSteps: - Returns the step size to be attempted on the next step + Returns the current number of stability-limited steps ---------------------------------------------------------------*/ -int arkGetCurrentStep(void* arkode_mem, sunrealtype* hcur) +int ARKodeGetNumExpSteps(void* arkode_mem, long int* nsteps) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1680,17 +2463,16 @@ int arkGetCurrentStep(void* arkode_mem, sunrealtype* hcur) } ark_mem = (ARKodeMem)arkode_mem; - *hcur = ark_mem->next_h; + *nsteps = ark_mem->hadapt_mem->nst_exp; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetCurrentState: + ARKodeGetNumAccSteps: - Returns the current solution (before or after as step) or - stage value (during step solve). + Returns the current number of accuracy-limited steps ---------------------------------------------------------------*/ -int arkGetCurrentState(void* arkode_mem, N_Vector* state) +int ARKodeGetNumAccSteps(void* arkode_mem, long int* nsteps) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1701,16 +2483,16 @@ int arkGetCurrentState(void* arkode_mem, N_Vector* state) } ark_mem = (ARKodeMem)arkode_mem; - *state = ark_mem->ycur; + *nsteps = ark_mem->hadapt_mem->nst_acc; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetCurrentTime: + ARKodeGetNumErrTestFails: - Returns the current value of the independent variable + Returns the current number of error test failures ---------------------------------------------------------------*/ -int arkGetCurrentTime(void* arkode_mem, sunrealtype* tcur) +int ARKodeGetNumErrTestFails(void* arkode_mem, long int* netfails) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1721,16 +2503,17 @@ int arkGetCurrentTime(void* arkode_mem, sunrealtype* tcur) } ark_mem = (ARKodeMem)arkode_mem; - *tcur = ark_mem->tcur; + *netfails = ark_mem->netf; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetTolScaleFactor: + ARKodeComputeState: - Returns a suggested factor for scaling tolerances + Computes y based on the current prediction and a given + correction. ---------------------------------------------------------------*/ -int arkGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) +int ARKodeComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1741,16 +2524,39 @@ int arkGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) } ark_mem = (ARKodeMem)arkode_mem; - *tolsfact = ark_mem->tolsf; - return (ARK_SUCCESS); + /* Guard against use for incompatible time stepper modules */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support algebraic solvers"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_computestate) + { + return (ark_mem->step_computestate(ark_mem, zcor, z)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkGetErrWeights: + ARKodeGetNonlinearSystemData: - This routine returns the current error weight vector. + This routine provides access to the relevant data needed to + compute the nonlinear system function. ---------------------------------------------------------------*/ -int arkGetErrWeights(void* arkode_mem, N_Vector eweight) +int ARKodeGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1761,16 +2567,36 @@ int arkGetErrWeights(void* arkode_mem, N_Vector eweight) } ark_mem = (ARKodeMem)arkode_mem; - N_VScale(ONE, ark_mem->ewt, eweight); - return (ARK_SUCCESS); + /* Guard against use for incompatible time stepper modules */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support algebraic solvers"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getnonlinearsystemdata) + { + return (ark_mem->step_getnonlinearsystemdata(ark_mem, tcur, zpred, z, Fi, + gamma, sdata, user_data)); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, + "time-stepping module does not support this function"); + return (ARK_STEPPER_UNSUPPORTED); + } } /*--------------------------------------------------------------- - arkGetResWeights: + ARKodeGetNumNonlinSolvIters: - This routine returns the current residual weight vector. + Returns the current number of nonlinear solver iterations ---------------------------------------------------------------*/ -int arkGetResWeights(void* arkode_mem, N_Vector rweight) +int ARKodeGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1781,16 +2607,24 @@ int arkGetResWeights(void* arkode_mem, N_Vector rweight) } ark_mem = (ARKodeMem)arkode_mem; - N_VScale(ONE, ark_mem->rwt, rweight); - return (ARK_SUCCESS); + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getnumnonlinsolviters) + { + return (ark_mem->step_getnumnonlinsolviters(ark_mem, nniters)); + } + else + { + *nniters = 0; + return (ARK_SUCCESS); + } } /*--------------------------------------------------------------- - arkGetEstLocalErrors: + ARKodeGetNumNonlinSolvConvFails: - This routine returns the current local temporal error estimate. + Returns the current number of nonlinear solver convergence fails ---------------------------------------------------------------*/ -int arkGetEstLocalErrors(void* arkode_mem, N_Vector ele) +int ARKodeGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1801,16 +2635,25 @@ int arkGetEstLocalErrors(void* arkode_mem, N_Vector ele) } ark_mem = (ARKodeMem)arkode_mem; - N_VScale(ONE, ark_mem->tempv1, ele); - return (ARK_SUCCESS); + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getnumnonlinsolvconvfails) + { + return (ark_mem->step_getnumnonlinsolvconvfails(ark_mem, nnfails)); + } + else + { + *nnfails = 0; + return (ARK_SUCCESS); + } } /*--------------------------------------------------------------- - arkGetWorkSpace: + ARKodeGetNonlinSolvStats: - Returns integrator work space requirements + Returns nonlinear solver statistics ---------------------------------------------------------------*/ -int arkGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) +int ARKodeGetNonlinSolvStats(void* arkode_mem, long int* nniters, + long int* nnfails) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1821,20 +2664,27 @@ int arkGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) } ark_mem = (ARKodeMem)arkode_mem; - *leniw = ark_mem->liw; - *lenrw = ark_mem->lrw; - return (ARK_SUCCESS); + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getnonlinsolvstats) + { + return (ark_mem->step_getnonlinsolvstats(ark_mem, nniters, nnfails)); + } + else + { + *nniters = *nnfails = 0; + return (ARK_SUCCESS); + } } /*--------------------------------------------------------------- - arkGetNumGEvals: + ARKodeGetNumStepSolveFails: - Returns the current number of calls to g (for rootfinding) + Returns the current number of failed steps due to an algebraic + solver convergence failure. ---------------------------------------------------------------*/ -int arkGetNumGEvals(void* arkode_mem, long int* ngevals) +int ARKodeGetNumStepSolveFails(void* arkode_mem, long int* nncfails) { ARKodeMem ark_mem; - ARKodeRootMem ark_root_mem; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -1842,27 +2692,19 @@ int arkGetNumGEvals(void* arkode_mem, long int* ngevals) return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; - if (ark_mem->root_mem == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - *ngevals = ark_root_mem->nge; + + *nncfails = ark_mem->ncfn; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetRootInfo: + ARKodeGetNumLinSolvSetups: - Returns pointer to array rootsfound showing roots found + Returns the current number of calls to the lsetup routine ---------------------------------------------------------------*/ -int arkGetRootInfo(void* arkode_mem, int* rootsfound) +int ARKodeGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) { - int i; ARKodeMem ark_mem; - ARKodeRootMem ark_root_mem; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -1870,27 +2712,25 @@ int arkGetRootInfo(void* arkode_mem, int* rootsfound) return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; - if (ark_mem->root_mem == NULL) + + /* Call stepper routine to compute the state (if provided) */ + if (ark_mem->step_getnumlinsolvsetups) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + return (ark_mem->step_getnumlinsolvsetups(ark_mem, nlinsetups)); } - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - for (i = 0; i < ark_root_mem->nrtfn; i++) + else { - rootsfound[i] = ark_root_mem->iroots[i]; + *nlinsetups = 0; + return (ARK_SUCCESS); } - return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetStepStats: + ARKodeGetUserData: - Returns step statistics + Returns the user data pointer ---------------------------------------------------------------*/ -int arkGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, - sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur) +int ARKodeGetUserData(void* arkode_mem, void** user_data) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1901,22 +2741,23 @@ int arkGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused, } ark_mem = (ARKodeMem)arkode_mem; - *nsteps = ark_mem->nst; - *hinused = ark_mem->h0u; - *hlast = ark_mem->hold; - *hcur = ark_mem->next_h; - *tcur = ark_mem->tcur; + *user_data = ark_mem->user_data; + return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - arkGetNumConstrFails: +/*----------------------------------------------------------------- + ARKodePrintAllStats - Returns the current number of constraint fails + Prints the current value of all statistics ---------------------------------------------------------------*/ -int arkGetNumConstrFails(void* arkode_mem, long int* nconstrfails) + +int ARKodePrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) { + int retval; ARKodeMem ark_mem; + ARKodeRootMem ark_root_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -1925,16 +2766,156 @@ int arkGetNumConstrFails(void* arkode_mem, long int* nconstrfails) } ark_mem = (ARKodeMem)arkode_mem; - *nconstrfails = ark_mem->nconstrfails; + switch (fmt) + { + case SUN_OUTPUTFORMAT_TABLE: + fprintf(outfile, "Current time = %" RSYM "\n", ark_mem->tcur); + fprintf(outfile, "Steps = %ld\n", ark_mem->nst); + fprintf(outfile, "Step attempts = %ld\n", + ark_mem->nst_attempts); + fprintf(outfile, "Stability limited steps = %ld\n", + ark_mem->hadapt_mem->nst_exp); + fprintf(outfile, "Accuracy limited steps = %ld\n", + ark_mem->hadapt_mem->nst_acc); + fprintf(outfile, "Error test fails = %ld\n", ark_mem->netf); + fprintf(outfile, "NLS step fails = %ld\n", ark_mem->ncfn); + fprintf(outfile, "Inequality constraint fails = %ld\n", + ark_mem->nconstrfails); + fprintf(outfile, "Initial step size = %" RSYM "\n", ark_mem->h0u); + fprintf(outfile, "Last step size = %" RSYM "\n", ark_mem->hold); + fprintf(outfile, "Current step size = %" RSYM "\n", + ark_mem->next_h); + if (ark_mem->root_mem) + { + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + fprintf(outfile, "Root fn evals = %ld\n", ark_root_mem->nge); + } + break; + case SUN_OUTPUTFORMAT_CSV: + fprintf(outfile, "Time,%" RSYM, ark_mem->tcur); + fprintf(outfile, ",Steps,%ld", ark_mem->nst); + fprintf(outfile, ",Step attempts,%ld", ark_mem->nst_attempts); + fprintf(outfile, ",Stability limited steps,%ld", + ark_mem->hadapt_mem->nst_exp); + fprintf(outfile, ",Accuracy limited steps,%ld", ark_mem->hadapt_mem->nst_acc); + fprintf(outfile, ",Error test fails,%ld", ark_mem->netf); + fprintf(outfile, ",NLS step fails,%ld", ark_mem->ncfn); + fprintf(outfile, ",Inequality constraint fails,%ld", ark_mem->nconstrfails); + fprintf(outfile, ",Initial step size,%" RSYM, ark_mem->h0u); + fprintf(outfile, ",Last step size,%" RSYM, ark_mem->hold); + fprintf(outfile, ",Current step size,%" RSYM, ark_mem->next_h); + if (ark_mem->root_mem) + { + ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; + fprintf(outfile, ",Roof fn evals,%ld", ark_root_mem->nge); + } + break; + default: + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid formatting option."); + return (ARK_ILL_INPUT); + } + + /* Print relaxation stats */ + if (ark_mem->relax_enabled) + { + retval = arkRelaxPrintAllStats(ark_mem, outfile, fmt); + if (retval != ARK_SUCCESS) { return (retval); } + } + + /* Print stepper stats (if provided) */ + if (ark_mem->step_printallstats) + { + return (ark_mem->step_printallstats(ark_mem, outfile, fmt)); + } + return (ARK_SUCCESS); } +/*-----------------------------------------------------------------*/ + +char* ARKodeGetReturnFlagName(long int flag) +{ + char* name; + name = (char*)malloc(27 * sizeof(char)); + + switch (flag) + { + case ARK_SUCCESS: sprintf(name, "ARK_SUCCESS"); break; + case ARK_TSTOP_RETURN: sprintf(name, "ARK_TSTOP_RETURN"); break; + case ARK_ROOT_RETURN: sprintf(name, "ARK_ROOT_RETURN"); break; + case ARK_WARNING: sprintf(name, "ARK_WARNING"); break; + case ARK_TOO_MUCH_WORK: sprintf(name, "ARK_TOO_MUCH_WORK"); break; + case ARK_TOO_MUCH_ACC: sprintf(name, "ARK_TOO_MUCH_ACC"); break; + case ARK_ERR_FAILURE: sprintf(name, "ARK_ERR_FAILURE"); break; + case ARK_CONV_FAILURE: sprintf(name, "ARK_CONV_FAILURE"); break; + case ARK_LINIT_FAIL: sprintf(name, "ARK_LINIT_FAIL"); break; + case ARK_LSETUP_FAIL: sprintf(name, "ARK_LSETUP_FAIL"); break; + case ARK_LSOLVE_FAIL: sprintf(name, "ARK_LSOLVE_FAIL"); break; + case ARK_RHSFUNC_FAIL: sprintf(name, "ARK_RHSFUNC_FAIL"); break; + case ARK_FIRST_RHSFUNC_ERR: sprintf(name, "ARK_FIRST_RHSFUNC_ERR"); break; + case ARK_REPTD_RHSFUNC_ERR: sprintf(name, "ARK_REPTD_RHSFUNC_ERR"); break; + case ARK_UNREC_RHSFUNC_ERR: sprintf(name, "ARK_UNREC_RHSFUNC_ERR"); break; + case ARK_RTFUNC_FAIL: sprintf(name, "ARK_RTFUNC_FAIL"); break; + case ARK_LFREE_FAIL: sprintf(name, "ARK_LFREE_FAIL"); break; + case ARK_MASSINIT_FAIL: sprintf(name, "ARK_MASSINIT_FAIL"); break; + case ARK_MASSSETUP_FAIL: sprintf(name, "ARK_MASSSETUP_FAIL"); break; + case ARK_MASSSOLVE_FAIL: sprintf(name, "ARK_MASSSOLVE_FAIL"); break; + case ARK_MASSFREE_FAIL: sprintf(name, "ARK_MASSFREE_FAIL"); break; + case ARK_MASSMULT_FAIL: sprintf(name, "ARK_MASSMULT_FAIL"); break; + case ARK_CONSTR_FAIL: sprintf(name, "ARK_CONSTR_FAIL"); break; + case ARK_MEM_FAIL: sprintf(name, "ARK_MEM_FAIL"); break; + case ARK_MEM_NULL: sprintf(name, "ARK_MEM_NULL"); break; + case ARK_ILL_INPUT: sprintf(name, "ARK_ILL_INPUT"); break; + case ARK_NO_MALLOC: sprintf(name, "ARK_NO_MALLOC"); break; + case ARK_BAD_K: sprintf(name, "ARK_BAD_K"); break; + case ARK_BAD_T: sprintf(name, "ARK_BAD_T"); break; + case ARK_BAD_DKY: sprintf(name, "ARK_BAD_DKY"); break; + case ARK_TOO_CLOSE: sprintf(name, "ARK_TOO_CLOSE"); break; + case ARK_VECTOROP_ERR: sprintf(name, "ARK_VECTOROP_ERR"); break; + case ARK_NLS_INIT_FAIL: sprintf(name, "ARK_NLS_INIT_FAIL"); break; + case ARK_NLS_SETUP_FAIL: sprintf(name, "ARK_NLS_SETUP_FAIL"); break; + case ARK_NLS_SETUP_RECVR: sprintf(name, "ARK_NLS_SETUP_RECVR"); break; + case ARK_NLS_OP_ERR: sprintf(name, "ARK_NLS_OP_ERR"); break; + case ARK_INNERSTEP_ATTACH_ERR: + sprintf(name, "ARK_INNERSTEP_ATTACH_ERR"); + break; + case ARK_INNERSTEP_FAIL: sprintf(name, "ARK_INNERSTEP_FAIL"); break; + case ARK_OUTERTOINNER_FAIL: sprintf(name, "ARK_OUTERTOINNER_FAIL"); break; + case ARK_INNERTOOUTER_FAIL: sprintf(name, "ARK_INNERTOOUTER_FAIL"); break; + case ARK_POSTPROCESS_STEP_FAIL: + sprintf(name, "ARK_POSTPROCESS_STEP_FAIL"); + break; + case ARK_POSTPROCESS_STAGE_FAIL: + sprintf(name, "ARK_POSTPROCESS_STAGE_FAIL"); + break; + case ARK_USER_PREDICT_FAIL: sprintf(name, "ARK_USER_PREDICT_FAIL"); break; + case ARK_INTERP_FAIL: sprintf(name, "ARK_INTERP_FAIL"); break; + case ARK_INVALID_TABLE: sprintf(name, "ARK_INVALID_TABLE"); break; + case ARK_CONTEXT_ERR: sprintf(name, "ARK_CONTEXT_ERR"); break; + case ARK_RELAX_FAIL: sprintf(name, "ARK_RELAX_FAIL"); break; + case ARK_RELAX_MEM_NULL: sprintf(name, "ARK_RELAX_MEM_NULL"); break; + case ARK_RELAX_FUNC_FAIL: sprintf(name, "ARK_RELAX_FUNC_FAIL"); break; + case ARK_RELAX_JAC_FAIL: sprintf(name, "ARK_RELAX_JAC_FAIL"); break; + case ARK_CONTROLLER_ERR: sprintf(name, "ARK_CONTROLLER_ERR"); break; + case ARK_STEPPER_UNSUPPORTED: sprintf(name, "ARK_STEPPER_UNSUPPORTED"); break; + case ARK_UNRECOGNIZED_ERROR: sprintf(name, "ARK_UNRECOGNIZED_ERROR"); break; + default: sprintf(name, "NONE"); + } + + return (name); +} + +/*=============================================================== + ARKODE parameter output utility routine + ===============================================================*/ + /*--------------------------------------------------------------- - arkGetNumExpSteps: + ARKodeWriteParameters: - Returns the current number of stability-limited steps + Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int arkGetNumExpSteps(void* arkode_mem, long int* nsteps) +int ARKodeWriteParameters(void* arkode_mem, FILE* fp) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1943,38 +2924,101 @@ int arkGetNumExpSteps(void* arkode_mem, long int* nsteps) MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } - ark_mem = (ARKodeMem)arkode_mem; - - *nsteps = ark_mem->hadapt_mem->nst_exp; - return (ARK_SUCCESS); -} + ark_mem = (ARKodeMem)arkode_mem; + + /* print integrator parameters to file */ + fprintf(fp, "ARKODE solver parameters:\n"); + if (ark_mem->hmin != ZERO) + { + fprintf(fp, " Minimum step size = %" RSYM "\n", ark_mem->hmin); + } + if (ark_mem->hmax_inv != ZERO) + { + fprintf(fp, " Maximum step size = %" RSYM "\n", ONE / ark_mem->hmax_inv); + } + if (ark_mem->fixedstep) { fprintf(fp, " Fixed time-stepping enabled\n"); } + if (ark_mem->itol == ARK_WF) + { + fprintf(fp, " User provided error weight function\n"); + } + else + { + fprintf(fp, " Solver relative tolerance = %" RSYM "\n", ark_mem->reltol); + if (ark_mem->itol == ARK_SS) + { + fprintf(fp, " Solver absolute tolerance = %" RSYM "\n", ark_mem->Sabstol); + } + else { fprintf(fp, " Vector-valued solver absolute tolerance\n"); } + } + if (!ark_mem->rwt_is_ewt) + { + if (ark_mem->ritol == ARK_WF) + { + fprintf(fp, " User provided residual weight function\n"); + } + else + { + if (ark_mem->ritol == ARK_SS) + { + fprintf(fp, " Absolute residual tolerance = %" RSYM "\n", + ark_mem->SRabstol); + } + else { fprintf(fp, " Vector-valued residual absolute tolerance\n"); } + } + } + if (ark_mem->hin != ZERO) + { + fprintf(fp, " Initial step size = %" RSYM "\n", ark_mem->hin); + } + fprintf(fp, "\n"); + fprintf(fp, " Maximum step increase (first step) = %" RSYM "\n", + ark_mem->hadapt_mem->etamx1); + fprintf(fp, " Step reduction factor on multiple error fails = %" RSYM "\n", + ark_mem->hadapt_mem->etamxf); + fprintf(fp, " Minimum error fails before above factor is used = %i\n", + ark_mem->hadapt_mem->small_nef); + fprintf(fp, + " Step reduction factor on nonlinear convergence failure = %" RSYM + "\n", + ark_mem->hadapt_mem->etacf); + fprintf(fp, " Explicit safety factor = %" RSYM "\n", ark_mem->hadapt_mem->cfl); + fprintf(fp, " Safety factor = %" RSYM "\n", ark_mem->hadapt_mem->safety); + fprintf(fp, " Growth factor = %" RSYM "\n", ark_mem->hadapt_mem->growth); + fprintf(fp, " Step growth lower bound = %" RSYM "\n", + ark_mem->hadapt_mem->lbound); + fprintf(fp, " Step growth upper bound = %" RSYM "\n", + ark_mem->hadapt_mem->ubound); + if (ark_mem->hadapt_mem->expstab == arkExpStab) + { + fprintf(fp, " Default explicit stability function\n"); + } + else { fprintf(fp, " User provided explicit stability function\n"); } + (void)SUNAdaptController_Write(ark_mem->hadapt_mem->hcontroller, fp); -/*--------------------------------------------------------------- - arkGetNumAccSteps: + fprintf(fp, " Maximum number of error test failures = %i\n", ark_mem->maxnef); + fprintf(fp, " Maximum number of convergence test failures = %i\n", + ark_mem->maxncf); - Returns the current number of accuracy-limited steps - ---------------------------------------------------------------*/ -int arkGetNumAccSteps(void* arkode_mem, long int* nsteps) -{ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + /* Call stepper routine (if provided) */ + if (ark_mem->step_writeparameters) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + return (ark_mem->step_writeparameters(ark_mem, fp)); } - ark_mem = (ARKodeMem)arkode_mem; - *nsteps = ark_mem->hadapt_mem->nst_acc; return (ARK_SUCCESS); } +/*=============================================================== + ARKODE + XBraid interface utility functions + ===============================================================*/ + /*--------------------------------------------------------------- - arkGetNumErrTestFails: + arkSetForcePass: - Returns the current number of error test failures + Ignore the value of kflag after the temporal error test and + force the step to pass. ---------------------------------------------------------------*/ -int arkGetNumErrTestFails(void* arkode_mem, long int* netfails) +int arkSetForcePass(void* arkode_mem, sunbooleantype force_pass) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -1985,17 +3029,17 @@ int arkGetNumErrTestFails(void* arkode_mem, long int* netfails) } ark_mem = (ARKodeMem)arkode_mem; - *netfails = ark_mem->netf; + ark_mem->force_pass = force_pass; + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - arkGetNumStepSolveFails: + arkGetLastKFlag: - Returns the current number of failed steps due to an algebraic - solver convergence failure. + The last kflag value retured by the temporal error test. ---------------------------------------------------------------*/ -int arkGetNumStepSolveFails(void* arkode_mem, long int* nncfails) +int arkGetLastKFlag(void* arkode_mem, int* last_kflag) { ARKodeMem ark_mem; if (arkode_mem == NULL) @@ -2006,18 +3050,34 @@ int arkGetNumStepSolveFails(void* arkode_mem, long int* nncfails) } ark_mem = (ARKodeMem)arkode_mem; - *nncfails = ark_mem->ncfn; + *last_kflag = ark_mem->last_kflag; + return (ARK_SUCCESS); } +/*=============================================================== + Deprecated functions + ===============================================================*/ + /*--------------------------------------------------------------- - arkGetUserData: + arkSetAdaptivityMethod: - Returns the user data pointer + Specifies the built-in time step adaptivity algorithm (and + optionally, its associated parameters) to use. All parameters + will be checked for validity when used by the solver. + + Users should transition to constructing non-default SUNAdaptController + objects directly, and providing those directly to the integrator + via the time-stepping module *SetController routines. ---------------------------------------------------------------*/ -int arkGetUserData(void* arkode_mem, void** user_data) +int arkSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault, int pq, + sunrealtype adapt_params[3]) { + int retval; + long int lenrw, leniw; + sunrealtype k1, k2, k3; ARKodeMem ark_mem; + SUNAdaptController C; if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, @@ -2026,301 +3086,273 @@ int arkGetUserData(void* arkode_mem, void** user_data) } ark_mem = (ARKodeMem)arkode_mem; - *user_data = ark_mem->user_data; - - return (ARK_SUCCESS); -} - -/*----------------------------------------------------------------- - arkPrintAllStats - - Prints the current value of all statistics - ---------------------------------------------------------------*/ + /* Check for illegal inputs */ + if ((idefault != 1) && (adapt_params == NULL)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "NULL-valued adapt_params provided"); + return (ARK_ILL_INPUT); + } -int arkPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) -{ - int retval; - ARKodeMem ark_mem; - ARKodeRootMem ark_root_mem; + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + if (retval == SUN_SUCCESS) + { + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; + } + if (ark_mem->hadapt_mem->owncontroller) + { + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; + if (retval != SUN_SUCCESS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_Destroy failure"); + return (ARK_MEM_FAIL); + } + } + ark_mem->hadapt_mem->hcontroller = NULL; - if (arkode_mem == NULL) + /* set adaptivity parameters from inputs */ + k1 = k2 = k3 = ZERO; + if (idefault != 1) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + k1 = adapt_params[0]; + k2 = adapt_params[1]; + k3 = adapt_params[2]; } - ark_mem = (ARKodeMem)arkode_mem; + ark_mem->hadapt_mem->pq = pq; - switch (fmt) + /* Create new SUNAdaptController object based on "imethod" input, optionally setting + the specified controller parameters */ + C = NULL; + switch (imethod) { - case SUN_OUTPUTFORMAT_TABLE: - fprintf(outfile, "Current time = %" RSYM "\n", ark_mem->tcur); - fprintf(outfile, "Steps = %ld\n", ark_mem->nst); - fprintf(outfile, "Step attempts = %ld\n", - ark_mem->nst_attempts); - fprintf(outfile, "Stability limited steps = %ld\n", - ark_mem->hadapt_mem->nst_exp); - fprintf(outfile, "Accuracy limited steps = %ld\n", - ark_mem->hadapt_mem->nst_acc); - fprintf(outfile, "Error test fails = %ld\n", ark_mem->netf); - fprintf(outfile, "NLS step fails = %ld\n", ark_mem->ncfn); - fprintf(outfile, "Inequality constraint fails = %ld\n", - ark_mem->nconstrfails); - fprintf(outfile, "Initial step size = %" RSYM "\n", ark_mem->h0u); - fprintf(outfile, "Last step size = %" RSYM "\n", ark_mem->hold); - fprintf(outfile, "Current step size = %" RSYM "\n", - ark_mem->next_h); - if (ark_mem->root_mem) + case (ARK_ADAPT_PID): + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) { - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - fprintf(outfile, "Root fn evals = %ld\n", ark_root_mem->nge); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); + } + if (idefault != 1) + { + retval = SUNAdaptController_SetParams_PID(C, k1, -k2, k3); + if (retval != SUN_SUCCESS) + { + (void)SUNAdaptController_Destroy(C); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, + __FILE__, "SUNAdaptController_SetParams_PID failure"); + return (ARK_CONTROLLER_ERR); + } } break; - case SUN_OUTPUTFORMAT_CSV: - fprintf(outfile, "Time,%" RSYM, ark_mem->tcur); - fprintf(outfile, ",Steps,%ld", ark_mem->nst); - fprintf(outfile, ",Step attempts,%ld", ark_mem->nst_attempts); - fprintf(outfile, ",Stability limited steps,%ld", - ark_mem->hadapt_mem->nst_exp); - fprintf(outfile, ",Accuracy limited steps,%ld", ark_mem->hadapt_mem->nst_acc); - fprintf(outfile, ",Error test fails,%ld", ark_mem->netf); - fprintf(outfile, ",NLS step fails,%ld", ark_mem->ncfn); - fprintf(outfile, ",Inequality constraint fails,%ld", ark_mem->nconstrfails); - fprintf(outfile, ",Initial step size,%" RSYM, ark_mem->h0u); - fprintf(outfile, ",Last step size,%" RSYM, ark_mem->hold); - fprintf(outfile, ",Current step size,%" RSYM, ark_mem->next_h); - if (ark_mem->root_mem) + case (ARK_ADAPT_PI): + C = SUNAdaptController_PI(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PI allocation failure"); + return (ARK_MEM_FAIL); + } + if (idefault != 1) + { + retval = SUNAdaptController_SetParams_PI(C, k1, -k2); + if (retval != SUN_SUCCESS) + { + (void)SUNAdaptController_Destroy(C); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, + __FILE__, "SUNAdaptController_SetParams_PI failure"); + return (ARK_CONTROLLER_ERR); + } + } + break; + case (ARK_ADAPT_I): + C = SUNAdaptController_I(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_I allocation failure"); + return (ARK_MEM_FAIL); + } + if (idefault != 1) + { + retval = SUNAdaptController_SetParams_I(C, k1); + if (retval != SUN_SUCCESS) + { + (void)SUNAdaptController_Destroy(C); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, + __FILE__, "SUNAdaptController_SetParams_I failure"); + return (ARK_CONTROLLER_ERR); + } + } + break; + case (ARK_ADAPT_EXP_GUS): + C = SUNAdaptController_ExpGus(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_ExpGus allocation failure"); + return (ARK_MEM_FAIL); + } + if (idefault != 1) + { + retval = SUNAdaptController_SetParams_ExpGus(C, k1, k2); + if (retval != SUN_SUCCESS) + { + (void)SUNAdaptController_Destroy(C); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, + __FILE__, "SUNAdaptController_SetParams_ExpGus failure"); + return (ARK_CONTROLLER_ERR); + } + } + break; + case (ARK_ADAPT_IMP_GUS): + C = SUNAdaptController_ImpGus(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_ImpGus allocation failure"); + return (ARK_MEM_FAIL); + } + if (idefault != 1) + { + retval = SUNAdaptController_SetParams_ImpGus(C, k1, k2); + if (retval != SUN_SUCCESS) + { + (void)SUNAdaptController_Destroy(C); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, + __FILE__, "SUNAdaptController_SetParams_ImpGus failure"); + return (ARK_CONTROLLER_ERR); + } + } + break; + case (ARK_ADAPT_IMEX_GUS): + C = SUNAdaptController_ImExGus(ark_mem->sunctx); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_ImExGus allocation failure"); + return (ARK_MEM_FAIL); + } + if (idefault != 1) { - ark_root_mem = (ARKodeRootMem)ark_mem->root_mem; - fprintf(outfile, ",Roof fn evals,%ld", ark_root_mem->nge); + retval = SUNAdaptController_SetParams_ImExGus(C, k1, k2, k3, k3); + if (retval != SUN_SUCCESS) + { + (void)SUNAdaptController_Destroy(C); + arkProcessError(ark_mem, ARK_CONTROLLER_ERR, __LINE__, __func__, + __FILE__, "SUNAdaptController_SetParams_ImExGus failure"); + return (ARK_CONTROLLER_ERR); + } } break; default: arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); + "Illegal imethod"); return (ARK_ILL_INPUT); } - /* Print relaxation stats */ - if (ark_mem->relax_enabled) + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUN_SUCCESS) { - retval = arkRelaxPrintAllStats(arkode_mem, outfile, fmt); - if (retval != ARK_SUCCESS) { return (retval); } + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; } + ark_mem->hadapt_mem->hcontroller = C; + ark_mem->hadapt_mem->owncontroller = SUNTRUE; return (ARK_SUCCESS); } -/*-----------------------------------------------------------------*/ - -char* arkGetReturnFlagName(long int flag) -{ - char* name; - name = (char*)malloc(27 * sizeof(char)); - - switch (flag) - { - case ARK_SUCCESS: sprintf(name, "ARK_SUCCESS"); break; - case ARK_TSTOP_RETURN: sprintf(name, "ARK_TSTOP_RETURN"); break; - case ARK_ROOT_RETURN: sprintf(name, "ARK_ROOT_RETURN"); break; - case ARK_WARNING: sprintf(name, "ARK_WARNING"); break; - case ARK_TOO_MUCH_WORK: sprintf(name, "ARK_TOO_MUCH_WORK"); break; - case ARK_TOO_MUCH_ACC: sprintf(name, "ARK_TOO_MUCH_ACC"); break; - case ARK_ERR_FAILURE: sprintf(name, "ARK_ERR_FAILURE"); break; - case ARK_CONV_FAILURE: sprintf(name, "ARK_CONV_FAILURE"); break; - case ARK_LINIT_FAIL: sprintf(name, "ARK_LINIT_FAIL"); break; - case ARK_LSETUP_FAIL: sprintf(name, "ARK_LSETUP_FAIL"); break; - case ARK_LSOLVE_FAIL: sprintf(name, "ARK_LSOLVE_FAIL"); break; - case ARK_RHSFUNC_FAIL: sprintf(name, "ARK_RHSFUNC_FAIL"); break; - case ARK_FIRST_RHSFUNC_ERR: sprintf(name, "ARK_FIRST_RHSFUNC_ERR"); break; - case ARK_REPTD_RHSFUNC_ERR: sprintf(name, "ARK_REPTD_RHSFUNC_ERR"); break; - case ARK_UNREC_RHSFUNC_ERR: sprintf(name, "ARK_UNREC_RHSFUNC_ERR"); break; - case ARK_RTFUNC_FAIL: sprintf(name, "ARK_RTFUNC_FAIL"); break; - case ARK_LFREE_FAIL: sprintf(name, "ARK_LFREE_FAIL"); break; - case ARK_MASSINIT_FAIL: sprintf(name, "ARK_MASSINIT_FAIL"); break; - case ARK_MASSSETUP_FAIL: sprintf(name, "ARK_MASSSETUP_FAIL"); break; - case ARK_MASSSOLVE_FAIL: sprintf(name, "ARK_MASSSOLVE_FAIL"); break; - case ARK_MASSFREE_FAIL: sprintf(name, "ARK_MASSFREE_FAIL"); break; - case ARK_MASSMULT_FAIL: sprintf(name, "ARK_MASSMULT_FAIL"); break; - case ARK_CONSTR_FAIL: sprintf(name, "ARK_CONSTR_FAIL"); break; - case ARK_MEM_FAIL: sprintf(name, "ARK_MEM_FAIL"); break; - case ARK_MEM_NULL: sprintf(name, "ARK_MEM_NULL"); break; - case ARK_ILL_INPUT: sprintf(name, "ARK_ILL_INPUT"); break; - case ARK_NO_MALLOC: sprintf(name, "ARK_NO_MALLOC"); break; - case ARK_BAD_K: sprintf(name, "ARK_BAD_K"); break; - case ARK_BAD_T: sprintf(name, "ARK_BAD_T"); break; - case ARK_BAD_DKY: sprintf(name, "ARK_BAD_DKY"); break; - case ARK_TOO_CLOSE: sprintf(name, "ARK_TOO_CLOSE"); break; - case ARK_VECTOROP_ERR: sprintf(name, "ARK_VECTOROP_ERR"); break; - case ARK_NLS_INIT_FAIL: sprintf(name, "ARK_NLS_INIT_FAIL"); break; - case ARK_NLS_SETUP_FAIL: sprintf(name, "ARK_NLS_SETUP_FAIL"); break; - case ARK_NLS_SETUP_RECVR: sprintf(name, "ARK_NLS_SETUP_RECVR"); break; - case ARK_NLS_OP_ERR: sprintf(name, "ARK_NLS_OP_ERR"); break; - case ARK_INNERSTEP_ATTACH_ERR: - sprintf(name, "ARK_INNERSTEP_ATTACH_ERR"); - break; - case ARK_INNERSTEP_FAIL: sprintf(name, "ARK_INNERSTEP_FAIL"); break; - case ARK_OUTERTOINNER_FAIL: sprintf(name, "ARK_OUTERTOINNER_FAIL"); break; - case ARK_INNERTOOUTER_FAIL: sprintf(name, "ARK_INNERTOOUTER_FAIL"); break; - case ARK_POSTPROCESS_STEP_FAIL: - sprintf(name, "ARK_POSTPROCESS_STEP_FAIL"); - break; - case ARK_POSTPROCESS_STAGE_FAIL: - sprintf(name, "ARK_POSTPROCESS_STAGE_FAIL"); - break; - case ARK_USER_PREDICT_FAIL: sprintf(name, "ARK_USER_PREDICT_FAIL"); break; - case ARK_INTERP_FAIL: sprintf(name, "ARK_INTERP_FAIL"); break; - case ARK_INVALID_TABLE: sprintf(name, "ARK_INVALID_TABLE"); break; - case ARK_CONTEXT_ERR: sprintf(name, "ARK_CONTEXT_ERR"); break; - case ARK_CONTROLLER_ERR: sprintf(name, "ARK_CONTROLLER_ERR"); break; - case ARK_UNRECOGNIZED_ERROR: sprintf(name, "ARK_UNRECOGNIZED_ERROR"); break; - default: sprintf(name, "NONE"); - } - - return (name); -} - -/*=============================================================== - ARKODE parameter output utility routine - ===============================================================*/ - /*--------------------------------------------------------------- - arkodeWriteParameters: + arkSetAdaptivityFn: - Outputs all solver parameters to the provided file pointer. + Specifies the user-provided time step adaptivity function to use. + If 'hfun' is NULL-valued, then the default PID controller will + be used instead. + + Users should transition to constructing a custom SUNAdaptController + object, and providing this directly to the integrator + via the time-stepping module *SetController routines. ---------------------------------------------------------------*/ -int arkWriteParameters(ARKodeMem ark_mem, FILE* fp) +int arkSetAdaptivityFn(void* arkode_mem, ARKAdaptFn hfun, void* h_data) { - if (ark_mem == NULL) + int retval; + long int lenrw, leniw; + ARKodeMem ark_mem; + SUNAdaptController C; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } + ark_mem = (ARKodeMem)arkode_mem; - /* print integrator parameters to file */ - fprintf(fp, "ARKODE solver parameters:\n"); - if (ark_mem->hmin != ZERO) - { - fprintf(fp, " Minimum step size = %" RSYM "\n", ark_mem->hmin); - } - if (ark_mem->hmax_inv != ZERO) - { - fprintf(fp, " Maximum step size = %" RSYM "\n", ONE / ark_mem->hmax_inv); - } - if (ark_mem->fixedstep) { fprintf(fp, " Fixed time-stepping enabled\n"); } - if (ark_mem->itol == ARK_WF) + /* Remove current SUNAdaptController object + (delete if owned, and then nullify pointer) */ + retval = SUNAdaptController_Space(ark_mem->hadapt_mem->hcontroller, &lenrw, + &leniw); + if (retval == SUN_SUCCESS) { - fprintf(fp, " User provided error weight function\n"); + ark_mem->liw -= leniw; + ark_mem->lrw -= lenrw; } - else + if (ark_mem->hadapt_mem->owncontroller) { - fprintf(fp, " Solver relative tolerance = %" RSYM "\n", ark_mem->reltol); - if (ark_mem->itol == ARK_SS) + retval = SUNAdaptController_Destroy(ark_mem->hadapt_mem->hcontroller); + ark_mem->hadapt_mem->owncontroller = SUNFALSE; + if (retval != SUN_SUCCESS) { - fprintf(fp, " Solver absolute tolerance = %" RSYM "\n", ark_mem->Sabstol); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_Destroy failure"); + return (ARK_MEM_FAIL); } - else { fprintf(fp, " Vector-valued solver absolute tolerance\n"); } } - if (!ark_mem->rwt_is_ewt) + ark_mem->hadapt_mem->hcontroller = NULL; + + /* Create new SUNAdaptController object depending on NULL-ity of 'hfun' */ + C = NULL; + if (hfun == NULL) { - if (ark_mem->ritol == ARK_WF) - { - fprintf(fp, " User provided residual weight function\n"); - } - else + C = SUNAdaptController_PID(ark_mem->sunctx); + if (C == NULL) { - if (ark_mem->ritol == ARK_SS) - { - fprintf(fp, " Absolute residual tolerance = %" RSYM "\n", - ark_mem->SRabstol); - } - else { fprintf(fp, " Vector-valued residual absolute tolerance\n"); } + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "SUNAdaptController_PID allocation failure"); + return (ARK_MEM_FAIL); } } - if (ark_mem->hin != ZERO) - { - fprintf(fp, " Initial step size = %" RSYM "\n", ark_mem->hin); - } - fprintf(fp, "\n"); - fprintf(fp, " Maximum step increase (first step) = %" RSYM "\n", - ark_mem->hadapt_mem->etamx1); - fprintf(fp, " Step reduction factor on multiple error fails = %" RSYM "\n", - ark_mem->hadapt_mem->etamxf); - fprintf(fp, " Minimum error fails before above factor is used = %i\n", - ark_mem->hadapt_mem->small_nef); - fprintf(fp, - " Step reduction factor on nonlinear convergence failure = %" RSYM - "\n", - ark_mem->hadapt_mem->etacf); - fprintf(fp, " Explicit safety factor = %" RSYM "\n", ark_mem->hadapt_mem->cfl); - fprintf(fp, " Safety factor = %" RSYM "\n", ark_mem->hadapt_mem->safety); - fprintf(fp, " Growth factor = %" RSYM "\n", ark_mem->hadapt_mem->growth); - fprintf(fp, " Step growth lower bound = %" RSYM "\n", - ark_mem->hadapt_mem->lbound); - fprintf(fp, " Step growth upper bound = %" RSYM "\n", - ark_mem->hadapt_mem->ubound); - if (ark_mem->hadapt_mem->expstab == arkExpStab) - { - fprintf(fp, " Default explicit stability function\n"); - } - else { fprintf(fp, " User provided explicit stability function\n"); } - (void)SUNAdaptController_Write(ark_mem->hadapt_mem->hcontroller, fp); - - fprintf(fp, " Maximum number of error test failures = %i\n", ark_mem->maxnef); - fprintf(fp, " Maximum number of convergence test failures = %i\n", - ark_mem->maxncf); - - return (ARK_SUCCESS); -} - -/*=============================================================== - ARKODE + XBraid interface utility functions - ===============================================================*/ - -/*--------------------------------------------------------------- - arkSetForcePass: - - Ignore the value of kflag after the temporal error test and - force the step to pass. - ---------------------------------------------------------------*/ -int arkSetForcePass(void* arkode_mem, sunbooleantype force_pass) -{ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + else { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + C = ARKUserControl(ark_mem->sunctx, arkode_mem, hfun, h_data); + if (C == NULL) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "ARKUserControl allocation failure"); + return (ARK_MEM_FAIL); + } } - ark_mem = (ARKodeMem)arkode_mem; - - ark_mem->force_pass = force_pass; - - return (ARK_SUCCESS); -} -/*--------------------------------------------------------------- - arkGetLastKFlag: - - The last kflag value retured by the temporal error test. - ---------------------------------------------------------------*/ -int arkGetLastKFlag(void* arkode_mem, int* last_kflag) -{ - ARKodeMem ark_mem; - if (arkode_mem == NULL) + /* Attach new SUNAdaptController object */ + retval = SUNAdaptController_Space(C, &lenrw, &leniw); + if (retval == SUN_SUCCESS) { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); + ark_mem->liw += leniw; + ark_mem->lrw += lenrw; } - ark_mem = (ARKodeMem)arkode_mem; - - *last_kflag = ark_mem->last_kflag; + ark_mem->hadapt_mem->hcontroller = C; + ark_mem->hadapt_mem->owncontroller = SUNTRUE; return (ARK_SUCCESS); } /*--------------------------------------------------------------- EOF - ---------------------------------------------------------------*/ + ===============================================================*/ diff --git a/src/arkode/arkode_ls.c b/src/arkode/arkode_ls.c index bf43998744..7032f62e40 100644 --- a/src/arkode/arkode_ls.c +++ b/src/arkode/arkode_ls.c @@ -35,17 +35,17 @@ /* Prototypes for internal functions */ static int arkLsLinSys(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, SUNMatrix M, sunbooleantype jok, sunbooleantype* jcur, - sunrealtype gamma, void* user_data, N_Vector tmp1, + sunrealtype gamma, void* arkode_mem, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3); /*=============================================================== - ARKLS utility routines (called by time-stepper modules) + Exported routines ===============================================================*/ /*--------------------------------------------------------------- - arkLSSetLinearSolver specifies the linear solver. + ARKodeSetLinearSolver specifies the linear solver. ---------------------------------------------------------------*/ -int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) +int ARKodeSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) { ARKodeMem ark_mem; ARKLsMem arkls_mem; @@ -57,12 +57,20 @@ int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) /* Return immediately if either arkode_mem or LS inputs are NULL */ if (arkode_mem == NULL) { - arkProcessError(NULL, ARKLS_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_LS_ARKMEM_NULL); - return (ARKLS_MEM_NULL); + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (LS == NULL) { arkProcessError(ark_mem, ARKLS_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -181,7 +189,7 @@ int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) arkls_mem->jtsetup = NULL; arkls_mem->jtimes = arkLsDQJtimes; arkls_mem->Jt_data = ark_mem; - arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(arkode_mem); + arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(ark_mem); if (arkls_mem->Jt_f == NULL) { @@ -277,7 +285,7 @@ int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) else { arkls_mem->scalesol = SUNFALSE; } /* Attach ARKLs interface to time stepper module */ - retval = ark_mem->step_attachlinsol(arkode_mem, arkLsInitialize, arkLsSetup, + retval = ark_mem->step_attachlinsol(ark_mem, arkLsInitialize, arkLsSetup, arkLsSolve, arkLsFree, LSType, arkls_mem); if (retval != ARK_SUCCESS) { @@ -294,12 +302,12 @@ int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) } /*--------------------------------------------------------------- - arkLSSetMassLinearSolver specifies the iterative mass-matrix + ARKodeSetMassLinearSolver specifies the iterative mass-matrix linear solver and user-supplied routine to perform the mass-matrix-vector product. ---------------------------------------------------------------*/ -int arkLSSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, - sunbooleantype time_dep) +int ARKodeSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, + sunbooleantype time_dep) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; @@ -311,12 +319,20 @@ int arkLSSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, /* Return immediately if either arkode_mem or LS inputs are NULL */ if (arkode_mem == NULL) { - arkProcessError(NULL, ARKLS_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_LS_ARKMEM_NULL); - return (ARKLS_MEM_NULL); + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); } ark_mem = (ARKodeMem)arkode_mem; + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (LS == NULL) { arkProcessError(ark_mem, ARKLS_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -502,7 +518,7 @@ int arkLSSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, if (iterative) { arkls_mem->nrmfac = SUNRsqrt(N_VGetLength(arkls_mem->x)); } /* Attach ARKLs interface to time stepper module */ - retval = ark_mem->step_attachmasssol(arkode_mem, arkLsMassInitialize, + retval = ark_mem->step_attachmasssol(ark_mem, arkLsMassInitialize, arkLsMassSetup, arkLsMTimes, arkLsMassSolve, arkLsMassFree, time_dep, LSType, arkls_mem); @@ -520,21 +536,34 @@ int arkLSSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, return (ARKLS_SUCCESS); } -/*=============================================================== - Optional Set functions (called by time-stepper modules) - ===============================================================*/ - /*--------------------------------------------------------------- - arkLSSetJacFn specifies the Jacobian function. + ARKodeSetJacFn specifies the Jacobian function. ---------------------------------------------------------------*/ -int arkLSSetJacFn(void* arkode_mem, ARKLsJacFn jac) +int ARKodeSetJacFn(void* arkode_mem, ARKLsJacFn jac) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* return with failure if jac cannot be used */ @@ -568,16 +597,33 @@ int arkLSSetJacFn(void* arkode_mem, ARKLsJacFn jac) } /*--------------------------------------------------------------- - arkLSSetMassFn specifies the mass matrix function. + ARKodeSetMassFn specifies the mass matrix function. ---------------------------------------------------------------*/ -int arkLSSetMassFn(void* arkode_mem, ARKLsMassFn mass) +int ARKodeSetMassFn(void* arkode_mem, ARKLsMassFn mass) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* return with failure if mass cannot be used */ @@ -602,38 +648,75 @@ int arkLSSetMassFn(void* arkode_mem, ARKLsMassFn mass) } /*--------------------------------------------------------------- - arkLSSetEpsLin specifies the nonlinear -> linear tolerance + ARKodeSetEpsLin specifies the nonlinear -> linear tolerance scale factor. ---------------------------------------------------------------*/ -int arkLSSetEpsLin(void* arkode_mem, sunrealtype eplifac) +int ARKodeSetEpsLin(void* arkode_mem, sunrealtype eplifac) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; store input and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* store input and return */ arkls_mem->eplifac = (eplifac <= ZERO) ? ARKLS_EPLIN : eplifac; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSSetNormFactor sets or computes the factor to use when + ARKodeSetLSNormFactor sets or computes the factor to use when converting from the integrator tolerance (WRMS norm) to the linear solver tolerance (L2 norm). ---------------------------------------------------------------*/ -int arkLSSetNormFactor(void* arkode_mem, sunrealtype nrmfac) +int ARKodeSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; store input and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + /* store input and return */ if (nrmfac > ZERO) { /* set user-provided factor */ @@ -655,35 +738,71 @@ int arkLSSetNormFactor(void* arkode_mem, sunrealtype nrmfac) } /*--------------------------------------------------------------- - arkLSSetJacEvalFrequency specifies the frequency for + ARKodeSetJacEvalFrequency specifies the frequency for recomputing the Jacobian matrix and/or preconditioner. ---------------------------------------------------------------*/ -int arkLSSetJacEvalFrequency(void* arkode_mem, long int msbj) +int ARKodeSetJacEvalFrequency(void* arkode_mem, long int msbj) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; store input and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* store input and return */ arkls_mem->msbj = (msbj <= ZERO) ? ARKLS_MSBJ : msbj; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSSetLinearSolutionScaling enables or disables scaling the + ARKodeSetLinearSolutionScaling enables or disables scaling the linear solver solution to account for changes in gamma. ---------------------------------------------------------------*/ -int arkLSSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) +int ARKodeSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; store input and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check for valid solver type */ @@ -696,11 +815,11 @@ int arkLSSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) } /*--------------------------------------------------------------- - arkLSSetPreconditioner specifies the user-supplied + ARKodeSetPreconditioner specifies the user-supplied preconditioner setup and solve routines. ---------------------------------------------------------------*/ -int arkLSSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, - ARKLsPrecSolveFn psolve) +int ARKodeSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, + ARKLsPrecSolveFn psolve) { ARKodeMem ark_mem; ARKLsMem arkls_mem; @@ -708,8 +827,25 @@ int arkLSSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, SUNPSolveFn arkls_psolve; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* issue error if LS object does not allow user-supplied preconditioning */ @@ -741,18 +877,35 @@ int arkLSSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, } /*--------------------------------------------------------------- - arkLSSetJacTimes specifies the user-supplied Jacobian-vector + ARKodeSetJacTimes specifies the user-supplied Jacobian-vector product setup and multiply routines. ---------------------------------------------------------------*/ -int arkLSSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, - ARKLsJacTimesVecFn jtimes) +int ARKodeSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, + ARKLsJacTimesVecFn jtimes) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* issue error if LS object does not allow user-supplied ATimes */ @@ -778,7 +931,7 @@ int arkLSSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, arkls_mem->jtsetup = NULL; arkls_mem->jtimes = arkLsDQJtimes; arkls_mem->Jt_data = ark_mem; - arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(arkode_mem); + arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(ark_mem); if (arkls_mem->Jt_f == NULL) { @@ -792,18 +945,35 @@ int arkLSSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, } /*--------------------------------------------------------------- - arkLSSetJacTimesRhsFn specifies an alternative user-supplied + ARKodeSetJacTimesRhsFn specifies an alternative user-supplied ODE right-hand side function to use in the internal finite difference Jacobian-vector product. ---------------------------------------------------------------*/ -int arkLSSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) +int ARKodeSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check if using internal finite difference approximation */ @@ -818,7 +988,7 @@ int arkLSSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) if (jtimesRhsFn != NULL) { arkls_mem->Jt_f = jtimesRhsFn; } else { - arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(arkode_mem); + arkls_mem->Jt_f = ark_mem->step_getimplicitrhs(ark_mem); if (arkls_mem->Jt_f == NULL) { @@ -831,15 +1001,32 @@ int arkLSSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) return (ARKLS_SUCCESS); } -/* arkLSSetLinSysFn specifies the linear system setup function. */ -int arkLSSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) +/* ARKodeSetLinSysFn specifies the linear system setup function. */ +int ARKodeSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not need an algebraic solver */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARKLS_SUCCESS) { return (retval); } /* return with failure if linsys cannot be used */ @@ -867,80 +1054,105 @@ int arkLSSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) return (ARKLS_SUCCESS); } -/* arkLSSetUserData sets user_data pointers in arkLS */ -int arkLSSetUserData(void* arkode_mem, void* user_data) +int ARKodeGetJac(void* arkode_mem, SUNMatrix* J) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); - if (retval != ARKLS_SUCCESS) { return (retval); } - - /* Set data for Jacobian */ - if (!arkls_mem->jacDQ) { arkls_mem->J_data = user_data; } - - /* Set data for Jtimes */ - if (!arkls_mem->jtimesDQ) { arkls_mem->Jt_data = user_data; } - - /* Set data for LinSys */ - if (arkls_mem->user_linsys) { arkls_mem->A_data = user_data; } - - /* Set data for Preconditioner */ - arkls_mem->P_data = user_data; - - return (ARKLS_SUCCESS); -} - -/*=============================================================== - Optional Get functions (called by time-stepper modules) - ===============================================================*/ + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; -int arkLSGetJac(void* arkode_mem, SUNMatrix* J) -{ - ARKodeMem ark_mem; - ARKLsMem arkls_mem; - int retval; + /* Return NULL for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *J = NULL; + return (ARK_SUCCESS); + } - /* access ARKLsMem structure; set output and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARKLS_SUCCESS) { return retval; } + + /* set output and return */ *J = arkls_mem->savedJ; return ARKLS_SUCCESS; } -int arkLSGetJacTime(void* arkode_mem, sunrealtype* t_J) +int ARKodeGetJacTime(void* arkode_mem, sunrealtype* t_J) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return an error for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not require an algebraic solver"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARKLS_SUCCESS) { return retval; } + + /* set output and return */ *t_J = arkls_mem->tnlj; return ARKLS_SUCCESS; } -int arkLSGetJacNumSteps(void* arkode_mem, long int* nst_J) +int ARKodeGetJacNumSteps(void* arkode_mem, long int* nst_J) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *nst_J = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARKLS_SUCCESS) { return retval; } + + /* set output and return */ *nst_J = arkls_mem->nstlj; return ARKLS_SUCCESS; } /*--------------------------------------------------------------- - arkLSGetWorkSpace returns the length of workspace allocated for + ARKodeGetLinWorkSpace returns the length of workspace allocated for the ARKLS linear solver interface. ---------------------------------------------------------------*/ -int arkLSGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) +int ARKodeGetLinWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) { ARKodeMem ark_mem; ARKLsMem arkls_mem; @@ -948,8 +1160,24 @@ int arkLSGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) long int lrw, liw; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *lenrw = *leniw = 0; + return (ARK_SUCCESS); + } + /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* start with fixed sizes plus vector/matrix pointers */ @@ -993,181 +1221,361 @@ int arkLSGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) } /*--------------------------------------------------------------- - arkLSGetNumJacEvals returns the number of Jacobian evaluations + ARKodeGetNumJacEvals returns the number of Jacobian evaluations ---------------------------------------------------------------*/ -int arkLSGetNumJacEvals(void* arkode_mem, long int* njevals) +int ARKodeGetNumJacEvals(void* arkode_mem, long int* njevals) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *njevals = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *njevals = arkls_mem->nje; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumRhsEvals returns the number of calls to the ODE + ARKodeGetNumLinRhsEvals returns the number of calls to the ODE function needed for the DQ Jacobian approximation or J*v product approximation. ---------------------------------------------------------------*/ -int arkLSGetNumRhsEvals(void* arkode_mem, long int* nfevalsLS) +int ARKodeGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *nfevalsLS = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nfevalsLS = arkls_mem->nfeDQ; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumPrecEvals returns the number of calls to the + ARKodeGetNumPrecEvals returns the number of calls to the user- or ARKODE-supplied preconditioner setup routine. ---------------------------------------------------------------*/ -int arkLSGetNumPrecEvals(void* arkode_mem, long int* npevals) +int ARKodeGetNumPrecEvals(void* arkode_mem, long int* npevals) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *npevals = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *npevals = arkls_mem->npe; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumPrecSolves returns the number of calls to the + ARKodeGetNumPrecSolves returns the number of calls to the user- or ARKODE-supplied preconditioner solve routine. ---------------------------------------------------------------*/ -int arkLSGetNumPrecSolves(void* arkode_mem, long int* npsolves) +int ARKodeGetNumPrecSolves(void* arkode_mem, long int* npsolves) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *npsolves = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *npsolves = arkls_mem->nps; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumLinIters returns the number of linear iterations + ARKodeGetNumLinIters returns the number of linear iterations (if accessible from the LS object). ---------------------------------------------------------------*/ -int arkLSGetNumLinIters(void* arkode_mem, long int* nliters) +int ARKodeGetNumLinIters(void* arkode_mem, long int* nliters) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *nliters = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nliters = arkls_mem->nli; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumConvFails returns the number of linear solver + ARKodeGetNumLinConvFails returns the number of linear solver convergence failures (as reported by the LS object). ---------------------------------------------------------------*/ -int arkLSGetNumConvFails(void* arkode_mem, long int* nlcfails) +int ARKodeGetNumLinConvFails(void* arkode_mem, long int* nlcfails) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *nlcfails = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nlcfails = arkls_mem->ncfl; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumJTSetupEvals returns the number of calls to the + ARKodeGetNumJTSetupEvals returns the number of calls to the user-supplied Jacobian-vector product setup routine. ---------------------------------------------------------------*/ -int arkLSGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) +int ARKodeGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *njtsetups = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *njtsetups = arkls_mem->njtsetup; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumJtimesEvals returns the number of calls to the + ARKodeGetNumJtimesEvals returns the number of calls to the Jacobian-vector product multiply routine. ---------------------------------------------------------------*/ -int arkLSGetNumJtimesEvals(void* arkode_mem, long int* njvevals) +int ARKodeGetNumJtimesEvals(void* arkode_mem, long int* njvevals) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *njvevals = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structures */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *njvevals = arkls_mem->njtimes; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassMatvecSetups returns the number of calls to the + ARKodeGetNumMassMultSetups returns the number of calls to the mass matrix-vector setup routine. ---------------------------------------------------------------*/ -int arkLSGetNumMassMatvecSetups(void* arkode_mem, long int* nmvsetups) +int ARKodeGetNumMassMultSetups(void* arkode_mem, long int* nmvsetups) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmvsetups = 0; + return (ARK_SUCCESS); + } + + /* access ARKMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nmvsetups = arkls_mem->nmvsetup; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetLastFlag returns the last flag set in a ARKLS + ARKodeGetLastLinFlag returns the last flag set in a ARKLS function. ---------------------------------------------------------------*/ -int arkLSGetLastFlag(void* arkode_mem, long int* flag) +int ARKodeGetLastLinFlag(void* arkode_mem, long int* flag) { ARKodeMem ark_mem; ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure; set output value and return */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return success for incompatible steppers */ + if (!ark_mem->step_supports_implicit) + { + *flag = ARKLS_SUCCESS; + return (ARK_SUCCESS); + } + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *flag = arkls_mem->last_flag; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetReturnFlagName translates from the integer error code + ARKodeGetLinReturnFlagName translates from the integer error code returned by an ARKLs routine to the corresponding string equivalent for that flag ---------------------------------------------------------------*/ -char* arkLSGetReturnFlagName(long int flag) +char* ARKodeGetLinReturnFlagName(long int flag) { char* name = (char*)malloc(30 * sizeof(char)); @@ -1192,38 +1600,75 @@ char* arkLSGetReturnFlagName(long int flag) } /*--------------------------------------------------------------- - arkLSSetMassEpsLin specifies the nonlinear -> linear tolerance + ARKodeSetMassEpsLin specifies the nonlinear -> linear tolerance scale factor for mass matrix linear systems. ---------------------------------------------------------------*/ -int arkLSSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) +int ARKodeSetMassEpsLin(void* arkode_mem, sunrealtype eplifac) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; store input and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* store input and return */ arkls_mem->eplifac = (eplifac <= ZERO) ? ARKLS_EPLIN : eplifac; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSSetMassNormFactor sets or computes the factor to use when + ARKodeSetMassLSNormFactor sets or computes the factor to use when converting from the integrator tolerance (WRMS norm) to the linear solver tolerance (L2 norm). ---------------------------------------------------------------*/ -int arkLSSetMassNormFactor(void* arkode_mem, sunrealtype nrmfac) +int ARKodeSetMassLSNormFactor(void* arkode_mem, sunrealtype nrmfac) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMem structure; store input and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + + /* access ARKLsMem structures */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + /* store input and return */ if (nrmfac > ZERO) { /* set user-provided factor */ @@ -1245,11 +1690,11 @@ int arkLSSetMassNormFactor(void* arkode_mem, sunrealtype nrmfac) } /*--------------------------------------------------------------- - arkLSSetMassPreconditioner specifies the user-supplied + ARKodeSetMassPreconditioner specifies the user-supplied preconditioner setup and solve routines. ---------------------------------------------------------------*/ -int arkLSSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, - ARKLsMassPrecSolveFn psolve) +int ARKodeSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, + ARKLsMassPrecSolveFn psolve) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; @@ -1257,8 +1702,25 @@ int arkLSSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, SUNPSolveFn arkls_mpsolve; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* issue error if LS object does not allow user-supplied preconditioning */ @@ -1290,18 +1752,35 @@ int arkLSSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, } /*--------------------------------------------------------------- - arkLSSetMassTimes specifies the user-supplied mass + ARKodeSetMassTimes specifies the user-supplied mass matrix-vector product setup and multiply routines. ---------------------------------------------------------------*/ -int arkLSSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, - ARKLsMassTimesVecFn mtimes, void* mtimes_data) +int ARKodeSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, + ARKLsMassTimesVecFn mtimes, void* mtimes_data) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Guard against use for time steppers that do not support mass matrices */ + if (!ark_mem->step_supports_massmatrix) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support non-identity mass matrices"); + return (ARK_STEPPER_UNSUPPORTED); + } + /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* issue error if mtimes function is unusable */ @@ -1338,32 +1817,10 @@ int arkLSSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn mtsetup, return (ARKLS_SUCCESS); } -/* arkLSMassSetUserData sets user_data pointers in arkLSMass */ -int arkLSSetMassUserData(void* arkode_mem, void* user_data) -{ - ARKodeMem ark_mem; - ARKLsMassMem arkls_mem; - int retval; - - /* access ARKLsMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); - if (retval != ARKLS_SUCCESS) { return (retval); } - - /* Set data for mass matrix */ - if (arkls_mem->mass != NULL) { arkls_mem->M_data = user_data; } - - /* Data for Mtimes is set in arkLSSetMassTimes */ - - /* Set data for Preconditioner */ - arkls_mem->P_data = user_data; - - return (ARKLS_SUCCESS); -} - /*--------------------------------------------------------------- - arkLSGetMassWorkSpace + ARKodeGetMassWorkSpace ---------------------------------------------------------------*/ -int arkLSGetMassWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) +int ARKodeGetMassWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; @@ -1371,8 +1828,24 @@ int arkLSGetMassWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) long int lrw, liw; int retval; + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *lenrw = *leniw = 0; + return (ARK_SUCCESS); + } + /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* start with fixed sizes plus vector/matrix pointers */ @@ -1416,170 +1889,350 @@ int arkLSGetMassWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) } /*--------------------------------------------------------------- - arkLSGetNumMassSetups returns the number of mass matrix + ARKodeGetNumMassSetups returns the number of mass matrix solver 'setup' calls ---------------------------------------------------------------*/ -int arkLSGetNumMassSetups(void* arkode_mem, long int* nmsetups) +int ARKodeGetNumMassSetups(void* arkode_mem, long int* nmsetups) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmsetups = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nmsetups = arkls_mem->nmsetups; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassMult returns the number of calls to the user- + ARKodeGetNumMassMult returns the number of calls to the user- supplied or internal mass matrix-vector product multiply routine. ---------------------------------------------------------------*/ -int arkLSGetNumMassMult(void* arkode_mem, long int* nmvevals) +int ARKodeGetNumMassMult(void* arkode_mem, long int* nmvevals) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmvevals = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nmvevals = arkls_mem->nmtimes; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassSolves returns the number of mass matrix + ARKodeGetNumMassSolves returns the number of mass matrix solver 'solve' calls ---------------------------------------------------------------*/ -int arkLSGetNumMassSolves(void* arkode_mem, long int* nmsolves) +int ARKodeGetNumMassSolves(void* arkode_mem, long int* nmsolves) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmsolves = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nmsolves = arkls_mem->nmsolves; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassPrecEvals returns the number of calls to the + ARKodeGetNumMassPrecEvals returns the number of calls to the user- or ARKODE-supplied preconditioner setup routine. ---------------------------------------------------------------*/ -int arkLSGetNumMassPrecEvals(void* arkode_mem, long int* npevals) +int ARKodeGetNumMassPrecEvals(void* arkode_mem, long int* npevals) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *npevals = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *npevals = arkls_mem->npe; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassPrecSolves returns the number of calls to the + ARKodeGetNumMassPrecSolves returns the number of calls to the user- or ARKODE-supplied preconditioner solve routine. ---------------------------------------------------------------*/ -int arkLSGetNumMassPrecSolves(void* arkode_mem, long int* npsolves) +int ARKodeGetNumMassPrecSolves(void* arkode_mem, long int* npsolves) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *npsolves = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *npsolves = arkls_mem->nps; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassIters returns the number of mass matrix solver + ARKodeGetNumMassIters returns the number of mass matrix solver linear iterations (if accessible from the LS object). ---------------------------------------------------------------*/ -int arkLSGetNumMassIters(void* arkode_mem, long int* nmiters) +int ARKodeGetNumMassIters(void* arkode_mem, long int* nmiters) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmiters = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nmiters = arkls_mem->nli; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMassConvFails returns the number of linear solver + ARKodeGetNumMassConvFails returns the number of linear solver convergence failures (as reported by the LS object). ---------------------------------------------------------------*/ -int arkLSGetNumMassConvFails(void* arkode_mem, long int* nmcfails) +int ARKodeGetNumMassConvFails(void* arkode_mem, long int* nmcfails) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmcfails = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *nmcfails = arkls_mem->ncfl; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetMassMatrix returns the current mass matrix. + ARKodeGetCurrentMassMatrix returns the current mass matrix. ---------------------------------------------------------------*/ -int arkLSGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M) +int ARKodeGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return NULL for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *M = NULL; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *M = arkls_mem->M; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetNumMTSetups returns the number of calls to the + ARKodeGetNumMTSetups returns the number of calls to the user-supplied mass matrix-vector product setup routine. ---------------------------------------------------------------*/ -int arkLSGetNumMTSetups(void* arkode_mem, long int* nmtsetups) +int ARKodeGetNumMTSetups(void* arkode_mem, long int* nmtsetups) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return 0 for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *nmtsetups = 0; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output value and return */ *nmtsetups = arkls_mem->nmtsetup; return (ARKLS_SUCCESS); } /*--------------------------------------------------------------- - arkLSGetLastMassFlag returns the last flag set in a ARKLS + ARKodeGetLastMassFlag returns the last flag set in a ARKLS function. ---------------------------------------------------------------*/ -int arkLSGetLastMassFlag(void* arkode_mem, long int* flag) +int ARKodeGetLastMassFlag(void* arkode_mem, long int* flag) { ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure; set output value and return */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* Return immediately if arkode_mem is NULL */ + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Return ARKLS_SUCCESS for incompatible steppers */ + if (!ark_mem->step_supports_massmatrix) + { + *flag = ARKLS_SUCCESS; + return (ARK_SUCCESS); + } + + /* access ARKLsMassMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } + + /* set output and return */ *flag = arkls_mem->last_flag; return (ARKLS_SUCCESS); } @@ -1588,6 +2241,52 @@ int arkLSGetLastMassFlag(void* arkode_mem, long int* flag) ARKLS Private functions ===============================================================*/ +/* arkLSSetUserData sets user_data pointers in arkLS */ +int arkLSSetUserData(ARKodeMem ark_mem, void* user_data) +{ + ARKLsMem arkls_mem; + int retval; + + /* access ARKLsMem structure */ + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); + if (retval != ARKLS_SUCCESS) { return (retval); } + + /* Set data for Jacobian */ + if (!arkls_mem->jacDQ) { arkls_mem->J_data = user_data; } + + /* Set data for Jtimes */ + if (!arkls_mem->jtimesDQ) { arkls_mem->Jt_data = user_data; } + + /* Set data for LinSys */ + if (arkls_mem->user_linsys) { arkls_mem->A_data = user_data; } + + /* Set data for Preconditioner */ + arkls_mem->P_data = user_data; + + return (ARKLS_SUCCESS); +} + +/* arkLSMassSetUserData sets user_data pointers in arkLSMass */ +int arkLSSetMassUserData(ARKodeMem ark_mem, void* user_data) +{ + ARKLsMassMem arkls_mem; + int retval; + + /* access ARKLsMem structure */ + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); + if (retval != ARKLS_SUCCESS) { return (retval); } + + /* Set data for mass matrix */ + if (arkls_mem->mass != NULL) { arkls_mem->M_data = user_data; } + + /* Data for Mtimes is set in arkLSSetMassTimes */ + + /* Set data for Preconditioner */ + arkls_mem->P_data = user_data; + + return (ARKLS_SUCCESS); +} + /*--------------------------------------------------------------- arkLsATimes: @@ -1608,8 +2307,8 @@ int arkLsATimes(void* arkode_mem, N_Vector v, N_Vector z) sunrealtype gamma, gamrat; sunbooleantype dgamma_fail, *jcur; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Access mass matrix solver (if it exists) */ @@ -1667,8 +2366,8 @@ int arkLsPSetup(void* arkode_mem) sunbooleantype dgamma_fail, *jcur; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get gamma values from time step module */ @@ -1708,8 +2407,8 @@ int arkLsPSolve(void* arkode_mem, N_Vector r, N_Vector z, sunrealtype tol, int l sunbooleantype dgamma_fail, *jcur; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* get gamma values from time step module */ @@ -1743,8 +2442,8 @@ int arkLsMTimes(void* arkode_mem, N_Vector v, N_Vector z) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* perform multiply by either calling the user-supplied routine @@ -1799,8 +2498,8 @@ int arkLsMPSetup(void* arkode_mem) ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* only proceed if the mass matrix is time-independent or if @@ -1830,8 +2529,8 @@ int arkLsMPSolve(void* arkode_mem, N_Vector r, N_Vector z, sunrealtype tol, int ARKLsMassMem arkls_mem; int retval; - /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMassMem structures */ + retval = arkLs_AccessARKODEMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* call the user-supplied psolve routine, and accumulate count */ @@ -1855,8 +2554,8 @@ int arkLsDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, ARKRhsFn fi; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* verify that Jac is non-NULL */ @@ -2129,8 +2828,8 @@ int arkLsDQJtimes(N_Vector v, N_Vector Jv, sunrealtype t, N_Vector y, sunrealtype sig, siginv; int iter, retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Initialize perturbation to 1/||v|| */ @@ -2175,8 +2874,8 @@ static int arkLsLinSys(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, ARKLsMem arkls_mem; int retval; - /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + /* access ARKodeMem and ARKLsMem structures */ + retval = arkLs_AccessARKODELMem(arkode_mem, __func__, &ark_mem, &arkls_mem); if (retval != ARKLS_SUCCESS) { return (retval); } /* Check if Jacobian needs to be updated */ @@ -2260,25 +2959,23 @@ static int arkLsLinSys(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix A, arkLsInitialize performs remaining initializations specific to the linear solver interface (and solver itself) ---------------------------------------------------------------*/ -int arkLsInitialize(void* arkode_mem) +int arkLsInitialize(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMem arkls_mem; ARKLsMassMem arkls_massmem; int retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* access ARKLsMassMem (if applicable) */ arkls_massmem = NULL; if (ark_mem->step_getmassmem != NULL) { - if (ark_mem->step_getmassmem(arkode_mem) != NULL) + if (ark_mem->step_getmassmem(ark_mem) != NULL) { - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, - &arkls_massmem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_massmem); if (retval != ARK_SUCCESS) { return (retval); } } } @@ -2419,13 +3116,13 @@ int arkLsInitialize(void* arkode_mem) if ((arkls_mem->A == NULL) && (arkls_mem->pset == NULL) && (ark_mem->step_disablelsetup != NULL)) { - ark_mem->step_disablelsetup(arkode_mem); + ark_mem->step_disablelsetup(ark_mem); } /* When using a matrix-embedded linear solver, disable lsetup call and solution scaling */ if (SUNLinSolGetType(arkls_mem->LS) == SUNLINEARSOLVER_MATRIX_EMBEDDED) { - ark_mem->step_disablelsetup(arkode_mem); + ark_mem->step_disablelsetup(ark_mem); arkls_mem->scalesol = SUNFALSE; } @@ -2447,11 +3144,10 @@ int arkLsInitialize(void* arkode_mem) This routine then calls the LS 'setup' routine with A. ---------------------------------------------------------------*/ -int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, +int arkLsSetup(ARKodeMem ark_mem, int convfail, sunrealtype tpred, N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3) { - ARKodeMem ark_mem = NULL; ARKLsMem arkls_mem = NULL; void* ark_step_massmem = NULL; SUNMatrix M = NULL; @@ -2460,7 +3156,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, int retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Immediately return when using matrix-embedded linear solver */ @@ -2477,7 +3173,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, arkls_mem->fcur = fpred; /* get gamma values from time step module */ - arkls_mem->last_flag = ark_mem->step_getgammas(arkode_mem, &gamma, &gamrat, + arkls_mem->last_flag = ark_mem->step_getgammas(ark_mem, &gamma, &gamrat, &jcur, &dgamma_fail); if (arkls_mem->last_flag) { @@ -2498,7 +3194,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, /* Check for mass matrix module and setup mass matrix */ if (ark_mem->step_getmassmem) { - ark_step_massmem = ark_mem->step_getmassmem(arkode_mem); + ark_step_massmem = ark_mem->step_getmassmem(ark_mem); } if (ark_step_massmem) @@ -2507,8 +3203,7 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, M = ((ARKLsMassMem)ark_step_massmem)->M; /* Setup mass matrix linear solver (including recomputation of mass matrix) */ - arkls_mem->last_flag = arkLsMassSetup(arkode_mem, tpred, vtemp1, vtemp2, - vtemp3); + arkls_mem->last_flag = arkLsMassSetup(ark_mem, tpred, vtemp1, vtemp2, vtemp3); if (arkls_mem->last_flag) { arkProcessError(ark_mem, ARKLS_SUNMAT_FAIL, __LINE__, __func__, __FILE__, @@ -2591,11 +3286,10 @@ int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, When using a non-NULL SUNMatrix, this will additionally scale the solution appropriately when gamrat != 1. ---------------------------------------------------------------*/ -int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, +int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, N_Vector fnow, sunrealtype eRNrm, int mnewt) { sunrealtype bnorm, resnorm; - ARKodeMem ark_mem; ARKLsMem arkls_mem; sunrealtype gamma, gamrat, delta, deltar, rwt_mean; sunbooleantype dgamma_fail, *jcur; @@ -2603,7 +3297,7 @@ int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, int nli_inc, retval; /* access ARKLsMem structure */ - retval = arkLs_AccessLMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessLMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set scalar tcur and vectors ycur and fcur for use by the @@ -2697,7 +3391,7 @@ int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, account for change in gamma (this is only beneficial if M==I) */ if (arkls_mem->scalesol) { - arkls_mem->last_flag = ark_mem->step_getgammas(arkode_mem, &gamma, &gamrat, + arkls_mem->last_flag = ark_mem->step_getgammas(ark_mem, &gamma, &gamrat, &jcur, &dgamma_fail); if (arkls_mem->last_flag != ARK_SUCCESS) { @@ -2787,16 +3481,14 @@ int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tnow, N_Vector ynow, arkLsFree frees memory associates with the ARKLs system solver interface. ---------------------------------------------------------------*/ -int arkLsFree(void* arkode_mem) +int arkLsFree(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMem arkls_mem; void* ark_step_lmem; /* Return immediately if ARKodeMem, ARKLsMem are NULL */ - if (arkode_mem == NULL) { return (ARKLS_SUCCESS); } - ark_mem = (ARKodeMem)arkode_mem; - ark_step_lmem = ark_mem->step_getlinmem(arkode_mem); + if (ark_mem == NULL) { return (ARKLS_SUCCESS); } + ark_step_lmem = ark_mem->step_getlinmem(ark_mem); if (ark_step_lmem == NULL) { return (ARKLS_SUCCESS); } arkls_mem = (ARKLsMem)ark_step_lmem; @@ -2839,14 +3531,13 @@ int arkLsFree(void* arkode_mem) arkLsMassInitialize performs remaining initializations specific to the mass matrix solver interface (and solver itself) ---------------------------------------------------------------*/ -int arkLsMassInitialize(void* arkode_mem) +int arkLsMassInitialize(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; int retval; /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* reset counters */ @@ -2898,13 +3589,13 @@ int arkLsMassInitialize(void* arkode_mem) if ((arkls_mem->M == NULL) && (arkls_mem->pset == NULL) && (arkls_mem->mtsetup == NULL) && (ark_mem->step_disablemsetup != NULL)) { - ark_mem->step_disablemsetup(arkode_mem); + ark_mem->step_disablemsetup(ark_mem); } /* When using a matrix-embedded linear solver, disable lsetup call */ if (SUNLinSolGetType(arkls_mem->LS) == SUNLINEARSOLVER_MATRIX_EMBEDDED) { - ark_mem->step_disablemsetup(arkode_mem); + ark_mem->step_disablemsetup(ark_mem); } /* Call LS initialize routine */ @@ -2915,16 +3606,15 @@ int arkLsMassInitialize(void* arkode_mem) /*--------------------------------------------------------------- arkLsMassSetup calls the LS 'setup' routine. ---------------------------------------------------------------*/ -int arkLsMassSetup(void* arkode_mem, sunrealtype t, N_Vector vtemp1, +int arkLsMassSetup(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; sunbooleantype call_mtsetup, call_mvsetup, call_lssetup; int retval; /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Immediately return when using matrix-embedded linear solver */ @@ -3069,16 +3759,15 @@ int arkLsMassSetup(void* arkode_mem, sunrealtype t, N_Vector vtemp1, and scaling vectors, calling the solver, and accumulating statistics from the solve for use/reporting by ARKODE. ---------------------------------------------------------------*/ -int arkLsMassSolve(void* arkode_mem, N_Vector b, sunrealtype nlscoef) +int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef) { sunrealtype resnorm, delta, rwt_mean; - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; long int nps_inc; int nli_inc, retval; /* access ARKLsMassMem structure */ - retval = arkLs_AccessMassMem(arkode_mem, __func__, &ark_mem, &arkls_mem); + retval = arkLs_AccessMassMem(ark_mem, __func__, &arkls_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set input tolerance for iterative solvers (in 2-norm) */ @@ -3214,16 +3903,14 @@ int arkLsMassSolve(void* arkode_mem, N_Vector b, sunrealtype nlscoef) arkLsMassFree frees memory associates with the ARKLs mass matrix solver interface. ---------------------------------------------------------------*/ -int arkLsMassFree(void* arkode_mem) +int arkLsMassFree(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKLsMassMem arkls_mem; void* ark_step_massmem; /* Return immediately if ARKodeMem, ARKLsMassMem are NULL */ - if (arkode_mem == NULL) { return (ARKLS_SUCCESS); } - ark_mem = (ARKodeMem)arkode_mem; - ark_step_massmem = ark_mem->step_getmassmem(arkode_mem); + if (ark_mem == NULL) { return (ARKLS_SUCCESS); } + ark_step_massmem = ark_mem->step_getmassmem(ark_mem); if (ark_step_massmem == NULL) { return (ARKLS_SUCCESS); } arkls_mem = (ARKLsMassMem)ark_step_massmem; @@ -3309,14 +3996,16 @@ int arkLsInitializeMassCounters(ARKLsMassMem arkls_mem) } /*--------------------------------------------------------------- - arkLs_AccessLMem and arkLs_AccessMassMem: + arkLs_AccessARKODELMem, arkLs_AccessLMem, + arkLs_AccessARKODEMassMem and arkLs_AccessMassMem: Shortcut routines to unpack ark_mem, ls_mem and mass_mem - structures from void* pointer. If any is missing it returns - ARKLS_MEM_NULL, ARKLS_LMEM_NULL or ARKLS_MASSMEM_NULL. + structures from void* pointer and ark_mem structure. If any + is missing it returns ARKLS_MEM_NULL, ARKLS_LMEM_NULL or + ARKLS_MASSMEM_NULL. ---------------------------------------------------------------*/ -int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKLsMem* arkls_mem) +int arkLs_AccessARKODELMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMem* arkls_mem) { void* ark_step_lmem; if (arkode_mem == NULL) @@ -3326,7 +4015,7 @@ int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; - ark_step_lmem = (*ark_mem)->step_getlinmem(arkode_mem); + ark_step_lmem = (*ark_mem)->step_getlinmem(*ark_mem); if (ark_step_lmem == NULL) { arkProcessError(*ark_mem, ARKLS_LMEM_NULL, __LINE__, fname, __FILE__, @@ -3337,8 +4026,22 @@ int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_SUCCESS); } -int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKLsMassMem* arkls_mem) +int arkLs_AccessLMem(ARKodeMem ark_mem, const char* fname, ARKLsMem* arkls_mem) +{ + void* ark_step_lmem; + ark_step_lmem = ark_mem->step_getlinmem(ark_mem); + if (ark_step_lmem == NULL) + { + arkProcessError(ark_mem, ARKLS_LMEM_NULL, __LINE__, fname, __FILE__, + MSG_LS_LMEM_NULL); + return (ARKLS_LMEM_NULL); + } + *arkls_mem = (ARKLsMem)ark_step_lmem; + return (ARKLS_SUCCESS); +} + +int arkLs_AccessARKODEMassMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMassMem* arkls_mem) { void* ark_step_massmem; if (arkode_mem == NULL) @@ -3348,7 +4051,7 @@ int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; - ark_step_massmem = (*ark_mem)->step_getmassmem(arkode_mem); + ark_step_massmem = (*ark_mem)->step_getmassmem(*ark_mem); if (ark_step_massmem == NULL) { arkProcessError(*ark_mem, ARKLS_MASSMEM_NULL, __LINE__, fname, __FILE__, @@ -3359,6 +4062,21 @@ int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, return (ARKLS_SUCCESS); } -/*--------------------------------------------------------------- +int arkLs_AccessMassMem(ARKodeMem ark_mem, const char* fname, + ARKLsMassMem* arkls_mem) +{ + void* ark_step_massmem; + ark_step_massmem = ark_mem->step_getmassmem(ark_mem); + if (ark_step_massmem == NULL) + { + arkProcessError(ark_mem, ARKLS_MASSMEM_NULL, __LINE__, fname, __FILE__, + MSG_LS_MASSMEM_NULL); + return (ARKLS_MASSMEM_NULL); + } + *arkls_mem = (ARKLsMassMem)ark_step_massmem; + return (ARKLS_SUCCESS); +} + +/*=============================================================== EOF - ---------------------------------------------------------------*/ + ===============================================================*/ diff --git a/src/arkode/arkode_ls_impl.h b/src/arkode/arkode_ls_impl.h index 8dc2723c2f..8a296d83d5 100644 --- a/src/arkode/arkode_ls_impl.h +++ b/src/arkode/arkode_ls_impl.h @@ -11,7 +11,8 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End *--------------------------------------------------------------- - * Implementation header file for ARKODE's linear solver interface. + * Implementation header file for ARKODE's linear solver + * interface. *--------------------------------------------------------------*/ #ifndef _ARKLS_IMPL_H @@ -217,97 +218,40 @@ int arkLsBandDQJac(sunrealtype t, N_Vector y, N_Vector fy, SUNMatrix Jac, N_Vector tmp1, N_Vector tmp2); /* Generic linit/lsetup/lsolve/lfree interface routines for ARKODE to call */ -int arkLsInitialize(void* arkode_mem); - -int arkLsSetup(void* arkode_mem, int convfail, sunrealtype tpred, +int arkLsInitialize(ARKodeMem ark_mem); +int arkLsSetup(ARKodeMem ark_mem, int convfail, sunrealtype tpred, N_Vector ypred, N_Vector fpred, sunbooleantype* jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); - -int arkLsSolve(void* arkode_mem, N_Vector b, sunrealtype tcur, N_Vector ycur, +int arkLsSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype tcur, N_Vector ycur, N_Vector fcur, sunrealtype eRnrm, int mnewt); - -int arkLsFree(void* arkode_mem); +int arkLsFree(ARKodeMem ark_mem); /* Generic minit/msetup/mmult/msolve/mfree routines for ARKODE to call */ -int arkLsMassInitialize(void* arkode_mem); - -int arkLsMassSetup(void* arkode_mem, sunrealtype t, N_Vector vtemp1, +int arkLsMassInitialize(ARKodeMem ark_mem); +int arkLsMassSetup(ARKodeMem ark_mem, sunrealtype t, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3); - int arkLsMassMult(void* arkode_mem, N_Vector v, N_Vector Mv); - -int arkLsMassSolve(void* arkode_mem, N_Vector b, sunrealtype nlscoef); - -int arkLsMassFree(void* arkode_mem); +int arkLsMassSolve(ARKodeMem ark_mem, N_Vector b, sunrealtype nlscoef); +int arkLsMassFree(ARKodeMem ark_mem); /* Auxilliary functions */ int arkLsInitializeCounters(ARKLsMem arkls_mem); - int arkLsInitializeMassCounters(ARKLsMassMem arkls_mem); - -int arkLs_AccessLMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, - ARKLsMem* arkls_mem); - -int arkLs_AccessMassMem(void* arkode_mem, const char* fname, ARKodeMem* ark_mem, +int arkLs_AccessARKODELMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMem* arkls_mem); +int arkLs_AccessLMem(ARKodeMem ark_mem, const char* fname, ARKLsMem* arkls_mem); +int arkLs_AccessARKODEMassMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKLsMassMem* arkls_mem); +int arkLs_AccessMassMem(ARKodeMem ark_mem, const char* fname, ARKLsMassMem* arkls_mem); /* Set/get routines called by time-stepper module */ -int arkLSSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A); - -int arkLSSetMassLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix M, +int arkLSSetLinearSolver(ARKodeMem ark_mem, SUNLinearSolver LS, SUNMatrix A); +int arkLSSetMassLinearSolver(ARKodeMem ark_mem, SUNLinearSolver LS, SUNMatrix M, sunbooleantype time_dep); - -int arkLSSetJacFn(void* arkode_mem, ARKLsJacFn jac); -int arkLSSetMassFn(void* arkode_mem, ARKLsMassFn mass); -int arkLSSetEpsLin(void* arkode_mem, sunrealtype eplifac); -int arkLSSetMassEpsLin(void* arkode_mem, sunrealtype eplifac); -int arkLSSetNormFactor(void* arkode_mem, sunrealtype nrmfac); -int arkLSSetMassNormFactor(void* arkode_mem, sunrealtype nrmfac); -int arkLSSetJacEvalFrequency(void* arkode_mem, long int msbj); -int arkLSSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff); -int arkLSSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, - ARKLsPrecSolveFn psolve); -int arkLSSetMassPreconditioner(void* arkode_mem, ARKLsMassPrecSetupFn psetup, - ARKLsMassPrecSolveFn psolve); -int arkLSSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, - ARKLsJacTimesVecFn jtimes); -int arkLSSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn); -int arkLSSetMassTimes(void* arkode_mem, ARKLsMassTimesSetupFn msetup, - ARKLsMassTimesVecFn mtimes, void* mtimes_data); -int arkLSSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys); - -int arkLSSetUserData(void* arkode_mem, void* user_data); -int arkLSSetMassUserData(void* arkode_mem, void* user_data); - -int arkLSGetJac(void* arkode_mem, SUNMatrix* J); -int arkLSGetJacTime(void* arkode_mem, sunrealtype* t_J); -int arkLSGetJacNumSteps(void* arkode_mem, long int* nst_J); -int arkLSGetWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS); -int arkLSGetNumJacEvals(void* arkode_mem, long int* njevals); -int arkLSGetNumPrecEvals(void* arkode_mem, long int* npevals); -int arkLSGetNumPrecSolves(void* arkode_mem, long int* npsolves); -int arkLSGetNumLinIters(void* arkode_mem, long int* nliters); -int arkLSGetNumConvFails(void* arkode_mem, long int* nlcfails); -int arkLSGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups); -int arkLSGetNumJtimesEvals(void* arkode_mem, long int* njvevals); -int arkLSGetNumRhsEvals(void* arkode_mem, long int* nfevalsLS); -int arkLSGetLastFlag(void* arkode_mem, long int* flag); - -int arkLSGetMassWorkSpace(void* arkode_mem, long int* lenrwMLS, - long int* leniwMLS); -int arkLSGetNumMassSetups(void* arkode_mem, long int* nmsetups); -int arkLSGetNumMassMult(void* arkode_mem, long int* nmvevals); -int arkLSGetNumMassMatvecSetups(void* arkode_mem, long int* nmvsetups); -int arkLSGetNumMassSolves(void* arkode_mem, long int* nmsolves); -int arkLSGetNumMassPrecEvals(void* arkode_mem, long int* nmpevals); -int arkLSGetNumMassPrecSolves(void* arkode_mem, long int* nmpsolves); -int arkLSGetNumMassIters(void* arkode_mem, long int* nmiters); -int arkLSGetNumMassConvFails(void* arkode_mem, long int* nmcfails); -int arkLSGetNumMTSetups(void* arkode_mem, long int* nmtsetups); -int arkLSGetCurrentMassMatrix(void* arkode_mem, SUNMatrix* M); -int arkLSGetLastMassFlag(void* arkode_mem, long int* flag); - -char* arkLSGetReturnFlagName(long int flag); +int arkLSSetUserData(ARKodeMem ark_mem, void* user_data); +int arkLSSetMassUserData(ARKodeMem ark_mem, void* user_data); +int arkLSGetCurrentMassMatrix(ARKodeMem ark_mem, SUNMatrix* M); /*--------------------------------------------------------------- Error Messages diff --git a/src/arkode/arkode_mri_tables.c b/src/arkode/arkode_mri_tables.c index 11d0d83697..dd4f35d051 100644 --- a/src/arkode/arkode_mri_tables.c +++ b/src/arkode/arkode_mri_tables.c @@ -204,7 +204,7 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, if (type == MRISTEP_MERK) { MRIC->ngroup = stages; - MRIC->group = (int**)malloc(stages*sizeof(int*)); + MRIC->group = (int**)malloc(stages * sizeof(int*)); if (!(MRIC->group)) { MRIStepCoupling_Free(MRIC); @@ -213,16 +213,13 @@ MRIStepCoupling MRIStepCoupling_Alloc(int nmat, int stages, for (i = 0; i < stages; i++) { MRIC->group[i] = NULL; - MRIC->group[i] = (int*)malloc(stages*sizeof(int)); + MRIC->group[i] = (int*)malloc(stages * sizeof(int)); if (!(MRIC->group[i])) { MRIStepCoupling_Free(MRIC); return (NULL); } - for (j = 0; j < stages; j++) - { - MRIC->group[i][j] = -1; - } + for (j = 0; j < stages; j++) { MRIC->group[i][j] = -1; } } } diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index 30bff39906..61c14323c6 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -27,12 +27,9 @@ #include "arkode_mristep_impl.h" /*=============================================================== - MRIStep Exported functions -- Required + Exported functions ===============================================================*/ -/*--------------------------------------------------------------- - Create MRIStep integrator memory struct - ---------------------------------------------------------------*/ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, MRIStepInnerStepper stepper, SUNContext sunctx) { @@ -99,29 +96,61 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_ARKMEM_FAIL); - MRIStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } memset(step_mem, 0, sizeof(struct ARKodeMRIStepMemRec)); /* Attach step_mem structure and function pointers to ark_mem */ - ark_mem->step_attachlinsol = mriStep_AttachLinsol; - ark_mem->step_disablelsetup = mriStep_DisableLSetup; - ark_mem->step_getlinmem = mriStep_GetLmem; - ark_mem->step_getimplicitrhs = mriStep_GetImplicitRHS; - ark_mem->step_getgammas = mriStep_GetGammas; - ark_mem->step_init = mriStep_Init; - ark_mem->step_fullrhs = mriStep_FullRHS; - ark_mem->step = mriStep_TakeStepMRIGARK; - ark_mem->step_mem = (void*)step_mem; - - /* Set default values for MRIStep optional inputs */ - retval = MRIStepSetDefaults((void*)ark_mem); + ark_mem->step_attachlinsol = mriStep_AttachLinsol; + ark_mem->step_disablelsetup = mriStep_DisableLSetup; + ark_mem->step_getlinmem = mriStep_GetLmem; + ark_mem->step_getimplicitrhs = mriStep_GetImplicitRHS; + ark_mem->step_getgammas = mriStep_GetGammas; + ark_mem->step_init = mriStep_Init; + ark_mem->step_fullrhs = mriStep_FullRHS; + ark_mem->step = mriStep_TakeStepMRIGARK; + ark_mem->step_setuserdata = mriStep_SetUserData; + ark_mem->step_printallstats = mriStep_PrintAllStats; + ark_mem->step_writeparameters = mriStep_WriteParameters; + ark_mem->step_resize = mriStep_Resize; + ark_mem->step_reset = mriStep_Reset; + ark_mem->step_free = mriStep_Free; + ark_mem->step_printmem = mriStep_PrintMem; + ark_mem->step_setdefaults = mriStep_SetDefaults; + ark_mem->step_computestate = mriStep_ComputeState; + ark_mem->step_setorder = mriStep_SetOrder; + ark_mem->step_setnonlinearsolver = mriStep_SetNonlinearSolver; + ark_mem->step_setlinear = mriStep_SetLinear; + ark_mem->step_setnonlinear = mriStep_SetNonlinear; + ark_mem->step_setnlsrhsfn = mriStep_SetNlsRhsFn; + ark_mem->step_setdeduceimplicitrhs = mriStep_SetDeduceImplicitRhs; + ark_mem->step_setnonlincrdown = mriStep_SetNonlinCRDown; + ark_mem->step_setnonlinrdiv = mriStep_SetNonlinRDiv; + ark_mem->step_setdeltagammamax = mriStep_SetDeltaGammaMax; + ark_mem->step_setlsetupfrequency = mriStep_SetLSetupFrequency; + ark_mem->step_setpredictormethod = mriStep_SetPredictorMethod; + ark_mem->step_setmaxnonliniters = mriStep_SetMaxNonlinIters; + ark_mem->step_setnonlinconvcoef = mriStep_SetNonlinConvCoef; + ark_mem->step_setstagepredictfn = mriStep_SetStagePredictFn; + ark_mem->step_getnumlinsolvsetups = mriStep_GetNumLinSolvSetups; + ark_mem->step_getcurrentgamma = mriStep_GetCurrentGamma; + ark_mem->step_getnonlinearsystemdata = mriStep_GetNonlinearSystemData; + ark_mem->step_getnumnonlinsolviters = mriStep_GetNumNonlinSolvIters; + ark_mem->step_getnumnonlinsolvconvfails = mriStep_GetNumNonlinSolvConvFails; + ark_mem->step_getnonlinsolvstats = mriStep_GetNonlinSolvStats; + ark_mem->step_supports_adaptive = SUNTRUE; + ark_mem->step_supports_implicit = SUNTRUE; + ark_mem->step_supports_relaxation = SUNTRUE; + ark_mem->step_mem = (void*)step_mem; + + /* Set default values for optional inputs */ + retval = mriStep_SetDefaults((void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Error setting default solver options"); - MRIStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -153,15 +182,15 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, "Error creating default Newton solver"); - MRIStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } - retval = MRIStepSetNonlinearSolver(ark_mem, NLS); + retval = ARKodeSetNonlinearSolver(ark_mem, NLS); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, "Error attaching default Newton solver"); - MRIStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } step_mem->ownNLS = SUNTRUE; @@ -173,6 +202,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, step_mem->lsolve = NULL; step_mem->lfree = NULL; step_mem->lmem = NULL; + /* Initialize initial error norm */ step_mem->eRNrm = ONE; @@ -187,6 +217,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, /* Initialize fused op work space */ step_mem->cvals = NULL; step_mem->Xvecs = NULL; + /* Initialize adaptivity parameters */ step_mem->inner_control = ZERO; step_mem->inner_dsm = ONE; @@ -202,7 +233,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Unable to initialize main ARKODE infrastructure"); - MRIStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -215,7 +246,7 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, "A required inner stepper function is NULL"); - MRIStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -224,26 +255,123 @@ void* MRIStepCreate(ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, N_Vector y0, } /*--------------------------------------------------------------- - MRIStepResize: + MRIStepReInit: - This routine resizes the memory within the MRIStep module. - It first resizes the main ARKODE infrastructure memory, and - then resizes its own data. + This routine re-initializes the MRIStep module to solve a new + problem of the same size as was previously solved (all counter + values are set to 0). + + NOTE: the inner stepper needs to be reinitialized before + calling this function. ---------------------------------------------------------------*/ -int MRIStepResize(void* arkode_mem, N_Vector y0, sunrealtype t0, - ARKVecResizeFn resize, void* resize_data) +int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, + N_Vector y0) { ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + SUNNonlinearSolver NLS; + int retval; + + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + + /* Check if ark_mem was allocated */ + if (ark_mem->MallocDone == SUNFALSE) + { + arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MALLOC); + return (ARK_NO_MALLOC); + } + + /* Check that at least one of fse, fsi is supplied and is to be used */ + if (fse == NULL && fsi == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NULL_F); + return (ARK_ILL_INPUT); + } + + /* Check that y0 is supplied */ + if (y0 == NULL) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + MSG_ARK_NULL_Y0); + return (ARK_ILL_INPUT); + } + + /* Set implicit/explicit problem based on function pointers */ + step_mem->explicit_rhs = (fse == NULL) ? SUNFALSE : SUNTRUE; + step_mem->implicit_rhs = (fsi == NULL) ? SUNFALSE : SUNTRUE; + + /* Create a default Newton NLS object (just in case; will be deleted if + the user attaches a nonlinear solver) */ + if (step_mem->implicit_rhs && !(step_mem->NLS)) + { + NLS = SUNNonlinSol_Newton(y0, ark_mem->sunctx); + if (!NLS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Error creating default Newton solver"); + ARKodeFree((void**)&ark_mem); + return (ARK_MEM_FAIL); + } + retval = ARKodeSetNonlinearSolver(ark_mem, NLS); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Error attaching default Newton solver"); + ARKodeFree((void**)&ark_mem); + return (ARK_MEM_FAIL); + } + step_mem->ownNLS = SUNTRUE; + } + + /* ReInitialize main ARKODE infrastructure */ + retval = arkInit(arkode_mem, t0, y0, FIRST_INIT); + if (retval != ARK_SUCCESS) + { + arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, + "Unable to reinitialize main ARKODE infrastructure"); + return (retval); + } + + /* Copy the input parameters into ARKODE state */ + step_mem->fse = fse; + step_mem->fsi = fsi; + + /* Initialize all the counters */ + step_mem->nfse = 0; + step_mem->nfsi = 0; + step_mem->nsetups = 0; + step_mem->nstlp = 0; + step_mem->nls_iters = 0; + + return (ARK_SUCCESS); +} + +/*=============================================================== + Interface routines supplied to ARKODE + ===============================================================*/ + +/*--------------------------------------------------------------- + mriStep_Resize: + + This routine resizes the memory within the MRIStep module. + ---------------------------------------------------------------*/ +int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) +{ ARKodeMRIStepMem step_mem; SUNNonlinearSolver NLS; sunindextype lrw1, liw1, lrw_diff, liw_diff; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Determing change in vector sizes */ + /* Determine change in vector sizes */ lrw1 = liw1 = 0; if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } lrw_diff = lrw1 - ark_mem->lrw1; @@ -251,15 +379,6 @@ int MRIStepResize(void* arkode_mem, N_Vector y0, sunrealtype t0, ark_mem->lrw1 = lrw1; ark_mem->liw1 = liw1; - /* resize ARKODE infrastructure memory (use hscale = 1.0) */ - retval = arkResize(ark_mem, y0, SUN_RCONST(1.0), t0, resize, resize_data); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to resize main ARKODE infrastructure"); - return (retval); - } - /* Resize Fse */ if (step_mem->Fse) { @@ -337,8 +456,8 @@ int MRIStepResize(void* arkode_mem, N_Vector y0, sunrealtype t0, return (ARK_MEM_FAIL); } - /* attach new Newton NLS object to MRIStep */ - retval = MRIStepSetNonlinearSolver(ark_mem, NLS); + /* attach new Newton NLS object */ + retval = ARKodeSetNonlinearSolver(ark_mem, NLS); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, @@ -365,130 +484,22 @@ int MRIStepResize(void* arkode_mem, N_Vector y0, sunrealtype t0, } /*--------------------------------------------------------------- - MRIStepReInit: - - This routine re-initializes the MRIStep module to solve a new - problem of the same size as was previously solved (all counter - values are set to 0). - - NOTE: the inner stepper needs to be reinitialized before - calling this function. - ---------------------------------------------------------------*/ -int MRIStepReInit(void* arkode_mem, ARKRhsFn fse, ARKRhsFn fsi, sunrealtype t0, - N_Vector y0) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - SUNNonlinearSolver NLS; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Check if ark_mem was allocated */ - if (ark_mem->MallocDone == SUNFALSE) - { - arkProcessError(ark_mem, ARK_NO_MALLOC, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MALLOC); - return (ARK_NO_MALLOC); - } - - /* Check that at least one of fse, fsi is supplied and is to be used */ - if (fse == NULL && fsi == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_NULL_F); - return (ARK_ILL_INPUT); - } - - /* Check that y0 is supplied */ - if (y0 == NULL) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - MSG_ARK_NULL_Y0); - return (ARK_ILL_INPUT); - } - - /* Set implicit/explicit problem based on function pointers */ - step_mem->explicit_rhs = (fse == NULL) ? SUNFALSE : SUNTRUE; - step_mem->implicit_rhs = (fsi == NULL) ? SUNFALSE : SUNTRUE; - - /* Create a default Newton NLS object (just in case; will be deleted if - the user attaches a nonlinear solver) */ - if (step_mem->implicit_rhs && !(step_mem->NLS)) - { - NLS = SUNNonlinSol_Newton(y0, ark_mem->sunctx); - if (!NLS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Error creating default Newton solver"); - MRIStepFree((void**)&ark_mem); - return (ARK_MEM_FAIL); - } - retval = MRIStepSetNonlinearSolver(ark_mem, NLS); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, - "Error attaching default Newton solver"); - MRIStepFree((void**)&ark_mem); - return (ARK_MEM_FAIL); - } - step_mem->ownNLS = SUNTRUE; - } - - /* ReInitialize main ARKODE infrastructure */ - retval = arkInit(arkode_mem, t0, y0, FIRST_INIT); - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to reinitialize main ARKODE infrastructure"); - return (retval); - } - /* Initialize initial error norm */ - step_mem->eRNrm = ONE; - - /* Copy the input parameters into ARKODE state */ - step_mem->fse = fse; - step_mem->fsi = fsi; - - /* Initialize all the counters */ - step_mem->nfse = 0; - step_mem->nfsi = 0; - step_mem->nsetups = 0; - step_mem->nstlp = 0; - step_mem->nls_iters = 0; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepReset: + mriStep_Reset: This routine resets the MRIStep module state to solve the same problem from the given time with the input state (all counter - values are retained). + values are retained). It is called after the main ARKODE + infrastructure is reset. ---------------------------------------------------------------*/ -int MRIStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +int mriStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Initialize main ARKODE infrastructure */ - retval = arkInit(ark_mem, tR, yR, RESET_INIT); - - if (retval != ARK_SUCCESS) - { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to initialize main ARKODE infrastructure"); - return (retval); - } - /* Reset the inner integrator with this same state */ retval = mriStepInnerStepper_Reset(step_mem->stepper, tR, yR); if (retval != ARK_SUCCESS) { return (ARK_INNERSTEP_FAIL); } @@ -497,136 +508,17 @@ int MRIStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) } /*--------------------------------------------------------------- - MRIStepSStolerances, MRIStepSVtolerances, MRIStepWFtolerances: - - These routines set integration tolerances (wrappers for general - ARKODE utility routines) - ---------------------------------------------------------------*/ -int MRIStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) -{ - /* unpack ark_mem, call arkSStolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkSStolerances(ark_mem, reltol, abstol)); -} - -int MRIStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) -{ - /* unpack ark_mem, call arkSVtolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkSVtolerances(ark_mem, reltol, abstol)); -} - -int MRIStepWFtolerances(void* arkode_mem, ARKEwtFn efun) -{ - /* unpack ark_mem, call arkWFtolerances, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkWFtolerances(ark_mem, efun)); -} - -/*--------------------------------------------------------------- - MRIStepRootInit: - - Initialize (attach) a rootfinding problem to the stepper - (wrappers for general ARKODE utility routine) - ---------------------------------------------------------------*/ -int MRIStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) -{ - /* unpack ark_mem, call arkRootInit, and return */ - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkRootInit(ark_mem, nrtfn, g)); -} - -/*--------------------------------------------------------------- - MRIStepEvolve: - - This is the main time-integration driver (wrappers for general - ARKODE utility routine) - ---------------------------------------------------------------*/ -int MRIStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask) -{ - /* unpack ark_mem, call arkEvolve, and return */ - int retval; - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkEvolve(ark_mem, tout, yout, tret, itask); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); -} - -/*--------------------------------------------------------------- - MRIStepGetDky: - - This returns interpolated output of the solution or its - derivatives over the most-recently-computed step (wrapper for - generic ARKODE utility routine) - ---------------------------------------------------------------*/ -int MRIStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) -{ - /* unpack ark_mem, call arkGetDky, and return */ - int retval; - ARKodeMem ark_mem; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkGetDky(ark_mem, t, k, dky); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); -} - -/*--------------------------------------------------------------- - MRIStepComputeState: + mriStep_ComputeState: Computes y based on the current prediction and given correction. ---------------------------------------------------------------*/ -int MRIStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) +int mriStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z) { int retval; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } N_VLinearSum(ONE, step_mem->zpred, ONE, zcor, z); @@ -635,20 +527,17 @@ int MRIStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) } /*--------------------------------------------------------------- - MRIStepFree frees all MRIStep memory, and then calls an ARKODE - utility routine to free the ARKODE infrastructure memory. + mriStep_Free frees all MRIStep memory. ---------------------------------------------------------------*/ -void MRIStepFree(void** arkode_mem) +void mriStep_Free(ARKodeMem ark_mem) { sunindextype Cliw, Clrw; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; - /* nothing to do if arkode_mem is already NULL */ - if (*arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL MRIStep module */ - ark_mem = (ARKodeMem)(*arkode_mem); if (ark_mem->step_mem != NULL) { step_mem = (ARKodeMRIStepMem)ark_mem->step_mem; @@ -753,35 +642,23 @@ void MRIStepFree(void** arkode_mem) free(ark_mem->step_mem); ark_mem->step_mem = NULL; } - - /* free memory for overall ARKODE infrastructure */ - arkFree(arkode_mem); } /*--------------------------------------------------------------- - MRIStepPrintMem: + mriStep_PrintMem: - This routine outputs the memory from the MRIStep structure and - the main ARKODE infrastructure to a specified file pointer - (useful when debugging). + This routine outputs the memory from the MRIStep structure to + a specified file pointer (useful when debugging). ---------------------------------------------------------------*/ -void MRIStepPrintMem(void* arkode_mem, FILE* outfile) +void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int i, retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } - /* if outfile==NULL, set it to stdout */ - if (outfile == NULL) { outfile = stdout; } - - /* output data from main ARKODE infrastructure */ - fprintf(outfile, "MRIStep Slow Stepper Mem:\n"); - arkPrintMem(ark_mem, outfile); - /* output integer quantities */ fprintf(outfile, "MRIStep: q = %i\n", step_mem->q); fprintf(outfile, "MRIStep: p = %i\n", step_mem->p); @@ -865,18 +742,9 @@ void MRIStepPrintMem(void* arkode_mem, FILE* outfile) /* print the inner stepper memory */ mriStepInnerStepper_PrintMem(step_mem->stepper, outfile); - return; } -/*=============================================================== - MRIStep Private functions - ===============================================================*/ - -/*--------------------------------------------------------------- - Interface routines supplied to ARKODE - ---------------------------------------------------------------*/ - /*--------------------------------------------------------------- mriStep_AttachLinsol: @@ -884,21 +752,20 @@ void MRIStepPrintMem(void* arkode_mem, FILE* outfile) interface routines, data structure, and solver type to the MRIStep module. ---------------------------------------------------------------*/ -int mriStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int mriStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* free any existing system solver */ - if (step_mem->lfree != NULL) { step_mem->lfree(arkode_mem); } + if (step_mem->lfree != NULL) { step_mem->lfree(ark_mem); } /* Attach the provided routines, data structure and solve type */ step_mem->linit = linit; @@ -920,14 +787,13 @@ int mriStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, This routine NULLifies the lsetup function pointer in the MRIStep module. ---------------------------------------------------------------*/ -void mriStep_DisableLSetup(void* arkode_mem) +void mriStep_DisableLSetup(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return; } /* nullify the lsetup function pointer */ @@ -940,14 +806,13 @@ void mriStep_DisableLSetup(void* arkode_mem) This routine returns the system linear solver interface memory structure, lmem. ---------------------------------------------------------------*/ -void* mriStep_GetLmem(void* arkode_mem) +void* mriStep_GetLmem(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure, and return lmem */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } return (step_mem->lmem); } @@ -957,14 +822,13 @@ void* mriStep_GetLmem(void* arkode_mem) This routine returns the implicit RHS function pointer, fi. ---------------------------------------------------------------*/ -ARKRhsFn mriStep_GetImplicitRHS(void* arkode_mem) +ARKRhsFn mriStep_GetImplicitRHS(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure, and return fi */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (NULL); } if (step_mem->implicit_rhs) { return (step_mem->fsi); } else { return (NULL); } @@ -976,15 +840,14 @@ ARKRhsFn mriStep_GetImplicitRHS(void* arkode_mem) This routine fills the current value of gamma, and states whether the gamma ratio fails the dgmax criteria. ---------------------------------------------------------------*/ -int mriStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set outputs */ @@ -1010,16 +873,15 @@ int mriStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, With other initialization types, this routine does nothing. ---------------------------------------------------------------*/ -int mriStep_Init(void* arkode_mem, int init_type) +int mriStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval, j; sunbooleantype reset_efun; SUNAdaptController_Type adapt_type; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if reset */ @@ -1065,15 +927,9 @@ int mriStep_Init(void* arkode_mem, int init_type) { case MRISTEP_EXPLICIT: case MRISTEP_IMPLICIT: - case MRISTEP_IMEX: - ark_mem->step = mriStep_TakeStepMRIGARK; - break; - case MRISTEP_MERK: - ark_mem->step = mriStep_TakeStepMERK; - break; - case MRISTEP_MRISR: - ark_mem->step = mriStep_TakeStepMRISR; - break; + case MRISTEP_IMEX: ark_mem->step = mriStep_TakeStepMRIGARK; break; + case MRISTEP_MERK: ark_mem->step = mriStep_TakeStepMERK; break; + case MRISTEP_MRISR: ark_mem->step = mriStep_TakeStepMRISR; break; } /* Retrieve/store method and embedding orders now that tables are finalized */ @@ -1349,8 +1205,8 @@ int mriStep_Init(void* arkode_mem, int init_type) if (ark_mem->hin == ZERO) { /* tempv1 = fslow(t0, y0) */ - if (mriStep_SlowRHS(arkode_mem, ark_mem->tcur, ark_mem->yn, - ark_mem->tempv1, ARK_FULLRHS_START) != ARK_SUCCESS) + if (mriStep_SlowRHS(ark_mem, ark_mem->tcur, ark_mem->yn, ark_mem->tempv1, + ARK_FULLRHS_START) != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, "error calling slow RHS function(s)"); @@ -1404,8 +1260,8 @@ int mriStep_Init(void* arkode_mem, int init_type) if (step_mem->stepper->ops->fullrhs) { /* tempv1 = ffast(t0, y0) */ - if (mriStep_FastRHS(arkode_mem, ark_mem->tcur, ark_mem->yn, - ark_mem->tempv1, ARK_FULLRHS_START) != ARK_SUCCESS) + if (mriStep_FastRHS(ark_mem, ark_mem->tcur, ark_mem->yn, ark_mem->tempv1, + ARK_FULLRHS_START) != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_RHSFUNC_FAIL, __LINE__, __func__, __FILE__, "error calling fast RHS function(s)"); @@ -1481,15 +1337,14 @@ int mriStep_Init(void* arkode_mem, int init_type) Presently ff(t,y) is always called with ARK_FULLRHS_OTHER mode. ----------------------------------------------------------------------------*/ -int mriStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* ensure that inner stepper provides fullrhs function */ @@ -1733,9 +1588,8 @@ int mriStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem; /* outer ARKODE memory */ ARKodeMRIStepMem step_mem; /* outer stepper memory */ int is; /* current stage index */ int retval; /* reusable return flag */ @@ -1744,7 +1598,7 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr sunrealtype t0, tf; /* start/end of each stage */ /* access the MRIStep mem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* initialize algebraic solver convergence flag to success; @@ -1810,7 +1664,8 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr /* compute the explicit component */ if (step_mem->explicit_rhs) { - retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); + retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], + ark_mem->user_data); step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } } @@ -1818,7 +1673,8 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr /* compute the implicit component */ if (step_mem->implicit_rhs) { - retval = step_mem->fsi(t0, ark_mem->yn, step_mem->Fsi[0], ark_mem->user_data); + retval = step_mem->fsi(t0, ark_mem->yn, step_mem->Fsi[0], + ark_mem->user_data); step_mem->nfsi++; if (retval) { return ARK_RHSFUNC_FAIL; } } @@ -1860,7 +1716,7 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr for (is = 1; is < step_mem->stages; is++) { /* Set relevant stage times (including desired stage time for implicit solves) */ - t0 = ark_mem->tn + step_mem->MRIC->c[is-1] * ark_mem->h; + t0 = ark_mem->tn + step_mem->MRIC->c[is - 1] * ark_mem->h; tf = ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[is] * ark_mem->h; /* Solver diagnostics reporting */ @@ -1880,10 +1736,13 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr { case (MRISTAGE_ERK_FAST): retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, is, t0, tf); - if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; break; } - retval = mriStep_StageERKFast(ark_mem, step_mem, is, t0, tf, - ark_mem->ycur, ark_mem->tempv2, - SUNFALSE, SUNTRUE); + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + break; + } + retval = mriStep_StageERKFast(ark_mem, step_mem, is, t0, tf, ark_mem->ycur, + ark_mem->tempv2, SUNFALSE, SUNTRUE); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): @@ -2005,8 +1864,9 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr /* Reset ark_mem->tcur as the time value corresponding with the end of the step */ /* Set relevant stage times (including desired stage time for implicit solves) */ - t0 = ark_mem->tn + step_mem->MRIC->c[step_mem->stages-2] * ark_mem->h; - tf = ark_mem->tcur = ark_mem->tn + step_mem->MRIC->c[step_mem->stages-1] * ark_mem->h; + t0 = ark_mem->tn + step_mem->MRIC->c[step_mem->stages - 2] * ark_mem->h; + tf = ark_mem->tcur = ark_mem->tn + + step_mem->MRIC->c[step_mem->stages - 1] * ark_mem->h; /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG @@ -2025,11 +1885,16 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr switch (step_mem->stagetypes[step_mem->stages]) { case (MRISTAGE_ERK_FAST): - retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->stages, t0, tf); - if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; break; } + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->stages, + t0, tf); + if (retval != ARK_SUCCESS) + { + *nflagPtr = CONV_FAIL; + break; + } retval = mriStep_StageERKFast(ark_mem, step_mem, step_mem->stages, t0, tf, - ark_mem->ycur, ark_mem->tempv2, - SUNTRUE, SUNFALSE); + ark_mem->ycur, ark_mem->tempv2, SUNTRUE, + SUNFALSE); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } break; case (MRISTAGE_ERK_NOFAST): @@ -2112,13 +1977,10 @@ int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem; /* outer ARKODE memory */ ARKodeMRIStepMem step_mem; /* outer stepper memory */ - int ig; /* current stage group index */ - int is; /* stage index in group */ - int stage, nextstage; /* current/next stages */ + int stage; /* current stage index */ int retval; /* reusable return flag */ N_Vector ytilde; /* embedded solution */ N_Vector ytemp; /* temporary vector */ @@ -2131,7 +1993,7 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF; /* access the MRIStep mem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* initialize algebraic solver convergence flag to success; @@ -2141,7 +2003,7 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* set N_Vector shortcuts */ ytilde = ark_mem->tempv4; - ytemp = ark_mem->tempv2; + ytemp = ark_mem->tempv2; /* initial time for step */ t0 = ark_mem->tn; @@ -2187,7 +2049,8 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* compute the explicit component */ if (step_mem->explicit_rhs) { - retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], ark_mem->user_data); + retval = step_mem->fse(t0, ark_mem->yn, step_mem->Fse[0], + ark_mem->user_data); step_mem->nfse++; if (retval) { return ARK_RHSFUNC_FAIL; } } @@ -2195,7 +2058,8 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* compute the implicit component */ if (step_mem->implicit_rhs) { - retval = step_mem->fsi(t0, ark_mem->yn, step_mem->Fsi[0], ark_mem->user_data); + retval = step_mem->fsi(t0, ark_mem->yn, step_mem->Fsi[0], + ark_mem->user_data); step_mem->nfsi++; if (retval) { return ARK_RHSFUNC_FAIL; } } @@ -2210,8 +2074,7 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", "slow stage", - "z[0] =", ""); + "ARKODE::mriStep_TakeStepMRISR", "slow stage", "z[0] =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) @@ -2229,18 +2092,17 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Loop over stages */ for (stage = 0; stage <= step_mem->stages; stage++) { - /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStepMRISR", "start-stage", - "step = %li, stage = %i, h = %" RSYM, - ark_mem->nst, stage, ark_mem->h); + "step = %li, stage = %i, h = %" RSYM, ark_mem->nst, + stage, ark_mem->h); #endif /* Set up fast RHS for this stage group */ - retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, stage, - ark_mem->tn, ark_mem->tn+ark_mem->h); + retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, stage, ark_mem->tn, + ark_mem->tn + ark_mem->h); if (retval != ARK_SUCCESS) { return (retval); } /* Set initial condition for this stage */ @@ -2248,19 +2110,21 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) t0 = ark_mem->tn; /* Determine if this is an "embedding" or "solution" stage */ - solution = (stage == step_mem->stages-1); + solution = (stage == step_mem->stages - 1); embedding = (stage == step_mem->stages); /* Skip the embedding if we're using fixed time-stepping and temporal error estimation is disabled */ if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType < 0)) - { break; } + { + break; + } /* Set current stage abscissa */ cstage = (embedding) ? ONE : step_mem->MRIC->c[stage]; /* Set desired output time for subinterval */ - tf = ark_mem->tn + cstage*ark_mem->h; + tf = ark_mem->tn + cstage * ark_mem->h; /* TO-DO: compute forcing function for inner solver */ /* retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, stage, t0, tf); */ @@ -2270,8 +2134,7 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) force reset due to "stage-restart" structure get inner dsm on all non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, stage, t0, tf, - ark_mem->ycur, ytemp, SUNTRUE, - !embedding); + ark_mem->ycur, ytemp, SUNTRUE, !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } /* set current stage time for implicit correction, postprocessing @@ -2281,11 +2144,11 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* TO-DO: add in MRISR slow correction */ impl_corr = (SUNRabs(step_mem->MRIC->G[0][stage][stage]) > tol); if (impl_corr) - { /* implicit correction */ + { /* implicit correction */ /* retval = mriStep_StageDIRKNoFast(ark_mem, step_mem, stage, nflagPtr); */ } else - { /* explicit correction */ + { /* explicit correction */ /* retval = mriStep_StageERKNoFast(ark_mem, step_mem, stage); */ } if (retval != ARK_SUCCESS) { return (retval); } @@ -2312,7 +2175,6 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Compute updated slow RHS (except for final solution or embedding) */ if ((!solution) && (!embedding)) { - /* store explicit slow rhs */ if (step_mem->explicit_rhs) { @@ -2324,8 +2186,8 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", - "slow explicit RHS", "Fse[%i] =", stage); + "ARKODE::mriStep_TakeStepMRISR", "slow explicit RHS", + "Fse[%i] =", stage); N_VPrintFile(step_mem->Fse[stage], ARK_LOGGER->debug_fp); #endif } @@ -2351,16 +2213,17 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMRISR", - "slow implicit RHS", "Fsi[%i] =", stage); + "ARKODE::mriStep_TakeStepMRISR", "slow implicit RHS", + "Fsi[%i] =", stage); N_VPrintFile(step_mem->Fsi[stage], ARK_LOGGER->debug_fp); #endif + } } /* If this is the solution stage, archive for error estimation */ if (solution) { N_VScale(ONE, ark_mem->ycur, ytilde); } - } /* loop over stages */ + } /* loop over stages */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, @@ -2427,9 +2290,8 @@ int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) reduce step and retry (if possible) <0 => step encountered unrecoverable failure ---------------------------------------------------------------*/ -int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem; /* outer ARKODE memory */ ARKodeMRIStepMem step_mem; /* outer stepper memory */ int ig; /* current stage group index */ int is; /* stage index in group */ @@ -2444,7 +2306,7 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) sunrealtype cstage; /* current stage abscissa */ /* access the MRIStep mem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* initialize algebraic solver convergence flag to success; @@ -2454,7 +2316,7 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* set N_Vector shortcuts */ ytilde = ark_mem->tempv4; - ytemp = ark_mem->tempv2; + ytemp = ark_mem->tempv2; /* initial time for step */ t0 = ark_mem->tn; @@ -2510,8 +2372,7 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", "slow stage", - "z[0] =", ""); + "ARKODE::mriStep_TakeStepMERK", "slow stage", "z[0] =", ""); N_VPrintFile(ark_mem->yn, ARK_LOGGER->debug_fp); if (step_mem->explicit_rhs) @@ -2529,19 +2390,18 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Loop over stage groups */ for (ig = 0; ig < step_mem->MRIC->ngroup; ig++) { - /* Solver diagnostics reporting */ #if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, "ARKODE::mriStep_TakeStepMERK", "start-stage", - "step = %li, stage group = %i, h = %" RSYM, - ark_mem->nst, is, ark_mem->h); + "step = %li, stage group = %i, h = %" RSYM, ark_mem->nst, + is, ark_mem->h); #endif /* Set up fast RHS for this stage group */ retval = mriStep_ComputeInnerForcing(ark_mem, step_mem, step_mem->MRIC->group[ig][0], - ark_mem->tn, ark_mem->tn+ark_mem->h); + ark_mem->tn, ark_mem->tn + ark_mem->h); if (retval != ARK_SUCCESS) { return (retval); } /* Set initial condition for this stage group */ @@ -2551,7 +2411,6 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Evolve fast IVP over each subinterval in stage group */ for (is = 0; is < step_mem->stages; is++) { - /* Get stage index from group; skip to the next group if we've reached the end of this one */ stage = step_mem->MRIC->group[ig][is]; @@ -2559,16 +2418,16 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) nextstage = -1; if (stage < step_mem->stages) { - nextstage = step_mem->MRIC->group[ig][is+1]; + nextstage = step_mem->MRIC->group[ig][is + 1]; } /* Determine if this is an "embedding" or "solution" stage */ embedding = solution = SUNFALSE; - if (ig == step_mem->MRIC->ngroup-2) + if (ig == step_mem->MRIC->ngroup - 2) { if ((stage >= 0) && (nextstage < 0)) { embedding = SUNTRUE; } } - if (ig == step_mem->MRIC->ngroup-1) + if (ig == step_mem->MRIC->ngroup - 1) { if ((stage >= 0) && (nextstage < 0)) { solution = SUNTRUE; } } @@ -2576,20 +2435,21 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Skip the embedding if we're using fixed time-stepping and temporal error estimation is disabled */ if (ark_mem->fixedstep && embedding && (ark_mem->AccumErrorType < 0)) - { break; } + { + break; + } /* Set current stage abscissa */ cstage = (stage >= step_mem->stages) ? ONE : step_mem->MRIC->c[stage]; /* Set desired output time for subinterval */ - tf = ark_mem->tn + cstage*ark_mem->h; + tf = ark_mem->tn + cstage * ark_mem->h; /* Evolve fast IVP for this stage: force reset on first stage in group get inner dsm on all non-embedding stages */ retval = mriStep_StageERKFast(ark_mem, step_mem, stage, t0, tf, - ark_mem->ycur, ytemp, is==0, - !embedding); + ark_mem->ycur, ytemp, is == 0, !embedding); if (retval != ARK_SUCCESS) { *nflagPtr = CONV_FAIL; } /* Update "initial time" for next stage in group */ @@ -2622,16 +2482,15 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) { /* store explicit slow rhs */ retval = step_mem->fse(ark_mem->tcur, ark_mem->ycur, - step_mem->Fse[stage], - ark_mem->user_data); + step_mem->Fse[stage], ark_mem->user_data); step_mem->nfse++; if (retval < 0) { return (ARK_RHSFUNC_FAIL); } if (retval > 0) { return (ARK_UNREC_RHSFUNC_ERR); } #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, - "ARKODE::mriStep_TakeStepMERK", - "slow explicit RHS", "Fse[%i] =", is); + "ARKODE::mriStep_TakeStepMERK", "slow explicit RHS", + "Fse[%i] =", is); N_VPrintFile(step_mem->Fse[stage], ARK_LOGGER->debug_fp); #endif } @@ -2639,9 +2498,9 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* If this is the embedding stage, archive solution for error estimation */ if (embedding) { N_VScale(ONE, ark_mem->ycur, ytilde); } - } /* loop over stages */ + } /* loop over stages */ - } /* loop over stage groups */ + } /* loop over stage groups */ #ifdef SUNDIALS_LOGGING_EXTRA_DEBUG SUNLogger_QueueMsg(ARK_LOGGER, SUN_LOGLEVEL_DEBUG, @@ -2669,18 +2528,18 @@ int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== Internal utility routines - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- - mriStep_AccessStepMem: + mriStep_AccessARKODEStepMem: Shortcut routine to unpack ark_mem and step_mem structures from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int mriStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem) +int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -2690,6 +2549,8 @@ int mriStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeMRIStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -2700,6 +2561,26 @@ int mriStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + mriStep_AccessStepMem: + + Shortcut routine to unpack step_mem structure from ark_mem. + If missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int mriStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeMRIStepMem* step_mem) +{ + /* access ARKodeMRIStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_MRISTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeMRIStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- mriStep_CheckNVector: @@ -2928,8 +2809,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) "Invalid coupling table for an IMEX problem!"); return (ARK_ILL_INPUT); } - if (step_mem->explicit_rhs && - (step_mem->MRIC->type != MRISTEP_EXPLICIT) && + if (step_mem->explicit_rhs && (step_mem->MRIC->type != MRISTEP_EXPLICIT) && (step_mem->MRIC->type != MRISTEP_IMEX) && (step_mem->MRIC->type != MRISTEP_MERK) && (step_mem->MRIC->type != MRISTEP_MRISR)) @@ -2938,8 +2818,7 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) "Invalid coupling table for an explicit problem!"); return (ARK_ILL_INPUT); } - if (step_mem->implicit_rhs && - (step_mem->MRIC->type != MRISTEP_IMPLICIT) && + if (step_mem->implicit_rhs && (step_mem->MRIC->type != MRISTEP_IMPLICIT) && (step_mem->MRIC->type != MRISTEP_IMEX) && (step_mem->MRIC->type != MRISTEP_MRISR)) { @@ -3041,9 +2920,9 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) } /* check that MRI-GARK stage times are sorted */ - if ( (step_mem->MRIC->type == MRISTEP_IMPLICIT) || - (step_mem->MRIC->type == MRISTEP_EXPLICIT) || - (step_mem->MRIC->type == MRISTEP_IMEX) ) + if ((step_mem->MRIC->type == MRISTEP_IMPLICIT) || + (step_mem->MRIC->type == MRISTEP_EXPLICIT) || + (step_mem->MRIC->type == MRISTEP_IMEX)) { okay = SUNTRUE; for (i = 1; i < step_mem->MRIC->stages; i++) @@ -3107,10 +2986,9 @@ int mriStep_CheckCoupling(ARKodeMem ark_mem) get_inner_dsm indicates whether this stage is one that should accumulate an inner temporal error estimate. ---------------------------------------------------------------*/ -int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, - int is, sunrealtype t0, sunrealtype tf, - N_Vector ycur, N_Vector ytemp, - sunbooleantype force_reset, +int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, + sunrealtype t0, sunrealtype tf, N_Vector ycur, + N_Vector ytemp, sunbooleantype force_reset, sunbooleantype get_inner_dsm) { int retval; /* reusable return flag */ @@ -3136,6 +3014,11 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, if (retval != ARK_SUCCESS) { return (ARK_INNERSTEP_FAIL); } } + /* Get the adaptivity type (if applicable) */ + adapt_type = (get_inner_dsm) + ? SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller) + : SUN_ADAPTCONTROLLER_NONE; + /* if we'll need to manually accumulate the fast error estimate, archive the current state to provide an initial condition for the ``fast embedding'' */ if ((get_inner_dsm) && (adapt_type == SUN_ADAPTCONTROLLER_MRI_H) && @@ -3153,7 +3036,6 @@ int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, if (get_inner_dsm) { /* if MRI adaptivity is enabled, get fast temporal error estimate */ - adapt_type = SUNAdaptController_GetType(ark_mem->hadapt_mem->hcontroller); if ((adapt_type == SUN_ADAPTCONTROLLER_MRI_H) || (adapt_type == SUN_ADAPTCONTROLLER_MRI_TOL)) { @@ -3773,15 +3655,14 @@ int mriStep_StageSetup(ARKodeMem ark_mem) by the user (i.e., mode should correspond with ARK_FULLRHS_OTHER. ---------------------------------------------------------------*/ -int mriStep_SlowRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* call fse if the problem has an explicit component */ @@ -3833,15 +3714,14 @@ int mriStep_SlowRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, when one is not specified by the user and H-H MRI time step adaptivity is enabled. ---------------------------------------------------------------*/ -int mriStep_FastRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* call ff */ @@ -3872,7 +3752,7 @@ int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector temp2, ARKTimestepFullRHSFn rhs, sunrealtype* h) { int sign; - sunrealtype tdiff, tdist, tround, fnorm, h0_inv, h0; + sunrealtype tdiff, tdist, tround, fnorm, h0_inv; /* If tout is too close to tn, give up */ if ((tdiff = tout - tcur) == ZERO) { return (ARK_TOO_CLOSE); } @@ -3889,9 +3769,9 @@ int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== User-callable functions for a custom inner integrator - ---------------------------------------------------------------*/ + ===============================================================*/ int MRIStepInnerStepper_Create(SUNContext sunctx, MRIStepInnerStepper* stepper) { @@ -4173,9 +4053,9 @@ int MRIStepInnerStepper_GetForcingData(MRIStepInnerStepper stepper, return ARK_SUCCESS; } -/*--------------------------------------------------------------- - Internal inner integrator functions - ---------------------------------------------------------------*/ +/*=============================================================== + Private inner integrator functions + ===============================================================*/ /* Check for required operations */ int mriStepInnerStepper_HasRequiredOps(MRIStepInnerStepper stepper) @@ -4505,7 +4385,7 @@ SUNAdaptController SUNAdaptController_MRIStep(void* arkode_mem, } /* Return with failure if stepper is inaccessible */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) return (NULL); /* Create an empty controller object */ diff --git a/src/arkode/arkode_mristep_impl.h b/src/arkode/arkode_mristep_impl.h index 41ec9b5dfc..ab3cc1bc3d 100644 --- a/src/arkode/arkode_mristep_impl.h +++ b/src/arkode/arkode_mristep_impl.h @@ -38,14 +38,19 @@ extern "C" { /* Default inner_factor value */ #define INNER_HFACTOR SUN_RCONST(2.0) + /* Implicit solver constants (duplicate from arkode_arkstep_impl.h) */ -#define MAXCOR 3 /* max number of nonlinear iterations */ -#define CRDOWN \ - SUN_RCONST(0.3) /* constant to estimate the convergence - rate for the nonlinear equation */ -#define DGMAX SUN_RCONST(0.2) /* if |gamma/gammap-1| > DGMAX then call lsetup */ -#define RDIV SUN_RCONST(2.3) /* declare divergence if ratio del/delp > RDIV */ -#define MSBP 20 /* max no. of steps between lsetup calls */ +/* max number of nonlinear iterations */ +#define MAXCOR 3 +/* constant to estimate the convergence rate for the nonlinear equation */ +#define CRDOWN SUN_RCONST(0.3) +/* if |gamma/gammap-1| > DGMAX then call lsetup */ +#define DGMAX SUN_RCONST(0.2) +/* declare divergence if ratio del/delp > RDIV */ +#define RDIV SUN_RCONST(2.3) +/* max no. of steps between lsetup calls */ +#define MSBP 20 +/* default solver tolerance factor */ #define NLSCOEF SUN_RCONST(0.1) /*=============================================================== @@ -127,6 +132,7 @@ typedef struct ARKodeMRIStepMemRec /* User-supplied pre and post inner evolve functions */ MRIStepPreInnerFn pre_inner_evolve; MRIStepPostInnerFn post_inner_evolve; + /* MRI adaptivity parameters */ sunrealtype inner_hfactor; /* h factor for inner stepper error estimation */ sunrealtype inner_control; /* prev control parameter (h or tolfac) */ @@ -197,32 +203,68 @@ struct _MRIStepInnerStepper ===============================================================*/ /* Interface routines supplied to ARKODE */ -int mriStep_AttachLinsol(void* arkode_mem, ARKLinsolInitFn linit, +int mriStep_AttachLinsol(ARKodeMem ark_mem, ARKLinsolInitFn linit, ARKLinsolSetupFn lsetup, ARKLinsolSolveFn lsolve, ARKLinsolFreeFn lfree, SUNLinearSolver_Type lsolve_type, void* lmem); -void mriStep_DisableLSetup(void* arkode_mem); -int mriStep_Init(void* arkode_mem, int init_type); -void* mriStep_GetLmem(void* arkode_mem); -ARKRhsFn mriStep_GetImplicitRHS(void* arkode_mem); -int mriStep_GetGammas(void* arkode_mem, sunrealtype* gamma, sunrealtype* gamrat, +void mriStep_DisableLSetup(ARKodeMem ark_mem); +int mriStep_Init(ARKodeMem ark_mem, int init_type); +void* mriStep_GetLmem(ARKodeMem ark_mem); +ARKRhsFn mriStep_GetImplicitRHS(ARKodeMem ark_mem); +int mriStep_GetGammas(ARKodeMem ark_mem, sunrealtype* gamma, sunrealtype* gamrat, sunbooleantype** jcur, sunbooleantype* dgamma_fail); -int mriStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int mriStep_TakeStepMRIGARK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int mriStep_TakeStepMRISR(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int mriStep_TakeStepMERK(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_TakeStepMRIGARK(ARKodeMem ark_mem, sunrealtype* dsmPtr, + int* nflagPtr); +int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_TakeStepMERK(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int mriStep_SetDefaults(ARKodeMem ark_mem); +int mriStep_SetOrder(ARKodeMem ark_mem, int ord); +int mriStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS); +int mriStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fi); +int mriStep_SetLinear(ARKodeMem ark_mem, int timedepend); +int mriStep_SetNonlinear(ARKodeMem ark_mem); +int mriStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown); +int mriStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv); +int mriStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax); +int mriStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp); +int mriStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method); +int mriStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor); +int mriStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef); +int mriStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage); +int mriStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce); +int mriStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma); +int mriStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data); +int mriStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups); +int mriStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters); +int mriStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails); +int mriStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, + long int* nnfails); +int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int mriStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int mriStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int mriStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data); +int mriStep_ComputeState(ARKodeMem ark_mem, N_Vector zcor, N_Vector z); +void mriStep_Free(ARKodeMem ark_mem); +void mriStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int mriStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem); +int mriStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeMRIStepMem* step_mem); +int mriStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeMRIStepMem* step_mem); sunbooleantype mriStep_CheckNVector(N_Vector tmpl); int mriStep_SetCoupling(ARKodeMem ark_mem); int mriStep_CheckCoupling(ARKodeMem ark_mem); -int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, - int is, sunrealtype t0, sunrealtype tf, - N_Vector ycur, N_Vector ytemp, - sunbooleantype force_reset, +int mriStep_StageERKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, + sunrealtype t0, sunrealtype tf, N_Vector ycur, + N_Vector ytemp, sunbooleantype force_reset, sunbooleantype get_inner_dsm); int mriStep_StageERKNoFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is); int mriStep_StageDIRKFast(ARKodeMem ark_mem, ARKodeMRIStepMem step_mem, int is, @@ -233,9 +275,9 @@ int mriStep_Predict(ARKodeMem ark_mem, int istage, N_Vector yguess); int mriStep_StageSetup(ARKodeMem ark_mem); int mriStep_NlsInit(ARKodeMem ark_mem); int mriStep_Nls(ARKodeMem ark_mem, int nflag); -int mriStep_SlowRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_SlowRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int mriStep_FastRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int mriStep_FastRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); int mriStep_Hin(ARKodeMem ark_mem, sunrealtype tcur, sunrealtype tout, N_Vector ycur, N_Vector fcur, N_Vector ytmp, N_Vector temp1, diff --git a/src/arkode/arkode_mristep_io.c b/src/arkode/arkode_mristep_io.c index a7c36c793e..bbad53ea70 100644 --- a/src/arkode/arkode_mristep_io.c +++ b/src/arkode/arkode_mristep_io.c @@ -24,375 +24,264 @@ #include "arkode_mristep_impl.h" /*=============================================================== - MRIStep Optional input functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. + Exported optional input functions. ===============================================================*/ -int MRIStepSetDenseOrder(void* arkode_mem, int dord) -{ - return (MRIStepSetInterpolantDegree(arkode_mem, dord)); -} -int MRIStepSetInterpolantDegree(void* arkode_mem, int degree) -{ - if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; } - return (arkSetInterpolantDegree(arkode_mem, degree)); -} +/*--------------------------------------------------------------- + MRIStepSetCoupling: -int MRIStepSetInterpolantType(void* arkode_mem, int itype) + Specifies to use a customized coupling structure for the slow + portion of the system. + ---------------------------------------------------------------*/ +int MRIStepSetCoupling(void* arkode_mem, MRIStepCoupling MRIC) { - return (arkSetInterpolantType(arkode_mem, itype)); -} + int retval; + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + sunindextype Tlrw, Tliw; -int MRIStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) -{ - return (arkSetMaxNumSteps(arkode_mem, mxsteps)); -} + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) -{ - return (arkSetMaxHnilWarns(arkode_mem, mxhnil)); -} + /* check for illegal inputs */ + if (MRIC == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_MRISTEP_NO_COUPLING); + return (ARK_ILL_INPUT); + } -int MRIStepSetStopTime(void* arkode_mem, sunrealtype tstop) -{ - return (arkSetStopTime(arkode_mem, tstop)); -} + /* clear any existing parameters and coupling structure */ + step_mem->stages = 0; + step_mem->q = 0; + step_mem->p = 0; + MRIStepCoupling_Space(step_mem->MRIC, &Tliw, &Tlrw); + MRIStepCoupling_Free(step_mem->MRIC); + step_mem->MRIC = NULL; + ark_mem->liw -= Tliw; + ark_mem->lrw -= Tlrw; -int MRIStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) -{ - return (arkSetInterpolateStopTime(arkode_mem, interp)); -} + /* set the relevant parameters */ + step_mem->stages = MRIC->stages; + step_mem->q = MRIC->q; + step_mem->p = MRIC->p; -int MRIStepClearStopTime(void* arkode_mem) -{ - return (arkClearStopTime(arkode_mem)); -} + /* copy the coupling structure in step memory */ + step_mem->MRIC = MRIStepCoupling_Copy(MRIC); + if (step_mem->MRIC == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_MRISTEP_NO_COUPLING); + return (ARK_MEM_NULL); + } + MRIStepCoupling_Space(step_mem->MRIC, &Tliw, &Tlrw); + ark_mem->liw += Tliw; + ark_mem->lrw += Tlrw; -int MRIStepSetRootDirection(void* arkode_mem, int* rootdir) -{ - return (arkSetRootDirection(arkode_mem, rootdir)); + return (ARK_SUCCESS); } -int MRIStepSetNoInactiveRootWarn(void* arkode_mem) -{ - return (arkSetNoInactiveRootWarn(arkode_mem)); -} +/*--------------------------------------------------------------- + MRIStepSetPreInnerFn: -int MRIStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) + Sets the user-supplied function called BEFORE the inner evolve + ---------------------------------------------------------------*/ +int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn) { - return (arkSetPostprocessStepFn(arkode_mem, ProcessStep)); -} + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; -int MRIStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) -{ - return (arkSetPostprocessStageFn(arkode_mem, ProcessStage)); -} + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepSetMaxErrTestFails(void* arkode_mem, int maxnef) -{ - return (arkSetMaxErrTestFails(arkode_mem, maxnef)); -} + /* Set pre inner evolve function */ + step_mem->pre_inner_evolve = prefn; -int MRIStepSetInitStep(void* arkode_mem, sunrealtype hin) -{ - return (arkSetInitStep(arkode_mem, hin)); + return (ARK_SUCCESS); } -int MRIStepSetMaxConvFails(void* arkode_mem, int maxncf) -{ - return (arkSetMaxConvFails(arkode_mem, maxncf)); -} +/*--------------------------------------------------------------- + MRIStepSetPostInnerFn: -int MRIStepSetConstraints(void* arkode_mem, N_Vector constraints) + Sets the user-supplied function called AFTER the inner evolve + ---------------------------------------------------------------*/ +int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) { - return (arkSetConstraints(arkode_mem, constraints)); -} + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; -int MRIStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) -{ - return (arkSetMaxNumConstrFails(arkode_mem, maxfails)); -} + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepSetFixedStep(void* arkode_mem, sunrealtype hsfixed) -{ - return (arkSetFixedStep(arkode_mem, hsfixed)); + /* Set pre inner evolve function */ + step_mem->post_inner_evolve = postfn; + + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - Wrapper functions for accumulated temporal error estimation. + MRIStepSetFastErrorStepFactor: + + Specifies a fast stepsize factor to use when estimating the + accumulated fast time scale solution error when MRI adaptivity + is enabled. The fast integrator is run twice over each fast + time interval, once using the inner step size h, and again + using hfactor*h (typically hfactor=k or 1/k for an integer k>1). + This is only needed when the results from + mriStepInnerStepper_GetError() cannot be trusted. In our + tests, we found this to be the case when the inner integrator + uses fixed step sizes. + + An argument of 0 disables this fast error estimation strategy. + Arguments of hfactor < 0 or hfactor == 1 are illegal. + All other positive hfactor values will *attempt* to be used. ---------------------------------------------------------------*/ -int MRIStepSetAccumulatedErrorType(void* arkode_mem, int accum_type) +int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) { - return (arkSetAccumulatedErrorType(arkode_mem, accum_type)); -} + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; -int MRIStepResetAccumulatedError(void* arkode_mem) -{ - return (arkResetAccumulatedError(arkode_mem)); -} + /* access ARKodeMRIStepMem structure */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepGetAccumulatedError(void* arkode_mem, sunrealtype* accum_error) -{ - return (arkGetAccumulatedError(arkode_mem, accum_error)); + /* return with error on illegal input */ + if ((hfactor < ZERO) || (hfactor == ONE)) + { + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Illegal input; must be >0 and not identically 1"); + return (ARK_ILL_INPUT); + } + + /* set value and return */ + step_mem->inner_hfactor = hfactor; + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - These wrappers for ARKLs module 'set' routines all are - documented in arkode_mristep.h. + MRIStepSetAdaptController: + + Specifies a temporal adaptivity controller for MRIStep to use. + If a non-MRI controller is provided, this just passes that + through to arkSetAdaptController. However, if an MRI + controller is provided, then this wraps that inside a + "SUNAdaptController_MRIStep" wrapper, which will properly + interact with the fast integration module. ---------------------------------------------------------------*/ -int MRIStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) +int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) { - return (arkLSSetLinearSolver(arkode_mem, LS, A)); -} + /* Retrieve the controller type */ + SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); -int MRIStepSetJacFn(void* arkode_mem, ARKLsJacFn jac) -{ - return (arkLSSetJacFn(arkode_mem, jac)); -} + /* If this does not have MRI type, then just pass to ARKODE */ + if ((ctype != SUN_ADAPTCONTROLLER_MRI_H) && + (ctype != SUN_ADAPTCONTROLLER_MRI_TOL)) + { + return (ARKodeSetAdaptController(arkode_mem, C)); + } -int MRIStepSetJacEvalFrequency(void* arkode_mem, long int msbj) -{ - return (arkLSSetJacEvalFrequency(arkode_mem, msbj)); + /* Create the mriStepControl wrapper, and pass that to ARKODE */ + SUNAdaptController Cwrapper = SUNAdaptController_MRIStep(arkode_mem, C); + return (ARKodeSetAdaptController(arkode_mem, Cwrapper)); } -int MRIStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) -{ - return (arkLSSetLinearSolutionScaling(arkode_mem, onoff)); -} +/*=============================================================== + Exported optional output functions. + ===============================================================*/ -int MRIStepSetEpsLin(void* arkode_mem, sunrealtype eplifac) -{ - return (arkLSSetEpsLin(arkode_mem, eplifac)); -} +/*--------------------------------------------------------------- + MRIStepGetNumRhsEvals: -int MRIStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) + Returns the current number of calls to fse and fsi + ---------------------------------------------------------------*/ +int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, + long int* nfsi_evals) { - return (arkLSSetNormFactor(arkode_mem, nrmfac)); -} + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; -int MRIStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, - ARKLsPrecSolveFn psolve) -{ - return (arkLSSetPreconditioner(arkode_mem, psetup, psolve)); -} + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, - ARKLsJacTimesVecFn jtimes) -{ - return (arkLSSetJacTimes(arkode_mem, jtsetup, jtimes)); -} + /* get number of fse and fsi evals from step_mem */ + *nfse_evals = step_mem->nfse; + *nfsi_evals = step_mem->nfsi; -int MRIStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) -{ - return (arkLSSetJacTimesRhsFn(arkode_mem, jtimesRhsFn)); + return (ARK_SUCCESS); } -int MRIStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) -{ - return (arkLSSetLinSysFn(arkode_mem, linsys)); -} +/*--------------------------------------------------------------- + MRIStepGetCurrentCoupling: -/*=============================================================== - MRIStep Optional output functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. - ===============================================================*/ -int MRIStepGetNumSteps(void* arkode_mem, long int* nssteps) + Sets pointer to the slow coupling structure currently in use. + ---------------------------------------------------------------*/ +int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC) { - return (arkGetNumSteps(arkode_mem, nssteps)); -} + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; -int MRIStepGetLastStep(void* arkode_mem, sunrealtype* hlast) -{ - return (arkGetLastStep(arkode_mem, hlast)); -} + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) -{ - return (arkGetCurrentTime(arkode_mem, tcur)); -} + /* get coupling structure from step_mem */ + *MRIC = step_mem->MRIC; -int MRIStepGetCurrentState(void* arkode_mem, N_Vector* state) -{ - return (arkGetCurrentState(arkode_mem, state)); + return (ARK_SUCCESS); } -int MRIStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) -{ - return (arkGetTolScaleFactor(arkode_mem, tolsfact)); -} +/*--------------------------------------------------------------- + MRIStepGetLastInnerStepFlag: -int MRIStepGetErrWeights(void* arkode_mem, N_Vector eweight) + Returns the last return value from the inner stepper. + ---------------------------------------------------------------*/ +int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) { - return (arkGetErrWeights(arkode_mem, eweight)); -} + ARKodeMem ark_mem; + ARKodeMRIStepMem step_mem; + int retval; -int MRIStepGetNumGEvals(void* arkode_mem, long int* ngevals) -{ - return (arkGetNumGEvals(arkode_mem, ngevals)); -} + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } -int MRIStepGetRootInfo(void* arkode_mem, int* rootsfound) -{ - return (arkGetRootInfo(arkode_mem, rootsfound)); -} - -int MRIStepGetNumStepSolveFails(void* arkode_mem, long int* nncfails) -{ - return (arkGetNumStepSolveFails(arkode_mem, nncfails)); -} - -int MRIStepGetUserData(void* arkode_mem, void** user_data) -{ - return (arkGetUserData(arkode_mem, user_data)); -} - -char* MRIStepGetReturnFlagName(long int flag) -{ - return (arkGetReturnFlagName(flag)); -} - -int MRIStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) -{ - return (arkGetNumStepAttempts(arkode_mem, nstep_attempts)); -} - -int MRIStepGetNumErrTestFails(void* arkode_mem, long int* netfails) -{ - return (arkGetNumErrTestFails(arkode_mem, netfails)); -} - -int MRIStepGetEstLocalErrors(void* arkode_mem, N_Vector ele) -{ - return (arkGetEstLocalErrors(arkode_mem, ele)); -} - -int MRIStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused) -{ - return (arkGetActualInitStep(arkode_mem, hinused)); -} - -int MRIStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) -{ - return (arkGetCurrentStep(arkode_mem, hcur)); -} - -int MRIStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) -{ - return (arkGetNumConstrFails(arkode_mem, nconstrfails)); -} - -int MRIStepGetNumExpSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumExpSteps(arkode_mem, nsteps)); -} - -int MRIStepGetNumAccSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumAccSteps(arkode_mem, nsteps)); -} - -/*--------------------------------------------------------------- - These wrappers for ARKLs module 'get' routines all are - documented in arkode_mristep.h. - ---------------------------------------------------------------*/ -int MRIStepGetJac(void* arkode_mem, SUNMatrix* J) -{ - return arkLSGetJac(arkode_mem, J); -} - -int MRIStepGetJacTime(void* arkode_mem, sunrealtype* t_J) -{ - return arkLSGetJacTime(arkode_mem, t_J); -} - -int MRIStepGetJacNumSteps(void* arkode_mem, long* nst_J) -{ - return arkLSGetJacNumSteps(arkode_mem, nst_J); -} - -int MRIStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) -{ - return (arkLSGetWorkSpace(arkode_mem, lenrwLS, leniwLS)); -} - -int MRIStepGetNumJacEvals(void* arkode_mem, long int* njevals) -{ - return (arkLSGetNumJacEvals(arkode_mem, njevals)); -} - -int MRIStepGetNumPrecEvals(void* arkode_mem, long int* npevals) -{ - return (arkLSGetNumPrecEvals(arkode_mem, npevals)); -} - -int MRIStepGetNumPrecSolves(void* arkode_mem, long int* npsolves) -{ - return (arkLSGetNumPrecSolves(arkode_mem, npsolves)); -} - -int MRIStepGetNumLinIters(void* arkode_mem, long int* nliters) -{ - return (arkLSGetNumLinIters(arkode_mem, nliters)); -} - -int MRIStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails) -{ - return (arkLSGetNumConvFails(arkode_mem, nlcfails)); -} - -int MRIStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) -{ - return (arkLSGetNumJTSetupEvals(arkode_mem, njtsetups)); -} - -int MRIStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals) -{ - return (arkLSGetNumJtimesEvals(arkode_mem, njvevals)); -} - -int MRIStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) -{ - return (arkLSGetNumRhsEvals(arkode_mem, nfevalsLS)); -} - -int MRIStepGetLastLinFlag(void* arkode_mem, long int* flag) -{ - return (arkLSGetLastFlag(arkode_mem, flag)); -} - -char* MRIStepGetLinReturnFlagName(long int flag) -{ - return (arkLSGetReturnFlagName(flag)); + /* get the last return value from the inner stepper */ + *flag = step_mem->stepper->last_flag; + + return (ARK_SUCCESS); } /*=============================================================== - MRIStep optional input functions -- stepper-specific + Private functions attached to ARKODE ===============================================================*/ /*--------------------------------------------------------------- - MRIStepSetUserData: + mriStep_SetUserData: - Wrapper for generic arkSetUserData and arkLSSetUserData - routines. + Passes user-data pointer to attached linear solver module. ---------------------------------------------------------------*/ -int MRIStepSetUserData(void* arkode_mem, void* user_data) +int mriStep_SetUserData(ARKodeMem ark_mem, void* user_data) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* set user_data in ARKODE mem */ - retval = arkSetUserData(arkode_mem, user_data); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set user data in ARKODELS mem */ if (step_mem->lmem != NULL) { - retval = arkLSSetUserData(arkode_mem, user_data); + retval = arkLSSetUserData(ark_mem, user_data); if (retval != ARKLS_SUCCESS) { return (retval); } } @@ -400,20 +289,19 @@ int MRIStepSetUserData(void* arkode_mem, void* user_data) } /*--------------------------------------------------------------- - MRIStepSetDefaults: + mriStep_SetDefaults: Resets all MRIStep optional inputs to their default values. Does not change problem-defining function pointers or user_data pointer. ---------------------------------------------------------------*/ -int MRIStepSetDefaults(void* arkode_mem) +int mriStep_SetDefaults(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Set default values for integrator optional inputs */ @@ -442,9 +330,9 @@ int MRIStepSetDefaults(void* arkode_mem) } /*--------------------------------------------------------------- - MRIStepSetLinear: + mriStep_SetLinear: - Specifies that the implicit slow function, fs(t,y), is linear + Specifies that the implicit slow function, fsi(t,y), is linear in y, and to tighten the linear solver tolerances while taking only one Newton iteration. DO NOT USE IN COMBINATION WITH THE FIXED-POINT SOLVER. Automatically tightens DeltaGammaMax @@ -456,14 +344,13 @@ int MRIStepSetDefaults(void* arkode_mem) using an iterative linear solver this flag denotes time dependence of the preconditioner. ---------------------------------------------------------------*/ -int MRIStepSetLinear(void* arkode_mem, int timedepend) +int mriStep_SetLinear(ARKodeMem ark_mem, int timedepend) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameters */ @@ -475,21 +362,20 @@ int MRIStepSetLinear(void* arkode_mem, int timedepend) } /*--------------------------------------------------------------- - MRIStepSetNonlinear: + mriStep_SetNonlinear: - Specifies that the implicit slow function, fs(t,y), is + Specifies that the implicit slow function, fsi(t,y), is nonlinear in y. Used to undo a previous call to - MRIStepSetLinear. Automatically loosens DeltaGammaMax back to + mriStep_SetLinear. Automatically loosens DeltaGammaMax back to default value. ---------------------------------------------------------------*/ -int MRIStepSetNonlinear(void* arkode_mem) +int mriStep_SetNonlinear(ARKodeMem ark_mem) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameters */ @@ -501,26 +387,22 @@ int MRIStepSetNonlinear(void* arkode_mem) } /*--------------------------------------------------------------- - MRIStepSetOrder: + mriStep_SetOrder: Specifies the method order - - NOTE: This should not be called along with MRIStepSetCoupling. - Any user-supplied coupling table will specify the order. ---------------------------------------------------------------*/ -int MRIStepSetOrder(void* arkode_mem, int ord) +int mriStep_SetOrder(ARKodeMem ark_mem, int ord) { int retval; - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; sunindextype Tlrw, Tliw; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval) { return (retval); } /* check for illegal inputs */ - if (ord < 2 || ord > 4) { step_mem->q = 3; } + if (ord < 3 || ord > 4) { step_mem->q = 3; } else { step_mem->q = ord; } /* Clear tables, the user is requesting a change in method or a reset to @@ -537,117 +419,19 @@ int MRIStepSetOrder(void* arkode_mem, int ord) } /*--------------------------------------------------------------- - MRIStepSetCoupling: - - Specifies to use a customized coupling structure for the slow - portion of the system. - ---------------------------------------------------------------*/ -int MRIStepSetCoupling(void* arkode_mem, MRIStepCoupling MRIC) -{ - int retval; - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - sunindextype Tlrw, Tliw; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* check for illegal inputs */ - if (MRIC == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_MRISTEP_NO_COUPLING); - return (ARK_ILL_INPUT); - } - - /* clear any existing parameters and coupling structure */ - step_mem->stages = 0; - step_mem->q = 0; - step_mem->p = 0; - MRIStepCoupling_Space(step_mem->MRIC, &Tliw, &Tlrw); - MRIStepCoupling_Free(step_mem->MRIC); - step_mem->MRIC = NULL; - ark_mem->liw -= Tliw; - ark_mem->lrw -= Tlrw; - - /* set the relevant parameters */ - step_mem->stages = MRIC->stages; - step_mem->q = MRIC->q; - step_mem->p = MRIC->p; - - /* copy the coupling structure in step memory */ - step_mem->MRIC = MRIStepCoupling_Copy(MRIC); - if (step_mem->MRIC == NULL) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_MRISTEP_NO_COUPLING); - return (ARK_MEM_NULL); - } - MRIStepCoupling_Space(step_mem->MRIC, &Tliw, &Tlrw); - ark_mem->liw += Tliw; - ark_mem->lrw += Tlrw; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepSetPreInnerFn: - - Sets the user-supplied function called BEFORE the inner evolve - ---------------------------------------------------------------*/ -int MRIStepSetPreInnerFn(void* arkode_mem, MRIStepPreInnerFn prefn) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Set pre inner evolve function */ - step_mem->pre_inner_evolve = prefn; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepSetPostInnerFn: - - Sets the user-supplied function called AFTER the inner evolve - ---------------------------------------------------------------*/ -int MRIStepSetPostInnerFn(void* arkode_mem, MRIStepPostInnerFn postfn) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Set pre inner evolve function */ - step_mem->post_inner_evolve = postfn; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepSetNonlinCRDown: + mriStep_SetNonlinCRDown: Specifies the user-provided nonlinear convergence constant crdown. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) +int mriStep_SetNonlinCRDown(ARKodeMem ark_mem, sunrealtype crdown) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -658,20 +442,19 @@ int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) } /*--------------------------------------------------------------- - MRIStepSetNonlinRDiv: + mriStep_SetNonlinRDiv: Specifies the user-provided nonlinear convergence constant rdiv. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int MRIStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) +int mriStep_SetNonlinRDiv(ARKodeMem ark_mem, sunrealtype rdiv) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -682,20 +465,19 @@ int MRIStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) } /*--------------------------------------------------------------- - MRIStepSetDeltaGammaMax: + mriStep_SetDeltaGammaMax: Specifies the user-provided linear setup decision constant dgmax. Legal values are strictly positive; illegal values imply a reset to the default. ---------------------------------------------------------------*/ -int MRIStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) +int mriStep_SetDeltaGammaMax(ARKodeMem ark_mem, sunrealtype dgmax) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -706,21 +488,20 @@ int MRIStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) } /*--------------------------------------------------------------- - MRIStepSetLSetupFrequency: + mriStep_SetLSetupFrequency: Specifies the user-provided linear setup decision constant msbp. Positive values give the frequency for calling lsetup; negative values imply recomputation of lsetup at each nonlinear solve; a zero value implies a reset to the default. ---------------------------------------------------------------*/ -int MRIStepSetLSetupFrequency(void* arkode_mem, int msbp) +int mriStep_SetLSetupFrequency(ARKodeMem ark_mem, int msbp) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if argument legal set it, otherwise set default */ @@ -731,20 +512,19 @@ int MRIStepSetLSetupFrequency(void* arkode_mem, int msbp) } /*--------------------------------------------------------------- - MRIStepSetPredictorMethod: + mriStep_SetPredictorMethod: Specifies the method to use for predicting implicit solutions. Non-default choices are {1,2,3,4}, all others will use default (trivial) predictor. ---------------------------------------------------------------*/ -int MRIStepSetPredictorMethod(void* arkode_mem, int pred_method) +int mriStep_SetPredictorMethod(ARKodeMem ark_mem, int pred_method) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set parameter */ @@ -754,20 +534,19 @@ int MRIStepSetPredictorMethod(void* arkode_mem, int pred_method) } /*--------------------------------------------------------------- - MRIStepSetMaxNonlinIters: + mriStep_SetMaxNonlinIters: Specifies the maximum number of nonlinear iterations during one solve. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int MRIStepSetMaxNonlinIters(void* arkode_mem, int maxcor) +int mriStep_SetMaxNonlinIters(ARKodeMem ark_mem, int maxcor) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return error message if no NLS module is present */ @@ -795,19 +574,18 @@ int MRIStepSetMaxNonlinIters(void* arkode_mem, int maxcor) } /*--------------------------------------------------------------- - MRIStepSetNonlinConvCoef: + mriStep_SetNonlinConvCoef: Specifies the coefficient in the nonlinear solver convergence test. A non-positive input implies a reset to the default value. ---------------------------------------------------------------*/ -int MRIStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) +int mriStep_SetNonlinConvCoef(ARKodeMem ark_mem, sunrealtype nlscoef) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* argument <= 0 sets default, otherwise set input */ @@ -818,18 +596,17 @@ int MRIStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) } /*--------------------------------------------------------------- - MRIStepSetStagePredictFn: Specifies a user-provided step + mriStep_SetStagePredictFn: Specifies a user-provided step predictor function having type ARKStagePredictFn. A NULL input function disables calls to this routine. ---------------------------------------------------------------*/ -int MRIStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) +int mriStep_SetStagePredictFn(ARKodeMem ark_mem, ARKStagePredictFn PredictStage) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure and set function pointer */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } step_mem->stage_predict = PredictStage; @@ -837,7 +614,7 @@ int MRIStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) } /*--------------------------------------------------------------- - MRIStepSetDeduceImplicitRhs: + mriStep_SetDeduceImplicitRhs: Specifies if an optimization is used to avoid an evaluation of fi after a nonlinear solve for an implicit stage. If stage @@ -848,14 +625,13 @@ int MRIStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) fi(z_i), and SUNFALSE indicates that fi(z_i) is computed with an additional evaluation of fi. ---------------------------------------------------------------*/ -int MRIStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) +int mriStep_SetDeduceImplicitRhs(ARKodeMem ark_mem, sunbooleantype deduce) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure and set function pointer */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } step_mem->deduce_rhs = deduce; @@ -863,189 +639,50 @@ int MRIStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) } /*--------------------------------------------------------------- - MRIStepSetFastErrorStepFactor: + mriStep_GetCurrentGamma: Returns the current value of gamma + ---------------------------------------------------------------*/ +int mriStep_GetCurrentGamma(ARKodeMem ark_mem, sunrealtype* gamma) +{ + int retval; + ARKodeMRIStepMem step_mem; + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } + *gamma = step_mem->gamma; + return (retval); +} - Specifies a fast stepsize factor to use when estimating the - accumulated fast time scale solution error when MRI adaptivity - is enabled. The fast integrator is run twice over each fast - time interval, once using the inner step size h, and again - using hfactor*h (typically hfactor=k or 1/k for an integer k>1). - This is only needed when the results from - mriStepInnerStepper_GetError() cannot be trusted. In our - tests, we found this to be the case when the inner integrator - uses fixed step sizes. +/*--------------------------------------------------------------- + mriStep_GetNumLinSolvSetups: - An argument of 0 disables this fast error estimation strategy. - Arguments of hfactor < 0 or hfactor == 1 are illegal. - All other positive hfactor values will *attempt* to be used. + Returns the current number of calls to the lsetup routine ---------------------------------------------------------------*/ -int MRIStepSetFastErrorStepFactor(void* arkode_mem, sunrealtype hfactor) +int mriStep_GetNumLinSolvSetups(ARKodeMem ark_mem, long int* nlinsetups) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* return with error on illegal input */ - if ((hfactor < ZERO) || (hfactor == ONE)) - { - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Illegal input; must be >0 and not identically 1"); - return (ARK_ILL_INPUT); - } + /* get value from step_mem */ + *nlinsetups = step_mem->nsetups; - /* set value and return */ - step_mem->inner_hfactor = hfactor; return (ARK_SUCCESS); } /*--------------------------------------------------------------- - MRIStepSetAdaptController: - - Specifies a temporal adaptivity controller for MRIStep to use. - If a non-MRI controller is provided, this just passes that - through to arkSetAdaptController. However, if an MRI - controller is provided, then this wraps that inside a - "SUNAdaptController_MRIStep" wrapper, which will properly - interact with the fast integration module. - ---------------------------------------------------------------*/ -int MRIStepSetAdaptController(void* arkode_mem, SUNAdaptController C) -{ - /* Retrieve the controller type */ - SUNAdaptController_Type ctype = SUNAdaptController_GetType(C); - - /* If this does not have MRI type, then just pass to ARKODE */ - if ((ctype != SUN_ADAPTCONTROLLER_MRI_H) && - (ctype != SUN_ADAPTCONTROLLER_MRI_TOL)) - { - return (arkSetAdaptController(arkode_mem, C)); - } - - /* Create the mriStepControl wrapper, and pass that to ARKODE */ - SUNAdaptController Cwrapper = SUNAdaptController_MRIStep(arkode_mem, C); - return (arkSetAdaptController(arkode_mem, Cwrapper)); -} - -/*=============================================================== - MRIStep optional output functions -- stepper-specific - ===============================================================*/ - -int MRIStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Get ARKODE workspace */ - retval = arkGetWorkSpace(arkode_mem, lenrw, leniw); - if (retval) { return retval; } - - /* Get the inner stepper workspace */ - *lenrw += step_mem->stepper->lrw; - *leniw += step_mem->stepper->liw; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepGetLastInnerStepFlag: - - Returns the last return value from the inner stepper. - ---------------------------------------------------------------*/ -int MRIStepGetLastInnerStepFlag(void* arkode_mem, int* flag) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get the last return value from the inner stepper */ - *flag = step_mem->stepper->last_flag; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepGetCurrentGamma: Returns the current value of gamma - ---------------------------------------------------------------*/ -int MRIStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma) -{ - int retval; - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - *gamma = step_mem->gamma; - return (retval); -} - -/*--------------------------------------------------------------- - MRIStepGetNumRhsEvals: - - Returns the current number of calls to fse and fsi - ---------------------------------------------------------------*/ -int MRIStepGetNumRhsEvals(void* arkode_mem, long int* nfse_evals, - long int* nfsi_evals) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get number of fse and fsi evals from step_mem */ - *nfse_evals = step_mem->nfse; - *nfsi_evals = step_mem->nfsi; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepGetNumLinSolvSetups: - - Returns the current number of calls to the lsetup routine - ---------------------------------------------------------------*/ -int MRIStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get value from step_mem */ - *nlinsetups = step_mem->nsetups; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepGetNumNonlinSolvIters: + mriStep_GetNumNonlinSolvIters: Returns the current number of nonlinear solver iterations ---------------------------------------------------------------*/ -int MRIStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) +int mriStep_GetNumNonlinSolvIters(ARKodeMem ark_mem, long int* nniters) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nniters = step_mem->nls_iters; @@ -1054,18 +691,17 @@ int MRIStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) } /*--------------------------------------------------------------- - MRIStepGetNumNonlinSolvConvFails: + mriStep_GetNumNonlinSolvConvFails: Returns the current number of nonlinear solver convergence fails ---------------------------------------------------------------*/ -int MRIStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) +int mriStep_GetNumNonlinSolvConvFails(ARKodeMem ark_mem, long int* nnfails) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* set output from step_mem */ @@ -1075,19 +711,18 @@ int MRIStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) } /*--------------------------------------------------------------- - MRIStepGetNonlinSolvStats: + mriStep_GetNonlinSolvStats: Returns nonlinear solver statistics ---------------------------------------------------------------*/ -int MRIStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, - long int* nnfails) +int mriStep_GetNonlinSolvStats(ARKodeMem ark_mem, long int* nniters, + long int* nnfails) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nniters = step_mem->nls_iters; @@ -1097,44 +732,18 @@ int MRIStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, } /*--------------------------------------------------------------- - MRIStepGetCurrentCoupling: - - Sets pointer to the slow coupling structure currently in use. - ---------------------------------------------------------------*/ -int MRIStepGetCurrentCoupling(void* arkode_mem, MRIStepCoupling* MRIC) -{ - ARKodeMem ark_mem; - ARKodeMRIStepMem step_mem; - int retval; - - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* get coupling structure from step_mem */ - *MRIC = step_mem->MRIC; - - return (ARK_SUCCESS); -} - -/*--------------------------------------------------------------- - MRIStepPrintAllStats: + mriStep_PrintAllStats: Prints integrator statistics ---------------------------------------------------------------*/ -int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int mriStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; ARKLsMem arkls_mem; int retval; /* access ARKode MRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* step and rootfinding stats */ - retval = arkPrintAllStats(arkode_mem, outfile, fmt); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } switch (fmt) @@ -1155,9 +764,9 @@ int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* linear solver stats */ fprintf(outfile, "LS setups = %ld\n", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) + if (ark_mem->step_getlinmem(ark_mem)) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); fprintf(outfile, "Jac fn evals = %ld\n", arkls_mem->nje); fprintf(outfile, "LS RHS fn evals = %ld\n", arkls_mem->nfeDQ); fprintf(outfile, "Prec setup evals = %ld\n", arkls_mem->npe); @@ -1197,9 +806,9 @@ int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) /* linear solver stats */ fprintf(outfile, ",LS setups,%ld", step_mem->nsetups); - if (ark_mem->step_getlinmem(arkode_mem)) + if (ark_mem->step_getlinmem(ark_mem)) { - arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(arkode_mem)); + arkls_mem = (ARKLsMem)(ark_mem->step_getlinmem(ark_mem)); fprintf(outfile, ",Jac fn evals,%ld", arkls_mem->nje); fprintf(outfile, ",LS RHS fn evals,%ld", arkls_mem->nfeDQ); fprintf(outfile, ",Prec setup evals,%ld", arkls_mem->npe); @@ -1236,50 +845,391 @@ int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) return (ARK_SUCCESS); } -/*=============================================================== - MRIStep parameter output - ===============================================================*/ - /*--------------------------------------------------------------- - MRIStepWriteParameters: + mriStep_WriteParameters: Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int MRIStepWriteParameters(void* arkode_mem, FILE* fp) +int mriStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* output ARKODE infrastructure parameters first */ - retval = arkWriteParameters(arkode_mem, fp); - if (retval != ARK_SUCCESS) + /* print integrator parameters to file */ + fprintf(fp, "MRIStep time step module parameters:\n"); + fprintf(fp, " Method order %i\n", step_mem->q); + if (step_mem->linear) { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error writing ARKODE infrastructure parameters"); - return (retval); + fprintf(fp, " Linear implicit problem"); + if (step_mem->linear_timedep) + { + fprintf(fp, " (time-dependent Jacobian)\n"); + } + else { fprintf(fp, " (time-independent Jacobian)\n"); } + } + if (step_mem->explicit_rhs && step_mem->implicit_rhs) + { + fprintf(fp, " ImEx slow time scale\n"); } + else if (step_mem->implicit_rhs) + { + fprintf(fp, " Implicit slow time scale\n"); + } + else { fprintf(fp, " Explicit slow time scale\n"); } + + if (step_mem->implicit_rhs) + { + fprintf(fp, " Implicit predictor method = %i\n", step_mem->predictor); + fprintf(fp, " Implicit solver tolerance coefficient = %" RSYM "\n", + step_mem->nlscoef); + fprintf(fp, " Maximum number of nonlinear corrections = %i\n", + step_mem->maxcor); + fprintf(fp, " Nonlinear convergence rate constant = %" RSYM "\n", + step_mem->crdown); + fprintf(fp, " Nonlinear divergence tolerance = %" RSYM "\n", step_mem->rdiv); + fprintf(fp, " Gamma factor LSetup tolerance = %" RSYM "\n", step_mem->dgmax); + fprintf(fp, " Number of steps between LSetup calls = %i\n", step_mem->msbp); + } + fprintf(fp, "\n"); return (ARK_SUCCESS); } -/*--------------------------------------------------------------- - MRIStepWriteCoupling: +/*=============================================================== + Exported-but-deprecated user-callable functions. + ===============================================================*/ + +int MRIStepResize(void* arkode_mem, N_Vector y0, sunrealtype t0, + ARKVecResizeFn resize, void* resize_data) +{ + return (ARKodeResize(arkode_mem, y0, ONE, t0, resize, resize_data)); +} + +int MRIStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +{ + return (ARKodeReset(arkode_mem, tR, yR)); +} + +int MRIStepSStolerances(void* arkode_mem, sunrealtype reltol, sunrealtype abstol) +{ + return (ARKodeSStolerances(arkode_mem, reltol, abstol)); +} + +int MRIStepSVtolerances(void* arkode_mem, sunrealtype reltol, N_Vector abstol) +{ + return (ARKodeSVtolerances(arkode_mem, reltol, abstol)); +} + +int MRIStepWFtolerances(void* arkode_mem, ARKEwtFn efun) +{ + return (ARKodeWFtolerances(arkode_mem, efun)); +} + +int MRIStepSetLinearSolver(void* arkode_mem, SUNLinearSolver LS, SUNMatrix A) +{ + return (ARKodeSetLinearSolver(arkode_mem, LS, A)); +} + +int MRIStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) +{ + return (ARKodeRootInit(arkode_mem, nrtfn, g)); +} + +int MRIStepSetDefaults(void* arkode_mem) +{ + return (ARKodeSetDefaults(arkode_mem)); +} + +int MRIStepSetOrder(void* arkode_mem, int ord) +{ + return (ARKodeSetOrder(arkode_mem, ord)); +} + +int MRIStepSetInterpolantType(void* arkode_mem, int itype) +{ + return (ARKodeSetInterpolantType(arkode_mem, itype)); +} + +int MRIStepSetInterpolantDegree(void* arkode_mem, int degree) +{ + return (ARKodeSetInterpolantDegree(arkode_mem, degree)); +} + +int MRIStepSetDenseOrder(void* arkode_mem, int dord) +{ + return (ARKodeSetInterpolantDegree(arkode_mem, dord)); +} + +int MRIStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) +{ + return (ARKodeSetNonlinearSolver(arkode_mem, NLS)); +} + +int MRIStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fi) +{ + return (ARKodeSetNlsRhsFn(arkode_mem, nls_fi)); +} + +int MRIStepSetLinear(void* arkode_mem, int timedepend) +{ + return (ARKodeSetLinear(arkode_mem, timedepend)); +} + +int MRIStepSetNonlinear(void* arkode_mem) +{ + return (ARKodeSetNonlinear(arkode_mem)); +} + +int MRIStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) +{ + return (ARKodeSetMaxNumSteps(arkode_mem, mxsteps)); +} + +int MRIStepSetNonlinCRDown(void* arkode_mem, sunrealtype crdown) +{ + return (ARKodeSetNonlinCRDown(arkode_mem, crdown)); +} + +int MRIStepSetNonlinRDiv(void* arkode_mem, sunrealtype rdiv) +{ + return (ARKodeSetNonlinRDiv(arkode_mem, rdiv)); +} + +int MRIStepSetDeltaGammaMax(void* arkode_mem, sunrealtype dgmax) +{ + return (ARKodeSetDeltaGammaMax(arkode_mem, dgmax)); +} + +int MRIStepSetLSetupFrequency(void* arkode_mem, int msbp) +{ + return (ARKodeSetLSetupFrequency(arkode_mem, msbp)); +} + +int MRIStepSetPredictorMethod(void* arkode_mem, int pred_method) +{ + return (ARKodeSetPredictorMethod(arkode_mem, pred_method)); +} + +int MRIStepSetMaxNonlinIters(void* arkode_mem, int maxcor) +{ + return (ARKodeSetMaxNonlinIters(arkode_mem, maxcor)); +} + +int MRIStepSetNonlinConvCoef(void* arkode_mem, sunrealtype nlscoef) +{ + return (ARKodeSetNonlinConvCoef(arkode_mem, nlscoef)); +} + +int MRIStepSetMaxHnilWarns(void* arkode_mem, int mxhnil) +{ + return (ARKodeSetMaxHnilWarns(arkode_mem, mxhnil)); +} + +int MRIStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp) +{ + return (ARKodeSetInterpolateStopTime(arkode_mem, interp)); +} + +int MRIStepSetStopTime(void* arkode_mem, sunrealtype tstop) +{ + return (ARKodeSetStopTime(arkode_mem, tstop)); +} + +int MRIStepClearStopTime(void* arkode_mem) +{ + return (ARKodeClearStopTime(arkode_mem)); +} + +int MRIStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) +{ + return (ARKodeSetFixedStep(arkode_mem, hfixed)); +} + +int MRIStepSetRootDirection(void* arkode_mem, int* rootdir) +{ + return (ARKodeSetRootDirection(arkode_mem, rootdir)); +} + +int MRIStepSetNoInactiveRootWarn(void* arkode_mem) +{ + return (ARKodeSetNoInactiveRootWarn(arkode_mem)); +} + +int MRIStepSetUserData(void* arkode_mem, void* user_data) +{ + return (ARKodeSetUserData(arkode_mem, user_data)); +} + +int MRIStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) +{ + return (ARKodeSetPostprocessStepFn(arkode_mem, ProcessStep)); +} + +int MRIStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) +{ + return (ARKodeSetPostprocessStageFn(arkode_mem, ProcessStage)); +} + +int MRIStepSetStagePredictFn(void* arkode_mem, ARKStagePredictFn PredictStage) +{ + return (ARKodeSetStagePredictFn(arkode_mem, PredictStage)); +} + +int MRIStepSetDeduceImplicitRhs(void* arkode_mem, sunbooleantype deduce) +{ + return (ARKodeSetDeduceImplicitRhs(arkode_mem, deduce)); +} + +int MRIStepSetJacFn(void* arkode_mem, ARKLsJacFn jac) +{ + return (ARKodeSetJacFn(arkode_mem, jac)); +} + +int MRIStepSetJacEvalFrequency(void* arkode_mem, long int msbj) +{ + return (ARKodeSetJacEvalFrequency(arkode_mem, msbj)); +} + +int MRIStepSetLinearSolutionScaling(void* arkode_mem, sunbooleantype onoff) +{ + return (ARKodeSetLinearSolutionScaling(arkode_mem, onoff)); +} + +int MRIStepSetEpsLin(void* arkode_mem, sunrealtype eplifac) +{ + return (ARKodeSetEpsLin(arkode_mem, eplifac)); +} + +int MRIStepSetLSNormFactor(void* arkode_mem, sunrealtype nrmfac) +{ + return (ARKodeSetLSNormFactor(arkode_mem, nrmfac)); +} + +int MRIStepSetPreconditioner(void* arkode_mem, ARKLsPrecSetupFn psetup, + ARKLsPrecSolveFn psolve) +{ + return (ARKodeSetPreconditioner(arkode_mem, psetup, psolve)); +} + +int MRIStepSetJacTimes(void* arkode_mem, ARKLsJacTimesSetupFn jtsetup, + ARKLsJacTimesVecFn jtimes) +{ + return (ARKodeSetJacTimes(arkode_mem, jtsetup, jtimes)); +} + +int MRIStepSetJacTimesRhsFn(void* arkode_mem, ARKRhsFn jtimesRhsFn) +{ + return (ARKodeSetJacTimesRhsFn(arkode_mem, jtimesRhsFn)); +} + +int MRIStepSetLinSysFn(void* arkode_mem, ARKLsLinSysFn linsys) +{ + return (ARKodeSetLinSysFn(arkode_mem, linsys)); +} + +int MRIStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask) +{ + return (ARKodeEvolve(arkode_mem, tout, yout, tret, itask)); +} + +int MRIStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) +{ + return (ARKodeGetDky(arkode_mem, t, k, dky)); +} + +int MRIStepComputeState(void* arkode_mem, N_Vector zcor, N_Vector z) +{ + return (ARKodeComputeState(arkode_mem, zcor, z)); +} + +int MRIStepGetNumLinSolvSetups(void* arkode_mem, long int* nlinsetups) +{ + return (ARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups)); +} + +int MRIStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw) +{ + return (ARKodeGetWorkSpace(arkode_mem, lenrw, leniw)); +} + +int MRIStepGetNumSteps(void* arkode_mem, long int* nssteps) +{ + return (ARKodeGetNumSteps(arkode_mem, nssteps)); +} + +int MRIStepGetLastStep(void* arkode_mem, sunrealtype* hlast) +{ + return (ARKodeGetLastStep(arkode_mem, hlast)); +} + +int MRIStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) +{ + return (ARKodeGetCurrentTime(arkode_mem, tcur)); +} + +int MRIStepGetCurrentState(void* arkode_mem, N_Vector* state) +{ + return (ARKodeGetCurrentState(arkode_mem, state)); +} + +int MRIStepGetCurrentGamma(void* arkode_mem, sunrealtype* gamma) +{ + return (ARKodeGetCurrentGamma(arkode_mem, gamma)); +} + +int MRIStepGetTolScaleFactor(void* arkode_mem, sunrealtype* tolsfact) +{ + return (ARKodeGetTolScaleFactor(arkode_mem, tolsfact)); +} + +int MRIStepGetErrWeights(void* arkode_mem, N_Vector eweight) +{ + return (ARKodeGetErrWeights(arkode_mem, eweight)); +} + +int MRIStepGetNumGEvals(void* arkode_mem, long int* ngevals) +{ + return (ARKodeGetNumGEvals(arkode_mem, ngevals)); +} + +int MRIStepGetRootInfo(void* arkode_mem, int* rootsfound) +{ + return (ARKodeGetRootInfo(arkode_mem, rootsfound)); +} + +int MRIStepGetUserData(void* arkode_mem, void** user_data) +{ + return (ARKodeGetUserData(arkode_mem, user_data)); +} + +int MRIStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +{ + return (ARKodePrintAllStats(arkode_mem, outfile, fmt)); +} + +char* MRIStepGetReturnFlagName(long int flag) +{ + return (ARKodeGetReturnFlagName(flag)); +} + +int MRIStepWriteParameters(void* arkode_mem, FILE* fp) +{ + return (ARKodeWriteParameters(arkode_mem, fp)); +} - Outputs coupling structure to the provided file pointer. - ---------------------------------------------------------------*/ int MRIStepWriteCoupling(void* arkode_mem, FILE* fp) { ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* check that coupling structure is non-NULL (otherwise report error) */ @@ -1297,6 +1247,113 @@ int MRIStepWriteCoupling(void* arkode_mem, FILE* fp) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +int MRIStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* Fi, + sunrealtype* gamma, N_Vector* sdata, + void** user_data) +{ + return (ARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, Fi, gamma, + sdata, user_data)); +} + +int MRIStepGetNumNonlinSolvIters(void* arkode_mem, long int* nniters) +{ + return (ARKodeGetNumNonlinSolvIters(arkode_mem, nniters)); +} + +int MRIStepGetNumNonlinSolvConvFails(void* arkode_mem, long int* nnfails) +{ + return (ARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails)); +} + +int MRIStepGetNonlinSolvStats(void* arkode_mem, long int* nniters, + long int* nnfails) +{ + return (ARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails)); +} + +int MRIStepGetNumStepSolveFails(void* arkode_mem, long int* nncfails) +{ + return (ARKodeGetNumStepSolveFails(arkode_mem, nncfails)); +} + +int MRIStepGetJac(void* arkode_mem, SUNMatrix* J) +{ + return (ARKodeGetJac(arkode_mem, J)); +} + +int MRIStepGetJacTime(void* arkode_mem, sunrealtype* t_J) +{ + return (ARKodeGetJacTime(arkode_mem, t_J)); +} + +int MRIStepGetJacNumSteps(void* arkode_mem, long* nst_J) +{ + return (ARKodeGetJacNumSteps(arkode_mem, nst_J)); +} + +int MRIStepGetLinWorkSpace(void* arkode_mem, long int* lenrwLS, long int* leniwLS) +{ + return (ARKodeGetLinWorkSpace(arkode_mem, lenrwLS, leniwLS)); +} + +int MRIStepGetNumJacEvals(void* arkode_mem, long int* njevals) +{ + return (ARKodeGetNumJacEvals(arkode_mem, njevals)); +} + +int MRIStepGetNumPrecEvals(void* arkode_mem, long int* npevals) +{ + return (ARKodeGetNumPrecEvals(arkode_mem, npevals)); +} + +int MRIStepGetNumPrecSolves(void* arkode_mem, long int* npsolves) +{ + return (ARKodeGetNumPrecSolves(arkode_mem, npsolves)); +} + +int MRIStepGetNumLinIters(void* arkode_mem, long int* nliters) +{ + return (ARKodeGetNumLinIters(arkode_mem, nliters)); +} + +int MRIStepGetNumLinConvFails(void* arkode_mem, long int* nlcfails) +{ + return (ARKodeGetNumLinConvFails(arkode_mem, nlcfails)); +} + +int MRIStepGetNumJTSetupEvals(void* arkode_mem, long int* njtsetups) +{ + return (ARKodeGetNumJTSetupEvals(arkode_mem, njtsetups)); +} + +int MRIStepGetNumJtimesEvals(void* arkode_mem, long int* njvevals) +{ + return (ARKodeGetNumJtimesEvals(arkode_mem, njvevals)); +} + +int MRIStepGetNumLinRhsEvals(void* arkode_mem, long int* nfevalsLS) +{ + return (ARKodeGetNumLinRhsEvals(arkode_mem, nfevalsLS)); +} + +int MRIStepGetLastLinFlag(void* arkode_mem, long int* flag) +{ + return (ARKodeGetLastLinFlag(arkode_mem, flag)); +} + +char* MRIStepGetLinReturnFlagName(long int flag) +{ + return (ARKodeGetLinReturnFlagName(flag)); +} + +void MRIStepFree(void** arkode_mem) { ARKodeFree(arkode_mem); } + +void MRIStepPrintMem(void* arkode_mem, FILE* outfile) +{ + ARKodePrintMem(arkode_mem, outfile); +} + +/*=============================================================== EOF - ---------------------------------------------------------------*/ + ===============================================================*/ diff --git a/src/arkode/arkode_mristep_nls.c b/src/arkode/arkode_mristep_nls.c index a48ae86d56..4375806ade 100644 --- a/src/arkode/arkode_mristep_nls.c +++ b/src/arkode/arkode_mristep_nls.c @@ -24,23 +24,22 @@ #include "arkode_mristep_impl.h" /*=============================================================== - Exported functions + Interface routines supplied to ARKODE ===============================================================*/ /*--------------------------------------------------------------- - MRIStepSetNonlinearSolver: + mriStep_SetNonlinearSolver: This routine attaches a SUNNonlinearSolver object to the MRIStep module. ---------------------------------------------------------------*/ -int MRIStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) +int mriStep_SetNonlinearSolver(ARKodeMem ark_mem, SUNNonlinearSolver NLS) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Return immediately if NLS input is NULL */ @@ -94,7 +93,7 @@ int MRIStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) /* set convergence test function */ retval = SUNNonlinSolSetConvTestFn(step_mem->NLS, mriStep_NlsConvTest, - arkode_mem); + (void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -129,20 +128,19 @@ int MRIStepSetNonlinearSolver(void* arkode_mem, SUNNonlinearSolver NLS) } /*--------------------------------------------------------------- - MRIStepSetNlsRhsFn: + mriStep_SetNlsRhsFn: This routine sets an alternative user-supplied slow ODE right-hand side function to use in the evaluation of nonlinear system functions. ---------------------------------------------------------------*/ -int MRIStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fsi) +int mriStep_SetNlsRhsFn(ARKodeMem ark_mem, ARKRhsFn nls_fsi) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (nls_fsi) { step_mem->nls_fsi = nls_fsi; } @@ -152,22 +150,21 @@ int MRIStepSetNlsRhsFn(void* arkode_mem, ARKRhsFn nls_fsi) } /*--------------------------------------------------------------- - MRIStepGetNonlinearSystemData: + mriStep_GetNonlinearSystemData: This routine provides access to the relevant data needed to compute the nonlinear system function. ---------------------------------------------------------------*/ -int MRIStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, - N_Vector* zpred, N_Vector* z, N_Vector* F, - sunrealtype* gamma, N_Vector* sdata, - void** user_data) +int mriStep_GetNonlinearSystemData(ARKodeMem ark_mem, sunrealtype* tcur, + N_Vector* zpred, N_Vector* z, N_Vector* F, + sunrealtype* gamma, N_Vector* sdata, + void** user_data) { - ARKodeMem ark_mem; ARKodeMRIStepMem step_mem; int retval; /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = mriStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *tcur = ark_mem->tcur; @@ -181,9 +178,9 @@ int MRIStepGetNonlinearSystemData(void* arkode_mem, sunrealtype* tcur, return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== Utility routines called by MRIStep - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- mriStep_NlsInit: @@ -356,9 +353,9 @@ int mriStep_Nls(ARKodeMem ark_mem, int nflag) return (retval); } -/*--------------------------------------------------------------- +/*=============================================================== Interface routines supplied to the SUNNonlinearSolver module - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- mriStep_NlsLSetup: @@ -372,8 +369,8 @@ int mriStep_NlsLSetup(sunbooleantype jbad, sunbooleantype* jcur, void* arkode_me ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update convfail based on jbad flag */ @@ -415,8 +412,8 @@ int mriStep_NlsLSolve(N_Vector b, void* arkode_mem) ARKodeMRIStepMem step_mem; int retval, nonlin_iter; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* retrieve nonlinear solver iteration from module */ @@ -462,8 +459,8 @@ int mriStep_NlsResidual(N_Vector zcor, N_Vector r, void* arkode_mem) sunrealtype c[3]; N_Vector X[3]; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -517,8 +514,8 @@ int mriStep_NlsFPFunction(N_Vector zcor, N_Vector g, void* arkode_mem) ARKodeMRIStepMem step_mem; int retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* update 'ycur' value as stored predictor + current corrector */ @@ -568,8 +565,8 @@ int mriStep_NlsConvTest(SUNNonlinearSolver NLS, N_Vector y, N_Vector del, sunrealtype delnrm, dcon; int m, retval; - /* access ARKodeMRIStepMem structure */ - retval = mriStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeMRIStepMem structures */ + retval = mriStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* if the problem is linearly implicit, just return success */ diff --git a/src/arkode/arkode_relaxation.c b/src/arkode/arkode_relaxation.c index f9de44e45c..451fa6711a 100644 --- a/src/arkode/arkode_relaxation.c +++ b/src/arkode/arkode_relaxation.c @@ -415,7 +415,31 @@ int arkRelaxSolve(ARKodeMem ark_mem, ARKodeRelaxMem relax_mem, * Set functions * ---------------------------------------------------------------------------*/ -int arkRelaxSetEtaFail(void* arkode_mem, sunrealtype eta_fail) +int ARKodeSetRelaxFn(void* arkode_mem, ARKRelaxFn rfn, ARKRelaxJacFn rjac) +{ + ARKodeMem ark_mem; + if (arkode_mem == NULL) + { + arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, + MSG_ARK_NO_MEM); + return (ARK_MEM_NULL); + } + ark_mem = (ARKodeMem)arkode_mem; + + /* Call stepper-specific routine (if it exists) */ + if (ark_mem->step_setrelaxfn) + { + return ark_mem->step_setrelaxfn(arkode_mem, rfn, rjac); + } + else + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } +} + +int ARKodeSetRelaxEtaFail(void* arkode_mem, sunrealtype eta_fail) { int retval; ARKodeMem ark_mem; @@ -424,13 +448,21 @@ int arkRelaxSetEtaFail(void* arkode_mem, sunrealtype eta_fail) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (eta_fail > ZERO && eta_fail < ONE) { relax_mem->eta_fail = eta_fail; } else { relax_mem->eta_fail = ARK_RELAX_DEFAULT_ETA_FAIL; } return ARK_SUCCESS; } -int arkRelaxSetLowerBound(void* arkode_mem, sunrealtype lower) +int ARKodeSetRelaxLowerBound(void* arkode_mem, sunrealtype lower) { int retval; ARKodeMem ark_mem; @@ -439,13 +471,21 @@ int arkRelaxSetLowerBound(void* arkode_mem, sunrealtype lower) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (lower > ZERO && lower < ONE) { relax_mem->lower_bound = lower; } else { relax_mem->lower_bound = ARK_RELAX_DEFAULT_LOWER_BOUND; } return ARK_SUCCESS; } -int arkRelaxSetMaxFails(void* arkode_mem, int max_fails) +int ARKodeSetRelaxMaxFails(void* arkode_mem, int max_fails) { int retval; ARKodeMem ark_mem; @@ -454,13 +494,21 @@ int arkRelaxSetMaxFails(void* arkode_mem, int max_fails) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (max_fails > 0) { relax_mem->max_fails = max_fails; } else { relax_mem->max_fails = ARK_RELAX_DEFAULT_MAX_FAILS; } return ARK_SUCCESS; } -int arkRelaxSetMaxIters(void* arkode_mem, int max_iters) +int ARKodeSetRelaxMaxIters(void* arkode_mem, int max_iters) { int retval; ARKodeMem ark_mem; @@ -469,13 +517,21 @@ int arkRelaxSetMaxIters(void* arkode_mem, int max_iters) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (max_iters > 0) { relax_mem->max_iters = max_iters; } else { relax_mem->max_iters = ARK_RELAX_DEFAULT_MAX_ITERS; } return ARK_SUCCESS; } -int arkRelaxSetSolver(void* arkode_mem, ARKRelaxSolver solver) +int ARKodeSetRelaxSolver(void* arkode_mem, ARKRelaxSolver solver) { int retval; ARKodeMem ark_mem; @@ -484,6 +540,14 @@ int arkRelaxSetSolver(void* arkode_mem, ARKRelaxSolver solver) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (solver != ARK_RELAX_BRENT && solver != ARK_RELAX_NEWTON) { arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, @@ -496,7 +560,7 @@ int arkRelaxSetSolver(void* arkode_mem, ARKRelaxSolver solver) return ARK_SUCCESS; } -int arkRelaxSetResTol(void* arkode_mem, sunrealtype res_tol) +int ARKodeSetRelaxResTol(void* arkode_mem, sunrealtype res_tol) { int retval; ARKodeMem ark_mem; @@ -505,13 +569,21 @@ int arkRelaxSetResTol(void* arkode_mem, sunrealtype res_tol) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (res_tol > ZERO) { relax_mem->res_tol = res_tol; } else { relax_mem->res_tol = ARK_RELAX_DEFAULT_RES_TOL; } return ARK_SUCCESS; } -int arkRelaxSetTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) +int ARKodeSetRelaxTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) { int retval; ARKodeMem ark_mem; @@ -520,6 +592,14 @@ int arkRelaxSetTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (rel_tol > ZERO) { relax_mem->rel_tol = rel_tol; } else { relax_mem->rel_tol = ARK_RELAX_DEFAULT_REL_TOL; } @@ -529,7 +609,7 @@ int arkRelaxSetTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol) return ARK_SUCCESS; } -int arkRelaxSetUpperBound(void* arkode_mem, sunrealtype upper) +int ARKodeSetRelaxUpperBound(void* arkode_mem, sunrealtype upper) { int retval; ARKodeMem ark_mem; @@ -538,6 +618,14 @@ int arkRelaxSetUpperBound(void* arkode_mem, sunrealtype upper) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + if (upper > ONE) { relax_mem->upper_bound = upper; } else { relax_mem->upper_bound = ARK_RELAX_DEFAULT_UPPER_BOUND; } @@ -548,7 +636,7 @@ int arkRelaxSetUpperBound(void* arkode_mem, sunrealtype upper) * Get functions * ---------------------------------------------------------------------------*/ -int arkRelaxGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) +int ARKodeGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) { int retval; ARKodeMem ark_mem; @@ -557,12 +645,20 @@ int arkRelaxGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + *r_evals = relax_mem->num_relax_fn_evals; return ARK_SUCCESS; } -int arkRelaxGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) +int ARKodeGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) { int retval; ARKodeMem ark_mem; @@ -571,12 +667,20 @@ int arkRelaxGetNumRelaxJacEvals(void* arkode_mem, long int* J_evals) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + *J_evals = relax_mem->num_relax_jac_evals; return ARK_SUCCESS; } -int arkRelaxGetNumRelaxFails(void* arkode_mem, long int* relax_fails) +int ARKodeGetNumRelaxFails(void* arkode_mem, long int* relax_fails) { int retval; ARKodeMem ark_mem; @@ -585,12 +689,20 @@ int arkRelaxGetNumRelaxFails(void* arkode_mem, long int* relax_fails) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + *relax_fails = relax_mem->num_fails; return ARK_SUCCESS; } -int arkRelaxGetNumRelaxSolveFails(void* arkode_mem, long int* fails) +int ARKodeGetNumRelaxSolveFails(void* arkode_mem, long int* fails) { int retval; ARKodeMem ark_mem; @@ -599,12 +711,20 @@ int arkRelaxGetNumRelaxSolveFails(void* arkode_mem, long int* fails) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } + *fails = relax_mem->nls_fails; return ARK_SUCCESS; } -int arkRelaxGetNumRelaxBoundFails(void* arkode_mem, long int* fails) +int ARKodeGetNumRelaxBoundFails(void* arkode_mem, long int* fails) { int retval; ARKodeMem ark_mem; @@ -613,26 +733,20 @@ int arkRelaxGetNumRelaxBoundFails(void* arkode_mem, long int* fails) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } - *fails = relax_mem->bound_fails; - - return ARK_SUCCESS; -} - -int arkRelaxGetNumRelaxSolveIters(void* arkode_mem, long int* iters) -{ - int retval; - ARKodeMem ark_mem; - ARKodeRelaxMem relax_mem; - - retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); - if (retval) { return retval; } + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) + { + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); + } - *iters = relax_mem->nls_iters; + *fails = relax_mem->bound_fails; return ARK_SUCCESS; } -int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int ARKodeGetNumRelaxSolveIters(void* arkode_mem, long int* iters) { int retval; ARKodeMem ark_mem; @@ -641,36 +755,16 @@ int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); if (retval) { return retval; } - switch (fmt) + /* Guard against use for time steppers that do not allow relaxation */ + if (!ark_mem->step_supports_relaxation) { - case SUN_OUTPUTFORMAT_TABLE: - fprintf(outfile, "Relax fn evals = %ld\n", - relax_mem->num_relax_fn_evals); - fprintf(outfile, "Relax Jac evals = %ld\n", - relax_mem->num_relax_jac_evals); - fprintf(outfile, "Relax fails = %ld\n", - relax_mem->num_fails); - fprintf(outfile, "Relax bound fails = %ld\n", - relax_mem->bound_fails); - fprintf(outfile, "Relax NLS iters = %ld\n", - relax_mem->nls_iters); - fprintf(outfile, "Relax NLS fails = %ld\n", - relax_mem->nls_fails); - break; - case SUN_OUTPUTFORMAT_CSV: - fprintf(outfile, ",Relax fn evals,%ld", relax_mem->num_relax_fn_evals); - fprintf(outfile, ",Relax Jac evals,%ld", relax_mem->num_relax_jac_evals); - fprintf(outfile, ",Relax fails,%ld", relax_mem->num_fails); - fprintf(outfile, ",Relax bound fails,%ld", relax_mem->bound_fails); - fprintf(outfile, ",Relax NLS iters,%ld", relax_mem->nls_iters); - fprintf(outfile, ",Relax NLS fails,%ld", relax_mem->nls_fails); - break; - default: - arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, - "Invalid formatting option."); - return ARK_ILL_INPUT; + arkProcessError(ark_mem, ARK_STEPPER_UNSUPPORTED, __LINE__, __func__, + __FILE__, "time-stepping module does not support relaxation"); + return (ARK_STEPPER_UNSUPPORTED); } + *iters = relax_mem->nls_iters; + return ARK_SUCCESS; } @@ -679,21 +773,10 @@ int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) * ===========================================================================*/ /* Constructor called by stepper */ -int arkRelaxCreate(void* arkode_mem, ARKRelaxFn relax_fn, +int arkRelaxCreate(ARKodeMem ark_mem, ARKRelaxFn relax_fn, ARKRelaxJacFn relax_jac_fn, ARKRelaxDeltaEFn delta_e_fn, ARKRelaxGetOrderFn get_order_fn) { - ARKodeMem ark_mem; - - /* Check inputs */ - if (!arkode_mem) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return ARK_MEM_NULL; - } - ark_mem = (ARKodeMem)arkode_mem; - /* Disable relaxation if both user inputs are NULL */ if (!relax_fn && !relax_jac_fn) { @@ -841,6 +924,49 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout, return ARK_SUCCESS; } +/* Print relaxation solver statistics, called by ARKODE */ +int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +{ + int retval; + ARKodeMem ark_mem; + ARKodeRelaxMem relax_mem; + + retval = arkRelaxAccessMem(arkode_mem, __func__, &ark_mem, &relax_mem); + if (retval) { return retval; } + + switch (fmt) + { + case SUN_OUTPUTFORMAT_TABLE: + fprintf(outfile, "Relax fn evals = %ld\n", + relax_mem->num_relax_fn_evals); + fprintf(outfile, "Relax Jac evals = %ld\n", + relax_mem->num_relax_jac_evals); + fprintf(outfile, "Relax fails = %ld\n", + relax_mem->num_fails); + fprintf(outfile, "Relax bound fails = %ld\n", + relax_mem->bound_fails); + fprintf(outfile, "Relax NLS iters = %ld\n", + relax_mem->nls_iters); + fprintf(outfile, "Relax NLS fails = %ld\n", + relax_mem->nls_fails); + break; + case SUN_OUTPUTFORMAT_CSV: + fprintf(outfile, ",Relax fn evals,%ld", relax_mem->num_relax_fn_evals); + fprintf(outfile, ",Relax Jac evals,%ld", relax_mem->num_relax_jac_evals); + fprintf(outfile, ",Relax fails,%ld", relax_mem->num_fails); + fprintf(outfile, ",Relax bound fails,%ld", relax_mem->bound_fails); + fprintf(outfile, ",Relax NLS iters,%ld", relax_mem->nls_iters); + fprintf(outfile, ",Relax NLS fails,%ld", relax_mem->nls_fails); + break; + default: + arkProcessError(ark_mem, ARK_ILL_INPUT, __LINE__, __func__, __FILE__, + "Invalid formatting option."); + return ARK_ILL_INPUT; + } + + return ARK_SUCCESS; +} + /* ============================================================================= * EOF * ===========================================================================*/ diff --git a/src/arkode/arkode_relaxation_impl.h b/src/arkode/arkode_relaxation_impl.h index c52cb2521c..a8c9001ed0 100644 --- a/src/arkode/arkode_relaxation_impl.h +++ b/src/arkode/arkode_relaxation_impl.h @@ -99,7 +99,7 @@ struct ARKodeRelaxMemRec * ---------------------------------------------------------------------------*/ /* Driver and Stepper Functions */ -int arkRelaxCreate(void* arkode_mem, ARKRelaxFn relax_fn, +int arkRelaxCreate(ARKodeMem ark_mem, ARKRelaxFn relax_fn, ARKRelaxJacFn relax_jac_fn, ARKRelaxDeltaEFn delta_e_fn, ARKRelaxGetOrderFn get_order_fn); int arkRelaxDestroy(ARKodeRelaxMem relax_mem); @@ -107,22 +107,6 @@ int arkRelax(ARKodeMem ark_mem, int* relax_fails, sunrealtype* dsm_inout, int* nflag_out); /* User Functions */ -int arkRelaxSetEtaFail(void* arkode_mem, sunrealtype eta_fail); -int arkRelaxSetLowerBound(void* arkode_mem, sunrealtype lower); -int arkRelaxSetMaxFails(void* arkode_mem, int max_fails); -int arkRelaxSetMaxIters(void* arkode_mem, int max_iters); -int arkRelaxSetSolver(void* arkode_mem, ARKRelaxSolver solver); -int arkRelaxSetResTol(void* arkode_mem, sunrealtype res_tol); -int arkRelaxSetTol(void* arkode_mem, sunrealtype rel_tol, sunrealtype abs_tol); -int arkRelaxSetUpperBound(void* arkode_mem, sunrealtype upper); - -int arkRelaxGetNumRelaxFnEvals(void* arkode_mem, long int* r_evals); -int arkRelaxGetNumRelaxJacEvals(void* arkode_mem, long int* j_evals); -int arkRelaxGetNumRelaxFails(void* arkode_mem, long int* relax_fails); -int arkRelaxGetNumRelaxBoundFails(void* arkode_mem, long int* fails); -int arkRelaxGetNumRelaxSolveFails(void* arkode_mem, long int* fails); -int arkRelaxGetNumRelaxSolveIters(void* arkode_mem, long int* iters); - int arkRelaxPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt); /* ----------------------------------------------------------------------------- diff --git a/src/arkode/arkode_root.c b/src/arkode/arkode_root.c index a0e02df7e7..05d0a4a08c 100644 --- a/src/arkode/arkode_root.c +++ b/src/arkode/arkode_root.c @@ -24,28 +24,34 @@ #include "arkode_impl.h" +/*=============================================================== + Exported functions + ===============================================================*/ + /*--------------------------------------------------------------- - arkRootInit: + ARKodeRootInit: - arkRootInit initializes a rootfinding problem to be solved + ARKodeRootInit initializes a rootfinding problem to be solved during the integration of the ODE system. It loads the root function pointer and the number of root functions, notifies ARKODE that the "fullrhs" function is required, and allocates workspace memory. The return value is ARK_SUCCESS = 0 if no errors occurred, or a negative value otherwise. ---------------------------------------------------------------*/ -int arkRootInit(ARKodeMem ark_mem, int nrtfn, ARKRootFn g) +int ARKodeRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) { int i, nrt; - /* Check ark_mem pointer */ - if (ark_mem == NULL) + /* unpack ark_mem */ + ARKodeMem ark_mem; + if (arkode_mem == NULL) { arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, MSG_ARK_NO_MEM); return (ARK_MEM_NULL); } - nrt = (nrtfn < 0) ? 0 : nrtfn; + ark_mem = (ARKodeMem)arkode_mem; + nrt = (nrtfn < 0) ? 0 : nrtfn; /* Ensure that stepper provides fullrhs function */ if (nrt > 0) @@ -91,7 +97,7 @@ int arkRootInit(ARKodeMem ark_mem, int nrtfn, ARKRootFn g) ark_mem->liw += ARK_ROOT_LIW; } - /* If rerunning arkRootInit() with a different number of root + /* If rerunning ARKodeRootInit() with a different number of root functions (changing number of gfun components), then free currently held memory resources */ if ((nrt != ark_mem->root_mem->nrtfn) && (ark_mem->root_mem->nrtfn > 0)) @@ -113,7 +119,7 @@ int arkRootInit(ARKodeMem ark_mem, int nrtfn, ARKRootFn g) ark_mem->liw -= 3 * (ark_mem->root_mem->nrtfn); } - /* If arkRootInit() was called with nrtfn == 0, then set + /* If ARKodeRootInit() was called with nrtfn == 0, then set nrtfn to zero and gfun to NULL before returning */ if (nrt == 0) { @@ -122,7 +128,7 @@ int arkRootInit(ARKodeMem ark_mem, int nrtfn, ARKRootFn g) return (ARK_SUCCESS); } - /* If rerunning arkRootInit() with the same number of root + /* If rerunning ARKodeRootInit() with the same number of root functions (not changing number of gfun components), then check if the root function argument has changed */ /* If g != NULL then return as currently reserved memory @@ -265,6 +271,10 @@ int arkRootInit(ARKodeMem ark_mem, int nrtfn, ARKRootFn g) return (ARK_SUCCESS); } +/*=============================================================== + Private functions + ===============================================================*/ + /*--------------------------------------------------------------- arkRootFree @@ -499,7 +509,7 @@ int arkRootCheck2(void* arkode_mem) if (rootmem->irfnd == 0) { return (ARK_SUCCESS); } /* Set ark_ycur = y(tlo) */ - (void)arkGetDky(ark_mem, rootmem->tlo, 0, ark_mem->ycur); + (void)ARKodeGetDky(ark_mem, rootmem->tlo, 0, ark_mem->ycur); /* Evaluate root-finding function: glo = g(tlo, y(tlo)) */ retval = rootmem->gfun(rootmem->tlo, ark_mem->ycur, rootmem->glo, @@ -539,7 +549,7 @@ int arkRootCheck2(void* arkode_mem) else { /* set ark_ycur = y(tplus) via interpolation */ - (void)arkGetDky(ark_mem, tplus, 0, ark_mem->ycur); + (void)ARKodeGetDky(ark_mem, tplus, 0, ark_mem->ycur); } /* set ghi = g(tplus,y(tplus)) */ retval = rootmem->gfun(tplus, ark_mem->ycur, rootmem->ghi, rootmem->root_data); @@ -609,7 +619,7 @@ int arkRootCheck3(void* arkode_mem) else { rootmem->thi = rootmem->toutc; - (void)arkGetDky(ark_mem, rootmem->thi, 0, ark_mem->ycur); + (void)ARKodeGetDky(ark_mem, rootmem->thi, 0, ark_mem->ycur); } } @@ -637,7 +647,7 @@ int arkRootCheck3(void* arkode_mem) if (ier == ARK_SUCCESS) { return (ARK_SUCCESS); } /* If a root was found, interpolate to get y(trout) and return. */ - (void)arkGetDky(ark_mem, rootmem->trout, 0, ark_mem->ycur); + (void)ARKodeGetDky(ark_mem, rootmem->trout, 0, ark_mem->ycur); return (RTFOUND); } @@ -826,7 +836,7 @@ int arkRootfind(void* arkode_mem) tmid = rootmem->thi - fracsub * (rootmem->thi - rootmem->tlo); } - (void)arkGetDky(ark_mem, tmid, 0, ark_mem->ycur); + (void)ARKodeGetDky(ark_mem, tmid, 0, ark_mem->ycur); retval = rootmem->gfun(tmid, ark_mem->ycur, rootmem->grout, rootmem->root_data); rootmem->nge++; diff --git a/src/arkode/arkode_root_impl.h b/src/arkode/arkode_root_impl.h index 6b4d66704b..8e410b6927 100644 --- a/src/arkode/arkode_root_impl.h +++ b/src/arkode/arkode_root_impl.h @@ -30,10 +30,10 @@ extern "C" { ===============================================================*/ #define ARK_ROOT_LRW 5 -#define ARK_ROOT_LIW 12 /* int, ptr, etc */ +#define ARK_ROOT_LIW 12 /* Numeric constants */ -#define HUND SUN_RCONST(100.0) /* real 100.0 */ +#define HUND SUN_RCONST(100.0) /*=============================================================== ARKODE Root-finding Data Structure diff --git a/src/arkode/arkode_sprkstep.c b/src/arkode/arkode_sprkstep.c index 7ac45ee764..8537444ab6 100644 --- a/src/arkode/arkode_sprkstep.c +++ b/src/arkode/arkode_sprkstep.c @@ -30,7 +30,7 @@ #include "arkode_sprkstep_impl.h" /*=============================================================== - SPRKStep Exported functions -- Required + Exported functions ===============================================================*/ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, @@ -103,7 +103,7 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, /* Allocate vectors in stepper mem */ if (!arkAllocVec(ark_mem, y0, &(step_mem->sdata))) { - SPRKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -111,23 +111,29 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, { if (!arkAllocVec(ark_mem, y0, &(step_mem->yerr))) { - SPRKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } } else { step_mem->yerr = NULL; } - ark_mem->step_init = sprkStep_Init; - ark_mem->step_fullrhs = sprkStep_FullRHS; - ark_mem->step = sprkStep_TakeStep; - ark_mem->step_mem = (void*)step_mem; - - /* Set default values for SPRKStep optional inputs */ - retval = SPRKStepSetDefaults((void*)ark_mem); + ark_mem->step_init = sprkStep_Init; + ark_mem->step_fullrhs = sprkStep_FullRHS; + ark_mem->step = sprkStep_TakeStep; + ark_mem->step_printallstats = sprkStep_PrintAllStats; + ark_mem->step_writeparameters = sprkStep_WriteParameters; + ark_mem->step_resize = sprkStep_Resize; + ark_mem->step_free = sprkStep_Free; + ark_mem->step_setdefaults = sprkStep_SetDefaults; + ark_mem->step_setorder = sprkStep_SetOrder; + ark_mem->step_mem = (void*)step_mem; + + /* Set default values for optional inputs */ + retval = sprkStep_SetDefaults((void*)ark_mem); if (retval != ARK_SUCCESS) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Error setting default solver options"); - SPRKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -145,7 +151,7 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, /* SPRKStep uses Lagrange interpolation by default, since Hermite is less compatible with these methods. */ - arkSetInterpolantType(ark_mem, ARK_INTERP_LAGRANGE); + ARKodeSetInterpolantType(ark_mem, ARK_INTERP_LAGRANGE); /* Initialize main ARKODE infrastructure */ retval = arkInit(ark_mem, t0, y0, FIRST_INIT); @@ -153,7 +159,7 @@ void* SPRKStepCreate(ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Unable to initialize main ARKODE infrastructure"); - SPRKStepFree((void**)&ark_mem); + ARKodeFree((void**)&ark_mem); return (NULL); } @@ -178,8 +184,9 @@ int SPRKStepReInit(void* arkode_mem, ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Check if ark_mem was allocated */ @@ -230,102 +237,88 @@ int SPRKStepReInit(void* arkode_mem, ARKRhsFn f1, ARKRhsFn f2, sunrealtype t0, return (ARK_SUCCESS); } +/*=============================================================== + Interface routines supplied to ARKODE + ===============================================================*/ + /*--------------------------------------------------------------- - SPRKStepReset: + sprkStep_Resize: - This routine resets the SPRKStep module state to solve the same - problem from the given time with the input state (all counter - values are retained). + This routine resizes the memory within the SPRKStep module. ---------------------------------------------------------------*/ -int SPRKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; - int retval = 0; + sunindextype lrw1, liw1, lrw_diff, liw_diff; + int retval; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Initialize main ARKODE infrastructure */ - retval = arkInit(ark_mem, tR, yR, RESET_INIT); - - if (retval != ARK_SUCCESS) + /* Determine change in vector sizes */ + lrw1 = liw1 = 0; + if (y0->ops->nvspace != NULL) { N_VSpace(y0, &lrw1, &liw1); } + lrw_diff = lrw1 - ark_mem->lrw1; + liw_diff = liw1 - ark_mem->liw1; + ark_mem->lrw1 = lrw1; + ark_mem->liw1 = liw1; + + /* Resize the local vectors */ + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->sdata)) { - arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, - "Unable to initialize main ARKODE infrastructure"); - return (retval); + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); } - N_VConst(SUN_RCONST(0.0), step_mem->yerr); + if (step_mem->yerr) + { + if (!arkResizeVec(ark_mem, resize, resize_data, lrw_diff, liw_diff, y0, + &step_mem->yerr)) + { + arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, + "Unable to resize vector"); + return (ARK_MEM_FAIL); + } + } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - SPRKStepEvolve: + sprkStep_Reset: - This is the main time-integration driver (wrappers for general - ARKODE utility routine) + This routine resets the SPRKStep module state to solve the same + problem from the given time with the input state (all counter + values are retained). ---------------------------------------------------------------*/ -int SPRKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, - sunrealtype* tret, int itask) +int sprkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR) { - /* unpack ark_mem, call arkEvolve, and return */ - ARKodeMem ark_mem = NULL; - int retval = 0; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkEvolve(ark_mem, tout, yout, tret, itask); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); -} + ARKodeSPRKStepMem step_mem = NULL; + int retval = 0; -/*--------------------------------------------------------------- - SPRKStepGetDky: + /* access ARKodeSPRKStepMem structure */ + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); + if (retval != ARK_SUCCESS) { return (retval); } - This returns interpolated output of the solution or its - derivatives over the most-recently-computed step (wrapper for - generic ARKODE utility routine) - ---------------------------------------------------------------*/ -int SPRKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) -{ - /* unpack ark_mem, call arkGetDky, and return */ - ARKodeMem ark_mem = NULL; - int retval = 0; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - SUNDIALS_MARK_FUNCTION_BEGIN(ARK_PROFILER); - retval = arkGetDky(ark_mem, t, k, dky); - SUNDIALS_MARK_FUNCTION_END(ARK_PROFILER); - return (retval); + N_VConst(SUN_RCONST(0.0), step_mem->yerr); + return (ARK_SUCCESS); } /*--------------------------------------------------------------- - SPRKStepFree frees all SPRKStep memory, and then calls an ARKODE - utility routine to free the ARKODE infrastructure memory. + sprkStep_Free frees all SPRKStep memory. ---------------------------------------------------------------*/ -void SPRKStepFree(void** arkode_mem) +void sprkStep_Free(ARKodeMem ark_mem) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; - /* nothing to do if arkode_mem is already NULL */ - if (*arkode_mem == NULL) { return; } + /* nothing to do if ark_mem is already NULL */ + if (ark_mem == NULL) { return; } /* conditional frees on non-NULL SPRKStep module */ - ark_mem = (ARKodeMem)(*arkode_mem); if (ark_mem->step_mem != NULL) { step_mem = (ARKodeSPRKStepMem)ark_mem->step_mem; @@ -347,19 +340,8 @@ void SPRKStepFree(void** arkode_mem) free(ark_mem->step_mem); ark_mem->step_mem = NULL; } - - /* free memory for overall ARKODE infrastructure */ - arkFree(arkode_mem); } -/*=============================================================== - SPRKStep Private functions - ===============================================================*/ - -/*--------------------------------------------------------------- - Interface routines supplied to ARKODE - ---------------------------------------------------------------*/ - /*--------------------------------------------------------------- sprkStep_Init: @@ -376,14 +358,13 @@ void SPRKStepFree(void** arkode_mem) With initialization type RESET_INIT, this routine does nothing. ---------------------------------------------------------------*/ -int sprkStep_Init(void* arkode_mem, int init_type) +int sprkStep_Init(ARKodeMem ark_mem, int init_type) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* immediately return if reset */ @@ -458,20 +439,6 @@ int sprkStep_Init(void* arkode_mem, int init_type) return (ARK_SUCCESS); } -int SPRKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) -{ - /* unpack ark_mem, call arkRootInit, and return */ - ARKodeMem ark_mem = NULL; - if (arkode_mem == NULL) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - MSG_ARK_NO_MEM); - return (ARK_MEM_NULL); - } - ark_mem = (ARKodeMem)arkode_mem; - return (arkRootInit(ark_mem, nrtfn, g)); -} - /* Utility to call f1 and increment the counter */ inline int sprkStep_f1(ARKodeSPRKStepMem step_mem, sunrealtype tcur, N_Vector ycur, N_Vector f1, void* user_data) @@ -511,15 +478,14 @@ inline int sprkStep_f2(ARKodeSPRKStepMem step_mem, sunrealtype tcur, Since RHS values are not stored in SPRKStep we evaluate the RHS functions for all modes. ----------------------------------------------------------------------------*/ -int sprkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode) { int retval = 0; - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* perform RHS functions contingent on 'mode' argument */ @@ -564,9 +530,8 @@ int sprkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, This requires only 2 vectors in principle, but we use three since we persist the stage data. Only the stage data vector belongs to SPRKStep, the other two are reused from the ARKODE core. */ -int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) +int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; N_Vector prev_stage = NULL; N_Vector curr_stage = NULL; @@ -576,7 +541,7 @@ int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } prev_stage = ark_mem->yn; @@ -640,10 +605,9 @@ int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr) /* Increment SPRK algorithm with compensated summation. This algorithm requires 6 vectors, but 5 of them are reused from the ARKODE core. */ -int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, +int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; N_Vector delta_Yi = NULL; N_Vector yn_plus_delta_Yi = NULL; @@ -654,7 +618,7 @@ int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } /* Vector shortcuts */ @@ -741,18 +705,18 @@ int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, return 0; } -/*--------------------------------------------------------------- +/*=============================================================== Internal utility routines - ---------------------------------------------------------------*/ + ===============================================================*/ /*--------------------------------------------------------------- - sprkStep_AccessStepMem: + sprkStep_AccessARKODEStepMem: Shortcut routine to unpack ark_mem and step_mem structures from void* pointer. If either is missing it returns ARK_MEM_NULL. ---------------------------------------------------------------*/ -int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem) +int sprkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem) { /* access ARKodeMem structure */ if (arkode_mem == NULL) @@ -762,6 +726,8 @@ int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_MEM_NULL); } *ark_mem = (ARKodeMem)arkode_mem; + + /* access ARKodeSPRKStepMem structure */ if ((*ark_mem)->step_mem == NULL) { arkProcessError(*ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, @@ -772,6 +738,26 @@ int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, return (ARK_SUCCESS); } +/*--------------------------------------------------------------- + sprkStep_AccessStepMem: + + Shortcut routine to unpack step_mem structure from ark_mem. + If missing it returns ARK_MEM_NULL. + ---------------------------------------------------------------*/ +int sprkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeSPRKStepMem* step_mem) +{ + /* access ARKodeSPRKStepMem structure */ + if (ark_mem->step_mem == NULL) + { + arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, fname, __FILE__, + MSG_SPRKSTEP_NO_MEM); + return (ARK_MEM_NULL); + } + *step_mem = (ARKodeSPRKStepMem)ark_mem->step_mem; + return (ARK_SUCCESS); +} + /*--------------------------------------------------------------- sprkStep_CheckNVector: @@ -788,3 +774,7 @@ sunbooleantype sprkStep_CheckNVector(N_Vector tmpl) } return (SUNTRUE); } + +/*=============================================================== + EOF + ===============================================================*/ diff --git a/src/arkode/arkode_sprkstep_impl.h b/src/arkode/arkode_sprkstep_impl.h index 720e9732ee..0493106586 100644 --- a/src/arkode/arkode_sprkstep_impl.h +++ b/src/arkode/arkode_sprkstep_impl.h @@ -66,20 +66,35 @@ typedef struct ARKodeSPRKStepMemRec SPRK time step module private function prototypes ===============================================================*/ -int sprkStep_Init(void* arkode_mem, int init_type); -int sprkStep_FullRHS(void* arkode_mem, sunrealtype t, N_Vector y, N_Vector f, +/* Interface routines supplied to ARKODE */ +int sprkStep_Init(ARKodeMem ark_mem, int init_type); +int sprkStep_FullRHS(ARKodeMem ark_mem, sunrealtype t, N_Vector y, N_Vector f, int mode); -int sprkStep_TakeStep(void* arkode_mem, sunrealtype* dsmPtr, int* nflagPtr); -int sprkStep_TakeStep_Compensated(void* arkode_mem, sunrealtype* dsmPtr, +int sprkStep_TakeStep(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int sprkStep_TakeStep_Compensated(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr); +int sprkStep_SetUserData(ARKodeMem ark_mem, void* user_data); +int sprkStep_SetDefaults(ARKodeMem ark_mem); +int sprkStep_SetOrder(ARKodeMem ark_mem, int ord); +int sprkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt); +int sprkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp); +int sprkStep_Reset(ARKodeMem ark_mem, sunrealtype tR, N_Vector yR); +int sprkStep_Resize(ARKodeMem ark_mem, N_Vector y0, sunrealtype hscale, + sunrealtype t0, ARKVecResizeFn resize, void* resize_data); +void sprkStep_Free(ARKodeMem ark_mem); +void sprkStep_PrintMem(ARKodeMem ark_mem, FILE* outfile); /* Internal utility routines */ -int sprkStep_AccessStepMem(void* arkode_mem, const char* fname, - ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem); +int sprkStep_AccessARKODEStepMem(void* arkode_mem, const char* fname, + ARKodeMem* ark_mem, ARKodeSPRKStepMem* step_mem); +int sprkStep_AccessStepMem(ARKodeMem ark_mem, const char* fname, + ARKodeSPRKStepMem* step_mem); sunbooleantype sprkStep_CheckNVector(N_Vector tmpl); + /* f1 = p' (Force evaluation) */ int sprkStep_f1(ARKodeSPRKStepMem step_mem, sunrealtype tcur, N_Vector ycur, N_Vector f1, void* user_data); + /* f2 = q' (Velocity evaluation) */ int sprkStep_f2(ARKodeSPRKStepMem step_mem, sunrealtype tcur, N_Vector ycur, N_Vector f2, void* user_data); diff --git a/src/arkode/arkode_sprkstep_io.c b/src/arkode/arkode_sprkstep_io.c index d26c5410eb..f8ccd8bfb2 100644 --- a/src/arkode/arkode_sprkstep_io.c +++ b/src/arkode/arkode_sprkstep_io.c @@ -29,170 +29,9 @@ #include "arkode_sprkstep_impl.h" /*=============================================================== - SPRKStep Optional input functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. - ===============================================================*/ -int SPRKStepSetInterpolantDegree(void* arkode_mem, int degree) -{ - if (degree < 0) { degree = ARK_INTERP_MAX_DEGREE; } - return (arkSetInterpolantDegree(arkode_mem, degree)); -} - -int SPRKStepSetInterpolantType(void* arkode_mem, int itype) -{ - return (arkSetInterpolantType(arkode_mem, itype)); -} - -int SPRKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) -{ - return (arkSetMaxNumSteps(arkode_mem, mxsteps)); -} - -int SPRKStepSetStopTime(void* arkode_mem, sunrealtype tstop) -{ - return (arkSetStopTime(arkode_mem, tstop)); -} - -int SPRKStepSetRootDirection(void* arkode_mem, int* rootdir) -{ - return (arkSetRootDirection(arkode_mem, rootdir)); -} - -int SPRKStepSetNoInactiveRootWarn(void* arkode_mem) -{ - return (arkSetNoInactiveRootWarn(arkode_mem)); -} - -int SPRKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) -{ - return (arkSetMaxNumConstrFails(arkode_mem, maxfails)); -} - -int SPRKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) -{ - return (arkSetPostprocessStepFn(arkode_mem, ProcessStep)); -} - -int SPRKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) -{ - return (arkSetPostprocessStageFn(arkode_mem, ProcessStage)); -} - -int SPRKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) -{ - return (arkSetFixedStep(arkode_mem, hfixed)); -} - -/*=============================================================== - SPRKStep Optional output functions (wrappers for generic ARKODE - utility routines). All are documented in arkode_io.c. - ===============================================================*/ -int SPRKStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) -{ - return (arkGetNumStepAttempts(arkode_mem, nstep_attempts)); -} - -int SPRKStepGetNumSteps(void* arkode_mem, long int* nsteps) -{ - return (arkGetNumSteps(arkode_mem, nsteps)); -} - -int SPRKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) -{ - return (arkGetLastStep(arkode_mem, hlast)); -} - -int SPRKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) -{ - return (arkGetCurrentStep(arkode_mem, hcur)); -} - -int SPRKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) -{ - return (arkGetCurrentTime(arkode_mem, tcur)); -} - -int SPRKStepGetCurrentState(void* arkode_mem, N_Vector* state) -{ - return (arkGetCurrentState(arkode_mem, state)); -} - -int SPRKStepGetRootInfo(void* arkode_mem, int* rootsfound) -{ - return (arkGetRootInfo(arkode_mem, rootsfound)); -} - -int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps, - sunrealtype* hinused, sunrealtype* hlast, - sunrealtype* hcur, sunrealtype* tcur) -{ - return (arkGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); -} - -int SPRKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) -{ - return (arkGetNumConstrFails(arkode_mem, nconstrfails)); -} - -int SPRKStepGetUserData(void* arkode_mem, void** user_data) -{ - return (arkGetUserData(arkode_mem, user_data)); -} - -char* SPRKStepGetReturnFlagName(long int flag) -{ - return (arkGetReturnFlagName(flag)); -} - -/*=============================================================== - SPRKStep optional input functions -- stepper-specific + Exported optional input functions. ===============================================================*/ -/*--------------------------------------------------------------- - SPRKStepSetUserData: - - Wrapper for generic arkSetUserData and arkLSSetUserData - routines. - ---------------------------------------------------------------*/ -int SPRKStepSetUserData(void* arkode_mem, void* user_data) -{ - return (arkSetUserData(arkode_mem, user_data)); -} - -/*--------------------------------------------------------------- - SPRKStepSetDefaults: - - Resets all SPRKStep optional inputs to their default values. - Does not change problem-defining function pointers or - user_data pointer. Also leaves alone any data - structures/options related to the ARKODE infrastructure itself - (e.g., root-finding and post-process step). - ---------------------------------------------------------------*/ -int SPRKStepSetDefaults(void* arkode_mem) -{ - ARKodeMem ark_mem = NULL; - ARKodeSPRKStepMem step_mem = NULL; - int retval = 0; - - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* Set default ARKODE infrastructure parameters */ - retval = arkSetDefaults(ark_mem); - if (retval != ARK_SUCCESS) - { - arkProcessError(NULL, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error setting ARKODE infrastructure defaults"); - return (retval); - } - - /* use the default method order */ - SPRKStepSetOrder(arkode_mem, 0); - - return (ARK_SUCCESS); -} - /*--------------------------------------------------------------- SPRKStepSetUseCompensatedSums: @@ -204,14 +43,15 @@ int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (onoff) { - arkSetUseCompensatedSums(arkode_mem, SUNTRUE); - ark_mem->step = sprkStep_TakeStep_Compensated; + ark_mem->use_compensated_sums = SUNTRUE; + ark_mem->step = sprkStep_TakeStep_Compensated; if (!step_mem->yerr) { if (!arkAllocVec(ark_mem, ark_mem->yn, &(step_mem->yerr))) @@ -222,11 +62,11 @@ int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) } else { - arkSetUseCompensatedSums(arkode_mem, SUNFALSE); - ark_mem->step = sprkStep_TakeStep; + ark_mem->use_compensated_sums = SUNFALSE; + ark_mem->step = sprkStep_TakeStep; } - return (ARK_SUCCESS); + return (retval); } /*--------------------------------------------------------------- @@ -235,7 +75,7 @@ int SPRKStepSetUseCompensatedSums(void* arkode_mem, sunbooleantype onoff) Specifies the SPRK method ** Note in documentation that this should not be called along - with SPRKStepSetOrder. ** + with ARKodeSetOrder. ** ---------------------------------------------------------------*/ int SPRKStepSetMethod(void* arkode_mem, ARKodeSPRKTable sprk_storage) { @@ -243,8 +83,9 @@ int SPRKStepSetMethod(void* arkode_mem, ARKodeSPRKTable sprk_storage) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (step_mem->method) @@ -269,8 +110,9 @@ int SPRKStepSetMethodName(void* arkode_mem, const char* method) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } if (step_mem->method) @@ -284,44 +126,31 @@ int SPRKStepSetMethodName(void* arkode_mem, const char* method) return step_mem->method ? ARK_SUCCESS : ARK_ILL_INPUT; } -/*--------------------------------------------------------------- - SPRKStepSetOrder: +/*=============================================================== + Exported optional output functions. + ===============================================================*/ - Specifies the method order +/*--------------------------------------------------------------- + SPRKStepGetCurrentMethod: - ** Note in documentation that this should not be called along - with SPRKStepSetMethod. ** + Returns the stepper method structure. ---------------------------------------------------------------*/ -int SPRKStepSetOrder(void* arkode_mem, int ord) +int SPRKStepGetCurrentMethod(void* arkode_mem, ARKodeSPRKTable* sprk_storage) { ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* Invalid orders result in the default order being used. */ - if (ord == 7 || ord == 9 || ord > 10) { ord = -1; } - - /* set user-provided value, or default, depending on argument */ - if (ord <= 0) { step_mem->q = 4; } - else { step_mem->q = ord; } - - if (step_mem->method) - { - ARKodeSPRKTable_Free(step_mem->method); - step_mem->method = NULL; - } + *sprk_storage = step_mem->method; return (ARK_SUCCESS); } -/*=============================================================== - SPRKStep optional output functions -- stepper-specific - ===============================================================*/ - /*--------------------------------------------------------------- SPRKStepGetNumRhsEvals: @@ -333,8 +162,9 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) ARKodeSPRKStepMem step_mem = NULL; int retval = 0; - /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + /* access ARKodeMem and ARKodeSPRKStepMem structures */ + retval = sprkStep_AccessARKODEStepMem(arkode_mem, __func__, &ark_mem, + &step_mem); if (retval != ARK_SUCCESS) { return (retval); } *nf1 = step_mem->nf1; @@ -343,43 +173,67 @@ int SPRKStepGetNumRhsEvals(void* arkode_mem, long int* nf1, long int* nf2) return (ARK_SUCCESS); } +/*=============================================================== + Private functions attached to ARKODE + ===============================================================*/ + /*--------------------------------------------------------------- - SPRKStepGetCurrentMethod: + sprkStep_SetDefaults: - Returns the stepper method structure. + Resets all SPRKStep optional inputs to their default values. + Does not change problem-defining function pointers or + user_data pointer. Also leaves alone any data + structures/options related to the ARKODE infrastructure itself + (e.g., root-finding and post-process step). ---------------------------------------------------------------*/ -int SPRKStepGetCurrentMethod(void* arkode_mem, ARKodeSPRKTable* sprk_storage) +int sprkStep_SetDefaults(ARKodeMem ark_mem) +{ + /* use the default method order */ + return (sprkStep_SetOrder(ark_mem, 0)); +} + +/*--------------------------------------------------------------- + sprkStep_SetOrder: + + Specifies the method order + ---------------------------------------------------------------*/ +int sprkStep_SetOrder(ARKodeMem ark_mem, int ord) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - *sprk_storage = step_mem->method; + /* Invalid orders result in the default order being used. */ + if (ord == 7 || ord == 9 || ord > 10) { ord = -1; } + + /* set user-provided value, or default, depending on argument */ + if (ord <= 0) { step_mem->q = 4; } + else { step_mem->q = ord; } + + if (step_mem->method) + { + ARKodeSPRKTable_Free(step_mem->method); + step_mem->method = NULL; + } return (ARK_SUCCESS); } /*--------------------------------------------------------------- - SPRKStepPrintAllStats: + sprkStep_PrintAllStats: Prints integrator statistics ---------------------------------------------------------------*/ -int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +int sprkStep_PrintAllStats(ARKodeMem ark_mem, FILE* outfile, SUNOutputFormat fmt) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); - if (retval != ARK_SUCCESS) { return (retval); } - - /* step and rootfinding stats */ - retval = arkPrintAllStats(arkode_mem, outfile, fmt); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } switch (fmt) @@ -403,35 +257,20 @@ int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) return (ARK_SUCCESS); } -/*=============================================================== - SPRKStep parameter output - ===============================================================*/ - /*--------------------------------------------------------------- - SPRKStepWriteParameters: + sprkStep_WriteParameters: Outputs all solver parameters to the provided file pointer. ---------------------------------------------------------------*/ -int SPRKStepWriteParameters(void* arkode_mem, FILE* fp) +int sprkStep_WriteParameters(ARKodeMem ark_mem, FILE* fp) { - ARKodeMem ark_mem = NULL; ARKodeSPRKStepMem step_mem = NULL; - int flag = 0; int retval = 0; /* access ARKodeSPRKStepMem structure */ - retval = sprkStep_AccessStepMem(arkode_mem, __func__, &ark_mem, &step_mem); + retval = sprkStep_AccessStepMem(ark_mem, __func__, &step_mem); if (retval != ARK_SUCCESS) { return (retval); } - /* output ARKODE infrastructure parameters first */ - flag = arkWriteParameters(ark_mem, fp); - if (flag != ARK_SUCCESS) - { - arkProcessError(ark_mem, ARK_MEM_NULL, __LINE__, __func__, __FILE__, - "Error writing ARKODE infrastructure parameters"); - return (flag); - } - /* print integrator parameters to file */ fprintf(fp, "SPRKStep time step module parameters:\n"); fprintf(fp, " Method order %i\n", step_mem->method->q); @@ -440,6 +279,170 @@ int SPRKStepWriteParameters(void* arkode_mem, FILE* fp) return (ARK_SUCCESS); } -/*--------------------------------------------------------------- +/*=============================================================== + Exported-but-deprecated user-callable functions. + ===============================================================*/ + +int SPRKStepReset(void* arkode_mem, sunrealtype tR, N_Vector yR) +{ + return (ARKodeReset(arkode_mem, tR, yR)); +} + +int SPRKStepRootInit(void* arkode_mem, int nrtfn, ARKRootFn g) +{ + return (ARKodeRootInit(arkode_mem, nrtfn, g)); +} + +int SPRKStepSetRootDirection(void* arkode_mem, int* rootdir) +{ + return (ARKodeSetRootDirection(arkode_mem, rootdir)); +} + +int SPRKStepSetNoInactiveRootWarn(void* arkode_mem) +{ + return (ARKodeSetNoInactiveRootWarn(arkode_mem)); +} + +int SPRKStepSetDefaults(void* arkode_mem) +{ + return (ARKodeSetDefaults(arkode_mem)); +} + +int SPRKStepSetOrder(void* arkode_mem, int ord) +{ + return (ARKodeSetOrder(arkode_mem, ord)); +} + +int SPRKStepSetInterpolantType(void* arkode_mem, int itype) +{ + return (ARKodeSetInterpolantType(arkode_mem, itype)); +} + +int SPRKStepSetInterpolantDegree(void* arkode_mem, int degree) +{ + return (ARKodeSetInterpolantDegree(arkode_mem, degree)); +} + +int SPRKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps) +{ + return (ARKodeSetMaxNumSteps(arkode_mem, mxsteps)); +} + +int SPRKStepSetStopTime(void* arkode_mem, sunrealtype tstop) +{ + return (ARKodeSetStopTime(arkode_mem, tstop)); +} + +int SPRKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed) +{ + return (ARKodeSetFixedStep(arkode_mem, hfixed)); +} + +int SPRKStepSetUserData(void* arkode_mem, void* user_data) +{ + return (ARKodeSetUserData(arkode_mem, user_data)); +} + +int SPRKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep) +{ + return (ARKodeSetPostprocessStepFn(arkode_mem, ProcessStep)); +} + +int SPRKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage) +{ + return (ARKodeSetPostprocessStageFn(arkode_mem, ProcessStage)); +} + +int SPRKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout, + sunrealtype* tret, int itask) +{ + return (ARKodeEvolve(arkode_mem, tout, yout, tret, itask)); +} + +int SPRKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky) +{ + return (ARKodeGetDky(arkode_mem, t, k, dky)); +} + +char* SPRKStepGetReturnFlagName(long int flag) +{ + return (ARKodeGetReturnFlagName(flag)); +} + +int SPRKStepGetCurrentState(void* arkode_mem, N_Vector* state) +{ + return (ARKodeGetCurrentState(arkode_mem, state)); +} + +int SPRKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur) +{ + return (ARKodeGetCurrentStep(arkode_mem, hcur)); +} + +int SPRKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur) +{ + return (ARKodeGetCurrentTime(arkode_mem, tcur)); +} + +int SPRKStepGetLastStep(void* arkode_mem, sunrealtype* hlast) +{ + return (ARKodeGetLastStep(arkode_mem, hlast)); +} + +int SPRKStepGetNumStepAttempts(void* arkode_mem, long int* nstep_attempts) +{ + return (ARKodeGetNumStepAttempts(arkode_mem, nstep_attempts)); +} + +int SPRKStepGetNumSteps(void* arkode_mem, long int* nsteps) +{ + return (ARKodeGetNumSteps(arkode_mem, nsteps)); +} + +int SPRKStepGetRootInfo(void* arkode_mem, int* rootsfound) +{ + return (ARKodeGetRootInfo(arkode_mem, rootsfound)); +} + +int SPRKStepGetUserData(void* arkode_mem, void** user_data) +{ + return (ARKodeGetUserData(arkode_mem, user_data)); +} + +int SPRKStepPrintAllStats(void* arkode_mem, FILE* outfile, SUNOutputFormat fmt) +{ + return (ARKodePrintAllStats(arkode_mem, outfile, fmt)); +} + +void SPRKStepPrintMem(void* arkode_mem, FILE* outfile) +{ + ARKodePrintMem(arkode_mem, outfile); +} + +int SPRKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails) +{ + return (ARKodeSetMaxNumConstrFails(arkode_mem, maxfails)); +} + +int SPRKStepWriteParameters(void* arkode_mem, FILE* fp) +{ + return (ARKodeWriteParameters(arkode_mem, fp)); +} + +int SPRKStepGetStepStats(void* arkode_mem, long int* nsteps, + sunrealtype* hinused, sunrealtype* hlast, + sunrealtype* hcur, sunrealtype* tcur) +{ + return (ARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur)); +} + +int SPRKStepGetNumConstrFails(void* arkode_mem, long int* nconstrfails) +{ + return (ARKodeGetNumConstrFails(arkode_mem, nconstrfails)); +} + +void SPRKStepFree(void** arkode_mem) { ARKodeFree(arkode_mem); } + +/*=============================================================== EOF - ---------------------------------------------------------------*/ + ===============================================================*/ diff --git a/src/arkode/arkode_user_controller.c b/src/arkode/arkode_user_controller.c index b8cfeb3655..29167a38cb 100644 --- a/src/arkode/arkode_user_controller.c +++ b/src/arkode/arkode_user_controller.c @@ -39,7 +39,7 @@ /* ----------------------------------------------------------------- * Function to create a new ARKUserControl controller - */ + * ----------------------------------------------------------------- */ SUNAdaptController ARKUserControl(SUNContext sunctx, void* arkode_mem, ARKAdaptFn hadapt, void* hadapt_data) diff --git a/src/arkode/fmod/farkode_arkstep_mod.c b/src/arkode/fmod/farkode_arkstep_mod.c index d71ece989a..4791bedcdc 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.c +++ b/src/arkode/fmod/farkode_arkstep_mod.c @@ -253,43 +253,203 @@ SWIGEXPORT void * _wrap_FARKStepCreate(ARKRhsFn farg1, ARKRhsFn farg2, double co } -SWIGEXPORT int _wrap_FARKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { +SWIGEXPORT int _wrap_FARKStepReInit(void *farg1, ARKRhsFn farg2, ARKRhsFn farg3, double const *farg4, N_Vector farg5) { int fresult ; void *arg1 = (void *) 0 ; - N_Vector arg2 = (N_Vector) 0 ; - sunrealtype arg3 ; + ARKRhsFn arg2 = (ARKRhsFn) 0 ; + ARKRhsFn arg3 = (ARKRhsFn) 0 ; sunrealtype arg4 ; - ARKVecResizeFn arg5 = (ARKVecResizeFn) 0 ; - void *arg6 = (void *) 0 ; + N_Vector arg5 = (N_Vector) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (N_Vector)(farg2); - arg3 = (sunrealtype)(*farg3); + arg2 = (ARKRhsFn)(farg2); + arg3 = (ARKRhsFn)(farg3); arg4 = (sunrealtype)(*farg4); - arg5 = (ARKVecResizeFn)(farg5); - arg6 = (void *)(farg6); - result = (int)ARKStepResize(arg1,arg2,arg3,arg4,arg5,arg6); + arg5 = (N_Vector)(farg5); + result = (int)ARKStepReInit(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FARKStepReInit(void *farg1, ARKRhsFn farg2, ARKRhsFn farg3, double const *farg4, N_Vector farg5) { +SWIGEXPORT int _wrap_FARKStepSetExplicit(void *farg1) { int fresult ; void *arg1 = (void *) 0 ; - ARKRhsFn arg2 = (ARKRhsFn) 0 ; - ARKRhsFn arg3 = (ARKRhsFn) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKStepSetExplicit(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepSetImplicit(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKStepSetImplicit(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepSetImEx(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKStepSetImEx(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepSetTables(void *farg1, int const *farg2, int const *farg3, void *farg4, void *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int arg3 ; + ARKodeButcherTable arg4 = (ARKodeButcherTable) 0 ; + ARKodeButcherTable arg5 = (ARKodeButcherTable) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + arg3 = (int)(*farg3); + arg4 = (ARKodeButcherTable)(farg4); + arg5 = (ARKodeButcherTable)(farg5); + result = (int)ARKStepSetTables(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepSetTableNum(void *farg1, int const *farg2, int const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKODE_DIRKTableID arg2 ; + ARKODE_ERKTableID arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKODE_DIRKTableID)(*farg2); + arg3 = (ARKODE_ERKTableID)(*farg3); + result = (int)ARKStepSetTableNum(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepSetTableName(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + arg3 = (char *)(farg3->data); + result = (int)ARKStepSetTableName(arg1,(char const *)arg2,(char const *)arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)ARKStepGetNumRhsEvals(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepGetCurrentButcherTables(void *farg1, void *farg2, void *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKodeButcherTable *arg2 = (ARKodeButcherTable *) 0 ; + ARKodeButcherTable *arg3 = (ARKodeButcherTable *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKodeButcherTable *)(farg2); + arg3 = (ARKodeButcherTable *)(farg3); + result = (int)ARKStepGetCurrentButcherTables(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepGetTimestepperStats(void *farg1, long *farg2, long *farg3, long *farg4, long *farg5, long *farg6, long *farg7, long *farg8) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + long *arg4 = (long *) 0 ; + long *arg5 = (long *) 0 ; + long *arg6 = (long *) 0 ; + long *arg7 = (long *) 0 ; + long *arg8 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + arg4 = (long *)(farg4); + arg5 = (long *)(farg5); + arg6 = (long *)(farg6); + arg7 = (long *)(farg7); + arg8 = (long *)(farg8); + result = (int)ARKStepGetTimestepperStats(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)ARKStepCreateMRIStepInnerStepper(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + sunrealtype arg3 ; sunrealtype arg4 ; - N_Vector arg5 = (N_Vector) 0 ; + ARKVecResizeFn arg5 = (ARKVecResizeFn) 0 ; + void *arg6 = (void *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKRhsFn)(farg2); - arg3 = (ARKRhsFn)(farg3); + arg2 = (N_Vector)(farg2); + arg3 = (sunrealtype)(*farg3); arg4 = (sunrealtype)(*farg4); - arg5 = (N_Vector)(farg5); - result = (int)ARKStepReInit(arg1,arg2,arg3,arg4,arg5); + arg5 = (ARKVecResizeFn)(farg5); + arg6 = (void *)(farg6); + result = (int)ARKStepResize(arg1,arg2,arg3,arg4,arg5,arg6); fresult = (int)(result); return fresult; } @@ -583,42 +743,6 @@ SWIGEXPORT int _wrap_FARKStepSetNonlinear(void *farg1) { } -SWIGEXPORT int _wrap_FARKStepSetExplicit(void *farg1) { - int fresult ; - void *arg1 = (void *) 0 ; - int result; - - arg1 = (void *)(farg1); - result = (int)ARKStepSetExplicit(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FARKStepSetImplicit(void *farg1) { - int fresult ; - void *arg1 = (void *) 0 ; - int result; - - arg1 = (void *)(farg1); - result = (int)ARKStepSetImplicit(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FARKStepSetImEx(void *farg1) { - int fresult ; - void *arg1 = (void *) 0 ; - int result; - - arg1 = (void *)(farg1); - result = (int)ARKStepSetImEx(arg1); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepSetDeduceImplicitRhs(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -633,58 +757,6 @@ SWIGEXPORT int _wrap_FARKStepSetDeduceImplicitRhs(void *farg1, int const *farg2) } -SWIGEXPORT int _wrap_FARKStepSetTables(void *farg1, int const *farg2, int const *farg3, void *farg4, void *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; - int arg3 ; - ARKodeButcherTable arg4 = (ARKodeButcherTable) 0 ; - ARKodeButcherTable arg5 = (ARKodeButcherTable) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - arg3 = (int)(*farg3); - arg4 = (ARKodeButcherTable)(farg4); - arg5 = (ARKodeButcherTable)(farg5); - result = (int)ARKStepSetTables(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FARKStepSetTableNum(void *farg1, int const *farg2, int const *farg3) { - int fresult ; - void *arg1 = (void *) 0 ; - ARKODE_DIRKTableID arg2 ; - ARKODE_ERKTableID arg3 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (ARKODE_DIRKTableID)(*farg2); - arg3 = (ARKODE_ERKTableID)(*farg3); - result = (int)ARKStepSetTableNum(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FARKStepSetTableName(void *farg1, SwigArrayWrapper *farg2, SwigArrayWrapper *farg3) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - arg3 = (char *)(farg3->data); - result = (int)ARKStepSetTableName(arg1,(char const *)arg2,(char const *)arg3); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepSetAdaptController(void *farg1, SUNAdaptController farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1527,46 +1599,6 @@ SWIGEXPORT int _wrap_FARKStepComputeState(void *farg1, N_Vector farg2, N_Vector } -SWIGEXPORT int _wrap_FARKStepSetAccumulatedErrorType(void *farg1, int const *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)ARKStepSetAccumulatedErrorType(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FARKStepResetAccumulatedError(void *farg1) { - int fresult ; - void *arg1 = (void *) 0 ; - int result; - - arg1 = (void *)(farg1); - result = (int)ARKStepResetAccumulatedError(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FARKStepGetAccumulatedError(void *farg1, double *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - sunrealtype *arg2 = (sunrealtype *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (sunrealtype *)(farg2); - result = (int)ARKStepGetAccumulatedError(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepGetNumExpSteps(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1609,22 +1641,6 @@ SWIGEXPORT int _wrap_FARKStepGetNumStepAttempts(void *farg1, long *farg2) { } -SWIGEXPORT int _wrap_FARKStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { - int fresult ; - void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)ARKStepGetNumRhsEvals(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepGetNumLinSolvSetups(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1653,22 +1669,6 @@ SWIGEXPORT int _wrap_FARKStepGetNumErrTestFails(void *farg1, long *farg2) { } -SWIGEXPORT int _wrap_FARKStepGetCurrentButcherTables(void *farg1, void *farg2, void *farg3) { - int fresult ; - void *arg1 = (void *) 0 ; - ARKodeButcherTable *arg2 = (ARKodeButcherTable *) 0 ; - ARKodeButcherTable *arg3 = (ARKodeButcherTable *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (ARKodeButcherTable *)(farg2); - arg3 = (ARKodeButcherTable *)(farg3); - result = (int)ARKStepGetCurrentButcherTables(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepGetEstLocalErrors(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1966,32 +1966,6 @@ SWIGEXPORT int _wrap_FARKStepWriteButcher(void *farg1, void *farg2) { } -SWIGEXPORT int _wrap_FARKStepGetTimestepperStats(void *farg1, long *farg2, long *farg3, long *farg4, long *farg5, long *farg6, long *farg7, long *farg8) { - int fresult ; - void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - long *arg4 = (long *) 0 ; - long *arg5 = (long *) 0 ; - long *arg6 = (long *) 0 ; - long *arg7 = (long *) 0 ; - long *arg8 = (long *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - arg4 = (long *)(farg4); - arg5 = (long *)(farg5); - arg6 = (long *)(farg6); - arg7 = (long *)(farg7); - arg8 = (long *)(farg8); - result = (int)ARKStepGetTimestepperStats(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepGetStepStats(void *farg1, long *farg2, double *farg3, double *farg4, double *farg5, double *farg6) { int fresult ; void *arg1 = (void *) 0 ; @@ -2469,20 +2443,6 @@ SWIGEXPORT void _wrap_FARKStepPrintMem(void *farg1, void *farg2) { } -SWIGEXPORT int _wrap_FARKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)ARKStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FARKStepSetRelaxFn(void *farg1, ARKRelaxFn farg2, ARKRelaxJacFn farg3) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod/farkode_arkstep_mod.f90 b/src/arkode/fmod/farkode_arkstep_mod.f90 index 3f264659b8..165149355b 100644 --- a/src/arkode/fmod/farkode_arkstep_mod.f90 +++ b/src/arkode/fmod/farkode_arkstep_mod.f90 @@ -47,8 +47,22 @@ module farkode_arkstep_mod integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_4 = ARKODE_ARK436L2SA_DIRK_6_3_4 integer(C_INT), parameter, public :: ARKSTEP_DEFAULT_ARK_ITABLE_5 = ARKODE_ARK548L2SA_DIRK_8_4_5 public :: FARKStepCreate - public :: FARKStepResize public :: FARKStepReInit + public :: FARKStepSetExplicit + public :: FARKStepSetImplicit + public :: FARKStepSetImEx + public :: FARKStepSetTables + public :: FARKStepSetTableNum + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FARKStepSetTableName + public :: FARKStepGetNumRhsEvals + public :: FARKStepGetCurrentButcherTables + public :: FARKStepGetTimestepperStats + public :: FARKStepCreateMRIStepInnerStepper + public :: FARKStepResize public :: FARKStepReset public :: FARKStepSStolerances public :: FARKStepSVtolerances @@ -69,17 +83,7 @@ module farkode_arkstep_mod public :: FARKStepSetNlsRhsFn public :: FARKStepSetLinear public :: FARKStepSetNonlinear - public :: FARKStepSetExplicit - public :: FARKStepSetImplicit - public :: FARKStepSetImEx public :: FARKStepSetDeduceImplicitRhs - public :: FARKStepSetTables - public :: FARKStepSetTableNum - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FARKStepSetTableName public :: FARKStepSetAdaptController public :: FARKStepSetAdaptivityAdjustment public :: FARKStepSetCFLFraction @@ -138,16 +142,11 @@ module farkode_arkstep_mod public :: FARKStepEvolve public :: FARKStepGetDky public :: FARKStepComputeState - public :: FARKStepSetAccumulatedErrorType - public :: FARKStepResetAccumulatedError - public :: FARKStepGetAccumulatedError public :: FARKStepGetNumExpSteps public :: FARKStepGetNumAccSteps public :: FARKStepGetNumStepAttempts - public :: FARKStepGetNumRhsEvals public :: FARKStepGetNumLinSolvSetups public :: FARKStepGetNumErrTestFails - public :: FARKStepGetCurrentButcherTables public :: FARKStepGetEstLocalErrors public :: FARKStepGetWorkSpace public :: FARKStepGetNumSteps @@ -169,7 +168,6 @@ module farkode_arkstep_mod public :: FARKStepGetReturnFlagName public :: FARKStepWriteParameters public :: FARKStepWriteButcher - public :: FARKStepGetTimestepperStats public :: FARKStepGetStepStats public :: FARKStepGetNonlinearSystemData public :: FARKStepGetNumNonlinSolvIters @@ -203,7 +201,6 @@ module farkode_arkstep_mod public :: FARKStepGetLinReturnFlagName public :: FARKStepFree public :: FARKStepPrintMem - public :: FARKStepCreateMRIStepInnerStepper public :: FARKStepSetRelaxFn public :: FARKStepSetRelaxEtaFail public :: FARKStepSetRelaxLowerBound @@ -234,28 +231,129 @@ function swigc_FARKStepCreate(farg1, farg2, farg3, farg4, farg5) & type(C_PTR) :: fresult end function -function swigc_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & -bind(C, name="_wrap_FARKStepResize") & +function swigc_FARKStepReInit(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FARKStepReInit") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -real(C_DOUBLE), intent(in) :: farg3 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 real(C_DOUBLE), intent(in) :: farg4 -type(C_FUNPTR), value :: farg5 +type(C_PTR), value :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepSetExplicit(farg1) & +bind(C, name="_wrap_FARKStepSetExplicit") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepSetImplicit(farg1) & +bind(C, name="_wrap_FARKStepSetImplicit") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepSetImEx(farg1) & +bind(C, name="_wrap_FARKStepSetImEx") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepSetTables(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FARKStepSetTables") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepSetTableNum(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKStepSetTableNum") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepSetTableName(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKStepSetTableName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepGetNumRhsEvals(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKStepGetNumRhsEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepGetCurrentButcherTables(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKStepGetCurrentButcherTables") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FARKStepGetTimestepperStats") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 type(C_PTR), value :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 integer(C_INT) :: fresult end function -function swigc_FARKStepReInit(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FARKStepReInit") & +function swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) & +bind(C, name="_wrap_FARKStepCreateMRIStepInnerStepper") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -type(C_FUNPTR), value :: farg3 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FARKStepResize") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg3 real(C_DOUBLE), intent(in) :: farg4 -type(C_PTR), value :: farg5 +type(C_FUNPTR), value :: farg5 +type(C_PTR), value :: farg6 integer(C_INT) :: fresult end function @@ -443,30 +541,6 @@ function swigc_FARKStepSetNonlinear(farg1) & integer(C_INT) :: fresult end function -function swigc_FARKStepSetExplicit(farg1) & -bind(C, name="_wrap_FARKStepSetExplicit") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepSetImplicit(farg1) & -bind(C, name="_wrap_FARKStepSetImplicit") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepSetImEx(farg1) & -bind(C, name="_wrap_FARKStepSetImEx") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - function swigc_FARKStepSetDeduceImplicitRhs(farg1, farg2) & bind(C, name="_wrap_FARKStepSetDeduceImplicitRhs") & result(fresult) @@ -476,39 +550,6 @@ function swigc_FARKStepSetDeduceImplicitRhs(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FARKStepSetTables(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FARKStepSetTables") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(C_PTR), value :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepSetTableNum(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKStepSetTableNum") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepSetTableName(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKStepSetTableName") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 -integer(C_INT) :: fresult -end function - function swigc_FARKStepSetAdaptController(farg1, farg2) & bind(C, name="_wrap_FARKStepSetAdaptController") & result(fresult) @@ -1046,32 +1087,6 @@ function swigc_FARKStepComputeState(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FARKStepSetAccumulatedErrorType(farg1, farg2) & -bind(C, name="_wrap_FARKStepSetAccumulatedErrorType") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepResetAccumulatedError(farg1) & -bind(C, name="_wrap_FARKStepResetAccumulatedError") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepGetAccumulatedError(farg1, farg2) & -bind(C, name="_wrap_FARKStepGetAccumulatedError") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FARKStepGetNumExpSteps(farg1, farg2) & bind(C, name="_wrap_FARKStepGetNumExpSteps") & result(fresult) @@ -1099,16 +1114,6 @@ function swigc_FARKStepGetNumStepAttempts(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FARKStepGetNumRhsEvals(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKStepGetNumRhsEvals") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -integer(C_INT) :: fresult -end function - function swigc_FARKStepGetNumLinSolvSetups(farg1, farg2) & bind(C, name="_wrap_FARKStepGetNumLinSolvSetups") & result(fresult) @@ -1127,16 +1132,6 @@ function swigc_FARKStepGetNumErrTestFails(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FARKStepGetCurrentButcherTables(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKStepGetCurrentButcherTables") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -integer(C_INT) :: fresult -end function - function swigc_FARKStepGetEstLocalErrors(farg1, farg2) & bind(C, name="_wrap_FARKStepGetEstLocalErrors") & result(fresult) @@ -1333,23 +1328,8 @@ function swigc_FARKStepWriteButcher(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & -bind(C, name="_wrap_FARKStepGetTimestepperStats") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -type(C_PTR), value :: farg4 -type(C_PTR), value :: farg5 -type(C_PTR), value :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR), value :: farg8 -integer(C_INT) :: fresult -end function - -function swigc_FARKStepGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) & -bind(C, name="_wrap_FARKStepGetStepStats") & +function swigc_FARKStepGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FARKStepGetStepStats") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -1653,15 +1633,6 @@ subroutine swigc_FARKStepPrintMem(farg1, farg2) & type(C_PTR), value :: farg2 end subroutine -function swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FARKStepCreateMRIStepInnerStepper") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FARKStepSetRelaxFn(farg1, farg2, farg3) & bind(C, name="_wrap_FARKStepSetRelaxFn") & result(fresult) @@ -1829,56 +1800,267 @@ function FARKStepCreate(fe, fi, t0, y0, sunctx) & swig_result = fresult end function -function FARKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & +function FARKStepReInit(arkode_mem, fe, fi, t0, y0) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(N_Vector), target, intent(inout) :: ynew -real(C_DOUBLE), intent(in) :: hscale +type(C_FUNPTR), intent(in), value :: fe +type(C_FUNPTR), intent(in), value :: fi real(C_DOUBLE), intent(in) :: t0 -type(C_FUNPTR), intent(in), value :: resize -type(C_PTR) :: resize_data +type(N_Vector), target, intent(inout) :: y0 integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -real(C_DOUBLE) :: farg3 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 real(C_DOUBLE) :: farg4 -type(C_FUNPTR) :: farg5 -type(C_PTR) :: farg6 +type(C_PTR) :: farg5 farg1 = arkode_mem -farg2 = c_loc(ynew) -farg3 = hscale +farg2 = fe +farg3 = fi farg4 = t0 -farg5 = resize -farg6 = resize_data -fresult = swigc_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) +farg5 = c_loc(y0) +fresult = swigc_FARKStepReInit(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function -function FARKStepReInit(arkode_mem, fe, fi, t0, y0) & +function FARKStepSetExplicit(arkode_mem) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: fe -type(C_FUNPTR), intent(in), value :: fi +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKStepSetExplicit(farg1) +swig_result = fresult +end function + +function FARKStepSetImplicit(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKStepSetImplicit(farg1) +swig_result = fresult +end function + +function FARKStepSetImEx(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKStepSetImEx(farg1) +swig_result = fresult +end function + +function FARKStepSetTables(arkode_mem, q, p, bi, be) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: q +integer(C_INT), intent(in) :: p +type(C_PTR) :: bi +type(C_PTR) :: be +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 + +farg1 = arkode_mem +farg2 = q +farg3 = p +farg4 = bi +farg5 = be +fresult = swigc_FARKStepSetTables(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FARKStepSetTableNum(arkode_mem, itable, etable) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(ARKODE_DIRKTableID), intent(in) :: itable +integer(ARKODE_ERKTableID), intent(in) :: etable +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +integer(C_INT) :: farg3 + +farg1 = arkode_mem +farg2 = itable +farg3 = etable +fresult = swigc_FARKStepSetTableNum(farg1, farg2, farg3) +swig_result = fresult +end function + + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FARKStepSetTableName(arkode_mem, itable, etable) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: itable +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +character(kind=C_CHAR, len=*), target :: etable +character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 +type(SwigArrayWrapper) :: farg3 + +farg1 = arkode_mem +call SWIG_string_to_chararray(itable, farg2_chars, farg2) +call SWIG_string_to_chararray(etable, farg3_chars, farg3) +fresult = swigc_FARKStepSetTableName(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKStepGetNumRhsEvals(arkode_mem, nfe_evals, nfi_evals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nfe_evals +integer(C_LONG), dimension(*), target, intent(inout) :: nfi_evals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(nfe_evals(1)) +farg3 = c_loc(nfi_evals(1)) +fresult = swigc_FARKStepGetNumRhsEvals(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKStepGetCurrentButcherTables(arkode_mem, bi, be) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: bi +type(C_PTR), target, intent(inout) :: be +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(bi) +farg3 = c_loc(be) +fresult = swigc_FARKStepGetCurrentButcherTables(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attempts, nfe_evals, nfi_evals, nlinsetups, & + netfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: expsteps +integer(C_LONG), dimension(*), target, intent(inout) :: accsteps +integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts +integer(C_LONG), dimension(*), target, intent(inout) :: nfe_evals +integer(C_LONG), dimension(*), target, intent(inout) :: nfi_evals +integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups +integer(C_LONG), dimension(*), target, intent(inout) :: netfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = arkode_mem +farg2 = c_loc(expsteps(1)) +farg3 = c_loc(accsteps(1)) +farg4 = c_loc(step_attempts(1)) +farg5 = c_loc(nfe_evals(1)) +farg6 = c_loc(nfi_evals(1)) +farg7 = c_loc(nlinsetups(1)) +farg8 = c_loc(netfails(1)) +fresult = swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FARKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(stepper) +fresult = swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) +swig_result = fresult +end function + +function FARKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: ynew +real(C_DOUBLE), intent(in) :: hscale real(C_DOUBLE), intent(in) :: t0 -type(N_Vector), target, intent(inout) :: y0 +type(C_FUNPTR), intent(in), value :: resize +type(C_PTR) :: resize_data integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 +type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg3 real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 +type(C_FUNPTR) :: farg5 +type(C_PTR) :: farg6 farg1 = arkode_mem -farg2 = fe -farg3 = fi +farg2 = c_loc(ynew) +farg3 = hscale farg4 = t0 -farg5 = c_loc(y0) -fresult = swigc_FARKStepReInit(farg1, farg2, farg3, farg4, farg5) +farg5 = resize +farg6 = resize_data +fresult = swigc_FARKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) swig_result = fresult end function @@ -2214,45 +2396,6 @@ function FARKStepSetNonlinear(arkode_mem) & swig_result = fresult end function -function FARKStepSetExplicit(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FARKStepSetExplicit(farg1) -swig_result = fresult -end function - -function FARKStepSetImplicit(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FARKStepSetImplicit(farg1) -swig_result = fresult -end function - -function FARKStepSetImEx(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FARKStepSetImEx(farg1) -swig_result = fresult -end function - function FARKStepSetDeduceImplicitRhs(arkode_mem, deduce) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2269,89 +2412,6 @@ function FARKStepSetDeduceImplicitRhs(arkode_mem, deduce) & swig_result = fresult end function -function FARKStepSetTables(arkode_mem, q, p, bi, be) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: q -integer(C_INT), intent(in) :: p -type(C_PTR) :: bi -type(C_PTR) :: be -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -integer(C_INT) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 - -farg1 = arkode_mem -farg2 = q -farg3 = p -farg4 = bi -farg5 = be -fresult = swigc_FARKStepSetTables(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - -function FARKStepSetTableNum(arkode_mem, itable, etable) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(ARKODE_DIRKTableID), intent(in) :: itable -integer(ARKODE_ERKTableID), intent(in) :: etable -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 -integer(C_INT) :: farg3 - -farg1 = arkode_mem -farg2 = itable -farg3 = etable -fresult = swigc_FARKStepSetTableNum(farg1, farg2, farg3) -swig_result = fresult -end function - - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FARKStepSetTableName(arkode_mem, itable, etable) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: itable -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -character(kind=C_CHAR, len=*), target :: etable -character(kind=C_CHAR), dimension(:), allocatable, target :: farg3_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 -type(SwigArrayWrapper) :: farg3 - -farg1 = arkode_mem -call SWIG_string_to_chararray(itable, farg2_chars, farg2) -call SWIG_string_to_chararray(etable, farg3_chars, farg3) -fresult = swigc_FARKStepSetTableName(farg1, farg2, farg3) -swig_result = fresult -end function - function FARKStepSetAdaptController(arkode_mem, c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3325,51 +3385,6 @@ function FARKStepComputeState(arkode_mem, zcor, z) & swig_result = fresult end function -function FARKStepSetAccumulatedErrorType(arkode_mem, accum_type) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = accum_type -fresult = swigc_FARKStepSetAccumulatedErrorType(farg1, farg2) -swig_result = fresult -end function - -function FARKStepResetAccumulatedError(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FARKStepResetAccumulatedError(farg1) -swig_result = fresult -end function - -function FARKStepGetAccumulatedError(arkode_mem, accum_error) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(accum_error(1)) -fresult = swigc_FARKStepGetAccumulatedError(farg1, farg2) -swig_result = fresult -end function - function FARKStepGetNumExpSteps(arkode_mem, expsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3418,25 +3433,6 @@ function FARKStepGetNumStepAttempts(arkode_mem, step_attempts) & swig_result = fresult end function -function FARKStepGetNumRhsEvals(arkode_mem, nfe_evals, nfi_evals) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: nfe_evals -integer(C_LONG), dimension(*), target, intent(inout) :: nfi_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 - -farg1 = arkode_mem -farg2 = c_loc(nfe_evals(1)) -farg3 = c_loc(nfi_evals(1)) -fresult = swigc_FARKStepGetNumRhsEvals(farg1, farg2, farg3) -swig_result = fresult -end function - function FARKStepGetNumLinSolvSetups(arkode_mem, nlinsetups) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3469,25 +3465,6 @@ function FARKStepGetNumErrTestFails(arkode_mem, netfails) & swig_result = fresult end function -function FARKStepGetCurrentButcherTables(arkode_mem, bi, be) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: bi -type(C_PTR), target, intent(inout) :: be -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 - -farg1 = arkode_mem -farg2 = c_loc(bi) -farg3 = c_loc(be) -fresult = swigc_FARKStepGetCurrentButcherTables(farg1, farg2, farg3) -swig_result = fresult -end function - function FARKStepGetEstLocalErrors(arkode_mem, ele) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3842,41 +3819,6 @@ function FARKStepWriteButcher(arkode_mem, fp) & swig_result = fresult end function -function FARKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attempts, nfe_evals, nfi_evals, nlinsetups, & - netfails) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_LONG), dimension(*), target, intent(inout) :: nfe_evals -integer(C_LONG), dimension(*), target, intent(inout) :: nfi_evals -integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups -integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -type(C_PTR) :: farg7 -type(C_PTR) :: farg8 - -farg1 = arkode_mem -farg2 = c_loc(expsteps(1)) -farg3 = c_loc(accsteps(1)) -farg4 = c_loc(step_attempts(1)) -farg5 = c_loc(nfe_evals(1)) -farg6 = c_loc(nfi_evals(1)) -farg7 = c_loc(nlinsetups(1)) -farg8 = c_loc(netfails(1)) -fresult = swigc_FARKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) -swig_result = fresult -end function - function FARKStepGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -4431,22 +4373,6 @@ subroutine FARKStepPrintMem(arkode_mem, outfile) call swigc_FARKStepPrintMem(farg1, farg2) end subroutine -function FARKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FARKStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FARKStepSetRelaxFn(arkode_mem, rfn, rjac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod/farkode_erkstep_mod.c b/src/arkode/fmod/farkode_erkstep_mod.c index 8b9e137d34..5def57befc 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.c +++ b/src/arkode/fmod/farkode_erkstep_mod.c @@ -251,41 +251,133 @@ SWIGEXPORT void * _wrap_FERKStepCreate(ARKRhsFn farg1, double const *farg2, N_Ve } -SWIGEXPORT int _wrap_FERKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { +SWIGEXPORT int _wrap_FERKStepReInit(void *farg1, ARKRhsFn farg2, double const *farg3, N_Vector farg4) { int fresult ; void *arg1 = (void *) 0 ; - N_Vector arg2 = (N_Vector) 0 ; + ARKRhsFn arg2 = (ARKRhsFn) 0 ; sunrealtype arg3 ; - sunrealtype arg4 ; - ARKVecResizeFn arg5 = (ARKVecResizeFn) 0 ; - void *arg6 = (void *) 0 ; + N_Vector arg4 = (N_Vector) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (N_Vector)(farg2); + arg2 = (ARKRhsFn)(farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (sunrealtype)(*farg4); - arg5 = (ARKVecResizeFn)(farg5); - arg6 = (void *)(farg6); - result = (int)ERKStepResize(arg1,arg2,arg3,arg4,arg5,arg6); + arg4 = (N_Vector)(farg4); + result = (int)ERKStepReInit(arg1,arg2,arg3,arg4); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FERKStepReInit(void *farg1, ARKRhsFn farg2, double const *farg3, N_Vector farg4) { +SWIGEXPORT int _wrap_FERKStepSetTable(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKRhsFn arg2 = (ARKRhsFn) 0 ; + ARKodeButcherTable arg2 = (ARKodeButcherTable) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKodeButcherTable)(farg2); + result = (int)ERKStepSetTable(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FERKStepSetTableNum(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKODE_ERKTableID arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKODE_ERKTableID)(*farg2); + result = (int)ERKStepSetTableNum(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FERKStepSetTableName(void *farg1, SwigArrayWrapper *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (char *)(farg2->data); + result = (int)ERKStepSetTableName(arg1,(char const *)arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FERKStepGetNumRhsEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ERKStepGetNumRhsEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FERKStepGetCurrentButcherTable(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKodeButcherTable *arg2 = (ARKodeButcherTable *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKodeButcherTable *)(farg2); + result = (int)ERKStepGetCurrentButcherTable(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FERKStepGetTimestepperStats(void *farg1, long *farg2, long *farg3, long *farg4, long *farg5, long *farg6) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + long *arg4 = (long *) 0 ; + long *arg5 = (long *) 0 ; + long *arg6 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + arg4 = (long *)(farg4); + arg5 = (long *)(farg5); + arg6 = (long *)(farg6); + result = (int)ERKStepGetTimestepperStats(arg1,arg2,arg3,arg4,arg5,arg6); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FERKStepResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; sunrealtype arg3 ; - N_Vector arg4 = (N_Vector) 0 ; + sunrealtype arg4 ; + ARKVecResizeFn arg5 = (ARKVecResizeFn) 0 ; + void *arg6 = (void *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKRhsFn)(farg2); + arg2 = (N_Vector)(farg2); arg3 = (sunrealtype)(*farg3); - arg4 = (N_Vector)(farg4); - result = (int)ERKStepReInit(arg1,arg2,arg3,arg4); + arg4 = (sunrealtype)(*farg4); + arg5 = (ARKVecResizeFn)(farg5); + arg6 = (void *)(farg6); + result = (int)ERKStepResize(arg1,arg2,arg3,arg4,arg5,arg6); fresult = (int)(result); return fresult; } @@ -437,48 +529,6 @@ SWIGEXPORT int _wrap_FERKStepSetDenseOrder(void *farg1, int const *farg2) { } -SWIGEXPORT int _wrap_FERKStepSetTable(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - ARKodeButcherTable arg2 = (ARKodeButcherTable) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (ARKodeButcherTable)(farg2); - result = (int)ERKStepSetTable(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FERKStepSetTableNum(void *farg1, int const *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - ARKODE_ERKTableID arg2 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (ARKODE_ERKTableID)(*farg2); - result = (int)ERKStepSetTableNum(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FERKStepSetTableName(void *farg1, SwigArrayWrapper *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - result = (int)ERKStepSetTableName(arg1,(char const *)arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepSetAdaptController(void *farg1, SUNAdaptController farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -959,46 +1009,6 @@ SWIGEXPORT int _wrap_FERKStepGetDky(void *farg1, double const *farg2, int const } -SWIGEXPORT int _wrap_FERKStepSetAccumulatedErrorType(void *farg1, int const *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)ERKStepSetAccumulatedErrorType(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FERKStepResetAccumulatedError(void *farg1) { - int fresult ; - void *arg1 = (void *) 0 ; - int result; - - arg1 = (void *)(farg1); - result = (int)ERKStepResetAccumulatedError(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FERKStepGetAccumulatedError(void *farg1, double *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - sunrealtype *arg2 = (sunrealtype *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (sunrealtype *)(farg2); - result = (int)ERKStepGetAccumulatedError(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepGetNumExpSteps(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1041,20 +1051,6 @@ SWIGEXPORT int _wrap_FERKStepGetNumStepAttempts(void *farg1, long *farg2) { } -SWIGEXPORT int _wrap_FERKStepGetNumRhsEvals(void *farg1, long *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)ERKStepGetNumRhsEvals(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepGetNumErrTestFails(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1069,20 +1065,6 @@ SWIGEXPORT int _wrap_FERKStepGetNumErrTestFails(void *farg1, long *farg2) { } -SWIGEXPORT int _wrap_FERKStepGetCurrentButcherTable(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - ARKodeButcherTable *arg2 = (ARKodeButcherTable *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (ARKodeButcherTable *)(farg2); - result = (int)ERKStepGetCurrentButcherTable(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepGetEstLocalErrors(void *farg1, N_Vector farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1324,28 +1306,6 @@ SWIGEXPORT int _wrap_FERKStepWriteButcher(void *farg1, void *farg2) { } -SWIGEXPORT int _wrap_FERKStepGetTimestepperStats(void *farg1, long *farg2, long *farg3, long *farg4, long *farg5, long *farg6) { - int fresult ; - void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - long *arg4 = (long *) 0 ; - long *arg5 = (long *) 0 ; - long *arg6 = (long *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - arg4 = (long *)(farg4); - arg5 = (long *)(farg5); - arg6 = (long *)(farg6); - result = (int)ERKStepGetTimestepperStats(arg1,arg2,arg3,arg4,arg5,arg6); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepGetStepStats(void *farg1, long *farg2, double *farg3, double *farg4, double *farg5, double *farg6) { int fresult ; void *arg1 = (void *) 0 ; @@ -1386,20 +1346,6 @@ SWIGEXPORT void _wrap_FERKStepPrintMem(void *farg1, void *farg2) { } -SWIGEXPORT int _wrap_FERKStepCreateMRIStepInnerStepper(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)ERKStepCreateMRIStepInnerStepper(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FERKStepSetRelaxFn(void *farg1, ARKRelaxFn farg2, ARKRelaxJacFn farg3) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod/farkode_erkstep_mod.f90 b/src/arkode/fmod/farkode_erkstep_mod.f90 index ed3fec7485..797d0ca9ff 100644 --- a/src/arkode/fmod/farkode_erkstep_mod.f90 +++ b/src/arkode/fmod/farkode_erkstep_mod.f90 @@ -35,8 +35,18 @@ module farkode_erkstep_mod integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_8 = ARKODE_FEHLBERG_13_7_8 integer(C_INT), parameter, public :: ERKSTEP_DEFAULT_9 = ARKODE_VERNER_16_8_9 public :: FERKStepCreate - public :: FERKStepResize public :: FERKStepReInit + public :: FERKStepSetTable + public :: FERKStepSetTableNum + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FERKStepSetTableName + public :: FERKStepGetNumRhsEvals + public :: FERKStepGetCurrentButcherTable + public :: FERKStepGetTimestepperStats + public :: FERKStepResize public :: FERKStepReset public :: FERKStepSStolerances public :: FERKStepSVtolerances @@ -47,13 +57,6 @@ module farkode_erkstep_mod public :: FERKStepSetInterpolantType public :: FERKStepSetInterpolantDegree public :: FERKStepSetDenseOrder - public :: FERKStepSetTable - public :: FERKStepSetTableNum - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type - public :: FERKStepSetTableName public :: FERKStepSetAdaptController public :: FERKStepSetAdaptivityAdjustment public :: FERKStepSetCFLFraction @@ -87,15 +90,10 @@ module farkode_erkstep_mod public :: FERKStepSetPostprocessStageFn public :: FERKStepEvolve public :: FERKStepGetDky - public :: FERKStepSetAccumulatedErrorType - public :: FERKStepResetAccumulatedError - public :: FERKStepGetAccumulatedError public :: FERKStepGetNumExpSteps public :: FERKStepGetNumAccSteps public :: FERKStepGetNumStepAttempts - public :: FERKStepGetNumRhsEvals public :: FERKStepGetNumErrTestFails - public :: FERKStepGetCurrentButcherTable public :: FERKStepGetEstLocalErrors public :: FERKStepGetWorkSpace public :: FERKStepGetNumSteps @@ -113,11 +111,9 @@ module farkode_erkstep_mod public :: FERKStepGetReturnFlagName public :: FERKStepWriteParameters public :: FERKStepWriteButcher - public :: FERKStepGetTimestepperStats public :: FERKStepGetStepStats public :: FERKStepFree public :: FERKStepPrintMem - public :: FERKStepCreateMRIStepInnerStepper public :: FERKStepSetRelaxFn public :: FERKStepSetRelaxEtaFail public :: FERKStepSetRelaxLowerBound @@ -147,27 +143,86 @@ function swigc_FERKStepCreate(farg1, farg2, farg3, farg4) & type(C_PTR) :: fresult end function -function swigc_FERKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & -bind(C, name="_wrap_FERKStepResize") & +function swigc_FERKStepReInit(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FERKStepReInit") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +type(C_FUNPTR), value :: farg2 real(C_DOUBLE), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 -type(C_FUNPTR), value :: farg5 +type(C_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FERKStepSetTable(farg1, farg2) & +bind(C, name="_wrap_FERKStepSetTable") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FERKStepSetTableNum(farg1, farg2) & +bind(C, name="_wrap_FERKStepSetTableNum") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FERKStepSetTableName(farg1, farg2) & +bind(C, name="_wrap_FERKStepSetTableName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FERKStepGetNumRhsEvals(farg1, farg2) & +bind(C, name="_wrap_FERKStepGetNumRhsEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FERKStepGetCurrentButcherTable(farg1, farg2) & +bind(C, name="_wrap_FERKStepGetCurrentButcherTable") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FERKStepGetTimestepperStats") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 type(C_PTR), value :: farg6 integer(C_INT) :: fresult end function -function swigc_FERKStepReInit(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FERKStepReInit") & +function swigc_FERKStepResize(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FERKStepResize") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +type(C_PTR), value :: farg2 real(C_DOUBLE), intent(in) :: farg3 -type(C_PTR), value :: farg4 +real(C_DOUBLE), intent(in) :: farg4 +type(C_FUNPTR), value :: farg5 +type(C_PTR), value :: farg6 integer(C_INT) :: fresult end function @@ -264,34 +319,6 @@ function swigc_FERKStepSetDenseOrder(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FERKStepSetTable(farg1, farg2) & -bind(C, name="_wrap_FERKStepSetTable") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FERKStepSetTableNum(farg1, farg2) & -bind(C, name="_wrap_FERKStepSetTableNum") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FERKStepSetTableName(farg1, farg2) & -bind(C, name="_wrap_FERKStepSetTableName") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FERKStepSetAdaptController(farg1, farg2) & bind(C, name="_wrap_FERKStepSetAdaptController") & result(fresult) @@ -598,32 +625,6 @@ function swigc_FERKStepGetDky(farg1, farg2, farg3, farg4) & integer(C_INT) :: fresult end function -function swigc_FERKStepSetAccumulatedErrorType(farg1, farg2) & -bind(C, name="_wrap_FERKStepSetAccumulatedErrorType") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FERKStepResetAccumulatedError(farg1) & -bind(C, name="_wrap_FERKStepResetAccumulatedError") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FERKStepGetAccumulatedError(farg1, farg2) & -bind(C, name="_wrap_FERKStepGetAccumulatedError") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FERKStepGetNumExpSteps(farg1, farg2) & bind(C, name="_wrap_FERKStepGetNumExpSteps") & result(fresult) @@ -651,15 +652,6 @@ function swigc_FERKStepGetNumStepAttempts(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FERKStepGetNumRhsEvals(farg1, farg2) & -bind(C, name="_wrap_FERKStepGetNumRhsEvals") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FERKStepGetNumErrTestFails(farg1, farg2) & bind(C, name="_wrap_FERKStepGetNumErrTestFails") & result(fresult) @@ -669,15 +661,6 @@ function swigc_FERKStepGetNumErrTestFails(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FERKStepGetCurrentButcherTable(farg1, farg2) & -bind(C, name="_wrap_FERKStepGetCurrentButcherTable") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FERKStepGetEstLocalErrors(farg1, farg2) & bind(C, name="_wrap_FERKStepGetEstLocalErrors") & result(fresult) @@ -838,19 +821,6 @@ function swigc_FERKStepWriteButcher(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6) & -bind(C, name="_wrap_FERKStepGetTimestepperStats") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -type(C_PTR), value :: farg4 -type(C_PTR), value :: farg5 -type(C_PTR), value :: farg6 -integer(C_INT) :: fresult -end function - function swigc_FERKStepGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) & bind(C, name="_wrap_FERKStepGetStepStats") & result(fresult) @@ -877,15 +847,6 @@ subroutine swigc_FERKStepPrintMem(farg1, farg2) & type(C_PTR), value :: farg2 end subroutine -function swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) & -bind(C, name="_wrap_FERKStepCreateMRIStepInnerStepper") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FERKStepSetRelaxFn(farg1, farg2, farg3) & bind(C, name="_wrap_FERKStepSetRelaxFn") & result(fresult) @@ -1014,39 +975,188 @@ function swigc_FERKStepGetNumRelaxSolveFails(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FERKStepGetNumRelaxSolveIters(farg1, farg2) & -bind(C, name="_wrap_FERKStepGetNumRelaxSolveIters") & -result(fresult) +function swigc_FERKStepGetNumRelaxSolveIters(farg1, farg2) & +bind(C, name="_wrap_FERKStepGetNumRelaxSolveIters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FERKStepCreate(f, t0, y0, sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(C_PTR) :: swig_result +type(C_FUNPTR), intent(in), value :: f +real(C_DOUBLE), intent(in) :: t0 +type(N_Vector), target, intent(inout) :: y0 +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 + +farg1 = f +farg2 = t0 +farg3 = c_loc(y0) +farg4 = sunctx +fresult = swigc_FERKStepCreate(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FERKStepReInit(arkode_mem, f, t0, y0) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: f +real(C_DOUBLE), intent(in) :: t0 +type(N_Vector), target, intent(inout) :: y0 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 + +farg1 = arkode_mem +farg2 = f +farg3 = t0 +farg4 = c_loc(y0) +fresult = swigc_FERKStepReInit(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FERKStepSetTable(arkode_mem, b) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: b +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = b +fresult = swigc_FERKStepSetTable(farg1, farg2) +swig_result = fresult +end function + +function FERKStepSetTableNum(arkode_mem, etable) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(ARKODE_ERKTableID), intent(in) :: etable +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = etable +fresult = swigc_FERKStepSetTableNum(farg1, farg2) +swig_result = fresult +end function + + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FERKStepSetTableName(arkode_mem, etable) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: etable +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 + +farg1 = arkode_mem +call SWIG_string_to_chararray(etable, farg2_chars, farg2) +fresult = swigc_FERKStepSetTableName(farg1, farg2) +swig_result = fresult +end function + +function FERKStepGetNumRhsEvals(arkode_mem, nfevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nfevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nfevals(1)) +fresult = swigc_FERKStepGetNumRhsEvals(farg1, farg2) +swig_result = fresult +end function + +function FERKStepGetCurrentButcherTable(arkode_mem, b) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -end interface +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: b +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +farg1 = arkode_mem +farg2 = c_loc(b) +fresult = swigc_FERKStepGetCurrentButcherTable(farg1, farg2) +swig_result = fresult +end function -contains - ! MODULE SUBPROGRAMS -function FERKStepCreate(f, t0, y0, sunctx) & +function FERKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attempts, nfevals, netfails) & result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR) :: swig_result -type(C_FUNPTR), intent(in), value :: f -real(C_DOUBLE), intent(in) :: t0 -type(N_Vector), target, intent(inout) :: y0 -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -real(C_DOUBLE) :: farg2 +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: expsteps +integer(C_LONG), dimension(*), target, intent(inout) :: accsteps +integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts +integer(C_LONG), dimension(*), target, intent(inout) :: nfevals +integer(C_LONG), dimension(*), target, intent(inout) :: netfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 type(C_PTR) :: farg3 type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 -farg1 = f -farg2 = t0 -farg3 = c_loc(y0) -farg4 = sunctx -fresult = swigc_FERKStepCreate(farg1, farg2, farg3, farg4) +farg1 = arkode_mem +farg2 = c_loc(expsteps(1)) +farg3 = c_loc(accsteps(1)) +farg4 = c_loc(step_attempts(1)) +farg5 = c_loc(nfevals(1)) +farg6 = c_loc(netfails(1)) +fresult = swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6) swig_result = fresult end function @@ -1078,28 +1188,6 @@ function FERKStepResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & swig_result = fresult end function -function FERKStepReInit(arkode_mem, f, t0, y0) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: f -real(C_DOUBLE), intent(in) :: t0 -type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 -type(C_PTR) :: farg4 - -farg1 = arkode_mem -farg2 = f -farg3 = t0 -farg4 = c_loc(y0) -fresult = swigc_FERKStepReInit(farg1, farg2, farg3, farg4) -swig_result = fresult -end function - function FERKStepReset(arkode_mem, tr, yr) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -1269,73 +1357,6 @@ function FERKStepSetDenseOrder(arkode_mem, dord) & swig_result = fresult end function -function FERKStepSetTable(arkode_mem, b) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR) :: b -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = b -fresult = swigc_FERKStepSetTable(farg1, farg2) -swig_result = fresult -end function - -function FERKStepSetTableNum(arkode_mem, etable) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(ARKODE_ERKTableID), intent(in) :: etable -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = etable -fresult = swigc_FERKStepSetTableNum(farg1, farg2) -swig_result = fresult -end function - - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FERKStepSetTableName(arkode_mem, etable) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: etable -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 - -farg1 = arkode_mem -call SWIG_string_to_chararray(etable, farg2_chars, farg2) -fresult = swigc_FERKStepSetTableName(farg1, farg2) -swig_result = fresult -end function - function FERKStepSetAdaptController(arkode_mem, c) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -1891,51 +1912,6 @@ function FERKStepGetDky(arkode_mem, t, k, dky) & swig_result = fresult end function -function FERKStepSetAccumulatedErrorType(arkode_mem, accum_type) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = accum_type -fresult = swigc_FERKStepSetAccumulatedErrorType(farg1, farg2) -swig_result = fresult -end function - -function FERKStepResetAccumulatedError(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FERKStepResetAccumulatedError(farg1) -swig_result = fresult -end function - -function FERKStepGetAccumulatedError(arkode_mem, accum_error) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(accum_error(1)) -fresult = swigc_FERKStepGetAccumulatedError(farg1, farg2) -swig_result = fresult -end function - function FERKStepGetNumExpSteps(arkode_mem, expsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -1984,22 +1960,6 @@ function FERKStepGetNumStepAttempts(arkode_mem, step_attempts) & swig_result = fresult end function -function FERKStepGetNumRhsEvals(arkode_mem, nfevals) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: nfevals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(nfevals(1)) -fresult = swigc_FERKStepGetNumRhsEvals(farg1, farg2) -swig_result = fresult -end function - function FERKStepGetNumErrTestFails(arkode_mem, netfails) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2016,22 +1976,6 @@ function FERKStepGetNumErrTestFails(arkode_mem, netfails) & swig_result = fresult end function -function FERKStepGetCurrentButcherTable(arkode_mem, b) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: b -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(b) -fresult = swigc_FERKStepGetCurrentButcherTable(farg1, farg2) -swig_result = fresult -end function - function FERKStepGetEstLocalErrors(arkode_mem, ele) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2322,34 +2266,6 @@ function FERKStepWriteButcher(arkode_mem, fp) & swig_result = fresult end function -function FERKStepGetTimestepperStats(arkode_mem, expsteps, accsteps, step_attempts, nfevals, netfails) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_LONG), dimension(*), target, intent(inout) :: nfevals -integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 -type(C_PTR) :: farg6 - -farg1 = arkode_mem -farg2 = c_loc(expsteps(1)) -farg3 = c_loc(accsteps(1)) -farg4 = c_loc(step_attempts(1)) -farg5 = c_loc(nfevals(1)) -farg6 = c_loc(netfails(1)) -fresult = swigc_FERKStepGetTimestepperStats(farg1, farg2, farg3, farg4, farg5, farg6) -swig_result = fresult -end function - function FERKStepGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2399,22 +2315,6 @@ subroutine FERKStepPrintMem(arkode_mem, outfile) call swigc_FERKStepPrintMem(farg1, farg2) end subroutine -function FERKStepCreateMRIStepInnerStepper(arkode_mem, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(stepper) -fresult = swigc_FERKStepCreateMRIStepInnerStepper(farg1, farg2) -swig_result = fresult -end function - function FERKStepSetRelaxFn(arkode_mem, rfn, rjac) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/fmod/farkode_mod.c b/src/arkode/fmod/farkode_mod.c index a66b1b0dcd..d2c2b6a895 100644 --- a/src/arkode/fmod/farkode_mod.c +++ b/src/arkode/fmod/farkode_mod.c @@ -242,6 +242,34 @@ enum { #include "arkode/arkode_ls.h" +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif + + +typedef struct { + void* data; + size_t size; +} SwigArrayWrapper; + + +SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { + SwigArrayWrapper result; + result.data = NULL; + result.size = 0; + return result; +} + + +#include + + typedef struct { void* cptr; int cmemflags; @@ -256,65 +284,1985 @@ SWIGINTERN SwigClassWrapper SwigClassWrapper_uninitialized() { } -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif - - -#include +SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { + if (self->cptr == NULL) { + /* LHS is unassigned */ + if (other.cmemflags & SWIG_MEM_RVALUE) { + /* Capture pointer from RHS, clear 'moving' flag */ + self->cptr = other.cptr; + self->cmemflags = other.cmemflags & (~SWIG_MEM_RVALUE); + } else { + /* Become a reference to the other object */ + self->cptr = other.cptr; + self->cmemflags = other.cmemflags & (~SWIG_MEM_OWN); + } + } else if (other.cptr == NULL) { + /* Replace LHS with a null pointer */ + free(self->cptr); + *self = SwigClassWrapper_uninitialized(); + } else { + if (self->cmemflags & SWIG_MEM_OWN) { + free(self->cptr); + } + self->cptr = other.cptr; + if (other.cmemflags & SWIG_MEM_RVALUE) { + /* Capture RHS */ + self->cmemflags = other.cmemflags & ~SWIG_MEM_RVALUE; + } else { + /* Point to RHS */ + self->cmemflags = other.cmemflags & ~SWIG_MEM_OWN; + } + } +} + +SWIGEXPORT int _wrap_FARKodeResize(void *farg1, N_Vector farg2, double const *farg3, double const *farg4, ARKVecResizeFn farg5, void *farg6) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + sunrealtype arg3 ; + sunrealtype arg4 ; + ARKVecResizeFn arg5 = (ARKVecResizeFn) 0 ; + void *arg6 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (sunrealtype)(*farg4); + arg5 = (ARKVecResizeFn)(farg5); + arg6 = (void *)(farg6); + result = (int)ARKodeResize(arg1,arg2,arg3,arg4,arg5,arg6); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeReset(void *farg1, double const *farg2, N_Vector farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (N_Vector)(farg3); + result = (int)ARKodeReset(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSStolerances(void *farg1, double const *farg2, double const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)ARKodeSStolerances(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSVtolerances(void *farg1, double const *farg2, N_Vector farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (N_Vector)(farg3); + result = (int)ARKodeSVtolerances(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeWFtolerances(void *farg1, ARKEwtFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKEwtFn arg2 = (ARKEwtFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKEwtFn)(farg2); + result = (int)ARKodeWFtolerances(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeResStolerance(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeResStolerance(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeResVtolerance(void *farg1, N_Vector farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + result = (int)ARKodeResVtolerance(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeResFtolerance(void *farg1, ARKRwtFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKRwtFn arg2 = (ARKRwtFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKRwtFn)(farg2); + result = (int)ARKodeResFtolerance(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeRootInit(void *farg1, int const *farg2, ARKRootFn farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + ARKRootFn arg3 = (ARKRootFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + arg3 = (ARKRootFn)(farg3); + result = (int)ARKodeRootInit(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRootDirection(void *farg1, int *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int *arg2 = (int *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int *)(farg2); + result = (int)ARKodeSetRootDirection(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNoInactiveRootWarn(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeSetNoInactiveRootWarn(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetDefaults(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeSetDefaults(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetOrder(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetOrder(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetInterpolantType(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetInterpolantType(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetInterpolantDegree(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetInterpolantDegree(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxNumSteps(void *farg1, long const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long)(*farg2); + result = (int)ARKodeSetMaxNumSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetInterpolateStopTime(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetInterpolateStopTime(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetStopTime(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetStopTime(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeClearStopTime(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeClearStopTime(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetFixedStep(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetFixedStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetUserData(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + void *arg2 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (void *)(farg2); + result = (int)ARKodeSetUserData(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetPostprocessStepFn(void *farg1, ARKPostProcessFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKPostProcessFn arg2 = (ARKPostProcessFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKPostProcessFn)(farg2); + result = (int)ARKodeSetPostprocessStepFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetPostprocessStageFn(void *farg1, ARKPostProcessFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKPostProcessFn arg2 = (ARKPostProcessFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKPostProcessFn)(farg2); + result = (int)ARKodeSetPostprocessStageFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNonlinearSolver(void *farg1, SUNNonlinearSolver farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNNonlinearSolver arg2 = (SUNNonlinearSolver) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNNonlinearSolver)(farg2); + result = (int)ARKodeSetNonlinearSolver(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetLinear(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetLinear(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNonlinear(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeSetNonlinear(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNlsRhsFn(void *farg1, ARKRhsFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKRhsFn arg2 = (ARKRhsFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKRhsFn)(farg2); + result = (int)ARKodeSetNlsRhsFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetDeduceImplicitRhs(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetDeduceImplicitRhs(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNonlinCRDown(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetNonlinCRDown(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNonlinRDiv(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetNonlinRDiv(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetDeltaGammaMax(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetDeltaGammaMax(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetLSetupFrequency(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetLSetupFrequency(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetPredictorMethod(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetPredictorMethod(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxNonlinIters(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetMaxNonlinIters(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxConvFails(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetMaxConvFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetNonlinConvCoef(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetNonlinConvCoef(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetStagePredictFn(void *farg1, ARKStagePredictFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKStagePredictFn arg2 = (ARKStagePredictFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKStagePredictFn)(farg2); + result = (int)ARKodeSetStagePredictFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetAdaptController(void *farg1, SUNAdaptController farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNAdaptController)(farg2); + result = (int)ARKodeSetAdaptController(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetAdaptivityAdjustment(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetAdaptivityAdjustment(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetCFLFraction(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetCFLFraction(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetErrorBias(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetErrorBias(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetSafetyFactor(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetSafetyFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxGrowth(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMaxGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMinReduction(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMinReduction(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetFixedStepBounds(void *farg1, double const *farg2, double const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)ARKodeSetFixedStepBounds(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxFirstGrowth(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMaxFirstGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxEFailGrowth(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMaxEFailGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetSmallNumEFails(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetSmallNumEFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxCFailGrowth(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMaxCFailGrowth(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetStabilityFn(void *farg1, ARKExpStabFn farg2, void *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKExpStabFn arg2 = (ARKExpStabFn) 0 ; + void *arg3 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKExpStabFn)(farg2); + arg3 = (void *)(farg3); + result = (int)ARKodeSetStabilityFn(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxErrTestFails(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetMaxErrTestFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetConstraints(void *farg1, N_Vector farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + result = (int)ARKodeSetConstraints(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxHnilWarns(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetMaxHnilWarns(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetInitStep(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetInitStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMinStep(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMinStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxStep(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMaxStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMaxNumConstrFails(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetMaxNumConstrFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetAccumulatedErrorType(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetAccumulatedErrorType(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeResetAccumulatedError(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)ARKodeResetAccumulatedError(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeEvolve(void *farg1, double const *farg2, N_Vector farg3, double *farg4, int const *farg5) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg5 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (N_Vector)(farg3); + arg4 = (sunrealtype *)(farg4); + arg5 = (int)(*farg5); + result = (int)ARKodeEvolve(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetDky(void *farg1, double const *farg2, int const *farg3, N_Vector farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int arg3 ; + N_Vector arg4 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (int)(*farg3); + arg4 = (N_Vector)(farg4); + result = (int)ARKodeGetDky(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeComputeState(void *farg1, N_Vector farg2, N_Vector farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + N_Vector arg3 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + arg3 = (N_Vector)(farg3); + result = (int)ARKodeComputeState(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumStepAttempts(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumStepAttempts(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetWorkSpace(void *farg1, long *farg2, long *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)ARKodeGetWorkSpace(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumSteps(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetLastStep(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetLastStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetCurrentStep(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetCurrentStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetErrWeights(void *farg1, N_Vector farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + result = (int)ARKodeGetErrWeights(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumGEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumGEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetRootInfo(void *farg1, int *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int *arg2 = (int *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int *)(farg2); + result = (int)ARKodeGetRootInfo(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetUserData(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + void **arg2 = (void **) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (void **)(farg2); + result = (int)ARKodeGetUserData(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodePrintAllStats(void *farg1, void *farg2, int const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + FILE *arg2 = (FILE *) 0 ; + SUNOutputFormat arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (FILE *)(farg2); + arg3 = (SUNOutputFormat)(*farg3); + result = (int)ARKodePrintAllStats(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT SwigArrayWrapper _wrap_FARKodeGetReturnFlagName(long const *farg1) { + SwigArrayWrapper fresult ; + long arg1 ; + char *result = 0 ; + + arg1 = (long)(*farg1); + result = (char *)ARKodeGetReturnFlagName(arg1); + fresult.size = strlen((const char*)(result)); + fresult.data = (char *)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeWriteParameters(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + FILE *arg2 = (FILE *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (FILE *)(farg2); + result = (int)ARKodeWriteParameters(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumExpSteps(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumExpSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumAccSteps(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumAccSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumErrTestFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumErrTestFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetEstLocalErrors(void *farg1, N_Vector farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + result = (int)ARKodeGetEstLocalErrors(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetActualInitStep(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetActualInitStep(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetTolScaleFactor(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetTolScaleFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumConstrFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumConstrFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetStepStats(void *farg1, long *farg2, double *farg3, double *farg4, double *farg5, double *farg6) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + sunrealtype *arg5 = (sunrealtype *) 0 ; + sunrealtype *arg6 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (sunrealtype *)(farg3); + arg4 = (sunrealtype *)(farg4); + arg5 = (sunrealtype *)(farg5); + arg6 = (sunrealtype *)(farg6); + result = (int)ARKodeGetStepStats(arg1,arg2,arg3,arg4,arg5,arg6); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetAccumulatedError(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetAccumulatedError(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumLinSolvSetups(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumLinSolvSetups(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetCurrentTime(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetCurrentTime(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetCurrentState(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector *arg2 = (N_Vector *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector *)(farg2); + result = (int)ARKodeGetCurrentState(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetCurrentGamma(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetCurrentGamma(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNonlinearSystemData(void *farg1, double *farg2, void *farg3, void *farg4, void *farg5, double *farg6, void *farg7, void *farg8) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + N_Vector *arg3 = (N_Vector *) 0 ; + N_Vector *arg4 = (N_Vector *) 0 ; + N_Vector *arg5 = (N_Vector *) 0 ; + sunrealtype *arg6 = (sunrealtype *) 0 ; + N_Vector *arg7 = (N_Vector *) 0 ; + void **arg8 = (void **) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + arg3 = (N_Vector *)(farg3); + arg4 = (N_Vector *)(farg4); + arg5 = (N_Vector *)(farg5); + arg6 = (sunrealtype *)(farg6); + arg7 = (N_Vector *)(farg7); + arg8 = (void **)(farg8); + result = (int)ARKodeGetNonlinearSystemData(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumNonlinSolvIters(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumNonlinSolvIters(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumNonlinSolvConvFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumNonlinSolvConvFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNonlinSolvStats(void *farg1, long *farg2, long *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)ARKodeGetNonlinSolvStats(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumStepSolveFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumStepSolveFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetJac(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNMatrix *arg2 = (SUNMatrix *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNMatrix *)(farg2); + result = (int)ARKodeGetJac(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetJacTime(void *farg1, double *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype *)(farg2); + result = (int)ARKodeGetJacTime(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetJacNumSteps(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetJacNumSteps(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetLinWorkSpace(void *farg1, long *farg2, long *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)ARKodeGetLinWorkSpace(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumJacEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumJacEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumPrecEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumPrecEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumPrecSolves(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumPrecSolves(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumLinIters(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumLinIters(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumLinConvFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumLinConvFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumJTSetupEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumJTSetupEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumJtimesEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumJtimesEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumLinRhsEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumLinRhsEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetLastLinFlag(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetLastLinFlag(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT SwigArrayWrapper _wrap_FARKodeGetLinReturnFlagName(long const *farg1) { + SwigArrayWrapper fresult ; + long arg1 ; + char *result = 0 ; + + arg1 = (long)(*farg1); + result = (char *)ARKodeGetLinReturnFlagName(arg1); + fresult.size = strlen((const char*)(result)); + fresult.data = (char *)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetCurrentMassMatrix(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNMatrix *arg2 = (SUNMatrix *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNMatrix *)(farg2); + result = (int)ARKodeGetCurrentMassMatrix(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetResWeights(void *farg1, N_Vector farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (N_Vector)(farg2); + result = (int)ARKodeGetResWeights(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetMassWorkSpace(void *farg1, long *farg2, long *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)ARKodeGetMassWorkSpace(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassSetups(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassSetups(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassMultSetups(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassMultSetups(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassMult(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassMult(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassSolves(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassSolves(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassPrecEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassPrecEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassPrecSolves(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassPrecSolves(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassIters(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassIters(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMassConvFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMassConvFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumMTSetups(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumMTSetups(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetLastMassFlag(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetLastMassFlag(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_FARKodeFree(void *farg1) { + void **arg1 = (void **) 0 ; + + arg1 = (void **)(farg1); + ARKodeFree(arg1); +} + + +SWIGEXPORT void _wrap_FARKodePrintMem(void *farg1, void *farg2) { + void *arg1 = (void *) 0 ; + FILE *arg2 = (FILE *) 0 ; + + arg1 = (void *)(farg1); + arg2 = (FILE *)(farg2); + ARKodePrintMem(arg1,arg2); +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxFn(void *farg1, ARKRelaxFn farg2, ARKRelaxJacFn farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKRelaxFn arg2 = (ARKRelaxFn) 0 ; + ARKRelaxJacFn arg3 = (ARKRelaxJacFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKRelaxFn)(farg2); + arg3 = (ARKRelaxJacFn)(farg3); + result = (int)ARKodeSetRelaxFn(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxEtaFail(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetRelaxEtaFail(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxLowerBound(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetRelaxLowerBound(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxMaxFails(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetRelaxMaxFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxMaxIters(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetRelaxMaxIters(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxSolver(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKRelaxSolver arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKRelaxSolver)(*farg2); + result = (int)ARKodeSetRelaxSolver(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxResTol(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetRelaxResTol(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxTol(void *farg1, double const *farg2, double const *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + sunrealtype arg3 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)ARKodeSetRelaxTol(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetRelaxUpperBound(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetRelaxUpperBound(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumRelaxFnEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumRelaxFnEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumRelaxJacEvals(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumRelaxJacEvals(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeGetNumRelaxFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumRelaxFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} -SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) { - if (self->cptr == NULL) { - /* LHS is unassigned */ - if (other.cmemflags & SWIG_MEM_RVALUE) { - /* Capture pointer from RHS, clear 'moving' flag */ - self->cptr = other.cptr; - self->cmemflags = other.cmemflags & (~SWIG_MEM_RVALUE); - } else { - /* Become a reference to the other object */ - self->cptr = other.cptr; - self->cmemflags = other.cmemflags & (~SWIG_MEM_OWN); - } - } else if (other.cptr == NULL) { - /* Replace LHS with a null pointer */ - free(self->cptr); - *self = SwigClassWrapper_uninitialized(); - } else { - if (self->cmemflags & SWIG_MEM_OWN) { - free(self->cptr); - } - self->cptr = other.cptr; - if (other.cmemflags & SWIG_MEM_RVALUE) { - /* Capture RHS */ - self->cmemflags = other.cmemflags & ~SWIG_MEM_RVALUE; - } else { - /* Point to RHS */ - self->cmemflags = other.cmemflags & ~SWIG_MEM_OWN; - } - } +SWIGEXPORT int _wrap_FARKodeGetNumRelaxBoundFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumRelaxBoundFails(arg1,arg2); + fresult = (int)(result); + return fresult; } -typedef struct { - void* data; - size_t size; -} SwigArrayWrapper; +SWIGEXPORT int _wrap_FARKodeGetNumRelaxSolveFails(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumRelaxSolveFails(arg1,arg2); + fresult = (int)(result); + return fresult; +} -SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { - SwigArrayWrapper result; - result.data = NULL; - result.size = 0; - return result; +SWIGEXPORT int _wrap_FARKodeGetNumRelaxSolveIters(void *farg1, long *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + result = (int)ARKodeGetNumRelaxSolveIters(arg1,arg2); + fresult = (int)(result); + return fresult; } + SWIGEXPORT int _wrap_FARKBandPrecInit(void *farg1, int64_t const *farg2, int64_t const *farg3, int64_t const *farg4) { int fresult ; void *arg1 = (void *) 0 ; @@ -1055,4 +3003,244 @@ SWIGEXPORT int _wrap_FARKodeSPRKTable_ToButcher(void *farg1, void *farg2, void * } +SWIGEXPORT int _wrap_FARKodeSetLinearSolver(void *farg1, SUNLinearSolver farg2, SUNMatrix farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNLinearSolver arg2 = (SUNLinearSolver) 0 ; + SUNMatrix arg3 = (SUNMatrix) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNLinearSolver)(farg2); + arg3 = (SUNMatrix)(farg3); + result = (int)ARKodeSetLinearSolver(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMassLinearSolver(void *farg1, SUNLinearSolver farg2, SUNMatrix farg3, int const *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + SUNLinearSolver arg2 = (SUNLinearSolver) 0 ; + SUNMatrix arg3 = (SUNMatrix) 0 ; + int arg4 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (SUNLinearSolver)(farg2); + arg3 = (SUNMatrix)(farg3); + arg4 = (int)(*farg4); + result = (int)ARKodeSetMassLinearSolver(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetJacFn(void *farg1, ARKLsJacFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsJacFn arg2 = (ARKLsJacFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsJacFn)(farg2); + result = (int)ARKodeSetJacFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMassFn(void *farg1, ARKLsMassFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsMassFn arg2 = (ARKLsMassFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsMassFn)(farg2); + result = (int)ARKodeSetMassFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetJacEvalFrequency(void *farg1, long const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + long arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long)(*farg2); + result = (int)ARKodeSetJacEvalFrequency(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetLinearSolutionScaling(void *farg1, int const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + int arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (int)(*farg2); + result = (int)ARKodeSetLinearSolutionScaling(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetEpsLin(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetEpsLin(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMassEpsLin(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMassEpsLin(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetLSNormFactor(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetLSNormFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMassLSNormFactor(void *farg1, double const *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + result = (int)ARKodeSetMassLSNormFactor(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetPreconditioner(void *farg1, ARKLsPrecSetupFn farg2, ARKLsPrecSolveFn farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsPrecSetupFn arg2 = (ARKLsPrecSetupFn) 0 ; + ARKLsPrecSolveFn arg3 = (ARKLsPrecSolveFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsPrecSetupFn)(farg2); + arg3 = (ARKLsPrecSolveFn)(farg3); + result = (int)ARKodeSetPreconditioner(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMassPreconditioner(void *farg1, ARKLsMassPrecSetupFn farg2, ARKLsMassPrecSolveFn farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsMassPrecSetupFn arg2 = (ARKLsMassPrecSetupFn) 0 ; + ARKLsMassPrecSolveFn arg3 = (ARKLsMassPrecSolveFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsMassPrecSetupFn)(farg2); + arg3 = (ARKLsMassPrecSolveFn)(farg3); + result = (int)ARKodeSetMassPreconditioner(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetJacTimes(void *farg1, ARKLsJacTimesSetupFn farg2, ARKLsJacTimesVecFn farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsJacTimesSetupFn arg2 = (ARKLsJacTimesSetupFn) 0 ; + ARKLsJacTimesVecFn arg3 = (ARKLsJacTimesVecFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsJacTimesSetupFn)(farg2); + arg3 = (ARKLsJacTimesVecFn)(farg3); + result = (int)ARKodeSetJacTimes(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetJacTimesRhsFn(void *farg1, ARKRhsFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKRhsFn arg2 = (ARKRhsFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKRhsFn)(farg2); + result = (int)ARKodeSetJacTimesRhsFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetMassTimes(void *farg1, ARKLsMassTimesSetupFn farg2, ARKLsMassTimesVecFn farg3, void *farg4) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsMassTimesSetupFn arg2 = (ARKLsMassTimesSetupFn) 0 ; + ARKLsMassTimesVecFn arg3 = (ARKLsMassTimesVecFn) 0 ; + void *arg4 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsMassTimesSetupFn)(farg2); + arg3 = (ARKLsMassTimesVecFn)(farg3); + arg4 = (void *)(farg4); + result = (int)ARKodeSetMassTimes(arg1,arg2,arg3,arg4); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FARKodeSetLinSysFn(void *farg1, ARKLsLinSysFn farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKLsLinSysFn arg2 = (ARKLsLinSysFn) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKLsLinSysFn)(farg2); + result = (int)ARKodeSetLinSysFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + diff --git a/src/arkode/fmod/farkode_mod.f90 b/src/arkode/fmod/farkode_mod.f90 index 7724193873..ab66905937 100644 --- a/src/arkode/fmod/farkode_mod.f90 +++ b/src/arkode/fmod/farkode_mod.f90 @@ -92,6 +92,7 @@ module farkode_mod integer(C_INT), parameter, public :: ARK_RELAX_FUNC_FAIL = -45_C_INT integer(C_INT), parameter, public :: ARK_RELAX_JAC_FAIL = -46_C_INT integer(C_INT), parameter, public :: ARK_CONTROLLER_ERR = -47_C_INT + integer(C_INT), parameter, public :: ARK_STEPPER_UNSUPPORTED = -48_C_INT integer(C_INT), parameter, public :: ARK_UNRECOGNIZED_ERROR = -99_C_INT ! typedef enum ARKRelaxSolver enum, bind(c) @@ -100,6 +101,146 @@ module farkode_mod end enum integer, parameter, public :: ARKRelaxSolver = kind(ARK_RELAX_BRENT) public :: ARK_RELAX_BRENT, ARK_RELAX_NEWTON + public :: FARKodeResize + public :: FARKodeReset + public :: FARKodeSStolerances + public :: FARKodeSVtolerances + public :: FARKodeWFtolerances + public :: FARKodeResStolerance + public :: FARKodeResVtolerance + public :: FARKodeResFtolerance + public :: FARKodeRootInit + public :: FARKodeSetRootDirection + public :: FARKodeSetNoInactiveRootWarn + public :: FARKodeSetDefaults + public :: FARKodeSetOrder + public :: FARKodeSetInterpolantType + public :: FARKodeSetInterpolantDegree + public :: FARKodeSetMaxNumSteps + public :: FARKodeSetInterpolateStopTime + public :: FARKodeSetStopTime + public :: FARKodeClearStopTime + public :: FARKodeSetFixedStep + public :: FARKodeSetUserData + public :: FARKodeSetPostprocessStepFn + public :: FARKodeSetPostprocessStageFn + public :: FARKodeSetNonlinearSolver + public :: FARKodeSetLinear + public :: FARKodeSetNonlinear + public :: FARKodeSetNlsRhsFn + public :: FARKodeSetDeduceImplicitRhs + public :: FARKodeSetNonlinCRDown + public :: FARKodeSetNonlinRDiv + public :: FARKodeSetDeltaGammaMax + public :: FARKodeSetLSetupFrequency + public :: FARKodeSetPredictorMethod + public :: FARKodeSetMaxNonlinIters + public :: FARKodeSetMaxConvFails + public :: FARKodeSetNonlinConvCoef + public :: FARKodeSetStagePredictFn + public :: FARKodeSetAdaptController + public :: FARKodeSetAdaptivityAdjustment + public :: FARKodeSetCFLFraction + public :: FARKodeSetErrorBias + public :: FARKodeSetSafetyFactor + public :: FARKodeSetMaxGrowth + public :: FARKodeSetMinReduction + public :: FARKodeSetFixedStepBounds + public :: FARKodeSetMaxFirstGrowth + public :: FARKodeSetMaxEFailGrowth + public :: FARKodeSetSmallNumEFails + public :: FARKodeSetMaxCFailGrowth + public :: FARKodeSetStabilityFn + public :: FARKodeSetMaxErrTestFails + public :: FARKodeSetConstraints + public :: FARKodeSetMaxHnilWarns + public :: FARKodeSetInitStep + public :: FARKodeSetMinStep + public :: FARKodeSetMaxStep + public :: FARKodeSetMaxNumConstrFails + public :: FARKodeSetAccumulatedErrorType + public :: FARKodeResetAccumulatedError + public :: FARKodeEvolve + public :: FARKodeGetDky + public :: FARKodeComputeState + public :: FARKodeGetNumStepAttempts + public :: FARKodeGetWorkSpace + public :: FARKodeGetNumSteps + public :: FARKodeGetLastStep + public :: FARKodeGetCurrentStep + public :: FARKodeGetErrWeights + public :: FARKodeGetNumGEvals + public :: FARKodeGetRootInfo + public :: FARKodeGetUserData + public :: FARKodePrintAllStats + type, bind(C) :: SwigArrayWrapper + type(C_PTR), public :: data = C_NULL_PTR + integer(C_SIZE_T), public :: size = 0 + end type + public :: FARKodeGetReturnFlagName + public :: FARKodeWriteParameters + public :: FARKodeGetNumExpSteps + public :: FARKodeGetNumAccSteps + public :: FARKodeGetNumErrTestFails + public :: FARKodeGetEstLocalErrors + public :: FARKodeGetActualInitStep + public :: FARKodeGetTolScaleFactor + public :: FARKodeGetNumConstrFails + public :: FARKodeGetStepStats + public :: FARKodeGetAccumulatedError + public :: FARKodeGetNumLinSolvSetups + public :: FARKodeGetCurrentTime + public :: FARKodeGetCurrentState + public :: FARKodeGetCurrentGamma + public :: FARKodeGetNonlinearSystemData + public :: FARKodeGetNumNonlinSolvIters + public :: FARKodeGetNumNonlinSolvConvFails + public :: FARKodeGetNonlinSolvStats + public :: FARKodeGetNumStepSolveFails + public :: FARKodeGetJac + public :: FARKodeGetJacTime + public :: FARKodeGetJacNumSteps + public :: FARKodeGetLinWorkSpace + public :: FARKodeGetNumJacEvals + public :: FARKodeGetNumPrecEvals + public :: FARKodeGetNumPrecSolves + public :: FARKodeGetNumLinIters + public :: FARKodeGetNumLinConvFails + public :: FARKodeGetNumJTSetupEvals + public :: FARKodeGetNumJtimesEvals + public :: FARKodeGetNumLinRhsEvals + public :: FARKodeGetLastLinFlag + public :: FARKodeGetLinReturnFlagName + public :: FARKodeGetCurrentMassMatrix + public :: FARKodeGetResWeights + public :: FARKodeGetMassWorkSpace + public :: FARKodeGetNumMassSetups + public :: FARKodeGetNumMassMultSetups + public :: FARKodeGetNumMassMult + public :: FARKodeGetNumMassSolves + public :: FARKodeGetNumMassPrecEvals + public :: FARKodeGetNumMassPrecSolves + public :: FARKodeGetNumMassIters + public :: FARKodeGetNumMassConvFails + public :: FARKodeGetNumMTSetups + public :: FARKodeGetLastMassFlag + public :: FARKodeFree + public :: FARKodePrintMem + public :: FARKodeSetRelaxFn + public :: FARKodeSetRelaxEtaFail + public :: FARKodeSetRelaxLowerBound + public :: FARKodeSetRelaxMaxFails + public :: FARKodeSetRelaxMaxIters + public :: FARKodeSetRelaxSolver + public :: FARKodeSetRelaxResTol + public :: FARKodeSetRelaxTol + public :: FARKodeSetRelaxUpperBound + public :: FARKodeGetNumRelaxFnEvals + public :: FARKodeGetNumRelaxJacEvals + public :: FARKodeGetNumRelaxFails + public :: FARKodeGetNumRelaxBoundFails + public :: FARKodeGetNumRelaxSolveFails + public :: FARKodeGetNumRelaxSolveIters public :: FARKBandPrecInit public :: FARKBandPrecGetWorkSpace public :: FARKBandPrecGetNumRhsEvals @@ -188,10 +329,6 @@ module farkode_mod ARKODE_ESDIRK437L2SA_7_3_4, ARKODE_ESDIRK547L2SA_7_4_5, ARKODE_ESDIRK547L2SA2_7_4_5, ARKODE_ARK2_DIRK_3_1_2, & ARKODE_MAX_DIRK_NUM public :: FARKodeButcherTable_LoadDIRK - type, bind(C) :: SwigArrayWrapper - type(C_PTR), public :: data = C_NULL_PTR - integer(C_SIZE_T), public :: size = 0 - end type public :: FARKodeButcherTable_LoadDIRKByName ! typedef enum ARKODE_ERKTableID enum, bind(c) @@ -294,78 +431,88 @@ module farkode_mod integer(C_INT), parameter, public :: ARKLS_MASSFUNC_RECVR = -10_C_INT integer(C_INT), parameter, public :: ARKLS_SUNMAT_FAIL = -11_C_INT integer(C_INT), parameter, public :: ARKLS_SUNLS_FAIL = -12_C_INT + public :: FARKodeSetLinearSolver + public :: FARKodeSetMassLinearSolver + public :: FARKodeSetJacFn + public :: FARKodeSetMassFn + public :: FARKodeSetJacEvalFrequency + public :: FARKodeSetLinearSolutionScaling + public :: FARKodeSetEpsLin + public :: FARKodeSetMassEpsLin + public :: FARKodeSetLSNormFactor + public :: FARKodeSetMassLSNormFactor + public :: FARKodeSetPreconditioner + public :: FARKodeSetMassPreconditioner + public :: FARKodeSetJacTimes + public :: FARKodeSetJacTimesRhsFn + public :: FARKodeSetMassTimes + public :: FARKodeSetLinSysFn ! WRAPPER DECLARATIONS interface -function swigc_FARKBandPrecInit(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FARKBandPrecInit") & +function swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FARKodeResize") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT64_T), intent(in) :: farg2 -integer(C_INT64_T), intent(in) :: farg3 -integer(C_INT64_T), intent(in) :: farg4 +type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +type(C_FUNPTR), value :: farg5 +type(C_PTR), value :: farg6 integer(C_INT) :: fresult end function -function swigc_FARKBandPrecGetWorkSpace(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKBandPrecGetWorkSpace") & +function swigc_FARKodeReset(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeReset") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FARKBandPrecGetNumRhsEvals(farg1, farg2) & -bind(C, name="_wrap_FARKBandPrecGetNumRhsEvals") & +function swigc_FARKodeSStolerances(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSStolerances") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 integer(C_INT) :: fresult end function -function swigc_FARKBBDPrecInit(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8, farg9) & -bind(C, name="_wrap_FARKBBDPrecInit") & +function swigc_FARKodeSVtolerances(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSVtolerances") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT64_T), intent(in) :: farg2 -integer(C_INT64_T), intent(in) :: farg3 -integer(C_INT64_T), intent(in) :: farg4 -integer(C_INT64_T), intent(in) :: farg5 -integer(C_INT64_T), intent(in) :: farg6 -real(C_DOUBLE), intent(in) :: farg7 -type(C_FUNPTR), value :: farg8 -type(C_FUNPTR), value :: farg9 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FARKBBDPrecReInit(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FARKBBDPrecReInit") & +function swigc_FARKodeWFtolerances(farg1, farg2) & +bind(C, name="_wrap_FARKodeWFtolerances") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT64_T), intent(in) :: farg2 -integer(C_INT64_T), intent(in) :: farg3 -real(C_DOUBLE), intent(in) :: farg4 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FARKBBDPrecGetWorkSpace(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKBBDPrecGetWorkSpace") & +function swigc_FARKodeResStolerance(farg1, farg2) & +bind(C, name="_wrap_FARKodeResStolerance") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FARKBBDPrecGetNumGfnEvals(farg1, farg2) & -bind(C, name="_wrap_FARKBBDPrecGetNumGfnEvals") & +function swigc_FARKodeResVtolerance(farg1, farg2) & +bind(C, name="_wrap_FARKodeResVtolerance") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -373,436 +520,4105 @@ function swigc_FARKBBDPrecGetNumGfnEvals(farg1, farg2) & integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_q_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_q_set") +function swigc_FARKodeResFtolerance(farg1, farg2) & +bind(C, name="_wrap_FARKodeResFtolerance") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeRootInit(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeRootInit") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 -end subroutine +type(C_FUNPTR), value :: farg3 +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_q_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_q_get") & +function swigc_FARKodeSetRootDirection(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRootDirection") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_p_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_p_set") +function swigc_FARKodeSetNoInactiveRootWarn(farg1) & +bind(C, name="_wrap_FARKodeSetNoInactiveRootWarn") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -integer(C_INT), intent(in) :: farg2 -end subroutine +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_p_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_p_get") & +function swigc_FARKodeSetDefaults(farg1) & +bind(C, name="_wrap_FARKodeSetDefaults") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_stages_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_stages_set") +function swigc_FARKodeSetOrder(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetOrder") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 -end subroutine +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_stages_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_stages_get") & +function swigc_FARKodeSetInterpolantType(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetInterpolantType") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_A_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_A_set") +function swigc_FARKodeSetInterpolantDegree(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetInterpolantDegree") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR), value :: farg2 -end subroutine +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_A_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_A_get") & +function swigc_FARKodeSetMaxNumSteps(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxNumSteps") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +integer(C_LONG), intent(in) :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_c_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_c_set") +function swigc_FARKodeSetInterpolateStopTime(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetInterpolateStopTime") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR), value :: farg2 -end subroutine +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_c_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_c_get") & +function swigc_FARKodeSetStopTime(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetStopTime") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_b_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_b_set") +function swigc_FARKodeClearStopTime(farg1) & +bind(C, name="_wrap_FARKodeClearStopTime") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR), value :: farg2 -end subroutine +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_b_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_b_get") & +function swigc_FARKodeSetFixedStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetFixedStep") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_ARKodeButcherTableMem_d_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_d_set") +function swigc_FARKodeSetUserData(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetUserData") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 type(C_PTR), value :: farg2 -end subroutine +integer(C_INT) :: fresult +end function -function swigc_ARKodeButcherTableMem_d_get(farg1) & -bind(C, name="_wrap_ARKodeButcherTableMem_d_get") & +function swigc_FARKodeSetPostprocessStepFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetPostprocessStepFn") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult end function -function swigc_new_ARKodeButcherTableMem() & -bind(C, name="_wrap_new_ARKodeButcherTableMem") & +function swigc_FARKodeSetPostprocessStageFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetPostprocessStageFn") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: fresult +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_delete_ARKodeButcherTableMem(farg1) & -bind(C, name="_wrap_delete_ARKodeButcherTableMem") -use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper), intent(inout) :: farg1 -end subroutine - -subroutine swigc_ARKodeButcherTableMem_op_assign__(farg1, farg2) & -bind(C, name="_wrap_ARKodeButcherTableMem_op_assign__") +function swigc_FARKodeSetNonlinearSolver(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetNonlinearSolver") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper), intent(inout) :: farg1 -type(SwigClassWrapper) :: farg2 -end subroutine +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function -function swigc_FARKodeButcherTable_Alloc(farg1, farg2) & -bind(C, name="_wrap_FARKodeButcherTable_Alloc") & +function swigc_FARKodeSetLinear(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetLinear") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 +type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 -type(C_PTR) :: fresult +integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_Create(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & -bind(C, name="_wrap_FARKodeButcherTable_Create") & +function swigc_FARKodeSetNonlinear(farg1) & +bind(C, name="_wrap_FARKodeSetNonlinear") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 -integer(C_INT), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(C_PTR), value :: farg4 -type(C_PTR), value :: farg5 -type(C_PTR), value :: farg6 -type(C_PTR), value :: farg7 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_Copy(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_Copy") & +function swigc_FARKodeSetNlsRhsFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetNlsRhsFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR) :: fresult +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_FARKodeButcherTable_Space(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKodeButcherTable_Space") +function swigc_FARKodeSetDeduceImplicitRhs(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetDeduceImplicitRhs") & +result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -end subroutine +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -subroutine swigc_FARKodeButcherTable_Free(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_Free") +function swigc_FARKodeSetNonlinCRDown(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetNonlinCRDown") & +result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -end subroutine +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -subroutine swigc_FARKodeButcherTable_Write(farg1, farg2) & -bind(C, name="_wrap_FARKodeButcherTable_Write") +function swigc_FARKodeSetNonlinRDiv(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetNonlinRDiv") & +result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -end subroutine +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -function swigc_FARKodeButcherTable_IsStifflyAccurate(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_IsStifflyAccurate") & +function swigc_FARKodeSetDeltaGammaMax(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetDeltaGammaMax") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_CheckOrder(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FARKodeButcherTable_CheckOrder") & +function swigc_FARKodeSetLSetupFrequency(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetLSetupFrequency") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -type(C_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_CheckARKOrder(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FARKodeButcherTable_CheckARKOrder") & +function swigc_FARKodeSetPredictorMethod(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetPredictorMethod") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -type(C_PTR), value :: farg4 -type(C_PTR), value :: farg5 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_LoadDIRK(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_LoadDIRK") & +function swigc_FARKodeSetMaxNonlinIters(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxNonlinIters") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_LoadDIRKByName(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_LoadDIRKByName") & +function swigc_FARKodeSetMaxConvFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxConvFails") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -type(SwigArrayWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_LoadERK(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_LoadERK") & +function swigc_FARKodeSetNonlinConvCoef(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetNonlinConvCoef") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult end function -function swigc_FARKodeButcherTable_LoadERKByName(farg1) & -bind(C, name="_wrap_FARKodeButcherTable_LoadERKByName") & +function swigc_FARKodeSetStagePredictFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetStagePredictFn") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -type(SwigArrayWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_ARKodeSPRKTableMem_q_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeSPRKTableMem_q_set") +function swigc_FARKodeSetAdaptController(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetAdaptController") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetAdaptivityAdjustment(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetAdaptivityAdjustment") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 -end subroutine +integer(C_INT) :: fresult +end function -function swigc_ARKodeSPRKTableMem_q_get(farg1) & -bind(C, name="_wrap_ARKodeSPRKTableMem_q_get") & +function swigc_FARKodeSetCFLFraction(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetCFLFraction") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -subroutine swigc_ARKodeSPRKTableMem_stages_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeSPRKTableMem_stages_set") +function swigc_FARKodeSetErrorBias(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetErrorBias") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetSafetyFactor(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetSafetyFactor") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMaxGrowth(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxGrowth") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMinReduction(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMinReduction") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetFixedStepBounds(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetFixedStepBounds") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMaxFirstGrowth(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxFirstGrowth") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMaxEFailGrowth(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxEFailGrowth") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetSmallNumEFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetSmallNumEFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 -end subroutine +integer(C_INT) :: fresult +end function -function swigc_ARKodeSPRKTableMem_stages_get(farg1) & -bind(C, name="_wrap_ARKodeSPRKTableMem_stages_get") & +function swigc_FARKodeSetMaxCFailGrowth(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxCFailGrowth") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -subroutine swigc_ARKodeSPRKTableMem_a_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeSPRKTableMem_a_set") +function swigc_FARKodeSetStabilityFn(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetStabilityFn") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR), value :: farg2 -end subroutine +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function -function swigc_ARKodeSPRKTableMem_a_get(farg1) & -bind(C, name="_wrap_ARKodeSPRKTableMem_a_get") & +function swigc_FARKodeSetMaxErrTestFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxErrTestFails") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_ARKodeSPRKTableMem_ahat_set(farg1, farg2) & -bind(C, name="_wrap_ARKodeSPRKTableMem_ahat_set") +function swigc_FARKodeSetConstraints(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetConstraints") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg1 type(C_PTR), value :: farg2 -end subroutine +integer(C_INT) :: fresult +end function -function swigc_ARKodeSPRKTableMem_ahat_get(farg1) & -bind(C, name="_wrap_ARKodeSPRKTableMem_ahat_get") & +function swigc_FARKodeSetMaxHnilWarns(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxHnilWarns") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult end function -function swigc_new_ARKodeSPRKTableMem() & -bind(C, name="_wrap_new_ARKodeSPRKTableMem") & +function swigc_FARKodeSetInitStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetInitStep") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper) :: fresult +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult end function -subroutine swigc_delete_ARKodeSPRKTableMem(farg1) & -bind(C, name="_wrap_delete_ARKodeSPRKTableMem") +function swigc_FARKodeSetMinStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMinStep") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper), intent(inout) :: farg1 -end subroutine +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -subroutine swigc_ARKodeSPRKTableMem_op_assign__(farg1, farg2) & -bind(C, name="_wrap_ARKodeSPRKTableMem_op_assign__") +function swigc_FARKodeSetMaxStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxStep") & +result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigclasswrapper -type(SwigClassWrapper), intent(inout) :: farg1 -type(SwigClassWrapper) :: farg2 -end subroutine +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function -function swigc_FARKodeSPRKTable_Create(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FARKodeSPRKTable_Create") & +function swigc_FARKodeSetMaxNumConstrFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMaxNumConstrFails") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetAccumulatedErrorType(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetAccumulatedErrorType") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeResetAccumulatedError(farg1) & +bind(C, name="_wrap_FARKodeResetAccumulatedError") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeEvolve(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FARKodeEvolve") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 type(C_PTR), value :: farg3 type(C_PTR), value :: farg4 -type(C_PTR) :: fresult +integer(C_INT), intent(in) :: farg5 +integer(C_INT) :: fresult end function -function swigc_FARKodeSPRKTable_Alloc(farg1) & -bind(C, name="_wrap_FARKodeSPRKTable_Alloc") & +function swigc_FARKodeGetDky(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKodeGetDky") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(C_PTR), value :: farg4 +integer(C_INT) :: fresult end function -function swigc_FARKodeSPRKTable_Load(farg1) & -bind(C, name="_wrap_FARKodeSPRKTable_Load") & +function swigc_FARKodeComputeState(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeComputeState") & result(fresult) use, intrinsic :: ISO_C_BINDING -integer(C_INT), intent(in) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult end function -function swigc_FARKodeSPRKTable_LoadByName(farg1) & -bind(C, name="_wrap_FARKodeSPRKTable_LoadByName") & +function swigc_FARKodeGetNumStepAttempts(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumStepAttempts") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper -type(SwigArrayWrapper) :: farg1 -type(C_PTR) :: fresult +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetWorkSpace(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeGetWorkSpace") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumSteps(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumSteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLastStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastStep") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetCurrentStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetCurrentStep") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetErrWeights(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetErrWeights") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumGEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumGEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetRootInfo(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetRootInfo") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetUserData(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetUserData") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodePrintAllStats(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodePrintAllStats") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + + subroutine SWIG_free(cptr) & + bind(C, name="free") + use, intrinsic :: ISO_C_BINDING + type(C_PTR), value :: cptr +end subroutine +function swigc_FARKodeGetReturnFlagName(farg1) & +bind(C, name="_wrap_FARKodeGetReturnFlagName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +integer(C_LONG), intent(in) :: farg1 +type(SwigArrayWrapper) :: fresult +end function + +function swigc_FARKodeWriteParameters(farg1, farg2) & +bind(C, name="_wrap_FARKodeWriteParameters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumExpSteps(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumExpSteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumAccSteps(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumAccSteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumErrTestFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumErrTestFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetEstLocalErrors(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetEstLocalErrors") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetActualInitStep(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetActualInitStep") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetTolScaleFactor(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetTolScaleFactor") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumConstrFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumConstrFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) & +bind(C, name="_wrap_FARKodeGetStepStats") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 +type(C_PTR), value :: farg6 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetAccumulatedError(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetAccumulatedError") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumLinSolvSetups(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumLinSolvSetups") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetCurrentTime(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetCurrentTime") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetCurrentState(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetCurrentState") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetCurrentGamma(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetCurrentGamma") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNonlinearSystemData(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) & +bind(C, name="_wrap_FARKodeGetNonlinearSystemData") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 +type(C_PTR), value :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR), value :: farg8 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumNonlinSolvIters(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumNonlinSolvIters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumNonlinSolvConvFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumNonlinSolvConvFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNonlinSolvStats(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeGetNonlinSolvStats") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumStepSolveFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumStepSolveFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetJac(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetJac") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetJacTime(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetJacTime") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetJacNumSteps(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetJacNumSteps") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLinWorkSpace(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeGetLinWorkSpace") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumJacEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumJacEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumPrecEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumPrecEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumPrecSolves(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumPrecSolves") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumLinIters(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumLinIters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumLinConvFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumLinConvFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumJTSetupEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumJTSetupEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumJtimesEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumJtimesEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumLinRhsEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumLinRhsEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLastLinFlag(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastLinFlag") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLinReturnFlagName(farg1) & +bind(C, name="_wrap_FARKodeGetLinReturnFlagName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +integer(C_LONG), intent(in) :: farg1 +type(SwigArrayWrapper) :: fresult +end function + +function swigc_FARKodeGetCurrentMassMatrix(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetCurrentMassMatrix") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetResWeights(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetResWeights") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetMassWorkSpace(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeGetMassWorkSpace") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassSetups(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassSetups") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassMultSetups(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassMultSetups") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassMult(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassMult") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassSolves(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassSolves") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassPrecEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassPrecEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassPrecSolves(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassPrecSolves") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassIters(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassIters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMassConvFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMassConvFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumMTSetups(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumMTSetups") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetLastMassFlag(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetLastMassFlag") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +subroutine swigc_FARKodeFree(farg1) & +bind(C, name="_wrap_FARKodeFree") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +end subroutine + +subroutine swigc_FARKodePrintMem(farg1, farg2) & +bind(C, name="_wrap_FARKodePrintMem") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_FARKodeSetRelaxFn(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetRelaxFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxEtaFail(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxEtaFail") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxLowerBound(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxLowerBound") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxMaxFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxMaxFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxMaxIters(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxMaxIters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxSolver(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxSolver") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxResTol(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxResTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxTol(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetRelaxTol") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetRelaxUpperBound(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetRelaxUpperBound") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumRelaxFnEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumRelaxFnEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumRelaxJacEvals(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumRelaxJacEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumRelaxFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumRelaxFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumRelaxBoundFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumRelaxBoundFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumRelaxSolveFails(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumRelaxSolveFails") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeGetNumRelaxSolveIters(farg1, farg2) & +bind(C, name="_wrap_FARKodeGetNumRelaxSolveIters") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKBandPrecInit(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKBandPrecInit") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT64_T), intent(in) :: farg2 +integer(C_INT64_T), intent(in) :: farg3 +integer(C_INT64_T), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FARKBandPrecGetWorkSpace(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKBandPrecGetWorkSpace") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKBandPrecGetNumRhsEvals(farg1, farg2) & +bind(C, name="_wrap_FARKBandPrecGetNumRhsEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKBBDPrecInit(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8, farg9) & +bind(C, name="_wrap_FARKBBDPrecInit") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT64_T), intent(in) :: farg2 +integer(C_INT64_T), intent(in) :: farg3 +integer(C_INT64_T), intent(in) :: farg4 +integer(C_INT64_T), intent(in) :: farg5 +integer(C_INT64_T), intent(in) :: farg6 +real(C_DOUBLE), intent(in) :: farg7 +type(C_FUNPTR), value :: farg8 +type(C_FUNPTR), value :: farg9 +integer(C_INT) :: fresult +end function + +function swigc_FARKBBDPrecReInit(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKBBDPrecReInit") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT64_T), intent(in) :: farg2 +integer(C_INT64_T), intent(in) :: farg3 +real(C_DOUBLE), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FARKBBDPrecGetWorkSpace(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKBBDPrecGetWorkSpace") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKBBDPrecGetNumGfnEvals(farg1, farg2) & +bind(C, name="_wrap_FARKBBDPrecGetNumGfnEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_q_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_q_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_q_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_q_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_p_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_p_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_p_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_p_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_stages_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_stages_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_stages_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_stages_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_A_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_A_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_A_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_A_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_c_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_c_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_c_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_c_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_b_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_b_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_b_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_b_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_ARKodeButcherTableMem_d_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_d_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_ARKodeButcherTableMem_d_get(farg1) & +bind(C, name="_wrap_ARKodeButcherTableMem_d_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_new_ARKodeButcherTableMem() & +bind(C, name="_wrap_new_ARKodeButcherTableMem") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: fresult +end function + +subroutine swigc_delete_ARKodeButcherTableMem(farg1) & +bind(C, name="_wrap_delete_ARKodeButcherTableMem") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +end subroutine + +subroutine swigc_ARKodeButcherTableMem_op_assign__(farg1, farg2) & +bind(C, name="_wrap_ARKodeButcherTableMem_op_assign__") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +type(SwigClassWrapper) :: farg2 +end subroutine + +function swigc_FARKodeButcherTable_Alloc(farg1, farg2) & +bind(C, name="_wrap_FARKodeButcherTable_Alloc") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeButcherTable_Create(farg1, farg2, farg3, farg4, farg5, farg6, farg7) & +bind(C, name="_wrap_FARKodeButcherTable_Create") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 +type(C_PTR), value :: farg6 +type(C_PTR), value :: farg7 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeButcherTable_Copy(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_Copy") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_FARKodeButcherTable_Space(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeButcherTable_Space") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +end subroutine + +subroutine swigc_FARKodeButcherTable_Free(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_Free") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +end subroutine + +subroutine swigc_FARKodeButcherTable_Write(farg1, farg2) & +bind(C, name="_wrap_FARKodeButcherTable_Write") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_FARKodeButcherTable_IsStifflyAccurate(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_IsStifflyAccurate") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeButcherTable_CheckOrder(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKodeButcherTable_CheckOrder") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeButcherTable_CheckARKOrder(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FARKodeButcherTable_CheckARKOrder") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeButcherTable_LoadDIRK(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_LoadDIRK") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeButcherTable_LoadDIRKByName(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_LoadDIRKByName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeButcherTable_LoadERK(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_LoadERK") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeButcherTable_LoadERKByName(farg1) & +bind(C, name="_wrap_FARKodeButcherTable_LoadERKByName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_ARKodeSPRKTableMem_q_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeSPRKTableMem_q_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_ARKodeSPRKTableMem_q_get(farg1) & +bind(C, name="_wrap_ARKodeSPRKTableMem_q_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_ARKodeSPRKTableMem_stages_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeSPRKTableMem_stages_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_ARKodeSPRKTableMem_stages_get(farg1) & +bind(C, name="_wrap_ARKodeSPRKTableMem_stages_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_ARKodeSPRKTableMem_a_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeSPRKTableMem_a_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_ARKodeSPRKTableMem_a_get(farg1) & +bind(C, name="_wrap_ARKodeSPRKTableMem_a_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_ARKodeSPRKTableMem_ahat_set(farg1, farg2) & +bind(C, name="_wrap_ARKodeSPRKTableMem_ahat_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_ARKodeSPRKTableMem_ahat_get(farg1) & +bind(C, name="_wrap_ARKodeSPRKTableMem_ahat_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_new_ARKodeSPRKTableMem() & +bind(C, name="_wrap_new_ARKodeSPRKTableMem") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: fresult +end function + +subroutine swigc_delete_ARKodeSPRKTableMem(farg1) & +bind(C, name="_wrap_delete_ARKodeSPRKTableMem") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +end subroutine + +subroutine swigc_ARKodeSPRKTableMem_op_assign__(farg1, farg2) & +bind(C, name="_wrap_ARKodeSPRKTableMem_op_assign__") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper), intent(inout) :: farg1 +type(SwigClassWrapper) :: farg2 +end subroutine + +function swigc_FARKodeSPRKTable_Create(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKodeSPRKTable_Create") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +integer(C_INT), intent(in) :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeSPRKTable_Alloc(farg1) & +bind(C, name="_wrap_FARKodeSPRKTable_Alloc") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeSPRKTable_Load(farg1) & +bind(C, name="_wrap_FARKodeSPRKTable_Load") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +integer(C_INT), intent(in) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeSPRKTable_LoadByName(farg1) & +bind(C, name="_wrap_FARKodeSPRKTable_LoadByName") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper +type(SwigArrayWrapper) :: farg1 +type(C_PTR) :: fresult +end function + +function swigc_FARKodeSPRKTable_Copy(farg1) & +bind(C, name="_wrap_FARKodeSPRKTable_Copy") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR) :: fresult +end function + +subroutine swigc_FARKodeSPRKTable_Write(farg1, farg2) & +bind(C, name="_wrap_FARKodeSPRKTable_Write") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +subroutine swigc_FARKodeSPRKTable_Space(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSPRKTable_Space") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +end subroutine + +subroutine swigc_FARKodeSPRKTable_Free(farg1) & +bind(C, name="_wrap_FARKodeSPRKTable_Free") +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +end subroutine + +function swigc_FARKodeSPRKTable_ToButcher(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSPRKTable_ToButcher") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetLinearSolver(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetLinearSolver") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMassLinearSolver(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKodeSetMassLinearSolver") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT), intent(in) :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetJacFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetJacFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMassFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMassFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetJacEvalFrequency(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetJacEvalFrequency") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_LONG), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetLinearSolutionScaling(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetLinearSolutionScaling") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetEpsLin(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetEpsLin") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMassEpsLin(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMassEpsLin") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetLSNormFactor(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetLSNormFactor") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMassLSNormFactor(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetMassLSNormFactor") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetPreconditioner(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetPreconditioner") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMassPreconditioner(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetMassPreconditioner") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetJacTimes(farg1, farg2, farg3) & +bind(C, name="_wrap_FARKodeSetJacTimes") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetJacTimesRhsFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetJacTimesRhsFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetMassTimes(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FARKodeSetMassTimes") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 +type(C_PTR), value :: farg4 +integer(C_INT) :: fresult +end function + +function swigc_FARKodeSetLinSysFn(farg1, farg2) & +bind(C, name="_wrap_FARKodeSetLinSysFn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 +integer(C_INT) :: fresult +end function + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FARKodeResize(arkode_mem, ynew, hscale, t0, resize, resize_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: ynew +real(C_DOUBLE), intent(in) :: hscale +real(C_DOUBLE), intent(in) :: t0 +type(C_FUNPTR), intent(in), value :: resize +type(C_PTR) :: resize_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_FUNPTR) :: farg5 +type(C_PTR) :: farg6 + +farg1 = arkode_mem +farg2 = c_loc(ynew) +farg3 = hscale +farg4 = t0 +farg5 = resize +farg6 = resize_data +fresult = swigc_FARKodeResize(farg1, farg2, farg3, farg4, farg5, farg6) +swig_result = fresult +end function + +function FARKodeReset(arkode_mem, tr, yr) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: tr +type(N_Vector), target, intent(inout) :: yr +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = tr +farg3 = c_loc(yr) +fresult = swigc_FARKodeReset(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSStolerances(arkode_mem, reltol, abstol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: reltol +real(C_DOUBLE), intent(in) :: abstol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = arkode_mem +farg2 = reltol +farg3 = abstol +fresult = swigc_FARKodeSStolerances(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSVtolerances(arkode_mem, reltol, abstol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: reltol +type(N_Vector), target, intent(inout) :: abstol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = reltol +farg3 = c_loc(abstol) +fresult = swigc_FARKodeSVtolerances(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeWFtolerances(arkode_mem, efun) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: efun +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = efun +fresult = swigc_FARKodeWFtolerances(farg1, farg2) +swig_result = fresult +end function + +function FARKodeResStolerance(arkode_mem, rabstol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: rabstol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = rabstol +fresult = swigc_FARKodeResStolerance(farg1, farg2) +swig_result = fresult +end function + +function FARKodeResVtolerance(arkode_mem, rabstol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: rabstol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(rabstol) +fresult = swigc_FARKodeResVtolerance(farg1, farg2) +swig_result = fresult +end function + +function FARKodeResFtolerance(arkode_mem, rfun) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: rfun +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = rfun +fresult = swigc_FARKodeResFtolerance(farg1, farg2) +swig_result = fresult +end function + +function FARKodeRootInit(arkode_mem, nrtfn, g) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: nrtfn +type(C_FUNPTR), intent(in), value :: g +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 +type(C_FUNPTR) :: farg3 + +farg1 = arkode_mem +farg2 = nrtfn +farg3 = g +fresult = swigc_FARKodeRootInit(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetRootDirection(arkode_mem, rootdir) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: rootdir +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(rootdir(1)) +fresult = swigc_FARKodeSetRootDirection(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetNoInactiveRootWarn(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeSetNoInactiveRootWarn(farg1) +swig_result = fresult +end function + +function FARKodeSetDefaults(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeSetDefaults(farg1) +swig_result = fresult +end function + +function FARKodeSetOrder(arkode_mem, maxord) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: maxord +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = maxord +fresult = swigc_FARKodeSetOrder(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetInterpolantType(arkode_mem, itype) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: itype +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = itype +fresult = swigc_FARKodeSetInterpolantType(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetInterpolantDegree(arkode_mem, degree) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: degree +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = degree +fresult = swigc_FARKodeSetInterpolantDegree(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxNumSteps(arkode_mem, mxsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), intent(in) :: mxsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 + +farg1 = arkode_mem +farg2 = mxsteps +fresult = swigc_FARKodeSetMaxNumSteps(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetInterpolateStopTime(arkode_mem, interp) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: interp +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = interp +fresult = swigc_FARKodeSetInterpolateStopTime(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetStopTime(arkode_mem, tstop) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: tstop +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = tstop +fresult = swigc_FARKodeSetStopTime(farg1, farg2) +swig_result = fresult +end function + +function FARKodeClearStopTime(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeClearStopTime(farg1) +swig_result = fresult +end function + +function FARKodeSetFixedStep(arkode_mem, hfixed) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hfixed +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hfixed +fresult = swigc_FARKodeSetFixedStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetUserData(arkode_mem, user_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: user_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = user_data +fresult = swigc_FARKodeSetUserData(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetPostprocessStepFn(arkode_mem, processstep) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: processstep +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = processstep +fresult = swigc_FARKodeSetPostprocessStepFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetPostprocessStageFn(arkode_mem, processstage) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: processstage +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = processstage +fresult = swigc_FARKodeSetPostprocessStageFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetNonlinearSolver(arkode_mem, nls) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNNonlinearSolver), target, intent(inout) :: nls +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nls) +fresult = swigc_FARKodeSetNonlinearSolver(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetLinear(arkode_mem, timedepend) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: timedepend +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = timedepend +fresult = swigc_FARKodeSetLinear(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetNonlinear(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeSetNonlinear(farg1) +swig_result = fresult +end function + +function FARKodeSetNlsRhsFn(arkode_mem, nls_fi) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: nls_fi +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = nls_fi +fresult = swigc_FARKodeSetNlsRhsFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetDeduceImplicitRhs(arkode_mem, deduce) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: deduce +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = deduce +fresult = swigc_FARKodeSetDeduceImplicitRhs(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetNonlinCRDown(arkode_mem, crdown) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: crdown +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = crdown +fresult = swigc_FARKodeSetNonlinCRDown(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetNonlinRDiv(arkode_mem, rdiv) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: rdiv +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = rdiv +fresult = swigc_FARKodeSetNonlinRDiv(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetDeltaGammaMax(arkode_mem, dgmax) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: dgmax +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = dgmax +fresult = swigc_FARKodeSetDeltaGammaMax(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetLSetupFrequency(arkode_mem, msbp) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: msbp +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = msbp +fresult = swigc_FARKodeSetLSetupFrequency(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetPredictorMethod(arkode_mem, method) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: method +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = method +fresult = swigc_FARKodeSetPredictorMethod(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxNonlinIters(arkode_mem, maxcor) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: maxcor +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = maxcor +fresult = swigc_FARKodeSetMaxNonlinIters(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxConvFails(arkode_mem, maxncf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: maxncf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = maxncf +fresult = swigc_FARKodeSetMaxConvFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetNonlinConvCoef(arkode_mem, nlscoef) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: nlscoef +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = nlscoef +fresult = swigc_FARKodeSetNonlinConvCoef(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetStagePredictFn(arkode_mem, predictstage) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: predictstage +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = predictstage +fresult = swigc_FARKodeSetStagePredictFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetAdaptController(arkode_mem, c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(c) +fresult = swigc_FARKodeSetAdaptController(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetAdaptivityAdjustment(arkode_mem, adjust) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: adjust +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = adjust +fresult = swigc_FARKodeSetAdaptivityAdjustment(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetCFLFraction(arkode_mem, cfl_frac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: cfl_frac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = cfl_frac +fresult = swigc_FARKodeSetCFLFraction(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetErrorBias(arkode_mem, bias) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: bias +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = bias +fresult = swigc_FARKodeSetErrorBias(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetSafetyFactor(arkode_mem, safety) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: safety +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = safety +fresult = swigc_FARKodeSetSafetyFactor(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxGrowth(arkode_mem, mx_growth) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: mx_growth +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = mx_growth +fresult = swigc_FARKodeSetMaxGrowth(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMinReduction(arkode_mem, eta_min) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: eta_min +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = eta_min +fresult = swigc_FARKodeSetMinReduction(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetFixedStepBounds(arkode_mem, lb, ub) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: lb +real(C_DOUBLE), intent(in) :: ub +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = arkode_mem +farg2 = lb +farg3 = ub +fresult = swigc_FARKodeSetFixedStepBounds(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetMaxFirstGrowth(arkode_mem, etamx1) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: etamx1 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = etamx1 +fresult = swigc_FARKodeSetMaxFirstGrowth(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxEFailGrowth(arkode_mem, etamxf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: etamxf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = etamxf +fresult = swigc_FARKodeSetMaxEFailGrowth(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetSmallNumEFails(arkode_mem, small_nef) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: small_nef +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = small_nef +fresult = swigc_FARKodeSetSmallNumEFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxCFailGrowth(arkode_mem, etacf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: etacf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = etacf +fresult = swigc_FARKodeSetMaxCFailGrowth(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetStabilityFn(arkode_mem, estab, estab_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: estab +type(C_PTR) :: estab_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = estab +farg3 = estab_data +fresult = swigc_FARKodeSetStabilityFn(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetMaxErrTestFails(arkode_mem, maxnef) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: maxnef +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = maxnef +fresult = swigc_FARKodeSetMaxErrTestFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetConstraints(arkode_mem, constraints) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: constraints +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(constraints) +fresult = swigc_FARKodeSetConstraints(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxHnilWarns(arkode_mem, mxhnil) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: mxhnil +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = mxhnil +fresult = swigc_FARKodeSetMaxHnilWarns(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetInitStep(arkode_mem, hin) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hin +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hin +fresult = swigc_FARKodeSetInitStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMinStep(arkode_mem, hmin) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hmin +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hmin +fresult = swigc_FARKodeSetMinStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxStep(arkode_mem, hmax) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hmax +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hmax +fresult = swigc_FARKodeSetMaxStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMaxNumConstrFails(arkode_mem, maxfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: maxfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = maxfails +fresult = swigc_FARKodeSetMaxNumConstrFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetAccumulatedErrorType(arkode_mem, accum_type) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: accum_type +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = accum_type +fresult = swigc_FARKodeSetAccumulatedErrorType(farg1, farg2) +swig_result = fresult +end function + +function FARKodeResetAccumulatedError(arkode_mem) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = arkode_mem +fresult = swigc_FARKodeResetAccumulatedError(farg1) +swig_result = fresult +end function + +function FARKodeEvolve(arkode_mem, tout, yout, tret, itask) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: tout +type(N_Vector), target, intent(inout) :: yout +real(C_DOUBLE), dimension(*), target, intent(inout) :: tret +integer(C_INT), intent(in) :: itask +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +integer(C_INT) :: farg5 + +farg1 = arkode_mem +farg2 = tout +farg3 = c_loc(yout) +farg4 = c_loc(tret(1)) +farg5 = itask +fresult = swigc_FARKodeEvolve(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FARKodeGetDky(arkode_mem, t, k, dky) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: t +integer(C_INT), intent(in) :: k +type(N_Vector), target, intent(inout) :: dky +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +integer(C_INT) :: farg3 +type(C_PTR) :: farg4 + +farg1 = arkode_mem +farg2 = t +farg3 = k +farg4 = c_loc(dky) +fresult = swigc_FARKodeGetDky(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FARKodeComputeState(arkode_mem, zcor, z) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: zcor +type(N_Vector), target, intent(inout) :: z +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(zcor) +farg3 = c_loc(z) +fresult = swigc_FARKodeComputeState(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeGetNumStepAttempts(arkode_mem, step_attempts) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(step_attempts(1)) +fresult = swigc_FARKodeGetNumStepAttempts(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetWorkSpace(arkode_mem, lenrw, leniw) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: lenrw +integer(C_LONG), dimension(*), target, intent(inout) :: leniw +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(lenrw(1)) +farg3 = c_loc(leniw(1)) +fresult = swigc_FARKodeGetWorkSpace(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeGetNumSteps(arkode_mem, nsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nsteps(1)) +fresult = swigc_FARKodeGetNumSteps(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLastStep(arkode_mem, hlast) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(hlast(1)) +fresult = swigc_FARKodeGetLastStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetCurrentStep(arkode_mem, hcur) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(hcur(1)) +fresult = swigc_FARKodeGetCurrentStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetErrWeights(arkode_mem, eweight) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: eweight +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(eweight) +fresult = swigc_FARKodeGetErrWeights(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumGEvals(arkode_mem, ngevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: ngevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(ngevals(1)) +fresult = swigc_FARKodeGetNumGEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetRootInfo(arkode_mem, rootsfound) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: rootsfound +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(rootsfound(1)) +fresult = swigc_FARKodeGetRootInfo(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetUserData(arkode_mem, user_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: user_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(user_data) +fresult = swigc_FARKodeGetUserData(farg1, farg2) +swig_result = fresult +end function + +function FARKodePrintAllStats(arkode_mem, outfile, fmt) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: outfile +integer(SUNOutputFormat), intent(in) :: fmt +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +integer(C_INT) :: farg3 + +farg1 = arkode_mem +farg2 = outfile +farg3 = fmt +fresult = swigc_FARKodePrintAllStats(farg1, farg2, farg3) +swig_result = fresult +end function + + +subroutine SWIG_chararray_to_string(wrap, string) + use, intrinsic :: ISO_C_BINDING + type(SwigArrayWrapper), intent(IN) :: wrap + character(kind=C_CHAR, len=:), allocatable, intent(OUT) :: string + character(kind=C_CHAR), dimension(:), pointer :: chars + integer(kind=C_SIZE_T) :: i + call c_f_pointer(wrap%data, chars, [wrap%size]) + allocate(character(kind=C_CHAR, len=wrap%size) :: string) + do i=1, wrap%size + string(i:i) = chars(i) + end do +end subroutine + +function FARKodeGetReturnFlagName(flag) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +character(kind=C_CHAR, len=:), allocatable :: swig_result +integer(C_LONG), intent(in) :: flag +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 + +farg1 = flag +fresult = swigc_FARKodeGetReturnFlagName(farg1) +call SWIG_chararray_to_string(fresult, swig_result) +if (.false.) call SWIG_free(fresult%data) +end function + +function FARKodeWriteParameters(arkode_mem, fp) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: fp +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = fp +fresult = swigc_FARKodeWriteParameters(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumExpSteps(arkode_mem, expsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: expsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(expsteps(1)) +fresult = swigc_FARKodeGetNumExpSteps(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumAccSteps(arkode_mem, accsteps) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: accsteps +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(accsteps(1)) +fresult = swigc_FARKodeGetNumAccSteps(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumErrTestFails(arkode_mem, netfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: netfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(netfails(1)) +fresult = swigc_FARKodeGetNumErrTestFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetEstLocalErrors(arkode_mem, ele) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: ele +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(ele) +fresult = swigc_FARKodeGetEstLocalErrors(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetActualInitStep(arkode_mem, hinused) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(hinused(1)) +fresult = swigc_FARKodeGetActualInitStep(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetTolScaleFactor(arkode_mem, tolsfac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: tolsfac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(tolsfac(1)) +fresult = swigc_FARKodeGetTolScaleFactor(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumConstrFails(arkode_mem, nconstrfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nconstrfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nconstrfails(1)) +fresult = swigc_FARKodeGetNumConstrFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetStepStats(arkode_mem, nsteps, hinused, hlast, hcur, tcur) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nsteps +real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused +real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast +real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur +real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 + +farg1 = arkode_mem +farg2 = c_loc(nsteps(1)) +farg3 = c_loc(hinused(1)) +farg4 = c_loc(hlast(1)) +farg5 = c_loc(hcur(1)) +farg6 = c_loc(tcur(1)) +fresult = swigc_FARKodeGetStepStats(farg1, farg2, farg3, farg4, farg5, farg6) +swig_result = fresult +end function + +function FARKodeGetAccumulatedError(arkode_mem, accum_error) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(accum_error(1)) +fresult = swigc_FARKodeGetAccumulatedError(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumLinSolvSetups(arkode_mem, nlinsetups) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nlinsetups +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nlinsetups(1)) +fresult = swigc_FARKodeGetNumLinSolvSetups(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetCurrentTime(arkode_mem, tcur) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(tcur(1)) +fresult = swigc_FARKodeGetCurrentTime(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetCurrentState(arkode_mem, state) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: state +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = state +fresult = swigc_FARKodeGetCurrentState(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetCurrentGamma(arkode_mem, gamma) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(gamma(1)) +fresult = swigc_FARKodeGetCurrentGamma(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNonlinearSystemData(arkode_mem, tcur, zpred, z, fi, gamma, sdata, user_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: tcur +type(C_PTR) :: zpred +type(C_PTR) :: z +type(C_PTR) :: fi +real(C_DOUBLE), dimension(*), target, intent(inout) :: gamma +type(C_PTR) :: sdata +type(C_PTR), target, intent(inout) :: user_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 +type(C_PTR) :: farg7 +type(C_PTR) :: farg8 + +farg1 = arkode_mem +farg2 = c_loc(tcur(1)) +farg3 = zpred +farg4 = z +farg5 = fi +farg6 = c_loc(gamma(1)) +farg7 = sdata +farg8 = c_loc(user_data) +fresult = swigc_FARKodeGetNonlinearSystemData(farg1, farg2, farg3, farg4, farg5, farg6, farg7, farg8) +swig_result = fresult +end function + +function FARKodeGetNumNonlinSolvIters(arkode_mem, nniters) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nniters +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nniters(1)) +fresult = swigc_FARKodeGetNumNonlinSolvIters(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumNonlinSolvConvFails(arkode_mem, nnfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nnfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nnfails(1)) +fresult = swigc_FARKodeGetNumNonlinSolvConvFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNonlinSolvStats(arkode_mem, nniters, nnfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nniters +integer(C_LONG), dimension(*), target, intent(inout) :: nnfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(nniters(1)) +farg3 = c_loc(nnfails(1)) +fresult = swigc_FARKodeGetNonlinSolvStats(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeGetNumStepSolveFails(arkode_mem, nncfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nncfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nncfails(1)) +fresult = swigc_FARKodeGetNumStepSolveFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetJac(arkode_mem, j) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: j +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(j) +fresult = swigc_FARKodeGetJac(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetJacTime(arkode_mem, t_j) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), dimension(*), target, intent(inout) :: t_j +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(t_j(1)) +fresult = swigc_FARKodeGetJacTime(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetJacNumSteps(arkode_mem, nst_j) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nst_j +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nst_j(1)) +fresult = swigc_FARKodeGetJacNumSteps(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLinWorkSpace(arkode_mem, lenrwls, leniwls) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls +integer(C_LONG), dimension(*), target, intent(inout) :: leniwls +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(lenrwls(1)) +farg3 = c_loc(leniwls(1)) +fresult = swigc_FARKodeGetLinWorkSpace(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeGetNumJacEvals(arkode_mem, njevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: njevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(njevals(1)) +fresult = swigc_FARKodeGetNumJacEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumPrecEvals(arkode_mem, npevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: npevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(npevals(1)) +fresult = swigc_FARKodeGetNumPrecEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumPrecSolves(arkode_mem, npsolves) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: npsolves +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(npsolves(1)) +fresult = swigc_FARKodeGetNumPrecSolves(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumLinIters(arkode_mem, nliters) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nliters +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nliters(1)) +fresult = swigc_FARKodeGetNumLinIters(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumLinConvFails(arkode_mem, nlcfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nlcfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nlcfails(1)) +fresult = swigc_FARKodeGetNumLinConvFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumJTSetupEvals(arkode_mem, njtsetups) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: njtsetups +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(njtsetups(1)) +fresult = swigc_FARKodeGetNumJTSetupEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumJtimesEvals(arkode_mem, njvevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: njvevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(njvevals(1)) +fresult = swigc_FARKodeGetNumJtimesEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumLinRhsEvals(arkode_mem, nfevalsls) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nfevalsls +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nfevalsls(1)) +fresult = swigc_FARKodeGetNumLinRhsEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLastLinFlag(arkode_mem, flag) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: flag +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(flag(1)) +fresult = swigc_FARKodeGetLastLinFlag(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLinReturnFlagName(flag) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +character(kind=C_CHAR, len=:), allocatable :: swig_result +integer(C_LONG), intent(in) :: flag +type(SwigArrayWrapper) :: fresult +integer(C_LONG) :: farg1 + +farg1 = flag +fresult = swigc_FARKodeGetLinReturnFlagName(farg1) +call SWIG_chararray_to_string(fresult, swig_result) +if (.false.) call SWIG_free(fresult%data) +end function + +function FARKodeGetCurrentMassMatrix(arkode_mem, m) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: m +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(m) +fresult = swigc_FARKodeGetCurrentMassMatrix(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetResWeights(arkode_mem, rweight) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(N_Vector), target, intent(inout) :: rweight +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(rweight) +fresult = swigc_FARKodeGetResWeights(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetMassWorkSpace(arkode_mem, lenrwmls, leniwmls) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: lenrwmls +integer(C_LONG), dimension(*), target, intent(inout) :: leniwmls +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(lenrwmls(1)) +farg3 = c_loc(leniwmls(1)) +fresult = swigc_FARKodeGetMassWorkSpace(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeGetNumMassSetups(arkode_mem, nmsetups) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmsetups +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmsetups(1)) +fresult = swigc_FARKodeGetNumMassSetups(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassMultSetups(arkode_mem, nmvsetups) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmvsetups +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmvsetups(1)) +fresult = swigc_FARKodeGetNumMassMultSetups(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassMult(arkode_mem, nmvevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmvevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmvevals(1)) +fresult = swigc_FARKodeGetNumMassMult(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassSolves(arkode_mem, nmsolves) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmsolves +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmsolves(1)) +fresult = swigc_FARKodeGetNumMassSolves(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassPrecEvals(arkode_mem, nmpevals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmpevals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmpevals(1)) +fresult = swigc_FARKodeGetNumMassPrecEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassPrecSolves(arkode_mem, nmpsolves) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmpsolves +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmpsolves(1)) +fresult = swigc_FARKodeGetNumMassPrecSolves(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassIters(arkode_mem, nmiters) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmiters +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmiters(1)) +fresult = swigc_FARKodeGetNumMassIters(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMassConvFails(arkode_mem, nmcfails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmcfails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmcfails(1)) +fresult = swigc_FARKodeGetNumMassConvFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumMTSetups(arkode_mem, nmtsetups) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nmtsetups +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(nmtsetups(1)) +fresult = swigc_FARKodeGetNumMTSetups(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetLastMassFlag(arkode_mem, flag) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: flag +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(flag(1)) +fresult = swigc_FARKodeGetLastMassFlag(farg1, farg2) +swig_result = fresult +end function + +subroutine FARKodeFree(arkode_mem) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), target, intent(inout) :: arkode_mem +type(C_PTR) :: farg1 + +farg1 = c_loc(arkode_mem) +call swigc_FARKodeFree(farg1) +end subroutine + +subroutine FARKodePrintMem(arkode_mem, outfile) +use, intrinsic :: ISO_C_BINDING +type(C_PTR) :: arkode_mem +type(C_PTR) :: outfile +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = outfile +call swigc_FARKodePrintMem(farg1, farg2) +end subroutine + +function FARKodeSetRelaxFn(arkode_mem, rfn, rjac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: rfn +type(C_FUNPTR), intent(in), value :: rjac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 + +farg1 = arkode_mem +farg2 = rfn +farg3 = rjac +fresult = swigc_FARKodeSetRelaxFn(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetRelaxEtaFail(arkode_mem, eta_rf) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: eta_rf +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = eta_rf +fresult = swigc_FARKodeSetRelaxEtaFail(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetRelaxLowerBound(arkode_mem, lower) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: lower +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = lower +fresult = swigc_FARKodeSetRelaxLowerBound(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetRelaxMaxFails(arkode_mem, max_fails) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: max_fails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = max_fails +fresult = swigc_FARKodeSetRelaxMaxFails(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetRelaxMaxIters(arkode_mem, max_iters) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: max_iters +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = max_iters +fresult = swigc_FARKodeSetRelaxMaxIters(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetRelaxSolver(arkode_mem, solver) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(ARKRelaxSolver), intent(in) :: solver +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = solver +fresult = swigc_FARKodeSetRelaxSolver(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetRelaxResTol(arkode_mem, res_tol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: res_tol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = res_tol +fresult = swigc_FARKodeSetRelaxResTol(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetRelaxTol(arkode_mem, rel_tol, abs_tol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: rel_tol +real(C_DOUBLE), intent(in) :: abs_tol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 +real(C_DOUBLE) :: farg3 + +farg1 = arkode_mem +farg2 = rel_tol +farg3 = abs_tol +fresult = swigc_FARKodeSetRelaxTol(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetRelaxUpperBound(arkode_mem, upper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: upper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = upper +fresult = swigc_FARKodeSetRelaxUpperBound(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumRelaxFnEvals(arkode_mem, r_evals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: r_evals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(r_evals(1)) +fresult = swigc_FARKodeGetNumRelaxFnEvals(farg1, farg2) +swig_result = fresult +end function + +function FARKodeGetNumRelaxJacEvals(arkode_mem, j_evals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: j_evals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(j_evals(1)) +fresult = swigc_FARKodeGetNumRelaxJacEvals(farg1, farg2) +swig_result = fresult end function -function swigc_FARKodeSPRKTable_Copy(farg1) & -bind(C, name="_wrap_FARKodeSPRKTable_Copy") & -result(fresult) +function FARKodeGetNumRelaxFails(arkode_mem, relax_fails) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR) :: fresult +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: relax_fails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(relax_fails(1)) +fresult = swigc_FARKodeGetNumRelaxFails(farg1, farg2) +swig_result = fresult end function -subroutine swigc_FARKodeSPRKTable_Write(farg1, farg2) & -bind(C, name="_wrap_FARKodeSPRKTable_Write") +function FARKodeGetNumRelaxBoundFails(arkode_mem, fails) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -end subroutine +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: fails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 -subroutine swigc_FARKodeSPRKTable_Space(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKodeSPRKTable_Space") -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -end subroutine +farg1 = arkode_mem +farg2 = c_loc(fails(1)) +fresult = swigc_FARKodeGetNumRelaxBoundFails(farg1, farg2) +swig_result = fresult +end function -subroutine swigc_FARKodeSPRKTable_Free(farg1) & -bind(C, name="_wrap_FARKodeSPRKTable_Free") +function FARKodeGetNumRelaxSolveFails(arkode_mem, fails) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -end subroutine +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: fails +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 -function swigc_FARKodeSPRKTable_ToButcher(farg1, farg2, farg3) & -bind(C, name="_wrap_FARKodeSPRKTable_ToButcher") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -integer(C_INT) :: fresult +farg1 = arkode_mem +farg2 = c_loc(fails(1)) +fresult = swigc_FARKodeGetNumRelaxSolveFails(farg1, farg2) +swig_result = fresult end function -end interface +function FARKodeGetNumRelaxSolveIters(arkode_mem, iters) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: iters +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +farg1 = arkode_mem +farg2 = c_loc(iters(1)) +fresult = swigc_FARKodeGetNumRelaxSolveIters(farg1, farg2) +swig_result = fresult +end function -contains - ! MODULE SUBPROGRAMS function FARKBandPrecInit(arkode_mem, n, mu, ml) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -1661,5 +5477,285 @@ function FARKodeSPRKTable_ToButcher(sprk_storage, a_ptr, b_ptr) & swig_result = fresult end function +function FARKodeSetLinearSolver(arkode_mem, ls, a) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNLinearSolver), target, intent(inout) :: ls +type(SUNMatrix), target, intent(inout) :: a +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(ls) +farg3 = c_loc(a) +fresult = swigc_FARKodeSetLinearSolver(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetMassLinearSolver(arkode_mem, ls, m, time_dep) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNLinearSolver), target, intent(inout) :: ls +type(SUNMatrix), target, intent(inout) :: m +integer(C_INT), intent(in) :: time_dep +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +integer(C_INT) :: farg4 + +farg1 = arkode_mem +farg2 = c_loc(ls) +farg3 = c_loc(m) +farg4 = time_dep +fresult = swigc_FARKodeSetMassLinearSolver(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FARKodeSetJacFn(arkode_mem, jac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: jac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = jac +fresult = swigc_FARKodeSetJacFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMassFn(arkode_mem, mass) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: mass +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = mass +fresult = swigc_FARKodeSetMassFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetJacEvalFrequency(arkode_mem, msbj) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), intent(in) :: msbj +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_LONG) :: farg2 + +farg1 = arkode_mem +farg2 = msbj +fresult = swigc_FARKodeSetJacEvalFrequency(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetLinearSolutionScaling(arkode_mem, onoff) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: onoff +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = onoff +fresult = swigc_FARKodeSetLinearSolutionScaling(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetEpsLin(arkode_mem, eplifac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: eplifac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = eplifac +fresult = swigc_FARKodeSetEpsLin(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMassEpsLin(arkode_mem, eplifac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: eplifac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = eplifac +fresult = swigc_FARKodeSetMassEpsLin(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetLSNormFactor(arkode_mem, nrmfac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: nrmfac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = nrmfac +fresult = swigc_FARKodeSetLSNormFactor(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMassLSNormFactor(arkode_mem, nrmfac) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: nrmfac +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = nrmfac +fresult = swigc_FARKodeSetMassLSNormFactor(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetPreconditioner(arkode_mem, psetup, psolve) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: psetup +type(C_FUNPTR), intent(in), value :: psolve +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 + +farg1 = arkode_mem +farg2 = psetup +farg3 = psolve +fresult = swigc_FARKodeSetPreconditioner(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetMassPreconditioner(arkode_mem, psetup, psolve) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: psetup +type(C_FUNPTR), intent(in), value :: psolve +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 + +farg1 = arkode_mem +farg2 = psetup +farg3 = psolve +fresult = swigc_FARKodeSetMassPreconditioner(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetJacTimes(arkode_mem, jtsetup, jtimes) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: jtsetup +type(C_FUNPTR), intent(in), value :: jtimes +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 + +farg1 = arkode_mem +farg2 = jtsetup +farg3 = jtimes +fresult = swigc_FARKodeSetJacTimes(farg1, farg2, farg3) +swig_result = fresult +end function + +function FARKodeSetJacTimesRhsFn(arkode_mem, jtimesrhsfn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: jtimesrhsfn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = jtimesrhsfn +fresult = swigc_FARKodeSetJacTimesRhsFn(farg1, farg2) +swig_result = fresult +end function + +function FARKodeSetMassTimes(arkode_mem, msetup, mtimes, mtimes_data) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: msetup +type(C_FUNPTR), intent(in), value :: mtimes +type(C_PTR) :: mtimes_data +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 +type(C_PTR) :: farg4 + +farg1 = arkode_mem +farg2 = msetup +farg3 = mtimes +farg4 = mtimes_data +fresult = swigc_FARKodeSetMassTimes(farg1, farg2, farg3, farg4) +swig_result = fresult +end function + +function FARKodeSetLinSysFn(arkode_mem, linsys) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: linsys +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = linsys +fresult = swigc_FARKodeSetLinSysFn(farg1, farg2) +swig_result = fresult +end function + end module diff --git a/src/arkode/fmod/farkode_mristep_mod.c b/src/arkode/fmod/farkode_mristep_mod.c index b413124754..dbb3438d16 100644 --- a/src/arkode/fmod/farkode_mristep_mod.c +++ b/src/arkode/fmod/farkode_mristep_mod.c @@ -308,6 +308,30 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() { return result; } +SWIGEXPORT void _wrap_MRIStepCouplingMem_type_set(SwigClassWrapper const *farg1, int const *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + MRISTEP_METHOD_TYPE arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (MRISTEP_METHOD_TYPE)(*farg2); + if (arg1) (arg1)->type = arg2; +} + + +SWIGEXPORT int _wrap_MRIStepCouplingMem_type_get(SwigClassWrapper const *farg1) { + int fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + MRISTEP_METHOD_TYPE result; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::type", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (MRISTEP_METHOD_TYPE) ((arg1)->type); + fresult = (int)(result); + return fresult; +} + + SWIGEXPORT void _wrap_MRIStepCouplingMem_nmat_set(SwigClassWrapper const *farg1, int const *farg2) { struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; int arg2 ; @@ -476,6 +500,54 @@ SWIGEXPORT void * _wrap_MRIStepCouplingMem_G_get(SwigClassWrapper const *farg1) } +SWIGEXPORT void _wrap_MRIStepCouplingMem_ngroup_set(SwigClassWrapper const *farg1, int const *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int arg2 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::ngroup", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (int)(*farg2); + if (arg1) (arg1)->ngroup = arg2; +} + + +SWIGEXPORT int _wrap_MRIStepCouplingMem_ngroup_get(SwigClassWrapper const *farg1) { + int fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int result; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::ngroup", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (int) ((arg1)->ngroup); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT void _wrap_MRIStepCouplingMem_group_set(SwigClassWrapper const *farg1, void *farg2) { + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int **arg2 = (int **) 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::group", return ); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + arg2 = (int **)(farg2); + if (arg1) (arg1)->group = arg2; +} + + +SWIGEXPORT void * _wrap_MRIStepCouplingMem_group_get(SwigClassWrapper const *farg1) { + void * fresult ; + struct MRIStepCouplingMem *arg1 = (struct MRIStepCouplingMem *) 0 ; + int **result = 0 ; + + SWIG_check_mutable_nonnull(*farg1, "struct MRIStepCouplingMem *", "MRIStepCouplingMem", "MRIStepCouplingMem::group", return 0); + arg1 = (struct MRIStepCouplingMem *)(farg1->cptr); + result = (int **) ((arg1)->group); + fresult = result; + return fresult; +} + + SWIGEXPORT SwigClassWrapper _wrap_new_MRIStepCouplingMem() { SwigClassWrapper fresult ; struct MRIStepCouplingMem *result = 0 ; @@ -651,26 +723,6 @@ SWIGEXPORT void * _wrap_FMRIStepCreate(ARKRhsFn farg1, ARKRhsFn farg2, double co } -SWIGEXPORT int _wrap_FMRIStepResize(void *farg1, N_Vector farg2, double const *farg3, ARKVecResizeFn farg4, void *farg5) { - int fresult ; - void *arg1 = (void *) 0 ; - N_Vector arg2 = (N_Vector) 0 ; - sunrealtype arg3 ; - ARKVecResizeFn arg4 = (ARKVecResizeFn) 0 ; - void *arg5 = (void *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (N_Vector)(farg2); - arg3 = (sunrealtype)(*farg3); - arg4 = (ARKVecResizeFn)(farg4); - arg5 = (void *)(farg5); - result = (int)MRIStepResize(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepReInit(void *farg1, ARKRhsFn farg2, ARKRhsFn farg3, double const *farg4, N_Vector farg5) { int fresult ; void *arg1 = (void *) 0 ; @@ -691,391 +743,435 @@ SWIGEXPORT int _wrap_FMRIStepReInit(void *farg1, ARKRhsFn farg2, ARKRhsFn farg3, } -SWIGEXPORT int _wrap_FMRIStepReset(void *farg1, double const *farg2, N_Vector farg3) { +SWIGEXPORT int _wrap_FMRIStepSetCoupling(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - N_Vector arg3 = (N_Vector) 0 ; + MRIStepCoupling arg2 = (MRIStepCoupling) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (N_Vector)(farg3); - result = (int)MRIStepReset(arg1,arg2,arg3); + arg2 = (MRIStepCoupling)(farg2); + result = (int)MRIStepSetCoupling(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSStolerances(void *farg1, double const *farg2, double const *farg3) { +SWIGEXPORT int _wrap_FMRIStepSetPreInnerFn(void *farg1, MRIStepPreInnerFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - sunrealtype arg3 ; + MRIStepPreInnerFn arg2 = (MRIStepPreInnerFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (sunrealtype)(*farg3); - result = (int)MRIStepSStolerances(arg1,arg2,arg3); + arg2 = (MRIStepPreInnerFn)(farg2); + result = (int)MRIStepSetPreInnerFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSVtolerances(void *farg1, double const *farg2, N_Vector farg3) { +SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - N_Vector arg3 = (N_Vector) 0 ; + MRIStepPostInnerFn arg2 = (MRIStepPostInnerFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (N_Vector)(farg3); - result = (int)MRIStepSVtolerances(arg1,arg2,arg3); + arg2 = (MRIStepPostInnerFn)(farg2); + result = (int)MRIStepSetPostInnerFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepWFtolerances(void *farg1, ARKEwtFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetFastErrorStepFactor(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKEwtFn arg2 = (ARKEwtFn) 0 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKEwtFn)(farg2); - result = (int)MRIStepWFtolerances(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetFastErrorStepFactor(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetLinearSolver(void *farg1, SUNLinearSolver farg2, SUNMatrix farg3) { +SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { int fresult ; void *arg1 = (void *) 0 ; - SUNLinearSolver arg2 = (SUNLinearSolver) 0 ; - SUNMatrix arg3 = (SUNMatrix) 0 ; + SUNAdaptController arg2 = (SUNAdaptController) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (SUNLinearSolver)(farg2); - arg3 = (SUNMatrix)(farg3); - result = (int)MRIStepSetLinearSolver(arg1,arg2,arg3); + arg2 = (SUNAdaptController)(farg2); + result = (int)MRIStepSetAdaptController(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepRootInit(void *farg1, int const *farg2, ARKRootFn farg3) { +SWIGEXPORT int _wrap_FMRIStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; - ARKRootFn arg3 = (ARKRootFn) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - arg3 = (ARKRootFn)(farg3); - result = (int)MRIStepRootInit(arg1,arg2,arg3); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)MRIStepGetNumRhsEvals(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetDefaults(void *farg1) { +SWIGEXPORT int _wrap_FMRIStepGetCurrentCoupling(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; + MRIStepCoupling *arg2 = (MRIStepCoupling *) 0 ; int result; arg1 = (void *)(farg1); - result = (int)MRIStepSetDefaults(arg1); + arg2 = (MRIStepCoupling *)(farg2); + result = (int)MRIStepGetCurrentCoupling(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetOrder(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepGetLastInnerStepFlag(void *farg1, int *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + int *arg2 = (int *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetOrder(arg1,arg2); + arg2 = (int *)(farg2); + result = (int)MRIStepGetLastInnerStepFlag(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetInterpolantType(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_Create(void *farg1, void *farg2) { int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; + SUNContext arg1 = (SUNContext) 0 ; + MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetInterpolantType(arg1,arg2); + arg1 = (SUNContext)(farg1); + arg2 = (MRIStepInnerStepper *)(farg2); + result = (int)MRIStepInnerStepper_Create(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetInterpolantDegree(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_Free(void *farg1) { int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; + MRIStepInnerStepper *arg1 = (MRIStepInnerStepper *) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetInterpolantDegree(arg1,arg2); + arg1 = (MRIStepInnerStepper *)(farg1); + result = (int)MRIStepInnerStepper_Free(arg1); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetDenseOrder(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetContent(void *farg1, void *farg2) { int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + void *arg2 = (void *) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetDenseOrder(arg1,arg2); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (void *)(farg2); + result = (int)MRIStepInnerStepper_SetContent(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNonlinearSolver(void *farg1, SUNNonlinearSolver farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetContent(void *farg1, void *farg2) { int fresult ; - void *arg1 = (void *) 0 ; - SUNNonlinearSolver arg2 = (SUNNonlinearSolver) 0 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + void **arg2 = (void **) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (SUNNonlinearSolver)(farg2); - result = (int)MRIStepSetNonlinearSolver(arg1,arg2); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (void **)(farg2); + result = (int)MRIStepInnerStepper_GetContent(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNlsRhsFn(void *farg1, ARKRhsFn farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetEvolveFn(void *farg1, MRIStepInnerEvolveFn farg2) { int fresult ; - void *arg1 = (void *) 0 ; - ARKRhsFn arg2 = (ARKRhsFn) 0 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerEvolveFn arg2 = (MRIStepInnerEvolveFn) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (ARKRhsFn)(farg2); - result = (int)MRIStepSetNlsRhsFn(arg1,arg2); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerEvolveFn)(farg2); + result = (int)MRIStepInnerStepper_SetEvolveFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetLinear(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFullRhsFn(void *farg1, MRIStepInnerFullRhsFn farg2) { int fresult ; - void *arg1 = (void *) 0 ; - int arg2 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerFullRhsFn arg2 = (MRIStepInnerFullRhsFn) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetLinear(arg1,arg2); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerFullRhsFn)(farg2); + result = (int)MRIStepInnerStepper_SetFullRhsFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNonlinear(void *farg1) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetResetFn(void *farg1, MRIStepInnerResetFn farg2) { int fresult ; - void *arg1 = (void *) 0 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerResetFn arg2 = (MRIStepInnerResetFn) 0 ; int result; - arg1 = (void *)(farg1); - result = (int)MRIStepSetNonlinear(arg1); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerResetFn)(farg2); + result = (int)MRIStepInnerStepper_SetResetFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetCoupling(void *farg1, void *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(void *farg1, MRIStepInnerGetAccumulatedError farg2) { int fresult ; - void *arg1 = (void *) 0 ; - MRIStepCoupling arg2 = (MRIStepCoupling) 0 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerGetAccumulatedError arg2 = (MRIStepInnerGetAccumulatedError) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (MRIStepCoupling)(farg2); - result = (int)MRIStepSetCoupling(arg1,arg2); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerGetAccumulatedError)(farg2); + result = (int)MRIStepInnerStepper_SetAccumulatedErrorGetFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetAdaptController(void *farg1, SUNAdaptController farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(void *farg1, MRIStepInnerResetAccumulatedError farg2) { int fresult ; - void *arg1 = (void *) 0 ; - SUNAdaptController arg2 = (SUNAdaptController) 0 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerResetAccumulatedError arg2 = (MRIStepInnerResetAccumulatedError) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (SUNAdaptController)(farg2); - result = (int)MRIStepSetAdaptController(arg1,arg2); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerResetAccumulatedError)(farg2); + result = (int)MRIStepInnerStepper_SetAccumulatedErrorResetFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetMaxNumSteps(void *farg1, long const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFixedStepFn(void *farg1, MRIStepInnerSetFixedStep farg2) { int fresult ; - void *arg1 = (void *) 0 ; - long arg2 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerSetFixedStep arg2 = (MRIStepInnerSetFixedStep) 0 ; int result; - arg1 = (void *)(farg1); - arg2 = (long)(*farg2); - result = (int)MRIStepSetMaxNumSteps(arg1,arg2); - fresult = (int)(result); + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerSetFixedStep)(farg2); + result = (int)MRIStepInnerStepper_SetFixedStepFn(arg1,arg2); + fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNonlinCRDown(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetRTolFn(void *farg1, MRIStepInnerSetRTol farg2) { int fresult ; - void *arg1 = (void *) 0 ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + MRIStepInnerSetRTol arg2 = (MRIStepInnerSetRTol) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (MRIStepInnerSetRTol)(farg2); + result = (int)MRIStepInnerStepper_SetRTolFn(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepInnerStepper_AddForcing(void *farg1, double const *farg2, N_Vector farg3) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; int result; - arg1 = (void *)(farg1); + arg1 = (MRIStepInnerStepper)(farg1); arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetNonlinCRDown(arg1,arg2); + arg3 = (N_Vector)(farg3); + result = (int)MRIStepInnerStepper_AddForcing(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNonlinRDiv(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetForcingData(void *farg1, double *farg2, double *farg3, void *farg4, int *farg5) { + int fresult ; + MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; + sunrealtype *arg2 = (sunrealtype *) 0 ; + sunrealtype *arg3 = (sunrealtype *) 0 ; + N_Vector **arg4 = (N_Vector **) 0 ; + int *arg5 = (int *) 0 ; + int result; + + arg1 = (MRIStepInnerStepper)(farg1); + arg2 = (sunrealtype *)(farg2); + arg3 = (sunrealtype *)(farg3); + arg4 = (N_Vector **)(farg4); + arg5 = (int *)(farg5); + result = (int)MRIStepInnerStepper_GetForcingData(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FMRIStepResize(void *farg1, N_Vector farg2, double const *farg3, ARKVecResizeFn farg4, void *farg5) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; + N_Vector arg2 = (N_Vector) 0 ; + sunrealtype arg3 ; + ARKVecResizeFn arg4 = (ARKVecResizeFn) 0 ; + void *arg5 = (void *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetNonlinRDiv(arg1,arg2); + arg2 = (N_Vector)(farg2); + arg3 = (sunrealtype)(*farg3); + arg4 = (ARKVecResizeFn)(farg4); + arg5 = (void *)(farg5); + result = (int)MRIStepResize(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetDeltaGammaMax(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepReset(void *farg1, double const *farg2, N_Vector farg3) { int fresult ; void *arg1 = (void *) 0 ; sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; int result; arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetDeltaGammaMax(arg1,arg2); + arg3 = (N_Vector)(farg3); + result = (int)MRIStepReset(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetLSetupFrequency(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSStolerances(void *farg1, double const *farg2, double const *farg3) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + sunrealtype arg2 ; + sunrealtype arg3 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetLSetupFrequency(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + arg3 = (sunrealtype)(*farg3); + result = (int)MRIStepSStolerances(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetPredictorMethod(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSVtolerances(void *farg1, double const *farg2, N_Vector farg3) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetPredictorMethod(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + arg3 = (N_Vector)(farg3); + result = (int)MRIStepSVtolerances(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetMaxNonlinIters(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepWFtolerances(void *farg1, ARKEwtFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + ARKEwtFn arg2 = (ARKEwtFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetMaxNonlinIters(arg1,arg2); + arg2 = (ARKEwtFn)(farg2); + result = (int)MRIStepWFtolerances(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNonlinConvCoef(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetLinearSolver(void *farg1, SUNLinearSolver farg2, SUNMatrix farg3) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; + SUNLinearSolver arg2 = (SUNLinearSolver) 0 ; + SUNMatrix arg3 = (SUNMatrix) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetNonlinConvCoef(arg1,arg2); + arg2 = (SUNLinearSolver)(farg2); + arg3 = (SUNMatrix)(farg3); + result = (int)MRIStepSetLinearSolver(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetMaxHnilWarns(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepRootInit(void *farg1, int const *farg2, ARKRootFn farg3) { int fresult ; void *arg1 = (void *) 0 ; int arg2 ; + ARKRootFn arg3 = (ARKRootFn) 0 ; int result; arg1 = (void *)(farg1); arg2 = (int)(*farg2); - result = (int)MRIStepSetMaxHnilWarns(arg1,arg2); + arg3 = (ARKRootFn)(farg3); + result = (int)MRIStepRootInit(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetStopTime(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetDefaults(void *farg1) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetStopTime(arg1,arg2); + result = (int)MRIStepSetDefaults(arg1); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetInterpolateStopTime(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetOrder(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; int arg2 ; @@ -1083,79 +1179,83 @@ SWIGEXPORT int _wrap_FMRIStepSetInterpolateStopTime(void *farg1, int const *farg arg1 = (void *)(farg1); arg2 = (int)(*farg2); - result = (int)MRIStepSetInterpolateStopTime(arg1,arg2); + result = (int)MRIStepSetOrder(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepClearStopTime(void *farg1) { +SWIGEXPORT int _wrap_FMRIStepSetInterpolantType(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; + int arg2 ; int result; arg1 = (void *)(farg1); - result = (int)MRIStepClearStopTime(arg1); + arg2 = (int)(*farg2); + result = (int)MRIStepSetInterpolantType(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetFixedStep(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetInterpolantDegree(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetFixedStep(arg1,arg2); + arg2 = (int)(*farg2); + result = (int)MRIStepSetInterpolantDegree(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetRootDirection(void *farg1, int *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetDenseOrder(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int *arg2 = (int *) 0 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (int *)(farg2); - result = (int)MRIStepSetRootDirection(arg1,arg2); + arg2 = (int)(*farg2); + result = (int)MRIStepSetDenseOrder(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetNoInactiveRootWarn(void *farg1) { +SWIGEXPORT int _wrap_FMRIStepSetNonlinearSolver(void *farg1, SUNNonlinearSolver farg2) { int fresult ; void *arg1 = (void *) 0 ; + SUNNonlinearSolver arg2 = (SUNNonlinearSolver) 0 ; int result; arg1 = (void *)(farg1); - result = (int)MRIStepSetNoInactiveRootWarn(arg1); + arg2 = (SUNNonlinearSolver)(farg2); + result = (int)MRIStepSetNonlinearSolver(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetUserData(void *farg1, void *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetNlsRhsFn(void *farg1, ARKRhsFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - void *arg2 = (void *) 0 ; + ARKRhsFn arg2 = (ARKRhsFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (void *)(farg2); - result = (int)MRIStepSetUserData(arg1,arg2); + arg2 = (ARKRhsFn)(farg2); + result = (int)MRIStepSetNlsRhsFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetMaxErrTestFails(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetLinear(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; int arg2 ; @@ -1163,55 +1263,53 @@ SWIGEXPORT int _wrap_FMRIStepSetMaxErrTestFails(void *farg1, int const *farg2) { arg1 = (void *)(farg1); arg2 = (int)(*farg2); - result = (int)MRIStepSetMaxErrTestFails(arg1,arg2); + result = (int)MRIStepSetLinear(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetMaxConvFails(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetNonlinear(void *farg1) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetMaxConvFails(arg1,arg2); + result = (int)MRIStepSetNonlinear(arg1); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetConstraints(void *farg1, N_Vector farg2) { +SWIGEXPORT int _wrap_FMRIStepSetMaxNumSteps(void *farg1, long const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - N_Vector arg2 = (N_Vector) 0 ; + long arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (N_Vector)(farg2); - result = (int)MRIStepSetConstraints(arg1,arg2); + arg2 = (long)(*farg2); + result = (int)MRIStepSetMaxNumSteps(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetMaxNumConstrFails(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetNonlinCRDown(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetMaxNumConstrFails(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetNonlinCRDown(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetInitStep(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetNonlinRDiv(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; sunrealtype arg2 ; @@ -1219,83 +1317,83 @@ SWIGEXPORT int _wrap_FMRIStepSetInitStep(void *farg1, double const *farg2) { arg1 = (void *)(farg1); arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetInitStep(arg1,arg2); + result = (int)MRIStepSetNonlinRDiv(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetPostprocessStepFn(void *farg1, ARKPostProcessFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetDeltaGammaMax(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKPostProcessFn arg2 = (ARKPostProcessFn) 0 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKPostProcessFn)(farg2); - result = (int)MRIStepSetPostprocessStepFn(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetDeltaGammaMax(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetPostprocessStageFn(void *farg1, ARKPostProcessFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetLSetupFrequency(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKPostProcessFn arg2 = (ARKPostProcessFn) 0 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKPostProcessFn)(farg2); - result = (int)MRIStepSetPostprocessStageFn(arg1,arg2); + arg2 = (int)(*farg2); + result = (int)MRIStepSetLSetupFrequency(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetPreInnerFn(void *farg1, MRIStepPreInnerFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetPredictorMethod(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - MRIStepPreInnerFn arg2 = (MRIStepPreInnerFn) 0 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (MRIStepPreInnerFn)(farg2); - result = (int)MRIStepSetPreInnerFn(arg1,arg2); + arg2 = (int)(*farg2); + result = (int)MRIStepSetPredictorMethod(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetPostInnerFn(void *farg1, MRIStepPostInnerFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetMaxNonlinIters(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - MRIStepPostInnerFn arg2 = (MRIStepPostInnerFn) 0 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (MRIStepPostInnerFn)(farg2); - result = (int)MRIStepSetPostInnerFn(arg1,arg2); + arg2 = (int)(*farg2); + result = (int)MRIStepSetMaxNonlinIters(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetStagePredictFn(void *farg1, ARKStagePredictFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetNonlinConvCoef(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKStagePredictFn arg2 = (ARKStagePredictFn) 0 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKStagePredictFn)(farg2); - result = (int)MRIStepSetStagePredictFn(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetNonlinConvCoef(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetDeduceImplicitRhs(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetMaxHnilWarns(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; int arg2 ; @@ -1303,211 +1401,191 @@ SWIGEXPORT int _wrap_FMRIStepSetDeduceImplicitRhs(void *farg1, int const *farg2) arg1 = (void *)(farg1); arg2 = (int)(*farg2); - result = (int)MRIStepSetDeduceImplicitRhs(arg1,arg2); + result = (int)MRIStepSetMaxHnilWarns(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetFastErrorStepFactor(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetInterpolateStopTime(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetFastErrorStepFactor(arg1,arg2); + arg2 = (int)(*farg2); + result = (int)MRIStepSetInterpolateStopTime(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetJacFn(void *farg1, ARKLsJacFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetStopTime(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKLsJacFn arg2 = (ARKLsJacFn) 0 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKLsJacFn)(farg2); - result = (int)MRIStepSetJacFn(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetStopTime(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetJacEvalFrequency(void *farg1, long const *farg2) { +SWIGEXPORT int _wrap_FMRIStepClearStopTime(void *farg1) { int fresult ; void *arg1 = (void *) 0 ; - long arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (long)(*farg2); - result = (int)MRIStepSetJacEvalFrequency(arg1,arg2); + result = (int)MRIStepClearStopTime(arg1); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetLinearSolutionScaling(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetFixedStep(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - result = (int)MRIStepSetLinearSolutionScaling(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetFixedStep(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetEpsLin(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetRootDirection(void *farg1, int *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; + int *arg2 = (int *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetEpsLin(arg1,arg2); + arg2 = (int *)(farg2); + result = (int)MRIStepSetRootDirection(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetLSNormFactor(void *farg1, double const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetNoInactiveRootWarn(void *farg1) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - result = (int)MRIStepSetLSNormFactor(arg1,arg2); + result = (int)MRIStepSetNoInactiveRootWarn(arg1); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetPreconditioner(void *farg1, ARKLsPrecSetupFn farg2, ARKLsPrecSolveFn farg3) { +SWIGEXPORT int _wrap_FMRIStepSetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKLsPrecSetupFn arg2 = (ARKLsPrecSetupFn) 0 ; - ARKLsPrecSolveFn arg3 = (ARKLsPrecSolveFn) 0 ; + void *arg2 = (void *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKLsPrecSetupFn)(farg2); - arg3 = (ARKLsPrecSolveFn)(farg3); - result = (int)MRIStepSetPreconditioner(arg1,arg2,arg3); + arg2 = (void *)(farg2); + result = (int)MRIStepSetUserData(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetJacTimes(void *farg1, ARKLsJacTimesSetupFn farg2, ARKLsJacTimesVecFn farg3) { +SWIGEXPORT int _wrap_FMRIStepSetPostprocessStepFn(void *farg1, ARKPostProcessFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKLsJacTimesSetupFn arg2 = (ARKLsJacTimesSetupFn) 0 ; - ARKLsJacTimesVecFn arg3 = (ARKLsJacTimesVecFn) 0 ; + ARKPostProcessFn arg2 = (ARKPostProcessFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKLsJacTimesSetupFn)(farg2); - arg3 = (ARKLsJacTimesVecFn)(farg3); - result = (int)MRIStepSetJacTimes(arg1,arg2,arg3); + arg2 = (ARKPostProcessFn)(farg2); + result = (int)MRIStepSetPostprocessStepFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetJacTimesRhsFn(void *farg1, ARKRhsFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetPostprocessStageFn(void *farg1, ARKPostProcessFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKRhsFn arg2 = (ARKRhsFn) 0 ; + ARKPostProcessFn arg2 = (ARKPostProcessFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKRhsFn)(farg2); - result = (int)MRIStepSetJacTimesRhsFn(arg1,arg2); + arg2 = (ARKPostProcessFn)(farg2); + result = (int)MRIStepSetPostprocessStageFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetLinSysFn(void *farg1, ARKLsLinSysFn farg2) { +SWIGEXPORT int _wrap_FMRIStepSetStagePredictFn(void *farg1, ARKStagePredictFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKLsLinSysFn arg2 = (ARKLsLinSysFn) 0 ; + ARKStagePredictFn arg2 = (ARKStagePredictFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKLsLinSysFn)(farg2); - result = (int)MRIStepSetLinSysFn(arg1,arg2); + arg2 = (ARKStagePredictFn)(farg2); + result = (int)MRIStepSetStagePredictFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepEvolve(void *farg1, double const *farg2, N_Vector farg3, double *farg4, int const *farg5) { +SWIGEXPORT int _wrap_FMRIStepSetDeduceImplicitRhs(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - N_Vector arg3 = (N_Vector) 0 ; - sunrealtype *arg4 = (sunrealtype *) 0 ; - int arg5 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (N_Vector)(farg3); - arg4 = (sunrealtype *)(farg4); - arg5 = (int)(*farg5); - result = (int)MRIStepEvolve(arg1,arg2,arg3,arg4,arg5); + arg2 = (int)(*farg2); + result = (int)MRIStepSetDeduceImplicitRhs(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetDky(void *farg1, double const *farg2, int const *farg3, N_Vector farg4) { +SWIGEXPORT int _wrap_FMRIStepSetJacFn(void *farg1, ARKLsJacFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - int arg3 ; - N_Vector arg4 = (N_Vector) 0 ; + ARKLsJacFn arg2 = (ARKLsJacFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (int)(*farg3); - arg4 = (N_Vector)(farg4); - result = (int)MRIStepGetDky(arg1,arg2,arg3,arg4); + arg2 = (ARKLsJacFn)(farg2); + result = (int)MRIStepSetJacFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepComputeState(void *farg1, N_Vector farg2, N_Vector farg3) { +SWIGEXPORT int _wrap_FMRIStepSetJacEvalFrequency(void *farg1, long const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - N_Vector arg2 = (N_Vector) 0 ; - N_Vector arg3 = (N_Vector) 0 ; + long arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (N_Vector)(farg2); - arg3 = (N_Vector)(farg3); - result = (int)MRIStepComputeState(arg1,arg2,arg3); + arg2 = (long)(*farg2); + result = (int)MRIStepSetJacEvalFrequency(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepSetAccumulatedErrorType(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetLinearSolutionScaling(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; int arg2 ; @@ -1515,147 +1593,163 @@ SWIGEXPORT int _wrap_FMRIStepSetAccumulatedErrorType(void *farg1, int const *far arg1 = (void *)(farg1); arg2 = (int)(*farg2); - result = (int)MRIStepSetAccumulatedErrorType(arg1,arg2); + result = (int)MRIStepSetLinearSolutionScaling(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepResetAccumulatedError(void *farg1) { +SWIGEXPORT int _wrap_FMRIStepSetEpsLin(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - result = (int)MRIStepResetAccumulatedError(arg1); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetEpsLin(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetAccumulatedError(void *farg1, double *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetLSNormFactor(void *farg1, double const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype *arg2 = (sunrealtype *) 0 ; + sunrealtype arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype *)(farg2); - result = (int)MRIStepGetAccumulatedError(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + result = (int)MRIStepSetLSNormFactor(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetNumExpSteps(void *farg1, long *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetPreconditioner(void *farg1, ARKLsPrecSetupFn farg2, ARKLsPrecSolveFn farg3) { int fresult ; void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; + ARKLsPrecSetupFn arg2 = (ARKLsPrecSetupFn) 0 ; + ARKLsPrecSolveFn arg3 = (ARKLsPrecSolveFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)MRIStepGetNumExpSteps(arg1,arg2); + arg2 = (ARKLsPrecSetupFn)(farg2); + arg3 = (ARKLsPrecSolveFn)(farg3); + result = (int)MRIStepSetPreconditioner(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetNumAccSteps(void *farg1, long *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetJacTimes(void *farg1, ARKLsJacTimesSetupFn farg2, ARKLsJacTimesVecFn farg3) { int fresult ; void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; + ARKLsJacTimesSetupFn arg2 = (ARKLsJacTimesSetupFn) 0 ; + ARKLsJacTimesVecFn arg3 = (ARKLsJacTimesVecFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)MRIStepGetNumAccSteps(arg1,arg2); + arg2 = (ARKLsJacTimesSetupFn)(farg2); + arg3 = (ARKLsJacTimesVecFn)(farg3); + result = (int)MRIStepSetJacTimes(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetNumStepAttempts(void *farg1, long *farg2) { +SWIGEXPORT int _wrap_FMRIStepSetJacTimesRhsFn(void *farg1, ARKRhsFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; + ARKRhsFn arg2 = (ARKRhsFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)MRIStepGetNumStepAttempts(arg1,arg2); + arg2 = (ARKRhsFn)(farg2); + result = (int)MRIStepSetJacTimesRhsFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { +SWIGEXPORT int _wrap_FMRIStepSetLinSysFn(void *farg1, ARKLsLinSysFn farg2) { int fresult ; void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; + ARKLsLinSysFn arg2 = (ARKLsLinSysFn) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)MRIStepGetNumRhsEvals(arg1,arg2,arg3); + arg2 = (ARKLsLinSysFn)(farg2); + result = (int)MRIStepSetLinSysFn(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetNumLinSolvSetups(void *farg1, long *farg2) { +SWIGEXPORT int _wrap_FMRIStepEvolve(void *farg1, double const *farg2, N_Vector farg3, double *farg4, int const *farg5) { int fresult ; void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; + sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; + sunrealtype *arg4 = (sunrealtype *) 0 ; + int arg5 ; int result; arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)MRIStepGetNumLinSolvSetups(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + arg3 = (N_Vector)(farg3); + arg4 = (sunrealtype *)(farg4); + arg5 = (int)(*farg5); + result = (int)MRIStepEvolve(arg1,arg2,arg3,arg4,arg5); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetNumErrTestFails(void *farg1, long *farg2) { +SWIGEXPORT int _wrap_FMRIStepGetDky(void *farg1, double const *farg2, int const *farg3, N_Vector farg4) { int fresult ; void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; + sunrealtype arg2 ; + int arg3 ; + N_Vector arg4 = (N_Vector) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)MRIStepGetNumErrTestFails(arg1,arg2); + arg2 = (sunrealtype)(*farg2); + arg3 = (int)(*farg3); + arg4 = (N_Vector)(farg4); + result = (int)MRIStepGetDky(arg1,arg2,arg3,arg4); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetCurrentCoupling(void *farg1, void *farg2) { +SWIGEXPORT int _wrap_FMRIStepComputeState(void *farg1, N_Vector farg2, N_Vector farg3) { int fresult ; void *arg1 = (void *) 0 ; - MRIStepCoupling *arg2 = (MRIStepCoupling *) 0 ; + N_Vector arg2 = (N_Vector) 0 ; + N_Vector arg3 = (N_Vector) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (MRIStepCoupling *)(farg2); - result = (int)MRIStepGetCurrentCoupling(arg1,arg2); + arg2 = (N_Vector)(farg2); + arg3 = (N_Vector)(farg3); + result = (int)MRIStepComputeState(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FMRIStepGetEstLocalErrors(void *farg1, N_Vector farg2) { +SWIGEXPORT int _wrap_FMRIStepGetNumLinSolvSetups(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; - N_Vector arg2 = (N_Vector) 0 ; + long *arg2 = (long *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (N_Vector)(farg2); - result = (int)MRIStepGetEstLocalErrors(arg1,arg2); + arg2 = (long *)(farg2); + result = (int)MRIStepGetNumLinSolvSetups(arg1,arg2); fresult = (int)(result); return fresult; } @@ -1691,20 +1785,6 @@ SWIGEXPORT int _wrap_FMRIStepGetNumSteps(void *farg1, long *farg2) { } -SWIGEXPORT int _wrap_FMRIStepGetActualInitStep(void *farg1, double *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - sunrealtype *arg2 = (sunrealtype *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (sunrealtype *)(farg2); - result = (int)MRIStepGetActualInitStep(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepGetLastStep(void *farg1, double *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1719,20 +1799,6 @@ SWIGEXPORT int _wrap_FMRIStepGetLastStep(void *farg1, double *farg2) { } -SWIGEXPORT int _wrap_FMRIStepGetCurrentStep(void *farg1, double *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - sunrealtype *arg2 = (sunrealtype *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (sunrealtype *)(farg2); - result = (int)MRIStepGetCurrentStep(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepGetCurrentTime(void *farg1, double *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -1831,34 +1897,6 @@ SWIGEXPORT int _wrap_FMRIStepGetRootInfo(void *farg1, int *farg2) { } -SWIGEXPORT int _wrap_FMRIStepGetNumConstrFails(void *farg1, long *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - result = (int)MRIStepGetNumConstrFails(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepGetLastInnerStepFlag(void *farg1, int *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - int *arg2 = (int *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (int *)(farg2); - result = (int)MRIStepGetLastInnerStepFlag(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FMRIStepGetUserData(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -2229,192 +2267,4 @@ SWIGEXPORT void _wrap_FMRIStepPrintMem(void *farg1, void *farg2) { } -SWIGEXPORT int _wrap_FMRIStepInnerStepper_Create(void *farg1, void *farg2) { - int fresult ; - SUNContext arg1 = (SUNContext) 0 ; - MRIStepInnerStepper *arg2 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (SUNContext)(farg1); - arg2 = (MRIStepInnerStepper *)(farg2); - result = (int)MRIStepInnerStepper_Create(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_Free(void *farg1) { - int fresult ; - MRIStepInnerStepper *arg1 = (MRIStepInnerStepper *) 0 ; - int result; - - arg1 = (MRIStepInnerStepper *)(farg1); - result = (int)MRIStepInnerStepper_Free(arg1); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetContent(void *farg1, void *farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - void *arg2 = (void *) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (void *)(farg2); - result = (int)MRIStepInnerStepper_SetContent(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetContent(void *farg1, void *farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - void **arg2 = (void **) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (void **)(farg2); - result = (int)MRIStepInnerStepper_GetContent(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetEvolveFn(void *farg1, MRIStepInnerEvolveFn farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerEvolveFn arg2 = (MRIStepInnerEvolveFn) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerEvolveFn)(farg2); - result = (int)MRIStepInnerStepper_SetEvolveFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFullRhsFn(void *farg1, MRIStepInnerFullRhsFn farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerFullRhsFn arg2 = (MRIStepInnerFullRhsFn) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerFullRhsFn)(farg2); - result = (int)MRIStepInnerStepper_SetFullRhsFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetResetFn(void *farg1, MRIStepInnerResetFn farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerResetFn arg2 = (MRIStepInnerResetFn) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerResetFn)(farg2); - result = (int)MRIStepInnerStepper_SetResetFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(void *farg1, MRIStepInnerGetAccumulatedError farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerGetAccumulatedError arg2 = (MRIStepInnerGetAccumulatedError) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerGetAccumulatedError)(farg2); - result = (int)MRIStepInnerStepper_SetAccumulatedErrorGetFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(void *farg1, MRIStepInnerResetAccumulatedError farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerResetAccumulatedError arg2 = (MRIStepInnerResetAccumulatedError) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerResetAccumulatedError)(farg2); - result = (int)MRIStepInnerStepper_SetAccumulatedErrorResetFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetFixedStepFn(void *farg1, MRIStepInnerSetFixedStep farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerSetFixedStep arg2 = (MRIStepInnerSetFixedStep) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerSetFixedStep)(farg2); - result = (int)MRIStepInnerStepper_SetFixedStepFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_SetRTolFn(void *farg1, MRIStepInnerSetRTol farg2) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - MRIStepInnerSetRTol arg2 = (MRIStepInnerSetRTol) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (MRIStepInnerSetRTol)(farg2); - result = (int)MRIStepInnerStepper_SetRTolFn(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_AddForcing(void *farg1, double const *farg2, N_Vector farg3) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - sunrealtype arg2 ; - N_Vector arg3 = (N_Vector) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (N_Vector)(farg3); - result = (int)MRIStepInnerStepper_AddForcing(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - -SWIGEXPORT int _wrap_FMRIStepInnerStepper_GetForcingData(void *farg1, double *farg2, double *farg3, void *farg4, int *farg5) { - int fresult ; - MRIStepInnerStepper arg1 = (MRIStepInnerStepper) 0 ; - sunrealtype *arg2 = (sunrealtype *) 0 ; - sunrealtype *arg3 = (sunrealtype *) 0 ; - N_Vector **arg4 = (N_Vector **) 0 ; - int *arg5 = (int *) 0 ; - int result; - - arg1 = (MRIStepInnerStepper)(farg1); - arg2 = (sunrealtype *)(farg2); - arg3 = (sunrealtype *)(farg3); - arg4 = (N_Vector **)(farg4); - arg5 = (int *)(farg5); - result = (int)MRIStepInnerStepper_GetForcingData(arg1,arg2,arg3,arg4,arg5); - fresult = (int)(result); - return fresult; -} - - diff --git a/src/arkode/fmod/farkode_mristep_mod.f90 b/src/arkode/fmod/farkode_mristep_mod.f90 index 1aaecffe87..4f9ed97c47 100644 --- a/src/arkode/fmod/farkode_mristep_mod.f90 +++ b/src/arkode/fmod/farkode_mristep_mod.f90 @@ -31,9 +31,11 @@ module farkode_mristep_mod enumerator :: MRISTEP_EXPLICIT enumerator :: MRISTEP_IMPLICIT enumerator :: MRISTEP_IMEX + enumerator :: MRISTEP_MERK + enumerator :: MRISTEP_MRISR end enum integer, parameter, public :: MRISTEP_METHOD_TYPE = kind(MRISTEP_EXPLICIT) - public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX + public :: MRISTEP_EXPLICIT, MRISTEP_IMPLICIT, MRISTEP_IMEX, MRISTEP_MERK, MRISTEP_MRISR ! typedef enum ARKODE_MRITableID enum, bind(c) enumerator :: ARKODE_MRI_NONE = -1 @@ -49,23 +51,35 @@ module farkode_mristep_mod enumerator :: ARKODE_IMEX_MRI_GARK4 enumerator :: ARKODE_MRI_GARK_ERK22a enumerator :: ARKODE_MRI_GARK_ERK22b - enumerator :: ARKODE_MAX_MRI_NUM = ARKODE_MRI_GARK_ERK22b + enumerator :: ARKODE_MERK21 + enumerator :: ARKODE_MERK32 + enumerator :: ARKODE_MERK43 + enumerator :: ARKODE_MERK54 + enumerator :: ARKODE_IMEX_MRI_SR21 + enumerator :: ARKODE_IMEX_MRI_SR32 + enumerator :: ARKODE_IMEX_MRI_SR43 + enumerator :: ARKODE_MAX_MRI_NUM = ARKODE_IMEX_MRI_SR43 end enum integer, parameter, public :: ARKODE_MRITableID = kind(ARKODE_MRI_NONE) public :: ARKODE_MRI_NONE, ARKODE_MIN_MRI_NUM, ARKODE_MIS_KW3, ARKODE_MRI_GARK_ERK33a, ARKODE_MRI_GARK_ERK45a, & ARKODE_MRI_GARK_IRK21a, ARKODE_MRI_GARK_ESDIRK34a, ARKODE_MRI_GARK_ESDIRK46a, ARKODE_IMEX_MRI_GARK3a, & - ARKODE_IMEX_MRI_GARK3b, ARKODE_IMEX_MRI_GARK4, ARKODE_MRI_GARK_ERK22a, ARKODE_MRI_GARK_ERK22b, ARKODE_MAX_MRI_NUM + ARKODE_IMEX_MRI_GARK3b, ARKODE_IMEX_MRI_GARK4, ARKODE_MRI_GARK_ERK22a, ARKODE_MRI_GARK_ERK22b, ARKODE_MERK21, ARKODE_MERK32, & + ARKODE_MERK43, ARKODE_MERK54, ARKODE_IMEX_MRI_SR21, ARKODE_IMEX_MRI_SR32, ARKODE_IMEX_MRI_SR43, ARKODE_MAX_MRI_NUM integer(C_INT), parameter, public :: MRISTEP_DEFAULT_3 = ARKODE_MIS_KW3 - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_3_AD = ARKODE_MRI_GARK_ERK33a - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2 = ARKODE_MRI_GARK_ERK22a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3 = ARKODE_MIS_KW3 - integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4 = ARKODE_MRI_GARK_ERK45a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_2 = ARKODE_MRI_GARK_IRK21a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_3 = ARKODE_MRI_GARK_ESDIRK34a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMPL_SD_4 = ARKODE_MRI_GARK_ESDIRK46a integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3 = ARKODE_IMEX_MRI_GARK3b integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4 = ARKODE_IMEX_MRI_GARK4 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_2_AD = ARKODE_MRI_GARK_ERK22a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_3_AD = ARKODE_MRI_GARK_ERK33a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_4_AD = ARKODE_MRI_GARK_ERK45a + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_EXPL_5_AD = ARKODE_MERK54 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_2_AD = ARKODE_IMEX_MRI_SR21 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_3_AD = ARKODE_IMEX_MRI_SR32 + integer(C_INT), parameter, public :: MRISTEP_DEFAULT_IMEX_SD_4_AD = ARKODE_IMEX_MRI_SR43 integer, parameter :: swig_cmem_own_bit = 0 integer, parameter :: swig_cmem_rvalue_bit = 1 @@ -78,6 +92,8 @@ module farkode_mristep_mod type, public :: MRIStepCouplingMem type(SwigClassWrapper), public :: swigdata contains + procedure :: set_type => swigf_MRIStepCouplingMem_type_set + procedure :: get_type => swigf_MRIStepCouplingMem_type_get procedure :: set_nmat => swigf_MRIStepCouplingMem_nmat_set procedure :: get_nmat => swigf_MRIStepCouplingMem_nmat_get procedure :: set_stages => swigf_MRIStepCouplingMem_stages_set @@ -92,6 +108,10 @@ module farkode_mristep_mod procedure :: get_W => swigf_MRIStepCouplingMem_W_get procedure :: set_G => swigf_MRIStepCouplingMem_G_set procedure :: get_G => swigf_MRIStepCouplingMem_G_get + procedure :: set_ngroup => swigf_MRIStepCouplingMem_ngroup_set + procedure :: get_ngroup => swigf_MRIStepCouplingMem_ngroup_get + procedure :: set_group => swigf_MRIStepCouplingMem_group_set + procedure :: get_group => swigf_MRIStepCouplingMem_group_get procedure :: release => swigf_release_MRIStepCouplingMem procedure, private :: swigf_MRIStepCouplingMem_op_assign__ generic :: assignment(=) => swigf_MRIStepCouplingMem_op_assign__ @@ -113,8 +133,29 @@ module farkode_mristep_mod public :: FMRIStepCoupling_Free public :: FMRIStepCoupling_Write public :: FMRIStepCreate - public :: FMRIStepResize public :: FMRIStepReInit + public :: FMRIStepSetCoupling + public :: FMRIStepSetPreInnerFn + public :: FMRIStepSetPostInnerFn + public :: FMRIStepSetFastErrorStepFactor + public :: FMRIStepSetAdaptController + public :: FMRIStepGetNumRhsEvals + public :: FMRIStepGetCurrentCoupling + public :: FMRIStepGetLastInnerStepFlag + public :: FMRIStepInnerStepper_Create + public :: FMRIStepInnerStepper_Free + public :: FMRIStepInnerStepper_SetContent + public :: FMRIStepInnerStepper_GetContent + public :: FMRIStepInnerStepper_SetEvolveFn + public :: FMRIStepInnerStepper_SetFullRhsFn + public :: FMRIStepInnerStepper_SetResetFn + public :: FMRIStepInnerStepper_SetAccumulatedErrorGetFn + public :: FMRIStepInnerStepper_SetAccumulatedErrorResetFn + public :: FMRIStepInnerStepper_SetFixedStepFn + public :: FMRIStepInnerStepper_SetRTolFn + public :: FMRIStepInnerStepper_AddForcing + public :: FMRIStepInnerStepper_GetForcingData + public :: FMRIStepResize public :: FMRIStepReset public :: FMRIStepSStolerances public :: FMRIStepSVtolerances @@ -130,8 +171,6 @@ module farkode_mristep_mod public :: FMRIStepSetNlsRhsFn public :: FMRIStepSetLinear public :: FMRIStepSetNonlinear - public :: FMRIStepSetCoupling - public :: FMRIStepSetAdaptController public :: FMRIStepSetMaxNumSteps public :: FMRIStepSetNonlinCRDown public :: FMRIStepSetNonlinRDiv @@ -141,25 +180,17 @@ module farkode_mristep_mod public :: FMRIStepSetMaxNonlinIters public :: FMRIStepSetNonlinConvCoef public :: FMRIStepSetMaxHnilWarns - public :: FMRIStepSetStopTime public :: FMRIStepSetInterpolateStopTime + public :: FMRIStepSetStopTime public :: FMRIStepClearStopTime public :: FMRIStepSetFixedStep public :: FMRIStepSetRootDirection public :: FMRIStepSetNoInactiveRootWarn public :: FMRIStepSetUserData - public :: FMRIStepSetMaxErrTestFails - public :: FMRIStepSetMaxConvFails - public :: FMRIStepSetConstraints - public :: FMRIStepSetMaxNumConstrFails - public :: FMRIStepSetInitStep public :: FMRIStepSetPostprocessStepFn public :: FMRIStepSetPostprocessStageFn - public :: FMRIStepSetPreInnerFn - public :: FMRIStepSetPostInnerFn public :: FMRIStepSetStagePredictFn public :: FMRIStepSetDeduceImplicitRhs - public :: FMRIStepSetFastErrorStepFactor public :: FMRIStepSetJacFn public :: FMRIStepSetJacEvalFrequency public :: FMRIStepSetLinearSolutionScaling @@ -172,22 +203,10 @@ module farkode_mristep_mod public :: FMRIStepEvolve public :: FMRIStepGetDky public :: FMRIStepComputeState - public :: FMRIStepSetAccumulatedErrorType - public :: FMRIStepResetAccumulatedError - public :: FMRIStepGetAccumulatedError - public :: FMRIStepGetNumExpSteps - public :: FMRIStepGetNumAccSteps - public :: FMRIStepGetNumStepAttempts - public :: FMRIStepGetNumRhsEvals public :: FMRIStepGetNumLinSolvSetups - public :: FMRIStepGetNumErrTestFails - public :: FMRIStepGetCurrentCoupling - public :: FMRIStepGetEstLocalErrors public :: FMRIStepGetWorkSpace public :: FMRIStepGetNumSteps - public :: FMRIStepGetActualInitStep public :: FMRIStepGetLastStep - public :: FMRIStepGetCurrentStep public :: FMRIStepGetCurrentTime public :: FMRIStepGetCurrentState public :: FMRIStepGetCurrentGamma @@ -195,8 +214,6 @@ module farkode_mristep_mod public :: FMRIStepGetErrWeights public :: FMRIStepGetNumGEvals public :: FMRIStepGetRootInfo - public :: FMRIStepGetNumConstrFails - public :: FMRIStepGetLastInnerStepFlag public :: FMRIStepGetUserData public :: FMRIStepPrintAllStats public :: FMRIStepGetReturnFlagName @@ -223,22 +240,26 @@ module farkode_mristep_mod public :: FMRIStepGetLinReturnFlagName public :: FMRIStepFree public :: FMRIStepPrintMem - public :: FMRIStepInnerStepper_Create - public :: FMRIStepInnerStepper_Free - public :: FMRIStepInnerStepper_SetContent - public :: FMRIStepInnerStepper_GetContent - public :: FMRIStepInnerStepper_SetEvolveFn - public :: FMRIStepInnerStepper_SetFullRhsFn - public :: FMRIStepInnerStepper_SetResetFn - public :: FMRIStepInnerStepper_SetAccumulatedErrorGetFn - public :: FMRIStepInnerStepper_SetAccumulatedErrorResetFn - public :: FMRIStepInnerStepper_SetFixedStepFn - public :: FMRIStepInnerStepper_SetRTolFn - public :: FMRIStepInnerStepper_AddForcing - public :: FMRIStepInnerStepper_GetForcingData ! WRAPPER DECLARATIONS interface +subroutine swigc_MRIStepCouplingMem_type_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_type_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_type_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_type_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + subroutine swigc_MRIStepCouplingMem_nmat_set(farg1, farg2) & bind(C, name="_wrap_MRIStepCouplingMem_nmat_set") use, intrinsic :: ISO_C_BINDING @@ -358,6 +379,40 @@ function swigc_MRIStepCouplingMem_G_get(farg1) & type(C_PTR) :: fresult end function +subroutine swigc_MRIStepCouplingMem_ngroup_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_ngroup_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT), intent(in) :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_ngroup_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_ngroup_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: fresult +end function + +subroutine swigc_MRIStepCouplingMem_group_set(farg1, farg2) & +bind(C, name="_wrap_MRIStepCouplingMem_group_set") +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR), value :: farg2 +end subroutine + +function swigc_MRIStepCouplingMem_group_get(farg1) & +bind(C, name="_wrap_MRIStepCouplingMem_group_get") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +import :: swigclasswrapper +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: fresult +end function + function swigc_new_MRIStepCouplingMem() & bind(C, name="_wrap_new_MRIStepCouplingMem") & result(fresult) @@ -474,18 +529,6 @@ function swigc_FMRIStepCreate(farg1, farg2, farg3, farg4, farg5, farg6) & type(C_PTR) :: fresult end function -function swigc_FMRIStepResize(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FMRIStepResize") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -real(C_DOUBLE), intent(in) :: farg3 -type(C_FUNPTR), value :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult -end function - function swigc_FMRIStepReInit(farg1, farg2, farg3, farg4, farg5) & bind(C, name="_wrap_FMRIStepReInit") & result(fresult) @@ -498,111 +541,107 @@ function swigc_FMRIStepReInit(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function -function swigc_FMRIStepReset(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepReset") & +function swigc_FMRIStepSetCoupling(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetCoupling") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -type(C_PTR), value :: farg3 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSStolerances(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepSStolerances") & +function swigc_FMRIStepSetPreInnerFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetPreInnerFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -real(C_DOUBLE), intent(in) :: farg3 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSVtolerances(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepSVtolerances") & +function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetPostInnerFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -type(C_PTR), value :: farg3 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepWFtolerances(farg1, farg2) & -bind(C, name="_wrap_FMRIStepWFtolerances") & +function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetFastErrorStepFactor") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetLinearSolver(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepSetLinearSolver") & +function swigc_FMRIStepSetAdaptController(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetAdaptController") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepRootInit(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepRootInit") & +function swigc_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepGetNumRhsEvals") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_FUNPTR), value :: farg3 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetDefaults(farg1) & -bind(C, name="_wrap_FMRIStepSetDefaults") & +function swigc_FMRIStepGetCurrentCoupling(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetCurrentCoupling") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetOrder(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetOrder") & +function swigc_FMRIStepGetLastInnerStepFlag(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetLastInnerStepFlag") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetInterpolantType(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetInterpolantType") & +function swigc_FMRIStepInnerStepper_Create(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_Create") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetInterpolantDegree(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetInterpolantDegree") & +function swigc_FMRIStepInnerStepper_Free(farg1) & +bind(C, name="_wrap_FMRIStepInnerStepper_Free") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetDenseOrder(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetDenseOrder") & +function swigc_FMRIStepInnerStepper_SetContent(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetContent") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNonlinearSolver(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetNonlinearSolver") & +function swigc_FMRIStepInnerStepper_GetContent(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_GetContent") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -610,8 +649,8 @@ function swigc_FMRIStepSetNonlinearSolver(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNlsRhsFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetNlsRhsFn") & +function swigc_FMRIStepInnerStepper_SetEvolveFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetEvolveFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -619,275 +658,288 @@ function swigc_FMRIStepSetNlsRhsFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetLinear(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetLinear") & +function swigc_FMRIStepInnerStepper_SetFullRhsFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetFullRhsFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNonlinear(farg1) & -bind(C, name="_wrap_FMRIStepSetNonlinear") & +function swigc_FMRIStepInnerStepper_SetResetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetResetFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetCoupling(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetCoupling") & +function swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetAdaptController(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetAdaptController") & +function swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetMaxNumSteps(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetMaxNumSteps") & +function swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetFixedStepFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_LONG), intent(in) :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNonlinCRDown(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetNonlinCRDown") & +function swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepInnerStepper_SetRTolFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNonlinRDiv(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetNonlinRDiv") & +function swigc_FMRIStepInnerStepper_AddForcing(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepInnerStepper_AddForcing") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetDeltaGammaMax(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetDeltaGammaMax") & +function swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FMRIStepInnerStepper_GetForcingData") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetLSetupFrequency(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetLSetupFrequency") & +function swigc_FMRIStepResize(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FMRIStepResize") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg3 +type(C_FUNPTR), value :: farg4 +type(C_PTR), value :: farg5 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetPredictorMethod(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetPredictorMethod") & +function swigc_FMRIStepReset(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepReset") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetMaxNonlinIters(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetMaxNonlinIters") & +function swigc_FMRIStepSStolerances(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepSStolerances") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNonlinConvCoef(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetNonlinConvCoef") & +function swigc_FMRIStepSVtolerances(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepSVtolerances") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetMaxHnilWarns(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetMaxHnilWarns") & +function swigc_FMRIStepWFtolerances(farg1, farg2) & +bind(C, name="_wrap_FMRIStepWFtolerances") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetStopTime(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetStopTime") & +function swigc_FMRIStepSetLinearSolver(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepSetLinearSolver") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetInterpolateStopTime(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetInterpolateStopTime") & +function swigc_FMRIStepRootInit(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepRootInit") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 +type(C_FUNPTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepClearStopTime(farg1) & -bind(C, name="_wrap_FMRIStepClearStopTime") & +function swigc_FMRIStepSetDefaults(farg1) & +bind(C, name="_wrap_FMRIStepSetDefaults") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetFixedStep(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetFixedStep") & +function swigc_FMRIStepSetOrder(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetOrder") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetRootDirection(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetRootDirection") & +function swigc_FMRIStepSetInterpolantType(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetInterpolantType") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetNoInactiveRootWarn(farg1) & -bind(C, name="_wrap_FMRIStepSetNoInactiveRootWarn") & +function swigc_FMRIStepSetInterpolantDegree(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetInterpolantDegree") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetUserData(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetUserData") & +function swigc_FMRIStepSetDenseOrder(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetDenseOrder") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetMaxErrTestFails(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetMaxErrTestFails") & +function swigc_FMRIStepSetNonlinearSolver(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetNonlinearSolver") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetMaxConvFails(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetMaxConvFails") & +function swigc_FMRIStepSetNlsRhsFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetNlsRhsFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetConstraints(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetConstraints") & +function swigc_FMRIStepSetLinear(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetLinear") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetMaxNumConstrFails(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetMaxNumConstrFails") & +function swigc_FMRIStepSetNonlinear(farg1) & +bind(C, name="_wrap_FMRIStepSetNonlinear") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetInitStep(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetInitStep") & +function swigc_FMRIStepSetMaxNumSteps(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetMaxNumSteps") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 +integer(C_LONG), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetPostprocessStepFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetPostprocessStepFn") & +function swigc_FMRIStepSetNonlinCRDown(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetNonlinCRDown") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetPostprocessStageFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetPostprocessStageFn") & +function swigc_FMRIStepSetNonlinRDiv(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetNonlinRDiv") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetPreInnerFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetPreInnerFn") & +function swigc_FMRIStepSetDeltaGammaMax(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetDeltaGammaMax") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetPostInnerFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetPostInnerFn") & +function swigc_FMRIStepSetLSetupFrequency(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetLSetupFrequency") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetStagePredictFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetStagePredictFn") & +function swigc_FMRIStepSetPredictorMethod(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetPredictorMethod") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetDeduceImplicitRhs(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetDeduceImplicitRhs") & +function swigc_FMRIStepSetMaxNonlinIters(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetMaxNonlinIters") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -895,8 +947,8 @@ function swigc_FMRIStepSetDeduceImplicitRhs(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetFastErrorStepFactor") & +function swigc_FMRIStepSetNonlinConvCoef(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetNonlinConvCoef") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -904,44 +956,43 @@ function swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetJacFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetJacFn") & +function swigc_FMRIStepSetMaxHnilWarns(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetMaxHnilWarns") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetJacEvalFrequency(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetJacEvalFrequency") & +function swigc_FMRIStepSetInterpolateStopTime(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetInterpolateStopTime") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_LONG), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetLinearSolutionScaling(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetLinearSolutionScaling") & +function swigc_FMRIStepSetStopTime(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetStopTime") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetEpsLin(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetEpsLin") & +function swigc_FMRIStepClearStopTime(farg1) & +bind(C, name="_wrap_FMRIStepClearStopTime") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetLSNormFactor(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetLSNormFactor") & +function swigc_FMRIStepSetFixedStep(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetFixedStep") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -949,37 +1000,34 @@ function swigc_FMRIStepSetLSNormFactor(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepSetPreconditioner(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepSetPreconditioner") & +function swigc_FMRIStepSetRootDirection(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetRootDirection") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -type(C_FUNPTR), value :: farg3 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetJacTimes(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepSetJacTimes") & +function swigc_FMRIStepSetNoInactiveRootWarn(farg1) & +bind(C, name="_wrap_FMRIStepSetNoInactiveRootWarn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -type(C_FUNPTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetJacTimesRhsFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetJacTimesRhsFn") & +function swigc_FMRIStepSetUserData(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetUserData") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetLinSysFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetLinSysFn") & +function swigc_FMRIStepSetPostprocessStepFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetPostprocessStepFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -987,140 +1035,141 @@ function swigc_FMRIStepSetLinSysFn(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepEvolve(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FMRIStepEvolve") & +function swigc_FMRIStepSetPostprocessStageFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetPostprocessStageFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -type(C_PTR), value :: farg3 -type(C_PTR), value :: farg4 -integer(C_INT), intent(in) :: farg5 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetDky(farg1, farg2, farg3, farg4) & -bind(C, name="_wrap_FMRIStepGetDky") & +function swigc_FMRIStepSetStagePredictFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetStagePredictFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -integer(C_INT), intent(in) :: farg3 -type(C_PTR), value :: farg4 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepComputeState(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepComputeState") & +function swigc_FMRIStepSetDeduceImplicitRhs(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetDeduceImplicitRhs") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepSetAccumulatedErrorType(farg1, farg2) & -bind(C, name="_wrap_FMRIStepSetAccumulatedErrorType") & +function swigc_FMRIStepSetJacFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetJacFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepResetAccumulatedError(farg1) & -bind(C, name="_wrap_FMRIStepResetAccumulatedError") & +function swigc_FMRIStepSetJacEvalFrequency(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetJacEvalFrequency") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 +integer(C_LONG), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetAccumulatedError(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetAccumulatedError") & +function swigc_FMRIStepSetLinearSolutionScaling(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetLinearSolutionScaling") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumExpSteps(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumExpSteps") & +function swigc_FMRIStepSetEpsLin(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetEpsLin") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumAccSteps(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumAccSteps") & +function swigc_FMRIStepSetLSNormFactor(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetLSNormFactor") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumStepAttempts(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumStepAttempts") & +function swigc_FMRIStepSetPreconditioner(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepSetPreconditioner") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepGetNumRhsEvals") & +function swigc_FMRIStepSetJacTimes(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepSetJacTimes") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 +type(C_FUNPTR), value :: farg2 +type(C_FUNPTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumLinSolvSetups(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumLinSolvSetups") & +function swigc_FMRIStepSetJacTimesRhsFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetJacTimesRhsFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumErrTestFails(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumErrTestFails") & +function swigc_FMRIStepSetLinSysFn(farg1, farg2) & +bind(C, name="_wrap_FMRIStepSetLinSysFn") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +type(C_FUNPTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetCurrentCoupling(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetCurrentCoupling") & +function swigc_FMRIStepEvolve(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FMRIStepEvolve") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +integer(C_INT), intent(in) :: farg5 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetEstLocalErrors(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetEstLocalErrors") & +function swigc_FMRIStepGetDky(farg1, farg2, farg3, farg4) & +bind(C, name="_wrap_FMRIStepGetDky") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 +real(C_DOUBLE), intent(in) :: farg2 +integer(C_INT), intent(in) :: farg3 +type(C_PTR), value :: farg4 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetWorkSpace(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepGetWorkSpace") & +function swigc_FMRIStepComputeState(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepComputeState") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -1129,8 +1178,8 @@ function swigc_FMRIStepGetWorkSpace(farg1, farg2, farg3) & integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumSteps(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumSteps") & +function swigc_FMRIStepGetNumLinSolvSetups(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetNumLinSolvSetups") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -1138,17 +1187,18 @@ function swigc_FMRIStepGetNumSteps(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepGetActualInitStep(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetActualInitStep") & +function swigc_FMRIStepGetWorkSpace(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepGetWorkSpace") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FMRIStepGetLastStep(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetLastStep") & +function swigc_FMRIStepGetNumSteps(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetNumSteps") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -1156,8 +1206,8 @@ function swigc_FMRIStepGetLastStep(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepGetCurrentStep(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetCurrentStep") & +function swigc_FMRIStepGetLastStep(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetLastStep") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -1228,8 +1278,8 @@ function swigc_FMRIStepGetRootInfo(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepGetNumConstrFails(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetNumConstrFails") & +function swigc_FMRIStepGetUserData(farg1, farg2) & +bind(C, name="_wrap_FMRIStepGetUserData") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -1237,31 +1287,13 @@ function swigc_FMRIStepGetNumConstrFails(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FMRIStepGetLastInnerStepFlag(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetLastInnerStepFlag") & +function swigc_FMRIStepPrintAllStats(farg1, farg2, farg3) & +bind(C, name="_wrap_FMRIStepPrintAllStats") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepGetUserData(farg1, farg2) & -bind(C, name="_wrap_FMRIStepGetUserData") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepPrintAllStats(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepPrintAllStats") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT), intent(in) :: farg3 +integer(C_INT), intent(in) :: farg3 integer(C_INT) :: fresult end function @@ -1489,131 +1521,36 @@ subroutine swigc_FMRIStepPrintMem(farg1, farg2) & type(C_PTR), value :: farg2 end subroutine -function swigc_FMRIStepInnerStepper_Create(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_Create") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_Free(farg1) & -bind(C, name="_wrap_FMRIStepInnerStepper_Free") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_SetContent(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetContent") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_GetContent(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_GetContent") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_SetEvolveFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetEvolveFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_SetFullRhsFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetFullRhsFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_SetResetFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetResetFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function - -function swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorGetFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function +end interface -function swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetAccumulatedErrorResetFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function -function swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetFixedStepFn") & -result(fresult) +contains + ! MODULE SUBPROGRAMS +subroutine swigf_MRIStepCouplingMem_type_set(self, type) use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function +class(MRIStepCouplingMem), intent(in) :: self +integer(MRISTEP_METHOD_TYPE), intent(in) :: type +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 -function swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) & -bind(C, name="_wrap_FMRIStepInnerStepper_SetRTolFn") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_FUNPTR), value :: farg2 -integer(C_INT) :: fresult -end function +farg1 = self%swigdata +farg2 = type +call swigc_MRIStepCouplingMem_type_set(farg1, farg2) +end subroutine -function swigc_FMRIStepInnerStepper_AddForcing(farg1, farg2, farg3) & -bind(C, name="_wrap_FMRIStepInnerStepper_AddForcing") & -result(fresult) +function swigf_MRIStepCouplingMem_type_get(self) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -type(C_PTR), value :: farg3 -integer(C_INT) :: fresult -end function +integer(MRISTEP_METHOD_TYPE) :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 -function swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, farg5) & -bind(C, name="_wrap_FMRIStepInnerStepper_GetForcingData") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -type(C_PTR), value :: farg4 -type(C_PTR), value :: farg5 -integer(C_INT) :: fresult +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_type_get(farg1) +swig_result = fresult end function -end interface - - -contains - ! MODULE SUBPROGRAMS subroutine swigf_MRIStepCouplingMem_nmat_set(self, nmat) use, intrinsic :: ISO_C_BINDING class(MRIStepCouplingMem), intent(in) :: self @@ -1789,6 +1726,56 @@ function swigf_MRIStepCouplingMem_G_get(self) & call c_f_pointer(fresult, swig_result) end function +subroutine swigf_MRIStepCouplingMem_ngroup_set(self, ngroup) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT), intent(in) :: ngroup +type(SwigClassWrapper) :: farg1 +integer(C_INT) :: farg2 + +farg1 = self%swigdata +farg2 = ngroup +call swigc_MRIStepCouplingMem_ngroup_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_ngroup_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +integer(C_INT) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_ngroup_get(farg1) +swig_result = fresult +end function + +subroutine swigf_MRIStepCouplingMem_group_set(self, group) +use, intrinsic :: ISO_C_BINDING +class(MRIStepCouplingMem), intent(in) :: self +type(C_PTR), target, intent(inout) :: group +type(SwigClassWrapper) :: farg1 +type(C_PTR) :: farg2 + +farg1 = self%swigdata +farg2 = c_loc(group) +call swigc_MRIStepCouplingMem_group_set(farg1, farg2) +end subroutine + +function swigf_MRIStepCouplingMem_group_get(self) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), pointer :: swig_result +class(MRIStepCouplingMem), intent(in) :: self +type(C_PTR) :: fresult +type(SwigClassWrapper) :: farg1 + +farg1 = self%swigdata +fresult = swigc_MRIStepCouplingMem_group_get(farg1) +call c_f_pointer(fresult, swig_result) +end function + function swigf_create_MRIStepCouplingMem() & result(self) use, intrinsic :: ISO_C_BINDING @@ -1959,61 +1946,434 @@ subroutine FMRIStepCoupling_Space(mric, liw, lrw) integer(C_INT64_T), dimension(*), target, intent(inout) :: liw integer(C_INT64_T), dimension(*), target, intent(inout) :: lrw type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = mric +farg2 = c_loc(liw(1)) +farg3 = c_loc(lrw(1)) +call swigc_FMRIStepCoupling_Space(farg1, farg2, farg3) +end subroutine + +subroutine FMRIStepCoupling_Free(mric) +use, intrinsic :: ISO_C_BINDING +type(C_PTR) :: mric +type(C_PTR) :: farg1 + +farg1 = mric +call swigc_FMRIStepCoupling_Free(farg1) +end subroutine + +subroutine FMRIStepCoupling_Write(mric, outfile) +use, intrinsic :: ISO_C_BINDING +type(C_PTR) :: mric +type(C_PTR) :: outfile +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = mric +farg2 = outfile +call swigc_FMRIStepCoupling_Write(farg1, farg2) +end subroutine + +function FMRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(C_PTR) :: swig_result +type(C_FUNPTR), intent(in), value :: fse +type(C_FUNPTR), intent(in), value :: fsi +real(C_DOUBLE), intent(in) :: t0 +type(N_Vector), target, intent(inout) :: y0 +type(C_PTR) :: stepper +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_FUNPTR) :: farg1 +type(C_FUNPTR) :: farg2 +real(C_DOUBLE) :: farg3 +type(C_PTR) :: farg4 +type(C_PTR) :: farg5 +type(C_PTR) :: farg6 + +farg1 = fse +farg2 = fsi +farg3 = t0 +farg4 = c_loc(y0) +farg5 = stepper +farg6 = sunctx +fresult = swigc_FMRIStepCreate(farg1, farg2, farg3, farg4, farg5, farg6) +swig_result = fresult +end function + +function FMRIStepReInit(arkode_mem, fse, fsi, t0, y0) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: fse +type(C_FUNPTR), intent(in), value :: fsi +real(C_DOUBLE), intent(in) :: t0 +type(N_Vector), target, intent(inout) :: y0 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 +type(C_FUNPTR) :: farg3 +real(C_DOUBLE) :: farg4 +type(C_PTR) :: farg5 + +farg1 = arkode_mem +farg2 = fse +farg3 = fsi +farg4 = t0 +farg5 = c_loc(y0) +fresult = swigc_FMRIStepReInit(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FMRIStepSetCoupling(arkode_mem, mric) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: mric +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = mric +fresult = swigc_FMRIStepSetCoupling(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepSetPreInnerFn(arkode_mem, prefn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: prefn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = prefn +fresult = swigc_FMRIStepSetPreInnerFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepSetPostInnerFn(arkode_mem, postfn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_FUNPTR), intent(in), value :: postfn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = arkode_mem +farg2 = postfn +fresult = swigc_FMRIStepSetPostInnerFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepSetFastErrorStepFactor(arkode_mem, hfactor) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: hfactor +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 + +farg1 = arkode_mem +farg2 = hfactor +fresult = swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepSetAdaptController(arkode_mem, c) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(SUNAdaptController), target, intent(inout) :: c +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(c) +fresult = swigc_FMRIStepSetAdaptController(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepGetNumRhsEvals(arkode_mem, nfse_evals, nfsi_evals) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nfse_evals +integer(C_LONG), dimension(*), target, intent(inout) :: nfsi_evals +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(nfse_evals(1)) +farg3 = c_loc(nfsi_evals(1)) +fresult = swigc_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) +swig_result = fresult +end function + +function FMRIStepGetCurrentCoupling(arkode_mem, mric) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: mric +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(mric) +fresult = swigc_FMRIStepGetCurrentCoupling(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepGetLastInnerStepFlag(arkode_mem, flag) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), dimension(*), target, intent(inout) :: flag +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(flag(1)) +fresult = swigc_FMRIStepGetLastInnerStepFlag(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_Create(sunctx, stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: sunctx +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = sunctx +farg2 = c_loc(stepper) +fresult = swigc_FMRIStepInnerStepper_Create(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_Free(stepper) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR), target, intent(inout) :: stepper +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(stepper) +fresult = swigc_FMRIStepInnerStepper_Free(farg1) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetContent(stepper, content) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_PTR) :: content +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = stepper +farg2 = content +fresult = swigc_FMRIStepInnerStepper_SetContent(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_GetContent(stepper, content) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_PTR), target, intent(inout) :: content +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = stepper +farg2 = c_loc(content) +fresult = swigc_FMRIStepInnerStepper_GetContent(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetEvolveFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetEvolveFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetFullRhsFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetFullRhsFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetResetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetResetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetAccumulatedErrorGetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetAccumulatedErrorResetFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 + +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) +swig_result = fresult +end function + +function FMRIStepInnerStepper_SetFixedStepFn(stepper, fn) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 -farg1 = mric -farg2 = c_loc(liw(1)) -farg3 = c_loc(lrw(1)) -call swigc_FMRIStepCoupling_Space(farg1, farg2, farg3) -end subroutine +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) +swig_result = fresult +end function -subroutine FMRIStepCoupling_Free(mric) +function FMRIStepInnerStepper_SetRTolFn(stepper, fn) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR) :: mric +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +type(C_FUNPTR), intent(in), value :: fn +integer(C_INT) :: fresult type(C_PTR) :: farg1 +type(C_FUNPTR) :: farg2 -farg1 = mric -call swigc_FMRIStepCoupling_Free(farg1) -end subroutine +farg1 = stepper +farg2 = fn +fresult = swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) +swig_result = fresult +end function -subroutine FMRIStepCoupling_Write(mric, outfile) +function FMRIStepInnerStepper_AddForcing(stepper, t, f) & +result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR) :: mric -type(C_PTR) :: outfile +integer(C_INT) :: swig_result +type(C_PTR) :: stepper +real(C_DOUBLE), intent(in) :: t +type(N_Vector), target, intent(inout) :: f +integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg3 -farg1 = mric -farg2 = outfile -call swigc_FMRIStepCoupling_Write(farg1, farg2) -end subroutine +farg1 = stepper +farg2 = t +farg3 = c_loc(f) +fresult = swigc_FMRIStepInnerStepper_AddForcing(farg1, farg2, farg3) +swig_result = fresult +end function -function FMRIStepCreate(fse, fsi, t0, y0, stepper, sunctx) & +function FMRIStepInnerStepper_GetForcingData(stepper, tshift, tscale, forcing, nforcing) & result(swig_result) use, intrinsic :: ISO_C_BINDING -type(C_PTR) :: swig_result -type(C_FUNPTR), intent(in), value :: fse -type(C_FUNPTR), intent(in), value :: fsi -real(C_DOUBLE), intent(in) :: t0 -type(N_Vector), target, intent(inout) :: y0 +integer(C_INT) :: swig_result type(C_PTR) :: stepper -type(C_PTR) :: sunctx -type(C_PTR) :: fresult -type(C_FUNPTR) :: farg1 -type(C_FUNPTR) :: farg2 -real(C_DOUBLE) :: farg3 +real(C_DOUBLE), dimension(*), target, intent(inout) :: tshift +real(C_DOUBLE), dimension(*), target, intent(inout) :: tscale +type(C_PTR), target, intent(inout) :: forcing +integer(C_INT), dimension(*), target, intent(inout) :: nforcing +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 type(C_PTR) :: farg4 type(C_PTR) :: farg5 -type(C_PTR) :: farg6 -farg1 = fse -farg2 = fsi -farg3 = t0 -farg4 = c_loc(y0) -farg5 = stepper -farg6 = sunctx -fresult = swigc_FMRIStepCreate(farg1, farg2, farg3, farg4, farg5, farg6) +farg1 = stepper +farg2 = c_loc(tshift(1)) +farg3 = c_loc(tscale(1)) +farg4 = c_loc(forcing) +farg5 = c_loc(nforcing(1)) +fresult = swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, farg5) swig_result = fresult end function @@ -2042,31 +2402,6 @@ function FMRIStepResize(arkode_mem, ynew, t0, resize, resize_data) & swig_result = fresult end function -function FMRIStepReInit(arkode_mem, fse, fsi, t0, y0) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: fse -type(C_FUNPTR), intent(in), value :: fsi -real(C_DOUBLE), intent(in) :: t0 -type(N_Vector), target, intent(inout) :: y0 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 -type(C_FUNPTR) :: farg3 -real(C_DOUBLE) :: farg4 -type(C_PTR) :: farg5 - -farg1 = arkode_mem -farg2 = fse -farg3 = fsi -farg4 = t0 -farg5 = c_loc(y0) -fresult = swigc_FMRIStepReInit(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - function FMRIStepReset(arkode_mem, tr, yr) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2316,38 +2651,6 @@ function FMRIStepSetNonlinear(arkode_mem) & swig_result = fresult end function -function FMRIStepSetCoupling(arkode_mem, mric) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR) :: mric -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = mric -fresult = swigc_FMRIStepSetCoupling(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepSetAdaptController(arkode_mem, c) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(SUNAdaptController), target, intent(inout) :: c -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(c) -fresult = swigc_FMRIStepSetAdaptController(farg1, farg2) -swig_result = fresult -end function - function FMRIStepSetMaxNumSteps(arkode_mem, mxsteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -2452,293 +2755,181 @@ function FMRIStepSetMaxNonlinIters(arkode_mem, maxcor) & integer(C_INT), intent(in) :: maxcor integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = maxcor -fresult = swigc_FMRIStepSetMaxNonlinIters(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepSetNonlinConvCoef(arkode_mem, nlscoef) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: nlscoef -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = arkode_mem -farg2 = nlscoef -fresult = swigc_FMRIStepSetNonlinConvCoef(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepSetMaxHnilWarns(arkode_mem, mxhnil) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: mxhnil -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = mxhnil -fresult = swigc_FMRIStepSetMaxHnilWarns(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepSetStopTime(arkode_mem, tstop) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: tstop -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = arkode_mem -farg2 = tstop -fresult = swigc_FMRIStepSetStopTime(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepSetInterpolateStopTime(arkode_mem, interp) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: interp -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = interp -fresult = swigc_FMRIStepSetInterpolateStopTime(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepClearStopTime(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FMRIStepClearStopTime(farg1) -swig_result = fresult -end function - -function FMRIStepSetFixedStep(arkode_mem, hsfixed) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: hsfixed -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = arkode_mem -farg2 = hsfixed -fresult = swigc_FMRIStepSetFixedStep(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepSetRootDirection(arkode_mem, rootdir) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), dimension(*), target, intent(inout) :: rootdir -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: farg2 farg1 = arkode_mem -farg2 = c_loc(rootdir(1)) -fresult = swigc_FMRIStepSetRootDirection(farg1, farg2) +farg2 = maxcor +fresult = swigc_FMRIStepSetMaxNonlinIters(farg1, farg2) swig_result = fresult end function -function FMRIStepSetNoInactiveRootWarn(arkode_mem) & +function FMRIStepSetNonlinConvCoef(arkode_mem, nlscoef) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem +real(C_DOUBLE), intent(in) :: nlscoef integer(C_INT) :: fresult type(C_PTR) :: farg1 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem -fresult = swigc_FMRIStepSetNoInactiveRootWarn(farg1) +farg2 = nlscoef +fresult = swigc_FMRIStepSetNonlinConvCoef(farg1, farg2) swig_result = fresult end function -function FMRIStepSetUserData(arkode_mem, user_data) & +function FMRIStepSetMaxHnilWarns(arkode_mem, mxhnil) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_PTR) :: user_data +integer(C_INT), intent(in) :: mxhnil integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_PTR) :: farg2 +integer(C_INT) :: farg2 farg1 = arkode_mem -farg2 = user_data -fresult = swigc_FMRIStepSetUserData(farg1, farg2) +farg2 = mxhnil +fresult = swigc_FMRIStepSetMaxHnilWarns(farg1, farg2) swig_result = fresult end function -function FMRIStepSetMaxErrTestFails(arkode_mem, maxnef) & +function FMRIStepSetInterpolateStopTime(arkode_mem, interp) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: maxnef +integer(C_INT), intent(in) :: interp integer(C_INT) :: fresult type(C_PTR) :: farg1 integer(C_INT) :: farg2 farg1 = arkode_mem -farg2 = maxnef -fresult = swigc_FMRIStepSetMaxErrTestFails(farg1, farg2) +farg2 = interp +fresult = swigc_FMRIStepSetInterpolateStopTime(farg1, farg2) swig_result = fresult end function -function FMRIStepSetMaxConvFails(arkode_mem, maxncf) & +function FMRIStepSetStopTime(arkode_mem, tstop) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: maxncf +real(C_DOUBLE), intent(in) :: tstop integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem -farg2 = maxncf -fresult = swigc_FMRIStepSetMaxConvFails(farg1, farg2) +farg2 = tstop +fresult = swigc_FMRIStepSetStopTime(farg1, farg2) swig_result = fresult end function -function FMRIStepSetConstraints(arkode_mem, constraints) & +function FMRIStepClearStopTime(arkode_mem) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(N_Vector), target, intent(inout) :: constraints integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = c_loc(constraints) -fresult = swigc_FMRIStepSetConstraints(farg1, farg2) +fresult = swigc_FMRIStepClearStopTime(farg1) swig_result = fresult end function -function FMRIStepSetMaxNumConstrFails(arkode_mem, maxfails) & +function FMRIStepSetFixedStep(arkode_mem, hsfixed) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: maxfails +real(C_DOUBLE), intent(in) :: hsfixed integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +real(C_DOUBLE) :: farg2 farg1 = arkode_mem -farg2 = maxfails -fresult = swigc_FMRIStepSetMaxNumConstrFails(farg1, farg2) +farg2 = hsfixed +fresult = swigc_FMRIStepSetFixedStep(farg1, farg2) swig_result = fresult end function -function FMRIStepSetInitStep(arkode_mem, hin) & +function FMRIStepSetRootDirection(arkode_mem, rootdir) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: hin +integer(C_INT), dimension(*), target, intent(inout) :: rootdir integer(C_INT) :: fresult type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 +type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = hin -fresult = swigc_FMRIStepSetInitStep(farg1, farg2) +farg2 = c_loc(rootdir(1)) +fresult = swigc_FMRIStepSetRootDirection(farg1, farg2) swig_result = fresult end function -function FMRIStepSetPostprocessStepFn(arkode_mem, processstep) & +function FMRIStepSetNoInactiveRootWarn(arkode_mem) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: processstep integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 farg1 = arkode_mem -farg2 = processstep -fresult = swigc_FMRIStepSetPostprocessStepFn(farg1, farg2) +fresult = swigc_FMRIStepSetNoInactiveRootWarn(farg1) swig_result = fresult end function -function FMRIStepSetPostprocessStageFn(arkode_mem, processstage) & +function FMRIStepSetUserData(arkode_mem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: processstage +type(C_PTR) :: user_data integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 +type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = processstage -fresult = swigc_FMRIStepSetPostprocessStageFn(farg1, farg2) +farg2 = user_data +fresult = swigc_FMRIStepSetUserData(farg1, farg2) swig_result = fresult end function -function FMRIStepSetPreInnerFn(arkode_mem, prefn) & +function FMRIStepSetPostprocessStepFn(arkode_mem, processstep) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: prefn +type(C_FUNPTR), intent(in), value :: processstep integer(C_INT) :: fresult type(C_PTR) :: farg1 type(C_FUNPTR) :: farg2 farg1 = arkode_mem -farg2 = prefn -fresult = swigc_FMRIStepSetPreInnerFn(farg1, farg2) +farg2 = processstep +fresult = swigc_FMRIStepSetPostprocessStepFn(farg1, farg2) swig_result = fresult end function -function FMRIStepSetPostInnerFn(arkode_mem, postfn) & +function FMRIStepSetPostprocessStageFn(arkode_mem, processstage) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_FUNPTR), intent(in), value :: postfn +type(C_FUNPTR), intent(in), value :: processstage integer(C_INT) :: fresult type(C_PTR) :: farg1 type(C_FUNPTR) :: farg2 farg1 = arkode_mem -farg2 = postfn -fresult = swigc_FMRIStepSetPostInnerFn(farg1, farg2) +farg2 = processstage +fresult = swigc_FMRIStepSetPostprocessStageFn(farg1, farg2) swig_result = fresult end function @@ -2774,22 +2965,6 @@ function FMRIStepSetDeduceImplicitRhs(arkode_mem, deduce) & swig_result = fresult end function -function FMRIStepSetFastErrorStepFactor(arkode_mem, hfactor) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), intent(in) :: hfactor -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 - -farg1 = arkode_mem -farg2 = hfactor -fresult = swigc_FMRIStepSetFastErrorStepFactor(farg1, farg2) -swig_result = fresult -end function - function FMRIStepSetJacFn(arkode_mem, jac) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3006,118 +3181,6 @@ function FMRIStepComputeState(arkode_mem, zcor, z) & swig_result = fresult end function -function FMRIStepSetAccumulatedErrorType(arkode_mem, accum_type) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: accum_type -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -integer(C_INT) :: farg2 - -farg1 = arkode_mem -farg2 = accum_type -fresult = swigc_FMRIStepSetAccumulatedErrorType(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepResetAccumulatedError(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FMRIStepResetAccumulatedError(farg1) -swig_result = fresult -end function - -function FMRIStepGetAccumulatedError(arkode_mem, accum_error) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), dimension(*), target, intent(inout) :: accum_error -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(accum_error(1)) -fresult = swigc_FMRIStepGetAccumulatedError(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetNumExpSteps(arkode_mem, expsteps) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: expsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(expsteps(1)) -fresult = swigc_FMRIStepGetNumExpSteps(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetNumAccSteps(arkode_mem, accsteps) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: accsteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(accsteps(1)) -fresult = swigc_FMRIStepGetNumAccSteps(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetNumStepAttempts(arkode_mem, step_attempts) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: step_attempts -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(step_attempts(1)) -fresult = swigc_FMRIStepGetNumStepAttempts(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetNumRhsEvals(arkode_mem, nfse_evals, nfsi_evals) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: nfse_evals -integer(C_LONG), dimension(*), target, intent(inout) :: nfsi_evals -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 - -farg1 = arkode_mem -farg2 = c_loc(nfse_evals(1)) -farg3 = c_loc(nfsi_evals(1)) -fresult = swigc_FMRIStepGetNumRhsEvals(farg1, farg2, farg3) -swig_result = fresult -end function - function FMRIStepGetNumLinSolvSetups(arkode_mem, nlinsetups) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3134,54 +3197,6 @@ function FMRIStepGetNumLinSolvSetups(arkode_mem, nlinsetups) & swig_result = fresult end function -function FMRIStepGetNumErrTestFails(arkode_mem, netfails) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: netfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(netfails(1)) -fresult = swigc_FMRIStepGetNumErrTestFails(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetCurrentCoupling(arkode_mem, mric) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: mric -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(mric) -fresult = swigc_FMRIStepGetCurrentCoupling(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetEstLocalErrors(arkode_mem, ele) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(N_Vector), target, intent(inout) :: ele -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(ele) -fresult = swigc_FMRIStepGetEstLocalErrors(farg1, farg2) -swig_result = fresult -end function - function FMRIStepGetWorkSpace(arkode_mem, lenrw, leniw) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3201,67 +3216,35 @@ function FMRIStepGetWorkSpace(arkode_mem, lenrw, leniw) & swig_result = fresult end function -function FMRIStepGetNumSteps(arkode_mem, nssteps) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: nssteps -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(nssteps(1)) -fresult = swigc_FMRIStepGetNumSteps(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetActualInitStep(arkode_mem, hinused) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -real(C_DOUBLE), dimension(*), target, intent(inout) :: hinused -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(hinused(1)) -fresult = swigc_FMRIStepGetActualInitStep(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetLastStep(arkode_mem, hlast) & +function FMRIStepGetNumSteps(arkode_mem, nssteps) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast +integer(C_LONG), dimension(*), target, intent(inout) :: nssteps integer(C_INT) :: fresult type(C_PTR) :: farg1 type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = c_loc(hlast(1)) -fresult = swigc_FMRIStepGetLastStep(farg1, farg2) +farg2 = c_loc(nssteps(1)) +fresult = swigc_FMRIStepGetNumSteps(farg1, farg2) swig_result = fresult end function -function FMRIStepGetCurrentStep(arkode_mem, hcur) & +function FMRIStepGetLastStep(arkode_mem, hlast) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -real(C_DOUBLE), dimension(*), target, intent(inout) :: hcur +real(C_DOUBLE), dimension(*), target, intent(inout) :: hlast integer(C_INT) :: fresult type(C_PTR) :: farg1 type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = c_loc(hcur(1)) -fresult = swigc_FMRIStepGetCurrentStep(farg1, farg2) +farg2 = c_loc(hlast(1)) +fresult = swigc_FMRIStepGetLastStep(farg1, farg2) swig_result = fresult end function @@ -3377,38 +3360,6 @@ function FMRIStepGetRootInfo(arkode_mem, rootsfound) & swig_result = fresult end function -function FMRIStepGetNumConstrFails(arkode_mem, nconstrfails) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: nconstrfails -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(nconstrfails(1)) -fresult = swigc_FMRIStepGetNumConstrFails(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepGetLastInnerStepFlag(arkode_mem, flag) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT), dimension(*), target, intent(inout) :: flag -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(flag(1)) -fresult = swigc_FMRIStepGetLastInnerStepFlag(farg1, farg2) -swig_result = fresult -end function - function FMRIStepGetUserData(arkode_mem, user_data) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -3851,222 +3802,5 @@ subroutine FMRIStepPrintMem(arkode_mem, outfile) call swigc_FMRIStepPrintMem(farg1, farg2) end subroutine -function FMRIStepInnerStepper_Create(sunctx, stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: sunctx -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = sunctx -farg2 = c_loc(stepper) -fresult = swigc_FMRIStepInnerStepper_Create(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_Free(stepper) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR), target, intent(inout) :: stepper -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = c_loc(stepper) -fresult = swigc_FMRIStepInnerStepper_Free(farg1) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetContent(stepper, content) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_PTR) :: content -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = stepper -farg2 = content -fresult = swigc_FMRIStepInnerStepper_SetContent(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_GetContent(stepper, content) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_PTR), target, intent(inout) :: content -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = stepper -farg2 = c_loc(content) -fresult = swigc_FMRIStepInnerStepper_GetContent(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetEvolveFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetEvolveFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetFullRhsFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetFullRhsFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetResetFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetResetFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetAccumulatedErrorGetFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorGetFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetAccumulatedErrorResetFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetAccumulatedErrorResetFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetFixedStepFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetFixedStepFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_SetRTolFn(stepper, fn) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -type(C_FUNPTR), intent(in), value :: fn -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_FUNPTR) :: farg2 - -farg1 = stepper -farg2 = fn -fresult = swigc_FMRIStepInnerStepper_SetRTolFn(farg1, farg2) -swig_result = fresult -end function - -function FMRIStepInnerStepper_AddForcing(stepper, t, f) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -real(C_DOUBLE), intent(in) :: t -type(N_Vector), target, intent(inout) :: f -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -real(C_DOUBLE) :: farg2 -type(C_PTR) :: farg3 - -farg1 = stepper -farg2 = t -farg3 = c_loc(f) -fresult = swigc_FMRIStepInnerStepper_AddForcing(farg1, farg2, farg3) -swig_result = fresult -end function - -function FMRIStepInnerStepper_GetForcingData(stepper, tshift, tscale, forcing, nforcing) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: stepper -real(C_DOUBLE), dimension(*), target, intent(inout) :: tshift -real(C_DOUBLE), dimension(*), target, intent(inout) :: tscale -type(C_PTR), target, intent(inout) :: forcing -integer(C_INT), dimension(*), target, intent(inout) :: nforcing -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 -type(C_PTR) :: farg4 -type(C_PTR) :: farg5 - -farg1 = stepper -farg2 = c_loc(tshift(1)) -farg3 = c_loc(tscale(1)) -farg4 = c_loc(forcing) -farg5 = c_loc(nforcing(1)) -fresult = swigc_FMRIStepInnerStepper_GetForcingData(farg1, farg2, farg3, farg4, farg5) -swig_result = fresult -end function - end module diff --git a/src/arkode/fmod/farkode_sprkstep_mod.c b/src/arkode/fmod/farkode_sprkstep_mod.c index d5858a372a..28cfb297d4 100644 --- a/src/arkode/fmod/farkode_sprkstep_mod.c +++ b/src/arkode/fmod/farkode_sprkstep_mod.c @@ -273,87 +273,143 @@ SWIGEXPORT int _wrap_FSPRKStepReInit(void *farg1, ARKRhsFn farg2, ARKRhsFn farg3 } -SWIGEXPORT int _wrap_FSPRKStepReset(void *farg1, double const *farg2, N_Vector farg3) { +SWIGEXPORT int _wrap_FSPRKStepSetUseCompensatedSums(void *farg1, int const *farg2) { int fresult ; void *arg1 = (void *) 0 ; - sunrealtype arg2 ; - N_Vector arg3 = (N_Vector) 0 ; + int arg2 ; int result; arg1 = (void *)(farg1); - arg2 = (sunrealtype)(*farg2); - arg3 = (N_Vector)(farg3); - result = (int)SPRKStepReset(arg1,arg2,arg3); + arg2 = (int)(*farg2); + result = (int)SPRKStepSetUseCompensatedSums(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FSPRKStepRootInit(void *farg1, int const *farg2, ARKRootFn farg3) { +SWIGEXPORT int _wrap_FSPRKStepSetMethod(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; - int arg2 ; - ARKRootFn arg3 = (ARKRootFn) 0 ; + ARKodeSPRKTable arg2 = (ARKodeSPRKTable) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (int)(*farg2); - arg3 = (ARKRootFn)(farg3); - result = (int)SPRKStepRootInit(arg1,arg2,arg3); + arg2 = (ARKodeSPRKTable)(farg2); + result = (int)SPRKStepSetMethod(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FSPRKStepSetDefaults(void *farg1) { +SWIGEXPORT int _wrap_FSPRKStepSetMethodName(void *farg1, SwigArrayWrapper *farg2) { int fresult ; void *arg1 = (void *) 0 ; + char *arg2 = (char *) 0 ; int result; arg1 = (void *)(farg1); - result = (int)SPRKStepSetDefaults(arg1); + arg2 = (char *)(farg2->data); + result = (int)SPRKStepSetMethodName(arg1,(char const *)arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FSPRKStepSetUseCompensatedSums(void *farg1, int const *farg2) { +SWIGEXPORT int _wrap_FSPRKStepGetCurrentMethod(void *farg1, void *farg2) { + int fresult ; + void *arg1 = (void *) 0 ; + ARKodeSPRKTable *arg2 = (ARKodeSPRKTable *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (ARKodeSPRKTable *)(farg2); + result = (int)SPRKStepGetCurrentMethod(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSPRKStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SPRKStepGetNumRhsEvals(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSPRKStepReset(void *farg1, double const *farg2, N_Vector farg3) { + int fresult ; + void *arg1 = (void *) 0 ; + sunrealtype arg2 ; + N_Vector arg3 = (N_Vector) 0 ; + int result; + + arg1 = (void *)(farg1); + arg2 = (sunrealtype)(*farg2); + arg3 = (N_Vector)(farg3); + result = (int)SPRKStepReset(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSPRKStepRootInit(void *farg1, int const *farg2, ARKRootFn farg3) { int fresult ; void *arg1 = (void *) 0 ; int arg2 ; + ARKRootFn arg3 = (ARKRootFn) 0 ; int result; arg1 = (void *)(farg1); arg2 = (int)(*farg2); - result = (int)SPRKStepSetUseCompensatedSums(arg1,arg2); + arg3 = (ARKRootFn)(farg3); + result = (int)SPRKStepRootInit(arg1,arg2,arg3); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FSPRKStepSetMethod(void *farg1, void *farg2) { +SWIGEXPORT int _wrap_FSPRKStepSetRootDirection(void *farg1, int *farg2) { int fresult ; void *arg1 = (void *) 0 ; - ARKodeSPRKTable arg2 = (ARKodeSPRKTable) 0 ; + int *arg2 = (int *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (ARKodeSPRKTable)(farg2); - result = (int)SPRKStepSetMethod(arg1,arg2); + arg2 = (int *)(farg2); + result = (int)SPRKStepSetRootDirection(arg1,arg2); fresult = (int)(result); return fresult; } -SWIGEXPORT int _wrap_FSPRKStepSetMethodName(void *farg1, SwigArrayWrapper *farg2) { +SWIGEXPORT int _wrap_FSPRKStepSetNoInactiveRootWarn(void *farg1) { int fresult ; void *arg1 = (void *) 0 ; - char *arg2 = (char *) 0 ; int result; arg1 = (void *)(farg1); - arg2 = (char *)(farg2->data); - result = (int)SPRKStepSetMethodName(arg1,(char const *)arg2); + result = (int)SPRKStepSetNoInactiveRootWarn(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSPRKStepSetDefaults(void *farg1) { + int fresult ; + void *arg1 = (void *) 0 ; + int result; + + arg1 = (void *)(farg1); + result = (int)SPRKStepSetDefaults(arg1); fresult = (int)(result); return fresult; } @@ -536,20 +592,6 @@ SWIGEXPORT SwigArrayWrapper _wrap_FSPRKStepGetReturnFlagName(long const *farg1) } -SWIGEXPORT int _wrap_FSPRKStepGetCurrentMethod(void *farg1, void *farg2) { - int fresult ; - void *arg1 = (void *) 0 ; - ARKodeSPRKTable *arg2 = (ARKodeSPRKTable *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (ARKodeSPRKTable *)(farg2); - result = (int)SPRKStepGetCurrentMethod(arg1,arg2); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSPRKStepGetCurrentState(void *farg1, void *farg2) { int fresult ; void *arg1 = (void *) 0 ; @@ -606,22 +648,6 @@ SWIGEXPORT int _wrap_FSPRKStepGetLastStep(void *farg1, double *farg2) { } -SWIGEXPORT int _wrap_FSPRKStepGetNumRhsEvals(void *farg1, long *farg2, long *farg3) { - int fresult ; - void *arg1 = (void *) 0 ; - long *arg2 = (long *) 0 ; - long *arg3 = (long *) 0 ; - int result; - - arg1 = (void *)(farg1); - arg2 = (long *)(farg2); - arg3 = (long *)(farg3); - result = (int)SPRKStepGetNumRhsEvals(arg1,arg2,arg3); - fresult = (int)(result); - return fresult; -} - - SWIGEXPORT int _wrap_FSPRKStepGetNumStepAttempts(void *farg1, long *farg2) { int fresult ; void *arg1 = (void *) 0 ; diff --git a/src/arkode/fmod/farkode_sprkstep_mod.f90 b/src/arkode/fmod/farkode_sprkstep_mod.f90 index a6cc16db19..82217e7b1b 100644 --- a/src/arkode/fmod/farkode_sprkstep_mod.f90 +++ b/src/arkode/fmod/farkode_sprkstep_mod.f90 @@ -36,9 +36,6 @@ module farkode_sprkstep_mod integer(C_INT), parameter, public :: SPRKSTEP_DEFAULT_10 = ARKODE_SPRK_SOFRONIOU_10_36 public :: FSPRKStepCreate public :: FSPRKStepReInit - public :: FSPRKStepReset - public :: FSPRKStepRootInit - public :: FSPRKStepSetDefaults public :: FSPRKStepSetUseCompensatedSums public :: FSPRKStepSetMethod type, bind(C) :: SwigArrayWrapper @@ -46,6 +43,13 @@ module farkode_sprkstep_mod integer(C_SIZE_T), public :: size = 0 end type public :: FSPRKStepSetMethodName + public :: FSPRKStepGetCurrentMethod + public :: FSPRKStepGetNumRhsEvals + public :: FSPRKStepReset + public :: FSPRKStepRootInit + public :: FSPRKStepSetRootDirection + public :: FSPRKStepSetNoInactiveRootWarn + public :: FSPRKStepSetDefaults public :: FSPRKStepSetOrder public :: FSPRKStepSetInterpolantType public :: FSPRKStepSetInterpolantDegree @@ -58,12 +62,10 @@ module farkode_sprkstep_mod public :: FSPRKStepEvolve public :: FSPRKStepGetDky public :: FSPRKStepGetReturnFlagName - public :: FSPRKStepGetCurrentMethod public :: FSPRKStepGetCurrentState public :: FSPRKStepGetCurrentStep public :: FSPRKStepGetCurrentTime public :: FSPRKStepGetLastStep - public :: FSPRKStepGetNumRhsEvals public :: FSPRKStepGetNumStepAttempts public :: FSPRKStepGetNumSteps public :: FSPRKStepGetRootInfo @@ -99,45 +101,75 @@ function swigc_FSPRKStepReInit(farg1, farg2, farg3, farg4, farg5) & integer(C_INT) :: fresult end function -function swigc_FSPRKStepReset(farg1, farg2, farg3) & -bind(C, name="_wrap_FSPRKStepReset") & +function swigc_FSPRKStepSetUseCompensatedSums(farg1, farg2) & +bind(C, name="_wrap_FSPRKStepSetUseCompensatedSums") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -real(C_DOUBLE), intent(in) :: farg2 -type(C_PTR), value :: farg3 +integer(C_INT), intent(in) :: farg2 integer(C_INT) :: fresult end function -function swigc_FSPRKStepRootInit(farg1, farg2, farg3) & -bind(C, name="_wrap_FSPRKStepRootInit") & +function swigc_FSPRKStepSetMethod(farg1, farg2) & +bind(C, name="_wrap_FSPRKStepSetMethod") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 -integer(C_INT), intent(in) :: farg2 -type(C_FUNPTR), value :: farg3 +type(C_PTR), value :: farg2 integer(C_INT) :: fresult end function -function swigc_FSPRKStepSetDefaults(farg1) & -bind(C, name="_wrap_FSPRKStepSetDefaults") & +function swigc_FSPRKStepSetMethodName(farg1, farg2) & +bind(C, name="_wrap_FSPRKStepSetMethodName") & result(fresult) use, intrinsic :: ISO_C_BINDING +import :: swigarraywrapper type(C_PTR), value :: farg1 +type(SwigArrayWrapper) :: farg2 integer(C_INT) :: fresult end function -function swigc_FSPRKStepSetUseCompensatedSums(farg1, farg2) & -bind(C, name="_wrap_FSPRKStepSetUseCompensatedSums") & +function swigc_FSPRKStepGetCurrentMethod(farg1, farg2) & +bind(C, name="_wrap_FSPRKStepGetCurrentMethod") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSPRKStepGetNumRhsEvals(farg1, farg2, farg3) & +bind(C, name="_wrap_FSPRKStepGetNumRhsEvals") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSPRKStepReset(farg1, farg2, farg3) & +bind(C, name="_wrap_FSPRKStepReset") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +real(C_DOUBLE), intent(in) :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSPRKStepRootInit(farg1, farg2, farg3) & +bind(C, name="_wrap_FSPRKStepRootInit") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 integer(C_INT), intent(in) :: farg2 +type(C_FUNPTR), value :: farg3 integer(C_INT) :: fresult end function -function swigc_FSPRKStepSetMethod(farg1, farg2) & -bind(C, name="_wrap_FSPRKStepSetMethod") & +function swigc_FSPRKStepSetRootDirection(farg1, farg2) & +bind(C, name="_wrap_FSPRKStepSetRootDirection") & result(fresult) use, intrinsic :: ISO_C_BINDING type(C_PTR), value :: farg1 @@ -145,13 +177,19 @@ function swigc_FSPRKStepSetMethod(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSPRKStepSetMethodName(farg1, farg2) & -bind(C, name="_wrap_FSPRKStepSetMethodName") & +function swigc_FSPRKStepSetNoInactiveRootWarn(farg1) & +bind(C, name="_wrap_FSPRKStepSetNoInactiveRootWarn") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSPRKStepSetDefaults(farg1) & +bind(C, name="_wrap_FSPRKStepSetDefaults") & result(fresult) use, intrinsic :: ISO_C_BINDING -import :: swigarraywrapper type(C_PTR), value :: farg1 -type(SwigArrayWrapper) :: farg2 integer(C_INT) :: fresult end function @@ -273,15 +311,6 @@ function swigc_FSPRKStepGetReturnFlagName(farg1) & type(SwigArrayWrapper) :: fresult end function -function swigc_FSPRKStepGetCurrentMethod(farg1, farg2) & -bind(C, name="_wrap_FSPRKStepGetCurrentMethod") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -integer(C_INT) :: fresult -end function - function swigc_FSPRKStepGetCurrentState(farg1, farg2) & bind(C, name="_wrap_FSPRKStepGetCurrentState") & result(fresult) @@ -318,16 +347,6 @@ function swigc_FSPRKStepGetLastStep(farg1, farg2) & integer(C_INT) :: fresult end function -function swigc_FSPRKStepGetNumRhsEvals(farg1, farg2, farg3) & -bind(C, name="_wrap_FSPRKStepGetNumRhsEvals") & -result(fresult) -use, intrinsic :: ISO_C_BINDING -type(C_PTR), value :: farg1 -type(C_PTR), value :: farg2 -type(C_PTR), value :: farg3 -integer(C_INT) :: fresult -end function - function swigc_FSPRKStepGetNumStepAttempts(farg1, farg2) & bind(C, name="_wrap_FSPRKStepGetNumStepAttempts") & result(fresult) @@ -457,6 +476,108 @@ function FSPRKStepReInit(arkode_mem, f1, f2, t0, y0) & swig_result = fresult end function +function FSPRKStepSetUseCompensatedSums(arkode_mem, onoff) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_INT), intent(in) :: onoff +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +integer(C_INT) :: farg2 + +farg1 = arkode_mem +farg2 = onoff +fresult = swigc_FSPRKStepSetUseCompensatedSums(farg1, farg2) +swig_result = fresult +end function + +function FSPRKStepSetMethod(arkode_mem, sprk_storage) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR) :: sprk_storage +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = sprk_storage +fresult = swigc_FSPRKStepSetMethod(farg1, farg2) +swig_result = fresult +end function + + +subroutine SWIG_string_to_chararray(string, chars, wrap) + use, intrinsic :: ISO_C_BINDING + character(kind=C_CHAR, len=*), intent(IN) :: string + character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars + type(SwigArrayWrapper), intent(OUT) :: wrap + integer :: i + + allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) + do i=1,len(string) + chars(i) = string(i:i) + end do + i = len(string) + 1 + chars(i) = C_NULL_CHAR ! C string compatibility + wrap%data = c_loc(chars) + wrap%size = len(string) +end subroutine + +function FSPRKStepSetMethodName(arkode_mem, method) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +character(kind=C_CHAR, len=*), target :: method +character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(SwigArrayWrapper) :: farg2 + +farg1 = arkode_mem +call SWIG_string_to_chararray(method, farg2_chars, farg2) +fresult = swigc_FSPRKStepSetMethodName(farg1, farg2) +swig_result = fresult +end function + +function FSPRKStepGetCurrentMethod(arkode_mem, sprk_storage) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +type(C_PTR), target, intent(inout) :: sprk_storage +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = arkode_mem +farg2 = c_loc(sprk_storage) +fresult = swigc_FSPRKStepGetCurrentMethod(farg1, farg2) +swig_result = fresult +end function + +function FSPRKStepGetNumRhsEvals(arkode_mem, nf1, nf2) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(C_PTR) :: arkode_mem +integer(C_LONG), dimension(*), target, intent(inout) :: nf1 +integer(C_LONG), dimension(*), target, intent(inout) :: nf2 +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = arkode_mem +farg2 = c_loc(nf1(1)) +farg3 = c_loc(nf2(1)) +fresult = swigc_FSPRKStepGetNumRhsEvals(farg1, farg2, farg3) +swig_result = fresult +end function + function FSPRKStepReset(arkode_mem, tr, yr) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -495,83 +616,45 @@ function FSPRKStepRootInit(arkode_mem, nrtfn, g) & swig_result = fresult end function -function FSPRKStepSetDefaults(arkode_mem) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_INT) :: fresult -type(C_PTR) :: farg1 - -farg1 = arkode_mem -fresult = swigc_FSPRKStepSetDefaults(farg1) -swig_result = fresult -end function - -function FSPRKStepSetUseCompensatedSums(arkode_mem, onoff) & +function FSPRKStepSetRootDirection(arkode_mem, rootdir) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -integer(C_INT), intent(in) :: onoff +integer(C_INT), dimension(*), target, intent(inout) :: rootdir integer(C_INT) :: fresult type(C_PTR) :: farg1 -integer(C_INT) :: farg2 +type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = onoff -fresult = swigc_FSPRKStepSetUseCompensatedSums(farg1, farg2) +farg2 = c_loc(rootdir(1)) +fresult = swigc_FSPRKStepSetRootDirection(farg1, farg2) swig_result = fresult end function -function FSPRKStepSetMethod(arkode_mem, sprk_storage) & +function FSPRKStepSetNoInactiveRootWarn(arkode_mem) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -type(C_PTR) :: sprk_storage integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(C_PTR) :: farg2 farg1 = arkode_mem -farg2 = sprk_storage -fresult = swigc_FSPRKStepSetMethod(farg1, farg2) +fresult = swigc_FSPRKStepSetNoInactiveRootWarn(farg1) swig_result = fresult end function - -subroutine SWIG_string_to_chararray(string, chars, wrap) - use, intrinsic :: ISO_C_BINDING - character(kind=C_CHAR, len=*), intent(IN) :: string - character(kind=C_CHAR), dimension(:), target, allocatable, intent(OUT) :: chars - type(SwigArrayWrapper), intent(OUT) :: wrap - integer :: i - - allocate(character(kind=C_CHAR) :: chars(len(string) + 1)) - do i=1,len(string) - chars(i) = string(i:i) - end do - i = len(string) + 1 - chars(i) = C_NULL_CHAR ! C string compatibility - wrap%data = c_loc(chars) - wrap%size = len(string) -end subroutine - -function FSPRKStepSetMethodName(arkode_mem, method) & +function FSPRKStepSetDefaults(arkode_mem) & result(swig_result) use, intrinsic :: ISO_C_BINDING integer(C_INT) :: swig_result type(C_PTR) :: arkode_mem -character(kind=C_CHAR, len=*), target :: method -character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_chars integer(C_INT) :: fresult type(C_PTR) :: farg1 -type(SwigArrayWrapper) :: farg2 farg1 = arkode_mem -call SWIG_string_to_chararray(method, farg2_chars, farg2) -fresult = swigc_FSPRKStepSetMethodName(farg1, farg2) +fresult = swigc_FSPRKStepSetDefaults(farg1) swig_result = fresult end function @@ -794,22 +877,6 @@ function FSPRKStepGetReturnFlagName(flag) & if (.false.) call SWIG_free(fresult%data) end function -function FSPRKStepGetCurrentMethod(arkode_mem, sprk_storage) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -type(C_PTR), target, intent(inout) :: sprk_storage -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 - -farg1 = arkode_mem -farg2 = c_loc(sprk_storage) -fresult = swigc_FSPRKStepGetCurrentMethod(farg1, farg2) -swig_result = fresult -end function - function FSPRKStepGetCurrentState(arkode_mem, state) & result(swig_result) use, intrinsic :: ISO_C_BINDING @@ -874,25 +941,6 @@ function FSPRKStepGetLastStep(arkode_mem, hlast) & swig_result = fresult end function -function FSPRKStepGetNumRhsEvals(arkode_mem, nf1, nf2) & -result(swig_result) -use, intrinsic :: ISO_C_BINDING -integer(C_INT) :: swig_result -type(C_PTR) :: arkode_mem -integer(C_LONG), dimension(*), target, intent(inout) :: nf1 -integer(C_LONG), dimension(*), target, intent(inout) :: nf2 -integer(C_INT) :: fresult -type(C_PTR) :: farg1 -type(C_PTR) :: farg2 -type(C_PTR) :: farg3 - -farg1 = arkode_mem -farg2 = c_loc(nf1(1)) -farg3 = c_loc(nf2(1)) -fresult = swigc_FSPRKStepGetNumRhsEvals(farg1, farg2, farg3) -swig_result = fresult -end function - function FSPRKStepGetNumStepAttempts(arkode_mem, step_attempts) & result(swig_result) use, intrinsic :: ISO_C_BINDING diff --git a/src/arkode/xbraid/arkode_xbraid.c b/src/arkode/xbraid/arkode_xbraid.c index fd98282db7..67e20edf1f 100644 --- a/src/arkode/xbraid/arkode_xbraid.c +++ b/src/arkode/xbraid/arkode_xbraid.c @@ -215,6 +215,11 @@ int ARKBraid_GetVecTmpl(braid_App app, N_Vector* tmpl) } int ARKBraid_GetARKStepMem(braid_App app, void** arkode_mem) +{ + return (ARKBraid_GetARKodeMem(app, arkode_mem)); +} + +int ARKBraid_GetARKodeMem(braid_App app, void** arkode_mem) { ARKBraidContent content; if (app == NULL) { return SUNBRAID_ILLINPUT; } @@ -247,6 +252,11 @@ int ARKBraid_GetLastBraidFlag(braid_App app, int* last_flag) } int ARKBraid_GetLastARKStepFlag(braid_App app, int* last_flag) +{ + return (ARKBraid_GetLastARKodeFlag(app, last_flag)); +} + +int ARKBraid_GetLastARKodeFlag(braid_App app, int* last_flag) { ARKBraidContent content; if (app == NULL) { return SUNBRAID_ILLINPUT; } @@ -321,7 +331,7 @@ int ARKBraid_Step(braid_App app, braid_Vector ustop, braid_Vector fstop, { /* Get the suggested step size. The rfac value is given by ETACF on a solver failure and limited by ETAMIN on an error test failure */ - flag = ARKStepGetCurrentStep((void*)(content->ark_mem), &hacc); + flag = ARKodeGetCurrentStep((void*)(content->ark_mem), &hacc); CHECK_ARKODE_RETURN(content->last_flag_arkode, flag); /* Set the refinement factor */ @@ -446,12 +456,12 @@ int ARKBraid_TakeStep(void* arkode_mem, sunrealtype tstart, sunrealtype tstop, if (arkode_mem == NULL) { return ARK_MEM_NULL; } if (y == NULL) { return ARK_ILL_INPUT; } - /* Reset ARKStep state */ - flag = ARKStepReset(arkode_mem, tstart, y); + /* Reset ARKODE state */ + flag = ARKodeReset(arkode_mem, tstart, y); if (flag != ARK_SUCCESS) { return flag; } /* Set the time step size */ - flag = ARKStepSetInitStep(arkode_mem, tstop - tstart); + flag = ARKodeSetInitStep(arkode_mem, tstop - tstart); if (flag != ARK_SUCCESS) { return flag; } /* Ignore temporal error test result and force step to pass */ @@ -459,7 +469,7 @@ int ARKBraid_TakeStep(void* arkode_mem, sunrealtype tstart, sunrealtype tstop, if (flag != ARK_SUCCESS) { return flag; } /* Take step, check flag below */ - tmp_flag = ARKStepEvolve(arkode_mem, tstop, y, &tret, ARK_ONE_STEP); + tmp_flag = ARKodeEvolve(arkode_mem, tstop, y, &tret, ARK_ONE_STEP); /* Re-enable temporal error test check */ flag = arkSetForcePass(arkode_mem, SUNFALSE); diff --git a/src/sundials/CMakeLists.txt b/src/sundials/CMakeLists.txt index 46bab728ef..8c91a3fd6d 100644 --- a/src/sundials/CMakeLists.txt +++ b/src/sundials/CMakeLists.txt @@ -114,9 +114,12 @@ endif() add_prefix(${SUNDIALS_SOURCE_DIR}/src/sundials/ sundials_SOURCES) if(ENABLE_MPI) - set(_link_mpi_if_needed PUBLIC MPI::MPI_C) + set(_link_mpi_if_needed PUBLIC + MPI::MPI_C + $<$:MPI::MPI_CXX>) endif() + if(SUNDIALS_BUILD_WITH_PROFILING) if(ENABLE_CALIPER) set(_link_caliper_if_needed PUBLIC caliper) diff --git a/src/sundials/sundials_context.c b/src/sundials/sundials_context.c index f031dea4f0..b3c847e682 100644 --- a/src/sundials/sundials_context.c +++ b/src/sundials/sundials_context.c @@ -285,7 +285,7 @@ SUNErrCode SUNContext_Free(SUNContext* sunctx) SUNLogger_Destroy(&(*sunctx)->logger); } - SUNErrHandler_Destroy(&(*sunctx)->err_handler); + SUNContext_ClearErrHandlers(*sunctx); free(*sunctx); *sunctx = NULL; diff --git a/test/answers b/test/answers index 1ab057ec30..ea6ac15fdc 160000 --- a/test/answers +++ b/test/answers @@ -1 +1 @@ -Subproject commit 1ab057ec30477fd531d4cc16c6b9bb0cd55ebd45 +Subproject commit ea6ac15fdcd8615e25e52692bcd453e2f003f46b diff --git a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp index 8a60b4801e..86b8efb0d3 100644 --- a/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp +++ b/test/unit_tests/arkode/CXX_parallel/ark_test_heat2D_mri.cpp @@ -258,86 +258,86 @@ int main(int argc, char* argv[]) if (check_flag((void*)C, "MRIStepCoupling_MIStoMRI", 0)) { return 1; } // Set routines - flag = ARKStepSetUserData(arkstep_mem, - (void*)udata); // Pass udata to user functions - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSetNonlinConvCoef(arkstep_mem, - SUN_RCONST(1.e-7)); // Update solver convergence coeff. - if (check_flag(&flag, "ARKStepSetNonlinConvCoef", 1)) { return 1; } - flag = ARKStepSStolerances(arkstep_mem, rtol, atol); // Specify tolerances - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } - flag = ARKStepSetFixedStep(arkstep_mem, Tf / Nt); // Specify fixed time step size - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetUserData(arkstep_mem, + (void*)udata); // Pass udata to user functions + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetNonlinConvCoef(arkstep_mem, + SUN_RCONST(1.e-7)); // Update solver convergence coeff. + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; } + flag = ARKodeSStolerances(arkstep_mem, rtol, atol); // Specify tolerances + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkstep_mem, Tf / Nt); // Specify fixed time step size + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } flag = ARKStepSetTables(arkstep_mem, 2, 0, B, NULL); // Specify Butcher table if (check_flag(&flag, "ARKStepSetTables", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkstep_mem, 2 * Nt); // Increase num internal steps - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - - flag = MRIStepSetUserData(mristep_mem, - (void*)udata); // Pass udata to user functions - if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; } - flag = MRIStepSetNonlinConvCoef(mristep_mem, - SUN_RCONST(1.e-7)); // Update solver convergence coeff. - if (check_flag(&flag, "MRIStepSetNonlinConvCoef", 1)) { return 1; } - flag = MRIStepSStolerances(mristep_mem, rtol, atol); // Specify tolerances - if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; } - flag = MRIStepSetFixedStep(mristep_mem, Tf / Nt); // Specify fixed time step sizes - if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; } - flag = ARKStepSetFixedStep(inner_mem, Tf / Nt / 10); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } - flag = MRIStepSetCoupling(mristep_mem, C); // Specify Butcher table + flag = ARKodeSetMaxNumSteps(arkstep_mem, 2 * Nt); // Increase num internal steps + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + + flag = ARKodeSetUserData(mristep_mem, + (void*)udata); // Pass udata to user functions + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSetNonlinConvCoef(mristep_mem, + SUN_RCONST(1.e-7)); // Update solver convergence coeff. + if (check_flag(&flag, "ARKodeSetNonlinConvCoef", 1)) { return 1; } + flag = ARKodeSStolerances(mristep_mem, rtol, atol); // Specify tolerances + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetFixedStep(mristep_mem, Tf / Nt); // Specify fixed time step sizes + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(inner_mem, Tf / Nt / 10); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } + flag = MRIStepSetCoupling(mristep_mem, C); // Specify coupling table if (check_flag(&flag, "MRIStepSetCoupling", 1)) { return 1; } - flag = MRIStepSetMaxNumSteps(mristep_mem, 2 * Nt); // Increase num internal steps - if (check_flag(&flag, "MRIStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(mristep_mem, 2 * Nt); // Increase num internal steps + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Linear solver interface - flag = ARKStepSetLinearSolver(arkstep_mem, LSa, NULL); // Attach linear solver - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetPreconditioner(arkstep_mem, PSet, - PSol); // Specify the Preconditoner - if (check_flag(&flag, "ARKStepSetPreconditioner", 1)) { return 1; } - - flag = MRIStepSetLinearSolver(mristep_mem, LSm, NULL); // Attach linear solver - if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; } - flag = MRIStepSetPreconditioner(mristep_mem, PSet, - PSol); // Specify the Preconditoner - if (check_flag(&flag, "MRIStepSetPreconditioner", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkstep_mem, LSa, NULL); // Attach linear solver + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetPreconditioner(arkstep_mem, PSet, + PSol); // Specify the Preconditoner + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } + + flag = ARKodeSetLinearSolver(mristep_mem, LSm, NULL); // Attach linear solver + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetPreconditioner(mristep_mem, PSet, + PSol); // Specify the Preconditoner + if (check_flag(&flag, "ARKodeSetPreconditioner", 1)) { return 1; } // Optionally specify linearly implicit RHS, with non-time-dependent preconditioner if (linear) { - flag = ARKStepSetLinear(arkstep_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkstep_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } - flag = MRIStepSetLinear(mristep_mem, 0); - if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(mristep_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } - // First call ARKStep to evolve the full problem, and print results + // First call ARKodeEvolve to evolve the full problem, and print results t = T0; N_VConst(ZERO, y); - flag = ARKStepEvolve(arkstep_mem, Tf, y, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } - flag = ARKStepGetNumSteps(arkstep_mem, &ark_nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return 1; } + flag = ARKodeEvolve(arkstep_mem, Tf, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } + flag = ARKodeGetNumSteps(arkstep_mem, &ark_nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } flag = ARKStepGetNumRhsEvals(arkstep_mem, &ark_nfe, &ark_nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return 1; } - flag = ARKStepGetNumLinSolvSetups(arkstep_mem, &ark_nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return 1; } - flag = ARKStepGetNumNonlinSolvIters(arkstep_mem, &ark_nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return 1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkstep_mem, &ark_ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return 1; } - flag = ARKStepGetNumLinIters(arkstep_mem, &ark_nli); - if (check_flag(&flag, "ARKStepGetNumLinIters", 1)) { return 1; } - flag = ARKStepGetNumJtimesEvals(arkstep_mem, &ark_nJv); - if (check_flag(&flag, "ARKStepGetNumJtimesEvals", 1)) { return 1; } - flag = ARKStepGetNumLinConvFails(arkstep_mem, &ark_nlcf); - if (check_flag(&flag, "ARKStepGetNumLinConvFails", 1)) { return 1; } - flag = ARKStepGetNumPrecEvals(arkstep_mem, &ark_npe); - if (check_flag(&flag, "ARKStepGetNumPrecEvals", 1)) { return 1; } - flag = ARKStepGetNumPrecSolves(arkstep_mem, &ark_nps); - if (check_flag(&flag, "ARKStepGetNumPrecSolves", 1)) { return 1; } + flag = ARKodeGetNumLinSolvSetups(arkstep_mem, &ark_nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(arkstep_mem, &ark_nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkstep_mem, &ark_ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; } + flag = ARKodeGetNumLinIters(arkstep_mem, &ark_nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return 1; } + flag = ARKodeGetNumJtimesEvals(arkstep_mem, &ark_nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return 1; } + flag = ARKodeGetNumLinConvFails(arkstep_mem, &ark_nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return 1; } + flag = ARKodeGetNumPrecEvals(arkstep_mem, &ark_npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return 1; } + flag = ARKodeGetNumPrecSolves(arkstep_mem, &ark_nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return 1; } if (outproc) { cout << "\nARKStep Solver Statistics:\n"; @@ -356,31 +356,31 @@ int main(int argc, char* argv[]) << ark_ncfn << "\n"; } - // Second call MRIStep to evolve the full problem, and print results + // Second call ARKodeEvolve to evolve the full problem, and print results t = T0; N_VConst(ZERO, y); - flag = MRIStepEvolve(mristep_mem, Tf, y, &t, ARK_NORMAL); - if (check_flag(&flag, "MRIStepEvolve", 1)) { return 1; } - flag = MRIStepGetNumSteps(mristep_mem, &mri_nst); - if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return 1; } + flag = ARKodeEvolve(mristep_mem, Tf, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } + flag = ARKodeGetNumSteps(mristep_mem, &mri_nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } flag = MRIStepGetNumRhsEvals(mristep_mem, &mri_nfse, &mri_nfsi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return 1; } - flag = MRIStepGetNumLinSolvSetups(mristep_mem, &mri_nsetups); - if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return 1; } - flag = MRIStepGetNumNonlinSolvIters(mristep_mem, &mri_nni); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return 1; } - flag = MRIStepGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) { return 1; } - flag = MRIStepGetNumLinIters(mristep_mem, &mri_nli); - if (check_flag(&flag, "MRIStepGetNumLinIters", 1)) { return 1; } - flag = MRIStepGetNumJtimesEvals(mristep_mem, &mri_nJv); - if (check_flag(&flag, "MRIStepGetNumJtimesEvals", 1)) { return 1; } - flag = MRIStepGetNumLinConvFails(mristep_mem, &mri_nlcf); - if (check_flag(&flag, "MRIStepGetNumLinConvFails", 1)) { return 1; } - flag = MRIStepGetNumPrecEvals(mristep_mem, &mri_npe); - if (check_flag(&flag, "MRIStepGetNumPrecEvals", 1)) { return 1; } - flag = MRIStepGetNumPrecSolves(mristep_mem, &mri_nps); - if (check_flag(&flag, "MRIStepGetNumPrecSolves", 1)) { return 1; } + flag = ARKodeGetNumLinSolvSetups(mristep_mem, &mri_nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(mristep_mem, &mri_nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; } + flag = ARKodeGetNumLinIters(mristep_mem, &mri_nli); + if (check_flag(&flag, "ARKodeGetNumLinIters", 1)) { return 1; } + flag = ARKodeGetNumJtimesEvals(mristep_mem, &mri_nJv); + if (check_flag(&flag, "ARKodeGetNumJtimesEvals", 1)) { return 1; } + flag = ARKodeGetNumLinConvFails(mristep_mem, &mri_nlcf); + if (check_flag(&flag, "ARKodeGetNumLinConvFails", 1)) { return 1; } + flag = ARKodeGetNumPrecEvals(mristep_mem, &mri_npe); + if (check_flag(&flag, "ARKodeGetNumPrecEvals", 1)) { return 1; } + flag = ARKodeGetNumPrecSolves(mristep_mem, &mri_nps); + if (check_flag(&flag, "ARKodeGetNumPrecSolves", 1)) { return 1; } if (outproc) { cout << "\nMRIStep Solver Statistics:\n"; @@ -491,9 +491,9 @@ int main(int argc, char* argv[]) ARKodeButcherTable_Free(B); // Free Butcher table ARKodeButcherTable_Free(Bc); // Free Butcher table MRIStepCoupling_Free(C); // Free MRI coupling table - ARKStepFree(&arkstep_mem); // Free integrator memory - MRIStepFree(&mristep_mem); - ARKStepFree(&inner_mem); + ARKodeFree(&arkstep_mem); // Free integrator memory + ARKodeFree(&mristep_mem); + ARKodeFree(&inner_mem); MRIStepInnerStepper_Free(&inner_stepper); SUNLinSolFree(LSa); // Free linear solver SUNLinSolFree(LSm); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp index 160caca944..c1fd11cf25 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_brusselator.cpp @@ -263,27 +263,26 @@ int main(int argc, char* argv[]) NV_Ith_S(y, 2) = w0; arkode_ref = ARKStepCreate(fn, NULL, T0, y, ctx); if (check_retval((void*)arkode_ref, "ARKStepCreate", 0)) return 1; - retval = ARKStepSetUserData(arkode_ref, (void*)&udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) return 1; - retval = ARKStepSetOrder(arkode_ref, 5); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; - retval = ARKStepSStolerances(arkode_ref, SUN_RCONST(1.e-10), - SUN_RCONST(1.e-12)); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_ref, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetUserData(arkode_ref, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(arkode_ref, SUN_RCONST(1.e-10), SUN_RCONST(1.e-12)); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); N_VScale(ONE, y, yref[0]); sunrealtype hpart = (Tf - T0) / udata.Npart; - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { sunrealtype t = T0 + ipart * hpart; - retval = ARKStepSetStopTime(arkode_ref, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepEvolve(arkode_ref, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) return 1; + retval = ARKodeSetStopTime(arkode_ref, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_ref, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; N_VScale(ONE, y, yref[ipart + 1]); } - ARKStepFree(&arkode_ref); + ARKodeFree(&arkode_ref); // Set up ARKStep integrator NV_Ith_S(y, 0) = u0; @@ -298,27 +297,27 @@ int main(int argc, char* argv[]) arkode_mem = ARKStepCreate(fn, NULL, T0, y, ctx); } if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) return 1; - retval = ARKStepSetUserData(arkode_mem, (void*)&udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) return 1; - retval = ARKStepSetOrder(arkode_mem, order); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; - retval = ARKStepSStolerances(arkode_mem, SUN_RCONST(1.e-4), SUN_RCONST(1.e-9)); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, SUN_RCONST(1.e-4), SUN_RCONST(1.e-9)); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; if (rk_type == 0) { // DIRK method A = SUNDenseMatrix(NEQ, NEQ, ctx); if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; LS = SUNLinSol_Dense(y, A, ctx); if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; - retval = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) return 1; - retval = ARKStepSetJacFn(arkode_mem, Jac); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + retval = ARKodeSetJacFn(arkode_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; } else { // ERK method - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); } // Integrate ODE, based on run type @@ -334,7 +333,7 @@ int main(int argc, char* argv[]) } // Clean up and return - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); if (LS) { SUNLinSolFree(LS); } // free system linear solver if (A) { SUNMatDestroy(A); } // free system matrix N_VDestroy(y); // Free y and yref vectors @@ -413,13 +412,13 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Loop over tolerances cout << "\nAdaptive-step runs:\n"; - for (size_t irtol = 0; irtol < rtols.size(); irtol++) + for (int irtol = 0; irtol < rtols.size(); irtol++) { // Loop over accumulation types - for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run, and evolve over partition interval t = T0 + ipart * hpart; @@ -433,23 +432,22 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); } if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); - if (check_retval(&retval, "ARKStepSetAccumulatedErrorType", 1)) - return 1; - retval = ARKStepResetAccumulatedError(arkode_mem); - if (check_retval(&retval, "ARKStepResetAccumulatedError", 1)) return 1; - retval = ARKStepSStolerances(arkode_mem, rtols[irtol], abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); - retval = ARKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); - if (check_retval(&retval, "ARKStepGetAccumulatedError", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, rtols[irtol], abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; // Compute/print solution error sunrealtype uref = NV_Ith_S(yref[ipart + 1], 0); @@ -501,13 +499,13 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T // Loop over step sizes cout << "\nFixed-step runs:\n"; - for (size_t ih = 0; ih < hvals.size(); ih++) + for (int ih = 0; ih < hvals.size(); ih++) { // Loop over built-in accumulation types - for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run, and evolve to Tf t = T0 + ipart * hpart; @@ -521,34 +519,33 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); } if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); - if (check_retval(&retval, "ARKStepSetAccumulatedErrorType", 1)) - return 1; - retval = ARKStepResetAccumulatedError(arkode_mem); - if (check_retval(&retval, "ARKStepResetAccumulatedError", 1)) return 1; - retval = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); - retval = ARKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; if (rk_type == 0) { - retval = ARKStepSetJacEvalFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetJacEvalFrequency", 1)) return 1; - retval = ARKStepSetLSetupFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetLSetupFrequency", 1)) return 1; - retval = ARKStepSetMaxNonlinIters(arkode_mem, 20); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; } - retval = ARKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); - if (check_retval(&retval, "ARKStepGetAccumulatedError", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; // Compute/print solution error sunrealtype udsm = abs(NV_Ith_S(y, 0) - NV_Ith_S(yref[ipart + 1], 0)) / @@ -569,7 +566,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T // Test double-step error estimator // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run, and evolve over partition interval t = t2 = T0 + ipart * hpart; @@ -584,29 +581,29 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T retval = ARKStepReInit(arkode_mem, fn, NULL, t, y); } if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetAccumulatedErrorType(arkode_mem, -1); - if (check_retval(&retval, "ARKStepSetAccumulatedErrorType", 1)) return 1; - retval = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); - retval = ARKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; if (rk_type == 0) { - retval = ARKStepSetJacEvalFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetJacEvalFrequency", 1)) return 1; - retval = ARKStepSetLSetupFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetLSetupFrequency", 1)) return 1; - retval = ARKStepSetMaxNonlinIters(arkode_mem, 20); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; } - retval = ARKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; if (rk_type == 0) { // DIRK @@ -617,14 +614,14 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, sunrealtype T retval = ARKStepReInit(arkode_mem, fn, NULL, t2, y2); } if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetFixedStep(arkode_mem, 2.0 * hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) return 1; - retval = ARKStepSetStopTime(arkode_mem, t2 + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &nsteps2); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeSetFixedStep(arkode_mem, 2.0 * hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t2 + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &nsteps2); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; retval = computeErrorWeights(y2, ewt, reltol, abstol, vtemp); if (check_retval(&retval, "computeErrorWeights", 1)) break; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp index f3fcbcd365..ff2f1de00b 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_accumerror_kpr.cpp @@ -234,18 +234,18 @@ int main(int argc, char* argv[]) if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; LS = SUNLinSol_Dense(y, A, ctx); if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; - retval = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) return (1); - retval = ARKStepSetJacFn(arkode_mem, Jn); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return (1); + retval = ARKodeSetJacFn(arkode_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; // Set desired solver order - retval = ARKStepSetOrder(arkode_mem, order); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; // Set the user data pointer - retval = ARKStepSetUserData(arkode_mem, (void*)&udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; } else { // ERK method @@ -254,16 +254,16 @@ int main(int argc, char* argv[]) if (check_retval((void*)arkode_mem, "ERKStepCreate", 0)) return 1; // Set maximum stepsize for ERK run - retval = ERKStepSetMaxStep(arkode_mem, ONE / abs(udata.G)); - if (check_retval(&retval, "ERKStepSetMaxStep", 1)) return (1); + retval = ARKodeSetMaxStep(arkode_mem, ONE / abs(udata.G)); + if (check_retval(&retval, "ARKodeSetMaxStep", 1)) return (1); // Set desired solver order - retval = ERKStepSetOrder(arkode_mem, order); - if (check_retval(&retval, "ERKStepSetOrder", 1)) return 1; + retval = ARKodeSetOrder(arkode_mem, order); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; // Set the user data pointer - retval = ERKStepSetUserData(arkode_mem, (void*)&udata); - if (check_retval(&retval, "ERKStepSetUserData", 1)) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; } // Integrate ODE, based on run type @@ -281,9 +281,9 @@ int main(int argc, char* argv[]) // Clean up and return if (rk_type == 0) { // Free integrator memory - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); } - else { ERKStepFree(&arkode_mem); } + else { ARKodeFree(&arkode_mem); } if (LS != NULL) SUNLinSolFree(LS); // free system linear solver if (A != NULL) SUNMatDestroy(A); // free system matrix N_VDestroy(y); // Free y vector @@ -356,13 +356,13 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Loop over tolerances cout << "\nAdaptive-step runs:\n"; - for (size_t irtol = 0; irtol < rtols.size(); irtol++) + for (int irtol = 0; irtol < rtols.size(); irtol++) { // Loop over accumulation types - for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run, and evolve over partition interval t = T0 + ipart * hpart; @@ -372,49 +372,45 @@ static int adaptive_run(void* arkode_mem, N_Vector y, sunrealtype T0, { // DIRK retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetAccumulatedErrorType(arkode_mem, - accum_types[iaccum]); - if (check_retval(&retval, "ARKStepSetAccumulatedErrorType", 1)) + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; - retval = ARKStepResetAccumulatedError(arkode_mem); - if (check_retval(&retval, "ARKStepResetAccumulatedError", 1)) - return 1; - retval = ARKStepSStolerances(arkode_mem, rtols[irtol], abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); - retval = ARKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); - if (check_retval(&retval, "ARKStepGetAccumulatedError", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, rtols[irtol], abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; } else { // ERK retval = ERKStepReInit(arkode_mem, fn, t, y); if (check_retval(&retval, "ERKStepReInit", 1)) return 1; - retval = ERKStepSetAccumulatedErrorType(arkode_mem, - accum_types[iaccum]); - if (check_retval(&retval, "ERKStepSetAccumulatedErrorType", 1)) - return 1; - retval = ERKStepResetAccumulatedError(arkode_mem); - if (check_retval(&retval, "ERKStepResetAccumulatedError", 1)) + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; - retval = ERKStepSStolerances(arkode_mem, rtols[irtol], abstol); - if (check_retval(&retval, "ERKStepSStolerances", 1)) return 1; - retval = ERKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ERKStepSetStopTime", 1)) return 1; - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1)) return (1); - retval = ERKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) break; - retval = ERKStepGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); - if (check_retval(&retval, "ERKStepGetAccumulatedError", 1)) break; - retval = ERKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ERKStepGetNumSteps", 1)) break; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, rtols[irtol], abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; } // Compute/print solution error @@ -459,13 +455,13 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Loop over step sizes cout << "\nFixed-step runs:\n"; - for (size_t ih = 0; ih < hvals.size(); ih++) + for (int ih = 0; ih < hvals.size(); ih++) { // Loop over built-in accumulation types - for (size_t iaccum = 0; iaccum < accum_types.size(); iaccum++) + for (int iaccum = 0; iaccum < accum_types.size(); iaccum++) { // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run, and evolve over partition interval t = T0 + ipart * hpart; @@ -475,59 +471,55 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, { // DIRK retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetAccumulatedErrorType(arkode_mem, - accum_types[iaccum]); - if (check_retval(&retval, "ARKStepSetAccumulatedErrorType", 1)) + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; - retval = ARKStepResetAccumulatedError(arkode_mem); - if (check_retval(&retval, "ARKStepResetAccumulatedError", 1)) - return 1; - retval = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); - retval = ARKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetJacEvalFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetJacEvalFrequency", 1)) return 1; - retval = ARKStepSetLSetupFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetLSetupFrequency", 1)) return 1; - retval = ARKStepSetMaxNonlinIters(arkode_mem, 20); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) return 1; - retval = ARKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); - if (check_retval(&retval, "ARKStepGetAccumulatedError", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; } else { // ERK retval = ERKStepReInit(arkode_mem, fn, t, y); if (check_retval(&retval, "ERKStepReInit", 1)) return 1; - retval = ERKStepSetAccumulatedErrorType(arkode_mem, - accum_types[iaccum]); - if (check_retval(&retval, "ERKStepSetAccumulatedErrorType", 1)) - return 1; - retval = ERKStepResetAccumulatedError(arkode_mem); - if (check_retval(&retval, "ERKStepResetAccumulatedError", 1)) + retval = ARKodeSetAccumulatedErrorType(arkode_mem, accum_types[iaccum]); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; - retval = ERKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ERKStepSetFixedStep", 1)) return 1; - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1)) return (1); - retval = ERKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ERKStepSStolerances", 1)) return 1; - retval = ERKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ERKStepSetStopTime", 1)) return 1; - retval = ERKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) break; - retval = ERKStepGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); - if (check_retval(&retval, "ERKStepGetAccumulatedError", 1)) break; - retval = ERKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ERKStepGetNumSteps", 1)) break; + retval = ARKodeResetAccumulatedError(arkode_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetAccumulatedError(arkode_mem, &(dsm_est[ipart])); + if (check_retval(&retval, "ARKodeGetAccumulatedError", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; } // Compute/print solution error @@ -546,7 +538,7 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, // Test double-step error estimator // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run, and evolve over partition interval t = t2 = T0 + ipart * hpart; @@ -558,69 +550,67 @@ static int fixed_run(void* arkode_mem, N_Vector y, sunrealtype T0, { // DIRK retval = ARKStepReInit(arkode_mem, NULL, fn, t, y); if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetAccumulatedErrorType(arkode_mem, -1); - if (check_retval(&retval, "ARKStepSetAccumulatedErrorType", 1)) - return 1; - retval = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); - retval = ARKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetJacEvalFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetJacEvalFrequency", 1)) return 1; - retval = ARKStepSetLSetupFrequency(arkode_mem, 1); - if (check_retval(&retval, "ARKStepSetLSetupFrequency", 1)) return 1; - retval = ARKStepSetMaxNonlinIters(arkode_mem, 20); - if (check_retval(&retval, "ARKStepSetMaxNonlinIters", 1)) return 1; - retval = ARKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(arkode_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(arkode_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; retval = ARKStepReInit(arkode_mem, NULL, fn, t2, y2); if (check_retval(&retval, "ARKStepReInit", 1)) return 1; - retval = ARKStepSetFixedStep(arkode_mem, 2.0 * hvals[ih]); - if (check_retval(&retval, "ARKStepSetFixedStep", 1)) return 1; - retval = ARKStepSetStopTime(arkode_mem, t2 + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) break; - retval = ARKStepGetNumSteps(arkode_mem, &nsteps2); - if (check_retval(&retval, "ARKStepGetNumSteps", 1)) break; + retval = ARKodeSetFixedStep(arkode_mem, 2.0 * hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t2 + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &nsteps2); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; } else { // ERK retval = ERKStepReInit(arkode_mem, fn, t, y); if (check_retval(&retval, "ERKStepReInit", 1)) return 1; - retval = ERKStepSetAccumulatedErrorType(arkode_mem, -1); - if (check_retval(&retval, "ERKStepSetAccumulatedErrorType", 1)) - return 1; - retval = ERKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_retval(&retval, "ERKStepSetFixedStep", 1)) return 1; - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000000); - if (check_retval(&retval, "ERKStepSetMaxNumSteps", 1)) return (1); - retval = ERKStepSetStopTime(arkode_mem, t + hpart); - if (check_retval(&retval, "ERKStepSetStopTime", 1)) return 1; - retval = ERKStepSStolerances(arkode_mem, reltol, abstol); - if (check_retval(&retval, "ERKStepSStolerances", 1)) return 1; - retval = ERKStepEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) break; - retval = ERKStepGetNumSteps(arkode_mem, &(Nsteps[ipart])); - if (check_retval(&retval, "ERKStepGetNumSteps", 1)) break; + retval = ARKodeSetAccumulatedErrorType(arkode_mem, -1); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetStopTime(arkode_mem, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &(Nsteps[ipart])); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; retval = ERKStepReInit(arkode_mem, fn, t2, y2); if (check_retval(&retval, "ERKStepReInit", 1)) return 1; - retval = ERKStepSetFixedStep(arkode_mem, 2.0 * hvals[ih]); - if (check_retval(&retval, "ERKStepSetFixedStep", 1)) return 1; - retval = ERKStepSetStopTime(arkode_mem, t2 + hpart); - if (check_retval(&retval, "ERKStepSetStopTime", 1)) return 1; - retval = ERKStepEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) break; - retval = ERKStepGetNumSteps(arkode_mem, &nsteps2); - if (check_retval(&retval, "ERKStepGetNumSteps", 1)) break; + retval = ARKodeSetFixedStep(arkode_mem, 2.0 * hvals[ih]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeSetStopTime(arkode_mem, t2 + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t2 + hpart, y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) break; + retval = ARKodeGetNumSteps(arkode_mem, &nsteps2); + if (check_retval(&retval, "ARKodeGetNumSteps", 1)) break; } retval = computeErrorWeights(y2, ewt, reltol, abstol, vtemp); if (check_retval(&retval, "computeErrorWeights", 1)) break; diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp index 1a6cbe642a..e2cb57a011 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_analytic_sys_mri.cpp @@ -162,31 +162,31 @@ int main(int argc, char* argv[]) if (check_flag((void*)C, "MRIStepCoupling_MIStoMRI", 0)) { return 1; } // Set routines - flag = ARKStepSetUserData(arkstep_mem, - (void*)&lamda); // Pass lamda to user functions - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } - flag = ARKStepSStolerances(arkstep_mem, reltol, abstol); // Specify tolerances - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } - flag = ARKStepSetFixedStep(arkstep_mem, Tf / Nt); // Specify fixed time step size - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetUserData(arkstep_mem, + (void*)&lamda); // Pass lamda to user functions + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(arkstep_mem, reltol, abstol); // Specify tolerances + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkstep_mem, Tf / Nt); // Specify fixed time step size + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } flag = ARKStepSetTables(arkstep_mem, 2, 0, B, NULL); // Specify Butcher table if (check_flag(&flag, "ARKStepSetTables", 1)) { return 1; } - flag = ARKStepSetMaxNumSteps(arkstep_mem, 2 * Nt); // Increase num internal steps - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } - - flag = MRIStepSetUserData(mristep_mem, - (void*)&lamda); // Pass lamda to user functions - if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; } - flag = MRIStepSStolerances(mristep_mem, reltol, abstol); // Specify tolerances - if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; } - flag = MRIStepSetFixedStep(mristep_mem, Tf / Nt); // Specify fixed time step sizes - if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; } - flag = ARKStepSetFixedStep(inner_mem, Tf / Nt / 10); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } - flag = MRIStepSetCoupling(mristep_mem, C); // Specify Butcher table + flag = ARKodeSetMaxNumSteps(arkstep_mem, 2 * Nt); // Increase num internal steps + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } + + flag = ARKodeSetUserData(mristep_mem, + (void*)&lamda); // Pass lamda to user functions + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } + flag = ARKodeSStolerances(mristep_mem, reltol, abstol); // Specify tolerances + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } + flag = ARKodeSetFixedStep(mristep_mem, Tf / Nt); // Specify fixed time step sizes + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(inner_mem, Tf / Nt / 10); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } + flag = MRIStepSetCoupling(mristep_mem, C); // Specify coupling table if (check_flag(&flag, "MRIStepSetCoupling", 1)) { return 1; } - flag = MRIStepSetMaxNumSteps(mristep_mem, 2 * Nt); // Increase num internal steps - if (check_flag(&flag, "MRIStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(mristep_mem, 2 * Nt); // Increase num internal steps + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } // Initialize implicit solver data structures if (fixedpoint) @@ -194,13 +194,13 @@ int main(int argc, char* argv[]) // Initialize fixed-point solvers and attach to integrators NLSa = SUNNonlinSol_FixedPoint(y, 50, sunctx); if (check_flag((void*)NLSa, "SUNNonlinSol_FixedPoint", 0)) { return 1; } - flag = ARKStepSetNonlinearSolver(arkstep_mem, NLSa); - if (check_flag(&flag, "ARKStepSetNonlinearSolver", 1)) { return 1; } + flag = ARKodeSetNonlinearSolver(arkstep_mem, NLSa); + if (check_flag(&flag, "ARKodeSetNonlinearSolver", 1)) { return 1; } NLSm = SUNNonlinSol_FixedPoint(y, 50, sunctx); if (check_flag((void*)NLSm, "SUNNonlinSol_FixedPoint", 0)) { return 1; } - flag = MRIStepSetNonlinearSolver(mristep_mem, NLSm); - if (check_flag(&flag, "MRIStepSetNonlinearSolver", 1)) { return 1; } + flag = ARKodeSetNonlinearSolver(mristep_mem, NLSm); + if (check_flag(&flag, "ARKodeSetNonlinearSolver", 1)) { return 1; } } else { @@ -216,47 +216,47 @@ int main(int argc, char* argv[]) if (check_flag((void*)LSm, "SUNLinSol_Dense", 0)) { return 1; } // Linear solver interface - flag = ARKStepSetLinearSolver(arkstep_mem, LSa, Aa); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } - flag = ARKStepSetJacFn(arkstep_mem, Jac); - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkstep_mem, LSa, Aa); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(arkstep_mem, Jac); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } - flag = MRIStepSetLinearSolver(mristep_mem, LSm, Am); - if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; } - flag = MRIStepSetJacFn(mristep_mem, Jac); - if (check_flag(&flag, "MRIStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetLinearSolver(mristep_mem, LSm, Am); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetJacFn(mristep_mem, Jac); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } // Specify linearly implicit RHS, with non-time-dependent Jacobian - flag = ARKStepSetLinear(arkstep_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkstep_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } - flag = MRIStepSetLinear(mristep_mem, 0); - if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(mristep_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } - // First call ARKStep to evolve the full problem, and print results + // First call ARKodeEvolve to evolve the full problem, and print results t = T0; N_VConst(ONE, y); - flag = ARKStepEvolve(arkstep_mem, Tf, y, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } - flag = ARKStepGetCurrentTime(arkstep_mem, &tcur); - if (check_flag(&flag, "ARKStepGetCurrentTime", 1)) { return 1; } - flag = ARKStepGetNumSteps(arkstep_mem, &ark_nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return 1; } + flag = ARKodeEvolve(arkstep_mem, Tf, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } + flag = ARKodeGetCurrentTime(arkstep_mem, &tcur); + if (check_flag(&flag, "ARKodeGetCurrentTime", 1)) { return 1; } + flag = ARKodeGetNumSteps(arkstep_mem, &ark_nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } flag = ARKStepGetNumRhsEvals(arkstep_mem, &ark_nfe, &ark_nfi); if (check_flag(&flag, "ARKStepGetNumRhsEvals", 1)) { return 1; } - flag = ARKStepGetNumNonlinSolvIters(arkstep_mem, &ark_nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return 1; } - flag = ARKStepGetNumNonlinSolvConvFails(arkstep_mem, &ark_ncfn); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvConvFails", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(arkstep_mem, &ark_nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvConvFails(arkstep_mem, &ark_ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; } if (!fixedpoint) { - flag = ARKStepGetNumLinSolvSetups(arkstep_mem, &ark_nsetups); - if (check_flag(&flag, "ARKStepGetNumLinSolvSetups", 1)) { return 1; } - flag = ARKStepGetNumJacEvals(arkstep_mem, &ark_nje); - if (check_flag(&flag, "ARKStepGetNumJacEvals", 1)) { return 1; } - flag = ARKStepGetNumLinRhsEvals(arkstep_mem, &ark_nfeLS); - check_flag(&flag, "ARKStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(arkstep_mem, &ark_nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; } + flag = ARKodeGetNumJacEvals(arkstep_mem, &ark_nje); + if (check_flag(&flag, "ARKodeGetNumJacEvals", 1)) { return 1; } + flag = ARKodeGetNumLinRhsEvals(arkstep_mem, &ark_nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); } cout << "\nARKStep Solver Statistics:\n"; cout << " Return time = " << t << "\n"; @@ -275,29 +275,29 @@ int main(int argc, char* argv[]) cout << " Total number of Jacobian evaluations = " << ark_nje << "\n"; } - // Second call MRIStep to evolve the full problem, and print results + // Second call ARKodeEvolve to evolve the full problem, and print results t = T0; N_VConst(ZERO, y); - flag = MRIStepEvolve(mristep_mem, Tf, y, &t, ARK_NORMAL); - if (check_flag(&flag, "MRIStepEvolve", 1)) { return 1; } - flag = MRIStepGetCurrentTime(arkstep_mem, &tcur); - if (check_flag(&flag, "MRIStepGetCurrentTime", 1)) { return 1; } - flag = MRIStepGetNumSteps(mristep_mem, &mri_nst); - if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return 1; } + flag = ARKodeEvolve(mristep_mem, Tf, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } + flag = ARKodeGetCurrentTime(arkstep_mem, &tcur); + if (check_flag(&flag, "ARKodeGetCurrentTime", 1)) { return 1; } + flag = ARKodeGetNumSteps(mristep_mem, &mri_nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } flag = MRIStepGetNumRhsEvals(mristep_mem, &mri_nfse, &mri_nfsi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return 1; } - flag = MRIStepGetNumNonlinSolvIters(mristep_mem, &mri_nni); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return 1; } - flag = MRIStepGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(mristep_mem, &mri_nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; } if (!fixedpoint) { - flag = MRIStepGetNumLinSolvSetups(mristep_mem, &mri_nsetups); - if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return 1; } - flag = MRIStepGetNumJacEvals(mristep_mem, &mri_nje); - if (check_flag(&flag, "MRIStepGetNumJacEvals", 1)) { return 1; } - flag = MRIStepGetNumLinRhsEvals(mristep_mem, &mri_nfeLS); - check_flag(&flag, "MRIStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinSolvSetups(mristep_mem, &mri_nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; } + flag = ARKodeGetNumJacEvals(mristep_mem, &mri_nje); + if (check_flag(&flag, "ARKodeGetNumJacEvals", 1)) { return 1; } + flag = ARKodeGetNumLinRhsEvals(mristep_mem, &mri_nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); } cout << "\nMRIStep Solver Statistics:\n"; cout << " Return time = " << t << "\n"; @@ -369,9 +369,9 @@ int main(int argc, char* argv[]) ARKodeButcherTable_Free(B); // Free Butcher table ARKodeButcherTable_Free(Bc); // Free Butcher table MRIStepCoupling_Free(C); // Free MRI coupling table - ARKStepFree(&arkstep_mem); // Free integrator memory - MRIStepFree(&mristep_mem); - ARKStepFree(&inner_mem); + ARKodeFree(&arkstep_mem); // Free integrator memory + ARKodeFree(&mristep_mem); + ARKodeFree(&inner_mem); MRIStepInnerStepper_Free(&inner_stepper); if (fixedpoint) { diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp index d08ddf3a30..6a98c79797 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_ark.cpp @@ -468,16 +468,16 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, if (check_flag((void*)arkstep_mem, "ARKStepCreate", 0)) { return 1; } // Set user data - flag = ARKStepSetUserData(arkstep_mem, &prob_data); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkstep_mem, &prob_data); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkstep_mem, prob_opts.reltol, prob_opts.abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkstep_mem, prob_opts.reltol, prob_opts.abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Specify fixed time step size - flag = ARKStepSetFixedStep(arkstep_mem, prob_opts.h); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkstep_mem, prob_opts.h); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } // Attach Butcher tables (ignore actual method order) flag = ARKStepSetTables(arkstep_mem, 1, 0, Bi, Be); @@ -486,8 +486,8 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, // Lagrange interpolant (removes additional RHS evaluation with DIRK methods) if (prob_opts.i_type == interp_type::lagrange) { - flag = ARKStepSetInterpolantType(arkstep_mem, ARK_INTERP_LAGRANGE); - if (check_flag(&flag, "ARKStepSetInterpolantType", 1)) { return 1; } + flag = ARKodeSetInterpolantType(arkstep_mem, ARK_INTERP_LAGRANGE); + if (check_flag(&flag, "ARKodeSetInterpolantType", 1)) { return 1; } } // Create matrix and linear solver (if necessary) @@ -504,20 +504,20 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, if (check_flag((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } // Attach linear solver - flag = ARKStepSetLinearSolver(arkstep_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkstep_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } // Set Jacobian function - flag = ARKStepSetJacFn(arkstep_mem, Ji); - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetJacFn(arkstep_mem, Ji); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } // Specify linearly implicit RHS, with non-time-dependent Jacobian - flag = ARKStepSetLinear(arkstep_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkstep_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } // Specify implicit predictor method - flag = ARKStepSetPredictorMethod(arkstep_mem, prob_opts.p_type); - if (check_flag(&flag, "ARKStepSetPredictorMethod", 1)) { return 1; } + flag = ARKodeSetPredictorMethod(arkstep_mem, prob_opts.p_type); + if (check_flag(&flag, "ARKodeSetPredictorMethod", 1)) { return 1; } } // Create mass matrix and linear solver (if necessary) @@ -536,11 +536,11 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, int time_dep = 0; if (prob_data.m_type == mass_matrix_type::time_dependent) { time_dep = 1; } - flag = ARKStepSetMassLinearSolver(arkstep_mem, MLS, M, time_dep); - if (check_flag(&flag, "ARKStepSetMassLinearSolver", 1)) { return 1; } + flag = ARKodeSetMassLinearSolver(arkstep_mem, MLS, M, time_dep); + if (check_flag(&flag, "ARKodeSetMassLinearSolver", 1)) { return 1; } - flag = ARKStepSetMassFn(arkstep_mem, MassMatrix); - if (check_flag(&flag, "ARKStepSetMassFn", 1)) { return 1; } + flag = ARKodeSetMassFn(arkstep_mem, MassMatrix); + if (check_flag(&flag, "ARKodeSetMassFn", 1)) { return 1; } } // -------------- @@ -557,8 +557,8 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, std::cout << "--------------------" << std::endl; // Advance in time - flag = ARKStepEvolve(arkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(arkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } // Update output time t_out += prob_opts.h; @@ -592,11 +592,11 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, std::cout << "Dense Output" << std::endl; sunrealtype h_last; - flag = ARKStepGetLastStep(arkstep_mem, &h_last); - if (check_flag(&flag, "ARKStepGetLastStep", 1)) { return 1; } + flag = ARKodeGetLastStep(arkstep_mem, &h_last); + if (check_flag(&flag, "ARKodeGetLastStep", 1)) { return 1; } - flag = ARKStepGetDky(arkstep_mem, t_ret - h_last / TWO, 0, y); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkstep_mem, t_ret - h_last / TWO, 0, y); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } // Stiffly accurate (and FSAL) methods do not require an additional RHS // evaluation to get the new RHS value at the end of a step for dense @@ -652,8 +652,8 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, if (numfails == 0) { // Advance in time - flag = ARKStepEvolve(arkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(arkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } // Update output time t_out += prob_opts.h; @@ -675,7 +675,7 @@ int run_tests(ARKodeButcherTable Be, ARKodeButcherTable Bi, // Clean up // -------- - ARKStepFree(&arkstep_mem); + ARKodeFree(&arkstep_mem); SUNLinSolFree(LS); SUNMatDestroy(A); SUNLinSolFree(MLS); @@ -746,8 +746,8 @@ int expected_rhs_evals(ProblemOptions& prob_opts, int stages, int order, // Get number of steps and nonlinear solver iterations long int nst = 0; - flag = ARKStepGetNumSteps(arkstep_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return 1; } + flag = ARKodeGetNumSteps(arkstep_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } long int nni = 0; long int extra_fe_evals = 0; @@ -755,8 +755,8 @@ int expected_rhs_evals(ProblemOptions& prob_opts, int stages, int order, if (prob_opts.r_type == rk_type::impl || prob_opts.r_type == rk_type::imex) { - flag = ARKStepGetNumNonlinSolvIters(arkstep_mem, &nni); - if (check_flag(&flag, "ARKStepGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(arkstep_mem, &nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } } // Expected number of explicit functions evaluations @@ -829,8 +829,8 @@ int check_rhs_evals(rk_type r_type, void* arkstep_mem, long int nfe_expected, int flag = 0; long int nst; - flag = ARKStepGetNumSteps(arkstep_mem, &nst); - if (check_flag(&flag, "ARKStepGetNumSteps", 1)) { return 1; } + flag = ARKodeGetNumSteps(arkstep_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } long int nfe, nfi; flag = ARKStepGetNumRhsEvals(arkstep_mem, &nfe, &nfi); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp index 9338d33550..a97e27ecd8 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_erk.cpp @@ -234,22 +234,22 @@ int run_tests(ARKodeButcherTable Be, ProblemData& prob_data, if (check_flag((void*)erkstep_mem, "ERKStepCreate", 0)) { return 1; } // Set user data - flag = ERKStepSetUserData(erkstep_mem, &prob_data); - if (check_flag(&flag, "ERKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(erkstep_mem, &prob_data); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Specify tolerances - flag = ERKStepSStolerances(erkstep_mem, prob_opts.reltol, prob_opts.abstol); - if (check_flag(&flag, "ERKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(erkstep_mem, prob_opts.reltol, prob_opts.abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Specify fixed time step size - flag = ERKStepSetFixedStep(erkstep_mem, prob_opts.h); - if (check_flag(&flag, "ERKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(erkstep_mem, prob_opts.h); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } // Lagrange interpolant (removes additional RHS evaluation with DIRK methods) if (prob_opts.i_type == interp_type::lagrange) { - flag = ERKStepSetInterpolantType(erkstep_mem, ARK_INTERP_LAGRANGE); - if (check_flag(&flag, "ERKStepSetInterpolantType", 1)) { return 1; } + flag = ARKodeSetInterpolantType(erkstep_mem, ARK_INTERP_LAGRANGE); + if (check_flag(&flag, "ARKodeSetInterpolantType", 1)) { return 1; } } // Attach Butcher tables @@ -270,8 +270,8 @@ int run_tests(ARKodeButcherTable Be, ProblemData& prob_data, std::cout << "--------------------" << std::endl; // Advance in time - flag = ERKStepEvolve(erkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); - if (check_flag(&flag, "ERKStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(erkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } // Update output time t_out += prob_opts.h; @@ -302,11 +302,11 @@ int run_tests(ARKodeButcherTable Be, ProblemData& prob_data, std::cout << "Dense Output" << std::endl; sunrealtype h_last; - flag = ERKStepGetLastStep(erkstep_mem, &h_last); - if (check_flag(&flag, "ERKStepGetLastStep", 1)) { return 1; } + flag = ARKodeGetLastStep(erkstep_mem, &h_last); + if (check_flag(&flag, "ARKodeGetLastStep", 1)) { return 1; } - flag = ERKStepGetDky(erkstep_mem, t_ret - h_last / TWO, 0, y); - if (check_flag(&flag, "ERKStepGetDky", 1)) { return 1; } + flag = ARKodeGetDky(erkstep_mem, t_ret - h_last / TWO, 0, y); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } // Stiffly accurate (and FSAL) methods do not require an additional RHS // evaluation to get the new RHS value at the end of a step for dense @@ -342,8 +342,8 @@ int run_tests(ARKodeButcherTable Be, ProblemData& prob_data, if (numfails == 0) { // Advance in time - flag = ERKStepEvolve(erkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); - if (check_flag(&flag, "ERKStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(erkstep_mem, t_out, y, &t_ret, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } // Update output time t_out += prob_opts.h; @@ -362,7 +362,7 @@ int run_tests(ARKodeButcherTable Be, ProblemData& prob_data, // Clean up // -------- - ERKStepFree(&erkstep_mem); + ARKodeFree(&erkstep_mem); N_VDestroy(y); return numfails; @@ -409,8 +409,8 @@ int expected_rhs_evals(interp_type i_type, int stages, // Get number of steps and nonlinear solver iterations long int nst = 0; - flag = ERKStepGetNumSteps(erkstep_mem, &nst); - if (check_flag(&flag, "ERKStepGetNumSteps", 1)) { return 1; } + flag = ARKodeGetNumSteps(erkstep_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } // Expected number of explicit functions evaluations nfe_expected = 0; @@ -445,8 +445,8 @@ int check_rhs_evals(void* erkstep_mem, long int nfe_expected) int flag = 0; long int nst = 0; - flag = ERKStepGetNumSteps(erkstep_mem, &nst); - if (check_flag(&flag, "ERKStepGetNumSteps", 1)) { return 1; } + flag = ARKodeGetNumSteps(erkstep_mem, &nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } long int nfe; flag = ERKStepGetNumRhsEvals(erkstep_mem, &nfe); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp index 956316dd75..1797f684b7 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_dahlquist_mri.cpp @@ -176,16 +176,16 @@ int run_tests(MRISTEP_METHOD_TYPE type, sunrealtype t0, int nsteps, if (check_flag((void*)arkstep_mem, "ARKStepCreate", 0)) { return 1; } // Set user data - flag = ARKStepSetUserData(arkstep_mem, udata); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkstep_mem, udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Specify tolerances - flag = ARKStepSStolerances(arkstep_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkstep_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Specify fixed time step size - flag = ARKStepSetFixedStep(arkstep_mem, hf); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkstep_mem, hf); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } // Wrap ARKStep integrator as fast integrator object MRIStepInnerStepper inner_stepper = nullptr; @@ -215,30 +215,30 @@ int run_tests(MRISTEP_METHOD_TYPE type, sunrealtype t0, int nsteps, if (check_flag((void*)mristep_mem, "MRIStepCreate", 0)) { return 1; } // Set user data - flag = MRIStepSetUserData(mristep_mem, udata); - if (check_flag(&flag, "MRIStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(mristep_mem, udata); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } // Specify tolerances - flag = MRIStepSStolerances(mristep_mem, reltol, abstol); - if (check_flag(&flag, "MRIStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } // Specify fixed time step sizes - flag = MRIStepSetFixedStep(mristep_mem, hs); - if (check_flag(&flag, "MRIStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(mristep_mem, hs); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) { // Attach linear solver - flag = MRIStepSetLinearSolver(mristep_mem, LS, A); - if (check_flag(&flag, "MRIStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } // Set Jacobian function - flag = MRIStepSetJacFn(mristep_mem, Ji); - if (check_flag(&flag, "MRIStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetJacFn(mristep_mem, Ji); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } // Specify linearly implicit RHS, with non-time-dependent Jacobian - flag = MRIStepSetLinear(mristep_mem, 0); - if (check_flag(&flag, "MRIStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(mristep_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } } // ------------------------------------ @@ -271,7 +271,7 @@ int run_tests(MRISTEP_METHOD_TYPE type, sunrealtype t0, int nsteps, num_methods = 4; //num_methods = 3; - methods = new ARKODE_MRITableID[num_methods]; + methods = new ARKODE_MRITableID[num_methods]; methods[0] = ARKODE_MERK21; methods[1] = ARKODE_MERK32; @@ -356,8 +356,8 @@ int run_tests(MRISTEP_METHOD_TYPE type, sunrealtype t0, int nsteps, for (int i = 0; i < nsteps; i++) { // Advance in time - flag = MRIStepEvolve(mristep_mem, tf, y, &t, ARK_ONE_STEP); - if (check_flag(&flag, "MRIStepEvolve", 1)) { return 1; } + flag = ARKodeEvolve(mristep_mem, tf, y, &t, ARK_ONE_STEP); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } // Update output time tf += hs; @@ -371,31 +371,28 @@ int run_tests(MRISTEP_METHOD_TYPE type, sunrealtype t0, int nsteps, long int mri_nni, mri_ncfn; // nonlinear solver long int mri_nsetups, mri_nje, mri_nfeLS; // linear solver - flag = MRIStepGetNumSteps(mristep_mem, &mri_nst); - if (check_flag(&flag, "MRIStepGetNumSteps", 1)) { return 1; } + flag = ARKodeGetNumSteps(mristep_mem, &mri_nst); + if (check_flag(&flag, "ARKodeGetNumSteps", 1)) { return 1; } flag = MRIStepGetNumRhsEvals(mristep_mem, &mri_nfse, &mri_nfsi); if (check_flag(&flag, "MRIStepGetNumRhsEvals", 1)) { return 1; } if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) { - flag = MRIStepGetNumNonlinSolvIters(mristep_mem, &mri_nni); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvIters", 1)) { return 1; } + flag = ARKodeGetNumNonlinSolvIters(mristep_mem, &mri_nni); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvIters", 1)) { return 1; } - flag = MRIStepGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn); - if (check_flag(&flag, "MRIStepGetNumNonlinSolvConvFails", 1)) - { - return 1; - } + flag = ARKodeGetNumNonlinSolvConvFails(mristep_mem, &mri_ncfn); + if (check_flag(&flag, "ARKodeGetNumNonlinSolvConvFails", 1)) { return 1; } - flag = MRIStepGetNumLinSolvSetups(mristep_mem, &mri_nsetups); - if (check_flag(&flag, "MRIStepGetNumLinSolvSetups", 1)) { return 1; } + flag = ARKodeGetNumLinSolvSetups(mristep_mem, &mri_nsetups); + if (check_flag(&flag, "ARKodeGetNumLinSolvSetups", 1)) { return 1; } - flag = MRIStepGetNumJacEvals(mristep_mem, &mri_nje); - if (check_flag(&flag, "MRIStepGetNumJacEvals", 1)) { return 1; } + flag = ARKodeGetNumJacEvals(mristep_mem, &mri_nje); + if (check_flag(&flag, "ARKodeGetNumJacEvals", 1)) { return 1; } - flag = MRIStepGetNumLinRhsEvals(mristep_mem, &mri_nfeLS); - check_flag(&flag, "MRIStepGetNumLinRhsEvals", 1); + flag = ARKodeGetNumLinRhsEvals(mristep_mem, &mri_nfeLS); + check_flag(&flag, "ARKodeGetNumLinRhsEvals", 1); } sunrealtype pow = udata->lambda_f; @@ -506,8 +503,8 @@ int run_tests(MRISTEP_METHOD_TYPE type, sunrealtype t0, int nsteps, // Clean up MRIStepInnerStepper_Free(&inner_stepper); - MRIStepFree(&mristep_mem); - ARKStepFree(&arkstep_mem); + ARKodeFree(&mristep_mem); + ARKodeFree(&arkstep_mem); if (type == MRISTEP_IMPLICIT || type == MRISTEP_IMEX) { SUNLinSolFree(LS); diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp index 7dee98545f..7b3598451d 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac.cpp @@ -214,8 +214,8 @@ int main(int argc, char* argv[]) void* arkode_mem = ARKStepCreate(nullptr, f, ZERO, y, sunctx); if (check_ptr(arkode_mem, "ARKStepCreate")) { return 1; } - flag = ARKStepSStolerances(arkode_mem, rtol, atol); - if (check_flag(flag, "ARKStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } SUNMatrix A = SUNDenseMatrix(2, 2, sunctx); if (check_ptr(A, "SUNDenseMatrix")) { return 1; } @@ -223,35 +223,35 @@ int main(int argc, char* argv[]) SUNLinearSolver LS = SUNLinSol_Dense(y, A, sunctx); if (check_ptr(LS, "SUNLinSol_Dense")) { return 1; } - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(flag, "ARKStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } sunrealtype udata[4] = {-TWO, HALF, HALF, -ONE}; - flag = ARKStepSetUserData(arkode_mem, udata); - if (check_flag(flag, "ARKStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(arkode_mem, udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // Initial time and fist output time sunrealtype tret = ZERO; sunrealtype tout = tret + SUN_RCONST(0.1); // Advance one step in time - flag = ARKStepEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); - if (check_flag(flag, "ARKStep")) { return 1; } + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKode")) { return 1; } // Get the internal finite difference approximation to J SUNMatrix Jdq; - flag = ARKStepGetJac(arkode_mem, &Jdq); - if (check_flag(flag, "ARKStepGetJac")) { return 1; } + flag = ARKodeGetJac(arkode_mem, &Jdq); + if (check_flag(flag, "ARKodeGetJac")) { return 1; } // Get the step and time at which the approximation was computed long int nst_Jdq; - flag = ARKStepGetJacNumSteps(arkode_mem, &nst_Jdq); - if (check_flag(flag, "ARKStepGetJacNumSteps")) { return 1; } + flag = ARKodeGetJacNumSteps(arkode_mem, &nst_Jdq); + if (check_flag(flag, "ARKodeGetJacNumSteps")) { return 1; } sunrealtype t_Jdq; - flag = ARKStepGetJacTime(arkode_mem, &t_Jdq); - if (check_flag(flag, "ARKStepGetJacTime")) { return 1; } + flag = ARKodeGetJacTime(arkode_mem, &t_Jdq); + if (check_flag(flag, "ARKodeGetJacTime")) { return 1; } // Compute the true Jacobian SUNMatrix Jtrue = SUNDenseMatrix(2, 2, sunctx); @@ -302,7 +302,7 @@ int main(int argc, char* argv[]) SUNMatDestroy(A); SUNMatDestroy(Jtrue); SUNLinSolFree(LS); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); return result; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp index 4ad57a55e4..af9168d5fd 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_getjac_mri.cpp @@ -233,11 +233,11 @@ int main(int argc, char* argv[]) void* arkode_mem = MRIStepCreate(nullptr, f, ZERO, y, inner_stepper, sunctx); if (check_ptr(arkode_mem, "MRIStepCreate")) { return 1; } - flag = MRIStepSStolerances(arkode_mem, rtol, atol); - if (check_flag(flag, "MRIStepSStolerances")) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(flag, "ARKodeSStolerances")) { return 1; } - flag = MRIStepSetFixedStep(arkode_mem, SUN_RCONST(1.0e-5)); - if (check_flag(flag, "MRIStepSetFixedStep")) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, SUN_RCONST(1.0e-5)); + if (check_flag(flag, "ARKodeSetFixedStep")) { return 1; } SUNMatrix A = SUNDenseMatrix(2, 2, sunctx); if (check_ptr(A, "SUNDenseMatrix")) { return 1; } @@ -245,35 +245,35 @@ int main(int argc, char* argv[]) SUNLinearSolver LS = SUNLinSol_Dense(y, A, sunctx); if (check_ptr(LS, "SUNLinSol_Dense")) { return 1; } - flag = MRIStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(flag, "MRIStepSetLinearSolver")) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(flag, "ARKodeSetLinearSolver")) { return 1; } sunrealtype udata[4] = {-TWO, HALF, HALF, -ONE}; - flag = MRIStepSetUserData(arkode_mem, udata); - if (check_flag(flag, "MRIStepSetUserData")) { return 1; } + flag = ARKodeSetUserData(arkode_mem, udata); + if (check_flag(flag, "ARKodeSetUserData")) { return 1; } // Initial time and fist output time sunrealtype tret = ZERO; sunrealtype tout = tret + SUN_RCONST(0.1); // Advance one step in time - flag = MRIStepEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); - if (check_flag(flag, "MRIStep")) { return 1; } + flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_ONE_STEP); + if (check_flag(flag, "ARKode")) { return 1; } // Get the internal finite difference approximation to J SUNMatrix Jdq; - flag = MRIStepGetJac(arkode_mem, &Jdq); - if (check_flag(flag, "MRIStepGetJac")) { return 1; } + flag = ARKodeGetJac(arkode_mem, &Jdq); + if (check_flag(flag, "ARKodeGetJac")) { return 1; } // Get the step and time at which the approximation was computed long int nst_Jdq; - flag = MRIStepGetJacNumSteps(arkode_mem, &nst_Jdq); - if (check_flag(flag, "MRIStepGetJacNumSteps")) { return 1; } + flag = ARKodeGetJacNumSteps(arkode_mem, &nst_Jdq); + if (check_flag(flag, "ARKodeGetJacNumSteps")) { return 1; } sunrealtype t_Jdq; - flag = MRIStepGetJacTime(arkode_mem, &t_Jdq); - if (check_flag(flag, "MRIStepGetJacTime")) { return 1; } + flag = ARKodeGetJacTime(arkode_mem, &t_Jdq); + if (check_flag(flag, "ARKodeGetJacTime")) { return 1; } // Compute the true Jacobian SUNMatrix Jtrue = SUNDenseMatrix(2, 2, sunctx); @@ -325,8 +325,8 @@ int main(int argc, char* argv[]) SUNMatDestroy(Jtrue); SUNLinSolFree(LS); MRIStepInnerStepper_Free(&inner_stepper); - ARKStepFree(&inner_arkode_mem); - MRIStepFree(&arkode_mem); + ARKodeFree(&inner_arkode_mem); + ARKodeFree(&arkode_mem); return result; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp index ddc880feb9..b050a99db9 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_kpr_mriadapt.cpp @@ -228,36 +228,6 @@ int main(int argc, char* argv[]) std::cout << " explicit Knoth-Wolke MIS\n"; PrintSlowAdaptivity(opts); break; - case (9): - f_se = (opts.fast_type == 0) ? fs : fse; - f_si = (opts.fast_type == 0) ? ff : fsi; - J_s = (opts.fast_type == 0) ? Jf : Jsi; - P = 3; - slowimplicit = SUNTRUE; - mri_table = ARKODE_IMEX_MRI_GARK3a; - std::cout << " ImEx 3a MRI-GARK\n"; - PrintSlowAdaptivity(opts); - break; - case (10): - f_se = (opts.fast_type == 0) ? fs : fse; - f_si = (opts.fast_type == 0) ? ff : fsi; - J_s = (opts.fast_type == 0) ? Jf : Jsi; - P = 3; - slowimplicit = SUNTRUE; - mri_table = ARKODE_IMEX_MRI_GARK3b; - std::cout << " ImEx 3b MRI-GARK\n"; - PrintSlowAdaptivity(opts); - break; - case (11): - f_se = (opts.fast_type == 0) ? fs : fse; - f_si = (opts.fast_type == 0) ? ff : fsi; - J_s = (opts.fast_type == 0) ? Jf : Jsi; - P = 4; - slowimplicit = SUNTRUE; - mri_table = ARKODE_IMEX_MRI_GARK4; - std::cout << " ImEx 4 MRI-GARK\n"; - PrintSlowAdaptivity(opts); - break; case (1): f_se = (opts.fast_type == 0) ? fn : fs; P = 2; @@ -313,6 +283,36 @@ int main(int argc, char* argv[]) std::cout << " implicit ESDIRK46a MRI-GARK\n"; PrintSlowAdaptivity(opts); break; + case (9): + f_se = (opts.fast_type == 0) ? fs : fse; + f_si = (opts.fast_type == 0) ? ff : fsi; + J_s = (opts.fast_type == 0) ? Jf : Jsi; + P = 3; + slowimplicit = SUNTRUE; + mri_table = ARKODE_IMEX_MRI_GARK3a; + std::cout << " ImEx 3a MRI-GARK\n"; + PrintSlowAdaptivity(opts); + break; + case (10): + f_se = (opts.fast_type == 0) ? fs : fse; + f_si = (opts.fast_type == 0) ? ff : fsi; + J_s = (opts.fast_type == 0) ? Jf : Jsi; + P = 3; + slowimplicit = SUNTRUE; + mri_table = ARKODE_IMEX_MRI_GARK3b; + std::cout << " ImEx 3b MRI-GARK\n"; + PrintSlowAdaptivity(opts); + break; + case (11): + f_se = (opts.fast_type == 0) ? fs : fse; + f_si = (opts.fast_type == 0) ? ff : fsi; + J_s = (opts.fast_type == 0) ? Jf : Jsi; + P = 4; + slowimplicit = SUNTRUE; + mri_table = ARKODE_IMEX_MRI_GARK4; + std::cout << " ImEx 4 MRI-GARK\n"; + PrintSlowAdaptivity(opts); + break; } std::cout << "\n Fast integrator:\n"; switch (opts.fast_type) @@ -409,8 +409,8 @@ int main(int argc, char* argv[]) void* inner_arkode_mem = NULL; // ARKode memory structure inner_arkode_mem = ARKStepCreate(f_fe, f_fi, T0, y, sunctx); if (check_ptr((void*)inner_arkode_mem, "ARKStepCreate")) return 1; - retval = ARKStepSetOrder(inner_arkode_mem, p); - if (check_flag(retval, "ARKStepSetOrder")) return 1; + retval = ARKodeSetOrder(inner_arkode_mem, p); + if (check_flag(retval, "ARKodeSetOrder")) return 1; SUNMatrix Af = NULL; // matrix for fast solver SUNLinearSolver LSf = NULL; // fast linear solver object if (fastimplicit) @@ -419,37 +419,37 @@ int main(int argc, char* argv[]) if (check_ptr((void*)Af, "SUNDenseMatrix")) return 1; LSf = SUNLinSol_Dense(y, Af, sunctx); if (check_ptr((void*)LSf, "SUNLinSol_Dense")) return 1; - retval = ARKStepSetLinearSolver(inner_arkode_mem, LSf, Af); - if (check_flag(retval, "ARKStepSetLinearSolver")) return 1; - retval = ARKStepSetJacFn(inner_arkode_mem, J_f); - if (check_flag(retval, "ARKStepSetJacFn")) return 1; + retval = ARKodeSetLinearSolver(inner_arkode_mem, LSf, Af); + if (check_flag(retval, "ARKodeSetLinearSolver")) return 1; + retval = ARKodeSetJacFn(inner_arkode_mem, J_f); + if (check_flag(retval, "ARKodeSetJacFn")) return 1; } - retval = ARKStepSStolerances(inner_arkode_mem, opts.rtol, opts.atol); - if (check_flag(retval, "ARKStepSStolerances")) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, opts.rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; if (opts.fcontrol != 0) { - retval = ARKStepSetAdaptController(inner_arkode_mem, fcontrol); - if (check_flag(retval, "ARKStepSetAdaptController")) return 1; + retval = ARKodeSetAdaptController(inner_arkode_mem, fcontrol); + if (check_flag(retval, "ARKodeSetAdaptController")) return 1; if (opts.set_h0 != 0) { - retval = ARKStepSetInitStep(inner_arkode_mem, opts.hf); - if (check_flag(retval, "ARKStepSetInitStep")) return 1; + retval = ARKodeSetInitStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; } if (opts.fast_pq == 1) { - retval = ARKStepSetAdaptivityAdjustment(inner_arkode_mem, 0); - if (check_flag(retval, "ARKStepSetAdaptivityAdjustment")) return 1; + retval = ARKodeSetAdaptivityAdjustment(inner_arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } } else { - retval = ARKStepSetFixedStep(inner_arkode_mem, opts.hf); - if (check_flag(retval, "ARKStepSetFixedStep")) return 1; + retval = ARKodeSetFixedStep(inner_arkode_mem, opts.hf); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; } - retval = ARKStepSetMaxNumSteps(inner_arkode_mem, 10000); - if (check_flag(retval, "ARKStepSetMaxNumSteps")) return 1; - retval = ARKStepSetUserData(inner_arkode_mem, (void*)&opts); - if (check_flag(retval, "ARKStepSetUserData")) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 10000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(inner_arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; // Create inner stepper MRIStepInnerStepper inner_stepper = NULL; // inner stepper @@ -565,36 +565,36 @@ int main(int argc, char* argv[]) if (check_ptr((void*)As, "SUNDenseMatrix")) return 1; LSs = SUNLinSol_Dense(y, As, sunctx); if (check_ptr((void*)LSs, "SUNLinSol_Dense")) return 1; - retval = MRIStepSetLinearSolver(arkode_mem, LSs, As); - if (check_flag(retval, "MRIStepSetLinearSolver")) return 1; - retval = MRIStepSetJacFn(arkode_mem, J_s); - if (check_flag(retval, "MRIStepSetJacFn")) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, LSs, As); + if (check_flag(retval, "ARKodeSetLinearSolver")) return 1; + retval = ARKodeSetJacFn(arkode_mem, J_s); + if (check_flag(retval, "ARKodeSetJacFn")) return 1; } - retval = MRIStepSStolerances(arkode_mem, opts.rtol, opts.atol); - if (check_flag(retval, "MRIStepSStolerances")) return 1; - retval = MRIStepSetMaxNumSteps(arkode_mem, 10000); - if (check_flag(retval, "MRIStepSetMaxNumSteps")) return 1; - retval = MRIStepSetUserData(arkode_mem, (void*)&opts); - if (check_flag(retval, "MRIStepSetUserData")) return 1; + retval = ARKodeSStolerances(arkode_mem, opts.rtol, opts.atol); + if (check_flag(retval, "ARKodeSStolerances")) return 1; + retval = ARKodeSetMaxNumSteps(arkode_mem, 10000); + if (check_flag(retval, "ARKodeSetMaxNumSteps")) return 1; + retval = ARKodeSetUserData(arkode_mem, (void*)&opts); + if (check_flag(retval, "ARKodeSetUserData")) return 1; if (opts.scontrol != 0) { retval = MRIStepSetAdaptController(arkode_mem, scontrol); - if (check_flag(retval, "MRIStepSetController")) return 1; + if (check_flag(retval, "MRIStepSetAdaptController")) return 1; if (opts.set_h0 != 0) { - retval = MRIStepSetInitStep(arkode_mem, opts.hs); - if (check_flag(retval, "MRIStepSetInitStep")) return 1; + retval = ARKodeSetInitStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetInitStep")) return 1; } if (opts.slow_pq == 1) { - retval = ARKStepSetAdaptivityAdjustment(arkode_mem, 0); - if (check_flag(retval, "ARKStepSetAdaptivityAdjustment")) return 1; + retval = ARKodeSetAdaptivityAdjustment(arkode_mem, 0); + if (check_flag(retval, "ARKodeSetAdaptivityAdjustment")) return 1; } } else { - retval = MRIStepSetFixedStep(arkode_mem, opts.hs); - if (check_flag(retval, "MRIStepSetFixedStep")) return 1; + retval = ARKodeSetFixedStep(arkode_mem, opts.hs); + if (check_flag(retval, "ARKodeSetFixedStep")) return 1; } // @@ -613,7 +613,7 @@ int main(int argc, char* argv[]) SUNRabs(NV_Ith_S(y, 0) - utrue(T0, &opts)), SUNRabs(NV_Ith_S(y, 1) - vtrue(T0, &opts))); - // Main time-stepping loop: calls MRIStepEvolve to perform the + // Main time-stepping loop: calls ARKodeEvolve to perform the // integration, then prints results. Stops when the final time // has been reached sunrealtype t, tout; @@ -634,8 +634,8 @@ int main(int argc, char* argv[]) for (int iout = 0; iout < Nt; iout++) { // call integrator - retval = MRIStepEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); - if (check_flag(retval, "MRIStepEvolve")) break; + retval = ARKodeEvolve(arkode_mem, tout, y, &t, ARK_NORMAL); + if (check_flag(retval, "ARKodeEvolve")) break; // access/print solution and error uerr = SUNRabs(NV_Ith_S(y, 0) - utrue(t, &opts)); @@ -666,23 +666,23 @@ int main(int argc, char* argv[]) // Get some slow integrator statistics long int nsts, natts, netfs, nfse, nfsi; - retval = MRIStepGetNumSteps(arkode_mem, &nsts); - check_flag(retval, "MRIStepGetNumSteps"); - retval = MRIStepGetNumStepAttempts(arkode_mem, &natts); - check_flag(retval, "MRIStepGetNumStepAttempts"); - retval = MRIStepGetNumErrTestFails(arkode_mem, &netfs); - check_flag(retval, "MRIStepGetNumErrTestFails"); + retval = ARKodeGetNumSteps(arkode_mem, &nsts); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(arkode_mem, &natts); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(arkode_mem, &netfs); + check_flag(retval, "ARKodeGetNumErrTestFails"); retval = MRIStepGetNumRhsEvals(arkode_mem, &nfse, &nfsi); check_flag(retval, "MRIStepGetNumRhsEvals"); // Get some fast integrator statistics long int nstf, nattf, netff, nffe, nffi; - retval = ARKStepGetNumSteps(inner_arkode_mem, &nstf); - check_flag(retval, "ARKStepGetNumSteps"); - retval = ARKStepGetNumStepAttempts(inner_arkode_mem, &nattf); - check_flag(retval, "ARKStepGetNumStepAttempts"); - retval = ARKStepGetNumErrTestFails(inner_arkode_mem, &netff); - check_flag(retval, "ARKStepGetNumErrTestFails"); + retval = ARKodeGetNumSteps(inner_arkode_mem, &nstf); + check_flag(retval, "ARKodeGetNumSteps"); + retval = ARKodeGetNumStepAttempts(inner_arkode_mem, &nattf); + check_flag(retval, "ARKodeGetNumStepAttempts"); + retval = ARKodeGetNumErrTestFails(inner_arkode_mem, &netff); + check_flag(retval, "ARKodeGetNumErrTestFails"); retval = ARKStepGetNumRhsEvals(inner_arkode_mem, &nffe, &nffi); check_flag(retval, "ARKStepGetNumRhsEvals"); @@ -701,10 +701,10 @@ int main(int argc, char* argv[]) if (slowimplicit) { long int nnis, nncs, njes; - retval = MRIStepGetNonlinSolvStats(arkode_mem, &nnis, &nncs); - check_flag(retval, "MRIStepGetNonlinSolvStats"); - retval = MRIStepGetNumJacEvals(arkode_mem, &njes); - check_flag(retval, "MRIStepGetNumJacEvals"); + retval = ARKodeGetNonlinSolvStats(arkode_mem, &nnis, &nncs); + check_flag(retval, "ARKodeGetNonlinSolvStats"); + retval = ARKodeGetNumJacEvals(arkode_mem, &njes); + check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Slow Newton iters = " << nnis << std::endl; std::cout << " Slow Newton conv fails = " << nncs << std::endl; std::cout << " Slow Jacobian evals = " << njes << std::endl; @@ -714,10 +714,10 @@ int main(int argc, char* argv[]) if (fastimplicit) { long int nnif, nncf, njef; - retval = ARKStepGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); - check_flag(retval, "ARKStepGetNonlinSolvStats"); - retval = ARKStepGetNumJacEvals(inner_arkode_mem, &njef); - check_flag(retval, "ARKStepGetNumJacEvals"); + retval = ARKodeGetNonlinSolvStats(inner_arkode_mem, &nnif, &nncf); + check_flag(retval, "ARKodeGetNonlinSolvStats"); + retval = ARKodeGetNumJacEvals(inner_arkode_mem, &njef); + check_flag(retval, "ARKodeGetNumJacEvals"); std::cout << " Fast Newton iters = " << nnif << std::endl; std::cout << " Fast Newton conv fails = " << nncf << std::endl; std::cout << " Fast Jacobian evals = " << njef << std::endl; @@ -745,9 +745,9 @@ int main(int argc, char* argv[]) // if (opts.fcontrol != 0) { // SUNAdaptControllerDestroy(fcontrol); // free slow controller // } - ARKStepFree(&inner_arkode_mem); // Free fast integrator memory - MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper - MRIStepFree(&arkode_mem); // Free slow integrator memory + ARKodeFree(&inner_arkode_mem); // Free fast integrator memory + MRIStepInnerStepper_Free(&inner_stepper); // Free inner stepper structure + ARKodeFree(&arkode_mem); // Free slow integrator memory return 0; } diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp index 40d5f5f0ab..2f09436db7 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_brusselator.cpp @@ -235,23 +235,23 @@ int main(int argc, char* argv[]) NV_Ith_S(y, 2) = w0; void* arkode_ref = ARKStepCreate(fn, NULL, T0, y, ctx); if (check_retval((void*)arkode_ref, "ARKStepCreate", 0)) return 1; - retval = ARKStepSetUserData(arkode_ref, (void*)&udata); - if (check_retval(&retval, "ARKStepSetUserData", 1)) return 1; - retval = ARKStepSetOrder(arkode_ref, 5); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; - retval = ARKStepSStolerances(arkode_ref, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetMaxNumSteps(arkode_ref, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetUserData(arkode_ref, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetOrder(arkode_ref, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(arkode_ref, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(arkode_ref, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); N_VScale(ONE, y, yref[0]); sunrealtype hpart = (Tf - T0) / udata.Npart; - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { sunrealtype t = T0 + ipart * hpart; - retval = ARKStepSetStopTime(arkode_ref, t + hpart); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; - retval = ARKStepEvolve(arkode_ref, t + hpart, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) return 1; + retval = ARKodeSetStopTime(arkode_ref, t + hpart); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; + retval = ARKodeEvolve(arkode_ref, t + hpart, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; N_VScale(ONE, y, yref[ipart + 1]); } @@ -261,12 +261,12 @@ int main(int argc, char* argv[]) NV_Ith_S(y, 2) = w0; void* inner_arkode_mem = ARKStepCreate(f0, NULL, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) return 1; - retval = ARKStepSetOrder(inner_arkode_mem, 5); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetMaxNumSteps(inner_arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); // Create inner stepper wrapper MRIStepInnerStepper inner_stepper = NULL; // inner stepper @@ -300,23 +300,23 @@ int main(int argc, char* argv[]) if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; LS = SUNLinSol_Dense(y, A, ctx); if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; - retval = MRIStepSetLinearSolver(mristep_mem, LS, A); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) return 1; - retval = MRIStepSetJacFn(mristep_mem, Jn); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) return 1; - retval = MRIStepSetJacEvalFrequency(mristep_mem, 1); - if (check_retval(&retval, "MRIStepSetJacEvalFrequency", 1)) return 1; - retval = MRIStepSetLSetupFrequency(mristep_mem, 1); - if (check_retval(&retval, "MRIStepSetLSetupFrequency", 1)) return 1; - retval = MRIStepSetMaxNonlinIters(mristep_mem, 50); - if (check_retval(&retval, "MRIStepSetMaxNonlinIters", 1)) return 1; + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + retval = ARKodeSetJacFn(mristep_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(mristep_mem, 50); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; } - retval = MRIStepSStolerances(mristep_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) return 1; - retval = MRIStepSetUserData(mristep_mem, (void*)&udata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) return 1; - retval = MRIStepSetAccumulatedErrorType(mristep_mem, 0); - if (check_retval(&retval, "MRIStepSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetUserData(mristep_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values sunrealtype hmax = (Tf - T0) / 20.0 / udata.Npart; @@ -328,10 +328,10 @@ int main(int argc, char* argv[]) // Clean up and return MRIStepCoupling_Free(C); - ARKStepFree(&arkode_ref); - ARKStepFree(&inner_arkode_mem); + ARKodeFree(&arkode_ref); + ARKodeFree(&inner_arkode_mem); MRIStepInnerStepper_Free(&inner_stepper); - MRIStepFree(&mristep_mem); + ARKodeFree(&mristep_mem); if (LS) { SUNLinSolFree(LS); } // free system linear solver if (A) { SUNMatDestroy(A); } // free system matrix N_VDestroy(y); // Free y and yref vectors @@ -416,33 +416,33 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, vector(udata.Npart, ZERO)); // Loop over step sizes - for (size_t iH = 0; iH < Hvals.size(); iH++) + for (int iH = 0; iH < Hvals.size(); iH++) { // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrators for this run t = t2 = T0 + ipart * hpart; N_VScale(ONE, yref[ipart], y); - retval = MRIStepReset(mristep_mem, t, y); - if (check_retval(&retval, "MRIStepReset", 1)) return 1; - retval = MRIStepSetFixedStep(mristep_mem, Hvals[iH]); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) return 1; - retval = MRIStepResetAccumulatedError(mristep_mem); - if (check_retval(&retval, "MRIStepResetAccumulatedError", 1)) return 1; + retval = ARKodeReset(mristep_mem, t, y); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetFixedStep(mristep_mem, Hvals[iH]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeResetAccumulatedError(mristep_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; N_VScale(ONE, yref[ipart], y2); - retval = ARKStepReset(arkode_ref, t2, y2); - if (check_retval(&retval, "ARKStepReset", 1)) return 1; - retval = ARKStepSetStopTime(arkode_ref, t2 + Hvals[iH]); - if (check_retval(&retval, "ARKStepSetStopTime", 1)) return 1; + retval = ARKodeReset(arkode_ref, t2, y2); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetStopTime(arkode_ref, t2 + Hvals[iH]); + if (check_retval(&retval, "ARKodeSetStopTime", 1)) return 1; // Run ARKStep to compute reference solution, and MRIStep to compute one step - retval = ARKStepEvolve(arkode_ref, t2 + Hvals[iH], y2, &t2, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) return 1; - retval = MRIStepEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); - if (check_retval(&retval, "MRIStepEvolve", 1)) return 1; - retval = MRIStepGetEstLocalErrors(mristep_mem, ele); - if (check_retval(&retval, "MRIStepGetEstLocalErrors", 1)) return 1; + retval = ARKodeEvolve(arkode_ref, t2 + Hvals[iH], y2, &t2, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeGetEstLocalErrors(mristep_mem, ele); + if (check_retval(&retval, "ARKodeGetEstLocalErrors", 1)) return 1; retval = computeErrorWeights(y, ewt, reltol, abstol, vtemp); if (check_retval(&retval, "computeErrorWeights", 1)) return 1; dsm_est[iH][ipart] = N_VWrmsNorm(ewt, ele); @@ -463,7 +463,7 @@ static int run_test(void* mristep_mem, void* arkode_ref, N_Vector y, } cout << endl << method << " summary:" << endl; - for (size_t iH = 0; iH < Hvals.size(); iH++) + for (int iH = 0; iH < Hvals.size(); iH++) { cout << " Stepsize " << Hvals[iH] << " \tmaxdsm " << *max_element(dsm[iH].begin(), dsm[iH].end()) << " \tmaxdsmest " diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp index 1b66fad813..8e57f6987c 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_kpr.cpp @@ -198,12 +198,12 @@ int main(int argc, char* argv[]) // Set up fast ARKStep integrator as fifth-order adaptive ERK void* inner_arkode_mem = ARKStepCreate(f0, NULL, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) return 1; - retval = ARKStepSetOrder(inner_arkode_mem, 5); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetMaxNumSteps(inner_arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); // Create inner stepper wrapper MRIStepInnerStepper inner_stepper = NULL; // inner stepper @@ -237,23 +237,23 @@ int main(int argc, char* argv[]) if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; LS = SUNLinSol_Dense(y, A, ctx); if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; - retval = MRIStepSetLinearSolver(mristep_mem, LS, A); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) return 1; - retval = MRIStepSetJacFn(mristep_mem, Jn); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) return 1; - retval = MRIStepSetJacEvalFrequency(mristep_mem, 1); - if (check_retval(&retval, "MRIStepSetJacEvalFrequency", 1)) return 1; - retval = MRIStepSetLSetupFrequency(mristep_mem, 1); - if (check_retval(&retval, "MRIStepSetLSetupFrequency", 1)) return 1; - retval = MRIStepSetMaxNonlinIters(mristep_mem, 50); - if (check_retval(&retval, "MRIStepSetMaxNonlinIters", 1)) return 1; + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + retval = ARKodeSetJacFn(mristep_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(mristep_mem, 50); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; } - retval = MRIStepSStolerances(mristep_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) return 1; - retval = MRIStepSetUserData(mristep_mem, (void*)&udata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) return 1; - retval = MRIStepSetAccumulatedErrorType(mristep_mem, 0); - if (check_retval(&retval, "MRIStepSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetUserData(mristep_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values sunrealtype hmax = (Tf - T0) / 20 / udata.Npart; @@ -264,9 +264,9 @@ int main(int argc, char* argv[]) // Clean up and return MRIStepCoupling_Free(C); - ARKStepFree(&inner_arkode_mem); + ARKodeFree(&inner_arkode_mem); MRIStepInnerStepper_Free(&inner_stepper); - MRIStepFree(&mristep_mem); + ARKodeFree(&mristep_mem); if (LS) { SUNLinSolFree(LS); } // free system linear solver if (A) { SUNMatDestroy(A); } // free system matrix N_VDestroy(y); // Free y vector @@ -348,27 +348,27 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, vector(udata.Npart, ZERO)); // Loop over step sizes - for (size_t iH = 0; iH < Hvals.size(); iH++) + for (int iH = 0; iH < Hvals.size(); iH++) { // Loop over partition - for (size_t ipart = 0; ipart < udata.Npart; ipart++) + for (int ipart = 0; ipart < udata.Npart; ipart++) { // Reset integrator for this run t = T0 + ipart * hpart; retval = Ytrue(t, y, udata); if (check_retval(&retval, "Ytrue", 1)) return 1; - retval = MRIStepReset(mristep_mem, t, y); - if (check_retval(&retval, "MRIStepReset", 1)) return 1; - retval = MRIStepSetFixedStep(mristep_mem, Hvals[iH]); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) return 1; - retval = MRIStepResetAccumulatedError(mristep_mem); - if (check_retval(&retval, "MRIStepResetAccumulatedError", 1)) return 1; - - // Run MRIStep to compute one step - retval = MRIStepEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); - if (check_retval(&retval, "MRIStepEvolve", 1)) return 1; - retval = MRIStepGetEstLocalErrors(mristep_mem, ele); - if (check_retval(&retval, "MRIStepGetEstLocalErrors", 1)) return 1; + retval = ARKodeReset(mristep_mem, t, y); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetFixedStep(mristep_mem, Hvals[iH]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeResetAccumulatedError(mristep_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + + // Run ARKodeEvolve to compute one step + retval = ARKodeEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeGetEstLocalErrors(mristep_mem, ele); + if (check_retval(&retval, "ARKodeGetEstLocalErrors", 1)) return 1; retval = computeErrorWeights(y, ewt, reltol, abstol, vtemp); if (check_retval(&retval, "computeErrorWeights", 1)) return 1; dsm_est[iH][ipart] = N_VWrmsNorm(ewt, ele); @@ -386,7 +386,7 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, } cout << endl << method << " summary:" << endl; - for (size_t iH = 0; iH < Hvals.size(); iH++) + for (int iH = 0; iH < Hvals.size(); iH++) { cout << " Stepsize " << Hvals[iH] << " \tmaxdsm " << *max_element(dsm[iH].begin(), dsm[iH].end()) << " \tmaxdsmest " diff --git a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp index d56d87eae7..e04b23e15a 100644 --- a/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp +++ b/test/unit_tests/arkode/CXX_serial/ark_test_slowerror_polynomial.cpp @@ -141,12 +141,12 @@ int main(int argc, char* argv[]) // Set up fast ARKStep integrator as fifth-order adaptive ERK void* inner_arkode_mem = ARKStepCreate(f0, NULL, T0, y, ctx); if (check_retval((void*)inner_arkode_mem, "ARKStepCreate", 0)) return 1; - retval = ARKStepSetOrder(inner_arkode_mem, 5); - if (check_retval(&retval, "ARKStepSetOrder", 1)) return 1; - retval = ARKStepSStolerances(inner_arkode_mem, reltol, abstol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) return 1; - retval = ARKStepSetMaxNumSteps(inner_arkode_mem, 1000000); - if (check_retval(&retval, "ARKStepSetMaxNumSteps", 1)) return (1); + retval = ARKodeSetOrder(inner_arkode_mem, 5); + if (check_retval(&retval, "ARKodeSetOrder", 1)) return 1; + retval = ARKodeSStolerances(inner_arkode_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetMaxNumSteps(inner_arkode_mem, 1000000); + if (check_retval(&retval, "ARKodeSetMaxNumSteps", 1)) return (1); // Create inner stepper wrapper MRIStepInnerStepper inner_stepper = NULL; // inner stepper @@ -180,23 +180,23 @@ int main(int argc, char* argv[]) if (check_retval((void*)A, "SUNDenseMatrix", 0)) return 1; LS = SUNLinSol_Dense(y, A, ctx); if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) return 1; - retval = MRIStepSetLinearSolver(mristep_mem, LS, A); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) return 1; - retval = MRIStepSetJacFn(mristep_mem, Jn); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) return 1; - retval = MRIStepSetJacEvalFrequency(mristep_mem, 1); - if (check_retval(&retval, "MRIStepSetJacEvalFrequency", 1)) return 1; - retval = MRIStepSetLSetupFrequency(mristep_mem, 1); - if (check_retval(&retval, "MRIStepSetLSetupFrequency", 1)) return 1; - retval = MRIStepSetMaxNonlinIters(mristep_mem, 20); - if (check_retval(&retval, "MRIStepSetMaxNonlinIters", 1)) return 1; + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; + retval = ARKodeSetJacFn(mristep_mem, Jn); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; + retval = ARKodeSetJacEvalFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetJacEvalFrequency", 1)) return 1; + retval = ARKodeSetLSetupFrequency(mristep_mem, 1); + if (check_retval(&retval, "ARKodeSetLSetupFrequency", 1)) return 1; + retval = ARKodeSetMaxNonlinIters(mristep_mem, 20); + if (check_retval(&retval, "ARKodeSetMaxNonlinIters", 1)) return 1; } - retval = MRIStepSStolerances(mristep_mem, reltol, abstol); - if (check_retval(&retval, "MRIStepSStolerances", 1)) return 1; - retval = MRIStepSetUserData(mristep_mem, (void*)&udata); - if (check_retval(&retval, "MRIStepSetUserData", 1)) return 1; - retval = MRIStepSetAccumulatedErrorType(mristep_mem, 0); - if (check_retval(&retval, "MRIStepSetAccumulatedErrorType", 1)) return 1; + retval = ARKodeSStolerances(mristep_mem, reltol, abstol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) return 1; + retval = ARKodeSetUserData(mristep_mem, (void*)&udata); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; + retval = ARKodeSetAccumulatedErrorType(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetAccumulatedErrorType", 1)) return 1; // Run test for various H values // vector Hvals = {ONE, ONE/2.0, ONE/4.0, ONE/8.0, ONE/16.0}; @@ -207,9 +207,9 @@ int main(int argc, char* argv[]) // Clean up and return MRIStepCoupling_Free(C); - ARKStepFree(&inner_arkode_mem); + ARKodeFree(&inner_arkode_mem); MRIStepInnerStepper_Free(&inner_stepper); - MRIStepFree(&mristep_mem); + ARKodeFree(&mristep_mem); if (LS) { SUNLinSolFree(LS); } // free system linear solver if (A) { SUNMatDestroy(A); } // free system matrix N_VDestroy(y); // Free y and yref vectors @@ -263,24 +263,24 @@ static int run_test(void* mristep_mem, N_Vector y, sunrealtype T0, vector dsm_est(Hvals.size(), ZERO); // Loop over step sizes - for (size_t iH = 0; iH < Hvals.size(); iH++) + for (int iH = 0; iH < Hvals.size(); iH++) { // Reset integrator for this run t = T0; retval = Ytrue(t, y, udata); if (check_retval(&retval, "Ytrue", 1)) return 1; - retval = MRIStepReset(mristep_mem, t, y); - if (check_retval(&retval, "MRIStepReset", 1)) return 1; - retval = MRIStepSetFixedStep(mristep_mem, Hvals[iH]); - if (check_retval(&retval, "MRIStepSetFixedStep", 1)) return 1; - retval = MRIStepResetAccumulatedError(mristep_mem); - if (check_retval(&retval, "MRIStepResetAccumulatedError", 1)) return 1; - - // Run MRIStep to compute one step - retval = MRIStepEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); - if (check_retval(&retval, "MRIStepEvolve", 1)) return 1; - retval = MRIStepGetEstLocalErrors(mristep_mem, ele); - if (check_retval(&retval, "MRIStepGetEstLocalErrors", 1)) return 1; + retval = ARKodeReset(mristep_mem, t, y); + if (check_retval(&retval, "ARKodeReset", 1)) return 1; + retval = ARKodeSetFixedStep(mristep_mem, Hvals[iH]); + if (check_retval(&retval, "ARKodeSetFixedStep", 1)) return 1; + retval = ARKodeResetAccumulatedError(mristep_mem); + if (check_retval(&retval, "ARKodeResetAccumulatedError", 1)) return 1; + + // Run ARKodeEvolve to compute one step + retval = ARKodeEvolve(mristep_mem, t + Hvals[iH], y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; + retval = ARKodeGetEstLocalErrors(mristep_mem, ele); + if (check_retval(&retval, "ARKodeGetEstLocalErrors", 1)) return 1; retval = computeErrorWeights(y, ewt, reltol, abstol, vtemp); if (check_retval(&retval, "computeErrorWeights", 1)) return 1; dsm_est[iH] = N_VWrmsNorm(ewt, ele); diff --git a/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c b/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c index 6ea963f176..7fdb34daf2 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c +++ b/test/unit_tests/arkode/C_serial/ark_test_arkstepsetforcing.c @@ -212,43 +212,43 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Specify tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Set stop time */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } /* Set max steps before output */ - flag = ARKStepSetMaxNumSteps(arkode_mem, mxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, mxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Set forcing */ flag = arkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, order + 1); if (check_flag(&flag, "arkStep_SetInnerForcing", 1)) { return 1; } /* Integrate the problem */ - flag = ARKStepEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); + flag = ARKodeEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); /* check for errors */ if (flag < 0) { - fprintf(stderr, "ARKStep failure, flag = %d\n", flag); + fprintf(stderr, "ARKodeEvolve failure, flag = %d\n", flag); return 1; } /* get some integrator stats */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); printf("Explicit stats:\n"); printf("Steps = %li (attempted = %li)\n\n", nst, nst_a); /* Free integrator memory */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /* print solution */ @@ -272,55 +272,55 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Specify tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Set stop time */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } /* Set max steps before output */ - flag = ARKStepSetMaxNumSteps(arkode_mem, mxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, mxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Attach matrix and linear solver */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set Jacobian routine */ - flag = ARKStepSetJacFn(arkode_mem, Jac); - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Set forcing */ flag = arkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, order + 1); if (check_flag(&flag, "arkStep_SetInnerForcing", 1)) { return 1; } /* Integrate the problem */ - flag = ARKStepEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); + flag = ARKodeEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); /* check for errors */ if (flag < 0) { - fprintf(stderr, "ARKStep failure, flag = %d\n", flag); + fprintf(stderr, "ARKodeEvolve failure, flag = %d\n", flag); return 1; } /* get some integrator stats */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); printf("Implicit stats:\n"); printf("Steps = %li (attempted = %li)\n\n", nst, nst_a); /* Free integrator memory */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /* print solution */ @@ -344,55 +344,55 @@ int main(int argc, char* argv[]) if (check_flag((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } /* Specify tolerances */ - flag = ARKStepSStolerances(arkode_mem, reltol, abstol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, reltol, abstol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* Set stop time */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } /* Set max steps before output */ - flag = ARKStepSetMaxNumSteps(arkode_mem, mxsteps); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, mxsteps); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* Attach matrix and linear solver */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } /* Set Jacobian routine */ - flag = ARKStepSetJacFn(arkode_mem, Jac); - if (check_flag(&flag, "ARKStepSetJacFn", 1)) { return 1; } + flag = ARKodeSetJacFn(arkode_mem, Jac); + if (check_flag(&flag, "ARKodeSetJacFn", 1)) { return 1; } /* Specify linearly implicit RHS, with non-time-dependent Jacobian */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* Set forcing */ flag = arkStep_SetInnerForcing(arkode_mem, tshift, tscale, forcing, order + 1); if (check_flag(&flag, "arkStep_SetInnerForcing", 1)) { return 1; } /* Integrate the problem */ - flag = ARKStepEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); + flag = ARKodeEvolve(arkode_mem, Tf, y, &tret, ARK_NORMAL); /* check for errors */ if (flag < 0) { - fprintf(stderr, "ARKStep failure, flag = %d\n", flag); + fprintf(stderr, "ARKodeEvolve failure, flag = %d\n", flag); return 1; } /* get some integrator stats */ - flag = ARKStepGetNumSteps(arkode_mem, &nst); - check_flag(&flag, "ARKStepGetNumSteps", 1); + flag = ARKodeGetNumSteps(arkode_mem, &nst); + check_flag(&flag, "ARKodeGetNumSteps", 1); - flag = ARKStepGetNumStepAttempts(arkode_mem, &nst_a); - check_flag(&flag, "ARKStepGetNumStepAttempts", 1); + flag = ARKodeGetNumStepAttempts(arkode_mem, &nst_a); + check_flag(&flag, "ARKodeGetNumStepAttempts", 1); printf("IMEX stats:\n"); printf("Steps = %li (attempted = %li)\n\n", nst, nst_a); /* Free integrator memory */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /* print solution */ diff --git a/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c b/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c index 1f57ea41fd..25c5de6982 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c +++ b/test/unit_tests/arkode/C_serial/ark_test_getuserdata.c @@ -73,18 +73,18 @@ int main(int argc, char* argv[]) } /* Set user data */ - retval = ARKStepSetUserData(arkode_mem, &udata_in); + retval = ARKodeSetUserData(arkode_mem, &udata_in); if (retval) { - fprintf(stderr, "ARKStepSetUserData returned %i\n", retval); + fprintf(stderr, "ARKodeSetUserData returned %i\n", retval); return 1; } /* Get user data */ - retval = ARKStepGetUserData(arkode_mem, &udata_out); + retval = ARKodeGetUserData(arkode_mem, &udata_out); if (retval) { - fprintf(stderr, "ARKStepGetUserData returned %i\n", retval); + fprintf(stderr, "ARKodeGetUserData returned %i\n", retval); return 1; } @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) udata_out = NULL; /* Free integrator memory */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* ------------ * * Test ERKStep * @@ -119,18 +119,18 @@ int main(int argc, char* argv[]) } /* Set user data */ - retval = ERKStepSetUserData(arkode_mem, &udata_in); + retval = ARKodeSetUserData(arkode_mem, &udata_in); if (retval) { - fprintf(stderr, "ERKStepSetUserData returned %i\n", retval); + fprintf(stderr, "ARKodeSetUserData returned %i\n", retval); return 1; } /* Get user data */ - retval = ERKStepGetUserData(arkode_mem, &udata_out); + retval = ARKodeGetUserData(arkode_mem, &udata_out); if (retval) { - fprintf(stderr, "ERKStepGetUserData returned %i\n", retval); + fprintf(stderr, "ARKodeGetUserData returned %i\n", retval); return 1; } @@ -150,7 +150,7 @@ int main(int argc, char* argv[]) udata_out = NULL; /* Free integrator memory */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* ------------ * * Test MRIStep * @@ -176,23 +176,23 @@ int main(int argc, char* argv[]) arkode_mem = MRIStepCreate(f, NULL, ZERO, y, inner_stepper, sunctx); if (!arkode_mem) { - fprintf(stderr, "ARKStepCreate returned NULL\n"); + fprintf(stderr, "MRIStepCreate returned NULL\n"); return 1; } /* Set user data */ - retval = MRIStepSetUserData(arkode_mem, &udata_in); + retval = ARKodeSetUserData(arkode_mem, &udata_in); if (retval) { - fprintf(stderr, "ARKStepSetUserData returned %i\n", retval); + fprintf(stderr, "ARKodeSetUserData returned %i\n", retval); return 1; } /* Get user data */ - retval = MRIStepGetUserData(arkode_mem, &udata_out); + retval = ARKodeGetUserData(arkode_mem, &udata_out); if (retval) { - fprintf(stderr, "ARKStepGetUserData returned %i\n", retval); + fprintf(stderr, "ARKodeGetUserData returned %i\n", retval); return 1; } @@ -212,8 +212,8 @@ int main(int argc, char* argv[]) udata_out = NULL; /* Free integrator memory */ - MRIStepFree(&arkode_mem); - ARKStepFree(&arkode_inner_mem); + ARKodeFree(&arkode_mem); + ARKodeFree(&arkode_inner_mem); MRIStepInnerStepper_Free(&inner_stepper); /* Clean up */ diff --git a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c index 315f819089..f79566aa6f 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c +++ b/test/unit_tests/arkode/C_serial/ark_test_innerstepper.c @@ -96,10 +96,10 @@ int main(int argc, char* argv[]) arkode_mem = MRIStepCreate(ode_slow_rhs, NULL, ZERO, y, fast_mem, sunctx); if (!arkode_mem) { return 1; } - flag = MRIStepSetFixedStep(arkode_mem, SUN_RCONST(0.01)); + flag = ARKodeSetFixedStep(arkode_mem, SUN_RCONST(0.01)); if (flag) { return 1; } - flag = MRIStepSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); if (flag) { return 1; } /* --------------- @@ -107,8 +107,8 @@ int main(int argc, char* argv[]) * --------------- */ /* Evolve should return a failure when using Hermite interpolation */ - arkode_flag = MRIStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); - printf("MRIStepEvolve returned %i\n", arkode_flag); + arkode_flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + printf("ARKodeEvolve returned %i\n", arkode_flag); if (arkode_flag != ARK_RHSFUNC_FAIL) { return 1; } /* ----------------------- @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) flag = MRIStepReInit(arkode_mem, ode_slow_rhs, NULL, ZERO, y); if (flag) { return 1; } - flag = MRIStepSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); if (flag) { return 1; } /* --------------- @@ -128,8 +128,8 @@ int main(int argc, char* argv[]) * --------------- */ /* Evolve should succeed when using Lagrange interpolation */ - arkode_flag = MRIStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); - printf("MRIStepEvolve returned %i\n", arkode_flag); + arkode_flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + printf("ARKodeEvolve returned %i\n", arkode_flag); if (arkode_flag != ARK_SUCCESS) { return 1; } /* -------- @@ -137,7 +137,7 @@ int main(int argc, char* argv[]) * -------- */ MRIStepInnerStepper_Free(&fast_mem); - MRIStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); N_VDestroy(y); SUNContext_Free(&sunctx); diff --git a/test/unit_tests/arkode/C_serial/ark_test_interp.c b/test/unit_tests/arkode/C_serial/ark_test_interp.c index 88d0636954..00eff80a35 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_interp.c +++ b/test/unit_tests/arkode/C_serial/ark_test_interp.c @@ -206,46 +206,46 @@ int main(int argc, char* argv[]) if (check_flag(arkode_mem, "ARKStepCreate", 0)) { return 1; } /* pass lambda to RHS routine */ - flag = ARKStepSetUserData(arkode_mem, &lambda); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, &lambda); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } /* select Hermite interpolation module */ - flag = ARKStepSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); - if (check_flag(&flag, "ARKStepSetInterpolantType", 1)) { return 1; } + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_HERMITE); + if (check_flag(&flag, "ARKodeSetInterpolantType", 1)) { return 1; } /* set dense output polynomial degree */ - flag = ARKStepSetInterpolantDegree(arkode_mem, ideg); - if (check_flag(&flag, "ARKStepSetInterpolantDegree", 1)) { return 1; } + flag = ARKodeSetInterpolantDegree(arkode_mem, ideg); + if (check_flag(&flag, "ARKodeSetInterpolantDegree", 1)) { return 1; } /* set fixed time-stepping with desired time step size */ - flag = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } /* set solver tolerances */ - flag = ARKStepSStolerances(arkode_mem, rtol, atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* indicate linearity of problem */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* attach linear solver */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } /* increase maximum number of time steps */ - flag = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* set RK order to highest available value */ - flag = ARKStepSetOrder(arkode_mem, 5); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, 5); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } /* evolve to Tf to prepare interpolation structure */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } - flag = ARKStepEvolve(arkode_mem, Tf, y, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } + flag = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } /* loop over 100 evenly-spaced values within interior of preceding step to accumulate errors */ @@ -254,19 +254,19 @@ int main(int argc, char* argv[]) /* set test time */ t_test = t - hvals[ih] + (itest + 1) * hvals[ih] / (nttest + 2); - /* call ARKStepGetDky to evaluate solution and derivatives at t_test */ - flag = ARKStepGetDky(arkode_mem, t_test, 0, ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 1, dytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 2, d2ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 3, d3ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 4, d4ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 5, d5ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } + /* call ARKodeGetDky to evaluate solution and derivatives at t_test */ + flag = ARKodeGetDky(arkode_mem, t_test, 0, ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 1, dytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 2, d2ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 3, d3ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 4, d4ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 5, d5ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } /* set error values */ /* y */ @@ -318,8 +318,8 @@ int main(int argc, char* argv[]) } /* end itest loop */ - /* free ARKStep memory (to prepare for next call) */ - ARKStepFree(&arkode_mem); + /* free ARKode memory (to prepare for next call) */ + ARKodeFree(&arkode_mem); arkode_mem = NULL; } /* end ih loop */ @@ -444,46 +444,46 @@ int main(int argc, char* argv[]) if (check_flag(arkode_mem, "ARKStepCreate", 0)) { return 1; } /* pass lambda to RHS routine */ - flag = ARKStepSetUserData(arkode_mem, &lambda); - if (check_flag(&flag, "ARKStepSetUserData", 1)) { return 1; } + flag = ARKodeSetUserData(arkode_mem, &lambda); + if (check_flag(&flag, "ARKodeSetUserData", 1)) { return 1; } /* select Lagrange interpolation module */ - flag = ARKStepSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); - if (check_flag(&flag, "ARKStepSetInterpolantType", 1)) { return 1; } + flag = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + if (check_flag(&flag, "ARKodeSetInterpolantType", 1)) { return 1; } /* set dense output polynomial degree */ - flag = ARKStepSetInterpolantDegree(arkode_mem, ideg); - if (check_flag(&flag, "ARKStepSetInterpolantDegree", 1)) { return 1; } + flag = ARKodeSetInterpolantDegree(arkode_mem, ideg); + if (check_flag(&flag, "ARKodeSetInterpolantDegree", 1)) { return 1; } /* set fixed time-stepping with desired time step size */ - flag = ARKStepSetFixedStep(arkode_mem, hvals[ih]); - if (check_flag(&flag, "ARKStepSetFixedStep", 1)) { return 1; } + flag = ARKodeSetFixedStep(arkode_mem, hvals[ih]); + if (check_flag(&flag, "ARKodeSetFixedStep", 1)) { return 1; } /* set solver tolerances */ - flag = ARKStepSStolerances(arkode_mem, rtol, atol); - if (check_flag(&flag, "ARKStepSStolerances", 1)) { return 1; } + flag = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_flag(&flag, "ARKodeSStolerances", 1)) { return 1; } /* indicate linearity of problem */ - flag = ARKStepSetLinear(arkode_mem, 0); - if (check_flag(&flag, "ARKStepSetLinear", 1)) { return 1; } + flag = ARKodeSetLinear(arkode_mem, 0); + if (check_flag(&flag, "ARKodeSetLinear", 1)) { return 1; } /* attach linear solver */ - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_flag(&flag, "ARKStepSetLinearSolver", 1)) { return 1; } + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_flag(&flag, "ARKodeSetLinearSolver", 1)) { return 1; } /* increase maximum number of time steps */ - flag = ARKStepSetMaxNumSteps(arkode_mem, 100000); - if (check_flag(&flag, "ARKStepSetMaxNumSteps", 1)) { return 1; } + flag = ARKodeSetMaxNumSteps(arkode_mem, 100000); + if (check_flag(&flag, "ARKodeSetMaxNumSteps", 1)) { return 1; } /* set RK order to highest available value */ - flag = ARKStepSetOrder(arkode_mem, 5); - if (check_flag(&flag, "ARKStepSetOrder", 1)) { return 1; } + flag = ARKodeSetOrder(arkode_mem, 5); + if (check_flag(&flag, "ARKodeSetOrder", 1)) { return 1; } /* evolve to Tf to prepare interpolation structure */ - flag = ARKStepSetStopTime(arkode_mem, Tf); - if (check_flag(&flag, "ARKStepSetStopTime", 1)) { return 1; } - flag = ARKStepEvolve(arkode_mem, Tf, y, &t, ARK_NORMAL); - if (check_flag(&flag, "ARKStepEvolve", 1)) { return 1; } + flag = ARKodeSetStopTime(arkode_mem, Tf); + if (check_flag(&flag, "ARKodeSetStopTime", 1)) { return 1; } + flag = ARKodeEvolve(arkode_mem, Tf, y, &t, ARK_NORMAL); + if (check_flag(&flag, "ARKodeEvolve", 1)) { return 1; } /* loop over 100 evenly-spaced values within interior of this step to accumulate errors */ for (itest = 0; itest < nttest; itest++) @@ -491,13 +491,13 @@ int main(int argc, char* argv[]) /* set test time */ t_test = t - hvals[ih] + (itest + 1) * hvals[ih] / (nttest + 2); - /* call ARKStepGetDky to evaluate solution and derivatives at t_test */ - flag = ARKStepGetDky(arkode_mem, t_test, 0, ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 1, dytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } - flag = ARKStepGetDky(arkode_mem, t_test, 2, d2ytest); - if (check_flag(&flag, "ARKStepGetDky", 1)) { return 1; } + /* call ARKodeGetDky to evaluate solution and derivatives at t_test */ + flag = ARKodeGetDky(arkode_mem, t_test, 0, ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 1, dytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } + flag = ARKodeGetDky(arkode_mem, t_test, 2, d2ytest); + if (check_flag(&flag, "ARKodeGetDky", 1)) { return 1; } /* set error values */ /* y */ @@ -525,8 +525,8 @@ int main(int argc, char* argv[]) } /* end itest loop */ - /* free ARKStep memory (to prepare for next call) */ - ARKStepFree(&arkode_mem); + /* free ARKode memory (to prepare for next call) */ + ARKodeFree(&arkode_mem); arkode_mem = NULL; } /* end ih loop */ diff --git a/test/unit_tests/arkode/C_serial/ark_test_mass.c b/test/unit_tests/arkode/C_serial/ark_test_mass.c index 586028cd1c..c011d11209 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_mass.c +++ b/test/unit_tests/arkode/C_serial/ark_test_mass.c @@ -131,57 +131,57 @@ int solve(const char* im, const char* ex, int steps, sunbooleantype time_dep, retval = ARKStepSetTableName(arkode_mem, im, ex); if (check_retval(&retval, "ARKStepSetTableNum", 1)) return 1; - retval = ARKStepSetUserData(arkode_mem, &time_dep); - if (check_retval(&retval, "ARKStepSetUserData", 1)) return 1; + retval = ARKodeSetUserData(arkode_mem, &time_dep); + if (check_retval(&retval, "ARKodeSetUserData", 1)) return 1; /* Specify a time step so no extra mass evaluations occur from initial step * size procedure */ - retval = ARKStepSetInitStep(arkode_mem, 0.01); - if (check_retval(&retval, "ARKStepSetInitStep", 1)) return 1; + retval = ARKodeSetInitStep(arkode_mem, 0.01); + if (check_retval(&retval, "ARKodeSetInitStep", 1)) return 1; /* Use Lagrange interpolation because Hermite may need addition mass matrix * solves to compute the interpolant */ - retval = ARKStepSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); - if (check_retval(&retval, "ARKStepSetInterpolantType", 1)) return 1; + retval = ARKodeSetInterpolantType(arkode_mem, ARK_INTERP_LAGRANGE); + if (check_retval(&retval, "ARKodeSetInterpolantType", 1)) return 1; /* Configure the solvers */ jacobian_ls = SUNLinSol_Dense(y, jacobian_mat, sunctx); if (check_retval(jacobian_ls, "SUNLinSol_Dense", 0)) return 1; - retval = ARKStepSetLinearSolver(arkode_mem, jacobian_ls, jacobian_mat); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) return 1; + retval = ARKodeSetLinearSolver(arkode_mem, jacobian_ls, jacobian_mat); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) return 1; mass_ls = SUNLinSol_Dense(y, mass_mat, sunctx); if (check_retval(mass_ls, "SUNLinSol_Dense", 0)) return 1; - retval = ARKStepSetMassLinearSolver(arkode_mem, mass_ls, mass_mat, time_dep); - if (check_retval(&retval, "ARKStepSetMassLinearSolver", 0)) return 1; + retval = ARKodeSetMassLinearSolver(arkode_mem, mass_ls, mass_mat, time_dep); + if (check_retval(&retval, "ARKodeSetMassLinearSolver", 0)) return 1; nls = SUNNonlinSol_Newton(y, sunctx); if (check_retval(nls, "SUNNonlinSol_Newton", 0)) return 1; - retval = ARKStepSetDeduceImplicitRhs(arkode_mem, deduce_implicit_rhs); - if (check_retval(&retval, "ARKStepSetDeduceImplicitRhs", 1)) return 1; + retval = ARKodeSetDeduceImplicitRhs(arkode_mem, deduce_implicit_rhs); + if (check_retval(&retval, "ARKodeSetDeduceImplicitRhs", 1)) return 1; /* Let ARKODE estimate the Jacobian with finite differences */ - retval = ARKStepSetJacFn(arkode_mem, NULL); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) return 1; + retval = ARKodeSetJacFn(arkode_mem, NULL); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) return 1; - retval = ARKStepSetMassFn(arkode_mem, mass); - if (check_retval(&retval, "ARKStepSetMassFn", 1)) return 1; + retval = ARKodeSetMassFn(arkode_mem, mass); + if (check_retval(&retval, "ARKodeSetMassFn", 1)) return 1; /* Take time step(s) */ for (s = 0; s < steps; s++) { - retval = ARKStepEvolve(arkode_mem, t, y, &t, ARK_ONE_STEP); - if (check_retval(&retval, "ARKStepEvolve", 1)) return 1; + retval = ARKodeEvolve(arkode_mem, t, y, &t, ARK_ONE_STEP); + if (check_retval(&retval, "ARKodeEvolve", 1)) return 1; } - retval = ARKStepGetNumMassSolves(arkode_mem, &actual_mass_solves); - if (check_retval(&retval, "ARKStepGetNumMassSolves", 1)) return 1; + retval = ARKodeGetNumMassSolves(arkode_mem, &actual_mass_solves); + if (check_retval(&retval, "ARKodeGetNumMassSolves", 1)) return 1; /* Free integrator memory */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); /* Clean up */ N_VDestroy(y); diff --git a/test/unit_tests/arkode/C_serial/ark_test_reset.c b/test/unit_tests/arkode/C_serial/ark_test_reset.c index 529c2879cd..445850399f 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_reset.c +++ b/test/unit_tests/arkode/C_serial/ark_test_reset.c @@ -11,8 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * SUNDIALS Copyright End *--------------------------------------------------------------- - * Routine to test that ARKStepReset, ERKStepReset and - * MRIStepReset function correctly. + * Routine to test that ARKodeReset functions correctly. * * This runs the same test problem as in * examples/arkode/C_serial/ark_analytic.c: @@ -107,196 +106,199 @@ int main(void) if (check_retval((void*)LS, "SUNLinSol_Dense", 0)) { return 1; } /******* Part I: ERKStep *******/ + printf("Testing ERKStep:\n"); /* Set initial condition, and construct stepper */ t = T0; N_VConst(ytrue(t), y); arkode_mem = ERKStepCreate(f, t, y, ctx); if (check_retval((void*)arkode_mem, "ERKStepCreate", 0)) { return 1; } - retval = ERKStepSetUserData(arkode_mem, (void*)&lambda); - if (check_retval(&retval, "ERKStepSetUserData", 1)) { return 1; } - retval = ERKStepSStolerances(arkode_mem, rtol, atol); - if (check_retval(&retval, "ERKStepSStolerances", 1)) { return 1; } - retval = ERKStepSetMaxNumSteps(arkode_mem, 1000); - check_retval(&retval, "ERKStepSetMaxNumSteps", 1); + retval = ARKodeSetUserData(arkode_mem, (void*)&lambda); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 1000); + check_retval(&retval, "ARKodeSetMaxNumSteps", 1); /* Initially evolve to dTout, and check result */ - retval = ERKStepSetStopTime(arkode_mem, t + dTout); - check_retval(&retval, "ERKStepSetStopTime", 1); - retval = ERKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) { return 1; } + retval = ARKodeSetStopTime(arkode_mem, t + dTout); + check_retval(&retval, "ARKodeSetStopTime", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Initial ERKStepEvolve had insufficient accuracy\n"); + printf(" Initial ARKodeEvolve had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Initial ERKStepEvolve call successful\n"); } + else { printf(" Initial ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at dTout, evolve to 2*dTout and check result */ t = T0 + dTout; N_VConst(ytrue(t), y); - retval = ERKStepReset(arkode_mem, t, y); - check_retval(&retval, "ERKStepReset", 1); - retval = ERKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Second ERKStepEvolve call had insufficient accuracy\n"); + printf(" Second ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Second ERKStepEvolve call successful\n"); } + else { printf(" Second ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at 3*dTout, evolve to 4*dTout and check result */ t = T0 + SUN_RCONST(3.0) * dTout; N_VConst(ytrue(t), y); - retval = ERKStepReset(arkode_mem, t, y); - check_retval(&retval, "ERKStepReset", 1); - retval = ERKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Third ERKStepEvolve call had insufficient accuracy\n"); + printf(" Third ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Third ERKStepEvolve call successful\n"); } + else { printf(" Third ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at dTout, evolve to 2*dTout and check result */ t = T0 + dTout; N_VConst(ytrue(t), y); - retval = ERKStepReset(arkode_mem, t, y); - check_retval(&retval, "ERKStepReset", 1); - retval = ERKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ERKStepEvolve", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Fourth ERKStepEvolve call had insufficient accuracy\n"); + printf(" Fourth ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Fourth ERKStepEvolve call successful\n"); } + else { printf(" Fourth ARKodeEvolve call successful\n"); } /* Free ERKStep memory structure */ - ERKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /******* Part II: ARKStep *******/ + printf("Testing ARKStep:\n"); /* Set initial condition, and construct stepper */ t = T0; N_VConst(ytrue(t), y); arkode_mem = ARKStepCreate(NULL, f, t, y, ctx); if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } - retval = ARKStepSetUserData(arkode_mem, (void*)&lambda); - if (check_retval(&retval, "ARKStepSetUserData", 1)) { return 1; } - retval = ARKStepSStolerances(arkode_mem, rtol, atol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } - retval = ARKStepSetLinearSolver(arkode_mem, LS, A); - if (check_retval(&retval, "ARKStepSetLinearSolver", 1)) { return 1; } - retval = ARKStepSetJacFn(arkode_mem, Jac); - if (check_retval(&retval, "ARKStepSetJacFn", 1)) { return 1; } - retval = ARKStepSetLinear(arkode_mem, 0); - if (check_retval(&retval, "ARKStepSetLinear", 1)) { return 1; } - retval = ARKStepSetMaxNumSteps(arkode_mem, 100); - check_retval(&retval, "ARKStepSetMaxNumSteps", 1); + retval = ARKodeSetUserData(arkode_mem, (void*)&lambda); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } + retval = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } + retval = ARKodeSetLinearSolver(arkode_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(arkode_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinear(arkode_mem, 0); + if (check_retval(&retval, "ARKodeSetLinear", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 100); + check_retval(&retval, "ARKodeSetMaxNumSteps", 1); /* Initially evolve to dTout, and check result */ - retval = ARKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { return 1; } + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Initial ARKStepEvolve had insufficient accuracy\n"); + printf(" Initial ARKodeEvolve had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Initial ARKStepEvolve call successful\n"); } + else { printf(" Initial ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at dTout, evolve to 2*dTout and check result */ t = T0 + dTout; N_VConst(ytrue(t), y); - retval = ARKStepReset(arkode_mem, t, y); - check_retval(&retval, "ARKStepReset", 1); - retval = ARKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Second ARKStepEvolve call had insufficient accuracy\n"); + printf(" Second ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Second ARKStepEvolve call successful\n"); } + else { printf(" Second ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at 3*dTout, evolve to 4*dTout and check result */ t = T0 + SUN_RCONST(3.0) * dTout; N_VConst(ytrue(t), y); - retval = ARKStepReset(arkode_mem, t, y); - check_retval(&retval, "ARKStepReset", 1); - retval = ARKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Third ARKStepEvolve call had insufficient accuracy\n"); + printf(" Third ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Third ARKStepEvolve call successful\n"); } + else { printf(" Third ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at dTout, evolve to 2*dTout and check result */ t = T0 + dTout; N_VConst(ytrue(t), y); - retval = ARKStepReset(arkode_mem, t, y); - check_retval(&retval, "ARKStepReset", 1); - retval = ARKStepEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "ARKStepEvolve", 1)) { return 1; } + retval = ARKodeReset(arkode_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(arkode_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Fourth ARKStepEvolve call had insufficient accuracy\n"); + printf(" Fourth ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Fourth ARKStepEvolve call successful\n"); } + else { printf(" Fourth ARKodeEvolve call successful\n"); } /* Free ARKStep memory structure */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /******* Part III: MRIStep *******/ + printf("Testing MRIStep:\n"); /* Set initial condition, and construct stepper */ t = T0; N_VConst(ytrue(t), y); arkode_mem = ARKStepCreate(f0, NULL, t, y, ctx); if (check_retval((void*)arkode_mem, "ARKStepCreate", 0)) { return 1; } - retval = ARKStepSStolerances(arkode_mem, rtol, atol); - if (check_retval(&retval, "ARKStepSStolerances", 1)) { return 1; } - retval = ARKStepSetMaxNumSteps(arkode_mem, 100); - check_retval(&retval, "ARKStepSetMaxNumSteps", 1); + retval = ARKodeSStolerances(arkode_mem, rtol, atol); + if (check_retval(&retval, "ARKodeSStolerances", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(arkode_mem, 100); + check_retval(&retval, "ARKodeSetMaxNumSteps", 1); retval = ARKStepCreateMRIStepInnerStepper(arkode_mem, &inner_stepper); if (check_retval(&retval, "ARKStepCreateMRIStepInnerStepper", 1)) { @@ -304,91 +306,91 @@ int main(void) } mristep_mem = MRIStepCreate(NULL, f, t, y, inner_stepper, ctx); if (check_retval((void*)mristep_mem, "MRIStepCreate", 0)) { return 1; } - retval = MRIStepSetUserData(mristep_mem, (void*)&lambda); - if (check_retval(&retval, "MRIStepSetUserData", 1)) { return 1; } - retval = MRIStepSetLinearSolver(mristep_mem, LS, A); - if (check_retval(&retval, "MRIStepSetLinearSolver", 1)) { return 1; } - retval = MRIStepSetJacFn(mristep_mem, Jac); - if (check_retval(&retval, "MRIStepSetJacFn", 1)) { return 1; } - retval = MRIStepSetLinear(mristep_mem, 0); - if (check_retval(&retval, "MRIStepSetLinear", 1)) { return 1; } - retval = MRIStepSetMaxNumSteps(mristep_mem, 100); - check_retval(&retval, "MRIStepSetMaxNumSteps", 1); - retval = MRIStepSetFixedStep(mristep_mem, dTout * SUN_RCONST(0.105)); - check_retval(&retval, "MRIStepSetFixedStep", 1); + retval = ARKodeSetUserData(mristep_mem, (void*)&lambda); + if (check_retval(&retval, "ARKodeSetUserData", 1)) { return 1; } + retval = ARKodeSetLinearSolver(mristep_mem, LS, A); + if (check_retval(&retval, "ARKodeSetLinearSolver", 1)) { return 1; } + retval = ARKodeSetJacFn(mristep_mem, Jac); + if (check_retval(&retval, "ARKodeSetJacFn", 1)) { return 1; } + retval = ARKodeSetLinear(mristep_mem, 0); + if (check_retval(&retval, "ARKodeSetLinear", 1)) { return 1; } + retval = ARKodeSetMaxNumSteps(mristep_mem, 100); + check_retval(&retval, "ARKodeSetMaxNumSteps", 1); + retval = ARKodeSetFixedStep(mristep_mem, dTout * SUN_RCONST(0.105)); + check_retval(&retval, "ARKodeSetFixedStep", 1); /* Initially evolve to dTout, and check result */ - retval = MRIStepEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { return 1; } + retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Initial MRIStepEvolve had insufficient accuracy\n"); + printf(" Initial ARKodeEvolve had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Initial MRIStepEvolve call successful\n"); } + else { printf(" Initial ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at dTout, evolve to 2*dTout and check result */ t = T0 + dTout; N_VConst(ytrue(t), y); - retval = MRIStepReset(mristep_mem, t, y); - check_retval(&retval, "MRIStepReset", 1); - retval = MRIStepEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { return 1; } + retval = ARKodeReset(mristep_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Second MRIStepEvolve call had insufficient accuracy\n"); + printf(" Second ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Second MRIStepEvolve call successful\n"); } + else { printf(" Second ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at 3*dTout, evolve to 4*dTout and check result */ t = T0 + SUN_RCONST(3.0) * dTout; N_VConst(ytrue(t), y); - retval = MRIStepReset(mristep_mem, t, y); - check_retval(&retval, "MRIStepReset", 1); - retval = MRIStepEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { return 1; } + retval = ARKodeReset(mristep_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Third MRIStepEvolve call had insufficient accuracy\n"); + printf(" Third ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Third MRIStepEvolve call successful\n"); } + else { printf(" Third ARKodeEvolve call successful\n"); } /* Reset state to analytical solution at dTout, evolve to 2*dTout and check result */ t = T0 + dTout; N_VConst(ytrue(t), y); - retval = MRIStepReset(mristep_mem, t, y); - check_retval(&retval, "MRIStepReset", 1); - retval = MRIStepEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); - if (check_retval(&retval, "MRIStepEvolve", 1)) { return 1; } + retval = ARKodeReset(mristep_mem, t, y); + check_retval(&retval, "ARKodeReset", 1); + retval = ARKodeEvolve(mristep_mem, t + dTout, y, &t, ARK_NORMAL); + if (check_retval(&retval, "ARKodeEvolve", 1)) { return 1; } if (check_ans(y, t, SUN_RCONST(0.001), SUN_RCONST(0.000001))) { - printf(" Fourth MRIStepEvolve call had insufficient accuracy\n"); + printf(" Fourth ARKodeEvolve call had insufficient accuracy\n"); printf(" t = %" GSYM "\n", t); printf(" y = %" GSYM "\n", NV_Ith_S(y, 0)); printf(" ytrue = %" GSYM "\n", ytrue(t)); printf(" |y-ytrue| = %" GSYM "\n", SUNRabs(ytrue(t) - NV_Ith_S(y, 0))); return 1; } - else { printf(" Fourth MRIStepEvolve call successful\n"); } + else { printf(" Fourth ARKodeEvolve call successful\n"); } /* Free MRIStep and ARKStep memory structures */ - MRIStepFree(&mristep_mem); + ARKodeFree(&mristep_mem); MRIStepInnerStepper_Free(&inner_stepper); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); arkode_mem = NULL; /* Clean up and return with success */ diff --git a/test/unit_tests/arkode/C_serial/ark_test_tstop.c b/test/unit_tests/arkode/C_serial/ark_test_tstop.c index 7e952e8a42..7498e251bb 100644 --- a/test/unit_tests/arkode/C_serial/ark_test_tstop.c +++ b/test/unit_tests/arkode/C_serial/ark_test_tstop.c @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) arkode_mem = ARKStepCreate(NULL, ode_rhs, ZERO, y, sunctx); if (!arkode_mem) { return 1; } - flag = ARKStepSStolerances(arkode_mem, SUN_RCONST(1.0e-4), SUN_RCONST(1.0e-8)); + flag = ARKodeSStolerances(arkode_mem, SUN_RCONST(1.0e-4), SUN_RCONST(1.0e-8)); if (flag) { return 1; } A = SUNDenseMatrix(1, 1, sunctx); @@ -101,16 +101,16 @@ int main(int argc, char* argv[]) LS = SUNLinSol_Dense(y, A, sunctx); if (!LS) { return 1; } - flag = ARKStepSetLinearSolver(arkode_mem, LS, A); + flag = ARKodeSetLinearSolver(arkode_mem, LS, A); if (flag) { return 1; } - flag = ARKStepSetJacFn(arkode_mem, ode_jac); + flag = ARKodeSetJacFn(arkode_mem, ode_jac); if (flag) { return 1; } - flag = ARKStepSetOrder(arkode_mem, 2); + flag = ARKodeSetOrder(arkode_mem, 2); if (flag) { return 1; } - flag = ARKStepSetStopTime(arkode_mem, tstop); + flag = ARKodeSetStopTime(arkode_mem, tstop); if (flag) { return 1; } /* --------------- @@ -123,14 +123,14 @@ int main(int argc, char* argv[]) for (i = 1; i <= 6; i++) { - arkode_flag = ARKStepEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); + arkode_flag = ARKodeEvolve(arkode_mem, tout, y, &tret, ARK_NORMAL); if (arkode_flag < 0) { flag = 1; break; } - flag = ARKStepGetCurrentTime(arkode_mem, &tcur); + flag = ARKodeGetCurrentTime(arkode_mem, &tcur); if (flag) { break; } printf("%i: tout = %" GSYM ", tstop = %" GSYM ", tret = %" GSYM @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) /* Update stop time */ tstop += dt_tstop; - flag = ARKStepSetStopTime(arkode_mem, tstop); + flag = ARKodeSetStopTime(arkode_mem, tstop); if (flag) { break; } } @@ -173,7 +173,7 @@ int main(int argc, char* argv[]) /* Update stop time */ tstop += dt_tstop; - flag = ARKStepSetStopTime(arkode_mem, tstop); + flag = ARKodeSetStopTime(arkode_mem, tstop); if (flag) { break; } } @@ -217,7 +217,7 @@ int main(int argc, char* argv[]) * Clean up * -------- */ - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); N_VDestroy(y); SUNMatDestroy(A); SUNLinSolFree(LS); diff --git a/test/unit_tests/arkode/gtest/test_arkode_error_handling.cpp b/test/unit_tests/arkode/gtest/test_arkode_error_handling.cpp index 44bfcc9c5c..96099d427f 100644 --- a/test/unit_tests/arkode/gtest/test_arkode_error_handling.cpp +++ b/test/unit_tests/arkode/gtest/test_arkode_error_handling.cpp @@ -45,7 +45,7 @@ class ARKodeErrConditionTest : public testing::Test ~ARKodeErrConditionTest() { N_VDestroy(v); - ARKStepFree(&arkode_mem); + ARKodeFree(&arkode_mem); } void* arkode_mem; @@ -70,7 +70,7 @@ TEST_F(ARKodeErrConditionTest, ErrorIsPrinted) { SUNLogger_SetErrorFilename(logger, errfile.c_str()); // negative reltol is illegal - ARKStepSStolerances(arkode_mem, /* reltol= */ -1e-4, /* abstol= */ 1e-4); + ARKodeSStolerances(arkode_mem, /* reltol= */ -1e-4, /* abstol= */ 1e-4); std::string output = dumpstderr(sunctx, errfile); EXPECT_THAT(output, testing::AllOf(testing::StartsWith("[ERROR]"), testing::HasSubstr("[rank 0]"),